@joshuafolkken/kit 1.1166.0 → 1.1178.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 (61) hide show
  1. package/.claude/skills/workflow-commands/backlogrun-lanes.md +3 -3
  2. package/.claude/skills/workflow-commands/backlogrun-park.md +6 -7
  3. package/.claude/skills/workflow-commands/backlogrun-steps.md +3 -2
  4. package/.claude/skills/workflow-commands/pre-gate-cut.md +4 -4
  5. package/.github/workflows/ci.yml +15 -2
  6. package/dist/hooks/batch-guard.js +4 -4
  7. package/dist/hooks/{chunk-5KTCMCOT.js → chunk-32GQTL4F.js} +1 -1
  8. package/dist/hooks/{chunk-URJA6XY4.js → chunk-DO6NWWHU.js} +4 -4
  9. package/dist/hooks/{chunk-GU5MATVE.js → chunk-G6KRCKEC.js} +11 -19
  10. package/dist/hooks/{chunk-ZDZ555YH.js → chunk-GDS5N2KB.js} +88 -291
  11. package/dist/hooks/{chunk-GYNGP7HI.js → chunk-I4XSL4TT.js} +1 -1
  12. package/dist/hooks/{chunk-DYAVAM6S.js → chunk-S6X6WYKR.js} +324 -49
  13. package/dist/hooks/{chunk-ANJ2WGFD.js → chunk-UAGLLIGZ.js} +1 -1
  14. package/dist/hooks/{chunk-ENA7P5FB.js → chunk-VESKRQOF.js} +3 -3
  15. package/dist/hooks/{chunk-V2BTOZHT.js → chunk-VQLLNFNT.js} +3 -3
  16. package/dist/hooks/{chunk-A6P7PN7P.js → chunk-ZAL3NRGL.js} +2 -2
  17. package/dist/hooks/codex-hook-adapter.js +10 -10
  18. package/dist/hooks/duplicate-read-guard.js +5 -5
  19. package/dist/hooks/format-edited.js +2 -2
  20. package/dist/hooks/inputs.json +192 -192
  21. package/dist/hooks/investigation-guard.js +5 -5
  22. package/dist/hooks/pretool-guard.js +9 -9
  23. package/dist/hooks/stop-guard.js +18 -4
  24. package/dist/josh.js +4 -1
  25. package/package.json +1 -1
  26. package/scripts/backlog/backlog-next.ts +15 -4
  27. package/scripts/backlog/backlog-plan-cli.ts +6 -5
  28. package/scripts/backlog/backlog-rank.ts +18 -9
  29. package/scripts/backlog/backlog-restructure.ts +152 -0
  30. package/scripts/backlog/backlog-waves.ts +15 -17
  31. package/scripts/cost-runtime/context-cut-threshold.ts +1 -9
  32. package/scripts/cost-runtime/cost-verdict.ts +15 -28
  33. package/scripts/followup/git-followup-stages.ts +9 -0
  34. package/scripts/followup/git-pr-followup.ts +1 -1
  35. package/scripts/gh/git-gh-issue.ts +5 -3
  36. package/scripts/gh/git-gh-pr-read.ts +4 -0
  37. package/scripts/gh/git-pr-checks-eval.ts +8 -0
  38. package/scripts/gh/git-pr-checks.ts +11 -1
  39. package/scripts/git/constants.ts +10 -0
  40. package/scripts/git/main-merge.ts +57 -21
  41. package/scripts/git/schemas.ts +2 -0
  42. package/scripts/josh/josh-commands-development.ts +1 -1
  43. package/scripts/lane/lane-launch-cli.ts +21 -3
  44. package/scripts/notify/telegram-notify.ts +26 -1
  45. package/scripts/rules/pre-gate-cut.ts +2 -2
  46. package/scripts/run/run-carry.ts +11 -5
  47. package/scripts/run/run-cut-cli.ts +1 -1
  48. package/scripts/run/run-cut-report.ts +2 -2
  49. package/scripts/run/run-ship-cli.ts +27 -6
  50. package/scripts/run/run-ship-next.ts +13 -0
  51. package/scripts/run/run-ship-pre-detach.ts +66 -0
  52. package/scripts/run/run-ship-return.ts +7 -4
  53. package/scripts/run/run-ship-stage.ts +13 -0
  54. package/scripts/run/run-ship-steps.ts +10 -2
  55. package/scripts/run/run-ship-sync.ts +114 -0
  56. package/scripts/run/run-ship.ts +6 -0
  57. package/scripts/run/run-wake-cli.ts +8 -1
  58. package/scripts/run/run-wake-driver.ts +42 -11
  59. package/scripts/test/test-red-logic.ts +17 -2
  60. package/scripts/test/test-red.ts +8 -7
  61. package/scripts/time-runtime/time-transcript-line.ts +27 -1
@@ -858,7 +858,7 @@ var DEV_COMMANDS = {
858
858
  },
