@joshuafolkken/kit 1.1050.0 → 1.1128.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 (630) hide show
  1. package/.claude/settings.json +9 -8
  2. package/.claude/skills/epic-commands/SKILL.md +5 -7
  3. package/.claude/skills/workflow-commands/SKILL.md +20 -12
  4. package/.claude/skills/workflow-commands/background-commands.md +36 -84
  5. package/.claude/skills/workflow-commands/backlogrun-child.md +1 -1
  6. package/.claude/skills/workflow-commands/backlogrun-lanes.md +8 -6
  7. package/.claude/skills/workflow-commands/backlogrun-progress.md +30 -33
  8. package/.claude/skills/workflow-commands/backlogrun-steps.md +12 -12
  9. package/.claude/skills/workflow-commands/backlogrun.md +2 -2
  10. package/.claude/skills/workflow-commands/chain-rule.md +4 -2
  11. package/.claude/skills/workflow-commands/delegation.md +3 -3
  12. package/.claude/skills/workflow-commands/followup-reference.md +1 -1
  13. package/.claude/skills/workflow-commands/followup.md +7 -3
  14. package/.claude/skills/workflow-commands/fullrun-steps.md +3 -2
  15. package/.claude/skills/workflow-commands/fullrun.md +8 -6
  16. package/.claude/skills/workflow-commands/halfrun.md +19 -21
  17. package/.claude/skills/workflow-commands/issue-comments.md +1 -1
  18. package/.claude/skills/workflow-commands/issue-fold-existing.md +10 -10
  19. package/.claude/skills/workflow-commands/issue-scout.md +1 -1
  20. package/.claude/skills/workflow-commands/kickoff.md +9 -4
  21. package/.claude/skills/workflow-commands/latest-gate.md +8 -16
  22. package/.claude/skills/workflow-commands/needs-human-review.md +1 -1
  23. package/.claude/skills/workflow-commands/observation-filing.md +3 -3
  24. package/.claude/skills/workflow-commands/pre-gate-cut.md +4 -8
  25. package/.claude/skills/workflow-commands/prerequisite.md +1 -1
  26. package/.claude/skills/workflow-commands/prrun.md +36 -0
  27. package/.claude/skills/workflow-commands/retrospective.md +1 -1
  28. package/.claude/skills/workflow-commands/split-assessment.md +4 -18
  29. package/.claude/skills/workflow-commands/working-tree-hold.md +22 -2
  30. package/.codex/hooks.json +16 -20
  31. package/.github/actions/setup-node/action.yml +33 -0
  32. package/.github/actions/setup-pnpm/action.yml +93 -0
  33. package/.github/dependabot.yml +5 -1
  34. package/.github/workflows/auto-tag.yml +2 -3
  35. package/.github/workflows/ci.yml +31 -134
  36. package/.github/workflows/dependabot-auto-merge.yml +1 -0
  37. package/.github/workflows/pr-classification.yml +6 -44
  38. package/.github/workflows/production.yml +1 -0
  39. package/.github/workflows/publish.yml +43 -47
  40. package/.github/workflows/sonar-qube.yml +41 -4
  41. package/.pnpmfile.mjs +29 -0
  42. package/AGENTS.md +5 -2
  43. package/CLAUDE.md +33 -27
  44. package/GEMINI.md +5 -2
  45. package/README.md +66 -20
  46. package/SECURITY.md +37 -6
  47. package/cspell/index.yaml +6 -1
  48. package/dist/CLAUDE.basic.md +6 -6
  49. package/dist/CLAUDE.md +33 -27
  50. package/dist/CLAUDE.static.md +6 -6
  51. package/dist/config-merge/index.js +48 -12
  52. package/dist/hooks/batch-guard.js +4 -4
  53. package/dist/hooks/{chunk-7VPDUBRN.js → chunk-4JZDP5X5.js} +152 -155
  54. package/dist/hooks/{chunk-HJIISEAC.js → chunk-5SD2YM7Z.js} +5 -13
  55. package/dist/hooks/{chunk-NAS4C7GP.js → chunk-77J7IEQM.js} +2 -2
  56. package/dist/hooks/{chunk-DMQN45FN.js → chunk-7HVB7SZG.js} +3 -3
  57. package/dist/hooks/{chunk-RLDX5SOC.js → chunk-AIOIOMPX.js} +4413 -1970
  58. package/dist/hooks/{chunk-5BK3K7V4.js → chunk-M7QKEKWO.js} +873 -2049
  59. package/dist/hooks/{chunk-WQ4OSBSS.js → chunk-MKVGBQPA.js} +2 -2
  60. package/dist/hooks/{chunk-EJDX2TOB.js → chunk-NXYMNPUQ.js} +7 -88
  61. package/dist/hooks/{chunk-NJQOBE6L.js → chunk-QVLT52OV.js} +2 -7
  62. package/dist/hooks/{chunk-GQ7KP45M.js → chunk-XYUIQOW3.js} +2 -2
  63. package/dist/hooks/codex-hook-adapter.js +12 -48
  64. package/dist/hooks/duplicate-read-guard.js +5 -5
  65. package/dist/hooks/format-edited.js +2 -2
  66. package/dist/hooks/inputs.json +280 -0
  67. package/dist/hooks/investigation-guard.js +5 -5
  68. package/dist/hooks/pretool-guard.js +9 -9
  69. package/dist/hooks/session-lang.js +0 -1
  70. package/dist/hooks/stop-guard.js +192 -333
  71. package/dist/josh.js +240 -148
  72. package/dist/managed-marker/index.js +2 -1
  73. package/dist/version/index.js +70 -78
  74. package/eslint/rules/promise.js +5 -0
  75. package/eslint/rules/unicorn.js +3 -2
  76. package/package.json +26 -5
  77. package/pnpm-workspace.yaml +5 -7
  78. package/prompts/collaboration-workflow/glossary.md +17 -0
  79. package/prompts/collaboration-workflow/issue-citation.md +5 -5
  80. package/prompts/collaboration-workflow/issue-template.md +1 -1
  81. package/prompts/collaboration-workflow/operating-rules.md +5 -5
  82. package/prompts/collaboration-workflow/overview.md +13 -1
  83. package/prompts/collaboration-workflow/principles.md +9 -0
  84. package/prompts/collaboration-workflow/report-format.md +1 -1
  85. package/prompts/collaboration-workflow/residency.md +3 -3
  86. package/prompts/collaboration-workflow/rule-delivery.md +1 -1
  87. package/prompts/collaboration-workflow/turn-batching.md +3 -3
  88. package/prompts/collaboration-workflow/upstream-interrupt.md +1 -1
  89. package/prompts/collaboration-workflow/wip-cap.md +25 -22
  90. package/prompts/collaboration-workflow.md +6 -8
  91. package/prompts/review-rubric.md +1 -1
  92. package/prompts/review.md +3 -3
  93. package/prompts/sonar-hotspot-handling.md +11 -3
  94. package/prompts/testing-guide.md +3 -3
  95. package/scripts/adopt/adopt-toolkits.ts +0 -2
  96. package/scripts/adopt/adopt.ts +0 -2
  97. package/scripts/agent/agent-argv.ts +0 -2
  98. package/scripts/agent/agent-diagnostics.ts +1 -1
  99. package/scripts/agent/agent-role-profile.ts +0 -7
  100. package/scripts/agent/claude-agent-argv.ts +0 -2
  101. package/scripts/agent/codex-agent-argv.ts +1 -1
  102. package/scripts/agent/codex-hooks.ts +92 -0
  103. package/scripts/agent/interactive-ask.ts +1 -1
  104. package/scripts/auto-ok/auto-ok-cli.ts +6 -16
  105. package/scripts/backlog/backlog-arrival.ts +30 -10
  106. package/scripts/backlog/backlog-budget-cli.ts +15 -16
  107. package/scripts/backlog/backlog-budget.ts +0 -2
  108. package/scripts/backlog/backlog-defect-priority.ts +2 -2
  109. package/scripts/backlog/backlog-drive-cli.ts +10 -8
  110. package/scripts/backlog/backlog-drive-named-offer.ts +16 -3
  111. package/scripts/backlog/backlog-drive-named.ts +2 -1
  112. package/scripts/backlog/backlog-drive.ts +76 -16
  113. package/scripts/backlog/backlog-named.ts +0 -3
  114. package/scripts/backlog/backlog-next.ts +9 -15
  115. package/scripts/backlog/backlog-offer-cli.ts +6 -19
  116. package/scripts/backlog/backlog-plan-cli.ts +1 -7
  117. package/scripts/backlog/backlog-plan.ts +30 -19
  118. package/scripts/backlog/backlog-pool.ts +3 -6
  119. package/scripts/backlog/backlog-rank.ts +2 -2
  120. package/scripts/backlog/backlog-ready.ts +39 -10
  121. package/scripts/backlog/backlog-scope.ts +1 -3
  122. package/scripts/backlog/backlog-stalled-detect.ts +2 -2
  123. package/scripts/backlog/backlog-stalled.ts +0 -1
  124. package/scripts/backlog/backlog-waves.ts +5 -2
  125. package/scripts/behavior/behavior-cli.ts +1 -1
  126. package/scripts/build/build-codex-hooks.ts +26 -0
  127. package/scripts/build/build-hooks.ts +85 -9
  128. package/scripts/build/hook-bundle-stamp.ts +111 -0
  129. package/scripts/cases/cases-cli.ts +1 -1
  130. package/scripts/cases/cases-logic.ts +1 -1
  131. package/scripts/ci/composite-actions.ts +30 -0
  132. package/scripts/ci/pr-classification.ts +3 -3
  133. package/scripts/claude/workflow-destination.ts +10 -1
  134. package/scripts/clone/clone-fingerprint.ts +0 -1
  135. package/scripts/clone/clone-scan-cli.ts +1 -1
  136. package/scripts/clone/clone-scan.ts +1 -1
  137. package/scripts/config-merge/json-format.ts +0 -1
  138. package/scripts/config-merge/parse-jsonc.ts +33 -3
  139. package/scripts/config-merge/patch-json-key.ts +13 -6
  140. package/scripts/config-merge/patch-yaml-list.ts +1 -1
  141. package/scripts/cost-runtime/codex-usage.ts +2 -9
  142. package/scripts/cost-runtime/cost-attribute.ts +0 -1
  143. package/scripts/cost-runtime/cost-cli.ts +3 -10
  144. package/scripts/cost-runtime/cost-corpus.ts +0 -2
  145. package/scripts/cost-runtime/cost-format.ts +0 -3
  146. package/scripts/cost-runtime/cost-pricing.ts +0 -1
  147. package/scripts/cost-runtime/cost-tokens.ts +0 -1
  148. package/scripts/delegation/delegation-cli.ts +1 -1
  149. package/scripts/delegation/delegation-policy.ts +0 -1
  150. package/scripts/delegation/duplicate-read-guard.ts +0 -8
  151. package/scripts/delegation/fanout-cli.ts +1 -1
  152. package/scripts/delegation/fanout.ts +0 -2
  153. package/scripts/delegation/investigation-reads.ts +1 -164
  154. package/scripts/discovery/repo-map-logic.ts +0 -1
  155. package/scripts/discovery/repo-party-cli.ts +1 -1
  156. package/scripts/doctor/doctor-consumer.ts +6 -10
  157. package/scripts/doctor/doctor-io.ts +9 -13
  158. package/scripts/doctor/doctor-logic.ts +0 -4
  159. package/scripts/doctor/doctor.ts +14 -9
  160. package/scripts/document/backlogrun-parent-read-set.ts +12 -1
  161. package/scripts/document/document-byte-budget.ts +5 -5
  162. package/scripts/document/document-byte-check.ts +0 -1
  163. package/scripts/document/document-read-cli.ts +0 -2
  164. package/scripts/document/document-section-cli.ts +1 -1
  165. package/scripts/document/document-section.ts +0 -3
  166. package/scripts/document/edit-files-cli.ts +0 -1
  167. package/scripts/document/entry-read-budget.ts +21 -7
  168. package/scripts/document/entry-read-set.ts +32 -8
  169. package/scripts/document/lane-child-read-set.ts +8 -6
  170. package/scripts/document/read-files-cli.ts +0 -4
  171. package/scripts/document/read-set-cli.ts +0 -2
  172. package/scripts/document/read-set-point-of-use.ts +9 -3
  173. package/scripts/document/read-set-pricing.ts +0 -1
  174. package/scripts/document/read-set-trim.ts +4 -2
  175. package/scripts/epic/epic-add.ts +1 -1
  176. package/scripts/epic/epic-audit-cli.ts +1 -4
  177. package/scripts/epic/epic-audit-orphans.ts +1 -3
  178. package/scripts/epic/epic-audit-rationale.ts +0 -1
  179. package/scripts/epic/epic-audit-report.ts +0 -2
  180. package/scripts/epic/epic-audit.ts +8 -22
  181. package/scripts/epic/epic-bundle-cli.ts +1 -1
  182. package/scripts/epic/epic-bundle-evidence.ts +0 -1
  183. package/scripts/epic/epic-bundle-referenced.ts +1 -5
  184. package/scripts/epic/epic-bundle.ts +0 -4
  185. package/scripts/epic/epic-busy.ts +4 -5
  186. package/scripts/epic/epic-candidate-confirm.ts +0 -5
  187. package/scripts/epic/epic-classify.ts +2 -2
  188. package/scripts/epic/epic-cli-argv.ts +0 -1
  189. package/scripts/epic/epic-close-comment.ts +1 -1
  190. package/scripts/epic/epic-close.ts +5 -2
  191. package/scripts/epic/epic-cross-repo.ts +2 -4
  192. package/scripts/epic/epic-decision.ts +0 -1
  193. package/scripts/epic/epic-fetch.ts +2 -2
  194. package/scripts/epic/epic-index.ts +2 -3
  195. package/scripts/epic/epic-issue.ts +1 -15
  196. package/scripts/epic/epic-lane-offer.ts +9 -8
  197. package/scripts/epic/epic-nested.ts +1 -1
  198. package/scripts/epic/epic-next-read.ts +1 -3
  199. package/scripts/epic/epic-next-views.ts +0 -1
  200. package/scripts/epic/epic-next.ts +1 -10
  201. package/scripts/epic/epic-parse.ts +0 -1
  202. package/scripts/epic/epic-promote.ts +0 -9
  203. package/scripts/epic/epic-rank.ts +2 -2
  204. package/scripts/epic/epic-read.ts +1 -2
  205. package/scripts/epic/epic-reconcile.ts +1 -1
  206. package/scripts/epic/epic-reference.ts +1 -13
  207. package/scripts/epic/epic-relation-recheck.ts +1 -1
  208. package/scripts/epic/epic-relations.ts +1 -1
  209. package/scripts/epic/epic-remove.ts +1 -1
  210. package/scripts/epic/epic-report.ts +0 -1
  211. package/scripts/epic/epic-run.ts +2 -3
  212. package/scripts/epic/epic-shape.ts +1 -1
  213. package/scripts/epic/epic-solo-stale.ts +107 -0
  214. package/scripts/epic/epic-solo.ts +3 -2
  215. package/scripts/epic/epic-triage.ts +1 -1
  216. package/scripts/epic/epic-validate.ts +1 -1
  217. package/scripts/epic/epic.ts +1 -1
  218. package/scripts/exports/unused-members-cli.ts +53 -0
  219. package/scripts/{git → followup}/followup-issue-number.ts +1 -6
  220. package/scripts/{git → followup}/git-followup-cleanup.ts +2 -1
  221. package/scripts/{git → followup}/git-followup-finish.ts +1 -3
  222. package/scripts/{git → followup}/git-followup-flush.ts +2 -2
  223. package/scripts/{git → followup}/git-followup-issue-close.ts +2 -2
  224. package/scripts/{git → followup}/git-followup-label.ts +4 -4
  225. package/scripts/followup/git-followup-merged.ts +112 -0
  226. package/scripts/{git → followup}/git-followup-pending.ts +1 -1
  227. package/scripts/{git → followup}/git-followup-workflow.ts +19 -11
  228. package/scripts/{git → followup}/git-pr-followup-wrapup.ts +9 -3
  229. package/scripts/{git → followup}/git-pr-followup.ts +53 -16
  230. package/scripts/gate/core-budget.ts +3 -9
  231. package/scripts/gate/gate-plan.ts +7 -4
  232. package/scripts/gate/gate-report.ts +0 -6
  233. package/scripts/gate/gate-tree.ts +1 -1
  234. package/scripts/gate/pre-commit-type-check.ts +0 -6
  235. package/scripts/gate/project-checks.ts +7 -8
  236. package/scripts/gate/scoped-green.ts +0 -1
  237. package/scripts/gate/type-check-step.ts +1 -1
  238. package/scripts/gate/verification-gate.ts +0 -2
  239. package/scripts/gh/fix-gh-packages.ts +15 -12
  240. package/scripts/gh/gh-spawn.ts +2 -2
  241. package/scripts/{git → gh}/git-ai-review-scan.ts +1 -5
  242. package/scripts/{git → gh}/git-gh-check.ts +2 -1
  243. package/scripts/{git → gh}/git-gh-exec.ts +1 -1
  244. package/scripts/{git → gh}/git-gh-failure.ts +1 -1
  245. package/scripts/{git → gh}/git-gh-helpers.ts +0 -1
  246. package/scripts/{git → gh}/git-gh-issue-list.ts +13 -10
  247. package/scripts/{git → gh}/git-gh-issue-read.ts +1 -1
  248. package/scripts/{git → gh}/git-gh-issue-rest.ts +6 -3
  249. package/scripts/{git → gh}/git-gh-issue-write.ts +4 -1
  250. package/scripts/{git → gh}/git-gh-pr-auto-merge.ts +4 -1
  251. package/scripts/{git → gh}/git-gh-pr-read.ts +24 -0
  252. package/scripts/{git → gh}/git-gh-pr-rest.ts +5 -2
  253. package/scripts/{git → gh}/git-gh-pr-review.ts +2 -2
  254. package/scripts/{git → gh}/git-gh-pr-rollup.ts +1 -3
  255. package/scripts/{git → gh}/git-gh-pr.ts +3 -1
  256. package/scripts/{git → gh}/git-pr-ai-review.ts +2 -5
  257. package/scripts/{git → gh}/git-pr-checks-eval.ts +0 -10
  258. package/scripts/{git → gh}/git-pr-checks-parse.ts +4 -20
  259. package/scripts/{git → gh}/git-pr-checks.ts +2 -1
  260. package/scripts/{git → gh}/git-pr-coderabbit.ts +2 -5
  261. package/scripts/{git → gh}/git-pr-confirmation.ts +1 -3
  262. package/scripts/{git → gh}/git-pr-managed-config.ts +2 -3
  263. package/scripts/{git → gh}/git-pr.ts +3 -3
  264. package/scripts/git/changed-file-scope.ts +0 -1
  265. package/scripts/git/git-branch.ts +3 -6
  266. package/scripts/git/git-command.ts +6 -1
  267. package/scripts/git/git-commit.ts +1 -1
  268. package/scripts/git/git-common-directory.ts +80 -24
  269. package/scripts/git/git-error.ts +66 -9
  270. package/scripts/git/git-issue.ts +1 -1
  271. package/scripts/git/git-preflight.ts +2 -2
  272. package/scripts/git/git-prompt.ts +6 -31
  273. package/scripts/git/git-push.ts +1 -1
  274. package/scripts/git/git-spawn-sync.ts +65 -0
  275. package/scripts/git/git-spawn.ts +5 -4
  276. package/scripts/git/git-staging.ts +1 -0
  277. package/scripts/git/git-status.ts +1 -1
  278. package/scripts/git/git-workflow.ts +1 -1
  279. package/scripts/git/gone-branch.ts +1 -0
  280. package/scripts/git/listing-cutoff.ts +1 -1
  281. package/scripts/git/main-merge.ts +1 -1
  282. package/scripts/git/main-sync.ts +19 -1
  283. package/scripts/git/parse-json-array.ts +0 -3
  284. package/scripts/git/repository-lock.ts +16 -16
  285. package/scripts/git/{git-stash.ts → stash/git-stash.ts} +1 -1
  286. package/scripts/git/{stash-pop-args.ts → stash/stash-pop-args.ts} +2 -7
  287. package/scripts/git/{stash-pop-cli.ts → stash/stash-pop-cli.ts} +0 -1
  288. package/scripts/git/{stash-sweep-lock.ts → stash/stash-sweep-lock.ts} +3 -3
  289. package/scripts/hooks/codex-hook-adapter.ts +0 -1
  290. package/scripts/hooks/edited-cspell.ts +1 -1
  291. package/scripts/hooks/format-edited-file.ts +2 -0
  292. package/scripts/hooks/pre-push-unit.ts +0 -4
  293. package/scripts/hooks/pretool-guard.ts +22 -4
  294. package/scripts/hooks/reserved-run.ts +1 -1
  295. package/scripts/hooks/step-zero-notice.ts +76 -0
  296. package/scripts/hooks/stop-guard.ts +47 -21
  297. package/scripts/init/claude-plugin-config.ts +4 -5
  298. package/scripts/init/hook-command-rewrite.ts +16 -8
  299. package/scripts/init/hook-launch.ts +41 -15
  300. package/scripts/init/init-basic.ts +2 -5
  301. package/scripts/init/init-file-action.ts +54 -0
  302. package/scripts/init/init-logic-migrate.ts +35 -17
  303. package/scripts/init/init-logic-secretlint.ts +1 -1
  304. package/scripts/init/init-logic.ts +10 -19
  305. package/scripts/init/init.ts +11 -71
  306. package/scripts/init/kit-written-paths.ts +2 -0
  307. package/scripts/init/project-profile.ts +9 -17
  308. package/scripts/init/start-exec.ts +1 -1
  309. package/scripts/init/start-setup-pr.ts +6 -6
  310. package/scripts/init/start-steps.ts +3 -1
  311. package/scripts/issue/behavior-change-lint.ts +0 -1
  312. package/scripts/issue/defect-rate-cli.ts +64 -23
  313. package/scripts/issue/defect-rate.ts +1 -2
  314. package/scripts/{git → issue}/git-next-issues.ts +3 -3
  315. package/scripts/issue/issue-backlinks-cli.ts +1 -5
  316. package/scripts/issue/issue-backlinks.ts +7 -14
  317. package/scripts/issue/issue-cite-cli.ts +2 -6
  318. package/scripts/issue/issue-cite.ts +12 -8
  319. package/scripts/issue/issue-classification.ts +1 -9
  320. package/scripts/issue/issue-closing-pr.ts +4 -4
  321. package/scripts/issue/issue-comment-cli.ts +2 -2
  322. package/scripts/issue/issue-file-cli.ts +5 -5
  323. package/scripts/issue/issue-file.ts +7 -14
  324. package/scripts/issue/issue-fold-cli.ts +1 -1
  325. package/scripts/issue/issue-fold-existing-cli.ts +1 -1
  326. package/scripts/{git → issue}/issue-labels.ts +8 -0
  327. package/scripts/issue/issue-lint-cli.ts +1 -1
  328. package/scripts/issue/issue-merged.ts +2 -2
  329. package/scripts/{git → issue}/issue-rank.ts +1 -1
  330. package/scripts/issue/issue-read-cli.ts +8 -47
  331. package/scripts/issue/issue-read.ts +0 -2
  332. package/scripts/issue/issue-report-failures.ts +80 -0
  333. package/scripts/issue/issue-scout-cli.ts +1 -7
  334. package/scripts/issue/issue-scout-closed.ts +2 -2
  335. package/scripts/issue/issue-scout.ts +0 -2
  336. package/scripts/issue/issue-state-cli.ts +5 -46
  337. package/scripts/issue/issue-state.ts +1 -5
  338. package/scripts/issue/markdown-section.ts +21 -6
  339. package/scripts/issue/measure-rerun-cli.ts +74 -15
  340. package/scripts/issue/reproduction-measure.ts +1 -1
  341. package/scripts/josh/cli-body.ts +1 -1
  342. package/scripts/josh/file-map-stamp.ts +0 -3
  343. package/scripts/josh/josh-command-map.ts +2 -0
  344. package/scripts/josh/josh-commands-ai.ts +9 -102
  345. package/scripts/josh/josh-commands-backlog.ts +5 -1
  346. package/scripts/josh/josh-commands-development.ts +8 -1
  347. package/scripts/josh/josh-commands-issue.ts +2 -2
  348. package/scripts/josh/josh-commands-maintenance.ts +7 -0
  349. package/scripts/josh/josh-commands-project.ts +7 -1
  350. package/scripts/josh/josh-commands-run.ts +114 -0
  351. package/scripts/josh/josh-commands-versioning.ts +8 -0
  352. package/scripts/josh/josh-commands-workflow.ts +3 -3
  353. package/scripts/josh/path-decision.ts +0 -3
  354. package/scripts/josh/process-owner.ts +16 -0
  355. package/scripts/josh/run-github-prerequisite.ts +3 -6
  356. package/scripts/josh/session-language-cli.ts +0 -1
  357. package/scripts/lane/lane-await.ts +46 -19
  358. package/scripts/lane/lane-capacity.ts +6 -3
  359. package/scripts/lane/lane-child-invocation.ts +20 -7
  360. package/scripts/lane/lane-cli.ts +1 -4
  361. package/scripts/lane/lane-close.ts +5 -4
  362. package/scripts/lane/lane-dispatch.ts +3 -4
  363. package/scripts/lane/lane-environment.ts +0 -9
  364. package/scripts/lane/lane-handoff.ts +38 -0
  365. package/scripts/lane/lane-launch-cli.ts +31 -27
  366. package/scripts/lane/lane-open.ts +0 -3
  367. package/scripts/lane/lane-output.ts +0 -1
  368. package/scripts/lane/lane-registry.ts +9 -0
  369. package/scripts/lane/openai-lane-ship.ts +2 -0
  370. package/scripts/lane/openai-lane-supervisor-decision.ts +2 -1
  371. package/scripts/lane/openai-lane-supervisor.ts +6 -4
  372. package/scripts/lane/openai-review-broker.ts +7 -1
  373. package/scripts/lib/bounded-pool.ts +1 -0
  374. package/scripts/lib/cli-flags.ts +31 -2
  375. package/scripts/lib/error-message.ts +12 -1
  376. package/scripts/lib/json-value.ts +5 -4
  377. package/scripts/lib/poll.ts +3 -1
  378. package/scripts/lib/timed-fetch.ts +15 -0
  379. package/scripts/lib/timeouts.ts +13 -0
  380. package/scripts/{yaml → lib}/yaml-document.ts +3 -1
  381. package/scripts/{bytes → lines}/bytes-command.ts +0 -2
  382. package/scripts/lines/line-targets.ts +0 -11
  383. package/scripts/lines/lines-command.ts +5 -4
  384. package/scripts/lint/lint-related-scope.ts +0 -1
  385. package/scripts/lint/lint-related.ts +1 -1
  386. package/scripts/{git → notify}/telegram-notify.ts +2 -2
  387. package/scripts/{git → notify}/telegram-test.ts +4 -4
  388. package/scripts/observations/observation-ledger-home.ts +0 -1
  389. package/scripts/observations/observation-ledger-line.ts +0 -1
  390. package/scripts/observations/observation-ledger-migrate.ts +1 -1
  391. package/scripts/observations/observations-flush-landing.ts +3 -3
  392. package/scripts/observations/observations-flush.ts +2 -2
  393. package/scripts/overrides/lockfile-overrides.ts +1 -1
  394. package/scripts/overrides/overrides-logic.ts +1 -1
  395. package/scripts/package/package-scout-cli.ts +2 -7
  396. package/scripts/package/package-scout.ts +0 -2
  397. package/scripts/propagate/propagate-git-failure.ts +0 -1
  398. package/scripts/propagate/propagate-git.ts +3 -10
  399. package/scripts/propagate/propagate-publish.ts +2 -3
  400. package/scripts/propagate/propagate-run.ts +0 -2
  401. package/scripts/propagate/propagate-steps.ts +3 -5
  402. package/scripts/propagate/propagate-targets.ts +0 -4
  403. package/scripts/propagate/propagate.ts +0 -4
  404. package/scripts/refactor/import-graph.ts +0 -1
  405. package/scripts/refactor/refactor-lint.ts +0 -2
  406. package/scripts/refactor/refactor-scan.ts +2 -2
  407. package/scripts/refactor/refactor-targets.ts +0 -1
  408. package/scripts/registry-migration/migrate-logic.ts +28 -21
  409. package/scripts/registry-migration/migrate.ts +25 -14
  410. package/scripts/release/github-release-cli.ts +19 -6
  411. package/scripts/release/github-release-environment.ts +46 -0
  412. package/scripts/release/github-release.ts +151 -94
  413. package/scripts/release/release-history.ts +0 -1
  414. package/scripts/release/release-plan.ts +0 -1
  415. package/scripts/release/release-publish.ts +38 -5
  416. package/scripts/release/release-scope-cli.ts +1 -2
  417. package/scripts/release/release-tag.ts +2 -4
  418. package/scripts/release/release-worktree.ts +97 -2
  419. package/scripts/repo/auto-merge-setting-logic.ts +1 -4
  420. package/scripts/repo/repo-setting.ts +1 -1
  421. package/scripts/repo/repository-labels.ts +3 -3
  422. package/scripts/repo/required-checks-logic.ts +206 -0
  423. package/scripts/repo/required-checks-report.ts +71 -0
  424. package/scripts/repo/ruleset-check-cli.ts +53 -0
  425. package/scripts/repo/ruleset-check.ts +147 -0
  426. package/scripts/report/report-lint-cli.ts +0 -4
  427. package/scripts/review/disposition-cli.ts +1 -1
  428. package/scripts/review/live-evidence.ts +1 -1
  429. package/scripts/review/review-attest-cli.ts +0 -6
  430. package/scripts/review/review-attest.ts +4 -16
  431. package/scripts/review/review-brief-cli.ts +23 -6
  432. package/scripts/review/review-brief.ts +21 -8
  433. package/scripts/review/review-checkout.ts +3 -2
  434. package/scripts/review/review-diff-parts.ts +89 -0
  435. package/scripts/review/review-diff-write.ts +97 -0
  436. package/scripts/review/review-finding-ledger.ts +0 -1
  437. package/scripts/review/review-record-cli.ts +10 -17
  438. package/scripts/review/review-record.ts +0 -1
  439. package/scripts/review/review-round2-cli.ts +1 -1
  440. package/scripts/review/review-stamps.ts +0 -3
  441. package/scripts/review/review-tree.ts +14 -2
  442. package/scripts/rules/decision-oracle-stage.ts +18 -0
  443. package/scripts/rules/decision-oracle.ts +10 -7
  444. package/scripts/rules/delivered-rules.ts +9 -1
  445. package/scripts/rules/destructive-command.ts +119 -0
  446. package/scripts/rules/direct-filing.ts +1 -1
  447. package/scripts/rules/early-heartbeat.ts +4 -3
  448. package/scripts/rules/file-body.ts +0 -3
  449. package/scripts/rules/filing-cap.ts +0 -2
  450. package/scripts/rules/gh-api.ts +7 -2
  451. package/scripts/rules/git-argv.ts +18 -7
  452. package/scripts/rules/git-force.ts +0 -2
  453. package/scripts/rules/implementation-cut.ts +0 -1
  454. package/scripts/rules/index-guard.ts +71 -0
  455. package/scripts/rules/issue-citation.ts +50 -25
  456. package/scripts/rules/lane-background.ts +15 -7
  457. package/scripts/rules/lane-park.ts +22 -6
  458. package/scripts/rules/last-prompt.ts +1 -0
  459. package/scripts/rules/oracle-consulted.ts +1 -1
  460. package/scripts/rules/oracle-firing.ts +1 -0
  461. package/scripts/rules/oracle-list-cli.ts +0 -3
  462. package/scripts/rules/permission-guards.ts +14 -0
  463. package/scripts/rules/protected-files.ts +74 -0
  464. package/scripts/rules/reply-language.ts +1 -1
  465. package/scripts/rules/rule-body-guard.ts +0 -3
  466. package/scripts/rules/rule-value-cli.ts +0 -1
  467. package/scripts/rules/shell-body-trigger.ts +0 -1
  468. package/scripts/rules/shell-segments.ts +0 -1
  469. package/scripts/rules/stop-rules.ts +20 -9
  470. package/scripts/rules/tail-commands.ts +1 -1
  471. package/scripts/rules/test-declared-commit.ts +1 -1
  472. package/scripts/rules/third-party-write.ts +0 -1
  473. package/scripts/rules/worktree-guard.ts +26 -9
  474. package/scripts/run/run-carry-args.ts +8 -12
  475. package/scripts/run/run-carry-cli.ts +0 -2
  476. package/scripts/run/run-carry-stash.ts +2 -2
  477. package/scripts/run/run-carry-streak.ts +1 -1
  478. package/scripts/run/run-cut-args.ts +1 -6
  479. package/scripts/run/run-cut-cli.ts +0 -7
  480. package/scripts/run/run-cut.ts +8 -54
  481. package/scripts/run/run-ending-cli.ts +2 -6
  482. package/scripts/run/run-ending.ts +1 -4
  483. package/scripts/run/run-entry-cli.ts +133 -25
  484. package/scripts/run/run-entry-stop.ts +104 -0
  485. package/scripts/run/run-entry.ts +0 -1
  486. package/scripts/run/run-event-cli.ts +0 -2
  487. package/scripts/run/run-event-follow.ts +1 -0
  488. package/scripts/run/run-event-render.ts +1 -1
  489. package/scripts/run/run-event-scope.ts +53 -4
  490. package/scripts/run/run-event-stream-emit.ts +7 -2
  491. package/scripts/run/run-event-stream.ts +0 -3
  492. package/scripts/run/run-event-watch.ts +1 -0
  493. package/scripts/run/run-halfrun-resume.ts +20 -7
  494. package/scripts/run/run-headless.ts +2 -2
  495. package/scripts/run/run-hold-cli.ts +33 -10
  496. package/scripts/run/run-hold.ts +29 -6
  497. package/scripts/run/run-issue-number.ts +1 -1
  498. package/scripts/run/run-liveness-cli.ts +2 -6
  499. package/scripts/run/run-liveness.ts +2 -3
  500. package/scripts/run/run-merge-cli.ts +7 -23
  501. package/scripts/run/run-merge-steps.ts +5 -5
  502. package/scripts/run/run-merge.ts +1 -1
  503. package/scripts/run/run-next-cli.ts +1 -1
  504. package/scripts/run/run-parent-cut-hook.ts +4 -2
  505. package/scripts/run/run-preflight.ts +2 -9
  506. package/scripts/run/run-prep-cli.ts +6 -3
  507. package/scripts/run/run-prep-locate.ts +1 -1
  508. package/scripts/run/run-progress-args.ts +20 -4
  509. package/scripts/run/run-progress-cli.ts +35 -36
  510. package/scripts/run/run-progress-clock.ts +10 -35
  511. package/scripts/run/run-progress-config.ts +0 -4
  512. package/scripts/run/run-progress-read.ts +1 -2
  513. package/scripts/run/run-progress.ts +1 -2
  514. package/scripts/run/run-prrun-resume.ts +117 -0
  515. package/scripts/run/run-report-cli.ts +1 -2
  516. package/scripts/run/run-report.ts +0 -1
  517. package/scripts/run/run-retrospective.ts +1 -1
  518. package/scripts/run/run-review-cli.ts +0 -3
  519. package/scripts/run/run-review-steps.ts +2 -0
  520. package/scripts/run/run-review.ts +0 -2
  521. package/scripts/run/run-ship-cli.ts +29 -19
  522. package/scripts/run/run-ship-detach.ts +1 -0
  523. package/scripts/run/run-ship-next.ts +106 -0
  524. package/scripts/run/run-ship-preflight.ts +1 -1
  525. package/scripts/run/run-ship-probe.ts +4 -1
  526. package/scripts/run/run-ship-return.ts +8 -3
  527. package/scripts/run/run-ship-review-steps.ts +18 -4
  528. package/scripts/run/run-ship-review.ts +11 -0
  529. package/scripts/run/run-ship-scoped.ts +1 -0
  530. package/scripts/run/run-ship-steps.ts +1 -1
  531. package/scripts/run/run-ship.ts +0 -1
  532. package/scripts/run/run-stage-read.ts +62 -0
  533. package/scripts/run/run-stage.ts +160 -0
  534. package/scripts/run/run-status-cli.ts +3 -16
  535. package/scripts/run/run-step-cli.ts +21 -14
  536. package/scripts/run/run-step.ts +1 -1
  537. package/scripts/run/run-stop-notify.ts +1 -3
  538. package/scripts/run/run-stranded-cli.ts +0 -4
  539. package/scripts/run/run-stranded-detect.ts +2 -2
  540. package/scripts/run/run-tail-cli.ts +17 -11
  541. package/scripts/run/run-tail.ts +2 -0
  542. package/scripts/run/run-tidy-lanes.ts +6 -2
  543. package/scripts/run/run-tidy-stashes.ts +12 -12
  544. package/scripts/run/run-wake-cli.ts +4 -13
  545. package/scripts/run/run-wake-loop.ts +2 -2
  546. package/scripts/run/run-wake.ts +2 -4
  547. package/scripts/run/run-watcher-guard-cli.ts +0 -4
  548. package/scripts/run/run-watcher-guard.ts +18 -12
  549. package/scripts/run/run-watcher-hook.ts +1 -1
  550. package/scripts/safe-chain/ci-installer-pin.ts +11 -5
  551. package/scripts/safe-chain/pack-hook.ts +92 -0
  552. package/scripts/safe-chain/project-config.ts +1 -1
  553. package/scripts/security/security-audit-provision-logic.ts +0 -1
  554. package/scripts/security/security-audit-provision.ts +3 -2
  555. package/scripts/security/security-audit.ts +0 -1
  556. package/scripts/security/security-updates-logic.ts +0 -1
  557. package/scripts/sonar/sonar-hotspots-cli.ts +10 -52
  558. package/scripts/sonar/sonar-hotspots.ts +0 -1
  559. package/scripts/sonar/sonar-new-code-cli.ts +150 -0
  560. package/scripts/sonar/sonar-new-code.ts +79 -0
  561. package/scripts/sonar/sonar-project.ts +97 -0
  562. package/scripts/split/split-assess-cli.ts +1 -1
  563. package/scripts/split/split-assess.ts +2 -5
  564. package/scripts/sync/managed-config-scope-cli.ts +1 -1
  565. package/scripts/sync/skill-migration.ts +0 -1
  566. package/scripts/sync/sync-ai-files.ts +4 -0
  567. package/scripts/sync/sync-hook-safety.ts +2 -3
  568. package/scripts/sync/sync.ts +1 -8
  569. package/scripts/sync/template-source-logic.ts +0 -1
  570. package/scripts/sync/workflow-pin-logic.ts +16 -28
  571. package/scripts/test/test-declared-changed.ts +13 -16
  572. package/scripts/test/test-declared-logic.ts +0 -1
  573. package/scripts/test/test-declared.ts +3 -9
  574. package/scripts/test/test-red-commit.ts +2 -2
  575. package/scripts/test/test-red.ts +14 -7
  576. package/scripts/test/test-type-logic.ts +1 -1
  577. package/scripts/test/unit-worker-share.ts +7 -16
  578. package/scripts/time-runtime/time-batch-guard.ts +1 -2
  579. package/scripts/time-runtime/time-bundle-call.ts +0 -1
  580. package/scripts/time-runtime/time-bundles.ts +0 -4
  581. package/scripts/time-runtime/time-density-hook.ts +0 -2
  582. package/scripts/time-runtime/time-followup-stage.ts +1 -1
  583. package/scripts/time-runtime/time-format.ts +0 -73
  584. package/scripts/time-runtime/time-round-trips.ts +0 -4
  585. package/scripts/time-runtime/time-single-check.ts +1 -1
  586. package/scripts/time-runtime/time-spans.ts +1 -1
  587. package/scripts/time-runtime/time-transcript-line.ts +1 -2
  588. package/scripts/ui/ui-routes-cli.ts +0 -5
  589. package/scripts/ui/ui-routes.ts +0 -5
  590. package/scripts/version/effective-upstream.ts +2 -2
  591. package/scripts/version/latest-corepack.ts +7 -9
  592. package/scripts/version/latest-scope-cli.ts +0 -2
  593. package/scripts/version/latest-update.ts +0 -2
  594. package/scripts/version/npm-registry.ts +2 -2
  595. package/scripts/version/publishable-range-check.ts +1 -1
  596. package/scripts/version/release-hold.ts +0 -4
  597. package/scripts/version/running-binary.ts +2 -2
  598. package/scripts/version/version-check-logic.ts +0 -2
  599. package/scripts/version/version-commands.ts +11 -1
  600. package/scripts/version/version-remote.ts +3 -3
  601. package/scripts/version/version-targets.ts +4 -4
  602. package/templates/CLAUDE.basic.md +6 -6
  603. package/templates/sonar-project.properties +28 -1
  604. package/templates/workflows/ci.yml +16 -82
  605. package/templates/workflows/dependabot-auto-merge.yml +6 -3
  606. package/templates/workflows/github-release.yml +79 -0
  607. package/tsconfig.sonar.json +4 -22
  608. package/prompts/collaboration-workflow/cross-repo-epic.md +0 -5
  609. package/prompts/collaboration-workflow/epic-audit.md +0 -5
  610. package/prompts/collaboration-workflow/epic-bundle.md +0 -5
  611. package/scripts/init/plugin-install-hint.ts +0 -47
  612. package/scripts/version/parse-json.ts +0 -13
  613. /package/scripts/{git → followup}/git-followup-stages.ts +0 -0
  614. /package/scripts/{git → gh}/git-gh-api-path.ts +0 -0
  615. /package/scripts/{git → gh}/git-gh-command.ts +0 -0
  616. /package/scripts/{git → gh}/git-gh-issue.ts +0 -0
  617. /package/scripts/{git → gh}/git-gh-pr-snapshot.ts +0 -0
  618. /package/scripts/{git → gh}/git-gh-reachability.ts +0 -0
  619. /package/scripts/{git → gh}/git-gh-repo.ts +0 -0
  620. /package/scripts/{git → gh}/git-gh-rest-state.ts +0 -0
  621. /package/scripts/{git → gh}/git-pr-checks-watch.ts +0 -0
  622. /package/scripts/{git → gh}/git-pr-error.ts +0 -0
  623. /package/scripts/{git → gh}/git-pr-messages.ts +0 -0
  624. /package/scripts/{git → gh}/github-issue-url.ts +0 -0
  625. /package/scripts/git/{stash-orphans.ts → stash/stash-orphans.ts} +0 -0
  626. /package/scripts/{git → issue}/issue-reference.ts +0 -0
  627. /package/scripts/{git → lib}/animation-helpers.ts +0 -0
  628. /package/scripts/{git → lib}/git-animation.ts +0 -0
  629. /package/scripts/{git → notify}/git-notify.ts +0 -0
  630. /package/scripts/{git → notify}/telegram-test-logic.ts +0 -0
