@joshuafolkken/kit 1.1010.0 → 1.1050.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 (350) hide show
  1. package/.claude/settings.json +1 -5
  2. package/.claude/skills/dependency-update/SKILL.md +6 -3
  3. package/.claude/skills/epic-commands/SKILL.md +46 -17
  4. package/.claude/skills/verify-ui/SKILL.md +1 -1
  5. package/.claude/skills/workflow-commands/SKILL.md +10 -25
  6. package/.claude/skills/workflow-commands/background-commands.md +1 -1
  7. package/.claude/skills/workflow-commands/backlogrun-child.md +6 -4
  8. package/.claude/skills/workflow-commands/backlogrun-lanes.md +1 -1
  9. package/.claude/skills/workflow-commands/backlogrun-park.md +6 -0
  10. package/.claude/skills/workflow-commands/backlogrun-progress.md +30 -36
  11. package/.claude/skills/workflow-commands/backlogrun-steps.md +16 -16
  12. package/.claude/skills/workflow-commands/backlogrun.md +3 -12
  13. package/.claude/skills/workflow-commands/chain-rule.md +2 -2
  14. package/.claude/skills/workflow-commands/followup-reference.md +2 -2
  15. package/.claude/skills/workflow-commands/fullrun-steps.md +4 -3
  16. package/.claude/skills/workflow-commands/fullrun.md +1 -1
  17. package/.claude/skills/workflow-commands/halfrun.md +2 -1
  18. package/.claude/skills/workflow-commands/into-target.md +1 -1
  19. package/.claude/skills/workflow-commands/issue-comments.md +1 -1
  20. package/.claude/skills/workflow-commands/observation-filing.md +80 -126
  21. package/.claude/skills/workflow-commands/pre-gate-cut.md +33 -36
  22. package/.claude/skills/workflow-commands/prerequisite.md +1 -1
  23. package/.claude/skills/workflow-commands/working-tree-hold.md +2 -2
  24. package/.codex/hooks.json +1 -5
  25. package/.github/workflows/auto-tag.yml +21 -0
  26. package/.github/workflows/publish.yml +9 -10
  27. package/.github/workflows/sonar-qube.yml +1 -1
  28. package/AGENTS.md +4 -25
  29. package/CLAUDE.md +24 -38
  30. package/GEMINI.md +4 -24
  31. package/README.md +22 -56
  32. package/dist/CLAUDE.md +24 -38
  33. package/dist/hooks/batch-guard.js +4 -4
  34. package/dist/hooks/{chunk-6PSTVOLH.js → chunk-5BK3K7V4.js} +114 -90
  35. package/dist/hooks/{chunk-PAXMLGSS.js → chunk-7VPDUBRN.js} +93 -175
  36. package/dist/hooks/{chunk-KPZN42RT.js → chunk-DMQN45FN.js} +3 -3
  37. package/dist/hooks/{chunk-WMIR5SNX.js → chunk-EJDX2TOB.js} +13 -3
  38. package/dist/hooks/{chunk-A2H5I2VD.js → chunk-GQ7KP45M.js} +2 -2
  39. package/dist/hooks/{chunk-4GDR2YTV.js → chunk-HJIISEAC.js} +4 -4
  40. package/dist/hooks/{chunk-AWTFKKFW.js → chunk-NAS4C7GP.js} +6 -33
  41. package/dist/hooks/{chunk-56LGMJJV.js → chunk-NJQOBE6L.js} +2 -2
  42. package/dist/hooks/{chunk-EZLHXKJ6.js → chunk-RLDX5SOC.js} +1222 -941
  43. package/dist/hooks/{chunk-GBJUERYK.js → chunk-WQ4OSBSS.js} +10 -3
  44. package/dist/hooks/codex-hook-adapter.js +10 -10
  45. package/dist/hooks/duplicate-read-guard.js +5 -5
  46. package/dist/hooks/format-edited.js +15 -34
  47. package/dist/hooks/investigation-guard.js +5 -5
  48. package/dist/hooks/pretool-guard.js +23 -16
  49. package/dist/hooks/stop-guard.js +21 -200
  50. package/dist/josh.js +42 -125
  51. package/dist/version/index.js +466 -42
  52. package/eslint/base.js +2 -11
  53. package/package.json +36 -10
  54. package/prompts/coding-standards.md +15 -290
  55. package/prompts/collaboration-workflow/cross-repo-epic.md +2 -51
  56. package/prompts/collaboration-workflow/epic-audit.md +2 -53
  57. package/prompts/collaboration-workflow/epic-bundle.md +2 -106
  58. package/prompts/collaboration-workflow/file-edits.md +6 -53
  59. package/prompts/collaboration-workflow/issue-template.md +4 -4
  60. package/prompts/collaboration-workflow/operating-rules.md +18 -75
  61. package/prompts/collaboration-workflow/principles.md +74 -0
  62. package/prompts/collaboration-workflow/residency.md +55 -15
  63. package/prompts/collaboration-workflow/rule-delivery.md +5 -46
  64. package/prompts/collaboration-workflow/shell-body.md +7 -9
  65. package/prompts/collaboration-workflow/turn-batching.md +21 -37
  66. package/prompts/collaboration-workflow/upstream-interrupt.md +1 -1
  67. package/prompts/collaboration-workflow/wip-cap.md +15 -18
  68. package/prompts/collaboration-workflow.md +22 -28
  69. package/prompts/sonar-hotspot-handling.md +1 -1
  70. package/scripts/adopt/adopt-logic.ts +2 -2
  71. package/scripts/adopt/adopt-toolkits.ts +3 -1
  72. package/scripts/adopt/adopt.ts +2 -2
  73. package/scripts/agent/agent-event.ts +2 -9
  74. package/scripts/agent/agent-exit-record.ts +2 -9
  75. package/scripts/auto-ok/auto-ok-cli.ts +9 -9
  76. package/scripts/backlog/backlog-budget-cli.ts +2 -6
  77. package/scripts/backlog/backlog-drive-cli.ts +20 -10
  78. package/scripts/backlog/backlog-drive.ts +50 -16
  79. package/scripts/backlog/backlog-next.ts +24 -8
  80. package/scripts/backlog/backlog-offer-cli.ts +6 -5
  81. package/scripts/backlog/backlog-plan-cli.ts +5 -1
  82. package/scripts/backlog/backlog-plan.ts +1 -1
  83. package/scripts/backlog/backlog-pool.ts +31 -11
  84. package/scripts/backlog/backlog-rank.ts +106 -0
  85. package/scripts/backlog/backlog-waves.ts +42 -29
  86. package/scripts/build/build-bin.ts +2 -1
  87. package/scripts/build/build-config-merge.ts +2 -1
  88. package/scripts/build/build-hooks.ts +31 -6
  89. package/scripts/build/build-managed-marker.ts +2 -1
  90. package/scripts/build/build-self-sync-guard.ts +2 -1
  91. package/scripts/build/build-version.ts +2 -1
  92. package/scripts/cases/cases-logic.ts +2 -6
  93. package/scripts/ci/pr-classification.ts +13 -11
  94. package/scripts/cost-runtime/cost-transcript.ts +4 -11
  95. package/scripts/delegation/delegation-policy.ts +11 -0
  96. package/scripts/doctor/doctor-consumer.ts +5 -12
  97. package/scripts/doctor/doctor-ports.ts +2 -2
  98. package/scripts/document/document-byte-budget.ts +13 -21
  99. package/scripts/document/document-section.ts +2 -6
  100. package/scripts/document/entry-read-budget.ts +6 -5
  101. package/scripts/{git/git-epic-add-body.ts → epic/epic-add-body.ts} +23 -23
  102. package/scripts/{git/git-epic-add-plan.ts → epic/epic-add-plan.ts} +23 -26
  103. package/scripts/{git/git-epic-add.ts → epic/epic-add.ts} +17 -17
  104. package/scripts/epic/epic-audit-cli.ts +4 -4
  105. package/scripts/epic/epic-audit-orphans.ts +2 -2
  106. package/scripts/epic/epic-audit-rationale.ts +1 -1
  107. package/scripts/epic/epic-audit.ts +1 -1
  108. package/scripts/{git/git-epic-body.ts → epic/epic-body.ts} +6 -6
  109. package/scripts/epic/epic-bundle-cli.ts +1 -1
  110. package/scripts/epic/epic-bundle.ts +2 -2
  111. package/scripts/epic/epic-candidate-confirm.ts +2 -1
  112. package/scripts/{git/git-epic-chains.ts → epic/epic-chains.ts} +4 -4
  113. package/{scripts-ai → scripts/epic}/epic-check.ts +5 -4
  114. package/{scripts-ai → scripts/epic}/epic-cli.ts +4 -4
  115. package/scripts/{git/git-epic-close-comment.ts → epic/epic-close-comment.ts} +9 -9
  116. package/scripts/{git/git-epic-close.ts → epic/epic-close.ts} +23 -19
  117. package/scripts/epic/epic-cross-repo.ts +21 -38
  118. package/scripts/{git/git-epic-decision.ts → epic/epic-decision.ts} +12 -14
  119. package/scripts/epic/epic-fetch.ts +3 -3
  120. package/scripts/epic/epic-graph.ts +3 -3
  121. package/scripts/epic/epic-index.ts +2 -2
  122. package/scripts/epic/epic-issue.ts +1 -1
  123. package/scripts/epic/epic-lane-offer.ts +11 -22
  124. package/scripts/epic/epic-next.ts +3 -3
  125. package/scripts/{git/git-epic-parse.ts → epic/epic-parse.ts} +3 -3
  126. package/scripts/{git/git-epic-promote.ts → epic/epic-promote.ts} +10 -10
  127. package/scripts/epic/epic-rank.ts +37 -0
  128. package/scripts/{git/git-epic-read.ts → epic/epic-read.ts} +9 -9
  129. package/scripts/{git/git-epic-reconcile.ts → epic/epic-reconcile.ts} +18 -20
  130. package/scripts/{git/git-epic-reference.ts → epic/epic-reference.ts} +4 -23
  131. package/scripts/epic/epic-relation-recheck.ts +4 -3
  132. package/scripts/{git/git-epic-relations.ts → epic/epic-relations.ts} +5 -5
  133. package/scripts/{git/git-epic-remove-plan.ts → epic/epic-remove-plan.ts} +17 -19
  134. package/scripts/{git/git-epic-remove.ts → epic/epic-remove.ts} +13 -13
  135. package/scripts/{git/git-epic-run.ts → epic/epic-run.ts} +27 -27
  136. package/scripts/{git/git-epic-sections.ts → epic/epic-sections.ts} +6 -6
  137. package/scripts/{git/git-epic-shape.ts → epic/epic-shape.ts} +7 -7
  138. package/scripts/epic/epic-solo.ts +29 -28
  139. package/scripts/{git/git-epic-validate.ts → epic/epic-validate.ts} +13 -13
  140. package/{scripts-ai → scripts/epic}/epic.ts +17 -16
  141. package/scripts/gh/fix-gh-packages.ts +2 -1
  142. package/scripts/gh/gh-spawn.ts +12 -10
  143. package/scripts/git/constants.ts +1 -1
  144. package/scripts/git/git-branch.ts +10 -1
  145. package/scripts/git/git-command.ts +2 -2
  146. package/scripts/git/git-error.ts +2 -5
  147. package/scripts/git/git-execa-error.ts +6 -1
  148. package/{scripts-ai → scripts/git}/git-followup-finish.ts +7 -7
  149. package/scripts/git/git-followup-flush.ts +74 -48
  150. package/scripts/git/git-followup-issue-close.ts +2 -2
  151. package/scripts/git/git-followup-label.ts +1 -1
  152. package/scripts/git/git-followup-pending.ts +1 -1
  153. package/{scripts-ai → scripts/git}/git-followup-workflow.ts +23 -11
  154. package/scripts/git/git-gh-exec.ts +85 -26
  155. package/scripts/git/git-gh-issue-read.ts +2 -2
  156. package/scripts/git/git-gh-issue-rest.ts +2 -2
  157. package/scripts/git/git-gh-issue-write.ts +6 -6
  158. package/scripts/git/git-gh-pr-read.ts +0 -21
  159. package/scripts/git/git-gh-pr.ts +2 -23
  160. package/scripts/git/git-next-issues.ts +34 -5
  161. package/scripts/git/git-pr-followup-wrapup.ts +2 -6
  162. package/scripts/git/git-preflight.ts +25 -10
  163. package/scripts/git/git-push-transport.ts +12 -69
  164. package/scripts/git/git-spawn.ts +79 -3
  165. package/scripts/git/git-ssh-keepalive.ts +74 -0
  166. package/scripts/git/git-staging.ts +21 -9
  167. package/{scripts-ai → scripts/git}/git-workflow.ts +11 -11
  168. package/scripts/git/github-issue-url.ts +1 -1
  169. package/scripts/git/gone-branch.ts +3 -2
  170. package/scripts/git/issue-labels.ts +13 -1
  171. package/scripts/git/issue-rank.ts +89 -0
  172. package/scripts/git/issue-reference.ts +19 -0
  173. package/scripts/git/main-merge.ts +2 -1
  174. package/scripts/git/main-sync.ts +3 -2
  175. package/scripts/git/schemas.ts +1 -1
  176. package/scripts/git/stash-pop-args.ts +7 -13
  177. package/scripts/git/stash-pop-cli.ts +2 -1
  178. package/{scripts-ai → scripts/git}/telegram-test-logic.ts +2 -2
  179. package/{scripts-ai → scripts/git}/telegram-test.ts +7 -7
  180. package/scripts/hooks/format-edited-cli.ts +15 -0
  181. package/scripts/hooks/format-edited-file.ts +2 -9
  182. package/scripts/hooks/format-rewrite-notice.ts +2 -8
  183. package/scripts/hooks/pretool-guard-cli.ts +21 -0
  184. package/scripts/hooks/pretool-guard.ts +14 -15
  185. package/scripts/init/init-ai-copy.ts +2 -5
  186. package/scripts/init/init.ts +8 -4
  187. package/scripts/init/start-exec.ts +7 -1
  188. package/scripts/init/start-plan.ts +18 -5
  189. package/scripts/init/start-setup-pr.ts +46 -19
  190. package/scripts/init/start-steps.ts +43 -10
  191. package/scripts/init/start.ts +42 -11
  192. package/scripts/issue/issue-cite.ts +19 -1
  193. package/scripts/issue/issue-comment-cli.ts +2 -1
  194. package/scripts/issue/issue-file-cli.ts +2 -1
  195. package/scripts/issue/issue-fold-cli.ts +9 -16
  196. package/scripts/issue/issue-scout-cli.ts +8 -13
  197. package/scripts/issue/measure-rerun-cli.ts +7 -6
  198. package/scripts/josh/josh-command-map.ts +0 -102
  199. package/scripts/josh/josh-commands-ai.ts +2 -2
  200. package/scripts/josh/josh-commands-backlog.ts +1 -1
  201. package/scripts/josh/josh-commands-development.ts +3 -3
  202. package/scripts/josh/josh-commands-project.ts +1 -1
  203. package/scripts/josh/josh-commands-workflow.ts +4 -4
  204. package/scripts/lane/lane-child-marker.ts +16 -2
  205. package/scripts/lane/lane-cli.ts +34 -15
  206. package/scripts/lane/lane-open.ts +3 -2
  207. package/scripts/lane/lane-registry.ts +3 -6
  208. package/scripts/lane/lane-report.ts +10 -4
  209. package/scripts/lib/cli-flags.ts +20 -2
  210. package/scripts/lib/error-message.ts +9 -0
  211. package/scripts/lib/read-file.ts +26 -2
  212. package/scripts/observations/observation-ledger-home.ts +98 -26
  213. package/scripts/observations/observation-ledger-migrate.ts +26 -21
  214. package/scripts/observations/observation-ledger-prepare.ts +10 -20
  215. package/scripts/observations/observation-ledger.ts +58 -25
  216. package/scripts/observations/observations-flush-cli.ts +6 -23
  217. package/scripts/observations/observations-flush-landing.ts +2 -1
  218. package/scripts/observations/observations-flush.ts +29 -20
  219. package/scripts/package/package-scout-cli.ts +8 -16
  220. package/scripts/ports/port-command.ts +2 -1
  221. package/scripts/propagate/propagate-plan.ts +185 -0
  222. package/scripts/propagate/propagate-publish.ts +6 -7
  223. package/scripts/propagate/propagate-run.ts +5 -1
  224. package/scripts/propagate/propagate-steps.ts +18 -2
  225. package/scripts/propagate/propagate-targets.ts +13 -2
  226. package/scripts/propagate/propagate.ts +63 -44
  227. package/scripts/refactor/import-graph.ts +2 -6
  228. package/scripts/registry-migration/migrate-logic.ts +1 -0
  229. package/scripts/registry-migration/migrate.ts +3 -2
  230. package/scripts/registry-migration/user-npmrc.ts +2 -2
  231. package/scripts/release/github-release.ts +1 -1
  232. package/scripts/release/release-cli.ts +2 -1
  233. package/scripts/repo/repo-setting.ts +10 -8
  234. package/scripts/review/review-attest.ts +44 -0
  235. package/scripts/review/review-brief-cli.ts +49 -2
  236. package/scripts/review/review-brief.ts +46 -1
  237. package/scripts/review/review-finding-ledger.ts +3 -3
  238. package/scripts/review/review-findings-cli.ts +4 -11
  239. package/scripts/review/review-record-cli.ts +14 -11
  240. package/scripts/review/review-record.ts +6 -16
  241. package/scripts/review/review-stamps.ts +7 -0
  242. package/scripts/rules/decision-oracle.ts +2 -2
  243. package/scripts/rules/implementation-cut.ts +1 -1
  244. package/scripts/rules/issue-fold.ts +1 -2
  245. package/scripts/rules/lane-carry-conflict.ts +1 -2
  246. package/scripts/rules/lane-park.ts +1 -2
  247. package/scripts/rules/pre-gate-cut.ts +2 -2
  248. package/scripts/rules/rule-body-guard.ts +2 -2
  249. package/scripts/rules/rule-value-cache.ts +99 -0
  250. package/scripts/rules/rule-value-cli.ts +10 -9
  251. package/scripts/rules/rule-value.ts +1 -1
  252. package/scripts/run/run-carry-args.ts +2 -6
  253. package/scripts/run/run-carry-cli.ts +5 -7
  254. package/scripts/run/run-cut-args.ts +7 -13
  255. package/scripts/run/run-ending-cli.ts +4 -7
  256. package/scripts/run/run-event-stream.ts +2 -5
  257. package/scripts/run/run-headless.ts +22 -6
  258. package/scripts/run/run-liveness-cli.ts +4 -7
  259. package/scripts/run/run-parent-cut-hook.ts +144 -0
  260. package/scripts/run/run-progress-args.ts +2 -6
  261. package/scripts/run/run-progress-cli.ts +2 -1
  262. package/scripts/run/run-progress-read.ts +2 -1
  263. package/scripts/run/run-progress.ts +21 -8
  264. package/scripts/run/run-ship-cli.ts +6 -74
  265. package/scripts/run/run-ship-preflight.ts +87 -0
  266. package/scripts/run/run-ship-review-steps.ts +5 -26
  267. package/scripts/run/run-ship-review.ts +9 -0
  268. package/scripts/run/run-ship-scoped.ts +44 -0
  269. package/scripts/run/run-ship-stage.ts +5 -1
  270. package/scripts/run/run-ship-steps.ts +105 -0
  271. package/scripts/run/run-ship.ts +2 -0
  272. package/scripts/run/run-tail-cli.ts +3 -3
  273. package/scripts/run/run-tidy-stashes.ts +7 -14
  274. package/scripts/run/run-wake-cli.ts +4 -8
  275. package/scripts/run/run-wake-describe.ts +19 -1
  276. package/scripts/run/run-wake-driver.ts +15 -2
  277. package/scripts/run/run-wake-session.ts +14 -4
  278. package/scripts/run/run-watcher-hook.ts +1 -1
  279. package/scripts/safe-chain/project-config.ts +3 -6
  280. package/scripts/security/security-audit-provision.ts +6 -7
  281. package/scripts/sonar/sonar-hotspots-cli.ts +2 -1
  282. package/scripts/sync/directory-copy-guard.ts +2 -1
  283. package/scripts/sync/sync-ai-files.ts +3 -3
  284. package/scripts/sync/template-source-logic.ts +3 -4
  285. package/scripts/test/e2e-retry-check.ts +3 -6
  286. package/scripts/time-runtime/time-bundle-call.ts +2 -2
  287. package/scripts/ui/ui-routes-cli.ts +3 -6
  288. package/scripts/version/bump-version.ts +2 -1
  289. package/scripts/version/npm-registry.ts +97 -0
  290. package/scripts/version/version-commands.ts +5 -4
  291. package/scripts/version/version-remote.ts +38 -33
  292. package/scripts/version/version-targets.ts +3 -3
  293. package/.claude/skills/workflow-commands/rule-residency.md +0 -267
  294. package/evals/scenarios/consult-not-execute.json +0 -20
  295. package/evals/scenarios/no-implicit-workflow.json +0 -26
  296. package/evals/scenarios/overrides-both-locations.json +0 -29
  297. package/evals/scenarios/upstream-interrupt.json +0 -23
  298. package/evals/scenarios/workflow-skill-loaded.json +0 -16
  299. package/prompts/agent-lint-protocol.json +0 -79
  300. package/prompts/agent-rules.md +0 -63
  301. package/prompts/collaboration-workflow/consultation-vs-execution.md +0 -8
  302. package/prompts/collaboration-workflow/distributed-docs.md +0 -7
  303. package/prompts/collaboration-workflow/durable-rules.md +0 -24
  304. package/prompts/collaboration-workflow/latest-first.md +0 -14
  305. package/prompts/collaboration-workflow/no-clones.md +0 -11
  306. package/prompts/collaboration-workflow/simplicity-first.md +0 -9
  307. package/prompts/collaboration-workflow/single-source-rules.md +0 -13
  308. package/scripts/build/shim-shell.ts +0 -25
  309. package/scripts/claude/skill-meta.ts +0 -37
  310. package/scripts/document/document-scan.ts +0 -108
  311. package/scripts/document/generate-catalog.ts +0 -69
  312. package/scripts/document/retired-phrases.ts +0 -143
  313. package/scripts/document/review-agent-type.ts +0 -46
  314. package/scripts/document/single-source.ts +0 -73
  315. package/scripts/git/git-fixture-workspace.ts +0 -88
  316. package/scripts/hooks/format-edited-file-fixtures.ts +0 -109
  317. package/scripts/hooks/prompt-hooks.ts +0 -38
  318. package/scripts/init/hook-command-bootstrap.ts +0 -83
  319. package/scripts/issue/issue-logic.ts +0 -50
  320. package/scripts/josh/__snapshots__/josh-command-map.test.ts.snap +0 -1227
  321. package/scripts/josh/josh-script-reader.ts +0 -11
  322. package/scripts/package/production-dependency-graph.ts +0 -68
  323. package/scripts/retrospective/retrospective-cli.ts +0 -97
  324. package/scripts/retrospective/retrospective.ts +0 -127
  325. package/scripts/rules/delivered-rules-harness.ts +0 -72
  326. package/scripts/rules/top-level-scripts-guard.ts +0 -47
  327. package/scripts/run/run-carry-flush.ts +0 -58
  328. package/scripts/run/run-transcript.golden.txt +0 -57
  329. package/scripts/run/run-wake-work.ts +0 -108
  330. package/scripts/sync/dependabot-pin-logic.ts +0 -135
  331. package/scripts/test/classify-isolation.ts +0 -149
  332. package/scripts/test/http-fault-injection.ts +0 -79
  333. package/scripts/test/josh-harness-environment.ts +0 -260
  334. package/scripts/test/josh-harness.ts +0 -96
  335. package/scripts/test/pilot-files.ts +0 -452
  336. package/scripts/test/pilot-measure.ts +0 -78
  337. package/scripts/test/test-network-guard.ts +0 -453
  338. package/scripts/test/test-repository-guard.ts +0 -317
  339. package/scripts/test/test-state-guard.ts +0 -85
  340. package/scripts/test/test-stdout-guard.ts +0 -54
  341. package/scripts/test/test-telegram-guard.ts +0 -90
  342. package/scripts/test/unit-guard-environment.ts +0 -12
  343. package/scripts/test/unit-projects.ts +0 -139
  344. package/scripts/test/vitest-include-globs.ts +0 -12
  345. package/scripts/time-runtime/time-batch-guard-fixtures.ts +0 -66
  346. package/scripts-ai/completion-gate.ts +0 -13
  347. package/scripts-ai/environment-loader.ts +0 -9
  348. /package/{scripts-ai → scripts/epic}/epic-cli-argv.ts +0 -0
  349. /package/{scripts-ai → scripts/epic}/epic-cli-remove.ts +0 -0
  350. /package/{scripts-ai → scripts/git}/followup-issue-number.ts +0 -0