859
859
  "test:red": {
860
860
  script: "scripts/test/test-red.ts",
861
- description: "Run the changed unit tests against the pre-fix tree (merge-base worktree) and report red/green/no-test",
861
+ description: "Run the changed unit tests against the pre-fix tree (merge-base worktree) and report red/green/no-test/test-only",
862
862
  category: "Development",
863
863
  reference: ["", "developer", ["git", "processes"]]
864
864
  },
@@ -1864,6 +1864,252 @@ var time_bundle_call = {
1864
1864
  READ_JOSH_SUBCOMMANDS
1865
1865
  };
1866
1866
 
1867
+ // scripts/git/schemas.ts
1868
+ import { z as z2 } from "zod";
1869
+ var package_name_schema = z2.object({ name: z2.string().min(1) });
1870
+ var rollup_item_schema = z2.looseObject({
1871
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- GraphQL field name from GitHub API
1872
+ __typename: z2.string().optional(),
1873
+ state: z2.string().optional(),
1874
+ status: z2.string().optional(),
1875
+ conclusion: z2.string().optional(),
1876
+ name: z2.string().optional(),
1877
+ context: z2.string().optional()
1878
+ });
1879
+ var pr_raw_schema = z2.object({
1880
+ statusCheckRollup: z2.array(rollup_item_schema).optional(),
1881
+ mergeStateStatus: z2.string().optional(),
1882
+ reviewDecision: z2.string().optional()
1883
+ });
1884
+ var pull_comment_schema = z2.object({
1885
+ body: z2.string().optional(),
1886
+ html_url: z2.string().optional(),
1887
+ user: z2.object({ login: z2.string().optional() }).optional()
1888
+ });
1889
+ var ai_review_pull_comment_schema = z2.object({
1890
+ body: z2.string().optional(),
1891
+ url: z2.string().optional(),
1892
+ author: z2.object({ login: z2.string().optional() }).optional()
1893
+ });
1894
+ var pr_info_schema = z2.object({
1895
+ mergeable: z2.union([z2.boolean(), z2.string()]).nullable().optional(),
1896
+ mergeStateStatus: z2.string().nullable().optional(),
1897
+ state: z2.string().optional()
1898
+ });
1899
+ var epic_issue_schema = z2.object({
1900
+ number: z2.number(),
1901
+ body: z2.string().optional()
1902
+ });
1903
+ var blocking_issue_schema = z2.object({
1904
+ number: z2.number(),
1905
+ state: z2.string().optional(),
1906
+ repository_url: z2.string().optional()
1907
+ });
1908
+ var blocked_by_schema = z2.object({
1909
+ nodes: z2.array(blocking_issue_schema).default([]),
1910
+ totalCount: z2.number().optional()
1911
+ }).optional();
1912
+ var epic_child_schema = z2.object({
1913
+ state: z2.string().optional(),
1914
+ blockedBy: blocked_by_schema
1915
+ });
1916
+ var rest_comment_schema = z2.looseObject({
1917
+ body: z2.string().nullish(),
1918
+ html_url: z2.string().optional(),
1919
+ user: z2.looseObject({ login: z2.string().optional() }).nullish()
1920
+ });
1921
+ var issue_label_schema = z2.object({ name: z2.string() });
1922
+ var epic_subject_schema = z2.object({
1923
+ number: z2.number(),
1924
+ state: z2.string().optional(),
1925
+ labels: z2.array(issue_label_schema).optional(),
1926
+ body: z2.string().optional()
1927
+ });
1928
+ var open_issue_schema = z2.object({
1929
+ number: z2.number(),
1930
+ title: z2.string(),
1931
+ labels: z2.array(issue_label_schema).optional(),
1932
+ createdAt: z2.string(),
1933
+ blockedBy: blocked_by_schema,
1934
+ // Present only on the pickup listing, which reads it for the restructures each issue declares.
1935
+ body: z2.string().optional()
1936
+ });
1937
+
1938
+ // scripts/gh/git-pr-checks-parse.ts
1939
+ var CHECK_STATUS_PASS = "pass";
1940
+ var CHECK_STATUS_PENDING = "pending";
1941
+ var CHECK_STATUS_FAIL = "fail";
1942
+ var CHECK_STATUS_MISSING = "missing";
1943
+ var PASSING_CONCLUSIONS = /* @__PURE__ */ new Set(["success", "skipped", "neutral"]);
1944
+ var KEY_TYPE_NAME = "__typename";
1945
+ var KEY_STATE = "state";
1946
+ var KEY_STATUS = "status";
1947
+ var KEY_CONCLUSION = "conclusion";
1948
+ var KEY_NAME = "name";
1949
+ var KEY_CONTEXT = "context";
1950
+ function read_string(value) {
1951
+ if (typeof value !== "string") return void 0;
1952
+ const trimmed = value.trim();
1953
+ if (trimmed.length === 0) return void 0;
1954
+ return trimmed;
1955
+ }
1956
+ var PENDING_STATUS_STATES = /* @__PURE__ */ new Set(["pending", "expected"]);
1957
+ function parse_status_context(item) {
1958
+ const state = read_string(item[KEY_STATE])?.toLowerCase();
1959
+ if (state === "success") return CHECK_STATUS_PASS;
1960
+ if (state !== void 0 && PENDING_STATUS_STATES.has(state)) return CHECK_STATUS_PENDING;
1961
+ return CHECK_STATUS_FAIL;
1962
+ }
1963
+ function is_passing_conclusion(item) {
1964
+ const conclusion = read_string(item[KEY_CONCLUSION])?.toLowerCase();
1965
+ return conclusion !== void 0 && PASSING_CONCLUSIONS.has(conclusion);
1966
+ }
1967
+ function parse_check_run(item) {
1968
+ const status = read_string(item[KEY_STATUS])?.toLowerCase();
1969
+ if (status !== "completed") return CHECK_STATUS_PENDING;
1970
+ return is_passing_conclusion(item) ? CHECK_STATUS_PASS : CHECK_STATUS_FAIL;
1971
+ }
1972
+ function parse_rollup_status(item) {
1973
+ const type_name = read_string(item[KEY_TYPE_NAME]);
1974
+ if (type_name === "StatusContext") return parse_status_context(item);
1975
+ return parse_check_run(item);
1976
+ }
1977
+ function read_rollup_array(parsed) {
1978
+ const result = pr_raw_schema.safeParse(parsed);
1979
+ if (!result.success) return [];
1980
+ return result.data.statusCheckRollup ?? [];
1981
+ }
1982
+ function parse_rollup_item(item) {
1983
+ const name = read_string(item[KEY_NAME]) ?? read_string(item[KEY_CONTEXT]);
1984
+ if (name === void 0) return void 0;
1985
+ return { name, status: parse_rollup_status(item) };
1986
+ }
1987
+ function parse_rollup_checks(raw_json) {
1988
+ const parsed = json_value.parse_or_undefined(raw_json);
1989
+ const rollup = read_rollup_array(parsed);
1990
+ const checks = [];
1991
+ for (const item of rollup) {
1992
+ const parsed_item = parse_rollup_item(item);
1993
+ if (parsed_item !== void 0) checks.push(parsed_item);
1994
+ }
1995
+ return checks;
1996
+ }
1997
+ function parse_pr_state_snapshot(raw_json) {
1998
+ const parsed = json_value.parse_or_undefined(raw_json);
1999
+ const result = pr_raw_schema.safeParse(parsed);
2000
+ const data = result.success ? result.data : void 0;
2001
+ return {
2002
+ rollup: parse_rollup_checks(raw_json),
2003
+ merge_state_status: read_string(data?.mergeStateStatus),
2004
+ review_decision: read_string(data?.reviewDecision)
2005
+ };
2006
+ }
2007
+
2008
+ // scripts/gh/git-pr-checks-eval.ts
2009
+ var DEFAULT_REQUIRED_CHECKS = ["SonarQube"];
2010
+ var CODERABBIT_CHECK_NAME = "CodeRabbit";
2011
+ var REQUIRED_CHECKS_ENV_VAR = "JOSH_REQUIRED_CHECKS";
2012
+ function parse_required_checks() {
2013
+ const raw = process.env[REQUIRED_CHECKS_ENV_VAR];
2014
+ if (!raw) return DEFAULT_REQUIRED_CHECKS;
2015
+ return raw.split(",").map((check) => check.trim()).filter((check) => check.length > 0);
2016
+ }
2017
+ var REQUIRED_CHECKS = parse_required_checks();
2018
+ var MERGE_STATE_CLEAN = "CLEAN";
2019
+ var MERGE_STATE_UNSTABLE = "UNSTABLE";
2020
+ var MERGE_STATE_DIRTY = "DIRTY";
2021
+ var REVIEW_CHANGES_REQUESTED = "CHANGES_REQUESTED";
2022
+ var CHECK_SUITE_SEPARATOR = " / ";
2023
+ var FAILURE_MESSAGE_PREFIX = "PR checks failed";
2024
+ var FAILURE_REASON_REVIEW = "review requested changes";
2025
+ var FAILURE_REASON_CHECKS = "failed checks";
2026
+ var FAILURE_REASON_CONFLICT = "merge conflict";
2027
+ function is_required_match(check_name, required_name) {
2028
+ if (check_name === required_name) return true;
2029
+ return check_name.startsWith(`${required_name}${CHECK_SUITE_SEPARATOR}`);
2030
+ }
2031
+ function find_required_check(checks, required_name) {
2032
+ return checks.find((check) => is_required_match(check.name, required_name));
2033
+ }
2034
+ function read_required_statuses(checks) {
2035
+ return REQUIRED_CHECKS.map(
2036
+ (name) => find_required_check(checks, name)?.status ?? CHECK_STATUS_MISSING
2037
+ );
2038
+ }
2039
+ function is_review_blocked(review_decision) {
2040
+ return review_decision === REVIEW_CHANGES_REQUESTED;
2041
+ }
2042
+ function is_merge_conflict(merge_state_status) {
2043
+ return merge_state_status === MERGE_STATE_DIRTY;
2044
+ }
2045
+ function evaluate_failure_state(input) {
2046
+ if (is_merge_conflict(input.merge_state_status) || is_review_blocked(input.review_decision) || input.failed_checks.length > 0) {
2047
+ return "failure";
2048
+ }
2049
+ return void 0;
2050
+ }
2051
+ function is_merge_state_clean(merge_state_status) {
2052
+ return merge_state_status === MERGE_STATE_CLEAN;
2053
+ }
2054
+ function is_every_required_passing(statuses) {
2055
+ return statuses.every((status) => status === CHECK_STATUS_PASS);
2056
+ }
2057
+ function is_coderabbit_check(check_name) {
2058
+ return is_required_match(check_name, CODERABBIT_CHECK_NAME);
2059
+ }
2060
+ function is_unstable_only_from_coderabbit(snapshot) {
2061
+ if (snapshot.merge_state_status !== MERGE_STATE_UNSTABLE) return false;
2062
+ const non_passing = snapshot.rollup.filter((check) => check.status !== CHECK_STATUS_PASS);
2063
+ if (non_passing.length === 0) return false;
2064
+ return non_passing.every((check) => is_coderabbit_check(check.name));
2065
+ }
2066
+ function is_required_check(check_name) {
2067
+ return REQUIRED_CHECKS.some((required) => is_required_match(check_name, required));
2068
+ }
2069
+ function is_blocking_failure(check) {
2070
+ if (check.status !== CHECK_STATUS_FAIL) return false;
2071
+ return !is_coderabbit_check(check.name) || is_required_check(check.name);
2072
+ }
2073
+ function collect_blocking_failures(snapshot) {
2074
+ return snapshot.rollup.filter((check) => is_blocking_failure(check)).map((check) => check.name);
2075
+ }
2076
+ function is_mergeable_state(snapshot) {
2077
+ if (is_merge_state_clean(snapshot.merge_state_status)) return true;
2078
+ return is_unstable_only_from_coderabbit(snapshot);
2079
+ }
2080
+ function collect_failure_reasons(snapshot) {
2081
+ const reasons = [];
2082
+ if (is_merge_conflict(snapshot.merge_state_status)) reasons.push(FAILURE_REASON_CONFLICT);
2083
+ if (is_review_blocked(snapshot.review_decision)) reasons.push(FAILURE_REASON_REVIEW);
2084
+ const failed = collect_blocking_failures(snapshot);
2085
+ if (failed.length > 0) reasons.push(`${FAILURE_REASON_CHECKS}: ${failed.join(", ")}`);
2086
+ return reasons;
2087
+ }
2088
+ function describe_pr_failure(snapshot) {
2089
+ const reasons = collect_failure_reasons(snapshot);
2090
+ if (reasons.length === 0) return `${FAILURE_MESSAGE_PREFIX}.`;
2091
+ return `${FAILURE_MESSAGE_PREFIX} (${reasons.join("; ")}).`;
2092
+ }
2093
+ function evaluate_pr_state(snapshot) {
2094
+ const statuses = read_required_statuses(snapshot.rollup);
2095
+ const failure = evaluate_failure_state({
2096
+ review_decision: snapshot.review_decision,
2097
+ failed_checks: collect_blocking_failures(snapshot),
2098
+ merge_state_status: snapshot.merge_state_status
2099
+ });
2100
+ if (failure !== void 0) return failure;
2101
+ if (is_mergeable_state(snapshot) && is_every_required_passing(statuses)) {
2102
+ return "success";
2103
+ }
2104
+ return "pending";
2105
+ }
2106
+ function is_review_decision_decisive(snapshot) {
2107
+ return evaluate_pr_state(snapshot) !== "pending";
2108
+ }
2109
+ var PrConflictError = class extends Error {
2110
+ name = "PrConflictError";
2111
+ };
2112
+
1867
2113
  // scripts/time-runtime/time-format.ts