@@ -1,32 +1,38 @@
1
1
  #!/usr/bin/env tsx
2
2
  import {
3
+ FETCH_TIMEOUT_MS,
3
4
  RUN_LANE_LABEL,
4
5
  RUN_SOLO_LABEL,
5
6
  agent_role_profile,
6
7
  backlog_budget,
7
8
  filing_cap,
8
9
  git_gh_api_path,
10
+ git_gh_command,
9
11
  git_gh_exec,
10
12
  has_label_name,
11
13
  issue_cite,
12
14
  lane_background,
15
+ lane_handoff,
13
16
  lane_park,
14
17
  lane_registry,
15
18
  process_identity,
19
+ process_owner_schema,
16
20
  repo_party,
17
21
  run_carry,
18
22
  run_cut,
23
+ run_event_stream,
24
+ run_event_stream_emit,
19
25
  run_headless,
20
26
  run_hold,
21
27
  run_invocation
22
- } from "./chunk-RLDX5SOC.js";
28
+ } from "./chunk-AIOIOMPX.js";
23
29
  import {
24
30
  session_language
25
31
  } from "./chunk-6V5OPIUU.js";
26
32
  import {
27
33
  hook_decision,
28
34
  lane_child_marker
29
- } from "./chunk-WQ4OSBSS.js";
35
+ } from "./chunk-MKVGBQPA.js";
30
36
  import {
31
37
  PROJECT_ROOT,
32
38
  json_value,
@@ -34,7 +40,7 @@ import {
34
40
  time_density_hook,
35
41
  time_hook_transcript,
36
42
  time_reported_failure
37
- } from "./chunk-7VPDUBRN.js";
43
+ } from "./chunk-4JZDP5X5.js";
38
44
  import "./chunk-WPALEIRX.js";