@@ -13,6 +13,7 @@ import {
13
13
  agent_role_profile,
14
14
  agent_session_environment,
15
15
  bash_triggers,
16
+ error_text,
16
17
  filing_cap,
17
18
  gh_failure,
18
19
  git_command,
@@ -20,6 +21,7 @@ import {
20
21
  git_gh_exec,
21
22
  has_any_label,
22
23
  has_stderr_field,
24
+ issue_cite,
23
25
  lane_background,
24
26
  lane_park,
25
27
  lane_registry,
@@ -30,52 +32,50 @@ import {
30
32
  repo_party,
31
33
  run_carry,
32
34
  run_cut,
35
+ run_headless,
33
36
  run_hold,
34
37
  run_progress_clock,
35
38
  run_tail,
36
39
  run_watcher_guard,
37
40
  shell_segments,
38
41
  tail_commands
39
- } from "./chunk-EZLHXKJ6.js";
42
+ } from "./chunk-RLDX5SOC.js";
40
43
  import {
41
44
  find_local_bin_upwards
42
45
  } from "./chunk-3V37IID6.js";
43
46
  import {
44
47
  batch_outcome
45
- } from "./chunk-A2H5I2VD.js";
48
+ } from "./chunk-GQ7KP45M.js";
46
49
  import {
47
50
  investigation_refusal
48
- } from "./chunk-KPZN42RT.js";
51
+ } from "./chunk-DMQN45FN.js";
49
52
  import {
50
53
  duplicate_read_outcome
51
- } from "./chunk-4GDR2YTV.js";
54
+ } from "./chunk-HJIISEAC.js";
52
55
  import {
53
56
  investigation_reads
54
- } from "./chunk-WMIR5SNX.js";
57
+ } from "./chunk-EJDX2TOB.js";
55
58
  import {
56
59
  lane_guard_policy,
57
60
  time_batch_guard
58
- } from "./chunk-56LGMJJV.js";
61
+ } from "./chunk-NJQOBE6L.js";
59
62
  import {
60
63
  hook_decision,
61
64
  lane_child_marker,
62
65
  run_issue_number
63
- } from "./chunk-GBJUERYK.js";
66
+ } from "./chunk-WQ4OSBSS.js";
64
67
  import {
65
68
  PLATFORM_TEMP_ROOT,
66
69
  cost_attribute,
67
70
  cost_blocks,
68
71
  cost_transcript,
69
72
  cost_usage,
73
+ file_reader,
70
74
  json_value,
71
75
  lane_paths,
72
76
  stamp_file,
73
77
  time_shell
74
- } from "./chunk-PAXMLGSS.js";
75
-
76
- // scripts/hooks/pretool-guard.ts
77
- import { text } from "node:stream/consumers";
78
- import { fileURLToPath as fileURLToPath3 } from "node:url";
78
+ } from "./chunk-7VPDUBRN.js";
79
79
 