1868
2114
  var MS_PER_MINUTE = 6e4;
1869
2115
  var MS_PER_SECOND = 1e3;
@@ -1935,8 +2181,14 @@ var STAGE = {
1935
2181
  // The lap that was still running when a stage threw. `followup` exits non-zero on an AI-review
1936
2182
  // blocker and on a red check, and those are the runs whose wait is longest — reporting nothing for
1937
2183
  // them would leave the measurement blind to exactly the invocations worth measuring.
1938
- interrupted: "interrupted"
2184
+ interrupted: "interrupted",
2185
+ // The interrupted lap when the wait failed on a merge conflict (joshuafolkken/kit#3221), so the
2186
+ // stage block names the cause a resumed session used to look up with `gh pr view`.
2187
+ conflict: "conflict"
1939
2188
  };
2189
+ function stopped_lap(error) {
2190
+ return error instanceof PrConflictError ? STAGE.conflict : STAGE.interrupted;
2191
+ }
1940
2192
  function new_log() {
1941
2193
  return { stages: [], last_ms: performance.now() };
1942
2194
  }
@@ -1969,7 +2221,8 @@ var git_followup_stages = {
1969
2221
  lap,
1970
2222
  total_ms,
1971
2223
  format_stages,
1972
- print_stages
2224
+ print_stages,
2225
+ stopped_lap
1973
2226
  };