39
45
  import "./chunk-RKUAD3I6.js";
40
46
 
@@ -62,6 +68,23 @@ async function josh_run(args, should_forward_stderr = false, timeout_ms) {
62
68
  }
63
69
  var josh_command = { josh_run };
64
70
 
71
+ // scripts/lane/lane-seed.ts
72
+ var FIRST_LANE_SEAT = 1;
73
+ var LAST_LANE_SEAT = 9;
74
+ function free_seats(used) {
75
+ const taken = new Set(used);
76
+ const free = [];
77
+ for (let seat = FIRST_LANE_SEAT; seat <= LAST_LANE_SEAT; seat += 1) {
78
+ if (!taken.has(seat)) free.push(seat);
79
+ }
80
+ return free;
81
+ }
82
+ var lane_seed_policy = {
83
+ FIRST_LANE_SEAT,
84
+ LAST_LANE_SEAT,
85
+ free_seats
86
+ };
87
+
65
88
  // scripts/lane/lane-capacity.ts
66
89
  var DEFAULT_LANE_LIMIT = 6;
67
90
  var LANE_LIMIT_KEY = "JOSH_LANE_LIMIT";
@@ -82,12 +105,10 @@ function lane_limit(environment = process.env) {
82
105
  return read_limit(environment[LANE_LIMIT_KEY]);
83
106
  }