80
80
  // scripts/rules/direct-filing.ts
81
81
  var DIRECT_FILING_REASON = '\u26D4 direct filing: an Issue is filed with `pnpm josh issue:file "<title>" --body-file <path> --depth <0|1|2> [--route <route>] [--label <name>] [--repo <owner/repo>]`, never with `gh api \u2026/issues` or `gh issue create`. The command runs every filing step in order \u2014 the duplicate scout, the body lint and its classification labels, the depth and `route:` labels, the `## Origin` check when filing into another repository, and `epic:bundle` after the create \u2014 so none of them is a step to remember. When the scout prints candidates it holds the filing: read each, then reissue with `--distinct <N,\u2026>` for the ones that are separate deliverables. Reference: `docs/josh-commands.md` \u2192 "`josh issue:file`". **This rule fires on every occurrence, not once per run.**';
@@ -136,17 +136,19 @@ function next_state(previous, key, now_ms) {
136
136
  if (previous?.key === key) return previous;
137
137
  return { key, unchanged_since_ms: now_ms };
138
138
  }
139
- function format_child(child) {
139
+ function format_child(child, cite) {
140
140
  const labels = child.labels.length > 0 ? child.labels.join(",") : "(no labels)";
141
- return `#${child.issue} ${labels} PR:${child.pr_state}`;
141
+ return `${cite(child.issue)} ${labels} PR:${child.pr_state}`;
142
142
  }
143
- function format_children(children) {
143
+ function format_children(children, repo) {
144
144
  if (children.length === 0) return NO_CHILD_YET;
145
- return children.map((child) => format_child(child)).join(" \xB7 ");
145
+ const cite = issue_cite.citer(repo, new Map(children.map((child) => [child.issue, child.title])));
146
+ return children.map((child) => format_child(child, cite)).join(" \xB7 ");
146
147
  }
147
- function format_lanes(lanes) {
148
+ function format_lanes(lanes, repo) {
148
149
  if (lanes.length === 0) return NO_LANES;
149
- return lanes.map((lane) => `${lane.issue}:${lane.state}`).join(" ");
150
+ const cite = issue_cite.citer(repo, /* @__PURE__ */ new Map());
151
+ return lanes.map((lane) => `${cite(lane.issue)}:${lane.state}`).join(" ");
150
152
  }
151
153
  function format_record(record_age_ms) {
152
154
  return record_age_ms === void 0 ? "unread" : `+${format_minutes(record_age_ms)}`;
@@ -171,8 +173,8 @@ function format_line(observations, timing) {
171
173
  observed_at: format_observed_at(timing.now_ms),
172
174
  quiet: format_minutes(timing.now_ms - timing.quiet_since_ms),
173
175
  unchanged: format_minutes(timing.now_ms - timing.unchanged_since_ms),
174
- children: format_children(observations.children),
175
- lanes: format_lanes(observations.lanes),
176
+ children: format_children(observations.children, observations.repo),
177
+ lanes: format_lanes(observations.lanes, observations.repo),
176
178
  load: observations.load_average.toFixed(1),
177
179
  record: format_record(observations.record_age_ms),
178
180
  next: format_next_report(timing.now_ms, timing.interval_ms)
@@ -1180,8 +1182,8 @@ function labels_of(question) {
1180
1182
  }
1181
1183
  function render_question(question) {
1182
1184
  const labels = labels_of(question);
1183
- const text2 = question.question ?? UNKNOWN_QUESTION;
1184
- return labels.length === 0 ? text2 : `${text2} [${labels.join(OPTION_SEPARATOR)}]`;
1185
+ const text = question.question ?? UNKNOWN_QUESTION;
1186
+ return labels.length === 0 ? text : `${text} [${labels.join(OPTION_SEPARATOR)}]`;
1185
1187
  }
1186
1188
  function interactive_input(raw) {
1187
1189
  const denial = DENIAL_SCHEMA.safeParse(raw);
@@ -1510,7 +1512,7 @@ var DECISION_ORACLES = [
1510
1512
  decision: "Whether cross-file or cross-repository code duplication exists",
1511
1513
  args: "",
1512
1514
  vocabulary: ["clean", "clones:"],
1513
- single_source: "prompts/collaboration-workflow/no-clones.md"
1515
+ single_source: "prompts/collaboration-workflow/principles.md \u2192 \u30AF\u30ED\u30FC\u30F3\u7981\u6B62"
1514
1516
  },
1515
1517
  {
1516
1518
  name: "epic:reconcile",
@@ -1848,7 +1850,6 @@ var ROW11 = {
1848
1850
  var raw_field_body = { RAW_FIELD_BODY_REASON, ROW: ROW11, posts_at_path_literally };
1849
1851
 
1850
1852
  // scripts/rules/rule-body-guard.ts
1851
- import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
1852
1853
  var EDIT_TOOL = "Edit";
1853
1854
  var WRITE_TOOL = "Write";
1854
1855
  var CLAUDE_DOCUMENT = /(?:^|\/)CLAUDE\.md$/u;
@@ -1859,8 +1860,8 @@ function is_rule_document(file_path) {
1859
1860
  }
1860
1861
  var LINK_TARGET = /\]\([^)]*\)/gu;
1861
1862
  var BARE_URL = /https?:\/\/\S+/gu;
1862
- function prose_of(text2) {
1863
- return text2.replaceAll(LINK_TARGET, "]()").replaceAll(BARE_URL, "");
1863
+ function prose_of(text) {
1864
+ return text.replaceAll(LINK_TARGET, "]()").replaceAll(BARE_URL, "");
1864
1865
  }
1865
1866
  var MIN_APPENDED_PROSE = 120;
1866
1867
  function adds_rule_prose(old_text, new_text) {
@@ -1871,7 +1872,7 @@ function string_field(input, key) {
1871
1872
  return typeof value === "string" ? value : "";
1872
1873
  }
1873
1874
  function read_existing(file_path) {
1874
- return existsSync2(file_path) ? readFileSync3(file_path, "utf8") : "";
1875
+ return file_reader.read_file_or_empty(file_path);
1875
1876
  }
1876
1877
  function texts_of(name, input, read2) {
1877
1878
  if (name === WRITE_TOOL) {
@@ -2010,11 +2011,11 @@ var shell_body_trigger = {
2010
2011
  import { execFileSync } from "node:child_process";
2011
2012
 
2012
2013
  // scripts/gate/project-checks.ts
2013
- import { existsSync as existsSync4, globSync as globSync2, readFileSync as readFileSync5 } from "node:fs";
2014
+ import { existsSync as existsSync3, globSync as globSync2, readFileSync as readFileSync4 } from "node:fs";
2014
2015
  import path5 from "node:path";
2015
2016
 
2016
2017
  // scripts/init/project-profile.ts
2017
- import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync4 } from "node:fs";
2018
+ import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync3 } from "node:fs";
2018
2019
  import path4 from "node:path";
2019
2020
 
2020
2021
  // scripts/version/kit-descriptor.ts
@@ -2054,8 +2055,8 @@ function requested_profile(args, usage = "josh init [--profile basic|full]") {
2054
2055
  }
2055
2056
  function read_manifest(root) {
2056
2057
  const filename = path4.join(root, "package.json");
2057
- if (!existsSync3(filename)) return void 0;
2058
- const parsed = JSON.parse(readFileSync4(filename, "utf8"));
2058
+ if (!existsSync2(filename)) return void 0;
2059
+ const parsed = JSON.parse(readFileSync3(filename, "utf8"));
2059
2060
  if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
2060
2061
  throw new Error("package.json must contain an object");
2061
2062
  }
@@ -2126,7 +2127,7 @@ function has_github_remote(root) {
2126
2127
  function inspect_project(root, requested) {
2127
2128
  const profile = resolve_profile(root, requested);
2128
2129
  const files = scan_files(root);
2129
- const has_git = existsSync3(path4.join(root, ".git"));
2130
+ const has_git = existsSync2(path4.join(root, ".git"));
2130
2131
  return { ...profile, ...files, has_git, has_github: has_git && has_github_remote(root) };
2131
2132
  }
2132
2133
  var project_profile = {
@@ -2179,7 +2180,7 @@ var DEPENDENCY_FIELDS = ["dependencies", "devDependencies"];
2179
2180
  var object_schema = z5.record(z5.string(), z5.unknown());
2180
2181
  function project_root(directory) {
2181
2182
  let current = directory;
2182
- while (!existsSync4(path5.join(current, PACKAGE_JSON))) {
2183
+ while (!existsSync3(path5.join(current, PACKAGE_JSON))) {
2183
2184
  const parent = path5.dirname(current);
2184
2185
  if (parent === current) return directory;
2185
2186
  current = parent;
@@ -2193,7 +2194,7 @@ function has_files(directory, pattern) {
2193
2194
  return globSync2(pattern, { cwd: project_root(directory), exclude: is_ignored }).length > 0;
2194
2195
  }
2195
2196
  function has_config(directory, names) {
2196
- return names.some((name) => existsSync4(path5.join(project_root(directory), name)));
2197
+ return names.some((name) => existsSync3(path5.join(project_root(directory), name)));
2197
2198
  }
2198
2199
  function has_bin(directory, bin_name) {
2199
2200
  return find_local_bin_upwards(directory, bin_name) !== void 0;
@@ -2210,7 +2211,7 @@ function is_basic_manifest(manifest) {
2210
2211
  function read_manifest2(directory) {
2211
2212
  try {
2212
2213
  const manifest_path = path5.join(project_root(directory), PACKAGE_JSON);
2213
- return JSON.parse(readFileSync5(manifest_path, "utf8"));
2214
+ return JSON.parse(readFileSync4(manifest_path, "utf8"));
2214
2215
  } catch {
2215
2216
  return void 0;
2216
2217
  }
@@ -3527,9 +3528,8 @@ var git_gh_issue = {
3527
3528
  };
3528
3529
 
3529
3530
  // scripts/ci/pr-classification.ts
3530
- import { readFileSync as readFileSync6 } from "node:fs";
3531
+ import { readFileSync as readFileSync5 } from "node:fs";
3531
3532
  import { fileURLToPath as fileURLToPath2 } from "node:url";
3532
- import { execaSync as execaSync2 } from "execa";
3533
3533
  import { z as z8 } from "zod";
3534
3534
  var CLASSIFICATION_SET = new Set(RELEASE_CLASSIFICATION_NAMES);
3535
3535
  var ISSUE_BUG_LABEL = "bug";
@@ -3587,18 +3587,17 @@ function select_issue_classification(issue_json) {
3587
3587
  return label;
3588
3588
  }
3589
3589
  function fetch_current_labels(repository, pull_number) {
3590
- const result = execaSync2(
3591
- "gh",
3592
- ["api", `repos/${repository}/issues/${String(pull_number)}/labels`, "--jq", ".[].name"],
3593
- { reject: false }
3594
- );
3595
- if (result.exitCode !== 0) {
3596
- throw new Error(`Could not read the pull request labels: ${result.stderr}`);
3590
+ const path7 = `repos/${repository}/issues/${String(pull_number)}/labels`;
3591
+ try {
3592
+ const names = git_gh_exec.exec_gh_api_sync({ path: path7, jq_filter: ".[].name" });
3593
+ return names.split("\n").filter((name) => name !== "");
3594
+ } catch (error) {
3595
+ const detail = error_text.message_of(error);
3596
+ throw new Error(`Could not read the pull request labels: ${detail}`, { cause: error });
3597
3597
  }
3598
- return result.stdout.split("\n").filter((name) => name !== "");
3599
3598
  }
3600
3599
  function check_event(event_path, read_labels = fetch_current_labels) {
3601
- const event = EVENT.parse(JSON.parse(readFileSync6(event_path, "utf8")));
3600
+ const event = EVENT.parse(JSON.parse(readFileSync5(event_path, "utf8")));
3602
3601
  const labels = read_labels(event.repository.full_name, event.pull_request.number);
3603
3602
  return classification_error(labels, event.pull_request.user.login);
3604
3603
  }
@@ -3614,6 +3613,7 @@ if (process.argv[1] === fileURLToPath2(import.meta.url)) {
3614
3613
  var pr_classification = {
3615
3614
  classification_error,
3616
3615
  check_event,
3616
+ fetch_current_labels,
3617
3617
  declaration,
3618
3618
  is_classification,
3619
3619
  select_issue_classification
@@ -3728,8 +3728,6 @@ var pr_number_by_branch = /* @__PURE__ */ new Map();
3728
3728
  var LOOKUP_QUERY = "state=all&sort=created&direction=desc&per_page=100";
3729
3729
  var COMMENTS_QUERY = FULL_PAGE_QUERY;
3730
3730
  var OWNER_PLACEHOLDER = "{owner}";
3731
- var NO_HEAD_REF_MESSAGE = "gh api answered a pull request with no head branch";
3732
- var FORK_HEAD_MESSAGE = "gh api answered a pull request whose head branch is in another repository";
3733
3731
  var NO_PULL_REQUEST_MESSAGE = "gh api found no pull request for branch";
3734
3732
  var UNREADABLE_PULL_REQUEST_MESSAGE = "gh api could not read the pull requests for branch";
3735
3733
  function lookup_path(branch_name) {
@@ -3822,13 +3820,6 @@ async function pr_view(branch_name) {
3822
3820
  if (pull === void 0) return "";
3823
3821
  return JSON.stringify(git_gh_pr_rest.to_pr_info(pull));
3824
3822
  }
3825
- async function pr_head_reference(pr_number) {
3826
- const pull = await read_pull(pr_number);
3827
- const reference = pull.head?.ref;
3828
- if (reference === void 0) throw new Error(NO_HEAD_REF_MESSAGE);
3829
- if (!git_gh_pr_rest.is_same_repository_head(pull)) throw new Error(FORK_HEAD_MESSAGE);
3830
- return reference;
3831
- }
3832
3823
  async function read_comments(branch_name, to_path, to_json) {
3833
3824
  const pr_number = await resolve_pr_number(branch_name);
3834
3825
  if (pr_number === void 0) return void 0;
@@ -3857,7 +3848,6 @@ var git_gh_pr_read = {
3857
3848
  pr_get_url,
3858
3849
  pr_get_body,
3859
3850
  pr_view,
3860
- pr_head_reference,
3861
3851
  pr_get_comments,
3862
3852
  pr_get_review_comments
3863
3853
  };
@@ -4097,12 +4087,6 @@ async function pr_create(title, body, label) {
4097
4087
  await add_pr_classification(number, label);
4098
4088
  return url;
4099
4089
  }
4100
- async function pr_checkout(pr_number) {
4101
- const branch_name = await git_gh_pr_read.pr_head_reference(pr_number);
4102
- await git_command.fetch_branch(branch_name);
4103
- await git_command.checkout(branch_name);
4104
- await git_command.merge_fast_forward(branch_name);
4105
- }
4106
4090
  async function pr_comment(branch_name, body) {
4107
4091
  const pr_number = await require_pr_number(branch_name);
4108
4092
  return await git_gh_issue_write.issue_comment(String(pr_number), body);
@@ -4156,7 +4140,6 @@ var git_gh_pr = {
4156
4140
  pr_create,
4157
4141
  pr_get_classification,
4158
4142
  pr_ensure_classification,
4159
- pr_checkout,
4160
4143
  pr_comment,
4161
4144
  pr_merge,
4162
4145
  pr_update_body
@@ -4634,7 +4617,7 @@ var epic_busy = {
4634
4617
  };
4635
4618
 
4636
4619
  // scripts/run/run-liveness.ts
4637
- import { readFileSync as readFileSync7, realpathSync, statSync } from "node:fs";
4620
+ import { readFileSync as readFileSync6, realpathSync, statSync } from "node:fs";
4638
4621
  import { homedir, tmpdir } from "node:os";
4639
4622
  import path6 from "node:path";
4640
4623
  import { setTimeout as sleep2 } from "node:timers/promises";
@@ -4732,18 +4715,11 @@ var EMPTY_STATE = {
4732
4715
  };
4733
4716
  var LAUNCH_HEADER_PREFIX = "=== ";
4734
4717
  var LAUNCH_HEADER_MARKER = " \xB7 started by process ";
4735
- function parse_line(line) {
4736
- try {
4737
- return JSON.parse(line);
4738
- } catch {
4739
- return void 0;
4740
- }
4741
- }
4742
4718
  function usable_text(value) {
4743
4719
  return typeof value === "string" && value.trim() !== "" ? value : void 0;
4744
4720
  }
4745
4721
  function claude_progress(content) {
4746
- return content.map((block) => TEXT_BLOCK_SCHEMA.safeParse(block)).filter((parsed) => parsed.success).map((parsed) => parsed.data.text).findLast((text2) => text2.trim() !== "");
4722
+ return content.map((block) => TEXT_BLOCK_SCHEMA.safeParse(block)).filter((parsed) => parsed.success).map((parsed) => parsed.data.text).findLast((text) => text.trim() !== "");
4747
4723
  }
4748
4724
  function claude_result(value, state) {
4749
4725
  const result = claude_result_event.decode(value);
@@ -4803,7 +4779,7 @@ function normalized(value, state) {
4803
4779
  function next_state2(line, state) {
4804
4780
  const is_header = line.startsWith(LAUNCH_HEADER_PREFIX) && line.includes(LAUNCH_HEADER_MARKER);
4805
4781
  if (is_header) return EMPTY_STATE;
4806
- return normalized(parse_line(line), state);
4782
+ return normalized(json_value.parse_or_undefined(line), state);
4807
4783
  }
4808
4784
  function read(transcript) {
4809
4785
  let state = EMPTY_STATE;
@@ -4970,7 +4946,7 @@ function read_agent_state(output_path) {
4970
4946
  const safe_path = to_safe_path(output_path);
4971
4947
  if (safe_path === void 0) return void 0;
4972
4948
  try {
4973
- const state = agent_event.read(readFileSync7(safe_path, "utf8"));
4949
+ const state = agent_event.read(readFileSync6(safe_path, "utf8"));
4974
4950
  return state.provider === void 0 ? void 0 : state;
4975
4951
  } catch {
4976
4952
  return void 0;
@@ -5065,9 +5041,10 @@ function event_column(lane) {
5065
5041
  const state = run_liveness.describe_agent_state(lane.output);
5066
5042
  return state ?? "agent -";
5067
5043
  }
5068
- function describe_lane(lane) {
5044
+ var PLAIN_CITE = issue_cite.citer(void 0, /* @__PURE__ */ new Map());
5045
+ function describe_lane(lane, cite = PLAIN_CITE) {
5069
5046
  return [
5070
- `#${lane.issue}`,
5047
+ cite(lane.issue),
5071
5048
  `seat ${value_or_unknown(lane.seat)}`,
5072
5049
  `dev ${value_or_unknown(lane.development_port)}`,
5073
5050
  `preview ${value_or_unknown(lane.preview_port)}`,
@@ -5079,9 +5056,9 @@ function describe_lane(lane) {
5079
5056
  event_column(lane)
5080
5057
  ].join(COLUMN_SEPARATOR);
5081
5058
  }
5082
- function describe_lanes(lanes) {
5059
+ function describe_lanes(lanes, cite = PLAIN_CITE) {
5083
5060
  if (lanes.length === 0) return NO_LANES2;
5084
- return lanes.map((lane) => describe_lane(lane)).join("\n");
5061
+ return lanes.map((lane) => describe_lane(lane, cite)).join("\n");
5085
5062
  }
5086
5063
  function describe_ports(lane) {
5087
5064
  if (lane.seat === void 0) return "no lane seat could be read";
@@ -5328,7 +5305,7 @@ function to_labels(issue) {
5328
5305
  async function to_child(issue) {
5329
5306
  const number = String(issue.number);
5330
5307
  const child = await run_preflight.read_child_state(number);
5331
- return { issue: number, labels: to_labels(issue), pr_state: child.pr_state };
5308
+ return { issue: number, title: issue.title, labels: to_labels(issue), pr_state: child.pr_state };
5332
5309
  }
5333
5310
  async function read_children(repo) {
5334
5311
  const read2 = await epic_busy.read_repository(repo);
@@ -5373,6 +5350,7 @@ async function read_observations(request) {
5373
5350
  if (children === void 0) return UNREADABLE_READ;
5374
5351
  if (children.length === 0 && !await has_run_started(lanes)) return IDLE_READ;
5375
5352
  const observations = {
5353
+ repo: request.repo,
5376
5354
  children,
5377
5355
  lanes,
5378
5356
  load_average: loadavg()[FIRST_LOAD_AVERAGE] ?? 0,
@@ -5427,7 +5405,58 @@ async function watcher_hook_reason(raw_payload, now_ms = Date.now()) {
5427
5405
  if (transcript === void 0) return void 0;
5428
5406
  return await stale_reason(transcript, now_ms);
5429
5407
  }
5430
- var run_watcher_hook = { SWITCH_ENV_KEY: SWITCH_ENV_KEY2, STAMP_PREFIX: STAMP_PREFIX2, watcher_hook_reason };
5408
+ var run_watcher_hook = { SWITCH_ENV_KEY: SWITCH_ENV_KEY2, STAMP_PREFIX: STAMP_PREFIX2, transcript_of, watcher_hook_reason };
5409
+
5410
+ // scripts/run/run-parent-cut-hook.ts
5411
+ var SWITCH_ENV_KEY3 = "JOSH_PARENT_CUT_GUARD";
5412
+ var STAMP_PREFIX3 = "josh-parent-cut-guard-";
5413
+ var QUIET_WINDOW_MS = 6e5;
5414
+ function current_state3() {
5415
+ return {
5416
+ carry: async () => await run_headless.driving_carry(),
5417
+ verdict: () => implementation_cut_verdict.reused_verdict(() => cost_cli.session_verdict())
5418
+ };
5419
+ }
5420
+ var THRESHOLD_TEXT2 = `${cost_format.format_tokens(CONTEXT_CUT_THRESHOLD)}-token`;
5421
+ var PARENT_CUT_REASON = `\u26D4 backlogrun parent hand-off: this session drives a \`backlogrun\` (it owns the live carry record) and its recent-context cost has crossed the shared ${THRESHOLD_TEXT2} threshold between merges, so every later request re-reads the accumulated context (joshuafolkken/kit#2947). Take the hand-off now rather than at the next merge: follow \`.claude/skills/workflow-commands/backlogrun-progress.md\` \u2192 "The hand-off" from its \`over\` branch \u2014 open no new lane and take no new child, read \`pnpm josh lane:list\`, make sure every lane in flight records an output path, then run \`pnpm josh run:carry --cut --owner "$PPID"\` and, unless it answers \`capped\`, \`pnpm josh run:wake\`, post the progress comment and end the turn. A lane nobody can poll means the cut does not happen; carry on and this asks again later. Reissue this call when the hand-off is done or cannot be taken \u2014 the guard stays quiet for a while after it refuses, so the hand-off calls themselves are not refused.`;
5422
+ async function is_due2(state) {
5423
+ const carry = await state.carry();
5424
+ if (carry === void 0 || run_carry.is_at_cut_cap(carry)) return false;
5425
+ return state.verdict() === cost_verdict.OVER_VERDICT;
5426
+ }
5427
+ function is_quiet(target, now_ms) {
5428
+ const last_ms = hook_decision.create_refusal_stamp(STAMP_PREFIX3).last_ms(target);
5429
+ return last_ms !== hook_decision.NEVER_MS && now_ms - last_ms < QUIET_WINDOW_MS;
5430
+ }
5431
+ async function refusal_for(transcript, now_ms, state) {
5432
+ const stamp = hook_decision.create_refusal_stamp(STAMP_PREFIX3);
5433
+ const target = stamp.path(transcript);
5434
+ if (is_quiet(target, now_ms) || !await is_due2(state)) return void 0;
5435
+ return stamp.record(target, now_ms) ? PARENT_CUT_REASON : void 0;
5436
+ }
5437
+ function is_unit_call(raw_payload) {
5438
+ try {
5439
+ return (hook_decision.parse_hook_payload(raw_payload)?.agent_id ?? "") !== "";
5440
+ } catch {
5441
+ return false;
5442
+ }
5443
+ }
5444
+ function is_exempt2(raw_payload) {
5445
+ return !hook_decision.is_switch_enabled(SWITCH_ENV_KEY3) || is_unit_call(raw_payload);
5446
+ }
5447
+ async function parent_cut_reason(raw_payload, now_ms = Date.now(), state = current_state3()) {
5448
+ if (is_exempt2(raw_payload)) return void 0;
5449
+ const transcript = run_watcher_hook.transcript_of(raw_payload);
5450
+ if (transcript === void 0) return void 0;
5451
+ return await refusal_for(transcript, now_ms, state);
5452
+ }
5453
+ var run_parent_cut_hook = {
5454
+ PARENT_CUT_REASON,
5455
+ QUIET_WINDOW_MS,
5456
+ STAMP_PREFIX: STAMP_PREFIX3,
5457
+ SWITCH_ENV_KEY: SWITCH_ENV_KEY3,
5458
+ parent_cut_reason
5459
+ };
5431
5460
 
5432
5461
  // scripts/hooks/pretool-guard.ts
5433
5462
  function combine_outcomes(batch, extra_reason) {
@@ -5453,24 +5482,19 @@ function pretool_outcome(raw_payload) {
5453
5482
  const combined = combine_outcomes(batch, investigation ?? duplicate_refusal ?? rule);
5454
5483
  return with_duplicate_notice(combined, duplicate.notice);
5455
5484
  }
5485
+ async function async_reason(raw_payload) {
5486
+ const watcher = await run_watcher_hook.watcher_hook_reason(raw_payload);
5487
+ return watcher ?? await run_parent_cut_hook.parent_cut_reason(raw_payload);
5488
+ }
5456
5489
  async function pretool_outcome_async(raw_payload) {
5457
5490
  const base = pretool_outcome(raw_payload);
5458
5491
  if (!is_clear(base)) return base;
5459
- const reason = await run_watcher_hook.watcher_hook_reason(raw_payload);
5492
+ const reason = await async_reason(raw_payload);
5460
5493
  return reason === void 0 ? base : { reason, notice: void 0, fault: void 0 };
5461
5494
  }
5462
5495
  var pretool_guard = { combine_outcomes, pretool_outcome, pretool_outcome_async };
5463
- if (process.argv[1] === fileURLToPath3(import.meta.url)) {
5464
- if (process.stdin.isTTY) hook_decision.report_no_payload("pretool:guard");
5465
- else {
5466
- const raw_payload = await text(process.stdin);
5467
- hook_decision.load_environment_file();
5468
- hook_decision.emit_outcome(await pretool_outcome_async(raw_payload));
5469
- }
5470
- }
5471
5496
 
5472
5497
  export {
5473
- pretool_outcome,
5474
5498
  pretool_outcome_async,
5475
5499
  pretool_guard
5476
5500
  };