1974
2227
 
1975
2228
  // scripts/time-runtime/time-followup-stage.ts
@@ -2204,9 +2457,9 @@ var josh_verdict = {
2204
2457
  };
2205
2458
 
2206
2459
  // scripts/time-runtime/time-reported-failure.ts
2207
- import { z as z2 } from "zod";
2208
- var TEXT_BLOCK_SCHEMA = z2.object({ text: z2.string().nullish() });
2209
- var CONTENT_SCHEMA = z2.union([z2.string(), z2.array(z2.unknown())]);
2460
+ import { z as z3 } from "zod";
2461
+ var TEXT_BLOCK_SCHEMA = z3.object({ text: z3.string().nullish() });
2462
+ var CONTENT_SCHEMA = z3.union([z3.string(), z3.array(z3.unknown())]);
2210
2463
  var LINE_SEPARATOR2 = "\n";
2211
2464
  function block_text(block) {
2212
2465
  const parsed = TEXT_BLOCK_SCHEMA.safeParse(block);
@@ -2301,7 +2554,7 @@ function check_key(josh_command, command) {
2301
2554
  var time_single_check = { NO_CHECK, check_key };
2302
2555
 
2303
2556
  // scripts/time-runtime/time-transcript-line.ts
2304
- import { z as z3 } from "zod";
2557
+ import { z as z4 } from "zod";
2305
2558
 
2306
2559
  // scripts/time-runtime/time-instant.ts
2307
2560
  function parse_instant(raw) {
@@ -2311,37 +2564,37 @@ function parse_instant(raw) {
2311
2564
  var time_instant = { parse_instant };
2312
2565
 
2313
2566
  // scripts/time-runtime/time-transcript-line.ts
2314
- var BLOCK_SCHEMA2 = z3.object({
2315
- type: z3.string().nullish(),
2316
- name: z3.string().nullish(),
2317
- id: z3.string().nullish(),
2318
- tool_use_id: z3.string().nullish(),
2319
- input: z3.unknown().nullish(),
2567
+ var BLOCK_SCHEMA2 = z4.object({
2568
+ type: z4.string().nullish(),
2569
+ name: z4.string().nullish(),
2570
+ id: z4.string().nullish(),
2571
+ tool_use_id: z4.string().nullish(),
2572
+ input: z4.unknown().nullish(),
2320
2573
  // Whether the harness wrote this result back as a failure (joshuafolkken/kit#1309). Present on a
2321
2574
  // `tool_result` block and on nothing else, and absent even there for the tools that never report
2322
2575
  // one — which is why it is read as three answers rather than as a boolean with a default.
2323
- is_error: z3.boolean().nullish(),
2576
+ is_error: z4.boolean().nullish(),
2324
2577
  // What the call printed. Read only to recover the outcome a pipeline threw away
2325
2578
  // (joshuafolkken/kit#1361): it is kept as flattened text rather than as blocks, because that is
2326
2579
  // the whole of what `time-reported-failure.ts` asks of it.
2327
- content: z3.unknown().nullish()
2580
+ content: z4.unknown().nullish()
2328
2581
  });
2329
- var CONTENT_SCHEMA2 = z3.union([z3.string(), z3.array(BLOCK_SCHEMA2)]);
2330
- var MESSAGE_SCHEMA2 = z3.object({ id: z3.string().nullish(), content: CONTENT_SCHEMA2.nullish() });
2331
- var LINE_SCHEMA = z3.object({
2332
- type: z3.string().nullish(),
2333
- timestamp: z3.string().nullish(),
2582
+ var CONTENT_SCHEMA2 = z4.union([z4.string(), z4.array(BLOCK_SCHEMA2)]);
2583
+ var MESSAGE_SCHEMA2 = z4.object({ id: z4.string().nullish(), content: CONTENT_SCHEMA2.nullish() });
2584
+ var LINE_SCHEMA = z4.object({
2585
+ type: z4.string().nullish(),
2586
+ timestamp: z4.string().nullish(),
2334
2587
  // The branch the line was written on, which is where the issue number lives — `josh git` names a
2335
2588
  // branch `<N>-<slug>`. Read here rather than re-parsed by a second reader so `josh time --issue`
2336
2589
  // and `josh cost --issue` answer from the same field (joshuafolkken/kit#1268).
2337
- gitBranch: z3.string().nullish(),
2590
+ gitBranch: z4.string().nullish(),
2338
2591
  // The two fields outside `message` that the harness writes an end-of-task notice on
2339
2592
  // (joshuafolkken/kit#1696). **Both are read as `unknown` rather than as strings**: a schema
2340
2593
  // insisting on a string here would reject every line whose `content` is a list of blocks — which is
2341
2594
  // most of them — and a rejected line is dropped from the timeline entirely, so the shares would stop
2342
2595
  // reconstructing the elapsed time. The shape is checked at the read below instead.
2343
- content: z3.unknown().nullish(),
2344
- attachment: z3.unknown().nullish(),
2596
+ content: z4.unknown().nullish(),
2597
+ attachment: z4.unknown().nullish(),
2345
2598
  message: MESSAGE_SCHEMA2.nullish()
2346
2599
  });
2347
2600
  var UNKNOWN_BRANCH = "";
@@ -2349,6 +2602,9 @@ var PROMPT_KEY2 = "prompt";
2349
2602
  var NO_MESSAGE_ID = "";
2350
2603
  var ERROR_TEXT_LIMIT = 256;
2351
2604
  var REFUSAL_MARKER = "\u26D4";
2605
+ var HOOK_ERROR_LABEL = /^PreToolUse:\S+ hook error: /u;
2606
+ var TOKEN_LINE = /^[a-z][a-z-]*$/u;
2607
+ var TOKEN_LINE_LIMIT = 8;
2352
2608
  function block_names(raw) {
2353
2609
  return {
2354
2610
  type: raw.type ?? "",
@@ -2358,12 +2614,15 @@ function block_names(raw) {
2358
2614
  };
2359
2615
  }
2360
2616
  function guard_from_refusal(text) {
2361
- const trimmed = text.trimStart();
2617
+ const trimmed = text.trimStart().replace(HOOK_ERROR_LABEL, "");
2362
2618
  if (!trimmed.startsWith(REFUSAL_MARKER)) return "";
2363
2619
  const headline = trimmed.slice(REFUSAL_MARKER.length).split("\n", 1)[0]?.trimStart() ?? "";
2364
2620
  const colon = headline.indexOf(":");
2365
2621
  return (colon === -1 ? headline : headline.slice(0, colon)).trim();
2366
2622
  }
2623
+ function token_lines_of(text) {
2624
+ return text.split("\n").map((line) => line.trim()).filter((line) => TOKEN_LINE.test(line)).slice(0, TOKEN_LINE_LIMIT);
2625
+ }
2367
2626
  function to_block2(raw) {
2368
2627
  const text = time_reported_failure.result_text(raw.content);
2369
2628
  const is_error = raw.is_error ?? void 0;
@@ -2375,6 +2634,7 @@ function to_block2(raw) {
2375
2634
  followup_stages: time_followup_stage.read_stages(text),
2376
2635
  error_text: is_error === true ? text.slice(0, ERROR_TEXT_LIMIT) : "",
2377
2636
  refusal_guard: is_error === true ? guard_from_refusal(text) : "",
2637
+ token_lines: is_error === true ? [] : token_lines_of(text),
2378
2638
  background_id: time_background.launch_id(text),
2379
2639
  agent_id: time_background.agent_launch_id(text)
2380
2640
  };
@@ -2408,6 +2668,7 @@ function parse_line2(line) {
2408
2668
  var time_transcript_line = {
2409
2669
  ERROR_TEXT_LIMIT,
2410
2670
  NO_MESSAGE_ID,
2671
+ TOKEN_LINE_LIMIT,
2411
2672
  guard_from_refusal,
2412
2673
  parse_line: parse_line2
2413
2674
  };
@@ -3246,30 +3507,30 @@ function read_if_readable(path6) {
3246
3507
  var file_reader = { read_optional, read_file_or_empty, read_if_readable };
3247
3508
 
3248
3509
  // scripts/cost-runtime/cost-usage.ts
3249
- import { z as z4 } from "zod";
3250
- var CACHE_CREATION_SCHEMA = z4.object({
3251
- ephemeral_1h_input_tokens: z4.number().nullish(),
3252
- ephemeral_5m_input_tokens: z4.number().nullish()
3510
+ import { z as z5 } from "zod";
3511
+ var CACHE_CREATION_SCHEMA = z5.object({
3512
+ ephemeral_1h_input_tokens: z5.number().nullish(),
3513
+ ephemeral_5m_input_tokens: z5.number().nullish()
3253
3514
  });
3254
- var USAGE_SCHEMA = z4.object({
3255
- input_tokens: z4.number(),
3256
- cache_creation_input_tokens: z4.number().nullish(),
3257
- cache_read_input_tokens: z4.number().nullish(),
3258
- output_tokens: z4.number(),
3259
- output_tokens_details: z4.object({ thinking_tokens: z4.number().nullish() }).nullish(),
3515
+ var USAGE_SCHEMA = z5.object({
3516
+ input_tokens: z5.number(),
3517
+ cache_creation_input_tokens: z5.number().nullish(),
3518
+ cache_read_input_tokens: z5.number().nullish(),
3519
+ output_tokens: z5.number(),
3520
+ output_tokens_details: z5.object({ thinking_tokens: z5.number().nullish() }).nullish(),
3260
3521
  cache_creation: CACHE_CREATION_SCHEMA.nullish()
3261
3522
  });
3262
- var MESSAGE_SCHEMA3 = z4.object({
3263
- id: z4.string().nullish(),
3264
- model: z4.string().nullish(),
3523
+ var MESSAGE_SCHEMA3 = z5.object({
3524
+ id: z5.string().nullish(),
3525
+ model: z5.string().nullish(),
3265
3526
  usage: USAGE_SCHEMA.nullish()
3266
3527
  });
3267
- var LINE_SCHEMA2 = z4.object({
3268
- type: z4.string(),
3269
- requestId: z4.string().nullish(),
3270
- uuid: z4.string().nullish(),
3271
- gitBranch: z4.string().nullish(),
3272
- timestamp: z4.string().nullish(),
3528
+ var LINE_SCHEMA2 = z5.object({
3529
+ type: z5.string(),
3530
+ requestId: z5.string().nullish(),
3531
+ uuid: z5.string().nullish(),
3532
+ gitBranch: z5.string().nullish(),
3533
+ timestamp: z5.string().nullish(),
3273
3534
  message: MESSAGE_SCHEMA3.nullish()
3274
3535
  });
3275
3536
  var SYNTHETIC_MODEL = "<synthetic>";
@@ -3742,7 +4003,7 @@ var stamp_file = {
3742
4003
  };
3743
4004
 
3744
4005
  // scripts/time-runtime/time-density-hook.ts
3745
- import { z as z5 } from "zod";
4006
+ import { z as z6 } from "zod";
3746
4007
 
3747
4008
  // scripts/time-runtime/time-density.ts
3748
4009
  var MIN_ROUND_TRIPS = 10;
@@ -3798,15 +4059,15 @@ var TAIL_BYTES = 262144;
3798
4059
  var FILE_START = 0;
3799
4060
  var NOTICE_PREFIX = "josh-density-notice-";
3800
4061
  var NEVER_MS = 0;
3801
- var payload_schema = z5.object({
3802
- transcript_path: z5.string().min(1).optional(),
4062
+ var payload_schema = z6.object({
4063
+ transcript_path: z6.string().min(1).optional(),
3803
4064
  // **`nullish`, not `optional`.** A payload spelling the absent agent as `null` has to read as "no
3804
4065
  // fork"; rejected, it would fail `safeParse` for the whole payload and silence the line for every
3805
4066
  // edit of the main line — the opposite of this module's stated failure direction.
3806
- agent_id: z5.string().nullish()
4067
+ agent_id: z6.string().nullish()
3807
4068
  });
3808
- var notice_schema = z5.object({ notified_at_ms: z5.number() });
3809
- var call_schema = z5.object({ tool_name: z5.string().min(1), tool_input: z5.unknown() });
4069
+ var notice_schema = z6.object({ notified_at_ms: z6.number() });
4070
+ var call_schema = z6.object({ tool_name: z6.string().min(1), tool_input: z6.unknown() });
3810
4071
  function parse_transcript_path(raw_payload) {
3811
4072
  const parsed = payload_schema.safeParse(JSON.parse(raw_payload));
3812
4073
  if (!parsed.success || parsed.data.transcript_path === void 0) return void 0;
@@ -3881,6 +4142,20 @@ export {
3881
4142
  ESLINT_EDIT_CACHE_FLAGS,
3882
4143
  time_shell,
3883
4144
  time_bundle_call,
4145
+ blocking_issue_schema,
4146
+ rest_comment_schema,
4147
+ open_issue_schema,
4148
+ CHECK_STATUS_PENDING,
4149
+ CHECK_STATUS_FAIL,
4150
+ read_string,
4151
+ parse_pr_state_snapshot,
4152
+ is_merge_conflict,
4153
+ is_coderabbit_check,
4154
+ is_required_check,
4155
+ describe_pr_failure,
4156
+ evaluate_pr_state,
4157
+ is_review_decision_decisive,
4158
+ PrConflictError,
3884
4159
  cost_attribute,
3885
4160
  time_reported_failure,
3886
4161
  time_transcript_line,
@@ -6,7 +6,7 @@ import {
6
6
  ESLINT_EDIT_CACHE_FLAGS,
7
7
  file_reader,
8
8
  time_density_hook
9
- } from "./chunk-DYAVAM6S.js";
9
+ } from "./chunk-S6X6WYKR.js";
10
10
 
11
11
  // scripts/hooks/format-edited-file.ts
12
12
  import { existsSync as existsSync2 } from "node:fs";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  investigation_reads
3
- } from "./chunk-A6P7PN7P.js";
3
+ } from "./chunk-ZAL3NRGL.js";
4
4
  import {
5
5
  lane_guard_policy
6
- } from "./chunk-GYNGP7HI.js";
6
+ } from "./chunk-I4XSL4TT.js";
7
7
  import {
8
8
  hook_decision
9
- } from "./chunk-5KTCMCOT.js";
9
+ } from "./chunk-32GQTL4F.js";
10
10
 
11
11
  // scripts/delegation/investigation-guard.ts
12
12
  import { text } from "node:stream/consumers";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  lane_guard_policy
3
- } from "./chunk-GYNGP7HI.js";
3
+ } from "./chunk-I4XSL4TT.js";
4
4
  import {
5
5
  hook_decision
6
- } from "./chunk-5KTCMCOT.js";
6
+ } from "./chunk-32GQTL4F.js";
7
7
  import {
8
8
  time_batch_guard
9
- } from "./chunk-DYAVAM6S.js";
9
+ } from "./chunk-S6X6WYKR.js";
10
10
 
11
11
  // scripts/hooks/batch-guard.ts
12
12
  import { text } from "node:stream/consumers";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  hook_decision
3
- } from "./chunk-5KTCMCOT.js";
3
+ } from "./chunk-32GQTL4F.js";
4
4
  import {
5
5
  cost_blocks,
6
6
  cost_transcript,
@@ -8,7 +8,7 @@ import {
8
8
  time_bundle_call,
9
9
  time_shell,
10
10
  time_spans
11
- } from "./chunk-DYAVAM6S.js";
11
+ } from "./chunk-S6X6WYKR.js";
12
12
 
13
13
  // scripts/delegation/investigation-reads.ts
14
14
  import path from "node:path";
@@ -1,27 +1,27 @@
1
1
  #!/usr/bin/env tsx
2
2
  import {
3
3
  pretool_guard
4
- } from "./chunk-GU5MATVE.js";
4
+ } from "./chunk-G6KRCKEC.js";
5
5
  import {
6
6
  bounded_pool
7
- } from "./chunk-ZDZ555YH.js";
7
+ } from "./chunk-GDS5N2KB.js";
8
8
  import {
9
9
  build_envelope,
10
10
  compose_context,
11
11
  format_edited_payload
12
- } from "./chunk-ANJ2WGFD.js";
12
+ } from "./chunk-UAGLLIGZ.js";
13
13
  import "./chunk-3V37IID6.js";
14
- import "./chunk-V2BTOZHT.js";
15
- import "./chunk-ENA7P5FB.js";
16
- import "./chunk-URJA6XY4.js";
17
- import "./chunk-A6P7PN7P.js";
18
- import "./chunk-GYNGP7HI.js";
14
+ import "./chunk-VQLLNFNT.js";
15
+ import "./chunk-VESKRQOF.js";
16
+ import "./chunk-DO6NWWHU.js";
17
+ import "./chunk-ZAL3NRGL.js";
18
+ import "./chunk-I4XSL4TT.js";
19
19
  import {
20
20
  hook_decision
21
- } from "./chunk-5KTCMCOT.js";
21
+ } from "./chunk-32GQTL4F.js";
22
22
  import {
23
23
  time_density_hook
24
- } from "./chunk-DYAVAM6S.js";
24
+ } from "./chunk-S6X6WYKR.js";
25
25
  import "./chunk-WPALEIRX.js";
26
26
  import "./chunk-RKUAD3I6.js";
27
27
 
@@ -9,11 +9,11 @@ import {
9
9
  is_enabled,
10
10
  notice_refusal_path,
11
11
  refusal_path
12
- } from "./chunk-URJA6XY4.js";
13
- import "./chunk-A6P7PN7P.js";
14
- import "./chunk-GYNGP7HI.js";
15
- import "./chunk-5KTCMCOT.js";
16
- import "./chunk-DYAVAM6S.js";
12
+ } from "./chunk-DO6NWWHU.js";
13
+ import "./chunk-ZAL3NRGL.js";
14
+ import "./chunk-I4XSL4TT.js";
15
+ import "./chunk-32GQTL4F.js";
16
+ import "./chunk-S6X6WYKR.js";
17
17
  import "./chunk-WPALEIRX.js";
18
18
  import "./chunk-RKUAD3I6.js";
19
19
  export {
@@ -2,9 +2,9 @@
2
2
  import {
3
3
  report_no_payload,
4
4
  run_hook
5
- } from "./chunk-ANJ2WGFD.js";
5
+ } from "./chunk-UAGLLIGZ.js";
6
6
  import "./chunk-3V37IID6.js";
7
- import "./chunk-DYAVAM6S.js";
7
+ import "./chunk-S6X6WYKR.js";
8
8
  import "./chunk-RKUAD3I6.js";
9
9
 
10
10
  // scripts/hooks/format-edited-cli.ts