84
107
  function free_lanes(limit, occupied) {
85
- return Math.max(NO_LANES, limit - occupied);
108
+ return Math.max(NO_LANES, Math.min(limit, lane_seed_policy.LAST_LANE_SEAT) - occupied);
86
109
  }
87
110
  var lane_capacity = {
88
- DEFAULT_LANE_LIMIT,
89
111
  LANE_LIMIT_KEY,
90
- read_limit,
91
112
  lane_limit,
92
113
  free_lanes
93
114
  };
@@ -96,26 +117,31 @@ var lane_capacity = {
96
117
  var ISSUE_NUMBER = /#\d+/gu;
97
118
  var REFERENCE_BOUNDARY = /[\s#()[\]<>|]/u;
98
119
  var OWNER_REPO = /^[^\s/#]+\/[^\s/#]+$/u;
99
- var MARKDOWN_LINK = /\[([^[\]]*)\]\([^()]*\)/gu;
120
+ var MARKDOWN_LINK = /\[[^[\]]*\]\([^()]*\)/gu;
121
+ var NUMBER_CONTINUATION = /^(?:\w|-[a-z])/iu;
122
+ var CONTINUATION_WIDTH = 2;
123
+ var GLUED_LEAD = /[&./]/u;
100
124
  var FENCE_MARKER = /^\s*(?:`{3,}|~{3,})/u;
101
125
  var QUOTE_LINE = /^\s*>/u;
102
126
  var PR_PREFIX = /\b(?:pr|pull request)\s*$/iu;
103
127
  var BACKTICK_PAIR = 2;
104
- function text_span_covers(link, index) {
105
- const start = (link.index ?? 0) + 1;
106
- const end = start + (link[1] ?? "").length;
107
- return index >= start && index < end;
128
+ function link_covers(link, index) {
129
+ const start = link.index ?? 0;
130
+ return index >= start && index < start + link[0].length;
108
131
  }
109
132
  function is_linked_at(line, index) {
110
133
  for (const link of line.matchAll(MARKDOWN_LINK)) {
111
- if (text_span_covers(link, index)) return true;
134
+ if (link_covers(link, index)) return true;
112
135
  }
113
136
  return false;
114
137
  }
115
- function repo_prefix(message2, hash_index) {
138
+ function lead_token(message2, hash_index) {
116
139
  let start = hash_index;
117
140
  while (start > 0 && !REFERENCE_BOUNDARY.test(message2.charAt(start - 1))) start -= 1;
118
- const token = message2.slice(start, hash_index);
141
+ return message2.slice(start, hash_index);
142
+ }
143
+ function repo_prefix(message2, hash_index) {
144
+ const token = lead_token(message2, hash_index);
119
145
  return OWNER_REPO.test(token) ? token : "";
120
146
  }
121
147
  function is_inline_code_at(line, index) {
@@ -126,13 +152,16 @@ function is_bare_at(line, index) {
126
152
  if (is_linked_at(line, index) || is_inline_code_at(line, index)) return false;
127
153
  return !PR_PREFIX.test(line.slice(0, index));
128
154
  }
155
+ function is_glued(line, reference) {
156
+ const end = reference.index + reference.text.length;
157
+ if (NUMBER_CONTINUATION.test(line.slice(end, end + CONTINUATION_WIDTH))) return true;
158
+ return reference.prefix === "" && GLUED_LEAD.test(lead_token(line, reference.index));
159
+ }
129
160
  function line_references(line) {
130
161
  const references = [];
131
162
  for (const match of line.matchAll(ISSUE_NUMBER)) {
132
- const { index } = match;
133
- if (is_bare_at(line, index)) {
134
- references.push({ index, prefix: repo_prefix(line, index), text: match[0] });
135
- }
163
+ const reference = { index: match.index, prefix: repo_prefix(line, match.index), text: match[0] };
164
+ if (!is_glued(line, reference) && is_bare_at(line, match.index)) references.push(reference);
136
165
  }
137
166
  return references;
138
167
  }
@@ -231,144 +260,6 @@ function message(children, repo) {
231
260
  }
232
261
  var epic_triage = { TRIAGE_VERDICT, is_triaged, message, untriaged };
233
262
 
234
- // scripts/run/run-event-stream.ts
235
- import { z } from "zod";
236
- var EVENT_PREFIX = "josh-run-events-";
237
- var EVENT_SUFFIX = ".jsonl";
238
- var EVENT_CAP = 500;
239
- var FIRST_POSITION = 0;
240
- var POSITION_INCREMENT = 1;
241
- var LINE_SEPARATOR = "\n";
242
- var EVENT_KIND = {
243
- PLAN: "plan",
244
- CHILD_LAUNCH: "child-launch",
245
- MERGE: "merge",
246
- PARK: "park",
247
- SPLIT: "split",
248
- OUTAGE: "outage",
249
- CUT: "cut",
250
- // The backlog emptied while nothing of the run's own was in flight — the drain
251
- // (joshuafolkken/kit#2335). It marks the position at which the end-of-run retrospective is owed,
252
- // *before* the idle watch opens, so `run:step` fires the retrospective at the drain rather than after
253
- // the watch runs its course. It is not itself a stop: the run watches on once the retrospective has
254
- // run, and the real `STOP` follows when the watch expires.
255
- DRAIN: "drain",
256
- STOP: "stop",
257
- PR_OPENED: "pr-opened",
258
- REVIEW_ROUND: "review-round",
259
- // The end-of-run retrospective's result, recorded when the run marks the retrospective done
260
- // (joshuafolkken/kit#2342). A retrospective that files zero improvements and one that never ran look
261
- // the same from outside — no new Issue either way — so the result is put on the stream the report is
262
- // generated from: the issues filed (or that none were), and the candidates dropped with why. It is
263
- // emitted from the `run:carry --retrospective` close, so marking the retrospective done and recording
264
- // what it found are one action rather than two the run could do only one of.
265
- RETROSPECTIVE: "retrospective",
266
- // Ready backlog work is sitting undispatched while a lane is free and nothing has dispatched for a
267
- // while (joshuafolkken/kit#2359). Emitted once per stall episode by the stop-time detector, it is
268
- // both the dedup marker — `emit_once_since` refuses a second until a `CHILD_LAUNCH` intervenes
269
- // (joshuafolkken/kit#2464) — and the line a
270
- // terminal reader following the stream sees. `run:step` reads it as `backlog:next`, so a run that
271
- // stalled is pointed straight at dispatching the work rather than left waiting.
272
- STALL: "stall",
273
- // The run's own driver is gone: the cut handed the budget off, the owner has died, and no supervisor
274
- // is watching (joshuafolkken/kit#2375). Emitted once per strand episode by the stop-time detector,
275
- // exactly as `STALL` is — the newest-event dedup keeps a run polled every stop from notifying more
276
- // than once, and a terminal reader following the stream sees the line. The strand is the step before
277
- // the stall: a stalled run still has a driver that could dispatch, a stranded one has none.
278
- STRANDED: "stranded",
279
- // One `josh ship` stage starting, succeeding or failing (joshuafolkken/kit#2426). It is a trace of the
280
- // composite's progress rather than a position the run is at — the positions a ship leaves behind are
281
- // the closed issue its `followup` merges, or a detached supervisor's `SHIP_LAUNCH` / `SHIP_STOP` below
282
- // — so it is one of the `TRACE_KINDS` the last-event read skips.
283
- SHIP_STAGE: "ship-stage",
284
- // One progress watcher line — the `at … / next …` heartbeat `run:progress` prints
285
- // (joshuafolkken/kit#2437). Printed only to the watcher's own output, a headless successor's heartbeat
286
- // was buried in its log after a cut; on the stream it reaches the attached session's relay. It says
287
- // the run is alive rather than where it is, so it is a trace kind like `SHIP_STAGE`.
288
- HEARTBEAT: "heartbeat",
289
- // The post-implementation region handed to a detached `josh ship --detach` supervisor
290
- // (joshuafolkken/kit#2428). Unlike a stage trace it is a position: the agent has ended and the
291
- // supervisor carries the run, so `run:step` answers `wait` until it stops or the issue closes.
292
- SHIP_LAUNCH: "ship-launch",
293
- // The supervisor stopped at a failed stage — a red gate, a High/Medium review, a failed push, red CI
294
- // (joshuafolkken/kit#2428). The position that hands control back: `run:step` prints the command that
295
- // shows the stopped report, so the agent fixes it and relaunches rather than rebuilding the context.
296
- SHIP_STOP: "ship-stop"
297
- };
298
- var EVENT_KINDS = Object.values(EVENT_KIND);
299
- var TRACE_KINDS = /* @__PURE__ */ new Set([EVENT_KIND.SHIP_STAGE, EVENT_KIND.HEARTBEAT]);
300
- var event_schema = z.object({
301
- pos: z.number(),
302
- at: z.string(),
303
- kind: z.string(),
304
- text: z.string()
305
- });
306
- function is_event_kind(value) {
307
- return EVENT_KINDS.includes(value);
308
- }
309
- function target_of(repository) {
310
- return stamp_file.stamp_path(EVENT_PREFIX, repository, EVENT_SUFFIX);
311
- }
312
- function is_present(event) {
313
- return event !== void 0;
314
- }
315
- function parse_line(line) {
316
- return event_schema.safeParse(json_value.parse_or_undefined(line)).data;
317
- }
318
- function read_events(target) {
319
- const raw = stamp_file.read_stamp_text(target);
320
- if (raw === void 0) return [];
321
- return raw.split(LINE_SEPARATOR).map((line) => line.trim()).filter((line) => line.length > 0).map((line) => parse_line(line)).filter(is_present);
322
- }
323
- function last_position(events) {
324
- return events[events.length - POSITION_INCREMENT]?.pos ?? FIRST_POSITION;
325
- }
326
- function serialize(events) {
327
- return `${events.map((event) => JSON.stringify(event)).join(LINE_SEPARATOR)}${LINE_SEPARATOR}`;
328
- }
329
- function append(target, kind, text2, at) {
330
- if (!is_event_kind(kind)) return { appended: false, position: FIRST_POSITION };
331
- const existing = read_events(target);
332
- const position = last_position(existing) + POSITION_INCREMENT;
333
- const bounded = [...existing, { pos: position, at, kind, text: text2 }].slice(-EVENT_CAP);
334
- stamp_file.write_text_stamp(target, serialize(bounded));
335
- return { appended: true, position };
336
- }
337
- function read_from(target, position) {
338
- const events = read_events(target);
339
- return {
340
- events: events.filter((event) => event.pos > position),
341
- next_position: last_position(events)
342
- };
343
- }
344
- function read_last(target) {
345
- return read_events(target).findLast((event) => !TRACE_KINDS.has(event.kind));
346
- }
347
- function has_since(events, kind, reset_kind) {
348
- const reset_at = events.findLastIndex((event) => event.kind === reset_kind);
349
- return events.slice(reset_at + POSITION_INCREMENT).some((event) => event.kind === kind);
350
- }
351
- var FIELD_SEPARATOR = " \xB7 ";
352
- function format_event(event) {
353
- return [event.at, event.kind, event.text].join(FIELD_SEPARATOR);
354
- }
355
- var run_event_stream = {
356
- EVENT_CAP,
357
- EVENT_KIND,
358
- EVENT_KINDS,
359
- EVENT_PREFIX,
360
- EVENT_SUFFIX,
361
- TRACE_KINDS,
362
- append,
363
- format_event,
364
- has_since,
365
- is_event_kind,
366
- read_events,
367
- read_from,
368
- read_last,
369
- target_of
370
- };
371
-
372
263
  // scripts/backlog/backlog-stalled.ts
373
264
  var STALL_THRESHOLD_MINUTES = 10;
374
265
  var MS_PER_MINUTE = 6e4;
@@ -420,7 +311,6 @@ var backlog_stalled = {
420
311
  count_ready_tokens,
421
312
  describe,
422
313
  dispatch_age_ms,
423
- is_stalled,
424
314
  needs_triage,
425
315
  ready_tokens
426
316
  };
@@ -428,12 +318,20 @@ var backlog_stalled = {
428
318
  // scripts/backlog/backlog-ready.ts
429
319
  var NO_FREE = 0;
430
320
  var NONE2 = 0;
321
+ async function free_under(limit) {
322
+ const lanes = await lane_registry.list_lanes();
323
+ const live = lanes.filter((lane) => !lane.is_stranded).length;
324
+ return lane_capacity.free_lanes(limit, live);
325
+ }
431
326
  async function free_lane_count() {
432
327
  const limit = lane_capacity.lane_limit();
433
328
  if (limit.kind !== "limit") return NO_FREE;
434
- const lanes = await lane_registry.list_lanes();
435
- const live = lanes.filter((lane) => !lane.is_stranded).length;
436
- return lane_capacity.free_lanes(limit.limit, live);
329
+ return await free_under(limit.limit);
330
+ }
331
+ async function drive_free_lane_count() {
332
+ const limit = lane_capacity.lane_limit();
333
+ if (limit.kind !== "limit") throw new Error(limit.problem);
334
+ return await free_under(limit.limit);
437
335
  }
438
336
  function drains_pool(carry) {
439
337
  return carry === void 0 || !run_invocation.has_only(carry.invocation);
@@ -452,19 +350,23 @@ async function read_ready(ports = DEFAULT_PORTS) {
452
350
  if (free_lanes2 <= NO_FREE) return { issues: [], free_lanes: free_lanes2 };
453
351
  return { issues: await ports.ready_issues(), free_lanes: free_lanes2 };
454
352
  }
455
- function ready_line(reading) {
353
+ function ready_line(reading, slug) {
456
354
  if (reading.issues.length === NONE2 || reading.free_lanes <= NO_FREE) return void 0;
457
- const issues = reading.issues.map((issue) => `#${issue}`).join(" ");
355
+ const cite = issue_cite.citer(slug, /* @__PURE__ */ new Map());
356
+ const issues = reading.issues.map((issue) => cite(issue)).join(" ");
458
357
  return `ready ${issues} \xB7 free lanes ${String(reading.free_lanes)}`;
459
358
  }
460
- async function parent_ready_line(ports, is_parent) {
359
+ async function parent_ready_line(ports, is_parent, read_repo) {
461
360
  if (!await is_parent()) return void 0;
462
- return ready_line(await read_ready(ports));
361
+ const reading = await read_ready(ports);
362
+ return reading.issues.length === NONE2 ? void 0 : ready_line(reading, await read_repo());
463
363
  }
464
- async function print_ready_line(ports = DEFAULT_PORTS, is_parent = run_headless.is_backlog_parent) {
364
+ function print_line(line) {
365
+ if (line !== void 0) console.info(line);
366
+ }
367
+ async function print_ready_line(ports = DEFAULT_PORTS, is_parent = run_headless.is_backlog_parent, read_repo = git_gh_command.repo_get_name_with_owner) {
465
368
  try {
466
- const line = await parent_ready_line(ports, is_parent);
467
- if (line !== void 0) console.info(line);
369
+ print_line(await parent_ready_line(ports, is_parent, read_repo));
468
370
  } catch {
469
371
  }
470
372
  }
@@ -481,6 +383,7 @@ var backlog_ready = {
481
383
  read_backlog_next,
482
384
  print_offer_hint,
483
385
  free_lane_count,
386
+ drive_free_lane_count,
484
387
  drains_pool,
485
388
  print_ready_line,
486
389
  read_ready,
@@ -508,12 +411,17 @@ function get_repo_name_with_owner_within(timeout_ms) {
508
411
  }
509
412
  var gh_spawn = { get_repo_name_with_owner, get_repo_name_with_owner_within };
510
413
 
511
- // scripts/git/telegram-notify.ts
512
- import { z as z2 } from "zod";
414
+ // scripts/lib/timed-fetch.ts
415
+ async function timed_fetch(url, init = {}, timeout_ms = FETCH_TIMEOUT_MS) {
416
+ return await fetch(url, { ...init, signal: AbortSignal.timeout(timeout_ms) });
417
+ }
418
+
419
+ // scripts/notify/telegram-notify.ts
420
+ import { z } from "zod";
513
421
  var TELEGRAM_API_BASE = "https://api.telegram.org";
514
- var telegram_environment_schema = z2.object({
515
- telegram_bot_token: z2.string().min(1, { message: "TELEGRAM_BOT_TOKEN is required" }),
516
- telegram_chat_id: z2.string().min(1, { message: "TELEGRAM_CHAT_ID is required" })
422
+ var telegram_environment_schema = z.object({
423
+ telegram_bot_token: z.string().min(1, { message: "TELEGRAM_BOT_TOKEN is required" }),
424
+ telegram_chat_id: z.string().min(1, { message: "TELEGRAM_CHAT_ID is required" })
517
425
  });
518
426
  var TASK_DEFINITIONS = {
519
427
  planning: { icon: "\u{1F4CB}", label: "Planning" },
@@ -599,7 +507,7 @@ function build_text(input) {
599
507
  }
600
508
  async function post_message(config, text2) {
601
509
  const url = `${TELEGRAM_API_BASE}/bot${config.bot_token}/sendMessage`;
602
- const response = await fetch(url, {
510
+ const response = await timed_fetch(url, {
603
511
  method: "POST",
604
512
  headers: { "Content-Type": "application/json" },
605
513
  body: JSON.stringify({ chat_id: config.chat_id, text: text2 })
@@ -698,7 +606,6 @@ async function stranded(input) {
698
606
  );
699
607
  }
700
608
  var telegram_notify = {
701
- REPO_LOOKUP_TIMEOUT_MS,
702
609
  confirm,
703
610
  send,
704
611
  send_or_report,
@@ -707,125 +614,6 @@ var telegram_notify = {
707
614
  warn
708
615
  };
709
616
 
710
- // scripts/run/run-event-scope.ts
711
- var SINCE_SCOPE = "since";
712
- var UNKNOWN_SCOPE = "unknown";
713
- var UNKNOWN_EVENT_SCOPE = { kind: UNKNOWN_SCOPE };
714
- function moment_of(at) {
715
- const parsed = Date.parse(at);
716
- return Number.isNaN(parsed) ? void 0 : parsed;
717
- }
718
- function is_within(event, floor) {
719
- const at = moment_of(event.at);
720
- return at !== void 0 && at >= floor;
721
- }
722
- function scoped_events(events, scope) {
723
- if (scope.kind === UNKNOWN_SCOPE) return void 0;
724
- const floor = moment_of(scope.started_at);
725
- if (floor === void 0) return void 0;
726
- return events.filter((event) => is_within(event, floor));
727
- }
728
- function scope_of(read) {
729
- if (read.kind === "carried" || read.kind === "expired") {
730
- return { kind: SINCE_SCOPE, started_at: read.carry.started_at };
731
- }
732
- return UNKNOWN_EVENT_SCOPE;
733
- }
734
- function last_scoped_event(events, scope) {
735
- return scoped_events(events, scope)?.findLast(
736
- (event) => !run_event_stream.TRACE_KINDS.has(event.kind)
737
- );
738
- }
739
- var SHIP_POSITION_KINDS = /* @__PURE__ */ new Set([
740
- run_event_stream.EVENT_KIND.SHIP_LAUNCH,
741
- run_event_stream.EVENT_KIND.SHIP_STOP
742
- ]);
743
- function is_foreign_ship_event(event, issue) {
744
- return SHIP_POSITION_KINDS.has(event.kind) && !event.text.startsWith(`#${issue} `);
745
- }
746
- function is_own_ship_event(event, issue) {
747
- return SHIP_POSITION_KINDS.has(event.kind) && !is_foreign_ship_event(event, issue);
748
- }
749
- function last_issue_event(events, scope, issue) {
750
- const own = events.filter((event) => !is_foreign_ship_event(event, issue));
751
- if (scope.kind === SINCE_SCOPE) return last_scoped_event(own, scope);
752
- return own.findLast((event) => is_own_ship_event(event, issue));
753
- }
754
- var run_event_scope = {
755
- UNKNOWN_EVENT_SCOPE,
756
- last_issue_event,
757
- last_scoped_event,
758
- scope_of,
759
- scoped_events
760
- };
761
-
762
- // scripts/run/run-event-stream-emit.ts
763
- function now_iso() {
764
- return (/* @__PURE__ */ new Date()).toISOString();
765
- }
766
- async function stream_target() {
767
- const repository = await run_carry.repository_directory();
768
- return repository === void 0 ? void 0 : run_event_stream.target_of(repository);
769
- }
770
- async function emit(kind, text2) {
771
- try {
772
- const target = await stream_target();
773
- if (target === void 0) return;
774
- run_event_stream.append(target, kind, text2, now_iso());
775
- } catch {
776
- }
777
- }
778
- async function emit_once(kind, text2) {
779
- try {
780
- const target = await stream_target();
781
- if (target === void 0 || run_event_stream.read_last(target)?.kind === kind) return false;
782
- return run_event_stream.append(target, kind, text2, now_iso()).appended;
783
- } catch {
784
- return false;
785
- }
786
- }
787
- function invocation_events(repository, target) {
788
- const events = run_event_stream.read_events(target);
789
- const scope = run_event_scope.scope_of(run_carry.read_carry(run_carry.carry_path(repository)));
790
- return run_event_scope.scoped_events(events, scope) ?? events;
791
- }
792
- async function emit_once_since(kind, text2, reset_kind) {
793
- try {
794
- const repository = await run_carry.repository_directory();
795
- if (repository === void 0) return false;
796
- const target = run_event_stream.target_of(repository);
797
- if (run_event_stream.has_since(invocation_events(repository, target), kind, reset_kind)) {
798
- return false;
799
- }
800
- return run_event_stream.append(target, kind, text2, now_iso()).appended;
801
- } catch {
802
- return false;
803
- }
804
- }
805
- async function emit_heartbeat(line) {
806
- await emit(run_event_stream.EVENT_KIND.HEARTBEAT, line);
807
- }
808
- async function current_events() {
809
- try {
810
- const repository = await run_carry.repository_directory();
811
- if (repository === void 0) return [];
812
- const read = run_carry.read_carry(run_carry.carry_path(repository));
813
- const scope = run_event_scope.scope_of(read);
814
- const events = run_event_stream.read_events(run_event_stream.target_of(repository));
815
- return run_event_scope.scoped_events(events, scope) ?? [];
816
- } catch {
817
- return [];
818
- }
819
- }
820
- var run_event_stream_emit = {
821
- current_events,
822
- emit,
823
- emit_heartbeat,
824
- emit_once,
825
- emit_once_since,
826
- stream_target
827
- };
828
-
829
617
  // scripts/backlog/backlog-stalled-detect.ts
830
618
  var NO_FREE2 = 0;
831
619
  var NO_READY = 0;
@@ -888,23 +676,24 @@ async function run_stall_check(ready = backlog_ready.DEFAULT_PORTS) {
888
676
  } catch {
889
677
  }
890
678
  }
891
- var backlog_stalled_detect = { DEFAULT_PORTS: DEFAULT_PORTS2, detect_and_report, gather, report, run_stall_check };
679
+ var backlog_stalled_detect = { detect_and_report, run_stall_check };
892
680
 
893
681
  // scripts/rules/last-prompt.ts
894
- import { z as z3 } from "zod";
682
+ import { z as z2 } from "zod";
895
683
  var WORKFLOW_KEYWORDS = /* @__PURE__ */ new Set([
896
684
  "kickoff",
897
685
  "fullrun",
898
686
  "halfrun",
687
+ "prrun",
899
688
  "backlogrun"
900
689
  ]);
901
690
  var NO_PROMPT = "";
902
691
  var HUMAN_ORIGIN = "human";
903
692
  var KEYWORD_BEFORE_ARGUMENT = -2;
904
- var PROMPT_LINE_SCHEMA = z3.object({
905
- isMeta: z3.boolean().nullish(),
906
- origin: z3.object({ kind: z3.string().nullish() }).nullish(),
907
- message: z3.object({ content: z3.unknown() })
693
+ var PROMPT_LINE_SCHEMA = z2.object({
694
+ isMeta: z2.boolean().nullish(),
695
+ origin: z2.object({ kind: z2.string().nullish() }).nullish(),
696
+ message: z2.object({ content: z2.unknown() })
908
697
  });
909
698
  function is_person(line) {
910
699
  if (line.isMeta === true) return false;
@@ -931,7 +720,7 @@ function prompt_text(tail) {
931
720
  var last_prompt = { prompt_text };
932
721
 
933
722
  // scripts/rules/stop-rules.ts
934
- import { z as z4 } from "zod";
723
+ import { z as z3 } from "zod";
935
724
 
936
725
  // scripts/rules/filing-offer.ts
937
726
  var OFFER_PATTERNS = [
@@ -1034,19 +823,19 @@ function is_mismatch(message2, lang) {
1034
823
  if (letter_count(prose) < MIN_PROSE_LETTERS) return false;
1035
824
  return matches_share(prose, script, pattern) < MATCH_SHARE_FLOOR;
1036
825
  }
1037
- var reply_language = { MIN_PROSE_LETTERS, is_mismatch, script_of };
826
+ var reply_language = { is_mismatch, script_of };
1038
827
 
1039
828
  // scripts/rules/stop-rules.ts
1040
829
  var SWITCH_ENV_KEY = "JOSH_STOP_GUARD";
1041
830
  var BLOCK_DECISION = "block";
1042
- var stop_payload_schema = z4.object({
1043
- transcript_path: z4.string().min(1),
1044
- stop_hook_active: z4.boolean().nullish(),
1045
- last_assistant_message: z4.string().nullish()
831
+ var stop_payload_schema = z3.object({
832
+ transcript_path: z3.string().min(1),
833
+ stop_hook_active: z3.boolean().nullish(),
834
+ last_assistant_message: z3.string().nullish()
1046
835
  });
1047
836
  var NO_OUTCOME = { reason: void 0 };
1048
837
  var STOP_NOTIFY_REASON = '\u26D4 mid-workflow stop notification: this working tree is still held by a run and no `confirmation` Telegram was sent this turn, so a person is being left to wait off-screen without knowing the run paused. `CLAUDE.md` \u2192 "Mid-workflow stop notification" requires `pnpm josh notify --task-type confirmation --issue-url "<url>" --body=$\'<reason>\'` before any mid-workflow pause. Send it, then end with a one-line confirmation that it was sent \u2014 do not repeat your previous reply. This fires only while the hold is held and no notify is on the transcript, and `stop_hook_active` lets a second stop through so a run is never wedged.';
1049
- var HOLD_RELEASE_REASON = "\u26D4 working-tree hold not released: this working tree is clean but its `run:hold` record is still in place, so the next run here runs `git switch main && git pull` believing the tree is free while you hold it. `.claude/skills/workflow-commands/SKILL.md` \u2192 \xA72f: a stop that leaves the tree clean releases the hold with `pnpm josh run:release <N>` (bare for a `new` entry). A `halfrun` pre-commit stop and a `needs-human-review` stop keep the hold because their tree is dirty \u2014 this row is silent there. Release it, then end with a one-line confirmation that it was released \u2014 do not repeat your previous reply.";
838
+ var HOLD_RELEASE_REASON = "\u26D4 working-tree hold not released: this working tree is clean but its `run:hold` record is still in place, so the next run here runs `git switch main && git pull` believing the tree is free while you hold it. `.claude/skills/workflow-commands/SKILL.md` \u2192 \xA72f: a stop that leaves the tree clean releases the hold with `pnpm josh run:release <N>` (bare for a `new` entry). A `halfrun` pre-commit stop and a `needs-human-review` stop keep the hold because their tree is dirty, and a `prrun` stop keeps it by its stop mark \u2014 this row is silent there. Release it, then end with a one-line confirmation that it was released \u2014 do not repeat your previous reply.";
1050
839
  var ISSUE_CITATION_REASON = "Session-facing output cites an Issue as a number-link so the reader can click through and see which repository it is (`CLAUDE.md`, `prompts/collaboration-workflow/issue-citation.md`).";
1051
840
  function build_citation_reason(references) {
1052
841
  const numbers = references.join(", ");
@@ -1056,8 +845,8 @@ function build_citation_reason(references) {
1056
845
  var FILING_OFFER_REASON = '\u26D4 filing offer: your reply offers to file an Issue instead of filing it. Filing into a first-party repository is Tier A \u2014 the trigger is the judgement that it is worth filing, not the run\'s progress (`.claude/skills/workflow-commands/SKILL.md` \u2192 \xA72i, `observation-filing.md`). Run `pnpm josh issue:file "<title>" --body-file <path> --depth <0|1|2>` \u2014 it scouts, lints, labels and runs `epic:bundle` itself \u2014 then end with the one-line citation of what was filed; do not repeat your previous reply. If it is not worth filing after all, say so in one line instead.';
1057
846
  var HEADLESS_WAIT_MARKER = "\u26D4 headless parent:";
1058
847
  var HEADLESS_REFUSAL_CAP = 3;
1059
- var HEADLESS_WAIT_CALLS = ['"command":"pnpm josh lane:await', '"command":"pnpm josh run:progress'];
1060
- var HEADLESS_WAIT_BODY = ' this is a `claude -p` `backlogrun` parent (`JOSH_RUN_HEADLESS`) with lanes still in flight, and ending this turn ends the process \u2014 its background waits are killed with it and the lanes are left without a parent. Wait in the foreground instead: run `pnpm josh lane:await <N...>` for the in-flight lanes (and `pnpm josh run:progress --wait` for the heartbeat) as foreground commands within the tool timeout, act on what they report, and continue the loop. End the turn only after `pnpm josh run:carry --cut` or `--end` (`backlogrun-progress.md` \u2192 "The parent keeps no clock of its own").';
848
+ var HEADLESS_WAIT_CALLS = ['"command":"pnpm josh lane:await'];
849
+ var HEADLESS_WAIT_BODY = ' this is a `claude -p` `backlogrun` parent (`JOSH_RUN_HEADLESS`) with lanes still in flight, and ending this turn ends the process \u2014 its background waits are killed with it and the lanes are left without a parent. Wait in the foreground instead: run `pnpm josh lane:await <N...>` for the in-flight lanes as a foreground command within the tool timeout (with `pnpm josh run:progress --wait` in the background for the heartbeat, which streams its reports itself and lives while this turn does), act on what it reports, and continue the loop. End the turn only after `pnpm josh run:carry --cut` or `--end` (`backlogrun-progress.md` \u2192 "The parent keeps no clock of its own").';
1061
850
  var HEADLESS_WAIT_REASON = `${HEADLESS_WAIT_MARKER}${HEADLESS_WAIT_BODY}`;
1062
851
  var INDEX_COMMAND_PATTERN = /git (?:add|stage|rm --cached|restore --staged|restore -S)\b/u;
1063
852
  var PERMISSION_PATTERN = /許可|承認|permission|approve|approval|authorization/iu;
@@ -1083,13 +872,13 @@ function needs_filing(context) {
1083
872
  return filing_offer.is_first_party_target(context.message, context.session_owner);
1084
873
  }
1085
874
  function is_held_idle(context) {
1086
- return context.hold_present && !context.agent_pending;
875
+ return context.hold_present && !context.agent_pending && !context.handed_off;
1087
876
  }
1088
877
  function needs_notify(context) {
1089
878
  return is_held_idle(context) && !context.notified;
1090
879
  }
1091
880
  function needs_release(context) {
1092
- return is_held_idle(context) && context.tree_clean;
881
+ return is_held_idle(context) && context.tree_clean && !context.prrun_stopped;
1093
882
  }
1094
883
  function citation_reason(context) {
1095
884
  const references = issue_citation.unquoted_references(context.message, context.prompt);
@@ -1147,7 +936,6 @@ var stop_rules = {
1147
936
  STOP_NOTIFY_REASON,
1148
937
  SWITCH_ENV_KEY,
1149
938
  block_envelope,
1150
- block_reason,
1151
939
  build_language_reason,
1152
940
  count_headless_refusals,
1153
941
  is_enabled,
@@ -1155,6 +943,67 @@ var stop_rules = {
1155
943
  stop_outcome
1156
944
  };
1157
945
 
946
+ // scripts/run/run-halfrun-resume.ts
947
+ var MARKED = "marked";
948
+ var FOREIGN = "foreign";
949
+ var UNREADABLE2 = "unreadable";
950
+ function hold_of(read) {
951
+ return read.kind === "held" || read.kind === "stale" ? read.hold : void 0;
952
+ }
953
+ function is_halfrun_stop(read, issue, is_dirty) {
954
+ const hold = hold_of(read);
955
+ return is_dirty && hold?.issue === issue && hold.is_halfrun_stop === true;
956
+ }
957
+ function is_own_record(read, issue) {
958
+ const hold = hold_of(read);
959
+ return hold === void 0 || hold.issue === issue || hold.issue === run_hold.UNNUMBERED_ISSUE;
960
+ }
961
+ function mark_stop_at(target, issue, mark = run_hold.HALFRUN_STOP_FIELDS) {
962
+ const read = run_hold.read_hold(target);
963
+ if (read.kind === "unreadable") return UNREADABLE2;
964
+ if (!is_own_record(read, issue)) return FOREIGN;
965
+ run_hold.release_hold(target);
966
+ return run_hold.create_stop_hold(target, issue, mark) ? MARKED : FOREIGN;
967
+ }
968
+ function take_over(target, issue) {
969
+ run_hold.release_hold(target);
970
+ return run_hold.create_hold(target, issue, /* @__PURE__ */ new Date(), true);
971
+ }
972
+ function adopt_at(target, issue, is_dirty) {
973
+ if (!is_halfrun_stop(run_hold.read_hold(target), issue, is_dirty)) return false;
974
+ return take_over(target, issue);
975
+ }
976
+ async function hold_target() {
977
+ try {
978
+ const directory = await run_hold.worktree_directory();
979
+ return directory === void 0 ? void 0 : run_hold.hold_path(directory);
980
+ } catch {
981
+ return void 0;
982
+ }
983
+ }
984
+ async function is_pending(issue) {
985
+ const target = await hold_target();
986
+ if (target === void 0) return false;
987
+ return is_halfrun_stop(run_hold.read_hold(target), issue, await run_hold.is_tree_dirty());
988
+ }
989
+ async function adopt(issue) {
990
+ const target = await hold_target();
991
+ if (target === void 0) return false;
992
+ return adopt_at(target, issue, await run_hold.is_tree_dirty());
993
+ }
994
+ var run_halfrun_resume = {
995
+ FOREIGN,
996
+ MARKED,
997
+ UNREADABLE: UNREADABLE2,
998
+ adopt,
999
+ adopt_at,
1000
+ hold_of,
1001
+ hold_target,
1002
+ is_pending,
1003
+ mark_stop_at,
1004
+ take_over
1005
+ };
1006
+
1158
1007
  // scripts/run/run-stranded.ts
1159
1008
  var RECOVERY_COMMAND = "pnpm josh run:wake --start";
1160
1009
  var LIVE = "live";
@@ -1194,7 +1043,7 @@ var run_stranded = {
1194
1043
  };
1195
1044
 
1196
1045
  // scripts/run/run-wake.ts
1197
- import { z as z5 } from "zod";
1046
+ import { z as z4 } from "zod";
1198
1047
  var WAKE_PREFIX = "josh-run-wake-";
1199
1048
  var WAKE_LOG_PREFIX = "josh-run-wake-log-";
1200
1049
  var WAKE_LOG_SUFFIX = ".log";
@@ -1214,21 +1063,19 @@ var STOP_REASONS = {
1214
1063
  expired: "expired",
1215
1064
  unreadable: "unreadable"
1216
1065
  };
1217
- var run_wake_schema = z5.object({
1218
- invocation: z5.string(),
1219
- started_at: z5.string(),
1220
- pid: z5.number(),
1221
- process_start: z5.string().optional(),
1222
- woke: z5.number(),
1223
- woke_at: z5.string().optional(),
1066
+ var run_wake_schema = process_owner_schema.extend({
1067
+ invocation: z4.string(),
1068
+ started_at: z4.string(),
1069
+ woke: z4.number(),
1070
+ woke_at: z4.string().optional(),
1224
1071
  // **Every optional field of `RunWake` has to be listed here.** `z.object` strips what it does not
1225
1072
  // declare, so a field added to the interface alone round-trips through disk as `undefined` — which
1226
1073
  // reads as "no attempt has been made yet" and would restart the retry count on every pass.
1227
- attempts: z5.number().optional(),
1228
- woke_pid: z5.number().optional(),
1229
- held_at: z5.string().optional(),
1230
- spawned: z5.array(z5.string()).optional(),
1231
- idle_since: z5.string().optional(),
1074
+ attempts: z4.number().optional(),
1075
+ woke_pid: z4.number().optional(),
1076
+ held_at: z4.string().optional(),
1077
+ spawned: z4.array(z4.string()).optional(),
1078
+ idle_since: z4.string().optional(),
1232
1079
  profile: agent_role_profile.PROFILE_SCHEMA.optional()
1233
1080
  });
1234
1081
  function is_overdue(marked_at, now, limit_ms = WAKE_GRACE_MS) {
@@ -1380,7 +1227,6 @@ var run_wake = {
1380
1227
  IDLE_CEILING_MS,
1381
1228
  MAX_WAKE_ATTEMPTS,
1382
1229
  WAKE_GRACE_MS,
1383
- WAKE_PREFIX,
1384
1230
  claim,
1385
1231
  count_claim,
1386
1232
  count_wake,
@@ -1451,14 +1297,13 @@ async function run_stranded_check() {
1451
1297
  } catch {
1452
1298
  }
1453
1299
  }
1454
- var run_stranded_detect = { DEFAULT_PORTS: DEFAULT_PORTS3, detect_and_report: detect_and_report2, gather: gather2, report: report2, run_stranded_check };
1300
+ var run_stranded_detect = { detect_and_report: detect_and_report2, run_stranded_check };
1455
1301
 
1456
1302
  // scripts/hooks/stop-guard.ts
1457
- async function is_hold_present() {
1303
+ async function hold_facts() {
1458
1304
  const directory = await run_hold.worktree_directory();
1459
- if (directory === void 0) return false;
1460
- const read = run_hold.read_hold(run_hold.hold_path(directory));
1461
- return read.kind === "held" || read.kind === "stale";
1305
+ const hold = directory === void 0 ? void 0 : run_halfrun_resume.hold_of(run_hold.read_hold(run_hold.hold_path(directory)));
1306
+ return { hold_present: hold !== void 0, prrun_stopped: hold?.prrun_stop_head !== void 0 };
1462
1307
  }
1463
1308
  function transcript_tail(transcript_path) {
1464
1309
  const transcript = time_hook_transcript.transcript_of(transcript_path, void 0);
@@ -1473,7 +1318,7 @@ function session_lang() {
1473
1318
  async function build_context(transcript_path, payload_tail) {
1474
1319
  const tail = transcript_tail(transcript_path);
1475
1320
  return {
1476
- hold_present: await is_hold_present(),
1321
+ ...await hold_facts(),
1477
1322
  tree_clean: !await run_hold.is_tree_dirty(),
1478
1323
  notified: lane_park.mentions_confirmation_notify(tail),
1479
1324
  message: payload_tail.message,
@@ -1487,6 +1332,7 @@ async function build_context(transcript_path, payload_tail) {
1487
1332
  lane_child: lane_child_marker.is_child_of(process.cwd()),
1488
1333
  background_pending: lane_background.pending_background_ids(tail).length > 0,
1489
1334
  agent_pending: lane_background.pending_agent_ids(tail).length > 0,
1335
+ handed_off: lane_handoff.is_handed_off(process.cwd()),
1490
1336
  session_lang: session_lang()
1491
1337
  };
1492
1338
  }
@@ -1506,10 +1352,23 @@ async function outcome_of(raw_payload) {
1506
1352
  return stop_rules.NO_OUTCOME;
1507
1353
  }
1508
1354
  }
1509
- async function write_stop_decision(raw_payload) {
1510
- hook_decision.load_environment_file();
1355
+ async function has_run_record() {
1356
+ try {
1357
+ const directory = await run_carry.repository_directory();
1358
+ if (directory === void 0) return false;
1359
+ return run_carry.read_carry(run_carry.carry_path(directory)).kind === "carried";
1360
+ } catch {
1361
+ return false;
1362
+ }
1363
+ }
1364
+ async function run_report_checks() {
1365
+ if (!await has_run_record()) return;
1511
1366
  await backlog_stalled_detect.run_stall_check(backlog_ready.DEFAULT_PORTS);
1512
1367
  await run_stranded_detect.run_stranded_check();
1368
+ }
1369
+ async function write_stop_decision(raw_payload) {
1370
+ hook_decision.load_environment_file();
1371
+ await run_report_checks();
1513
1372
  const { reason } = await outcome_of(raw_payload);
1514
1373
  if (reason === void 0) return;
1515
1374
  process.stdout.write(`${stop_rules.block_envelope(reason, session_lang())}