@joshuafolkken/kit 1.1178.0 → 1.1240.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.
- package/.claude/.claude-plugin/plugin.json +1 -1
- package/.claude/settings.json +2 -2
- package/.claude/skills/dependency-update/SKILL.md +4 -8
- package/.claude/skills/epic-commands/SKILL.md +2 -2
- package/.claude/skills/epic-commands/epic-bundle.md +1 -1
- package/.claude/skills/workflow-commands/SKILL.md +2 -4
- package/.claude/skills/workflow-commands/backlogrun-child.md +6 -4
- package/.claude/skills/workflow-commands/backlogrun-lanes.md +7 -3
- package/.claude/skills/workflow-commands/backlogrun-park.md +23 -2
- package/.claude/skills/workflow-commands/backlogrun-progress.md +9 -4
- package/.claude/skills/workflow-commands/backlogrun-recovery.md +4 -3
- package/.claude/skills/workflow-commands/backlogrun-steps.md +21 -13
- package/.claude/skills/workflow-commands/chain-rule.md +1 -1
- package/.claude/skills/workflow-commands/delegation.md +2 -2
- package/.claude/skills/workflow-commands/followup.md +10 -0
- package/.claude/skills/workflow-commands/fullrun-steps.md +1 -1
- package/.claude/skills/workflow-commands/halfrun.md +1 -1
- package/.claude/skills/workflow-commands/issue-scout.md +1 -1
- package/.claude/skills/workflow-commands/kickoff.md +2 -1
- package/.claude/skills/workflow-commands/latest-gate.md +1 -1
- package/.claude/skills/workflow-commands/observation-ledger.md +3 -3
- package/.claude/skills/workflow-commands/pre-gate-cut.md +6 -1
- package/.claude/skills/workflow-commands/prerequisite.md +2 -2
- package/.claude/skills/workflow-commands/progress-watcher.md +1 -1
- package/.claude/skills/workflow-commands/working-tree-hold.md +1 -1
- package/.codex/hooks.json +2 -2
- package/.cursorrules +6 -41
- package/.github/actions/setup-node/action.yml +1 -1
- package/.github/workflows/auto-tag.yml +3 -4
- package/.github/workflows/ci.yml +32 -31
- package/.github/workflows/dependabot-auto-merge.yml +13 -6
- package/.github/workflows/publish.yml +50 -4
- package/.github/workflows/sonar-qube.yml +3 -0
- package/.pnpmfile.mjs +4 -3
- package/.prettierignore +8 -2
- package/CLAUDE.md +18 -20
- package/README.md +44 -38
- package/SECURITY.md +15 -1
- package/dist/CLAUDE.md +18 -20
- package/dist/commands/document-section-cli.js +734 -0
- package/dist/hooks/audit-provision.js +346 -0
- package/dist/hooks/batch-guard.js +5 -4
- package/dist/hooks/{chunk-G6KRCKEC.js → chunk-4TZVB44A.js} +496 -378
- package/dist/hooks/chunk-5VNDSNG3.js +12 -0
- package/dist/hooks/chunk-CDY4NFQG.js +15 -0
- package/dist/hooks/chunk-ELCN5LCH.js +135 -0
- package/dist/hooks/{chunk-VQLLNFNT.js → chunk-F3ELQ2AF.js} +3 -3
- package/dist/hooks/{chunk-I4XSL4TT.js → chunk-GPTFMK5E.js} +1 -1
- package/dist/hooks/{chunk-3V37IID6.js → chunk-JBBMAPC4.js} +23 -14
- package/dist/hooks/{chunk-UAGLLIGZ.js → chunk-KHGB5S3Y.js} +7 -6
- package/dist/hooks/{chunk-GDS5N2KB.js → chunk-KHX4U3BG.js} +735 -683
- package/dist/hooks/{chunk-VESKRQOF.js → chunk-KRBERBBI.js} +3 -3
- package/dist/hooks/{chunk-DO6NWWHU.js → chunk-QVSWU24O.js} +4 -4
- package/dist/hooks/{chunk-S6X6WYKR.js → chunk-WK2XSHSI.js} +1643 -923
- package/dist/hooks/{chunk-ZAL3NRGL.js → chunk-XZYKEM6J.js} +25 -10
- package/dist/hooks/{chunk-32GQTL4F.js → chunk-ZQGD4GBY.js} +4 -2
- package/dist/hooks/codex-hook-adapter.js +14 -12
- package/dist/hooks/duplicate-read-guard.js +6 -5
- package/dist/hooks/format-edited.js +4 -3
- package/dist/hooks/inputs.json +203 -179
- package/dist/hooks/investigation-guard.js +6 -5
- package/dist/hooks/pretool-guard.js +12 -10
- package/dist/hooks/session-lang.js +2 -4
- package/dist/hooks/stop-guard.js +66 -72
- package/dist/josh.js +1088 -78
- package/dist/version/index.d.ts +7 -2
- package/dist/version/index.js +152 -75
- package/eslint/base.js +23 -1
- package/eslint/rules/code-quality.js +3 -0
- package/eslint/rules/early-return-one-liner.js +98 -0
- package/eslint/rules/unicorn.js +16 -1
- package/package.json +7 -6
- package/pnpm-workspace.yaml +9 -4
- package/prettier/basic.d.ts +3 -1
- package/prettier/index.d.ts +3 -1
- package/prettier/static.d.ts +3 -1
- package/prompts/coding-standards.md +1 -1
- package/prompts/collaboration-workflow/file-edits.md +4 -4
- package/prompts/collaboration-workflow/glossary.md +1 -1
- package/prompts/collaboration-workflow/issue-template.md +1 -0
- package/prompts/collaboration-workflow/operating-rules.md +17 -9
- package/prompts/collaboration-workflow/overview.md +2 -2
- package/prompts/collaboration-workflow/principles.md +14 -12
- package/prompts/collaboration-workflow/report-format.md +1 -1
- package/prompts/collaboration-workflow/residency.md +1 -1
- package/prompts/collaboration-workflow/rule-delivery.md +6 -6
- package/prompts/collaboration-workflow/shell-body.md +6 -6
- package/prompts/collaboration-workflow/turn-batching.md +1 -1
- package/prompts/collaboration-workflow/upstream-interrupt.md +12 -2
- package/prompts/collaboration-workflow/wip-cap.md +10 -10
- package/prompts/review-rubric.md +1 -2
- package/prompts/review.md +1 -1
- package/scripts/agent/agent-headless.ts +29 -0
- package/scripts/agent/agent-launch-environment.ts +6 -2
- package/scripts/agent/codex-agent-argv.ts +2 -1
- package/scripts/auto-ok/auto-ok-cli.ts +1 -1
- package/scripts/backlog/backlog-arrival.ts +3 -3
- package/scripts/backlog/backlog-budget.ts +1 -1
- package/scripts/backlog/backlog-drive-args.ts +135 -0
- package/scripts/backlog/backlog-drive-cli.ts +11 -137
- package/scripts/backlog/backlog-drive-launch.ts +39 -0
- package/scripts/backlog/backlog-drive-named-offer.ts +3 -5
- package/scripts/backlog/backlog-drive-named.ts +3 -3
- package/scripts/backlog/backlog-drive-offer-argv.ts +1 -1
- package/scripts/backlog/backlog-drive-owner.ts +1 -1
- package/scripts/backlog/backlog-drive-restore.ts +1 -1
- package/scripts/backlog/backlog-drive-retrospective.ts +1 -1
- package/scripts/backlog/backlog-drive.ts +1 -1
- package/scripts/backlog/backlog-next.ts +16 -5
- package/scripts/backlog/backlog-offer-cli.ts +6 -6
- package/scripts/backlog/backlog-offer.ts +1 -1
- package/scripts/backlog/backlog-plan-cli.ts +1 -1
- package/scripts/backlog/backlog-pool.ts +57 -11
- package/scripts/backlog/backlog-ready.ts +1 -1
- package/scripts/backlog/backlog-scope.ts +1 -1
- package/scripts/backlog/backlog-stalled-detect.ts +2 -2
- package/scripts/backlog/backlog-stalled.ts +1 -1
- package/scripts/build/build-codex-hooks.ts +3 -1
- package/scripts/build/build-commands.ts +66 -0
- package/scripts/build/build-hooks.ts +2 -1
- package/scripts/build/build-library.ts +12 -3
- package/scripts/build/build.ts +70 -0
- package/scripts/build/local-bin.ts +3 -13
- package/scripts/delegation/investigation-reads.ts +3 -1
- package/scripts/discovery/repo-origin.ts +5 -5
- package/scripts/doctor/doctor-consumer.ts +2 -2
- package/scripts/doctor/doctor-io.ts +2 -3
- package/scripts/document/capped-print-part.ts +30 -0
- package/scripts/document/capped-print.ts +3 -4
- package/scripts/document/document-byte-budget.ts +11 -2
- package/scripts/document/document-scan.ts +117 -0
- package/scripts/document/document-section.ts +143 -16
- package/scripts/document/entry-read-budget.ts +5 -3
- package/scripts/document/entry-read-set.ts +10 -89
- package/scripts/document/read-set-cost.ts +98 -0
- package/scripts/epic/epic-add-body.ts +1 -0
- package/scripts/epic/epic-audit-checks.ts +1 -1
- package/scripts/epic/epic-audit-rationale.ts +4 -3
- package/scripts/epic/epic-bundle-cli.ts +14 -3
- package/scripts/epic/epic-bundle-poll.ts +41 -0
- package/scripts/epic/epic-busy.ts +1 -1
- package/scripts/epic/epic-candidate-confirm.ts +3 -2
- package/scripts/epic/epic-classify.ts +1 -1
- package/scripts/epic/epic-cli-argv.ts +78 -46
- package/scripts/epic/epic-cli-remove.ts +11 -19
- package/scripts/epic/epic-cli.ts +74 -73
- package/scripts/epic/epic-close-comment.ts +1 -1
- package/scripts/epic/epic-close.ts +1 -1
- package/scripts/epic/epic-cross-repo.ts +5 -5
- package/scripts/epic/epic-graph.ts +1 -1
- package/scripts/epic/epic-index.ts +1 -1
- package/scripts/epic/epic-issue.ts +2 -6
- package/scripts/epic/epic-lane-offer.ts +2 -2
- package/scripts/epic/epic-next.ts +29 -42
- package/scripts/epic/epic-solo-stale.ts +1 -1
- package/scripts/epic/epic-triage.ts +8 -4
- package/scripts/epic/epic-validate.ts +1 -1
- package/scripts/followup/git-followup-finish.ts +2 -2
- package/scripts/followup/git-followup-label.ts +2 -2
- package/scripts/followup/git-followup-merged.ts +2 -2
- package/scripts/followup/git-pr-followup-checks.ts +142 -0
- package/scripts/followup/git-pr-followup.ts +4 -129
- package/scripts/gate/core-admission.ts +162 -0
- package/scripts/gate/core-budget.ts +190 -68
- package/scripts/gate/gate-plan.ts +80 -7
- package/scripts/gate/gate-report.ts +28 -9
- package/scripts/gate/gate-skip.ts +38 -7
- package/scripts/gate/hook-gate-reuse.ts +12 -10
- package/scripts/gate/machine-capacity.ts +175 -0
- package/scripts/gate/pre-commit-type-check.ts +4 -1
- package/scripts/gate/project-checks.ts +6 -9
- package/scripts/gate/type-check-step.ts +2 -3
- package/scripts/gate/verification-gate.ts +34 -10
- package/scripts/gh/git-gh-api-path.ts +2 -2
- package/scripts/gh/git-gh-issue-rest.ts +3 -3
- package/scripts/gh/git-gh-issue-write.ts +53 -7
- package/scripts/gh/git-gh-pr-read.ts +64 -19
- package/scripts/gh/git-gh-pr-rest.ts +1 -1
- package/scripts/gh/git-gh-pr.ts +5 -1
- package/scripts/gh/git-pr-ai-review.ts +1 -1
- package/scripts/gh/git-pr-checks-eval.ts +1 -3
- package/scripts/gh/git-pr-checks-parse.ts +1 -1
- package/scripts/gh/git-pr-checks-watch.ts +6 -5
- package/scripts/gh/git-pr-checks.ts +7 -5
- package/scripts/gh/git-pr-coderabbit.ts +1 -1
- package/scripts/gh/git-pr-error.ts +1 -3
- package/scripts/gh/git-pr.ts +9 -13
- package/scripts/gh/github-issue-url.ts +2 -2
- package/scripts/git/constants.ts +2 -6
- package/scripts/git/git-command.ts +20 -218
- package/scripts/git/git-diff-reads.ts +225 -0
- package/scripts/git/git-error.ts +4 -12
- package/scripts/git/git-pre-push-hook.ts +139 -0
- package/scripts/git/git-prompt.ts +2 -6
- package/scripts/git/git-spawn-sync.ts +3 -1
- package/scripts/git/git-spawn.ts +1 -1
- package/scripts/git/git-staging.ts +4 -6
- package/scripts/git/git-status.ts +3 -9
- package/scripts/hooks/codex-hook-adapter.ts +1 -1
- package/scripts/hooks/edited-cspell.ts +2 -4
- package/scripts/hooks/format-edited-file.ts +3 -12
- package/scripts/hooks/pre-push-unit.ts +31 -9
- package/scripts/hooks/reserved-run.ts +2 -2
- package/scripts/hooks/run-hook.sh +5 -4
- package/scripts/hooks/stop-guard.ts +5 -3
- package/scripts/init/init-actions.ts +0 -5
- package/scripts/init/init-ai-copy.ts +13 -2
- package/scripts/init/init-logic-json-merge.ts +19 -0
- package/scripts/init/init-logic-secretlint.ts +7 -7
- package/scripts/init/init-logic-workspace.ts +41 -2
- package/scripts/init/init-logic.ts +16 -26
- package/scripts/init/init.ts +10 -16
- package/scripts/init/initial-commit.ts +4 -4
- package/scripts/init/kit-development-versions.ts +40 -0
- package/scripts/init/kit-setup-state.ts +2 -2
- package/scripts/init/package-manager-pin.ts +35 -0
- package/scripts/init/start-exec.ts +68 -19
- package/scripts/init/start-setup-pr.ts +9 -9
- package/scripts/init/start-steps.ts +6 -10
- package/scripts/issue/defect-rate-cli.ts +1 -1
- package/scripts/issue/git-next-issues.ts +1 -1
- package/scripts/issue/issue-auto-ok.ts +32 -7
- package/scripts/issue/issue-backlinks-cli.ts +2 -2
- package/scripts/issue/issue-backlinks.ts +9 -9
- package/scripts/issue/issue-comment-cli.ts +19 -13
- package/scripts/issue/issue-file-cli.ts +72 -22
- package/scripts/issue/issue-file.ts +29 -1
- package/scripts/issue/issue-labels.ts +13 -0
- package/scripts/issue/issue-release-cli.ts +155 -0
- package/scripts/issue/issue-release.ts +58 -0
- package/scripts/issue/issue-scout-closed.ts +1 -1
- package/scripts/issue/issue-state-cli.ts +30 -74
- package/scripts/josh/josh-command-map.ts +2 -0
- package/scripts/josh/josh-command-types.ts +14 -0
- package/scripts/josh/josh-commands-ai.ts +4 -4
- package/scripts/josh/josh-commands-backlog.ts +4 -1
- package/scripts/josh/josh-commands-development.ts +18 -0
- package/scripts/josh/josh-commands-document.ts +1 -0
- package/scripts/josh/josh-commands-issue.ts +8 -1
- package/scripts/josh/josh-commands-lane.ts +24 -1
- package/scripts/josh/josh-commands-maintenance.ts +6 -6
- package/scripts/josh/josh-commands-run.ts +12 -7
- package/scripts/josh/josh-in-process.ts +28 -9
- package/scripts/josh/josh-logic.ts +34 -15
- package/scripts/josh/process-identity.ts +1 -3
- package/scripts/josh/session-language-cli.ts +3 -4
- package/scripts/lane/lane-await.ts +5 -1
- package/scripts/lane/lane-child-invocation.ts +2 -2
- package/scripts/lane/lane-cli.ts +12 -4
- package/scripts/lane/lane-dispatch.ts +14 -10
- package/scripts/lane/lane-environment.ts +5 -1
- package/scripts/lane/lane-handoff.ts +1 -1
- package/scripts/lane/lane-install.ts +2 -13
- package/scripts/lane/lane-launch-cli.ts +15 -1
- package/scripts/lane/lane-ledger.ts +145 -0
- package/scripts/lane/lane-leftover.ts +44 -30
- package/scripts/lane/lane-load.ts +108 -0
- package/scripts/lane/lane-measure-cli.ts +149 -0
- package/scripts/lane/lane-occupancy.ts +3 -0
- package/scripts/lane/lane-open.ts +5 -5
- package/scripts/lane/lane-paths.ts +13 -0
- package/scripts/lane/lane-reap.ts +1 -3
- package/scripts/lane/lane-registry.ts +11 -0
- package/scripts/lane/lane-relaunch.ts +1 -1
- package/scripts/lane/lane-stats.ts +224 -0
- package/scripts/lane/lane-stray.ts +140 -0
- package/scripts/lane/lane-vacant.ts +36 -0
- package/scripts/lane/openai-lane-ship.ts +2 -2
- package/scripts/lane/openai-lane-supervisor-owner.ts +180 -0
- package/scripts/lane/openai-lane-supervisor.ts +7 -165
- package/scripts/lane/openai-review-broker.ts +2 -4
- package/scripts/lib/ancestor-directories.ts +35 -0
- package/scripts/lib/animation-helpers.ts +2 -2
- package/scripts/lib/buffered-process.ts +3 -7
- package/scripts/lib/cli-flags.ts +71 -1
- package/scripts/lib/spawn-exit.ts +2 -2
- package/scripts/lib/timeouts.ts +35 -2
- package/scripts/lines/line-budget.ts +4 -6
- package/scripts/notify/telegram-test.ts +6 -0
- package/scripts/observations/observation-ledger-line.ts +6 -6
- package/scripts/observations/observation-ledger-migrate.ts +55 -4
- package/scripts/observations/observation-ledger.ts +26 -7
- package/scripts/overrides/lockfile-overrides.ts +1 -1
- package/scripts/overrides/overrides-logic.ts +1 -1
- package/scripts/propagate/propagate-git.ts +1 -1
- package/scripts/propagate/propagate-publish.ts +2 -2
- package/scripts/propagate/propagate-steps.ts +20 -15
- package/scripts/propagate/propagate.ts +36 -27
- package/scripts/refactor/import-graph.ts +18 -1
- package/scripts/refactor/refactor-lint.ts +4 -4
- package/scripts/release/github-release-environment.ts +1 -0
- package/scripts/release/github-release-runs.ts +115 -0
- package/scripts/release/github-release.ts +13 -67
- package/scripts/repo/repository-labels.ts +2 -2
- package/scripts/repo/required-checks-logic.ts +1 -3
- package/scripts/review/live-evidence.ts +2 -4
- package/scripts/review/review-brief-cli.ts +1 -1
- package/scripts/review/review-finding-ledger.ts +1 -1
- package/scripts/review/review-findings-cli.ts +1 -3
- package/scripts/rules/decision-oracle-batch.ts +128 -0
- package/scripts/rules/decision-oracle-tokens.ts +21 -0
- package/scripts/rules/decision-oracle.ts +8 -120
- package/scripts/rules/delivered-rules.ts +26 -182
- package/scripts/rules/direct-filing.ts +1 -1
- package/scripts/rules/early-heartbeat.ts +3 -3
- package/scripts/rules/git-argv.ts +1 -1
- package/scripts/rules/git-force.ts +1 -1
- package/scripts/rules/implementation-cut.ts +2 -2
- package/scripts/rules/index-guard.ts +1 -1
- package/scripts/rules/issue-comments.ts +118 -0
- package/scripts/rules/{issue-fold.ts → issue-fold-rule.ts} +2 -2
- package/scripts/rules/lane-background.ts +2 -2
- package/scripts/rules/lane-park.ts +18 -0
- package/scripts/rules/lane-split-park.ts +128 -0
- package/scripts/rules/oracle-firing.ts +1 -1
- package/scripts/rules/poll-loop.ts +1 -1
- package/scripts/rules/pre-gate-cut.ts +1 -1
- package/scripts/rules/protected-files.ts +59 -4
- package/scripts/rules/{run-tail.ts → run-tail-rule.ts} +2 -2
- package/scripts/rules/shell-body-trigger.ts +1 -1
- package/scripts/rules/stop-rules.ts +18 -7
- package/scripts/rules/test-declared-commit.ts +4 -4
- package/scripts/rules/wip-cap.ts +63 -0
- package/scripts/run/{run-carry-args.ts → carry/run-carry-args.ts} +37 -13
- package/scripts/run/{run-carry-change.ts → carry/run-carry-change.ts} +29 -7
- package/scripts/run/{run-carry-cli.ts → carry/run-carry-cli.ts} +4 -6
- package/scripts/run/{run-carry.ts → carry/run-carry.ts} +1 -1
- package/scripts/run/{run-cut-args.ts → cut/run-cut-args.ts} +1 -1
- package/scripts/run/{run-cut-cli.ts → cut/run-cut-cli.ts} +18 -5
- package/scripts/run/{run-cut.ts → cut/run-cut.ts} +1 -1
- package/scripts/run/{run-entry-cli.ts → entry/run-entry-cli.ts} +11 -11
- package/scripts/run/{run-entry.ts → entry/run-entry.ts} +2 -2
- package/scripts/run/{run-event-render.ts → event/run-event-render.ts} +1 -0
- package/scripts/run/{run-event-scope.ts → event/run-event-scope.ts} +1 -1
- package/scripts/run/{run-event-stream-emit.ts → event/run-event-stream-emit.ts} +1 -1
- package/scripts/run/{run-event-stream.ts → event/run-event-stream.ts} +20 -2
- package/scripts/run/{run-hold-cli.ts → hold/run-hold-cli.ts} +5 -5
- package/scripts/run/{run-merge-cli.ts → merge/run-merge-cli.ts} +10 -5
- package/scripts/run/{run-merge-steps.ts → merge/run-merge-steps.ts} +53 -5
- package/scripts/run/{run-merge.ts → merge/run-merge.ts} +1 -1
- package/scripts/run/{run-progress-cli.ts → progress/run-progress-cli.ts} +1 -1
- package/scripts/run/{run-progress-config.ts → progress/run-progress-config.ts} +2 -17
- package/scripts/run/{run-progress-read.ts → progress/run-progress-read.ts} +5 -5
- package/scripts/run/{run-progress.ts → progress/run-progress.ts} +1 -1
- package/scripts/run/{run-review-steps.ts → review/run-review-steps.ts} +2 -3
- package/scripts/run/run-ending.ts +2 -2
- package/scripts/run/run-halfrun-resume.ts +6 -1
- package/scripts/run/run-headless.ts +1 -1
- package/scripts/run/run-invocation.ts +85 -84
- package/scripts/run/run-liveness.ts +1 -1
- package/scripts/run/run-parent-cut-hook.ts +1 -1
- package/scripts/run/run-preflight.ts +6 -6
- package/scripts/run/run-prep-cli.ts +1 -1
- package/scripts/run/run-prrun-resume.ts +1 -1
- package/scripts/run/run-report-cli.ts +4 -4
- package/scripts/run/run-report.ts +2 -2
- package/scripts/run/run-status-cli.ts +1 -1
- package/scripts/run/run-step-cli.ts +3 -3
- package/scripts/run/run-step.ts +7 -4
- package/scripts/run/run-stop-notify.ts +1 -1
- package/scripts/run/run-stranded-detect.ts +4 -4
- package/scripts/run/run-stranded.ts +2 -2
- package/scripts/run/run-watcher-guard-cli.ts +1 -1
- package/scripts/run/run-watcher-guard.ts +5 -3
- package/scripts/run/run-watcher-hook.ts +1 -1
- package/scripts/run/{run-ship-cli.ts → ship/run-ship-cli.ts} +2 -2
- package/scripts/run/{run-ship-detach.ts → ship/run-ship-detach.ts} +3 -3
- package/scripts/run/ship/run-ship-lock.ts +50 -0
- package/scripts/run/{run-ship-preflight.ts → ship/run-ship-preflight.ts} +6 -2
- package/scripts/run/{run-ship-probe.ts → ship/run-ship-probe.ts} +2 -2
- package/scripts/run/{run-ship-return.ts → ship/run-ship-return.ts} +4 -3
- package/scripts/run/{run-ship-review-steps.ts → ship/run-ship-review-steps.ts} +3 -3
- package/scripts/run/{run-ship-scoped.ts → ship/run-ship-scoped.ts} +10 -1
- package/scripts/run/{run-ship-steps.ts → ship/run-ship-steps.ts} +11 -12
- package/scripts/run/ship/run-ship-stop-text.ts +13 -0
- package/scripts/run/{run-ship-sync.ts → ship/run-ship-sync.ts} +25 -11
- package/scripts/run/{run-tidy-lanes.ts → tidy/run-tidy-lanes.ts} +1 -1
- package/scripts/run/{run-wake-cli.ts → wake/run-wake-cli.ts} +25 -11
- package/scripts/run/{run-wake-describe.ts → wake/run-wake-describe.ts} +58 -7
- package/scripts/run/{run-wake-driver.ts → wake/run-wake-driver.ts} +59 -8
- package/scripts/run/{run-wake-handoff.ts → wake/run-wake-handoff.ts} +1 -1
- package/scripts/run/{run-wake-loop.ts → wake/run-wake-loop.ts} +13 -15
- package/scripts/run/wake/run-wake-restart.ts +58 -0
- package/scripts/run/{run-wake-session.ts → wake/run-wake-session.ts} +3 -3
- package/scripts/run/{run-wake.ts → wake/run-wake.ts} +16 -65
- package/scripts/safe-chain/preinstall-command.ts +20 -21
- package/scripts/safe-chain/project-config.ts +19 -15
- package/scripts/sync/sync-ai-files.ts +1 -1
- package/scripts/sync/sync-configs.ts +2 -1
- package/scripts/sync/sync.ts +15 -2
- package/scripts/test/unit-worker-share.ts +1 -0
- package/scripts/time-runtime/time-background.ts +5 -1
- package/scripts/time-runtime/time-instant.ts +3 -1
- package/scripts/time-runtime/time-spans.ts +6 -139
- package/scripts/time-runtime/time-tool-call.ts +160 -0
- package/scripts/version/effective-upstream.ts +2 -20
- package/scripts/version/latest-corepack.ts +124 -93
- package/scripts/version/latest-regression.ts +1 -1
- package/scripts/version/latest-update.ts +4 -4
- package/scripts/version/npm-registry.ts +20 -5
- package/scripts/version/publishable-range-check.ts +2 -2
- package/scripts/version/publishable-range.ts +1 -1
- package/scripts/version/release-age.ts +48 -38
- package/scripts/version/release-hold.ts +1 -1
- package/scripts/version/safe-chain-version-update.ts +40 -0
- package/scripts/version/upgrade-shell-command.ts +48 -8
- package/scripts/version/version-check-logic.ts +23 -14
- package/scripts/version/version-commands.ts +23 -11
- package/scripts/version/version-remote.ts +28 -13
- package/templates/pnpm-workspace.basic.yaml +4 -0
- package/templates/workflows/dependabot-auto-merge.yml +5 -5
- package/templates/workflows/github-release.yml +6 -0
- package/scripts/build/build-config-merge.ts +0 -27
- package/scripts/build/build-managed-marker.ts +0 -27
- package/scripts/build/build-self-sync-guard.ts +0 -27
- package/scripts/build/build-version.ts +0 -26
- package/scripts/version/preinstall-version-update.ts +0 -86
- /package/scripts/git/{schemas.ts → git-schemas.ts} +0 -0
- /package/scripts/overrides/{schemas.ts → overrides-schemas.ts} +0 -0
- /package/scripts/run/{run-carry-conversation.ts → carry/run-carry-conversation.ts} +0 -0
- /package/scripts/run/{run-carry-reclaim.ts → carry/run-carry-reclaim.ts} +0 -0
- /package/scripts/run/{run-carry-stash.ts → carry/run-carry-stash.ts} +0 -0
- /package/scripts/run/{run-carry-streak.ts → carry/run-carry-streak.ts} +0 -0
- /package/scripts/run/{run-cut-handoff.ts → cut/run-cut-handoff.ts} +0 -0
- /package/scripts/run/{run-cut-report.ts → cut/run-cut-report.ts} +0 -0
- /package/scripts/run/{run-entry-stop.ts → entry/run-entry-stop.ts} +0 -0
- /package/scripts/run/{run-event-cli.ts → event/run-event-cli.ts} +0 -0
- /package/scripts/run/{run-event-follow.ts → event/run-event-follow.ts} +0 -0
- /package/scripts/run/{run-event-watch.ts → event/run-event-watch.ts} +0 -0
- /package/scripts/run/{run-hold.ts → hold/run-hold.ts} +0 -0
- /package/scripts/run/{run-progress-args.ts → progress/run-progress-args.ts} +0 -0
- /package/scripts/run/{run-progress-clock.ts → progress/run-progress-clock.ts} +0 -0
- /package/scripts/run/{run-review-cli.ts → review/run-review-cli.ts} +0 -0
- /package/scripts/run/{run-review.ts → review/run-review.ts} +0 -0
- /package/scripts/run/{run-ship-next.ts → ship/run-ship-next.ts} +0 -0
- /package/scripts/run/{run-ship-pre-detach.ts → ship/run-ship-pre-detach.ts} +0 -0
- /package/scripts/run/{run-ship-review.ts → ship/run-ship-review.ts} +0 -0
- /package/scripts/run/{run-ship-stage.ts → ship/run-ship-stage.ts} +0 -0
- /package/scripts/run/{run-ship.ts → ship/run-ship.ts} +0 -0
- /package/scripts/run/{run-tidy-cli.ts → tidy/run-tidy-cli.ts} +0 -0
- /package/scripts/run/{run-tidy-stashes.ts → tidy/run-tidy-stashes.ts} +0 -0
- /package/scripts/run/{run-tidy.ts → tidy/run-tidy.ts} +0 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
error_text
|
|
3
|
+
} from "./chunk-CDY4NFQG.js";
|
|
1
4
|
import {
|
|
2
5
|
lane_child_marker,
|
|
3
6
|
run_issue_number
|
|
4
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZQGD4GBY.js";
|
|
5
8
|
import {
|
|
6
9
|
CHECK_STATUS_FAIL,
|
|
7
10
|
CHECK_STATUS_PENDING,
|
|
8
|
-
PLATFORM_TEMP_ROOT,
|
|
9
11
|
PrConflictError,
|
|
10
12
|
blocking_issue_schema,
|
|
11
13
|
cost_blocks,
|
|
@@ -21,19 +23,27 @@ import {
|
|
|
21
23
|
json_value,
|
|
22
24
|
lane_paths,
|
|
23
25
|
parse_pr_state_snapshot,
|
|
26
|
+
process_identity,
|
|
27
|
+
process_owner_schema,
|
|
24
28
|
read_string,
|
|
25
29
|
rest_comment_schema,
|
|
26
|
-
stamp_file,
|
|
27
30
|
time_density_hook,
|
|
28
31
|
time_shell,
|
|
29
32
|
time_transcript_line
|
|
30
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-WK2XSHSI.js";
|
|
31
34
|
import {
|
|
32
35
|
ENV_FILE_NAME,
|
|
33
36
|
LANE_SEAT_KEY,
|
|
34
37
|
PORT_SEED_KEY,
|
|
35
38
|
ports
|
|
36
39
|
} from "./chunk-RKUAD3I6.js";
|
|
40
|
+
import {
|
|
41
|
+
COMMAND_TIMEOUT_MS,
|
|
42
|
+
GIT_TIMEOUT_MS,
|
|
43
|
+
PLATFORM_TEMP_ROOT,
|
|
44
|
+
PROBE_TIMEOUT_MS,
|
|
45
|
+
stamp_file
|
|
46
|
+
} from "./chunk-ELCN5LCH.js";
|
|
37
47
|
|
|
38
48
|
// scripts/lib/bounded-pool.ts
|
|
39
49
|
function pool_width(limit, total) {
|
|
@@ -157,8 +167,8 @@ function current_turn(tail) {
|
|
|
157
167
|
function turn_filing_count(tail) {
|
|
158
168
|
return prior_filing_count(current_turn(tail));
|
|
159
169
|
}
|
|
160
|
-
function decide(_call,
|
|
161
|
-
return prior_filing_count(time_density_hook.read_tail(
|
|
170
|
+
function decide(_call, run4) {
|
|
171
|
+
return prior_filing_count(time_density_hook.read_tail(run4.transcript)) >= CAP_REACHED;
|
|
162
172
|
}
|
|
163
173
|
var FILING_CAP_REASON = `\u26D4 filing cap: this run has already filed ${String(FILING_CAP)} Issues, the per-run ceiling \u2014 on reaching it, stop and report rather than filing more. Automatic filing is capped so a run cannot manufacture Issues faster than they can be closed (\`.claude/skills/workflow-commands/SKILL.md\` \u2192 \`prerequisite.md\`, \`observation-filing.md\`). A further Issue that genuinely must exist is a person's call, not this run's. **This rule fires on every filing past the cap, not once per run**, so reissuing the same filing will be refused again.`;
|
|
164
174
|
var ROW = {
|
|
@@ -183,17 +193,13 @@ var PORCELAIN_FLAG = "--porcelain";
|
|
|
183
193
|
var UNTRACKED_FILES_FLAG = "--untracked-files=all";
|
|
184
194
|
var GIT_BINARY_KEY = "JOSH_GIT_BINARY";
|
|
185
195
|
function get_git_command() {
|
|
186
|
-
if (platform() === "win32")
|
|
187
|
-
return String.raw`"C:\Program Files\Git\cmd\git.exe"`;
|
|
188
|
-
}
|
|
196
|
+
if (platform() === "win32") return String.raw`"C:\Program Files\Git\cmd\git.exe"`;
|
|
189
197
|
return GIT_COMMAND_UNIX;
|
|
190
198
|
}
|
|
191
199
|
function get_git_command_for_spawn() {
|
|
192
200
|
const binary = process.env[GIT_BINARY_KEY];
|
|
193
201
|
if (binary !== void 0 && binary !== "") return binary;
|
|
194
|
-
if (platform() === "win32")
|
|
195
|
-
return String.raw`C:\Program Files\Git\cmd\git.exe`;
|
|
196
|
-
}
|
|
202
|
+
if (platform() === "win32") return String.raw`C:\Program Files\Git\cmd\git.exe`;
|
|
197
203
|
return GIT_COMMAND_UNIX;
|
|
198
204
|
}
|
|
199
205
|
var git_utilities = {
|
|
@@ -201,6 +207,9 @@ var git_utilities = {
|
|
|
201
207
|
get_git_command_for_spawn
|
|
202
208
|
};
|
|
203
209
|
|
|
210
|
+
// scripts/git/git-spawn.ts
|
|
211
|
+
import { execa as execa3 } from "execa";
|
|
212
|
+
|
|
204
213
|
// scripts/git/git-execa-error.ts
|
|
205
214
|
function get_exit_code(error) {
|
|
206
215
|
if (typeof error !== "object" || error === null) return void 0;
|
|
@@ -300,7 +309,6 @@ var git_push_transport = {
|
|
|
300
309
|
};
|
|
301
310
|
|
|
302
311
|
// scripts/git/git-spawn.ts
|
|
303
|
-
import { execa as execa3 } from "execa";
|
|
304
312
|
async function read(arguments_) {
|
|
305
313
|
const git_cmd = git_utilities.get_git_command_for_spawn();
|
|
306
314
|
const { stdout } = await execa3(git_cmd, arguments_);
|
|
@@ -352,73 +360,7 @@ var git_spawn = {
|
|
|
352
360
|
with_output_remote
|
|
353
361
|
};
|
|
354
362
|
|
|
355
|
-
// scripts/
|
|
356
|
-
function read_spawn_stdout(result) {
|
|
357
|
-
return result.stdout ?? "";
|
|
358
|
-
}
|
|
359
|
-
function read_spawn_stderr(result) {
|
|
360
|
-
return result.stderr ?? "";
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// scripts/git/git-spawn-sync.ts
|
|
364
|
-
import { execaSync } from "execa";
|
|
365
|
-
var GIT_TIMEOUT_MS = 1e4;
|
|
366
|
-
var SUCCESS_EXIT_CODE = 0;
|
|
367
|
-
var C_LOCALE = { LC_ALL: "C", LANGUAGE: "C" };
|
|
368
|
-
function run(args, options = {}) {
|
|
369
|
-
const result = execaSync(git_utilities.get_git_command_for_spawn(), args, {
|
|
370
|
-
...options,
|
|
371
|
-
extendEnv: true,
|
|
372
|
-
reject: false,
|
|
373
|
-
timeout: options.timeout ?? GIT_TIMEOUT_MS
|
|
374
|
-
});
|
|
375
|
-
return {
|
|
376
|
-
exit_code: result.exitCode,
|
|
377
|
-
stdout: read_spawn_stdout(result),
|
|
378
|
-
stderr: read_spawn_stderr(result)
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
function read2(args, options = {}) {
|
|
382
|
-
const result = run(args, options);
|
|
383
|
-
return result.exit_code === SUCCESS_EXIT_CODE ? result.stdout.trim() : void 0;
|
|
384
|
-
}
|
|
385
|
-
function origin_url(cwd) {
|
|
386
|
-
return read2(["config", "--get", "remote.origin.url"], { cwd });
|
|
387
|
-
}
|
|
388
|
-
function toplevel(timeout = GIT_TIMEOUT_MS) {
|
|
389
|
-
return run(["rev-parse", "--show-toplevel"], { env: C_LOCALE, timeout });
|
|
390
|
-
}
|
|
391
|
-
var git_spawn_sync = { GIT_TIMEOUT_MS, C_LOCALE, run, read: read2, origin_url, toplevel };
|
|
392
|
-
|
|
393
|
-
// scripts/git/git-command.ts
|
|
394
|
-
async function branch() {
|
|
395
|
-
return await git_spawn.read(["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
396
|
-
}
|
|
397
|
-
async function status(directory) {
|
|
398
|
-
const location = directory === void 0 ? [] : ["-C", directory];
|
|
399
|
-
return await git_spawn.read([...location, "status", PORCELAIN_FLAG, UNTRACKED_FILES_FLAG]);
|
|
400
|
-
}
|
|
401
|
-
async function repository_root() {
|
|
402
|
-
const result = git_spawn_sync.toplevel();
|
|
403
|
-
if (result.exit_code !== 0) throw create_spawn_error("rev-parse", result.exit_code);
|
|
404
|
-
return result.stdout.trim();
|
|
405
|
-
}
|
|
406
|
-
async function head_commit() {
|
|
407
|
-
return await git_spawn.read(["rev-parse", "HEAD"]);
|
|
408
|
-
}
|
|
409
|
-
var GIT_DIRECTORY_ARGUMENTS = [
|
|
410
|
-
"rev-parse",
|
|
411
|
-
"--absolute-git-dir",
|
|
412
|
-
"--path-format=absolute",
|
|
413
|
-
"--git-common-dir"
|
|
414
|
-
];
|
|
415
|
-
async function git_directories() {
|
|
416
|
-
const output = await git_spawn.read([...GIT_DIRECTORY_ARGUMENTS]);
|
|
417
|
-
return output.split("\n").filter((line) => line !== "");
|
|
418
|
-
}
|
|
419
|
-
async function diff_cached(file_path) {
|
|
420
|
-
return await git_spawn.read(["diff", "--cached", file_path]);
|
|
421
|
-
}
|
|
363
|
+
// scripts/git/git-diff-reads.ts
|
|
422
364
|
var REFS_REMOTES_ORIGIN_PREFIX = "refs/remotes/origin/";
|
|
423
365
|
var NAME_ONLY_FLAG = "--name-only";
|
|
424
366
|
var DEFAULT_BRANCH_FALLBACK = "main";
|
|
@@ -507,6 +449,164 @@ async function untracked_names() {
|
|
|
507
449
|
WHOLE_TREE_PATHSPEC
|
|
508
450
|
]);
|
|
509
451
|
}
|
|
452
|
+
var git_diff_reads = {
|
|
453
|
+
change_base,
|
|
454
|
+
change_base_commit,
|
|
455
|
+
default_branch_reference,
|
|
456
|
+
diff_cached_names,
|
|
457
|
+
diff_main,
|
|
458
|
+
diff_main_names,
|
|
459
|
+
diff_main_numstat,
|
|
460
|
+
get_default_branch,
|
|
461
|
+
untracked_names
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
// scripts/git/git-pre-push-hook.ts
|
|
465
|
+
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
466
|
+
import { tmpdir } from "node:os";
|
|
467
|
+
import path from "node:path";
|
|
468
|
+
var REMOTE = "origin";
|
|
469
|
+
var HOOK_NAME = "pre-push";
|
|
470
|
+
var PROBE_HOOK_NAME = "kit-hook-run-probe";
|
|
471
|
+
var ALLOW_UNKNOWN_HOOK_NAME_FLAG = "--allow-unknown-hook-name";
|
|
472
|
+
var HOOK_RUN = "run";
|
|
473
|
+
var STDIN_FILE = "refs";
|
|
474
|
+
var TEMPORARY_PREFIX = "kit-pre-push-";
|
|
475
|
+
var ZERO_DIGIT = "0";
|
|
476
|
+
async function read_remote_oid(branch2) {
|
|
477
|
+
try {
|
|
478
|
+
return await git_spawn.read([
|
|
479
|
+
"rev-parse",
|
|
480
|
+
"--verify",
|
|
481
|
+
"--quiet",
|
|
482
|
+
`refs/remotes/${REMOTE}/${branch2}`
|
|
483
|
+
]);
|
|
484
|
+
} catch {
|
|
485
|
+
return void 0;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
async function read_push_references() {
|
|
489
|
+
const [branch2, local_oid] = await Promise.all([
|
|
490
|
+
git_spawn.read(["rev-parse", "--abbrev-ref", "HEAD"]),
|
|
491
|
+
git_spawn.read(["rev-parse", "HEAD"])
|
|
492
|
+
]);
|
|
493
|
+
return { branch: branch2, local_oid, remote_oid: await read_remote_oid(branch2) };
|
|
494
|
+
}
|
|
495
|
+
function to_stdin_line(references) {
|
|
496
|
+
const reference2 = `refs/heads/${references.branch}`;
|
|
497
|
+
const remote_oid = references.remote_oid ?? ZERO_DIGIT.repeat(references.local_oid.length);
|
|
498
|
+
return `${reference2} ${references.local_oid} ${reference2} ${remote_oid}
|
|
499
|
+
`;
|
|
500
|
+
}
|
|
501
|
+
function to_hook_run_arguments(stdin_path, hook_name) {
|
|
502
|
+
return [HOOK_RUN, "--ignore-missing", `--to-stdin=${stdin_path}`, hook_name];
|
|
503
|
+
}
|
|
504
|
+
async function can_probe(probe_arguments) {
|
|
505
|
+
try {
|
|
506
|
+
await git_spawn.read(["hook", ...probe_arguments]);
|
|
507
|
+
return true;
|
|
508
|
+
} catch {
|
|
509
|
+
return false;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
async function can_run_hooks(stdin_path) {
|
|
513
|
+
const [, ...options] = to_hook_run_arguments(stdin_path, PROBE_HOOK_NAME);
|
|
514
|
+
if (await can_probe([HOOK_RUN, ALLOW_UNKNOWN_HOOK_NAME_FLAG, ...options])) return true;
|
|
515
|
+
return await can_probe([HOOK_RUN, ...options]);
|
|
516
|
+
}
|
|
517
|
+
async function run_with_stdin(stdin_line) {
|
|
518
|
+
const directory = await mkdtemp(path.join(tmpdir(), TEMPORARY_PREFIX));
|
|
519
|
+
const stdin_path = path.join(directory, STDIN_FILE);
|
|
520
|
+
try {
|
|
521
|
+
await writeFile(stdin_path, stdin_line);
|
|
522
|
+
if (!await can_run_hooks(stdin_path)) return false;
|
|
523
|
+
const url = await git_spawn.read(["remote", "get-url", REMOTE]);
|
|
524
|
+
await git_spawn.with_output("hook", [
|
|
525
|
+
...to_hook_run_arguments(stdin_path, HOOK_NAME),
|
|
526
|
+
"--",
|
|
527
|
+
REMOTE,
|
|
528
|
+
url
|
|
529
|
+
]);
|
|
530
|
+
return true;
|
|
531
|
+
} finally {
|
|
532
|
+
await rm(directory, { force: true, recursive: true });
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
async function run() {
|
|
536
|
+
const references = await read_push_references();
|
|
537
|
+
if (references.local_oid === references.remote_oid) return true;
|
|
538
|
+
return await run_with_stdin(to_stdin_line(references));
|
|
539
|
+
}
|
|
540
|
+
var git_pre_push_hook = {
|
|
541
|
+
run
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
// scripts/lib/spawn-exit.ts
|
|
545
|
+
function read_spawn_stdout(result) {
|
|
546
|
+
return result.stdout ?? "";
|
|
547
|
+
}
|
|
548
|
+
function read_spawn_stderr(result) {
|
|
549
|
+
return result.stderr ?? "";
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// scripts/git/git-spawn-sync.ts
|
|
553
|
+
import { execaSync } from "execa";
|
|
554
|
+
var SUCCESS_EXIT_CODE = 0;
|
|
555
|
+
var C_LOCALE = { LC_ALL: "C", LANGUAGE: "C" };
|
|
556
|
+
function run2(args, options = {}) {
|
|
557
|
+
const result = execaSync(git_utilities.get_git_command_for_spawn(), args, {
|
|
558
|
+
...options,
|
|
559
|
+
extendEnv: true,
|
|
560
|
+
reject: false,
|
|
561
|
+
timeout: options.timeout ?? GIT_TIMEOUT_MS
|
|
562
|
+
});
|
|
563
|
+
return {
|
|
564
|
+
exit_code: result.exitCode,
|
|
565
|
+
stdout: read_spawn_stdout(result),
|
|
566
|
+
stderr: read_spawn_stderr(result)
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
function read2(args, options = {}) {
|
|
570
|
+
const result = run2(args, options);
|
|
571
|
+
return result.exit_code === SUCCESS_EXIT_CODE ? result.stdout.trim() : void 0;
|
|
572
|
+
}
|
|
573
|
+
function origin_url(cwd) {
|
|
574
|
+
return read2(["config", "--get", "remote.origin.url"], { cwd });
|
|
575
|
+
}
|
|
576
|
+
function toplevel(timeout = GIT_TIMEOUT_MS) {
|
|
577
|
+
return run2(["rev-parse", "--show-toplevel"], { env: C_LOCALE, timeout });
|
|
578
|
+
}
|
|
579
|
+
var git_spawn_sync = { GIT_TIMEOUT_MS, C_LOCALE, run: run2, read: read2, origin_url, toplevel };
|
|
580
|
+
|
|
581
|
+
// scripts/git/git-command.ts
|
|
582
|
+
async function branch() {
|
|
583
|
+
return await git_spawn.read(["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
584
|
+
}
|
|
585
|
+
async function status(directory) {
|
|
586
|
+
const location = directory === void 0 ? [] : ["-C", directory];
|
|
587
|
+
return await git_spawn.read([...location, "status", PORCELAIN_FLAG, UNTRACKED_FILES_FLAG]);
|
|
588
|
+
}
|
|
589
|
+
async function repository_root() {
|
|
590
|
+
const result = git_spawn_sync.toplevel();
|
|
591
|
+
if (result.exit_code !== 0) throw create_spawn_error("rev-parse", result.exit_code);
|
|
592
|
+
return result.stdout.trim();
|
|
593
|
+
}
|
|
594
|
+
async function head_commit() {
|
|
595
|
+
return await git_spawn.read(["rev-parse", "HEAD"]);
|
|
596
|
+
}
|
|
597
|
+
var GIT_DIRECTORY_ARGUMENTS = [
|
|
598
|
+
"rev-parse",
|
|
599
|
+
"--absolute-git-dir",
|
|
600
|
+
"--path-format=absolute",
|
|
601
|
+
"--git-common-dir"
|
|
602
|
+
];
|
|
603
|
+
async function git_directories() {
|
|
604
|
+
const output = await git_spawn.read([...GIT_DIRECTORY_ARGUMENTS]);
|
|
605
|
+
return output.split("\n").filter((line) => line !== "");
|
|
606
|
+
}
|
|
607
|
+
async function diff_cached(file_path) {
|
|
608
|
+
return await git_spawn.read(["diff", "--cached", file_path]);
|
|
609
|
+
}
|
|
510
610
|
async function fetch_branch(branch_name) {
|
|
511
611
|
const refspec = `+refs/heads/${branch_name}:refs/remotes/origin/${branch_name}`;
|
|
512
612
|
return await git_spawn.read(["fetch", "origin", refspec]);
|
|
@@ -548,16 +648,18 @@ function is_upstream_not_set_error(error) {
|
|
|
548
648
|
const { cause } = error;
|
|
549
649
|
return cause !== void 0 && is_exit_code_128(cause);
|
|
550
650
|
}
|
|
551
|
-
|
|
552
|
-
|
|
651
|
+
var NO_VERIFY_FLAG = "--no-verify";
|
|
652
|
+
async function push_with_upstream(branch_name, verify_flags) {
|
|
653
|
+
await git_push_transport.push([...verify_flags, "--set-upstream", "origin", branch_name]);
|
|
553
654
|
}
|
|
554
655
|
async function push2() {
|
|
656
|
+
const verify_flags = await git_pre_push_hook.run() ? [NO_VERIFY_FLAG] : [];
|
|
555
657
|
try {
|
|
556
|
-
await git_push_transport.push([]);
|
|
658
|
+
await git_push_transport.push([...verify_flags]);
|
|
557
659
|
} catch (error) {
|
|
558
660
|
if (is_upstream_not_set_error(error)) {
|
|
559
661
|
const current_branch = await branch();
|
|
560
|
-
await push_with_upstream(current_branch);
|
|
662
|
+
await push_with_upstream(current_branch, verify_flags);
|
|
561
663
|
return;
|
|
562
664
|
}
|
|
563
665
|
throw error;
|
|
@@ -642,15 +744,9 @@ var git_command = {
|
|
|
642
744
|
head_commit,
|
|
643
745
|
git_directories,
|
|
644
746
|
diff_cached,
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
change_base_commit,
|
|
649
|
-
diff_main_names,
|
|
650
|
-
diff_main_numstat,
|
|
651
|
-
untracked_names,
|
|
652
|
-
get_default_branch,
|
|
653
|
-
default_branch_reference,
|
|
747
|
+
// The default branch, the change base and every reading against it are `git-diff-reads.ts`'s
|
|
748
|
+
// (joshuafolkken/kit#3264), re-exported here so no call site, mock or spy moved with them.
|
|
749
|
+
...git_diff_reads,
|
|
654
750
|
fetch_branch,
|
|
655
751
|
merge_fast_forward,
|
|
656
752
|
fast_forward_local,
|
|
@@ -674,19 +770,7 @@ var git_command = {
|
|
|
674
770
|
is_upstream_not_set_error
|
|
675
771
|
};
|
|
676
772
|
|
|
677
|
-
// scripts/
|
|
678
|
-
function message_of(error) {
|
|
679
|
-
return error instanceof Error ? error.message : String(error);
|
|
680
|
-
}
|
|
681
|
-
var DEBUG_ENV_KEY = "JOSH_DEBUG";
|
|
682
|
-
function trace_swallowed(where, error) {
|
|
683
|
-
if ((process.env[DEBUG_ENV_KEY] ?? "").trim() === "") return;
|
|
684
|
-
process.stderr.write(`josh debug: ${where}: ${message_of(error)}
|
|
685
|
-
`);
|
|
686
|
-
}
|
|
687
|
-
var error_text = { message_of, trace_swallowed };
|
|
688
|
-
|
|
689
|
-
// scripts/run/run-hold.ts
|
|
773
|
+
// scripts/run/hold/run-hold.ts
|
|
690
774
|
import { z } from "zod";
|
|
691
775
|
var HOLD_PREFIX = "josh-run-hold-";
|
|
692
776
|
var UNNUMBERED_ISSUE = "new";
|
|
@@ -986,18 +1070,18 @@ function trimmed(value) {
|
|
|
986
1070
|
const result = value?.trim();
|
|
987
1071
|
return result === void 0 || result.length === EMPTY_LENGTH ? void 0 : result;
|
|
988
1072
|
}
|
|
989
|
-
function override_value(role, field,
|
|
1073
|
+
function override_value(role, field, environment3) {
|
|
990
1074
|
const key2 = ENV_KEYS[role][field];
|
|
991
|
-
const value = trimmed(
|
|
1075
|
+
const value = trimmed(environment3[key2]);
|
|
992
1076
|
if (value !== void 0) return { key: key2, value };
|
|
993
1077
|
if (role !== WORKER) return { key: key2, value: void 0 };
|
|
994
1078
|
const legacy = LEGACY_WORKER_KEYS[field];
|
|
995
|
-
const legacy_value = trimmed(
|
|
1079
|
+
const legacy_value = trimmed(environment3[legacy]);
|
|
996
1080
|
return legacy_value === void 0 ? { key: key2, value: void 0 } : { key: legacy, value: legacy_value };
|
|
997
1081
|
}
|
|
998
|
-
function model_override(role,
|
|
1082
|
+
function model_override(role, environment3, provider) {
|
|
999
1083
|
const key2 = ENV_KEYS[role].model;
|
|
1000
|
-
return provider === OPENAI_PROVIDER ? { key: key2, value: void 0 } : override_value(role, "model",
|
|
1084
|
+
return provider === OPENAI_PROVIDER ? { key: key2, value: void 0 } : override_value(role, "model", environment3);
|
|
1001
1085
|
}
|
|
1002
1086
|
function rejection(key2, value, expected) {
|
|
1003
1087
|
return { kind: "rejected", note: `${key2}=${value} ${expected}, so the agent was not started` };
|
|
@@ -1006,35 +1090,35 @@ function resolved_effort(override, fallback) {
|
|
|
1006
1090
|
const parsed = EFFORT_SCHEMA.safeParse(override.value ?? fallback);
|
|
1007
1091
|
return parsed.success ? { kind: "effort", effort: parsed.data } : rejection(override.key, override.value ?? "", "is not an allowed effort");
|
|
1008
1092
|
}
|
|
1009
|
-
function has_session(
|
|
1010
|
-
return keys.some((key2) => trimmed(
|
|
1093
|
+
function has_session(environment3, keys) {
|
|
1094
|
+
return keys.some((key2) => trimmed(environment3[key2]) !== void 0);
|
|
1011
1095
|
}
|
|
1012
1096
|
function session_rejection(is_conflicting) {
|
|
1013
1097
|
const note = is_conflicting ? "both Codex and Claude Code sessions were detected" : "no Codex or Claude Code session was detected";
|
|
1014
1098
|
return { kind: "rejected", note };
|
|
1015
1099
|
}
|
|
1016
1100
|
var HANDED_PROVIDER_KEY = "JOSH_AGENT_PROVIDER";
|
|
1017
|
-
function handed_provider(
|
|
1018
|
-
const value = trimmed(
|
|
1101
|
+
function handed_provider(environment3) {
|
|
1102
|
+
const value = trimmed(environment3[HANDED_PROVIDER_KEY]);
|
|
1019
1103
|
if (value === void 0) return session_rejection(false);
|
|
1020
1104
|
const parsed = PROVIDER_SCHEMA.safeParse(value);
|
|
1021
1105
|
return parsed.success ? { kind: "provider", provider: parsed.data } : rejection(HANDED_PROVIDER_KEY, value, "is not an allowed provider");
|
|
1022
1106
|
}
|
|
1023
|
-
function detected_provider(
|
|
1024
|
-
const has_codex = has_session(
|
|
1025
|
-
const has_claude = has_session(
|
|
1107
|
+
function detected_provider(environment3) {
|
|
1108
|
+
const has_codex = has_session(environment3, [CODEX_SESSION_KEY]);
|
|
1109
|
+
const has_claude = has_session(environment3, agent_session_environment.PARENT_SESSION_KEYS);
|
|
1026
1110
|
if (has_codex === has_claude) return has_codex ? session_rejection(true) : void 0;
|
|
1027
1111
|
return { kind: "provider", provider: has_codex ? OPENAI_PROVIDER : ANTHROPIC_PROVIDER };
|
|
1028
1112
|
}
|
|
1029
|
-
function resolve_provider(
|
|
1030
|
-
return detected_provider(
|
|
1113
|
+
function resolve_provider(environment3 = process.env) {
|
|
1114
|
+
return detected_provider(environment3) ?? handed_provider(environment3);
|
|
1031
1115
|
}
|
|
1032
|
-
function has_completion_callback(
|
|
1033
|
-
const selected = resolve_provider(
|
|
1116
|
+
function has_completion_callback(environment3 = process.env) {
|
|
1117
|
+
const selected = resolve_provider(environment3);
|
|
1034
1118
|
return selected.kind !== "provider" || selected.provider !== OPENAI_PROVIDER;
|
|
1035
1119
|
}
|
|
1036
|
-
function handoff_environment(
|
|
1037
|
-
const selected = resolve_provider(
|
|
1120
|
+
function handoff_environment(environment3 = process.env) {
|
|
1121
|
+
const selected = resolve_provider(environment3);
|
|
1038
1122
|
return selected.kind === "provider" ? { [HANDED_PROVIDER_KEY]: selected.provider } : {};
|
|
1039
1123
|
}
|
|
1040
1124
|
function validate(profile, model_key) {
|
|
@@ -1048,19 +1132,19 @@ function phase_effort(role, phase, fallback) {
|
|
|
1048
1132
|
if (!parsed.success) return fallback;
|
|
1049
1133
|
return PHASE_EFFORT[role]?.[parsed.data] ?? fallback;
|
|
1050
1134
|
}
|
|
1051
|
-
function overridden_effort(profile, phase,
|
|
1052
|
-
const parsed = EFFORT_SCHEMA.safeParse(override_value(profile.role, "effort",
|
|
1135
|
+
function overridden_effort(profile, phase, environment3) {
|
|
1136
|
+
const parsed = EFFORT_SCHEMA.safeParse(override_value(profile.role, "effort", environment3).value);
|
|
1053
1137
|
return parsed.success ? parsed.data : phase_effort(profile.role, phase, profile.effort);
|
|
1054
1138
|
}
|
|
1055
|
-
function with_phase_effort(profile, phase,
|
|
1056
|
-
return { ...profile, effort: overridden_effort(profile, phase,
|
|
1139
|
+
function with_phase_effort(profile, phase, environment3 = process.env) {
|
|
1140
|
+
return { ...profile, effort: overridden_effort(profile, phase, environment3) };
|
|
1057
1141
|
}
|
|
1058
|
-
function resolve(role,
|
|
1059
|
-
const selected = resolve_provider(
|
|
1142
|
+
function resolve(role, environment3 = process.env, phase) {
|
|
1143
|
+
const selected = resolve_provider(environment3);
|
|
1060
1144
|
if (selected.kind === "rejected") return selected;
|
|
1061
1145
|
const defaults = PROVIDER_PROFILES[selected.provider][role];
|
|
1062
|
-
const model = model_override(role,
|
|
1063
|
-
const effort = override_value(role, "effort",
|
|
1146
|
+
const model = model_override(role, environment3, selected.provider);
|
|
1147
|
+
const effort = override_value(role, "effort", environment3);
|
|
1064
1148
|
const resolved = resolved_effort(effort, phase_effort(role, phase, defaults.effort));
|
|
1065
1149
|
if (resolved.kind === "rejected") return resolved;
|
|
1066
1150
|
const profile = {
|
|
@@ -1371,7 +1455,7 @@ var git_location_environment = { clear_git_location_variables, location_free_env
|
|
|
1371
1455
|
// scripts/git/git-common-directory.ts
|
|
1372
1456
|
var OWN_GIT_DIRECTORY = 0;
|
|
1373
1457
|
var COMMON_GIT_DIRECTORY = 1;
|
|
1374
|
-
var
|
|
1458
|
+
var PROBE_TIMEOUT_MS2 = 5e3;
|
|
1375
1459
|
var answers = /* @__PURE__ */ new Map();
|
|
1376
1460
|
function probe_environment(cwd) {
|
|
1377
1461
|
if (cwd === void 0) return process.env;
|
|
@@ -1392,7 +1476,7 @@ function read_directories(cwd) {
|
|
|
1392
1476
|
env: probe_environment(cwd),
|
|
1393
1477
|
encoding: "utf8",
|
|
1394
1478
|
stdio: ["ignore", "pipe", "ignore"],
|
|
1395
|
-
timeout:
|
|
1479
|
+
timeout: PROBE_TIMEOUT_MS2
|
|
1396
1480
|
}
|
|
1397
1481
|
);
|
|
1398
1482
|
return output.split("\n").filter((line) => line !== "");
|
|
@@ -1424,7 +1508,7 @@ function resolve2(cwd) {
|
|
|
1424
1508
|
}
|
|
1425
1509
|
var git_common_directory = { directories, own, repository, resolve: resolve2, select_linked };
|
|
1426
1510
|
|
|
1427
|
-
// scripts/run/run-ship-stage.ts
|
|
1511
|
+
// scripts/run/ship/run-ship-stage.ts
|
|
1428
1512
|
import { z as z3 } from "zod";
|
|
1429
1513
|
var STAGE = {
|
|
1430
1514
|
PREFLIGHT: "preflight",
|
|
@@ -1520,7 +1604,7 @@ var run_ship_stage = {
|
|
|
1520
1604
|
stop_reason: stop_reason2
|
|
1521
1605
|
};
|
|
1522
1606
|
|
|
1523
|
-
// scripts/run/run-ship-next.ts
|
|
1607
|
+
// scripts/run/ship/run-ship-next.ts
|
|
1524
1608
|
var { STAGE: STAGE2 } = run_ship_stage;
|
|
1525
1609
|
var COMMAND = {
|
|
1526
1610
|
LOG: "pnpm josh ship --log",
|
|
@@ -1607,10 +1691,10 @@ var lane_child_invocation = {
|
|
|
1607
1691
|
ship_stop_invocation
|
|
1608
1692
|
};
|
|
1609
1693
|
|
|
1610
|
-
// scripts/run/run-cut.ts
|
|
1694
|
+
// scripts/run/cut/run-cut.ts
|
|
1611
1695
|
import { z as z5 } from "zod";
|
|
1612
1696
|
|
|
1613
|
-
// scripts/run/run-cut-handoff.ts
|
|
1697
|
+
// scripts/run/cut/run-cut-handoff.ts
|
|
1614
1698
|
import { readFileSync } from "node:fs";
|
|
1615
1699
|
import { z as z4 } from "zod";
|
|
1616
1700
|
var handoff_schema = z4.object({
|
|
@@ -1689,7 +1773,7 @@ var run_cut_handoff = {
|
|
|
1689
1773
|
read_handoff_file
|
|
1690
1774
|
};
|
|
1691
1775
|
|
|
1692
|
-
// scripts/run/run-cut.ts
|
|
1776
|
+
// scripts/run/cut/run-cut.ts
|
|
1693
1777
|
var CUT_PREFIX = "josh-run-cut-";
|
|
1694
1778
|
var { PRE_GATE_PHASE: PRE_GATE_PHASE2, IMPLEMENTATION_PHASE: IMPLEMENTATION_PHASE2 } = agent_role_profile;
|
|
1695
1779
|
var IMPLEMENTATION_CONTEXT_THRESHOLD = CONTEXT_CUT_THRESHOLD;
|
|
@@ -1888,7 +1972,7 @@ var run_cut = {
|
|
|
1888
1972
|
worktree_git_directory_sync
|
|
1889
1973
|
};
|
|
1890
1974
|
|
|
1891
|
-
// scripts/rules/run-tail.ts
|
|
1975
|
+
// scripts/rules/run-tail-rule.ts
|
|
1892
1976
|
var SEGMENT_PREFIX = String.raw`(?:\(\s*)?(?:[A-Za-z_][A-Za-z0-9_]*=\S*\s+)*(?:npx\s+|pnpm\s+(?:exec\s+|run\s+)?)?`;
|
|
1893
1977
|
var WORD_END = String.raw`(?=\s|$|\))`;
|
|
1894
1978
|
var PUSH_STEP_SEGMENT = new RegExp(String.raw`^${SEGMENT_PREFIX}josh\s+(?:git|g)${WORD_END}`, "u");
|
|
@@ -1928,7 +2012,7 @@ function decide3() {
|
|
|
1928
2012
|
return true;
|
|
1929
2013
|
}
|
|
1930
2014
|
var RUN_TAIL_REASON = '\u26D4 run tail: this issues the commit-push-PR step in the foreground, where the harness decides when to stop waiting. Reissue it with `run_in_background` set. In `fullrun #1501` this call was given a 900-second timeout, the harness detached it at its own 600-second cap, and nothing read the output for a further 6m28s \u2014 45m03s of wall clock on about 17 minutes of work (joshuafolkken/kit#1510). **Never give a foreground call a timeout above the harness cap**: the cap decides, not the number. A backgrounded call re-invokes you when it exits, so the completion notification is what resumes the run. **When it arrives, the turn that reads it goes straight through any branch-2 filing and `pnpm josh epic:bundle` to `pnpm josh followup` \u2014 the turn never ends at the push.** CI went green 6m06s before the merge started in that run, and it started only because the person asked; joshuafolkken/kit#1333 had already settled that the merge is issued in the turn the review closes. While the push runs, do the work that writes nothing \u2014 drafting the completion body to a file, deciding the branch-2 disposition. `pnpm josh followup` itself stays in the **foreground** \u2014 nearly every step after it reads its result. But a tail does follow the merge, measured at 3.0 min and 5.9% of a run (joshuafolkken/kit#1462), so empty it beforehand: the steps that read the merge result stay after `followup`, and the rest are composed in the turn that issues it, bar the one exception background-commands.md names. The procedure is `.claude/skills/workflow-commands/background-commands.md`, "A command that can take minutes is issued in the background". **This rule fires on every foreground push, not once per run**, so reissuing the same call in the foreground will be refused again.';
|
|
1931
|
-
var
|
|
2015
|
+
var run_tail_rule = {
|
|
1932
2016
|
RUN_TAIL_REASON,
|
|
1933
2017
|
decide: decide3,
|
|
1934
2018
|
is_backgrounded_push_step,
|
|
@@ -1965,7 +2049,7 @@ function is_backgrounded_ship(call) {
|
|
|
1965
2049
|
return command !== void 0 && ships_alone(command);
|
|
1966
2050
|
}
|
|
1967
2051
|
function is_candidate(call) {
|
|
1968
|
-
if (
|
|
2052
|
+
if (run_tail_rule.is_push_step_call(call)) return true;
|
|
1969
2053
|
const command = backgrounded_bash_command(call);
|
|
1970
2054
|
if (command === void 0 || is_backgrounded_ship(call)) return false;
|
|
1971
2055
|
return long_commands_of(command).length > 0;
|
|
@@ -1984,347 +2068,44 @@ function unfinished_ids(tail, launched_ids) {
|
|
|
1984
2068
|
const finished = new Set(lines.map((line) => line?.finished_background ?? ""));
|
|
1985
2069
|
const blocks = lines.flatMap((line) => line?.blocks ?? []);
|
|
1986
2070
|
const launched2 = blocks.flatMap((block) => launched_ids(block));
|
|
1987
|
-
return launched2.filter((id) => id !== "" && !finished.has(id));
|
|
1988
|
-
}
|
|
1989
|
-
function pending_background_ids(tail) {
|
|
1990
|
-
return unfinished_ids(tail, (block) => [block.background_id, block.agent_id]);
|
|
1991
|
-
}
|
|
1992
|
-
function pending_agent_ids(tail) {
|
|
1993
|
-
return unfinished_ids(tail, (block) => [block.agent_id]);
|
|
1994
|
-
}
|
|
1995
|
-
var LANE_BACKGROUND_REASON = '\u26D4 lane background: this session is a dispatched lane child (`JOSH_LANE_CHILD`), a headless `claude -p` process whose background Bash tasks are killed when the turn ends \u2014 so a backgrounded `josh gate` / `josh git` / `josh followup` / `josh ship` never re-invokes you; it dies at `exit code 143` (joshuafolkken/kit#2704, measured on the #2606 child: implementation, review and live verification done, the run parked instead of merged). Hand the gate-to-merge region to the detached supervisor instead: `pnpm josh ship --detach --review "<title> #<N>"` (add `--cite <N>`) issued in the foreground \u2014 its preflight runs in this process before the supervisor exists, so a backgrounded `ship` dies with the turn (joshuafolkken/kit#3027; a backgrounded `ship` issued alone is moved to the foreground for you, joshuafolkken/kit#3154) \u2014 then end the turn on `launched` / `busy`. `.claude/skills/workflow-commands/chain-rule.md` step 0 is the single source. A single check you must read before continuing runs in the foreground within the tool timeout; the commit-push step does not \u2014 in a child it too belongs to the detached ship, in either spelling. This rule fires on every occurrence, not once per run.';
|
|
1996
|
-
var LANE_BACKGROUND_STOP_REASON = "\u26D4 lane background stop: this is a dispatched lane child (`JOSH_LANE_CHILD`) and a background task it launched has not finished \u2014 ending this headless turn kills it, and nothing re-invokes you afterwards (joshuafolkken/kit#2704). Do not send a notification and do not stop: wait for the task in the foreground and act on its result, or re-issue the work through `pnpm josh ship --detach`, whose supervisor outlives the turn (`.claude/skills/workflow-commands/chain-rule.md` step 0). Do not repeat your previous reply.";
|
|
1997
|
-
var ROW2 = {
|
|
1998
|
-
id: "lane-background",
|
|
1999
|
-
is_trigger: (call) => is_background_long_run(call),
|
|
2000
|
-
reason: LANE_BACKGROUND_REASON,
|
|
2001
|
-
decide: () => true
|
|
2002
|
-
};
|
|
2003
|
-
var lane_background = {
|
|
2004
|
-
FOREGROUND_NOTE,
|
|
2005
|
-
LANE_BACKGROUND_REASON,
|
|
2006
|
-
LANE_BACKGROUND_STOP_REASON,
|
|
2007
|
-
ROW: ROW2,
|
|
2008
|
-
foreground_input,
|
|
2009
|
-
is_background_long_run,
|
|
2010
|
-
pending_agent_ids,
|
|
2011
|
-
pending_background_ids
|
|
2012
|
-
};
|
|
2013
|
-
|
|
2014
|
-
// scripts/josh/process-identity.ts
|
|
2015
|
-
import { execFileSync as execFileSync2, spawnSync } from "node:child_process";
|
|
2016
|
-
import { randomUUID } from "node:crypto";
|
|
2017
|
-
import { readFileSync as readFileSync2, rmSync } from "node:fs";
|
|
2018
|
-
import { createServer } from "node:net";
|
|
2019
|
-
import path from "node:path";
|
|
2020
|
-
var PS_COMMAND = "/bin/ps";
|
|
2021
|
-
var FORMAT_FLAG = "-o";
|
|
2022
|
-
var START_TIME_FORMAT = "lstart=";
|
|
2023
|
-
var PID_FLAG = "-p";
|
|
2024
|
-
var PROBE_ENVIRONMENT = { TZ: "UTC", LC_ALL: "C" };
|
|
2025
|
-
var PROBE_TIMEOUT_MS2 = 2e3;
|
|
2026
|
-
var LIVENESS_SIGNAL = 0;
|
|
2027
|
-
var LOWEST_REAL_PID = 1;
|
|
2028
|
-
var PROC_START_FIELD_INDEX = 19;
|
|
2029
|
-
var BEACON_SCHEME = "socket:";
|
|
2030
|
-
var BEACON_SUFFIX = ".sock";
|
|
2031
|
-
var BEACON_PREFIX = `josh-process-identity-${String(process.getuid?.() ?? "")}-`;
|
|
2032
|
-
var BEACON_ID_LENGTH = 36;
|
|
2033
|
-
var BEACON_ID_PATTERN = /^[\da-f-]+$/u;
|
|
2034
|
-
var WINDOWS_PLATFORM = "win32";
|
|
2035
|
-
var SOCKET_PROBE_SOURCE = "const net=require('node:net');const socket=net.createConnection(process.argv[1]);socket.once('connect',()=>process.exit(0));socket.once('error',()=>process.exit(1));socket.setTimeout(1000,()=>process.exit(1));";
|
|
2036
|
-
var beacons = /* @__PURE__ */ new Map();
|
|
2037
|
-
var exit_cleanup = { is_registered: false };
|
|
2038
|
-
function is_live_pid(pid) {
|
|
2039
|
-
if (pid < LOWEST_REAL_PID) return false;
|
|
2040
|
-
try {
|
|
2041
|
-
process.kill(pid, LIVENESS_SIGNAL);
|
|
2042
|
-
return true;
|
|
2043
|
-
} catch {
|
|
2044
|
-
return false;
|
|
2045
|
-
}
|
|
2046
|
-
}
|
|
2047
|
-
function read_proc_start(pid) {
|
|
2048
|
-
try {
|
|
2049
|
-
const stat = readFileSync2(`/proc/${String(pid)}/stat`, "utf8");
|
|
2050
|
-
const fields = stat.slice(stat.lastIndexOf(")") + 1).trim().split(/\s+/u);
|
|
2051
|
-
const start = fields[PROC_START_FIELD_INDEX];
|
|
2052
|
-
return start === void 0 ? void 0 : `proc:${start}`;
|
|
2053
|
-
} catch {
|
|
2054
|
-
return void 0;
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
function read_ps_start(pid) {
|
|
2058
|
-
try {
|
|
2059
|
-
const printed = execFileSync2(
|
|
2060
|
-
PS_COMMAND,
|
|
2061
|
-
[FORMAT_FLAG, START_TIME_FORMAT, PID_FLAG, String(pid)],
|
|
2062
|
-
{
|
|
2063
|
-
encoding: "utf8",
|
|
2064
|
-
timeout: PROBE_TIMEOUT_MS2,
|
|
2065
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
2066
|
-
env: PROBE_ENVIRONMENT
|
|
2067
|
-
}
|
|
2068
|
-
).trim();
|
|
2069
|
-
return printed.length > 0 ? printed : void 0;
|
|
2070
|
-
} catch {
|
|
2071
|
-
return void 0;
|
|
2072
|
-
}
|
|
2073
|
-
}
|
|
2074
|
-
var START_PROBES = { read_proc_start, read_ps_start };
|
|
2075
|
-
function safe_probe(probe, pid) {
|
|
2076
|
-
try {
|
|
2077
|
-
return probe(pid);
|
|
2078
|
-
} catch {
|
|
2079
|
-
return void 0;
|
|
2080
|
-
}
|
|
2081
|
-
}
|
|
2082
|
-
function read_start(pid, probes = START_PROBES) {
|
|
2083
|
-
return safe_probe(probes.read_proc_start, pid) ?? safe_probe(probes.read_ps_start, pid);
|
|
2084
|
-
}
|
|
2085
|
-
function close_beacon(token) {
|
|
2086
|
-
const server = beacons.get(token);
|
|
2087
|
-
if (server === void 0) return;
|
|
2088
|
-
beacons.delete(token);
|
|
2089
|
-
server.close();
|
|
2090
|
-
rmSync(token.slice(BEACON_SCHEME.length), { force: true });
|
|
2091
|
-
}
|
|
2092
|
-
function close_beacons() {
|
|
2093
|
-
for (const token of beacons.keys()) close_beacon(token);
|
|
2094
|
-
}
|
|
2095
|
-
function ensure_exit_cleanup() {
|
|
2096
|
-
if (exit_cleanup.is_registered) return;
|
|
2097
|
-
exit_cleanup.is_registered = true;
|
|
2098
|
-
process.once("exit", close_beacons);
|
|
2099
|
-
}
|
|
2100
|
-
function ignore_beacon_error() {
|
|
2101
|
-
}
|
|
2102
|
-
function bind_beacon(target) {
|
|
2103
|
-
return createServer().on("error", ignore_beacon_error).listen(target);
|
|
2104
|
-
}
|
|
2105
|
-
function try_bind_beacon(bind, target) {
|
|
2106
|
-
try {
|
|
2107
|
-
const server = bind(target);
|
|
2108
|
-
return server.listening ? server : void 0;
|
|
2109
|
-
} catch {
|
|
2110
|
-
return void 0;
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
2113
|
-
function open_beacon(bind = bind_beacon) {
|
|
2114
|
-
const target = path.join(PLATFORM_TEMP_ROOT, `${BEACON_PREFIX}${randomUUID()}${BEACON_SUFFIX}`);
|
|
2115
|
-
const token = `${BEACON_SCHEME}${target}`;
|
|
2116
|
-
const server = try_bind_beacon(bind, target);
|
|
2117
|
-
if (server === void 0) return void 0;
|
|
2118
|
-
server.unref();
|
|
2119
|
-
beacons.set(token, server);
|
|
2120
|
-
ensure_exit_cleanup();
|
|
2121
|
-
return token;
|
|
2122
|
-
}
|
|
2123
|
-
function resolve_own_start(probes = START_PROBES, platform2 = process.platform) {
|
|
2124
|
-
const start = read_start(process.pid, probes);
|
|
2125
|
-
if (start !== void 0 || platform2 === WINDOWS_PLATFORM) return start;
|
|
2126
|
-
return open_beacon();
|
|
2127
|
-
}
|
|
2128
|
-
function is_valid_beacon_name(name) {
|
|
2129
|
-
if (!name.startsWith(BEACON_PREFIX) || !name.endsWith(BEACON_SUFFIX)) return false;
|
|
2130
|
-
const id = name.slice(BEACON_PREFIX.length, -BEACON_SUFFIX.length);
|
|
2131
|
-
return id.length === BEACON_ID_LENGTH && BEACON_ID_PATTERN.test(id);
|
|
2132
|
-
}
|
|
2133
|
-
function beacon_target(token) {
|
|
2134
|
-
if (!token.startsWith(BEACON_SCHEME)) return void 0;
|
|
2135
|
-
const target = token.slice(BEACON_SCHEME.length);
|
|
2136
|
-
if (path.dirname(target) !== PLATFORM_TEMP_ROOT) return void 0;
|
|
2137
|
-
return is_valid_beacon_name(path.basename(target)) ? target : void 0;
|
|
2138
|
-
}
|
|
2139
|
-
function is_live_beacon(target) {
|
|
2140
|
-
return spawnSync(process.execPath, ["-e", SOCKET_PROBE_SOURCE, target], {
|
|
2141
|
-
stdio: "ignore",
|
|
2142
|
-
timeout: PROBE_TIMEOUT_MS2
|
|
2143
|
-
}).status === 0;
|
|
2144
|
-
}
|
|
2145
|
-
function has_matching_start(pid, recorded_start, read3) {
|
|
2146
|
-
const observed = read3(pid);
|
|
2147
|
-
return observed === void 0 ? void 0 : observed === recorded_start;
|
|
2148
|
-
}
|
|
2149
|
-
function matches_recorded_start(pid, recorded_start, read3) {
|
|
2150
|
-
const target = beacon_target(recorded_start);
|
|
2151
|
-
return target === void 0 ? has_matching_start(pid, recorded_start, read3) : is_live_beacon(target);
|
|
2152
|
-
}
|
|
2153
|
-
var own_probe = /* @__PURE__ */ new Map();
|
|
2154
|
-
function own_start() {
|
|
2155
|
-
if (!own_probe.has(process.pid)) own_probe.set(process.pid, resolve_own_start());
|
|
2156
|
-
return own_probe.get(process.pid);
|
|
2157
|
-
}
|
|
2158
|
-
function own_fields() {
|
|
2159
|
-
const start = own_start();
|
|
2160
|
-
return { pid: process.pid, ...start !== void 0 && { process_start: start } };
|
|
2161
|
-
}
|
|
2162
|
-
function is_same_process(pid, recorded_start, read3 = read_start) {
|
|
2163
|
-
if (pid === void 0 || !is_live_pid(pid)) return false;
|
|
2164
|
-
if (recorded_start === void 0) return void 0;
|
|
2165
|
-
return matches_recorded_start(pid, recorded_start, read3);
|
|
2166
|
-
}
|
|
2167
|
-
function is_own_process(pid, recorded_start) {
|
|
2168
|
-
return pid === process.pid && recorded_start === own_start();
|
|
2169
|
-
}
|
|
2170
|
-
var process_identity = {
|
|
2171
|
-
close_beacon,
|
|
2172
|
-
is_live_pid,
|
|
2173
|
-
is_own_process,
|
|
2174
|
-
is_same_process,
|
|
2175
|
-
open_beacon,
|
|
2176
|
-
own_fields,
|
|
2177
|
-
own_start,
|
|
2178
|
-
read_start,
|
|
2179
|
-
resolve_own_start
|
|
2180
|
-
};
|
|
2181
|
-
|
|
2182
|
-
// scripts/run/run-carry.ts
|
|
2183
|
-
import { z as z6 } from "zod";
|
|
2184
|
-
|
|
2185
|
-
// scripts/run/run-carry-streak.ts
|
|
2186
|
-
var NO_INCREMENT = 0;
|
|
2187
|
-
var OUTAGE_FOLD_WINDOW_MS = 12e4;
|
|
2188
|
-
function has_increment(value) {
|
|
2189
|
-
return (value ?? NO_INCREMENT) > NO_INCREMENT;
|
|
2190
|
-
}
|
|
2191
|
-
function next_failures(carry, change) {
|
|
2192
|
-
if (has_increment(change.merged)) return NO_INCREMENT;
|
|
2193
|
-
return carry.failures + (change.failures ?? NO_INCREMENT);
|
|
2194
|
-
}
|
|
2195
|
-
function is_within_fold_window(last_outage_at, now) {
|
|
2196
|
-
if (last_outage_at === void 0) return false;
|
|
2197
|
-
const last = Date.parse(last_outage_at);
|
|
2198
|
-
if (Number.isNaN(last)) return false;
|
|
2199
|
-
return now.getTime() - last <= OUTAGE_FOLD_WINDOW_MS;
|
|
2200
|
-
}
|
|
2201
|
-
function folded_outage(carry) {
|
|
2202
|
-
return { outages: carry.outages, last_outage_at: carry.last_outage_at };
|
|
2203
|
-
}
|
|
2204
|
-
function counted_outage(carry, change, now) {
|
|
2205
|
-
const outages = carry.outages + (change.outages ?? NO_INCREMENT);
|
|
2206
|
-
return { outages, last_outage_at: now.toISOString() };
|
|
2207
|
-
}
|
|
2208
|
-
function next_outage(carry, change, now) {
|
|
2209
|
-
if (has_increment(change.outages)) {
|
|
2210
|
-
return is_within_fold_window(carry.last_outage_at, now) ? folded_outage(carry) : counted_outage(carry, change, now);
|
|
2211
|
-
}
|
|
2212
|
-
const is_reachable = has_increment(change.merged) || has_increment(change.failures);
|
|
2213
|
-
return is_reachable ? { outages: NO_INCREMENT, last_outage_at: void 0 } : folded_outage(carry);
|
|
2214
|
-
}
|
|
2215
|
-
function next_state(carry, change, now) {
|
|
2216
|
-
const outage = next_outage(carry, change, now);
|
|
2217
|
-
return {
|
|
2218
|
-
failures: next_failures(carry, change),
|
|
2219
|
-
outages: outage.outages,
|
|
2220
|
-
last_outage_at: outage.last_outage_at
|
|
2221
|
-
};
|
|
2222
|
-
}
|
|
2223
|
-
var run_carry_streak = { next_state };
|
|
2224
|
-
|
|
2225
|
-
// scripts/run/run-carry-change.ts
|
|
2226
|
-
var NO_INCREMENT2 = 0;
|
|
2227
|
-
function next_done(carry, done) {
|
|
2228
|
-
if (done === void 0) return carry.done;
|
|
2229
|
-
const current = carry.done ?? [];
|
|
2230
|
-
return current.includes(done) ? current : [...current, done];
|
|
2231
|
-
}
|
|
2232
|
-
function next_merged_issues(carry, issue) {
|
|
2233
|
-
if (issue === void 0) return carry.merged_issues;
|
|
2234
|
-
return [...carry.merged_issues ?? [], issue];
|
|
2235
|
-
}
|
|
2236
|
-
function is_duplicate_merge(carry, change) {
|
|
2237
|
-
const issue = change.merged_issue;
|
|
2238
|
-
return issue !== void 0 && carry.merged_issues?.includes(issue) === true;
|
|
2239
|
-
}
|
|
2240
|
-
function next_counts(carry, change) {
|
|
2241
|
-
const cuts = change.cuts ?? NO_INCREMENT2;
|
|
2242
|
-
return {
|
|
2243
|
-
merged: carry.merged + (change.merged ?? NO_INCREMENT2),
|
|
2244
|
-
filed: carry.filed + (change.filed ?? NO_INCREMENT2),
|
|
2245
|
-
cuts: carry.cuts + cuts,
|
|
2246
|
-
is_handed_off: cuts > NO_INCREMENT2
|
|
2247
|
-
};
|
|
2248
|
-
}
|
|
2249
|
-
function apply_change(target, carry, change, now = /* @__PURE__ */ new Date()) {
|
|
2250
|
-
if (is_duplicate_merge(carry, change)) return carry;
|
|
2251
|
-
const streak = run_carry_streak.next_state(carry, change, now);
|
|
2252
|
-
const next = {
|
|
2253
|
-
...carry,
|
|
2254
|
-
...next_counts(carry, change),
|
|
2255
|
-
merged_issues: next_merged_issues(carry, change.merged_issue),
|
|
2256
|
-
failures: streak.failures,
|
|
2257
|
-
outages: streak.outages,
|
|
2258
|
-
last_outage_at: streak.last_outage_at,
|
|
2259
|
-
done: next_done(carry, change.done),
|
|
2260
|
-
retrospective: change.retrospective === true || carry.retrospective
|
|
2261
|
-
};
|
|
2262
|
-
stamp_file.write_stamp(target, next);
|
|
2263
|
-
return next;
|
|
2264
|
-
}
|
|
2265
|
-
var run_carry_change = { apply_change };
|
|
2266
|
-
|
|
2267
|
-
// scripts/run/run-carry-conversation.ts
|
|
2268
|
-
import { existsSync, statSync } from "node:fs";
|
|
2269
|
-
import path2 from "node:path";
|
|
2270
|
-
|
|
2271
|
-
// scripts/cost-runtime/own-session.ts
|
|
2272
|
-
var NOT_FOUND = -1;
|
|
2273
|
-
function session_id_of(environment2) {
|
|
2274
|
-
const value = environment2[agent_session_environment.SESSION_ID_KEY];
|
|
2275
|
-
return value === void 0 || value === "" ? void 0 : value;
|
|
2276
|
-
}
|
|
2277
|
-
function select_own_session(files, environment2) {
|
|
2278
|
-
const session_id = session_id_of(environment2);
|
|
2279
|
-
if (session_id === void 0) {
|
|
2280
|
-
return { kind: "own", index: cost_transcript.latest_own_index(files) };
|
|
2281
|
-
}
|
|
2282
|
-
const index = files.findIndex((file) => file.session_id === session_id);
|
|
2283
|
-
return index === NOT_FOUND ? { kind: "absent", session_id } : { kind: "own", index };
|
|
2284
|
-
}
|
|
2285
|
-
var own_session = {
|
|
2286
|
-
session_id_of,
|
|
2287
|
-
select_own_session
|
|
2288
|
-
};
|
|
2289
|
-
|
|
2290
|
-
// scripts/run/run-carry-conversation.ts
|
|
2291
|
-
var CONVERSATION_QUIET_MS = 6e5;
|
|
2292
|
-
function own_transcript(environment2 = process.env, directories2 = cost_transcript.transcript_directories(process.cwd())) {
|
|
2293
|
-
const session_id = own_session.session_id_of(environment2);
|
|
2294
|
-
if (session_id === void 0) return void 0;
|
|
2295
|
-
const name = `${session_id}${cost_transcript.TRANSCRIPT_EXTENSION}`;
|
|
2296
|
-
return directories2.map((directory) => path2.join(directory, name)).find((file) => existsSync(file));
|
|
2297
|
-
}
|
|
2298
|
-
function modified_ms(transcript) {
|
|
2299
|
-
try {
|
|
2300
|
-
return statSync(transcript).mtimeMs;
|
|
2301
|
-
} catch {
|
|
2302
|
-
return void 0;
|
|
2303
|
-
}
|
|
2304
|
-
}
|
|
2305
|
-
function is_recent(modified, now) {
|
|
2306
|
-
return modified !== void 0 && now.getTime() - modified <= CONVERSATION_QUIET_MS;
|
|
2307
|
-
}
|
|
2308
|
-
function is_conversation_live(carry, now = /* @__PURE__ */ new Date(), read_modified = modified_ms) {
|
|
2309
|
-
if (carry.is_handed_off === true || carry.owner_transcript === void 0) return false;
|
|
2310
|
-
return is_recent(read_modified(carry.owner_transcript), now);
|
|
2071
|
+
return launched2.filter((id) => id !== "" && !finished.has(id));
|
|
2311
2072
|
}
|
|
2312
|
-
function
|
|
2313
|
-
return
|
|
2073
|
+
function pending_background_ids(tail) {
|
|
2074
|
+
return unfinished_ids(tail, (block) => [block.background_id, block.agent_id]);
|
|
2314
2075
|
}
|
|
2315
|
-
function
|
|
2316
|
-
|
|
2317
|
-
if (owner.pid === carry.owner_pid) return carry;
|
|
2318
|
-
return { ...carry, owner_pid: owner.pid, owner_start: owner.start };
|
|
2076
|
+
function pending_agent_ids(tail) {
|
|
2077
|
+
return unfinished_ids(tail, (block) => [block.agent_id]);
|
|
2319
2078
|
}
|
|
2320
|
-
var
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2079
|
+
var LANE_BACKGROUND_REASON = '\u26D4 lane background: this session is a dispatched lane child (`JOSH_LANE_CHILD`), a headless `claude -p` process whose background Bash tasks are killed when the turn ends \u2014 so a backgrounded `josh gate` / `josh git` / `josh followup` / `josh ship` never re-invokes you; it dies at `exit code 143` (joshuafolkken/kit#2704, measured on the #2606 child: implementation, review and live verification done, the run parked instead of merged). Hand the gate-to-merge region to the detached supervisor instead: `pnpm josh ship --detach --review "<title> #<N>"` (add `--cite <N>`) issued in the foreground \u2014 its preflight runs in this process before the supervisor exists, so a backgrounded `ship` dies with the turn (joshuafolkken/kit#3027; a backgrounded `ship` issued alone is moved to the foreground for you, joshuafolkken/kit#3154) \u2014 then end the turn on `launched` / `busy`. `.claude/skills/workflow-commands/chain-rule.md` step 0 is the single source. A single check you must read before continuing runs in the foreground within the tool timeout; the commit-push step does not \u2014 in a child it too belongs to the detached ship, in either spelling. This rule fires on every occurrence, not once per run.';
|
|
2080
|
+
var LANE_BACKGROUND_STOP_REASON = "\u26D4 lane background stop: this is a dispatched lane child (`JOSH_LANE_CHILD`) and a background task it launched has not finished \u2014 ending this headless turn kills it, and nothing re-invokes you afterwards (joshuafolkken/kit#2704). Do not send a notification and do not stop: wait for the task in the foreground and act on its result, or re-issue the work through `pnpm josh ship --detach`, whose supervisor outlives the turn (`.claude/skills/workflow-commands/chain-rule.md` step 0). Do not repeat your previous reply.";
|
|
2081
|
+
var ROW2 = {
|
|
2082
|
+
id: "lane-background",
|
|
2083
|
+
is_trigger: (call) => is_background_long_run(call),
|
|
2084
|
+
reason: LANE_BACKGROUND_REASON,
|
|
2085
|
+
decide: () => true
|
|
2086
|
+
};
|
|
2087
|
+
var lane_background = {
|
|
2088
|
+
FOREGROUND_NOTE,
|
|
2089
|
+
LANE_BACKGROUND_REASON,
|
|
2090
|
+
LANE_BACKGROUND_STOP_REASON,
|
|
2091
|
+
ROW: ROW2,
|
|
2092
|
+
foreground_input,
|
|
2093
|
+
is_background_long_run,
|
|
2094
|
+
pending_agent_ids,
|
|
2095
|
+
pending_background_ids
|
|
2326
2096
|
};
|
|
2327
2097
|
|
|
2098
|
+
// scripts/agent/agent-headless.ts
|
|
2099
|
+
var KEY = "JOSH_AGENT_HEADLESS";
|
|
2100
|
+
var VALUE = "1";
|
|
2101
|
+
function environment() {
|
|
2102
|
+
return { [KEY]: VALUE };
|
|
2103
|
+
}
|
|
2104
|
+
function is_headless(source = process.env) {
|
|
2105
|
+
return source[KEY] === VALUE;
|
|
2106
|
+
}
|
|
2107
|
+
var agent_headless = { KEY, environment, is_headless };
|
|
2108
|
+
|
|
2328
2109
|
// scripts/backlog/backlog-budget-cli.ts
|
|
2329
2110
|
import { fileURLToPath } from "node:url";
|
|
2330
2111
|
|
|
@@ -2411,7 +2192,50 @@ function arguments_of(argv, options) {
|
|
|
2411
2192
|
function string_of(value) {
|
|
2412
2193
|
return typeof value === "string" ? value : void 0;
|
|
2413
2194
|
}
|
|
2414
|
-
var
|
|
2195
|
+
var LONG_FLAG_PREFIX = "--";
|
|
2196
|
+
var SHORT_FLAG_PREFIX = "-";
|
|
2197
|
+
function option_name(flag) {
|
|
2198
|
+
return flag.slice(LONG_FLAG_PREFIX.length);
|
|
2199
|
+
}
|
|
2200
|
+
function is_unusable_value(value) {
|
|
2201
|
+
if (typeof value === "boolean" || value.length === 0) return true;
|
|
2202
|
+
return value !== SHORT_FLAG_PREFIX && value.startsWith(SHORT_FLAG_PREFIX);
|
|
2203
|
+
}
|
|
2204
|
+
function given_values(argv, flag) {
|
|
2205
|
+
const name = option_name(flag);
|
|
2206
|
+
const given = parse_or_undefined({
|
|
2207
|
+
args: [...argv],
|
|
2208
|
+
options: { [name]: { type: "string", multiple: true } },
|
|
2209
|
+
strict: false,
|
|
2210
|
+
allowPositionals: true
|
|
2211
|
+
})?.values[name];
|
|
2212
|
+
return Array.isArray(given) ? given : [];
|
|
2213
|
+
}
|
|
2214
|
+
function is_value_unusable(argv, flag) {
|
|
2215
|
+
return given_values(argv, flag).some((value) => is_unusable_value(value));
|
|
2216
|
+
}
|
|
2217
|
+
function attach_one(attached, argument, flags) {
|
|
2218
|
+
const previous = attached.at(-1);
|
|
2219
|
+
if (previous !== void 0 && flags.includes(previous)) {
|
|
2220
|
+
attached[attached.length - 1] = `${previous}=${argument}`;
|
|
2221
|
+
} else attached.push(argument);
|
|
2222
|
+
}
|
|
2223
|
+
function attach_values(argv, flags) {
|
|
2224
|
+
const attached = [];
|
|
2225
|
+
for (const argument of argv) attach_one(attached, argument, flags);
|
|
2226
|
+
return attached;
|
|
2227
|
+
}
|
|
2228
|
+
var cli_flags = {
|
|
2229
|
+
attach_values,
|
|
2230
|
+
refuse_unknown_flags,
|
|
2231
|
+
parse_or_undefined,
|
|
2232
|
+
values_of,
|
|
2233
|
+
arguments_of,
|
|
2234
|
+
string_of,
|
|
2235
|
+
option_name,
|
|
2236
|
+
given_values,
|
|
2237
|
+
is_value_unusable
|
|
2238
|
+
};
|
|
2415
2239
|
|
|
2416
2240
|
// scripts/backlog/backlog-budget-cli.ts
|
|
2417
2241
|
var ARGV_OFFSET = 2;
|
|
@@ -2500,7 +2324,7 @@ function refuse() {
|
|
|
2500
2324
|
console.error(USAGE);
|
|
2501
2325
|
return FAILURE_EXIT_CODE2;
|
|
2502
2326
|
}
|
|
2503
|
-
function
|
|
2327
|
+
function run3(argv, now_ms = Date.now()) {
|
|
2504
2328
|
const values = read_arguments(argv);
|
|
2505
2329
|
if (values === void 0) return refuse();
|
|
2506
2330
|
const input = build_input(values, now_ms);
|
|
@@ -2516,7 +2340,7 @@ function run2(argv, now_ms = Date.now()) {
|
|
|
2516
2340
|
return SUCCESS_EXIT_CODE2;
|
|
2517
2341
|
}
|
|
2518
2342
|
function main(argv) {
|
|
2519
|
-
process.exitCode =
|
|
2343
|
+
process.exitCode = run3(argv);
|
|
2520
2344
|
}
|
|
2521
2345
|
var backlog_budget_cli = {
|
|
2522
2346
|
JSON_KEY,
|
|
@@ -2526,7 +2350,7 @@ var backlog_budget_cli = {
|
|
|
2526
2350
|
build_input,
|
|
2527
2351
|
main,
|
|
2528
2352
|
read_arguments,
|
|
2529
|
-
run:
|
|
2353
|
+
run: run3,
|
|
2530
2354
|
to_answer,
|
|
2531
2355
|
to_count,
|
|
2532
2356
|
to_time_ms
|
|
@@ -2537,38 +2361,34 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) main(process.argv.slice(
|
|
|
2537
2361
|
var BACKLOG_COMMAND = "backlogrun";
|
|
2538
2362
|
var KNOWN_FLAGS2 = ["--max", "--idle"];
|
|
2539
2363
|
var ONLY_FLAG = "--only";
|
|
2364
|
+
var OPTIONS2 = {
|
|
2365
|
+
max: { type: "string" },
|
|
2366
|
+
idle: { type: "string" },
|
|
2367
|
+
only: { type: "boolean" }
|
|
2368
|
+
};
|
|
2540
2369
|
var ISSUE_PREFIX = "#";
|
|
2370
|
+
var FLAG_PREFIX = "-";
|
|
2541
2371
|
var TOKEN_SEPARATOR = " ";
|
|
2542
2372
|
var FIRST_TOKEN = 0;
|
|
2543
2373
|
var FIRST_ARGUMENT_INDEX = 1;
|
|
2544
|
-
var VALUE_OFFSET = 1;
|
|
2545
|
-
var FLAG_PAIR_LENGTH = 2;
|
|
2546
|
-
var ONLY_STEP = 1;
|
|
2547
2374
|
var EMPTY_LENGTH2 = 0;
|
|
2548
|
-
var
|
|
2375
|
+
var NOT_FOUND = -1;
|
|
2549
2376
|
function tokens_of(invocation) {
|
|
2550
2377
|
return invocation.split(TOKEN_SEPARATOR).filter((token) => token.length > EMPTY_LENGTH2);
|
|
2551
2378
|
}
|
|
2552
|
-
function
|
|
2553
|
-
|
|
2554
|
-
const
|
|
2379
|
+
function render_option(token) {
|
|
2380
|
+
if (token.name === cli_flags.option_name(ONLY_FLAG)) return ONLY_FLAG;
|
|
2381
|
+
const flag = KNOWN_FLAGS2.find((known) => cli_flags.option_name(known) === token.name);
|
|
2382
|
+
const value = backlog_budget_cli.to_count(token.value);
|
|
2555
2383
|
if (flag === void 0 || value === void 0) return void 0;
|
|
2556
2384
|
return `${flag} ${String(value)}`;
|
|
2557
2385
|
}
|
|
2558
|
-
function
|
|
2559
|
-
const token = tokens[index] ?? "";
|
|
2560
|
-
if (token === ONLY_FLAG) return { part: ONLY_FLAG, advance: ONLY_STEP };
|
|
2561
|
-
const part = flag_token(token, tokens[index + VALUE_OFFSET]);
|
|
2562
|
-
return part === void 0 ? void 0 : { part, advance: FLAG_PAIR_LENGTH };
|
|
2563
|
-
}
|
|
2564
|
-
function flag_tokens(tokens, start) {
|
|
2386
|
+
function rendered_options(tokens) {
|
|
2565
2387
|
const rendered = [];
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
rendered.push(read3.part);
|
|
2571
|
-
index += read3.advance;
|
|
2388
|
+
for (const token of tokens) {
|
|
2389
|
+
const part = render_option(token);
|
|
2390
|
+
if (part === void 0) return void 0;
|
|
2391
|
+
rendered.push(part);
|
|
2572
2392
|
}
|
|
2573
2393
|
return rendered;
|
|
2574
2394
|
}
|
|
@@ -2579,49 +2399,59 @@ function issue_of(token) {
|
|
|
2579
2399
|
const issue = Number(digits);
|
|
2580
2400
|
return Number.isSafeInteger(issue) ? issue : void 0;
|
|
2581
2401
|
}
|
|
2582
|
-
function
|
|
2583
|
-
const stop = args.findIndex((token) => !token.startsWith(ISSUE_PREFIX));
|
|
2584
|
-
return args.slice(FIRST_TOKEN, stop === NOT_FOUND2 ? args.length : stop);
|
|
2585
|
-
}
|
|
2586
|
-
function leading_issues(tokens) {
|
|
2402
|
+
function issues_of(tokens) {
|
|
2587
2403
|
const issues = [];
|
|
2588
|
-
const
|
|
2589
|
-
|
|
2590
|
-
const issue = issue_of(token);
|
|
2404
|
+
for (const token of tokens) {
|
|
2405
|
+
const issue = issue_of(token.value ?? "");
|
|
2591
2406
|
if (issue === void 0) return void 0;
|
|
2592
2407
|
issues.push(issue);
|
|
2593
2408
|
}
|
|
2594
2409
|
return issues;
|
|
2595
2410
|
}
|
|
2411
|
+
function argument_tokens(invocation) {
|
|
2412
|
+
const tokens = tokens_of(invocation);
|
|
2413
|
+
if (tokens[FIRST_TOKEN] !== BACKLOG_COMMAND) return void 0;
|
|
2414
|
+
return cli_flags.parse_or_undefined({
|
|
2415
|
+
args: tokens.slice(FIRST_ARGUMENT_INDEX),
|
|
2416
|
+
options: OPTIONS2,
|
|
2417
|
+
allowPositionals: true,
|
|
2418
|
+
tokens: true
|
|
2419
|
+
})?.tokens;
|
|
2420
|
+
}
|
|
2421
|
+
function parse2(invocation) {
|
|
2422
|
+
const tokens = argument_tokens(invocation);
|
|
2423
|
+
if (tokens === void 0) return void 0;
|
|
2424
|
+
const stop = tokens.findIndex((token) => token.kind !== "positional");
|
|
2425
|
+
const split_at = stop === NOT_FOUND ? tokens.length : stop;
|
|
2426
|
+
const issues = issues_of(tokens.slice(FIRST_TOKEN, split_at));
|
|
2427
|
+
const flags = rendered_options(tokens.slice(split_at));
|
|
2428
|
+
if (issues === void 0 || flags === void 0) return void 0;
|
|
2429
|
+
return { issues, flags };
|
|
2430
|
+
}
|
|
2596
2431
|
function issue_token(issue) {
|
|
2597
2432
|
return `${ISSUE_PREFIX}${String(issue)}`;
|
|
2598
2433
|
}
|
|
2599
2434
|
function joined(command, rendered) {
|
|
2600
2435
|
return [command, ...rendered].join(TOKEN_SEPARATOR);
|
|
2601
2436
|
}
|
|
2602
|
-
function rebuilt_backlog(tokens) {
|
|
2603
|
-
const issues = leading_issues(tokens);
|
|
2604
|
-
if (issues === void 0) return void 0;
|
|
2605
|
-
const flags = flag_tokens(tokens, FIRST_ARGUMENT_INDEX + issues.length);
|
|
2606
|
-
if (flags === void 0) return void 0;
|
|
2607
|
-
return joined(BACKLOG_COMMAND, [...issues.map((issue) => issue_token(issue)), ...flags]);
|
|
2608
|
-
}
|
|
2609
2437
|
function rebuild(invocation) {
|
|
2610
|
-
const
|
|
2611
|
-
if (
|
|
2612
|
-
return
|
|
2438
|
+
const parsed = parse2(invocation);
|
|
2439
|
+
if (parsed === void 0) return void 0;
|
|
2440
|
+
return joined(BACKLOG_COMMAND, [
|
|
2441
|
+
...parsed.issues.map((issue) => issue_token(issue)),
|
|
2442
|
+
...parsed.flags
|
|
2443
|
+
]);
|
|
2613
2444
|
}
|
|
2614
2445
|
function issue_numbers(invocation) {
|
|
2615
2446
|
const tokens = tokens_of(invocation);
|
|
2616
|
-
|
|
2617
|
-
const
|
|
2447
|
+
const stop = tokens.findIndex((token) => token.startsWith(FLAG_PREFIX));
|
|
2448
|
+
const leading = stop === NOT_FOUND ? tokens : tokens.slice(FIRST_TOKEN, stop);
|
|
2449
|
+
const issues = parse2(leading.join(TOKEN_SEPARATOR))?.issues;
|
|
2618
2450
|
if (issues === void 0 || issues.length === EMPTY_LENGTH2) return void 0;
|
|
2619
2451
|
return issues;
|
|
2620
2452
|
}
|
|
2621
2453
|
function has_only(invocation) {
|
|
2622
|
-
|
|
2623
|
-
if (tokens[FIRST_TOKEN] !== BACKLOG_COMMAND) return false;
|
|
2624
|
-
return tokens.slice(FIRST_ARGUMENT_INDEX).includes(ONLY_FLAG);
|
|
2454
|
+
return parse2(invocation)?.flags.includes(ONLY_FLAG) === true;
|
|
2625
2455
|
}
|
|
2626
2456
|
var run_invocation = {
|
|
2627
2457
|
has_only,
|
|
@@ -2629,7 +2459,164 @@ var run_invocation = {
|
|
|
2629
2459
|
rebuild
|
|
2630
2460
|
};
|
|
2631
2461
|
|
|
2632
|
-
// scripts/run/run-carry.ts
|
|
2462
|
+
// scripts/run/carry/run-carry.ts
|
|
2463
|
+
import { z as z6 } from "zod";
|
|
2464
|
+
|
|
2465
|
+
// scripts/run/carry/run-carry-streak.ts
|
|
2466
|
+
var NO_INCREMENT = 0;
|
|
2467
|
+
var OUTAGE_FOLD_WINDOW_MS = 12e4;
|
|
2468
|
+
function has_increment(value) {
|
|
2469
|
+
return (value ?? NO_INCREMENT) > NO_INCREMENT;
|
|
2470
|
+
}
|
|
2471
|
+
function next_failures(carry, change) {
|
|
2472
|
+
if (has_increment(change.merged)) return NO_INCREMENT;
|
|
2473
|
+
return carry.failures + (change.failures ?? NO_INCREMENT);
|
|
2474
|
+
}
|
|
2475
|
+
function is_within_fold_window(last_outage_at, now) {
|
|
2476
|
+
if (last_outage_at === void 0) return false;
|
|
2477
|
+
const last = Date.parse(last_outage_at);
|
|
2478
|
+
if (Number.isNaN(last)) return false;
|
|
2479
|
+
return now.getTime() - last <= OUTAGE_FOLD_WINDOW_MS;
|
|
2480
|
+
}
|
|
2481
|
+
function folded_outage(carry) {
|
|
2482
|
+
return { outages: carry.outages, last_outage_at: carry.last_outage_at };
|
|
2483
|
+
}
|
|
2484
|
+
function counted_outage(carry, change, now) {
|
|
2485
|
+
const outages = carry.outages + (change.outages ?? NO_INCREMENT);
|
|
2486
|
+
return { outages, last_outage_at: now.toISOString() };
|
|
2487
|
+
}
|
|
2488
|
+
function next_outage(carry, change, now) {
|
|
2489
|
+
if (has_increment(change.outages)) {
|
|
2490
|
+
return is_within_fold_window(carry.last_outage_at, now) ? folded_outage(carry) : counted_outage(carry, change, now);
|
|
2491
|
+
}
|
|
2492
|
+
const is_reachable = has_increment(change.merged) || has_increment(change.failures);
|
|
2493
|
+
return is_reachable ? { outages: NO_INCREMENT, last_outage_at: void 0 } : folded_outage(carry);
|
|
2494
|
+
}
|
|
2495
|
+
function next_state(carry, change, now) {
|
|
2496
|
+
const outage = next_outage(carry, change, now);
|
|
2497
|
+
return {
|
|
2498
|
+
failures: next_failures(carry, change),
|
|
2499
|
+
outages: outage.outages,
|
|
2500
|
+
last_outage_at: outage.last_outage_at
|
|
2501
|
+
};
|
|
2502
|
+
}
|
|
2503
|
+
var run_carry_streak = { next_state };
|
|
2504
|
+
|
|
2505
|
+
// scripts/run/carry/run-carry-change.ts
|
|
2506
|
+
var NO_INCREMENT2 = 0;
|
|
2507
|
+
function next_done(carry, done) {
|
|
2508
|
+
if (done === void 0) return carry.done;
|
|
2509
|
+
const current = carry.done ?? [];
|
|
2510
|
+
return current.includes(done) ? current : [...current, done];
|
|
2511
|
+
}
|
|
2512
|
+
function next_merged_issues(carry, issue) {
|
|
2513
|
+
if (issue === void 0) return carry.merged_issues;
|
|
2514
|
+
const current = carry.merged_issues ?? [];
|
|
2515
|
+
return current.includes(issue) ? current : [...current, issue];
|
|
2516
|
+
}
|
|
2517
|
+
function is_duplicate_merge(carry, change) {
|
|
2518
|
+
const issue = change.merged_issue;
|
|
2519
|
+
return issue !== void 0 && carry.merged_issues?.includes(issue) === true;
|
|
2520
|
+
}
|
|
2521
|
+
function has_other_change(change) {
|
|
2522
|
+
const amounts = [change.filed, change.cuts, change.failures, change.outages];
|
|
2523
|
+
const has_amount = amounts.some((amount) => (amount ?? NO_INCREMENT2) > NO_INCREMENT2);
|
|
2524
|
+
return has_amount || change.done !== void 0 || change.retrospective === true;
|
|
2525
|
+
}
|
|
2526
|
+
function effective_change(carry, change) {
|
|
2527
|
+
if (!is_duplicate_merge(carry, change)) return change;
|
|
2528
|
+
return has_other_change(change) ? { ...change, merged: NO_INCREMENT2 } : void 0;
|
|
2529
|
+
}
|
|
2530
|
+
function next_counts(carry, change) {
|
|
2531
|
+
const cuts = change.cuts ?? NO_INCREMENT2;
|
|
2532
|
+
return {
|
|
2533
|
+
merged: carry.merged + (change.merged ?? NO_INCREMENT2),
|
|
2534
|
+
filed: carry.filed + (change.filed ?? NO_INCREMENT2),
|
|
2535
|
+
cuts: carry.cuts + cuts,
|
|
2536
|
+
is_handed_off: cuts > NO_INCREMENT2
|
|
2537
|
+
};
|
|
2538
|
+
}
|
|
2539
|
+
function apply_change(target, carry, change, now = /* @__PURE__ */ new Date()) {
|
|
2540
|
+
const effective = effective_change(carry, change);
|
|
2541
|
+
if (effective === void 0) return carry;
|
|
2542
|
+
const streak = run_carry_streak.next_state(carry, effective, now);
|
|
2543
|
+
const next = {
|
|
2544
|
+
...carry,
|
|
2545
|
+
...next_counts(carry, effective),
|
|
2546
|
+
merged_issues: next_merged_issues(carry, effective.merged_issue),
|
|
2547
|
+
failures: streak.failures,
|
|
2548
|
+
outages: streak.outages,
|
|
2549
|
+
last_outage_at: streak.last_outage_at,
|
|
2550
|
+
done: next_done(carry, effective.done),
|
|
2551
|
+
retrospective: effective.retrospective === true || carry.retrospective
|
|
2552
|
+
};
|
|
2553
|
+
stamp_file.write_stamp(target, next);
|
|
2554
|
+
return next;
|
|
2555
|
+
}
|
|
2556
|
+
var run_carry_change = { apply_change };
|
|
2557
|
+
|
|
2558
|
+
// scripts/run/carry/run-carry-conversation.ts
|
|
2559
|
+
import { existsSync, statSync } from "node:fs";
|
|
2560
|
+
import path2 from "node:path";
|
|
2561
|
+
|
|
2562
|
+
// scripts/cost-runtime/own-session.ts
|
|
2563
|
+
var NOT_FOUND2 = -1;
|
|
2564
|
+
function session_id_of(environment3) {
|
|
2565
|
+
const value = environment3[agent_session_environment.SESSION_ID_KEY];
|
|
2566
|
+
return value === void 0 || value === "" ? void 0 : value;
|
|
2567
|
+
}
|
|
2568
|
+
function select_own_session(files, environment3) {
|
|
2569
|
+
const session_id = session_id_of(environment3);
|
|
2570
|
+
if (session_id === void 0) {
|
|
2571
|
+
return { kind: "own", index: cost_transcript.latest_own_index(files) };
|
|
2572
|
+
}
|
|
2573
|
+
const index = files.findIndex((file) => file.session_id === session_id);
|
|
2574
|
+
return index === NOT_FOUND2 ? { kind: "absent", session_id } : { kind: "own", index };
|
|
2575
|
+
}
|
|
2576
|
+
var own_session = {
|
|
2577
|
+
session_id_of,
|
|
2578
|
+
select_own_session
|
|
2579
|
+
};
|
|
2580
|
+
|
|
2581
|
+
// scripts/run/carry/run-carry-conversation.ts
|
|
2582
|
+
var CONVERSATION_QUIET_MS = 6e5;
|
|
2583
|
+
function own_transcript(environment3 = process.env, directories2 = cost_transcript.transcript_directories(process.cwd())) {
|
|
2584
|
+
const session_id = own_session.session_id_of(environment3);
|
|
2585
|
+
if (session_id === void 0) return void 0;
|
|
2586
|
+
const name = `${session_id}${cost_transcript.TRANSCRIPT_EXTENSION}`;
|
|
2587
|
+
return directories2.map((directory) => path2.join(directory, name)).find((file) => existsSync(file));
|
|
2588
|
+
}
|
|
2589
|
+
function modified_ms(transcript) {
|
|
2590
|
+
try {
|
|
2591
|
+
return statSync(transcript).mtimeMs;
|
|
2592
|
+
} catch {
|
|
2593
|
+
return void 0;
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
function is_recent(modified, now) {
|
|
2597
|
+
return modified !== void 0 && now.getTime() - modified <= CONVERSATION_QUIET_MS;
|
|
2598
|
+
}
|
|
2599
|
+
function is_conversation_live(carry, now = /* @__PURE__ */ new Date(), read_modified = modified_ms) {
|
|
2600
|
+
if (carry.is_handed_off === true || carry.owner_transcript === void 0) return false;
|
|
2601
|
+
return is_recent(read_modified(carry.owner_transcript), now);
|
|
2602
|
+
}
|
|
2603
|
+
function is_same_conversation(carry, owner) {
|
|
2604
|
+
return owner.transcript !== void 0 && owner.transcript === carry.owner_transcript;
|
|
2605
|
+
}
|
|
2606
|
+
function reclaim_owner(carry, owner) {
|
|
2607
|
+
if (carry.is_handed_off === true || !is_same_conversation(carry, owner)) return carry;
|
|
2608
|
+
if (owner.pid === carry.owner_pid) return carry;
|
|
2609
|
+
return { ...carry, owner_pid: owner.pid, owner_start: owner.start };
|
|
2610
|
+
}
|
|
2611
|
+
var run_carry_conversation = {
|
|
2612
|
+
CONVERSATION_QUIET_MS,
|
|
2613
|
+
own_transcript,
|
|
2614
|
+
is_conversation_live,
|
|
2615
|
+
is_same_conversation,
|
|
2616
|
+
reclaim_owner
|
|
2617
|
+
};
|
|
2618
|
+
|
|
2619
|
+
// scripts/run/carry/run-carry.ts
|
|
2633
2620
|
var CARRY_PREFIX = "josh-run-carry-";
|
|
2634
2621
|
var REPOSITORY_DIRECTORY_INDEX = 1;
|
|
2635
2622
|
var CARRY_MAX_AGE_HOURS = backlog_budget.WHOLE_RUN_BUDGET_HOURS;
|
|
@@ -2852,10 +2839,9 @@ var run_carry = {
|
|
|
2852
2839
|
unreadable_message: unreadable_message3
|
|
2853
2840
|
};
|
|
2854
2841
|
|
|
2855
|
-
// scripts/run/run-ship-detach.ts
|
|
2856
|
-
import { randomUUID
|
|
2842
|
+
// scripts/run/ship/run-ship-detach.ts
|
|
2843
|
+
import { randomUUID } from "node:crypto";
|
|
2857
2844
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
2858
|
-
import { z as z8 } from "zod";
|
|
2859
2845
|
|
|
2860
2846
|
// scripts/run/detached-launch.ts
|
|
2861
2847
|
import { spawn } from "node:child_process";
|
|
@@ -2909,17 +2895,19 @@ function link_home_file(source_home, target_home, name) {
|
|
|
2909
2895
|
const target = path4.join(target_home, name);
|
|
2910
2896
|
if (!remove_old_home_link(source, target) && existsSync2(source)) symlinkSync(source, target);
|
|
2911
2897
|
}
|
|
2912
|
-
function reviewer_home(cwd,
|
|
2913
|
-
const source =
|
|
2898
|
+
function reviewer_home(cwd, environment3) {
|
|
2899
|
+
const source = environment3["CODEX_HOME"] ?? process.env["CODEX_HOME"] ?? codex_home_source.default_home();
|
|
2914
2900
|
const target = path4.resolve(cwd, ...REVIEWER_HOME);
|
|
2915
2901
|
mkdirSync(target, { recursive: true, mode: PRIVATE_DIRECTORY_MODE });
|
|
2916
2902
|
for (const name of HOME_FILES) link_home_file(source, target, name);
|
|
2917
2903
|
return target;
|
|
2918
2904
|
}
|
|
2919
|
-
function build(cwd, profile,
|
|
2920
|
-
if (profile
|
|
2921
|
-
const
|
|
2922
|
-
|
|
2905
|
+
function build(cwd, profile, environment3 = {}) {
|
|
2906
|
+
if (profile === void 0) return environment3;
|
|
2907
|
+
const marked = { ...agent_headless.environment(), ...environment3 };
|
|
2908
|
+
if (profile.provider !== OPENAI_PROVIDER2) return marked;
|
|
2909
|
+
const base = { ...openai_environment(), ...marked };
|
|
2910
|
+
return profile.role === agent_role_profile.REVIEWER ? { ...base, CODEX_HOME: reviewer_home(cwd, environment3) } : base;
|
|
2923
2911
|
}
|
|
2924
2912
|
var agent_launch_environment = { build };
|
|
2925
2913
|
|
|
@@ -2977,12 +2965,12 @@ function ensure_log(log_path2, on_error) {
|
|
|
2977
2965
|
const descriptor = open_log(log_path2, on_error);
|
|
2978
2966
|
if (descriptor !== void 0) closeSync(descriptor);
|
|
2979
2967
|
}
|
|
2980
|
-
function spawn_options(cwd, log,
|
|
2968
|
+
function spawn_options(cwd, log, environment3 = {}, is_detached = true) {
|
|
2981
2969
|
return {
|
|
2982
2970
|
cwd,
|
|
2983
2971
|
detached: is_detached,
|
|
2984
2972
|
stdio: log === void 0 ? "ignore" : ["ignore", log, log],
|
|
2985
|
-
env: { ...process.env, ...agent_session_environment.removed_environment(), ...
|
|
2973
|
+
env: { ...process.env, ...agent_session_environment.removed_environment(), ...environment3 }
|
|
2986
2974
|
};
|
|
2987
2975
|
}
|
|
2988
2976
|
function notify_spawn(pid, on_spawn, on_error) {
|
|
@@ -2995,11 +2983,11 @@ function notify_spawn(pid, on_spawn, on_error) {
|
|
|
2995
2983
|
}
|
|
2996
2984
|
async function attached_spawn(request, log, on_error, on_spawn) {
|
|
2997
2985
|
return await new Promise((resolve3) => {
|
|
2998
|
-
const
|
|
2986
|
+
const environment3 = agent_launch_environment.build(request.cwd, request.profile, request.env);
|
|
2999
2987
|
const child = spawn(
|
|
3000
2988
|
request.argv.command,
|
|
3001
2989
|
[...request.argv.args],
|
|
3002
|
-
spawn_options(request.cwd, log,
|
|
2990
|
+
spawn_options(request.cwd, log, environment3, false)
|
|
3003
2991
|
);
|
|
3004
2992
|
child.once("error", (error) => {
|
|
3005
2993
|
on_error(note_of(error));
|
|
@@ -3015,8 +3003,8 @@ function ignore_spawn(_pid) {
|
|
|
3015
3003
|
}
|
|
3016
3004
|
function spawned(request, log, on_error) {
|
|
3017
3005
|
const { command, args } = request.argv;
|
|
3018
|
-
const
|
|
3019
|
-
const child = spawn(command, [...args], spawn_options(request.cwd, log,
|
|
3006
|
+
const environment3 = agent_launch_environment.build(request.cwd, request.profile, request.env);
|
|
3007
|
+
const child = spawn(command, [...args], spawn_options(request.cwd, log, environment3));
|
|
3020
3008
|
child.on("error", (error) => {
|
|
3021
3009
|
on_error(note_of(error));
|
|
3022
3010
|
});
|
|
@@ -3058,7 +3046,7 @@ var detached_launch = {
|
|
|
3058
3046
|
note_of
|
|
3059
3047
|
};
|
|
3060
3048
|
|
|
3061
|
-
// scripts/run/run-event-stream.ts
|
|
3049
|
+
// scripts/run/event/run-event-stream.ts
|
|
3062
3050
|
import { z as z7 } from "zod";
|
|
3063
3051
|
var EVENT_PREFIX = "josh-run-events-";
|
|
3064
3052
|
var EVENT_SUFFIX = ".jsonl";
|
|
@@ -3074,6 +3062,10 @@ var EVENT_KIND = {
|
|
|
3074
3062
|
SPLIT: "split",
|
|
3075
3063
|
OUTAGE: "outage",
|
|
3076
3064
|
CUT: "cut",
|
|
3065
|
+
// A fresh session adopted an implementation cut — `run:cut --resume` answered `resume-impl`
|
|
3066
|
+
// (joshuafolkken/kit#3375). The resume clears the cut record, so without this the `cut` stayed the
|
|
3067
|
+
// newest position and `run:step` kept answering the resume command it had just run.
|
|
3068
|
+
RESUME: "resume",
|
|
3077
3069
|
// The backlog emptied while nothing of the run's own was in flight — the drain
|
|
3078
3070
|
// (joshuafolkken/kit#2335). It marks the position at which the end-of-run retrospective is owed,
|
|
3079
3071
|
// *before* the idle watch opens, so `run:step` fires the retrospective at the drain rather than after
|
|
@@ -3150,6 +3142,12 @@ function read_events(target) {
|
|
|
3150
3142
|
function last_position(events) {
|
|
3151
3143
|
return events[events.length - POSITION_INCREMENT]?.pos ?? FIRST_POSITION;
|
|
3152
3144
|
}
|
|
3145
|
+
function bounded(events) {
|
|
3146
|
+
const excess = events.length - EVENT_CAP;
|
|
3147
|
+
if (excess <= 0) return events;
|
|
3148
|
+
const dropped = new Set(events.filter((event) => TRACE_KINDS.has(event.kind)).slice(0, excess));
|
|
3149
|
+
return events.filter((event) => !dropped.has(event)).slice(-EVENT_CAP);
|
|
3150
|
+
}
|
|
3153
3151
|
function serialize(events) {
|
|
3154
3152
|
return `${events.map((event) => JSON.stringify(event)).join(LINE_SEPARATOR)}${LINE_SEPARATOR}`;
|
|
3155
3153
|
}
|
|
@@ -3157,8 +3155,8 @@ function append(target, kind, text, at) {
|
|
|
3157
3155
|
if (!is_event_kind(kind)) return { appended: false, position: FIRST_POSITION };
|
|
3158
3156
|
const existing = read_events(target);
|
|
3159
3157
|
const position = last_position(existing) + POSITION_INCREMENT;
|
|
3160
|
-
const
|
|
3161
|
-
stamp_file.write_text_stamp(target, serialize(
|
|
3158
|
+
const events = bounded([...existing, { pos: position, at, kind, text }]);
|
|
3159
|
+
stamp_file.write_text_stamp(target, serialize(events));
|
|
3162
3160
|
return { appended: true, position };
|
|
3163
3161
|
}
|
|
3164
3162
|
function read_from(target, position) {
|
|
@@ -3193,7 +3191,7 @@ var run_event_stream = {
|
|
|
3193
3191
|
target_of
|
|
3194
3192
|
};
|
|
3195
3193
|
|
|
3196
|
-
// scripts/run/run-event-scope.ts
|
|
3194
|
+
// scripts/run/event/run-event-scope.ts
|
|
3197
3195
|
var SINCE_SCOPE = "since";
|
|
3198
3196
|
var UNKNOWN_SCOPE = "unknown";
|
|
3199
3197
|
var UNKNOWN_EVENT_SCOPE = { kind: UNKNOWN_SCOPE };
|
|
@@ -3271,7 +3269,7 @@ var run_event_scope = {
|
|
|
3271
3269
|
scoped_events
|
|
3272
3270
|
};
|
|
3273
3271
|
|
|
3274
|
-
// scripts/run/run-event-stream-emit.ts
|
|
3272
|
+
// scripts/run/event/run-event-stream-emit.ts
|
|
3275
3273
|
function now_iso() {
|
|
3276
3274
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
3277
3275
|
}
|
|
@@ -3340,7 +3338,8 @@ var run_event_stream_emit = {
|
|
|
3340
3338
|
stream_target
|
|
3341
3339
|
};
|
|
3342
3340
|
|
|
3343
|
-
// scripts/run/run-ship-detach.ts
|
|
3341
|
+
// scripts/run/ship/run-ship-detach.ts
|
|
3342
|
+
import { z as z8 } from "zod";
|
|
3344
3343
|
var LOG_PREFIX = "josh-ship-log-";
|
|
3345
3344
|
var PID_PREFIX = "josh-ship-pid-";
|
|
3346
3345
|
var BODY_PREFIX = "josh-ship-notify-";
|
|
@@ -3491,7 +3490,7 @@ function supervisor_argv(request) {
|
|
|
3491
3490
|
};
|
|
3492
3491
|
}
|
|
3493
3492
|
function prepare_launch(request) {
|
|
3494
|
-
const launch_id =
|
|
3493
|
+
const launch_id = randomUUID();
|
|
3495
3494
|
const launcher = process_identity.own_fields();
|
|
3496
3495
|
stamp_file.replace_stamp(result_path(request.repository, request.number), {
|
|
3497
3496
|
launch_id,
|
|
@@ -3590,6 +3589,7 @@ var RUN_LANE_LABEL = "run:lane";
|
|
|
3590
3589
|
var PRIORITY_HIGH_LABEL = "priority:high";
|
|
3591
3590
|
var NEEDS_HUMAN_REVIEW_LABEL = "needs-human-review";
|
|
3592
3591
|
var ALREADY_DONE_LABEL = "already-done";
|
|
3592
|
+
var RELEASE_LABEL = "release";
|
|
3593
3593
|
var INTERRUPT_ROUTE_LABEL = "route:interrupt";
|
|
3594
3594
|
var REVIEW_CAP_ROUTE_LABEL = "route:review-cap";
|
|
3595
3595
|
var SPLIT_ROUTE_LABEL = "route:split";
|
|
@@ -3663,6 +3663,11 @@ var WORKFLOW_LABELS = [
|
|
|
3663
3663
|
color: "e99695",
|
|
3664
3664
|
description: "Offered first in a backlogrun; only a person removes it"
|
|
3665
3665
|
},
|
|
3666
|
+
{
|
|
3667
|
+
name: RELEASE_LABEL,
|
|
3668
|
+
color: "fef2c0",
|
|
3669
|
+
description: "Tracks the next release; its blockers are the merged work it publishes"
|
|
3670
|
+
},
|
|
3666
3671
|
...FILING_ROUTE_LABELS,
|
|
3667
3672
|
...DEPTH_LABELS
|
|
3668
3673
|
];
|
|
@@ -3728,9 +3733,16 @@ function records_the_park(command) {
|
|
|
3728
3733
|
return APPLIES_NEEDS_DECISION.test(command);
|
|
3729
3734
|
}
|
|
3730
3735
|
var LANE_PARK_REASON = '\u26D4 lane child park: this session is a dispatched lane child, and a stop that waits on a person must leave the question on the Issue before it sends this Telegram \u2014 otherwise the parent finds an OPEN Issue with `in-progress` and no question, and a person cannot tell what to answer (joshuafolkken/kit#2034 measured this twice in one run). The child is the only process that knows the question, the options and whether it stashed, so it records the park itself rather than leaving the parent to guess from a log. Before you notify and stop: apply `needs-decision` and post a comment carrying the question, the options, and whether work was stashed \u2014 `gh api repos/{owner}/{repo}/issues/<N>/labels -f \'labels[]=needs-decision\'` then `pnpm josh issue:comment <N> --body-file <path>`. If this stop is a `needs-human-review` or `already-done` one, that label is already on the Issue and there is nothing to add. Then reissue this notify \u2014 it fires once per run and cannot repeat on the call in hand. The procedure is `.claude/skills/workflow-commands/pre-gate-cut.md` \u2192 "A lane child records its park before it stops", and the park itself is `backlogrun-park.md` \u2192 "park and continue".';
|
|
3736
|
+
var ROW3 = {
|
|
3737
|
+
id: "lane-park",
|
|
3738
|
+
is_trigger: bash_triggers.on_bash_command(is_unparked_stop),
|
|
3739
|
+
reason: LANE_PARK_REASON,
|
|
3740
|
+
keeps: bash_triggers.on_bash_command(records_the_park)
|
|
3741
|
+
};
|
|
3731
3742
|
var lane_park = {
|
|
3732
3743
|
COMMAND_NOTIFY_MARKER,
|
|
3733
3744
|
LANE_PARK_REASON,
|
|
3745
|
+
ROW: ROW3,
|
|
3734
3746
|
is_confirmation_notify,
|
|
3735
3747
|
is_parking_child,
|
|
3736
3748
|
is_unparked_stop,
|
|
@@ -3739,7 +3751,7 @@ var lane_park = {
|
|
|
3739
3751
|
};
|
|
3740
3752
|
|
|
3741
3753
|
// scripts/discovery/repo-discovery.ts
|
|
3742
|
-
import { existsSync as existsSync3, readdirSync, readFileSync as
|
|
3754
|
+
import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync2, statSync as statSync2 } from "node:fs";
|
|
3743
3755
|
import path5 from "node:path";
|
|
3744
3756
|
|
|
3745
3757
|
// scripts/discovery/repo-origin.ts
|
|
@@ -3805,15 +3817,15 @@ function origin_section_lines(lines) {
|
|
|
3805
3817
|
const end = rest.findIndex((line) => is_section_header(line));
|
|
3806
3818
|
return end === NOT_FOUND3 ? rest : rest.slice(0, end);
|
|
3807
3819
|
}
|
|
3808
|
-
function
|
|
3820
|
+
function url_value(line) {
|
|
3809
3821
|
const separator = line.indexOf("=");
|
|
3810
3822
|
if (separator === NOT_FOUND3) return void 0;
|
|
3811
|
-
if (line.slice(0, separator).trim() !==
|
|
3823
|
+
if (line.slice(0, separator).trim() !== URL_KEY) return void 0;
|
|
3812
3824
|
return line.slice(separator + 1).trim();
|
|
3813
3825
|
}
|
|
3814
3826
|
function parse_origin_from_config(content) {
|
|
3815
3827
|
const lines = content.split("\n").map((line) => line.trim());
|
|
3816
|
-
return origin_section_lines(lines).map((line) =>
|
|
3828
|
+
return origin_section_lines(lines).map((line) => url_value(line)).find((url) => url !== void 0);
|
|
3817
3829
|
}
|
|
3818
3830
|
function section_groups(lines) {
|
|
3819
3831
|
const groups = [];
|
|
@@ -3825,7 +3837,7 @@ function section_groups(lines) {
|
|
|
3825
3837
|
}
|
|
3826
3838
|
function parse_remote_urls_from_config(content) {
|
|
3827
3839
|
const lines = content.split("\n").map((line) => line.trim());
|
|
3828
|
-
return section_groups(lines).filter((group) => REMOTE_SECTION.test(group[0] ?? "")).flatMap((group) => group.map((line) =>
|
|
3840
|
+
return section_groups(lines).filter((group) => REMOTE_SECTION.test(group[0] ?? "")).flatMap((group) => group.map((line) => url_value(line))).filter((url) => url !== void 0);
|
|
3829
3841
|
}
|
|
3830
3842
|
function format_identity(identity) {
|
|
3831
3843
|
return `${identity.owner}${PATH_SEPARATOR2}${identity.repo}`.toLowerCase();
|
|
@@ -3890,13 +3902,13 @@ function resolve_common_directory(git_directory) {
|
|
|
3890
3902
|
const pointer = path5.join(git_directory, COMMON_DIRECTORY_FILE);
|
|
3891
3903
|
if (!existsSync3(pointer)) return git_directory;
|
|
3892
3904
|
try {
|
|
3893
|
-
return path5.resolve(git_directory,
|
|
3905
|
+
return path5.resolve(git_directory, readFileSync2(pointer, "utf8").trim());
|
|
3894
3906
|
} catch {
|
|
3895
3907
|
return git_directory;
|
|
3896
3908
|
}
|
|
3897
3909
|
}
|
|
3898
3910
|
function follow_git_file(repository_path, git_file) {
|
|
3899
|
-
const pointer =
|
|
3911
|
+
const pointer = readFileSync2(git_file, "utf8").trim();
|
|
3900
3912
|
if (!pointer.startsWith(GITDIR_PREFIX)) return void 0;
|
|
3901
3913
|
return path5.resolve(repository_path, pointer.slice(GITDIR_PREFIX.length).trim());
|
|
3902
3914
|
}
|
|
@@ -3915,7 +3927,7 @@ function read_config(repository_path) {
|
|
|
3915
3927
|
const git_directory = resolve_git_directory(repository_path);
|
|
3916
3928
|
if (git_directory === void 0) return void 0;
|
|
3917
3929
|
try {
|
|
3918
|
-
return
|
|
3930
|
+
return readFileSync2(path5.join(git_directory, GIT_CONFIG), "utf8");
|
|
3919
3931
|
} catch {
|
|
3920
3932
|
return void 0;
|
|
3921
3933
|
}
|
|
@@ -3952,14 +3964,14 @@ function main_worktree(repository_path) {
|
|
|
3952
3964
|
if (path5.basename(git_directory) !== GIT_DIRECTORY) return repository_path;
|
|
3953
3965
|
return path5.dirname(git_directory);
|
|
3954
3966
|
}
|
|
3955
|
-
function discover_repositories(repository_path,
|
|
3967
|
+
function discover_repositories(repository_path, environment3 = process.env) {
|
|
3956
3968
|
const main2 = main_worktree(repository_path);
|
|
3957
3969
|
const current_owner2 = resolve_current_owner(main2);
|
|
3958
3970
|
if (current_owner2 === void 0) return /* @__PURE__ */ new Map();
|
|
3959
3971
|
return repo_map_logic.build_repository_map(
|
|
3960
3972
|
scan_siblings(path5.dirname(main2)),
|
|
3961
3973
|
current_owner2,
|
|
3962
|
-
|
|
3974
|
+
environment3[OVERRIDE_ENV_KEY]
|
|
3963
3975
|
);
|
|
3964
3976
|
}
|
|
3965
3977
|
var repo_discovery = {
|
|
@@ -3994,8 +4006,8 @@ function gh_repo_owners(gh_repo) {
|
|
|
3994
4006
|
function remote_owners(repository_path) {
|
|
3995
4007
|
return repo_discovery.read_remote_urls(repository_path).map((url) => repo_origin.parse_origin_url(url)?.owner);
|
|
3996
4008
|
}
|
|
3997
|
-
function placeholder_owners(repository_path = process.cwd(),
|
|
3998
|
-
const gh_repo =
|
|
4009
|
+
function placeholder_owners(repository_path = process.cwd(), environment3 = process.env) {
|
|
4010
|
+
const gh_repo = environment3[GH_REPO_ENV_KEY];
|
|
3999
4011
|
return gh_repo === void 0 || gh_repo === "" ? remote_owners(repository_path) : gh_repo_owners(gh_repo);
|
|
4000
4012
|
}
|
|
4001
4013
|
var repo_party = {
|
|
@@ -4009,23 +4021,22 @@ var repo_party = {
|
|
|
4009
4021
|
};
|
|
4010
4022
|
|
|
4011
4023
|
// scripts/lane/lane-reap.ts
|
|
4012
|
-
import { execFileSync as
|
|
4024
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
4013
4025
|
var PGREP_COMMAND = "pgrep";
|
|
4014
4026
|
var MATCH_FULL_COMMAND_LINE = "-f";
|
|
4015
4027
|
var CHILDREN_OF_FLAG = "-P";
|
|
4016
|
-
var
|
|
4028
|
+
var PS_COMMAND = "/bin/ps";
|
|
4017
4029
|
var PARENT_FORMAT = ["-o", "ppid=", "-p"];
|
|
4018
4030
|
var TERMINATE_SIGNAL = "SIGTERM";
|
|
4019
|
-
var PROBE_TIMEOUT_MS3 = 2e3;
|
|
4020
4031
|
var LOWEST_CHILD_PID = 2;
|
|
4021
4032
|
function parse_pids(printed) {
|
|
4022
4033
|
return printed.split("\n").map((line) => Number(line.trim())).filter((pid) => Number.isSafeInteger(pid) && pid >= LOWEST_CHILD_PID);
|
|
4023
4034
|
}
|
|
4024
4035
|
function run_probe(command, args) {
|
|
4025
4036
|
try {
|
|
4026
|
-
return
|
|
4037
|
+
return execFileSync2(command, [...args], {
|
|
4027
4038
|
encoding: "utf8",
|
|
4028
|
-
timeout:
|
|
4039
|
+
timeout: PROBE_TIMEOUT_MS,
|
|
4029
4040
|
stdio: ["ignore", "pipe", "ignore"]
|
|
4030
4041
|
});
|
|
4031
4042
|
} catch {
|
|
@@ -4033,7 +4044,7 @@ function run_probe(command, args) {
|
|
|
4033
4044
|
}
|
|
4034
4045
|
}
|
|
4035
4046
|
function parent_of(pid) {
|
|
4036
|
-
return parse_pids(run_probe(
|
|
4047
|
+
return parse_pids(run_probe(PS_COMMAND, [...PARENT_FORMAT, String(pid)]))[0];
|
|
4037
4048
|
}
|
|
4038
4049
|
function terminate(pid) {
|
|
4039
4050
|
try {
|
|
@@ -4101,15 +4112,9 @@ function ls_remote_branch_arguments(branch_name) {
|
|
|
4101
4112
|
}
|
|
4102
4113
|
|
|
4103
4114
|
// scripts/git/repository-lock.ts
|
|
4104
|
-
import { randomUUID as
|
|
4105
|
-
import { linkSync, renameSync, rmSync
|
|
4115
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
4116
|
+
import { linkSync, renameSync, rmSync } from "node:fs";
|
|
4106
4117
|
import { setTimeout as sleep2 } from "node:timers/promises";
|
|
4107
|
-
|
|
4108
|
-
// scripts/josh/process-owner.ts
|
|
4109
|
-
import { z as z9 } from "zod";
|
|
4110
|
-
var process_owner_schema = z9.object({ pid: z9.number(), process_start: z9.string().optional() });
|
|
4111
|
-
|
|
4112
|
-
// scripts/git/repository-lock.ts
|
|
4113
4118
|
var POLL_INTERVAL_MS = 200;
|
|
4114
4119
|
function lock_path(prefix, cwd) {
|
|
4115
4120
|
return stamp_file.stamp_path(prefix, git_common_directory.repository(cwd) ?? cwd ?? process.cwd());
|
|
@@ -4137,7 +4142,7 @@ function stale_record(target, is_gone2) {
|
|
|
4137
4142
|
return owner !== void 0 && is_gone2(owner) ? raw : void 0;
|
|
4138
4143
|
}
|
|
4139
4144
|
function move_aside(target) {
|
|
4140
|
-
const aside = `${target}.${String(process.pid)}.${
|
|
4145
|
+
const aside = `${target}.${String(process.pid)}.${randomUUID2()}`;
|
|
4141
4146
|
try {
|
|
4142
4147
|
renameSync(target, aside);
|
|
4143
4148
|
return aside;
|
|
@@ -4151,7 +4156,7 @@ function clear_stale(target, is_gone2 = is_owner_gone) {
|
|
|
4151
4156
|
const aside = move_aside(target);
|
|
4152
4157
|
if (aside === void 0) return;
|
|
4153
4158
|
if (stamp_file.read_stamp_text(aside) !== raw) restore(aside, target);
|
|
4154
|
-
|
|
4159
|
+
rmSync(aside, { force: true });
|
|
4155
4160
|
}
|
|
4156
4161
|
function claim(target) {
|
|
4157
4162
|
clear_stale(target);
|
|
@@ -4285,13 +4290,13 @@ function read_lane_seat(content) {
|
|
|
4285
4290
|
return raw === void 0 ? void 0 : ports.resolve_lane({ [LANE_SEAT_KEY]: raw });
|
|
4286
4291
|
}
|
|
4287
4292
|
function read_lane_ports(content) {
|
|
4288
|
-
const
|
|
4293
|
+
const environment3 = {
|
|
4289
4294
|
[PORT_SEED_KEY]: read_assignment(content, PORT_SEED_KEY),
|
|
4290
4295
|
[LANE_SEAT_KEY]: read_assignment(content, LANE_SEAT_KEY)
|
|
4291
4296
|
};
|
|
4292
4297
|
return {
|
|
4293
|
-
development: ports.resolve_development_port(
|
|
4294
|
-
preview: ports.resolve_preview_port(
|
|
4298
|
+
development: ports.resolve_development_port(environment3),
|
|
4299
|
+
preview: ports.resolve_preview_port(environment3)
|
|
4295
4300
|
};
|
|
4296
4301
|
}
|
|
4297
4302
|
function read_lane_output(content) {
|
|
@@ -4310,7 +4315,8 @@ function read_lane_profile(content) {
|
|
|
4310
4315
|
function replace_assignment(lines, keep, assignment, key2) {
|
|
4311
4316
|
return lines.flatMap((entry, index) => {
|
|
4312
4317
|
if (index === keep) return [assignment];
|
|
4313
|
-
|
|
4318
|
+
if (is_key_line(entry, key2)) return [];
|
|
4319
|
+
return [entry];
|
|
4314
4320
|
});
|
|
4315
4321
|
}
|
|
4316
4322
|
function upsert_assignment(content, key2, value) {
|
|
@@ -4422,6 +4428,10 @@ async function list_lanes() {
|
|
|
4422
4428
|
const lanes = blocks.map((block) => parse_block(block, root)).filter(is_lane);
|
|
4423
4429
|
return lanes.toSorted((left, right) => Number(left.issue) - Number(right.issue));
|
|
4424
4430
|
}
|
|
4431
|
+
async function registered_directories() {
|
|
4432
|
+
const blocks = await worktree_blocks();
|
|
4433
|
+
return blocks.flatMap((block) => line_value(block.split("\n"), WORKTREE_PREFIX) ?? []);
|
|
4434
|
+
}
|
|
4425
4435
|
async function has_lanes_in_flight() {
|
|
4426
4436
|
const lanes = await list_lanes();
|
|
4427
4437
|
return lanes.some((lane) => !lane.is_stranded);
|
|
@@ -4446,6 +4456,7 @@ var lane_registry = {
|
|
|
4446
4456
|
main_repository_root,
|
|
4447
4457
|
parse_block,
|
|
4448
4458
|
read_environment,
|
|
4459
|
+
registered_directories,
|
|
4449
4460
|
unreadable_lanes,
|
|
4450
4461
|
used_seats
|
|
4451
4462
|
};
|
|
@@ -4453,10 +4464,10 @@ var lane_registry = {
|
|
|
4453
4464
|
// scripts/run/run-headless.ts
|
|
4454
4465
|
var HEADLESS_ENV_KEY = "JOSH_RUN_HEADLESS";
|
|
4455
4466
|
var HEADLESS_VALUE = "1";
|
|
4456
|
-
function
|
|
4467
|
+
function environment2() {
|
|
4457
4468
|
return { [HEADLESS_ENV_KEY]: HEADLESS_VALUE };
|
|
4458
4469
|
}
|
|
4459
|
-
function
|
|
4470
|
+
function is_headless2(source = process.env) {
|
|
4460
4471
|
return source[HEADLESS_ENV_KEY] === HEADLESS_VALUE;
|
|
4461
4472
|
}
|
|
4462
4473
|
function is_driving(read3) {
|
|
@@ -4467,7 +4478,7 @@ async function read_carry_here() {
|
|
|
4467
4478
|
return repository2 === void 0 ? void 0 : run_carry.read_carry(run_carry.carry_path(repository2));
|
|
4468
4479
|
}
|
|
4469
4480
|
async function must_keep_waiting(source = process.env) {
|
|
4470
|
-
const is_candidate2 =
|
|
4481
|
+
const is_candidate2 = is_headless2(source) && lane_child_marker.marked_issue(source) === void 0;
|
|
4471
4482
|
if (!is_candidate2 || !await lane_registry.has_lanes_in_flight()) return false;
|
|
4472
4483
|
return is_driving(await read_carry_here());
|
|
4473
4484
|
}
|
|
@@ -4493,9 +4504,9 @@ var run_headless = {
|
|
|
4493
4504
|
HEADLESS_ENV_KEY,
|
|
4494
4505
|
current_carry,
|
|
4495
4506
|
driving_carry,
|
|
4496
|
-
environment,
|
|
4507
|
+
environment: environment2,
|
|
4497
4508
|
is_backlog_parent,
|
|
4498
|
-
is_headless,
|
|
4509
|
+
is_headless: is_headless2,
|
|
4499
4510
|
is_owned_here,
|
|
4500
4511
|
must_keep_waiting
|
|
4501
4512
|
};
|
|
@@ -4561,8 +4572,8 @@ var issue_cite = {
|
|
|
4561
4572
|
|
|
4562
4573
|
// scripts/gh/git-gh-api-path.ts
|
|
4563
4574
|
var FULL_PAGE_QUERY = "?per_page=100";
|
|
4564
|
-
function repo_api_path(repo) {
|
|
4565
|
-
return `repos/${repo
|
|
4575
|
+
function repo_api_path(repo = "{owner}/{repo}") {
|
|
4576
|
+
return `repos/${repo}`;
|
|
4566
4577
|
}
|
|
4567
4578
|
function issues_api_path(repo) {
|
|
4568
4579
|
return `${repo_api_path(repo)}/issues`;
|
|
@@ -4628,10 +4639,6 @@ var git_gh_api_path = {
|
|
|
4628
4639
|
// scripts/gh/git-gh-exec.ts
|
|
4629
4640
|
import { execa as execa5, execaSync as execaSync3 } from "execa";
|
|
4630
4641
|
|
|
4631
|
-
// scripts/lib/timeouts.ts
|
|
4632
|
-
var FETCH_TIMEOUT_MS = 1e4;
|
|
4633
|
-
var COMMAND_TIMEOUT_MS = 3e4;
|
|
4634
|
-
|
|
4635
4642
|
// scripts/gh/git-gh-check.ts
|
|
4636
4643
|
import { execa as execa4 } from "execa";
|
|
4637
4644
|
var GH_NOT_INSTALLED_MSG = "gh CLI is not installed. Install it from https://cli.github.com/";
|
|
@@ -4682,8 +4689,8 @@ var parse_json = {
|
|
|
4682
4689
|
};
|
|
4683
4690
|
|
|
4684
4691
|
// scripts/gh/git-gh-failure.ts
|
|
4685
|
-
import { z as
|
|
4686
|
-
var error_document_schema =
|
|
4692
|
+
import { z as z9 } from "zod";
|
|
4693
|
+
var error_document_schema = z9.object({ status: z9.union([z9.string(), z9.number()]).optional() }).catch({});
|
|
4687
4694
|
var GH_FAILURE_FIELD = "gh_failure";
|
|
4688
4695
|
function has_gh_failure(error) {
|
|
4689
4696
|
return error instanceof Error && Object.hasOwn(error, GH_FAILURE_FIELD);
|
|
@@ -4886,7 +4893,7 @@ var git_gh_helpers = {
|
|
|
4886
4893
|
};
|
|
4887
4894
|
|
|
4888
4895
|
// scripts/gh/git-gh-issue-rest.ts
|
|
4889
|
-
import { z as
|
|
4896
|
+
import { z as z10 } from "zod";
|
|
4890
4897
|
|
|
4891
4898
|
// scripts/gh/git-gh-rest-state.ts
|
|
4892
4899
|
var MERGED_STATE = "MERGED";
|
|
@@ -4895,11 +4902,11 @@ function to_gh_state(state) {
|
|
|
4895
4902
|
}
|
|
4896
4903
|
|
|
4897
4904
|
// scripts/gh/git-gh-issue-rest.ts
|
|
4898
|
-
var rest_issue_schema =
|
|
4899
|
-
number:
|
|
4900
|
-
issue_dependencies_summary:
|
|
4905
|
+
var rest_issue_schema = z10.looseObject({
|
|
4906
|
+
number: z10.number(),
|
|
4907
|
+
issue_dependencies_summary: z10.looseObject({ total_blocked_by: z10.number().optional() }).nullish(),
|
|
4901
4908
|
// Present only on a pull request, which this endpoint serves as readily as an issue.
|
|
4902
|
-
pull_request:
|
|
4909
|
+
pull_request: z10.looseObject({ merged_at: z10.string().nullish() }).nullish()
|
|
4903
4910
|
});
|
|
4904
4911
|
var REPOSITORY_URL = /\/repos\/([\w.-]+\/[\w.-]+)$/u;
|
|
4905
4912
|
var REPOSITORY_URL_GROUP = 1;
|
|
@@ -4951,8 +4958,8 @@ function parse_rest_issues(rest_json) {
|
|
|
4951
4958
|
function empty_blocked_by() {
|
|
4952
4959
|
return { nodes: [], totalCount: 0 };
|
|
4953
4960
|
}
|
|
4954
|
-
function repo_of_url(repository_url) {
|
|
4955
|
-
const match = REPOSITORY_URL.exec(repository_url
|
|
4961
|
+
function repo_of_url(repository_url = "") {
|
|
4962
|
+
const match = REPOSITORY_URL.exec(repository_url);
|
|
4956
4963
|
return match?.[REPOSITORY_URL_GROUP];
|
|
4957
4964
|
}
|
|
4958
4965
|
function to_blocked_by(blockers_json, exact_total) {
|
|
@@ -5246,6 +5253,7 @@ var PATCH_METHOD = "PATCH";
|
|
|
5246
5253
|
var DELETE_METHOD = "DELETE";
|
|
5247
5254
|
var HTML_URL_FILTER = ".html_url";
|
|
5248
5255
|
var ID_FILTER = ".id";
|
|
5256
|
+
var LABEL_NAMES_FILTER = ".[].name";
|
|
5249
5257
|
var LABELS_SEGMENT = "/labels";
|
|
5250
5258
|
var COMMENTS_SEGMENT = "/comments";
|
|
5251
5259
|
var CLOSED_STATE = "closed";
|
|
@@ -5320,13 +5328,35 @@ async function issue_create_with_label(input) {
|
|
|
5320
5328
|
issue_create_request({ title: input.title, body: input.body, labels: [input.label] })
|
|
5321
5329
|
);
|
|
5322
5330
|
}
|
|
5323
|
-
async function
|
|
5324
|
-
|
|
5325
|
-
|
|
5331
|
+
async function read_label_names(issue_number) {
|
|
5332
|
+
try {
|
|
5333
|
+
const raw = await git_gh_exec.exec_gh_api({
|
|
5326
5334
|
path: `${git_gh_api_path.issue_api_path(issue_number)}${LABELS_SEGMENT}`,
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5335
|
+
should_paginate: true,
|
|
5336
|
+
jq_filter: LABEL_NAMES_FILTER
|
|
5337
|
+
});
|
|
5338
|
+
return raw.split("\n").map((name) => name.trim());
|
|
5339
|
+
} catch (error) {
|
|
5340
|
+
error_text.trace_swallowed("git_gh_issue_write.read_label_names", error);
|
|
5341
|
+
return void 0;
|
|
5342
|
+
}
|
|
5343
|
+
}
|
|
5344
|
+
async function issue_apply_label(issue_number, label2) {
|
|
5345
|
+
const labels_path = `${git_gh_api_path.issue_api_path(issue_number)}${LABELS_SEGMENT}`;
|
|
5346
|
+
try {
|
|
5347
|
+
await git_gh_exec.exec_gh_api({ path: labels_path, body: JSON.stringify({ labels: [label2] }) });
|
|
5348
|
+
return { is_applied: true };
|
|
5349
|
+
} catch (error) {
|
|
5350
|
+
const names = await read_label_names(issue_number);
|
|
5351
|
+
if (names?.includes(label2) === true) return { is_applied: true };
|
|
5352
|
+
error_text.trace_swallowed("git_gh_issue_write.issue_apply_label", error);
|
|
5353
|
+
const [gist = ""] = error_text.message_of(error).split("\n", 1);
|
|
5354
|
+
return { is_applied: false, reason: gist };
|
|
5355
|
+
}
|
|
5356
|
+
}
|
|
5357
|
+
async function issue_add_label(issue_number, label2) {
|
|
5358
|
+
const write = await issue_apply_label(issue_number, label2);
|
|
5359
|
+
return write.is_applied;
|
|
5330
5360
|
}
|
|
5331
5361
|
async function issue_remove_label(issue_number, label2) {
|
|
5332
5362
|
const labels_path = `${git_gh_api_path.issue_api_path(issue_number)}${LABELS_SEGMENT}`;
|
|
@@ -5373,6 +5403,7 @@ var git_gh_issue_write = {
|
|
|
5373
5403
|
label_ensure,
|
|
5374
5404
|
issue_create_request,
|
|
5375
5405
|
issue_create_with_label,
|
|
5406
|
+
issue_apply_label,
|
|
5376
5407
|
issue_add_label,
|
|
5377
5408
|
issue_remove_label,
|
|
5378
5409
|
issue_add_blocked_by,
|
|
@@ -5433,20 +5464,20 @@ var git_gh_issue = {
|
|
|
5433
5464
|
};
|
|
5434
5465
|
|
|
5435
5466
|
// scripts/ci/pr-classification.ts
|
|
5436
|
-
import { readFileSync as
|
|
5467
|
+
import { readFileSync as readFileSync3 } from "node:fs";
|
|
5437
5468
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
5438
|
-
import { z as
|
|
5469
|
+
import { z as z11 } from "zod";
|
|
5439
5470
|
var CLASSIFICATION_SET = new Set(RELEASE_CLASSIFICATION_NAMES);
|
|
5440
5471
|
var ISSUE_BUG_LABEL = "bug";
|
|
5441
5472
|
var DECLARATION_PREFIX = "- \u30EA\u30EA\u30FC\u30B9\u5206\u985E: ";
|
|
5442
5473
|
var DECLARATION = new RegExp(`^${DECLARATION_PREFIX}(.+)$`, "gmu");
|
|
5443
5474
|
var LEGACY_LABELS = /* @__PURE__ */ new Set(["semver-major", "semver-minor"]);
|
|
5444
|
-
var LABEL =
|
|
5445
|
-
var USER =
|
|
5446
|
-
var PULL_REQUEST =
|
|
5447
|
-
var EVENT =
|
|
5475
|
+
var LABEL = z11.object({ name: z11.string() });
|
|
5476
|
+
var USER = z11.object({ login: z11.string() });
|
|
5477
|
+
var PULL_REQUEST = z11.object({ number: z11.number(), user: USER });
|
|
5478
|
+
var EVENT = z11.object({
|
|
5448
5479
|
pull_request: PULL_REQUEST,
|
|
5449
|
-
repository:
|
|
5480
|
+
repository: z11.object({ full_name: z11.string() })
|
|
5450
5481
|
});
|
|
5451
5482
|
function classification_error(labels, author) {
|
|
5452
5483
|
const legacy = labels.filter((label2) => LEGACY_LABELS.has(label2.toLowerCase()));
|
|
@@ -5469,7 +5500,7 @@ function release_candidates(candidates) {
|
|
|
5469
5500
|
return candidates.filter((candidate) => candidate !== ENHANCEMENT_LABEL);
|
|
5470
5501
|
}
|
|
5471
5502
|
function issue_candidates(issue_json) {
|
|
5472
|
-
const issue =
|
|
5503
|
+
const issue = z11.object({ labels: z11.array(LABEL), body: z11.string().nullable() }).parse(JSON.parse(issue_json));
|
|
5473
5504
|
const names = issue.labels.map((label2) => label2.name.toLowerCase());
|
|
5474
5505
|
const declared = [...(issue.body ?? "").matchAll(DECLARATION)].map((match) => match[1] ?? "");
|
|
5475
5506
|
const candidates = [...release_candidates([...names, ...declared].filter(is_classification))];
|
|
@@ -5502,7 +5533,7 @@ function fetch_current_labels(repository2, pull_number) {
|
|
|
5502
5533
|
}
|
|
5503
5534
|
}
|
|
5504
5535
|
function check_event(event_path, read_labels = fetch_current_labels) {
|
|
5505
|
-
const event = EVENT.parse(JSON.parse(
|
|
5536
|
+
const event = EVENT.parse(JSON.parse(readFileSync3(event_path, "utf8")));
|
|
5506
5537
|
const labels = read_labels(event.repository.full_name, event.pull_request.number);
|
|
5507
5538
|
return classification_error(labels, event.pull_request.user.login);
|
|
5508
5539
|
}
|
|
@@ -5544,31 +5575,31 @@ async function poll_until(is_done2, options) {
|
|
|
5544
5575
|
var poll = { poll_until, sleep: sleep3 };
|
|
5545
5576
|
|
|
5546
5577
|
// scripts/gh/git-gh-pr.ts
|
|
5547
|
-
import { z as
|
|
5578
|
+
import { z as z15 } from "zod";
|
|
5548
5579
|
|
|
5549
5580
|
// scripts/gh/git-gh-pr-rest.ts
|
|
5550
|
-
import { z as
|
|
5551
|
-
var rest_repo_schema =
|
|
5552
|
-
var rest_pull_side_schema =
|
|
5553
|
-
var rest_pull_schema =
|
|
5554
|
-
number:
|
|
5555
|
-
html_url:
|
|
5556
|
-
body:
|
|
5557
|
-
state:
|
|
5558
|
-
merged:
|
|
5559
|
-
merged_at:
|
|
5560
|
-
mergeable:
|
|
5561
|
-
mergeable_state:
|
|
5581
|
+
import { z as z12 } from "zod";
|
|
5582
|
+
var rest_repo_schema = z12.looseObject({ full_name: z12.string().optional() }).nullish();
|
|
5583
|
+
var rest_pull_side_schema = z12.looseObject({ repo: rest_repo_schema });
|
|
5584
|
+
var rest_pull_schema = z12.looseObject({
|
|
5585
|
+
number: z12.number(),
|
|
5586
|
+
html_url: z12.string().optional(),
|
|
5587
|
+
body: z12.string().nullish(),
|
|
5588
|
+
state: z12.string().optional(),
|
|
5589
|
+
merged: z12.boolean().nullish(),
|
|
5590
|
+
merged_at: z12.string().nullish(),
|
|
5591
|
+
mergeable: z12.boolean().nullish(),
|
|
5592
|
+
mergeable_state: z12.string().optional(),
|
|
5562
5593
|
// `sha` is the head commit, which is what both halves of the merge-gate rollup are keyed by —
|
|
5563
5594
|
// REST hangs the check runs and the status contexts off the commit rather than off the pull
|
|
5564
5595
|
// request (joshuafolkken/kit#1028).
|
|
5565
|
-
head:
|
|
5596
|
+
head: z12.looseObject({ ref: z12.string().optional(), sha: z12.string().optional(), repo: rest_repo_schema }).nullish(),
|
|
5566
5597
|
base: rest_pull_side_schema.nullish(),
|
|
5567
5598
|
// `node_id` is what the GraphQL auto-merge mutation addresses a pull request by, and `auto_merge`
|
|
5568
5599
|
// is `null` until auto-merge is enabled — both read by `git-gh-pr-auto-merge.ts`
|
|
5569
5600
|
// (joshuafolkken/kit#2497).
|
|
5570
|
-
node_id:
|
|
5571
|
-
auto_merge:
|
|
5601
|
+
node_id: z12.string().optional(),
|
|
5602
|
+
auto_merge: z12.looseObject({}).nullish()
|
|
5572
5603
|
});
|
|
5573
5604
|
var NOT_A_PULL_MESSAGE = "gh api answered something other than a pull request object";
|
|
5574
5605
|
var NOT_A_PULL_LISTING_MESSAGE = "gh api answered something other than a pull request listing";
|
|
@@ -5644,6 +5675,7 @@ async function fetch_pr_number(branch_name) {
|
|
|
5644
5675
|
return git_gh_pr_rest.select_pull(git_gh_pr_rest.parse_rest_pulls(json))?.number;
|
|
5645
5676
|
}
|
|
5646
5677
|
var pending_pr_number_by_branch = /* @__PURE__ */ new Map();
|
|
5678
|
+
var pull_by_number = /* @__PURE__ */ new Map();
|
|
5647
5679
|
async function fetch_pr_number_read(branch_name) {
|
|
5648
5680
|
try {
|
|
5649
5681
|
const pr_number = await fetch_pr_number(branch_name);
|
|
@@ -5668,6 +5700,7 @@ async function start_pr_number_read(branch_name) {
|
|
|
5668
5700
|
function forget_pr_numbers() {
|
|
5669
5701
|
pr_number_by_branch.clear();
|
|
5670
5702
|
pending_pr_number_by_branch.clear();
|
|
5703
|
+
pull_by_number.clear();
|
|
5671
5704
|
}
|
|
5672
5705
|
async function read_pr_number(branch_name) {
|
|
5673
5706
|
const cached = pr_number_by_branch.get(branch_name);
|
|
@@ -5693,15 +5726,29 @@ async function read_pull(pr_number) {
|
|
|
5693
5726
|
});
|
|
5694
5727
|
return git_gh_pr_rest.parse_rest_pull(json);
|
|
5695
5728
|
}
|
|
5696
|
-
async function
|
|
5697
|
-
const
|
|
5698
|
-
|
|
5729
|
+
async function read_remembered_pull(pr_number) {
|
|
5730
|
+
const pending = pull_by_number.get(pr_number) ?? read_pull(pr_number);
|
|
5731
|
+
pull_by_number.set(pr_number, pending);
|
|
5699
5732
|
try {
|
|
5700
|
-
return await
|
|
5701
|
-
} catch {
|
|
5702
|
-
|
|
5733
|
+
return await pending;
|
|
5734
|
+
} catch (error) {
|
|
5735
|
+
if (pull_by_number.get(pr_number) === pending) pull_by_number.delete(pr_number);
|
|
5736
|
+
throw error;
|
|
5737
|
+
}
|
|
5738
|
+
}
|
|
5739
|
+
async function read_pull_of_branch(branch_name, read3 = read_remembered_pull) {
|
|
5740
|
+
const number_read = await read_pr_number(branch_name);
|
|
5741
|
+
if (number_read.kind !== "read") return number_read;
|
|
5742
|
+
try {
|
|
5743
|
+
return { kind: "read", pull: await read3(number_read.pr_number) };
|
|
5744
|
+
} catch (error) {
|
|
5745
|
+
return { kind: "unreadable", cause: error };
|
|
5703
5746
|
}
|
|
5704
5747
|
}
|
|
5748
|
+
async function read_pull_or_undefined(branch_name) {
|
|
5749
|
+
const read3 = await read_pull_of_branch(branch_name);
|
|
5750
|
+
return read3.kind === "read" ? read3.pull : void 0;
|
|
5751
|
+
}
|
|
5705
5752
|
async function pr_exists(branch_name) {
|
|
5706
5753
|
const read3 = await read_pr_number(branch_name);
|
|
5707
5754
|
if (read3.kind === "unreadable") throw to_unreadable_error(branch_name, read3.cause);
|
|
@@ -5711,13 +5758,14 @@ async function pr_get_number(branch_name) {
|
|
|
5711
5758
|
return await resolve_pr_number(branch_name);
|
|
5712
5759
|
}
|
|
5713
5760
|
async function pr_get_url(branch_name) {
|
|
5714
|
-
const pull = await
|
|
5761
|
+
const pull = await read_pull_or_undefined(branch_name);
|
|
5715
5762
|
if (pull?.html_url === void 0) return void 0;
|
|
5716
5763
|
return git_gh_helpers.parse_pr_state_string(pull.html_url);
|
|
5717
5764
|
}
|
|
5718
5765
|
async function pr_get_merge_state(branch_name) {
|
|
5719
|
-
const
|
|
5720
|
-
if (
|
|
5766
|
+
const read3 = await read_pull_of_branch(branch_name, read_pull);
|
|
5767
|
+
if (read3.kind !== "read") return void 0;
|
|
5768
|
+
const { pull } = read3;
|
|
5721
5769
|
return {
|
|
5722
5770
|
is_merged: git_gh_pr_rest.is_merged(pull),
|
|
5723
5771
|
merged_at: pull.merged_at ?? void 0,
|
|
@@ -5726,14 +5774,15 @@ async function pr_get_merge_state(branch_name) {
|
|
|
5726
5774
|
};
|
|
5727
5775
|
}
|
|
5728
5776
|
async function pr_get_body(branch_name) {
|
|
5729
|
-
const pull = await
|
|
5777
|
+
const pull = await read_pull_or_undefined(branch_name);
|
|
5730
5778
|
const body = pull?.body;
|
|
5731
5779
|
return typeof body === "string" && body.length > 0 ? body : void 0;
|
|
5732
5780
|
}
|
|
5733
5781
|
async function pr_view(branch_name) {
|
|
5734
|
-
const
|
|
5735
|
-
if (
|
|
5736
|
-
|
|
5782
|
+
const read3 = await read_pull_of_branch(branch_name, read_pull);
|
|
5783
|
+
if (read3.kind === "unreadable") throw to_unreadable_error(branch_name, read3.cause);
|
|
5784
|
+
if (read3.kind === "missing") return "";
|
|
5785
|
+
return JSON.stringify(git_gh_pr_rest.to_pr_info(read3.pull));
|
|
5737
5786
|
}
|
|
5738
5787
|
async function read_comments(branch_name, to_path, to_json) {
|
|
5739
5788
|
const pr_number = await resolve_pr_number(branch_name);
|
|
@@ -5769,14 +5818,14 @@ var git_gh_pr_read = {
|
|
|
5769
5818
|
};
|
|
5770
5819
|
|
|
5771
5820
|
// scripts/gh/git-gh-pr-review.ts
|
|
5772
|
-
import { z as
|
|
5821
|
+
import { z as z13 } from "zod";
|
|
5773
5822
|
var REVIEW_APPROVED = "APPROVED";
|
|
5774
5823
|
var REVIEW_CHANGES_REQUESTED = "CHANGES_REQUESTED";
|
|
5775
5824
|
var REVIEW_NONE = "";
|
|
5776
5825
|
var STATE_CHANGING_REVIEWS = /* @__PURE__ */ new Set([REVIEW_APPROVED, REVIEW_CHANGES_REQUESTED]);
|
|
5777
|
-
var rest_review_schema =
|
|
5778
|
-
state:
|
|
5779
|
-
user:
|
|
5826
|
+
var rest_review_schema = z13.looseObject({
|
|
5827
|
+
state: z13.string().optional(),
|
|
5828
|
+
user: z13.looseObject({ login: z13.string().optional() }).nullish()
|
|
5780
5829
|
});
|
|
5781
5830
|
var NOT_A_REVIEW_LISTING = "gh api answered something other than a review listing";
|
|
5782
5831
|
function parse_rest_reviews(reviews_json) {
|
|
@@ -5809,18 +5858,18 @@ function to_review_decision(reviews_json) {
|
|
|
5809
5858
|
var git_gh_pr_review = { to_review_decision };
|
|
5810
5859
|
|
|
5811
5860
|
// scripts/gh/git-gh-pr-rollup.ts
|
|
5812
|
-
import { z as
|
|
5861
|
+
import { z as z14 } from "zod";
|
|
5813
5862
|
var STATUS_CONTEXT_TYPE_NAME = "StatusContext";
|
|
5814
5863
|
var TYPE_NAME_KEY = "__typename";
|
|
5815
|
-
var rollup_element_schema =
|
|
5816
|
-
var check_runs_page_schema =
|
|
5864
|
+
var rollup_element_schema = z14.looseObject({});
|
|
5865
|
+
var check_runs_page_schema = z14.looseObject({
|
|
5817
5866
|
// Required, not optional: GitHub always names the key, and accepting a page without one would
|
|
5818
5867
|
// answer an empty rollup — which `git-pr-followup.ts` reports as "this branch has no checks".
|
|
5819
|
-
check_runs:
|
|
5868
|
+
check_runs: z14.array(rollup_element_schema)
|
|
5820
5869
|
});
|
|
5821
|
-
var id_holder_schema =
|
|
5822
|
-
var status_page_schema =
|
|
5823
|
-
statuses:
|
|
5870
|
+
var id_holder_schema = z14.object({ id: z14.number() });
|
|
5871
|
+
var status_page_schema = z14.looseObject({
|
|
5872
|
+
statuses: z14.array(rollup_element_schema)
|
|
5824
5873
|
});
|
|
5825
5874
|
var NOT_A_CHECK_RUNS_LISTING = "gh api answered something other than a check run listing";
|
|
5826
5875
|
var NOT_A_STATUS_LISTING = "gh api answered something other than a commit status listing";
|
|
@@ -5834,15 +5883,15 @@ function read_id(value) {
|
|
|
5834
5883
|
const parsed = id_holder_schema.safeParse(value);
|
|
5835
5884
|
return parsed.success ? parsed.data.id : void 0;
|
|
5836
5885
|
}
|
|
5837
|
-
function check_run_group_key(
|
|
5838
|
-
const { name, app } =
|
|
5886
|
+
function check_run_group_key(run4) {
|
|
5887
|
+
const { name, app } = run4;
|
|
5839
5888
|
if (typeof name !== "string") return void 0;
|
|
5840
5889
|
return JSON.stringify([name, read_id(app)]);
|
|
5841
5890
|
}
|
|
5842
|
-
function read_rank(
|
|
5843
|
-
const id = read_id(
|
|
5891
|
+
function read_rank(run4) {
|
|
5892
|
+
const id = read_id(run4);
|
|
5844
5893
|
if (id === void 0) return void 0;
|
|
5845
|
-
return { suite: read_id(
|
|
5894
|
+
return { suite: read_id(run4["check_suite"]) ?? NO_SUITE, run: id };
|
|
5846
5895
|
}
|
|
5847
5896
|
function is_ranked_above(candidate, current) {
|
|
5848
5897
|
if (candidate.suite !== current.suite) return candidate.suite > current.suite;
|
|
@@ -5852,23 +5901,23 @@ function should_replace(previous, rank) {
|
|
|
5852
5901
|
const previous_rank = previous === void 0 ? void 0 : read_rank(previous);
|
|
5853
5902
|
return previous_rank === void 0 || is_ranked_above(rank, previous_rank);
|
|
5854
5903
|
}
|
|
5855
|
-
function remember_newest_run(
|
|
5856
|
-
const key2 = check_run_group_key(
|
|
5857
|
-
const rank = read_rank(
|
|
5904
|
+
function remember_newest_run(run4, newest) {
|
|
5905
|
+
const key2 = check_run_group_key(run4);
|
|
5906
|
+
const rank = read_rank(run4);
|
|
5858
5907
|
if (key2 === void 0 || rank === void 0) return;
|
|
5859
|
-
if (should_replace(newest.get(key2), rank)) newest.set(key2,
|
|
5908
|
+
if (should_replace(newest.get(key2), rank)) newest.set(key2, run4);
|
|
5860
5909
|
}
|
|
5861
|
-
function is_newest_run(
|
|
5862
|
-
const key2 = check_run_group_key(
|
|
5863
|
-
if (key2 === void 0 || read_rank(
|
|
5864
|
-
return newest.get(key2) ===
|
|
5910
|
+
function is_newest_run(run4, newest) {
|
|
5911
|
+
const key2 = check_run_group_key(run4);
|
|
5912
|
+
if (key2 === void 0 || read_rank(run4) === void 0) return true;
|
|
5913
|
+
return newest.get(key2) === run4;
|
|
5865
5914
|
}
|
|
5866
5915
|
function to_check_run_items(check_runs_json) {
|
|
5867
5916
|
const pages = read_pages(check_runs_json, check_runs_page_schema, NOT_A_CHECK_RUNS_LISTING);
|
|
5868
5917
|
const runs = pages.flatMap((page) => page.check_runs);
|
|
5869
5918
|
const newest = /* @__PURE__ */ new Map();
|
|
5870
|
-
for (const
|
|
5871
|
-
return runs.filter((
|
|
5919
|
+
for (const run4 of runs) remember_newest_run(run4, newest);
|
|
5920
|
+
return runs.filter((run4) => is_newest_run(run4, newest));
|
|
5872
5921
|
}
|
|
5873
5922
|
function to_status_context_items(status_json) {
|
|
5874
5923
|
const pages = read_pages(status_json, status_page_schema, NOT_A_STATUS_LISTING);
|
|
@@ -5954,7 +6003,7 @@ var MERGE_READ_BACK_ATTEMPTS = 3;
|
|
|
5954
6003
|
var MERGE_READ_BACK_INTERVAL_MS = 1e3;
|
|
5955
6004
|
var PR_NUMBER_PATTERN = /\/pull\/([1-9]\d*)$/u;
|
|
5956
6005
|
var LABELS_SEGMENT2 = "/labels";
|
|
5957
|
-
var PR_LABELS =
|
|
6006
|
+
var PR_LABELS = z15.array(z15.object({ name: z15.string() }));
|
|
5958
6007
|
async function add_pr_classification(number, label2) {
|
|
5959
6008
|
await git_gh_exec.exec_gh_api({
|
|
5960
6009
|
path: `${git_gh_api_path.issue_api_path(number)}${LABELS_SEGMENT2}`,
|
|
@@ -6007,6 +6056,7 @@ async function pr_comment(branch_name, body) {
|
|
|
6007
6056
|
}
|
|
6008
6057
|
async function pr_update_body(branch_name, body) {
|
|
6009
6058
|
const pr_number = await require_pr_number(branch_name);
|
|
6059
|
+
forget_pr_numbers();
|
|
6010
6060
|
await git_gh_exec.exec_gh_api({
|
|
6011
6061
|
path: git_gh_api_path.pull_api_path(String(pr_number)),
|
|
6012
6062
|
method: PATCH_METHOD2,
|
|
@@ -6014,6 +6064,7 @@ async function pr_update_body(branch_name, body) {
|
|
|
6014
6064
|
});
|
|
6015
6065
|
}
|
|
6016
6066
|
async function put_merge(pr_number) {
|
|
6067
|
+
forget_pr_numbers();
|
|
6017
6068
|
await git_gh_exec.exec_gh_api({
|
|
6018
6069
|
path: git_gh_api_path.pull_merge_api_path(String(pr_number)),
|
|
6019
6070
|
method: PUT_METHOD,
|
|
@@ -6141,7 +6192,9 @@ var PR_CHECKS_TIMEOUT_MESSAGE = "Timed out while waiting for PR checks to comple
|
|
|
6141
6192
|
function is_pr_checks_timeout(error) {
|
|
6142
6193
|
return error instanceof Error && error.message === PR_CHECKS_TIMEOUT_MESSAGE;
|
|
6143
6194
|
}
|
|
6144
|
-
|
|
6195
|
+
function should_always_read_review_decision() {
|
|
6196
|
+
return true;
|
|
6197
|
+
}
|
|
6145
6198
|
var MERGE_GATE_EVALUATOR = {
|
|
6146
6199
|
evaluate: evaluate_pr_state,
|
|
6147
6200
|
describe: describe_pr_failure,
|
|
@@ -6168,7 +6221,7 @@ async function read_pr_state(input, evaluator) {
|
|
|
6168
6221
|
try {
|
|
6169
6222
|
const snapshot = await input.options.fetcher(
|
|
6170
6223
|
input.options.branch_name,
|
|
6171
|
-
evaluator.should_read_review_decision ??
|
|
6224
|
+
evaluator.should_read_review_decision ?? should_always_read_review_decision
|
|
6172
6225
|
);
|
|
6173
6226
|
return { kind: "read", snapshot };
|
|
6174
6227
|
} catch (error) {
|
|
@@ -6222,7 +6275,7 @@ async function wait_for_pr_success(options) {
|
|
|
6222
6275
|
}
|
|
6223
6276
|
throw to_exhaustion_error(carried.read_failure);
|
|
6224
6277
|
}
|
|
6225
|
-
async function default_fetch_pr_state(branch_name, should_read_review_decision =
|
|
6278
|
+
async function default_fetch_pr_state(branch_name, should_read_review_decision = should_always_read_review_decision) {
|
|
6226
6279
|
const checks = await git_gh_pr_snapshot.pr_get_checks_snapshot(branch_name);
|
|
6227
6280
|
const snapshot = parse_pr_state_snapshot(checks.snapshot_json);
|
|
6228
6281
|
if (!should_read_review_decision(snapshot)) return snapshot;
|
|
@@ -6250,11 +6303,13 @@ function describe_checks_failure(snapshot) {
|
|
|
6250
6303
|
const failed = snapshot.rollup.filter((check) => check.status === CHECK_STATUS_FAIL);
|
|
6251
6304
|
return `${CHECKS_FAILED_MESSAGE}: ${failed.map((check) => check.name).join(", ")}`;
|
|
6252
6305
|
}
|
|
6253
|
-
|
|
6306
|
+
function should_never_read_review_decision() {
|
|
6307
|
+
return false;
|
|
6308
|
+
}
|
|
6254
6309
|
var CHECKS_SETTLED_EVALUATOR = {
|
|
6255
6310
|
evaluate: evaluate_checks_settled,
|
|
6256
6311
|
describe: describe_checks_failure,
|
|
6257
|
-
should_read_review_decision:
|
|
6312
|
+
should_read_review_decision: should_never_read_review_decision
|
|
6258
6313
|
};
|
|
6259
6314
|
async function watch_until_settled(branch_name) {
|
|
6260
6315
|
await wait_for_pr_success({
|
|
@@ -6270,7 +6325,7 @@ async function watch_until_settled(branch_name) {
|
|
|
6270
6325
|
});
|
|
6271
6326
|
}
|
|
6272
6327
|
async function fail_when_no_checks(branch_name) {
|
|
6273
|
-
const snapshot = await default_fetch_pr_state(branch_name,
|
|
6328
|
+
const snapshot = await default_fetch_pr_state(branch_name, should_never_read_review_decision);
|
|
6274
6329
|
if (snapshot.rollup.length === 0) throw new Error(NO_CHECKS_MESSAGE);
|
|
6275
6330
|
}
|
|
6276
6331
|
async function pr_checks_watch(branch_name) {
|
|
@@ -6304,7 +6359,6 @@ export {
|
|
|
6304
6359
|
git_spawn_sync,
|
|
6305
6360
|
git_command,
|
|
6306
6361
|
git_common_directory,
|
|
6307
|
-
error_text,
|
|
6308
6362
|
tail_commands,
|
|
6309
6363
|
filing_cap,
|
|
6310
6364
|
CONTEXT_CUT_THRESHOLD,
|
|
@@ -6312,10 +6366,10 @@ export {
|
|
|
6312
6366
|
cli_flags,
|
|
6313
6367
|
own_session,
|
|
6314
6368
|
backlog_budget,
|
|
6315
|
-
run_cut_handoff,
|
|
6316
6369
|
run_hold,
|
|
6370
|
+
run_cut_handoff,
|
|
6317
6371
|
run_cut,
|
|
6318
|
-
|
|
6372
|
+
run_tail_rule,
|
|
6319
6373
|
lane_background,
|
|
6320
6374
|
IN_PROGRESS_LABEL,
|
|
6321
6375
|
NEEDS_DECISION_LABEL,
|
|
@@ -6325,7 +6379,7 @@ export {
|
|
|
6325
6379
|
ALREADY_DONE_LABEL,
|
|
6326
6380
|
has_any_label,
|
|
6327
6381
|
has_label_name,
|
|
6328
|
-
|
|
6382
|
+
agent_headless,
|
|
6329
6383
|
run_event_stream,
|
|
6330
6384
|
run_invocation,
|
|
6331
6385
|
run_carry,
|
|
@@ -6334,11 +6388,9 @@ export {
|
|
|
6334
6388
|
lane_park,
|
|
6335
6389
|
repo_origin,
|
|
6336
6390
|
repo_party,
|
|
6337
|
-
process_owner_schema,
|
|
6338
6391
|
lane_registry,
|
|
6339
6392
|
run_headless,
|
|
6340
6393
|
git_gh_api_path,
|
|
6341
|
-
FETCH_TIMEOUT_MS,
|
|
6342
6394
|
read_json_listing,
|
|
6343
6395
|
parse_json_object_safe,
|
|
6344
6396
|
git_gh_exec,
|