@joshuafolkken/kit 1.1514.0 → 1.2114.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/agents/investigator.md +1 -1
- package/.claude/agents/reviewer-verification.md +19 -0
- package/.claude/agents/reviewer.md +19 -0
- package/.claude/settings.json +5 -6
- package/.claude/skills/dependency-update/SKILL.md +9 -10
- package/.claude/skills/epic-commands/SKILL.md +26 -65
- package/.claude/skills/epic-commands/epic-bundle.md +3 -1
- package/.claude/skills/workflow-commands/SKILL.md +11 -11
- package/.claude/skills/workflow-commands/background-commands.md +13 -10
- package/.claude/skills/workflow-commands/backlogrun-child.md +12 -8
- package/.claude/skills/workflow-commands/backlogrun-handoff-report.md +7 -25
- package/.claude/skills/workflow-commands/backlogrun-lanes.md +18 -14
- package/.claude/skills/workflow-commands/backlogrun-park.md +18 -24
- package/.claude/skills/workflow-commands/backlogrun-progress.md +4 -5
- package/.claude/skills/workflow-commands/backlogrun-recovery.md +6 -6
- package/.claude/skills/workflow-commands/backlogrun-steps.md +12 -11
- package/.claude/skills/workflow-commands/backlogrun.md +1 -1
- package/.claude/skills/workflow-commands/chain-rule.md +43 -28
- package/.claude/skills/workflow-commands/delegation.md +11 -10
- package/.claude/skills/workflow-commands/entry-sequence.md +10 -10
- package/.claude/skills/workflow-commands/followup.md +16 -36
- package/.claude/skills/workflow-commands/fullrun-steps.md +38 -47
- package/.claude/skills/workflow-commands/fullrun.md +3 -3
- package/.claude/skills/workflow-commands/halfrun.md +17 -25
- package/.claude/skills/workflow-commands/issue-comments.md +25 -16
- package/.claude/skills/workflow-commands/issue-fold-existing.md +2 -1
- package/.claude/skills/workflow-commands/issue-scout.md +2 -2
- package/.claude/skills/workflow-commands/kickoff.md +24 -23
- package/.claude/skills/workflow-commands/latest-gate.md +7 -12
- package/.claude/skills/workflow-commands/needs-human-review.md +9 -14
- package/.claude/skills/workflow-commands/observation-filing.md +4 -36
- package/.claude/skills/workflow-commands/observation-ledger.md +6 -4
- package/.claude/skills/workflow-commands/pre-gate-cut.md +22 -37
- package/.claude/skills/workflow-commands/prerequisite.md +11 -16
- package/.claude/skills/workflow-commands/progress-watcher.md +1 -1
- package/.claude/skills/workflow-commands/prrun.md +3 -7
- package/.claude/skills/workflow-commands/retrospective.md +2 -2
- package/.claude/skills/workflow-commands/split-assessment.md +15 -1
- package/.claude/skills/workflow-commands/working-tree-hold.md +9 -9
- package/.codex/hooks.json +5 -5
- package/.github/actions/setup-node/action.yml +9 -0
- package/.github/actions/setup-pnpm/action.yml +10 -17
- package/.github/dependabot.yml +32 -0
- package/.github/release.yml +0 -2
- package/.github/workflows/auto-tag.yml +45 -0
- package/.github/workflows/ci.yml +267 -17
- package/.github/workflows/dependabot-auto-merge.yml +63 -4
- package/.github/workflows/production.yml +8 -0
- package/.github/workflows/publish.yml +67 -46
- package/.github/workflows/sonar-qube.yml +1 -0
- package/.prettierignore +2 -0
- package/.vscode/settings.json +19 -0
- package/.vscode/tasks.json +1 -2
- package/CLAUDE.md +7 -18
- package/README.md +4 -2
- package/SECURITY.md +3 -3
- package/dist/CLAUDE.md +7 -18
- package/dist/commands/document-read-cli.js +883 -0
- package/dist/commands/{document-section-cli.js → document-section-main.js} +81 -38
- package/dist/commands/read-set-cli.js +1927 -0
- package/dist/commands/run-prep-main.js +21174 -0
- package/dist/commands/run-step-cli.js +27733 -0
- package/dist/config-merge/index.js +5 -1
- package/dist/hooks/audit-provision.js +39 -36
- package/dist/hooks/chunk-3GKE653K.js +6204 -0
- package/dist/hooks/chunk-45CJJOO7.js +1243 -0
- package/dist/hooks/chunk-5PM2JRGV.js +7780 -0
- package/dist/hooks/chunk-7SIUNQXK.js +3591 -0
- package/dist/hooks/chunk-CQD4LJE6.js +4858 -0
- package/dist/hooks/{chunk-723HKZO5.js → chunk-OPSRGWFU.js} +1 -1
- package/dist/hooks/chunk-UJ3FPMMM.js +628 -0
- package/dist/hooks/chunk-VVNYJWEI.js +30 -0
- package/dist/hooks/chunk-Z6DQJKH3.js +2806 -0
- package/dist/hooks/codex-hook-adapter.js +10 -22
- package/dist/hooks/format-edited.js +4 -6
- package/dist/hooks/inputs.json +460 -308
- package/dist/hooks/pretool-guard.js +8 -25
- package/dist/hooks/session-lang.js +135 -299
- package/dist/hooks/stop-guard.js +6496 -1799
- package/dist/josh.js +7412 -4228
- package/dist/self-sync-guard/index.js +74 -10
- package/dist/version/index.js +276 -407
- package/eslint/base.js +1 -1
- package/eslint/rules/comment-why-only.js +108 -0
- package/lefthook/base.yml +3 -1
- package/package.json +23 -54
- package/pnpm-workspace.yaml +4 -2
- package/prompts/coding-standards.md +2 -2
- package/prompts/collaboration-workflow/file-edits.md +14 -17
- package/prompts/collaboration-workflow/issue-citation.md +0 -4
- package/prompts/collaboration-workflow/issue-template.md +54 -18
- package/prompts/collaboration-workflow/lane-instructions.md +3 -2
- package/prompts/collaboration-workflow/measurement.md +44 -0
- package/prompts/collaboration-workflow/operating-rules.md +15 -8
- package/prompts/collaboration-workflow/output-bounds.md +6 -7
- package/prompts/collaboration-workflow/plan-comment.md +3 -42
- package/prompts/collaboration-workflow/principles.md +14 -0
- package/prompts/collaboration-workflow/report-format.md +31 -60
- package/prompts/collaboration-workflow/residency.md +3 -2
- package/prompts/collaboration-workflow/rule-delivery.md +13 -1
- package/prompts/collaboration-workflow/shell-body.md +6 -16
- package/prompts/collaboration-workflow/turn-batching.md +0 -2
- package/prompts/collaboration-workflow/upstream-interrupt.md +15 -5
- package/prompts/collaboration-workflow/wip-cap.md +4 -2
- package/prompts/collaboration-workflow.md +3 -7
- package/prompts/refactoring.md +1 -1
- package/prompts/review-rubric.md +9 -2
- package/prompts/review.md +65 -36
- package/prompts/testing-guide.md +9 -43
- package/scripts/agent/agent-argv.ts +14 -16
- package/scripts/agent/agent-event.ts +15 -15
- package/scripts/agent/agent-exit-record.ts +13 -1
- package/scripts/agent/agent-provider.ts +138 -0
- package/scripts/agent/agent-role-profile.ts +108 -156
- package/scripts/agent/agent-safe-text.ts +20 -5
- package/scripts/agent/api-auth.ts +41 -0
- package/scripts/agent/api-outage.ts +1 -1
- package/scripts/agent/api-usage-limit.ts +65 -0
- package/scripts/agent/claude-agent-argv.ts +19 -9
- package/scripts/agent/codex-agent-argv.ts +118 -22
- package/scripts/agent/usage-limit-reset.ts +179 -0
- package/scripts/auth/claude-token-output.ts +2 -2
- package/scripts/auto-ok/auto-ok-author.ts +53 -0
- package/scripts/auto-ok/auto-ok-cli.ts +25 -16
- package/scripts/auto-ok/auto-ok-judge-read.ts +12 -3
- package/scripts/auto-ok/auto-ok-judge-write.ts +46 -19
- package/scripts/auto-ok/auto-ok-judge.ts +13 -2
- package/scripts/auto-ok/auto-ok-main.ts +17 -0
- package/scripts/backlog/backlog-arrival.ts +14 -3
- package/scripts/backlog/backlog-budget-cli.ts +7 -33
- package/scripts/backlog/backlog-budget-main.ts +16 -0
- package/scripts/backlog/backlog-budget.ts +2 -3
- package/scripts/backlog/backlog-defect-priority.ts +5 -4
- package/scripts/backlog/backlog-drive-adopt.ts +67 -0
- package/scripts/backlog/backlog-drive-args.ts +4 -5
- package/scripts/backlog/backlog-drive-cli.ts +118 -28
- package/scripts/backlog/backlog-drive-hold.ts +162 -0
- package/scripts/backlog/backlog-drive-idle.ts +161 -0
- package/scripts/backlog/backlog-drive-judge.ts +25 -0
- package/scripts/backlog/backlog-drive-launch-pass.ts +90 -0
- package/scripts/backlog/backlog-drive-launch.ts +8 -2
- package/scripts/backlog/backlog-drive-memory.ts +126 -0
- package/scripts/backlog/backlog-drive-named-offer.ts +73 -35
- package/scripts/backlog/backlog-drive-named.ts +81 -13
- package/scripts/backlog/backlog-drive-offer-argv.ts +3 -8
- package/scripts/backlog/backlog-drive-paused.ts +170 -0
- package/scripts/backlog/backlog-drive-restore.ts +39 -8
- package/scripts/backlog/backlog-drive-seats.ts +18 -8
- package/scripts/backlog/backlog-drive-token-handling.ts +38 -0
- package/scripts/backlog/backlog-drive.ts +96 -131
- package/scripts/backlog/backlog-gate-scope.ts +61 -0
- package/scripts/backlog/backlog-measure-close.ts +112 -0
- package/scripts/backlog/backlog-next-main.ts +16 -0
- package/scripts/backlog/backlog-next-shared.ts +73 -0
- package/scripts/backlog/backlog-next.ts +78 -56
- package/scripts/backlog/backlog-occupied.ts +52 -39
- package/scripts/backlog/backlog-offer-cli.ts +6 -21
- package/scripts/backlog/backlog-offer-exclude.ts +15 -0
- package/scripts/backlog/backlog-offer-main.ts +12 -0
- package/scripts/backlog/backlog-offer.ts +36 -3
- package/scripts/backlog/backlog-overlap.ts +62 -10
- package/scripts/backlog/backlog-plan-cli.ts +4 -1
- package/scripts/backlog/backlog-plan-comment.ts +81 -0
- package/scripts/backlog/backlog-plan-read.ts +22 -5
- package/scripts/backlog/backlog-plan.ts +18 -4
- package/scripts/backlog/backlog-pool.ts +60 -22
- package/scripts/backlog/backlog-rank.ts +70 -15
- package/scripts/backlog/backlog-ready.ts +112 -30
- package/scripts/backlog/backlog-stalled-detect.ts +110 -36
- package/scripts/backlog/backlog-stalled.ts +52 -16
- package/scripts/backlog/backlog-wait-cause.ts +86 -0
- package/scripts/backlog/backlog-waves.ts +56 -15
- package/scripts/backlog/backlogrun-args.ts +19 -7
- package/scripts/backlog/backlogrun-cli.ts +19 -5
- package/scripts/backlog/backlogrun-launch.ts +13 -4
- package/scripts/backlog/backlogrun-restart.ts +97 -0
- package/scripts/backlog/backlogrun-stop.ts +79 -7
- package/scripts/behavior/behavior-cli.ts +2 -2
- package/scripts/behavior/behavior-rules.ts +47 -24
- package/scripts/build/build-bin.ts +2 -16
- package/scripts/build/build-claude-md.ts +0 -7
- package/scripts/build/build-commands.ts +0 -13
- package/scripts/build/build-hooks.ts +49 -48
- package/scripts/build/hook-bundle-stamp.ts +29 -11
- package/scripts/build/local-bin.ts +1 -1
- package/scripts/cases/cases-cli.ts +25 -13
- package/scripts/cases/cases-interaction-scan.ts +134 -0
- package/scripts/cases/cases-interaction.ts +183 -0
- package/scripts/cases/cases-logic.ts +39 -6
- package/scripts/ci/pr-classification-main.ts +18 -0
- package/scripts/ci/pr-classification.ts +10 -17
- package/scripts/clone/clone-scan.ts +1 -1
- package/scripts/cost-runtime/context-cut-payback.ts +27 -25
- package/scripts/cost-runtime/cost-blocks.ts +22 -37
- package/scripts/cost-runtime/cost-cli.ts +67 -29
- package/scripts/cost-runtime/cost-main.ts +12 -0
- package/scripts/cost-runtime/cost-pricing.ts +9 -0
- package/scripts/cost-runtime/cost-transcript.ts +1 -0
- package/scripts/cost-runtime/cost-verdict.ts +4 -1
- package/scripts/delegation/delegation-policy.ts +18 -5
- package/scripts/delegation/duplicate-read-guard.ts +1 -8
- package/scripts/delegation/investigation-guard.ts +12 -8
- package/scripts/delegation/investigation-reads.ts +48 -27
- package/scripts/dependabot/dependabot-cooldown.ts +195 -0
- package/scripts/discovery/repo-discovery.ts +24 -6
- package/scripts/discovery/repo-party.ts +80 -20
- package/scripts/discovery/session-owner-pin.ts +51 -0
- package/scripts/doctor/doctor-consumer.ts +2 -5
- package/scripts/document/capped-print.ts +1 -1
- package/scripts/document/command-reference-line-budget.ts +42 -0
- package/scripts/document/document-byte-budget.ts +18 -6
- package/scripts/document/document-checks.ts +20 -0
- package/scripts/document/document-ratchet-check.ts +101 -0
- package/scripts/document/document-scan.ts +1 -1
- package/scripts/document/document-section-cli.ts +0 -8
- package/scripts/document/document-section-main.ts +12 -0
- package/scripts/document/document-section.ts +1 -0
- package/scripts/document/entry-read-budget.ts +7 -3
- package/scripts/document/issue-citation-budget.ts +94 -0
- package/scripts/epic/epic-audit-cli.ts +12 -6
- package/scripts/epic/epic-bundle-apply.ts +137 -0
- package/scripts/epic/epic-bundle-cli.ts +32 -121
- package/scripts/epic/epic-bundle-format.ts +116 -0
- package/scripts/epic/epic-bundle-main.ts +17 -0
- package/scripts/epic/epic-busy.ts +5 -12
- package/scripts/epic/epic-classify.ts +24 -15
- package/scripts/epic/epic-cli-argv.ts +33 -2
- package/scripts/epic/epic-cli-decide.ts +42 -0
- package/scripts/epic/epic-cli.ts +6 -38
- package/scripts/epic/epic-close.ts +112 -55
- package/scripts/epic/epic-cross-repo.ts +4 -7
- package/scripts/epic/epic-decide.ts +119 -0
- package/scripts/epic/epic-decision.ts +9 -0
- package/scripts/epic/epic-fetch.ts +6 -0
- package/scripts/epic/epic-graph.ts +8 -1
- package/scripts/epic/epic-issue.ts +8 -2
- package/scripts/epic/epic-label-age.ts +1 -1
- package/scripts/epic/epic-lane-offer.ts +39 -4
- package/scripts/epic/epic-next-main.ts +24 -0
- package/scripts/epic/epic-next.ts +6 -24
- package/scripts/epic/epic-outside-blocker.ts +6 -2
- package/scripts/epic/epic-parse.ts +9 -3
- package/scripts/epic/epic-rank.ts +5 -0
- package/scripts/epic/epic-read.ts +1 -0
- package/scripts/epic/epic-reconcile.ts +39 -0
- package/scripts/epic/epic-run.ts +10 -1
- package/scripts/epic/epic-solo.ts +50 -14
- package/scripts/epic/epic.ts +41 -7
- package/scripts/exports/unused-members-check.ts +62 -0
- package/scripts/exports/unused-members-cli.ts +6 -51
- package/scripts/followup/followup-checks-event.ts +8 -3
- package/scripts/followup/followup-ci-path.ts +67 -0
- package/scripts/followup/followup-coderabbit-retrigger.ts +261 -0
- package/scripts/followup/followup-coderabbit-wait.ts +85 -0
- package/scripts/followup/followup-failed-tests.ts +160 -0
- package/scripts/followup/followup-job-needs.ts +100 -0
- package/scripts/followup/followup-job-rerun.ts +303 -0
- package/scripts/followup/followup-main-move.ts +113 -0
- package/scripts/followup/followup-review-gates.ts +81 -0
- package/scripts/followup/git-followup-finish.ts +43 -11
- package/scripts/followup/git-followup-pending.ts +3 -3
- package/scripts/followup/git-followup-stages.ts +52 -12
- package/scripts/followup/git-followup-workflow.ts +19 -66
- package/scripts/followup/git-pr-followup-checks.ts +55 -16
- package/scripts/followup/git-pr-followup-wrapup.ts +32 -18
- package/scripts/followup/git-pr-followup.ts +96 -33
- package/scripts/fresh-machine/fresh-machine-cli.ts +1 -1
- package/scripts/fresh-machine/fresh-machine-run.ts +8 -8
- package/scripts/fresh-machine/fresh-machine-script.ts +5 -9
- package/scripts/fresh-machine/specs/kit-test-backlogrun-python.json +2 -2
- package/scripts/fresh-machine/specs/kit-test-backlogrun.json +3 -3
- package/scripts/gate/busy-average.ts +90 -0
- package/scripts/gate/check-cpu.ts +60 -0
- package/scripts/gate/check-inputs.ts +39 -95
- package/scripts/gate/check-related-pinned.ts +43 -0
- package/scripts/gate/check-related-reuse.ts +64 -0
- package/scripts/gate/check-related-section.ts +57 -0
- package/scripts/gate/check-related-unplanned.ts +34 -0
- package/scripts/gate/check-related.ts +265 -0
- package/scripts/gate/check-reuse.ts +33 -54
- package/scripts/gate/command-memory.ts +192 -0
- package/scripts/gate/core-admission.ts +236 -28
- package/scripts/gate/core-budget-timing.ts +51 -0
- package/scripts/gate/core-budget.ts +111 -100
- package/scripts/gate/core-wait-record.ts +49 -0
- package/scripts/gate/core-wait.ts +62 -7
- package/scripts/gate/core-weights.ts +94 -0
- package/scripts/gate/free-cores.ts +27 -4
- package/scripts/gate/gate-labels.ts +46 -0
- package/scripts/gate/gate-ledger.ts +44 -8
- package/scripts/gate/gate-plan.ts +130 -78
- package/scripts/gate/gate-report.ts +23 -9
- package/scripts/gate/gate-run-steps.ts +77 -9
- package/scripts/gate/gate-skip.ts +57 -8
- package/scripts/gate/gate-static-group.ts +60 -0
- package/scripts/gate/gate-steps.ts +14 -2
- package/scripts/gate/gate-tree.ts +4 -2
- package/scripts/gate/hook-gate-reuse.ts +19 -2
- package/scripts/gate/input-fingerprint.ts +42 -0
- package/scripts/gate/machine-capacity.ts +65 -31
- package/scripts/gate/metrics-totals.ts +59 -0
- package/scripts/gate/moved-paths.ts +67 -0
- package/scripts/gate/project-checks.ts +5 -12
- package/scripts/gate/scoped-green.ts +76 -19
- package/scripts/gate/since-green.ts +70 -0
- package/scripts/gate/structural-checks.ts +96 -0
- package/scripts/gate/toolchain-inputs.ts +115 -0
- package/scripts/gate/verification-gate.ts +70 -32
- package/scripts/gate/verification-inputs.ts +265 -0
- package/scripts/gate/verification-tail.ts +52 -0
- package/scripts/gh/gh-author-association.ts +117 -9
- package/scripts/gh/git-ai-review-scan.ts +5 -3
- package/scripts/gh/git-gh-api-path.ts +26 -2
- package/scripts/gh/git-gh-branch-rules.ts +73 -0
- package/scripts/gh/git-gh-comments-unreadable.ts +36 -0
- package/scripts/gh/git-gh-conditional.ts +5 -2
- package/scripts/gh/git-gh-exec.ts +32 -2
- package/scripts/gh/git-gh-issue-read.ts +7 -1
- package/scripts/gh/git-gh-issue-rest.ts +1 -0
- package/scripts/gh/git-gh-issue-write.ts +75 -31
- package/scripts/gh/git-gh-issue.ts +19 -8
- package/scripts/gh/git-gh-poll-read.ts +89 -0
- package/scripts/gh/git-gh-pr-auto-merge.ts +21 -9
- package/scripts/gh/git-gh-pr-graphql-state.ts +56 -0
- package/scripts/gh/git-gh-pr-read.ts +74 -13
- package/scripts/gh/git-gh-pr-rest.ts +4 -2
- package/scripts/gh/git-gh-pr-snapshot.ts +48 -20
- package/scripts/gh/git-gh-pr-too-large.ts +20 -0
- package/scripts/gh/git-gh-pr.ts +48 -22
- package/scripts/gh/git-gh-retry.ts +141 -0
- package/scripts/gh/git-pr-ai-review.ts +15 -6
- package/scripts/gh/git-pr-checks-eval.ts +42 -7
- package/scripts/gh/git-pr-checks-parse.ts +39 -9
- package/scripts/gh/git-pr-checks.ts +5 -5
- package/scripts/gh/git-pr-merge-checked.ts +80 -0
- package/scripts/git/base-tree.ts +49 -2
- package/scripts/git/change-base.ts +4 -10
- package/scripts/git/changed-file-scope.ts +6 -4
- package/scripts/git/changed-paths-sync.ts +63 -0
- package/scripts/git/changed-paths.ts +34 -2
- package/scripts/git/git-common-directory.ts +11 -1
- package/scripts/git/git-diff-reads.ts +91 -20
- package/scripts/git/git-error.ts +9 -2
- package/scripts/git/git-grep-hits.ts +85 -0
- package/scripts/git/git-location-environment.ts +1 -1
- package/scripts/git/git-merge-conflicts.ts +83 -0
- package/scripts/git/git-preflight.ts +37 -12
- package/scripts/git/git-push-transport.ts +1 -2
- package/scripts/git/git-schemas.ts +30 -7
- package/scripts/git/git-spawn.ts +1 -2
- package/scripts/git/git-status.ts +4 -4
- package/scripts/git/git-worktree.ts +13 -0
- package/scripts/git/gone-branch.ts +4 -1
- package/scripts/git/main-merge-budget-conflict.ts +89 -0
- package/scripts/git/main-merge-guard.ts +55 -18
- package/scripts/git/main-merge-main.ts +12 -0
- package/scripts/git/main-merge-regenerate.ts +59 -25
- package/scripts/git/main-merge.ts +77 -13
- package/scripts/git/main-sync-main.ts +12 -0
- package/scripts/git/main-sync.ts +0 -9
- package/scripts/git/no-base-checkout.ts +127 -0
- package/scripts/git/stash/git-stash.ts +38 -6
- package/scripts/git/stash/{stash-pop-args.ts → stash-args.ts} +13 -10
- package/scripts/git/stash/stash-pop-cli.ts +6 -12
- package/scripts/git/stash/stash-pop-main.ts +12 -0
- package/scripts/git/stash/stash-push-cli.ts +86 -0
- package/scripts/git/stash/stash-push-main.ts +12 -0
- package/scripts/hooks/batch-guard.ts +38 -27
- package/scripts/hooks/check-commit-message-main.ts +8 -0
- package/scripts/hooks/check-commit-message.ts +4 -7
- package/scripts/hooks/edited-cspell.ts +37 -11
- package/scripts/hooks/format-edited-file.ts +29 -25
- package/scripts/hooks/lane-plan-guard.ts +50 -0
- package/scripts/hooks/pre-commit-lint-switch.ts +9 -0
- package/scripts/hooks/pre-commit-lint.ts +44 -4
- package/scripts/hooks/pre-push-related-switch.ts +10 -0
- package/scripts/hooks/pre-push-unit.ts +77 -9
- package/scripts/hooks/pretool-guard-cli.ts +1 -8
- package/scripts/hooks/pretool-guard.ts +34 -19
- package/scripts/hooks/reserved-run.ts +81 -10
- package/scripts/hooks/run-hook.sh +30 -6
- package/scripts/hooks/shell-rules-notice.ts +37 -0
- package/scripts/hooks/step-zero-notice.ts +6 -1
- package/scripts/hooks/stop-actions.ts +5 -36
- package/scripts/hooks/stop-guard.ts +20 -15
- package/scripts/init/distributed-paths.ts +1 -0
- package/scripts/init/hook-command-rewrite.ts +23 -5
- package/scripts/init/hook-launch.ts +17 -17
- package/scripts/init/init-actions.ts +0 -6
- package/scripts/init/init-ai-copy.ts +10 -36
- package/scripts/init/init-bootstrap.ts +9 -8
- package/scripts/init/init-dry-run-report.ts +1 -1
- package/scripts/init/init-dry-run.ts +1 -1
- package/scripts/init/init-file-action.ts +7 -9
- package/scripts/init/init-logic-json-merge.ts +2 -2
- package/scripts/init/init-logic-migrate.ts +9 -82
- package/scripts/init/init-logic.ts +3 -2
- package/scripts/init/init-main.ts +12 -0
- package/scripts/init/init.ts +5 -12
- package/scripts/init/kit-development-versions.ts +3 -7
- package/scripts/init/kit-written-paths.ts +2 -2
- package/scripts/init/project-profile.ts +5 -4
- package/scripts/init/tsconfig-preset-migration.ts +2 -1
- package/scripts/init/vscode-tasks.ts +1 -1
- package/scripts/issue/aggregation-split.ts +52 -0
- package/scripts/issue/defect-origin-cli.ts +106 -0
- package/scripts/issue/defect-origin-line.ts +78 -0
- package/scripts/issue/defect-origin-main.ts +11 -0
- package/scripts/issue/defect-origin.ts +114 -0
- package/scripts/issue/defect-rate-cli.ts +38 -179
- package/scripts/issue/defect-rate.ts +0 -16
- package/scripts/issue/defect-report-cli.ts +128 -0
- package/scripts/issue/defect-report-format.ts +56 -0
- package/scripts/issue/defect-report-main.ts +11 -0
- package/scripts/issue/defect-report.ts +160 -0
- package/scripts/issue/effect-audit-cli.ts +178 -0
- package/scripts/issue/effect-audit.ts +185 -0
- package/scripts/issue/expected-effect-lint.ts +65 -9
- package/scripts/issue/git-next-issues.ts +5 -0
- package/scripts/issue/issue-already-done-cli.ts +62 -0
- package/scripts/issue/issue-body-or-comment.ts +74 -0
- package/scripts/issue/issue-cite-cli.ts +1 -12
- package/scripts/issue/issue-cite-main.ts +12 -0
- package/scripts/issue/issue-classification.ts +13 -7
- package/scripts/issue/issue-closing-pr.ts +8 -1
- package/scripts/issue/issue-comment-cli.ts +10 -24
- package/scripts/issue/issue-comment-main.ts +12 -0
- package/scripts/issue/issue-evidence-exit.ts +102 -0
- package/scripts/issue/issue-file-cap.ts +58 -0
- package/scripts/issue/issue-file-cli.ts +131 -36
- package/scripts/issue/issue-file-deferral.ts +52 -0
- package/scripts/issue/issue-file-fold.ts +29 -10
- package/scripts/issue/issue-file-interrupt.ts +85 -0
- package/scripts/issue/issue-file-lane-hint.ts +30 -0
- package/scripts/issue/issue-file.ts +56 -19
- package/scripts/issue/issue-fold-cli.ts +2 -11
- package/scripts/issue/issue-fold-main.ts +12 -0
- package/scripts/issue/issue-labels.ts +97 -89
- package/scripts/issue/issue-lint-cli.ts +29 -12
- package/scripts/issue/issue-lint-main.ts +12 -0
- package/scripts/issue/issue-measured-cli.ts +34 -0
- package/scripts/issue/issue-measured-close.ts +58 -0
- package/scripts/issue/issue-merged.ts +19 -2
- package/scripts/issue/issue-not-before-label.ts +135 -0
- package/scripts/issue/issue-not-before.ts +114 -0
- package/scripts/issue/issue-number-shape.ts +15 -1
- package/scripts/issue/issue-park.ts +28 -0
- package/scripts/issue/issue-plan-cli.ts +151 -0
- package/scripts/issue/issue-priority-cli.ts +60 -0
- package/scripts/issue/issue-priority-raise.ts +55 -0
- package/scripts/issue/issue-priority.ts +282 -0
- package/scripts/issue/issue-rank.ts +27 -4
- package/scripts/issue/issue-read-cli.ts +35 -16
- package/scripts/issue/issue-read-main.ts +12 -0
- package/scripts/issue/issue-read.ts +62 -13
- package/scripts/issue/issue-release-cli.ts +0 -10
- package/scripts/issue/issue-release-main.ts +13 -0
- package/scripts/issue/issue-release.ts +7 -12
- package/scripts/issue/issue-sample-gate.ts +213 -0
- package/scripts/issue/issue-sample-prime.ts +127 -0
- package/scripts/issue/issue-sample-required.ts +57 -0
- package/scripts/issue/issue-sample-source.ts +77 -0
- package/scripts/issue/issue-scout-cli.ts +0 -11
- package/scripts/issue/issue-scout-main.ts +14 -0
- package/scripts/issue/issue-search.ts +124 -0
- package/scripts/issue/issue-state-cli.ts +0 -10
- package/scripts/issue/issue-state-main.ts +12 -0
- package/scripts/issue/issue-state.ts +13 -1
- package/scripts/issue/issue-template-section.ts +43 -0
- package/scripts/issue/issue-watch-diff.ts +87 -16
- package/scripts/issue/issue-watch-hook.ts +11 -2
- package/scripts/issue/issue-watch.ts +55 -11
- package/scripts/issue/issue-wip.ts +2 -7
- package/scripts/issue/markdown-section.ts +1 -0
- package/scripts/issue/measure-declaration.ts +121 -0
- package/scripts/issue/measure-rerun-cli.ts +7 -65
- package/scripts/issue/plan-consumers-cli.ts +39 -0
- package/scripts/issue/plan-consumers-main.ts +11 -0
- package/scripts/issue/plan-consumers-section.ts +76 -0
- package/scripts/issue/plan-consumers.ts +127 -0
- package/scripts/issue/reproduction-measure.ts +3 -1
- package/scripts/issue/size-estimate.ts +90 -0
- package/scripts/issue/trusted-measure.ts +84 -0
- package/scripts/josh/agent-session-environment.ts +1 -1
- package/scripts/josh/command-usage.ts +17 -44
- package/scripts/josh/durable-state-migrate.ts +105 -0
- package/scripts/josh/durable-state.ts +112 -0
- package/scripts/josh/file-map-stamp.ts +49 -16
- package/scripts/josh/hook-decision.ts +32 -20
- package/scripts/josh/josh-aliases.ts +95 -0
- package/scripts/josh/josh-command-map.ts +1 -79
- package/scripts/josh/josh-command-types.ts +12 -6
- package/scripts/josh/josh-commands-agent-hooks.ts +83 -0
- package/scripts/josh/josh-commands-ai.ts +160 -161
- package/scripts/josh/josh-commands-backlog.ts +82 -16
- package/scripts/josh/josh-commands-clone.ts +1 -0
- package/scripts/josh/josh-commands-development.ts +142 -101
- package/scripts/josh/josh-commands-document.ts +43 -1
- package/scripts/josh/josh-commands-epic.ts +171 -0
- package/scripts/josh/josh-commands-hooks.ts +25 -2
- package/scripts/josh/josh-commands-issue-write.ts +200 -0
- package/scripts/josh/josh-commands-issue.ts +156 -24
- package/scripts/josh/josh-commands-lane.ts +187 -3
- package/scripts/josh/josh-commands-lint.ts +34 -10
- package/scripts/josh/josh-commands-maintenance.ts +127 -4
- package/scripts/josh/josh-commands-pause.ts +29 -0
- package/scripts/josh/josh-commands-progress.ts +87 -0
- package/scripts/josh/josh-commands-project.ts +138 -9
- package/scripts/josh/josh-commands-review.ts +159 -0
- package/scripts/josh/josh-commands-run.ts +211 -23
- package/scripts/josh/josh-commands-ship.ts +217 -0
- package/scripts/josh/josh-commands-split.ts +9 -0
- package/scripts/josh/josh-commands-test-check.ts +80 -0
- package/scripts/josh/josh-commands-versioning.ts +49 -2
- package/scripts/josh/josh-commands-workflow.ts +144 -6
- package/scripts/josh/josh-environment-file.ts +43 -3
- package/scripts/josh/josh-in-process.ts +2 -2
- package/scripts/josh/josh-logic.ts +11 -16
- package/scripts/josh/josh-run.ts +19 -1
- package/scripts/josh/package-directory.ts +2 -4
- package/scripts/josh/process-identity.ts +13 -4
- package/scripts/josh/run-record-path.ts +15 -0
- package/scripts/josh/session-language-cli.ts +4 -8
- package/scripts/josh/session-language-main.ts +13 -0
- package/scripts/josh/session-language.ts +6 -1
- package/scripts/josh/shared-cache.ts +90 -0
- package/scripts/josh/stamp-file.ts +20 -17
- package/scripts/lane/lane-adopt-cli.ts +98 -0
- package/scripts/lane/lane-adopt.ts +208 -0
- package/scripts/lane/lane-await.ts +56 -20
- package/scripts/lane/lane-baseline.ts +123 -0
- package/scripts/lane/lane-breakdown-cli.ts +64 -0
- package/scripts/lane/lane-breakdown-implement.ts +170 -0
- package/scripts/lane/lane-breakdown-laps.ts +107 -0
- package/scripts/lane/lane-breakdown-pinned.ts +76 -0
- package/scripts/lane/lane-breakdown-text.ts +145 -0
- package/scripts/lane/lane-breakdown.ts +239 -0
- package/scripts/lane/lane-cache.ts +5 -30
- package/scripts/lane/lane-capacity.ts +14 -23
- package/scripts/lane/lane-check-stats.ts +84 -22
- package/scripts/lane/lane-child-invocation.ts +17 -2
- package/scripts/lane/lane-child-mark-keys.ts +12 -0
- package/scripts/lane/lane-child-marker.ts +20 -1
- package/scripts/lane/lane-ci-path-stats.ts +73 -0
- package/scripts/lane/lane-claim-stats.ts +84 -0
- package/scripts/lane/lane-cli.ts +15 -5
- package/scripts/lane/lane-close.ts +91 -18
- package/scripts/lane/lane-core-wait-stats.ts +66 -0
- package/scripts/lane/lane-dispatch-log.ts +3 -3
- package/scripts/lane/lane-dispatch.ts +26 -5
- package/scripts/lane/lane-gap-stats.ts +157 -0
- package/scripts/lane/lane-guard-policy.ts +7 -1
- package/scripts/lane/lane-handoff.ts +69 -1
- package/scripts/lane/lane-held-stats.ts +129 -0
- package/scripts/lane/lane-implement-stats.ts +207 -0
- package/scripts/lane/lane-implement-subagents.ts +90 -0
- package/scripts/lane/lane-install.ts +4 -11
- package/scripts/lane/lane-investigation-switch.ts +16 -0
- package/scripts/lane/lane-launch-cli.ts +0 -9
- package/scripts/lane/lane-launch-main.ts +12 -0
- package/scripts/lane/lane-ledger-kind.ts +31 -0
- package/scripts/lane/lane-ledger-schema-ship.ts +49 -0
- package/scripts/lane/lane-ledger-schema.ts +349 -0
- package/scripts/lane/lane-ledger-write.ts +257 -0
- package/scripts/lane/lane-ledger.ts +56 -233
- package/scripts/lane/lane-limit-cli.ts +12 -1
- package/scripts/lane/lane-load.ts +1 -1
- package/scripts/lane/lane-measure-cli.ts +193 -30
- package/scripts/lane/lane-net-read.ts +44 -0
- package/scripts/lane/lane-net-time.ts +212 -0
- package/scripts/lane/lane-open.ts +25 -8
- package/scripts/lane/lane-output.ts +2 -4
- package/scripts/lane/lane-overrun-prompt.ts +147 -0
- package/scripts/lane/lane-overrun.ts +274 -0
- package/scripts/lane/lane-parked.ts +3 -3
- package/scripts/lane/lane-paths.ts +24 -1
- package/scripts/lane/lane-pause-cli.ts +133 -0
- package/scripts/lane/lane-pause.ts +158 -0
- package/scripts/lane/lane-paused-spans.ts +97 -0
- package/scripts/lane/lane-plan-check.ts +207 -0
- package/scripts/lane/lane-plan-cli.ts +41 -0
- package/scripts/lane/lane-plan.ts +144 -0
- package/scripts/lane/lane-process-table.ts +166 -0
- package/scripts/lane/lane-reap-settle.ts +124 -0
- package/scripts/lane/lane-reap.ts +50 -15
- package/scripts/lane/lane-registry.ts +38 -4
- package/scripts/lane/lane-relaunch.ts +1 -1
- package/scripts/lane/lane-residents.ts +162 -0
- package/scripts/lane/lane-restart.ts +22 -2
- package/scripts/lane/lane-round-one-stats.ts +51 -0
- package/scripts/lane/lane-round-two-stats.ts +49 -0
- package/scripts/lane/lane-sampler.ts +26 -3
- package/scripts/lane/lane-session-action.ts +112 -23
- package/scripts/lane/lane-session-broker.ts +146 -37
- package/scripts/lane/lane-session-reread-main.ts +14 -0
- package/scripts/lane/lane-session-reread.ts +51 -0
- package/scripts/lane/lane-ship-lap-stats.ts +74 -0
- package/scripts/lane/lane-sleep.ts +58 -0
- package/scripts/lane/lane-snapshot-trace.ts +84 -0
- package/scripts/lane/lane-spans.ts +51 -0
- package/scripts/lane/lane-spent.ts +7 -4
- package/scripts/lane/lane-split-stats.ts +28 -0
- package/scripts/lane/lane-stage-stats.ts +20 -3
- package/scripts/lane/lane-state.ts +334 -0
- package/scripts/lane/lane-stats-tables.ts +58 -0
- package/scripts/lane/lane-stats.ts +74 -4
- package/scripts/lane/lane-stop-stats.ts +145 -37
- package/scripts/lane/lane-tail-stats.ts +32 -0
- package/scripts/lane/lane-test-related-stats.ts +127 -0
- package/scripts/lane/lane-transcript-calls.ts +202 -0
- package/scripts/lane/lane-transcript-stats.ts +200 -0
- package/scripts/lane/lane-vacant.ts +13 -3
- package/scripts/lane/lane-value-cell.ts +72 -0
- package/scripts/lane/lane-value.ts +118 -0
- package/scripts/lane/lane-withdraw-cli.ts +5 -4
- package/scripts/lane/lane-withdraw-closed.ts +124 -0
- package/scripts/lane/lane-withdraw.ts +149 -71
- package/scripts/lane/lane-yield.ts +85 -0
- package/scripts/lane/openai-lane-ship.ts +12 -11
- package/scripts/lane/openai-lane-supervisor-decision.ts +6 -8
- package/scripts/lane/openai-lane-supervisor-owner.ts +5 -8
- package/scripts/lane/openai-lane-supervisor.ts +5 -4
- package/scripts/lane/process-directories.ts +70 -0
- package/scripts/lane/process-lane-marks.ts +94 -0
- package/scripts/lib/atomic-write.ts +62 -0
- package/scripts/lib/buffered-process.ts +12 -5
- package/scripts/lib/cli-flags.ts +53 -0
- package/scripts/lib/figure-format.ts +63 -0
- package/scripts/lib/json-value.ts +9 -1
- package/scripts/lib/package-manifest.ts +35 -0
- package/scripts/lib/poll.ts +38 -9
- package/scripts/lib/read-file.ts +3 -1
- package/scripts/lib/settled-together.ts +10 -0
- package/scripts/lib/shell-quote.ts +21 -0
- package/scripts/lib/stamped-memo.ts +63 -0
- package/scripts/lib/stdout-on-stderr.ts +24 -0
- package/scripts/lib/timeouts.ts +9 -0
- package/scripts/lib/token-shape.ts +111 -0
- package/scripts/lib/transcript-record.ts +91 -0
- package/scripts/lines/effective-limit.ts +1 -1
- package/scripts/lint/eslint-cache-dependencies.ts +145 -0
- package/scripts/lint/eslint-daemon-sources.ts +79 -0
- package/scripts/lint/eslint-daemon.ts +304 -0
- package/scripts/lint/eslint-warm-cli.ts +7 -0
- package/scripts/lint/eslint-warm.ts +66 -0
- package/scripts/lint/format.ts +11 -2
- package/scripts/lint/import-graph.ts +409 -0
- package/scripts/lint/lint-gate-scope.ts +102 -0
- package/scripts/lint/lint-parallel-main.ts +19 -0
- package/scripts/lint/lint-parallel.ts +113 -33
- package/scripts/lint/lint-related-scope.ts +30 -24
- package/scripts/lint/lint-related.ts +183 -30
- package/scripts/lint/rename-cli.ts +179 -0
- package/scripts/lint/rename-identifier.ts +192 -0
- package/scripts/lint/type-only-imports.ts +58 -0
- package/scripts/notify/confirmation-options.ts +1 -2
- package/scripts/notify/telegram-notify.ts +32 -23
- package/scripts/notify/telegram-test-logic.ts +0 -1
- package/scripts/notify/telegram-test-main.ts +8 -0
- package/scripts/notify/telegram-test.ts +2 -6
- package/scripts/observations/observation-ledger.ts +13 -0
- package/scripts/observations/observation-record.ts +42 -16
- package/scripts/observations/observations-flush-landing.ts +5 -3
- package/scripts/observations/observations-flush.ts +38 -10
- package/scripts/overrides/overrides-check.ts +11 -6
- package/scripts/overrides/overrides-files.ts +2 -1
- package/scripts/overrides/overrides-logic.ts +3 -6
- package/scripts/package/verify-optional-eslint-install.ts +8 -6
- package/scripts/propagate/propagate-publish.ts +2 -7
- package/scripts/propagate/propagate-targets.ts +4 -12
- package/scripts/refactor/import-graph.ts +9 -7
- package/scripts/release/github-release-runs.ts +17 -6
- package/scripts/release/release-approval-prune.ts +24 -0
- package/scripts/release/release-history.ts +1 -3
- package/scripts/release/release-progress.ts +42 -22
- package/scripts/release/release-publish-run.ts +39 -0
- package/scripts/release/release-publish.ts +6 -6
- package/scripts/release/release-scope-cli.ts +0 -10
- package/scripts/release/release-scope-main.ts +12 -0
- package/scripts/repo/repo-setting.ts +3 -6
- package/scripts/repo/required-checks-logic.ts +10 -16
- package/scripts/repo/ruleset-check.ts +4 -3
- package/scripts/report/markdown-shape.ts +28 -0
- package/scripts/report/report-format-reference.ts +17 -1
- package/scripts/report/report-labels.ts +166 -0
- package/scripts/report/report-lint-child-summary.ts +94 -0
- package/scripts/report/report-lint-cli.ts +29 -7
- package/scripts/report/report-lint.ts +85 -128
- package/scripts/report/report-template-cli.ts +59 -0
- package/scripts/report/report-template.ts +112 -0
- package/scripts/review/acceptance-map.ts +1 -0
- package/scripts/review/prose-stale-cli.ts +88 -0
- package/scripts/review/prose-stale-scan.ts +152 -0
- package/scripts/review/removed-tests-check.ts +86 -0
- package/scripts/review/removed-tests.ts +149 -0
- package/scripts/review/review-attest.ts +73 -23
- package/scripts/review/review-brief-cli.ts +138 -23
- package/scripts/review/review-brief-main.ts +12 -0
- package/scripts/review/review-brief-paths.ts +22 -0
- package/scripts/review/review-brief.ts +45 -10
- package/scripts/review/review-code-tree.ts +10 -6
- package/scripts/review/review-comment-carry.ts +47 -0
- package/scripts/review/review-comment-round.ts +111 -30
- package/scripts/review/review-finding-ledger.ts +135 -18
- package/scripts/review/review-finding-text.ts +43 -0
- package/scripts/review/review-interaction.ts +105 -0
- package/scripts/review/review-lane-handover.ts +68 -0
- package/scripts/review/review-lint-cli.ts +57 -0
- package/scripts/review/review-lint-findings.ts +92 -0
- package/scripts/review/review-lint-sections.ts +80 -0
- package/scripts/review/review-lint.ts +221 -0
- package/scripts/review/review-prior-findings.ts +102 -0
- package/scripts/review/review-readers-scan.ts +165 -0
- package/scripts/review/review-record-cli.ts +236 -74
- package/scripts/review/review-record-code-round.ts +55 -0
- package/scripts/review/review-record-comment.ts +60 -0
- package/scripts/review/review-record-interaction.ts +35 -0
- package/scripts/review/review-record-main.ts +12 -0
- package/scripts/review/review-record-pinned.ts +108 -0
- package/scripts/review/review-record.ts +25 -1
- package/scripts/review/review-reviewed-tree.ts +307 -0
- package/scripts/review/review-round-one-blobs.ts +221 -0
- package/scripts/review/review-round-one-closure.ts +62 -0
- package/scripts/review/review-round-reuse.ts +106 -0
- package/scripts/review/review-round2-cli.ts +135 -36
- package/scripts/review/review-round2-skip-comment.ts +55 -0
- package/scripts/review/review-round2.ts +103 -19
- package/scripts/review/review-stamps.ts +23 -1
- package/scripts/review/review-stop-log.ts +110 -0
- package/scripts/review/review-stops-cli.ts +86 -0
- package/scripts/review/review-submit-cli.ts +101 -0
- package/scripts/review/review-tree.ts +6 -17
- package/scripts/review/review-untouched-readers.ts +146 -0
- package/scripts/review/test-titles.ts +118 -0
- package/scripts/rules/agent-model.ts +9 -1
- package/scripts/rules/bash-triggers.ts +49 -6
- package/scripts/rules/concise-reply.ts +88 -0
- package/scripts/rules/credential-body.ts +77 -0
- package/scripts/rules/decision-oracle-batch.ts +9 -1
- package/scripts/rules/decision-oracle.ts +3 -3
- package/scripts/rules/delivered-rules.ts +115 -18
- package/scripts/rules/destructive-command.ts +11 -12
- package/scripts/rules/direct-filing.ts +10 -2
- package/scripts/rules/direct-issue-comment.ts +139 -0
- package/scripts/rules/direct-issue-read.ts +191 -0
- package/scripts/rules/direct-pr-create.ts +72 -26
- package/scripts/rules/early-heartbeat.ts +4 -1
- package/scripts/rules/edit-tool.ts +27 -0
- package/scripts/rules/file-body.ts +7 -0
- package/scripts/rules/file-edit-rows.ts +17 -0
- package/scripts/rules/file-rewrite.ts +146 -0
- package/scripts/rules/firing-point.ts +3 -2
- package/scripts/rules/gh-api.ts +128 -7
- package/scripts/rules/gh-repo-selector.ts +84 -0
- package/scripts/rules/git-argv.ts +72 -14
- package/scripts/rules/git-force.ts +14 -4
- package/scripts/rules/guard-remedy.ts +17 -4
- package/scripts/rules/implementation-cut-verdict.ts +1 -1
- package/scripts/rules/implementation-cut.ts +68 -27
- package/scripts/rules/index-guard.ts +8 -1
- package/scripts/rules/investigator-foreground.ts +231 -0
- package/scripts/rules/issue-citation.ts +15 -60
- package/scripts/rules/issue-comments.ts +18 -5
- package/scripts/rules/josh-git-bare.ts +7 -0
- package/scripts/rules/lane-background.ts +103 -33
- package/scripts/rules/lane-carry-conflict.ts +6 -0
- package/scripts/rules/lane-direct-tool.ts +172 -0
- package/scripts/rules/lane-interactive-ask.ts +12 -2
- package/scripts/rules/lane-park.ts +49 -25
- package/scripts/rules/lane-spilled-read.ts +90 -0
- package/scripts/rules/lane-split-park.ts +11 -3
- package/scripts/rules/lane-switch-main.ts +11 -4
- package/scripts/rules/last-prompt.ts +20 -47
- package/scripts/rules/oracle-consulted.ts +11 -1
- package/scripts/rules/oracle-firing.ts +1 -0
- package/scripts/rules/permission-guards.ts +7 -0
- package/scripts/rules/piped-verification-shapes.ts +110 -0
- package/scripts/rules/piped-verification.ts +68 -18
- package/scripts/rules/poll-loop.ts +78 -8
- package/scripts/rules/pr-merge.ts +123 -0
- package/scripts/rules/pre-gate-cut.ts +3 -3
- package/scripts/rules/protected-files.ts +113 -22
- package/scripts/rules/raw-field-body.ts +6 -0
- package/scripts/rules/reply-language.ts +3 -17
- package/scripts/rules/reply-prose.ts +34 -0
- package/scripts/rules/repo-admin.ts +132 -0
- package/scripts/rules/reviewer-foreground.ts +88 -0
- package/scripts/rules/round-one-check-related.ts +120 -0
- package/scripts/rules/rule-body-guard.ts +13 -15
- package/scripts/rules/rule-list.ts +9 -28
- package/scripts/rules/rule-value-cache.ts +57 -14
- package/scripts/rules/rule-value-candidates.ts +84 -0
- package/scripts/rules/rule-value-cli.ts +106 -39
- package/scripts/rules/rule-value.ts +18 -5
- package/scripts/rules/run-tail-rule.ts +1 -1
- package/scripts/rules/sed-in-place.ts +196 -0
- package/scripts/rules/shell-segments.ts +43 -0
- package/scripts/rules/stop-rule-rows.ts +52 -0
- package/scripts/rules/stop-rules.ts +36 -62
- package/scripts/rules/test-declared-commit.ts +11 -1
- package/scripts/rules/third-party-write.ts +115 -21
- package/scripts/rules/timed-rerun.ts +69 -0
- package/scripts/rules/turn-filings.ts +90 -0
- package/scripts/rules/worktree-guard.ts +32 -7
- package/scripts/run/board/run-board-app-name.ts +23 -0
- package/scripts/run/board/run-board-cli.ts +65 -32
- package/scripts/run/board/run-board-earlier.ts +94 -0
- package/scripts/run/board/run-board-ending-reason.ts +71 -0
- package/scripts/run/board/run-board-estimate-schedule.ts +103 -0
- package/scripts/run/board/run-board-estimate.ts +98 -0
- package/scripts/run/board/run-board-fit.ts +177 -37
- package/scripts/run/board/run-board-fold.ts +123 -0
- package/scripts/run/board/run-board-found.ts +134 -0
- package/scripts/run/board/run-board-fresh.ts +2 -2
- package/scripts/run/board/run-board-gather-live.ts +29 -0
- package/scripts/run/board/run-board-gather-thread.ts +189 -0
- package/scripts/run/board/run-board-gather-worker.ts +29 -0
- package/scripts/run/board/run-board-gather.ts +187 -0
- package/scripts/run/board/run-board-github.ts +118 -38
- package/scripts/run/board/run-board-header.ts +90 -20
- package/scripts/run/board/run-board-keys.ts +58 -0
- package/scripts/run/board/run-board-kind.ts +20 -6
- package/scripts/run/board/run-board-labels.ts +126 -71
- package/scripts/run/board/run-board-lane-state.ts +109 -0
- package/scripts/run/board/run-board-lane-time.ts +123 -0
- package/scripts/run/board/run-board-layout.ts +239 -60
- package/scripts/run/board/run-board-length.ts +52 -0
- package/scripts/run/board/run-board-link.ts +15 -2
- package/scripts/run/board/run-board-machine.ts +8 -4
- package/scripts/run/board/run-board-main.ts +12 -0
- package/scripts/run/board/run-board-notes.ts +59 -32
- package/scripts/run/board/run-board-now.ts +1 -1
- package/scripts/run/board/run-board-operation.ts +19 -35
- package/scripts/run/board/run-board-phase.ts +3 -6
- package/scripts/run/board/run-board-plan-shared.ts +115 -0
- package/scripts/run/board/run-board-plan.ts +56 -4
- package/scripts/run/board/run-board-planning.ts +45 -0
- package/scripts/run/board/run-board-priority.ts +44 -0
- package/scripts/run/board/run-board-process-groups.ts +195 -0
- package/scripts/run/board/run-board-read.ts +197 -28
- package/scripts/run/board/run-board-reason.ts +247 -51
- package/scripts/run/board/run-board-released.ts +35 -0
- package/scripts/run/board/run-board-render-checks.ts +42 -7
- package/scripts/run/board/run-board-render-condition.ts +96 -0
- package/scripts/run/board/run-board-render-drawn.ts +78 -0
- package/scripts/run/board/run-board-render-foot.ts +59 -0
- package/scripts/run/board/run-board-render-found.ts +157 -0
- package/scripts/run/board/run-board-render-icon.ts +35 -0
- package/scripts/run/board/run-board-render-lanes.ts +145 -0
- package/scripts/run/board/run-board-render-lead.ts +89 -0
- package/scripts/run/board/run-board-render-legend.ts +136 -48
- package/scripts/run/board/run-board-render-notes.ts +156 -29
- package/scripts/run/board/run-board-render-processes.ts +196 -0
- package/scripts/run/board/run-board-render-section.ts +119 -0
- package/scripts/run/board/run-board-render-slot.ts +3 -36
- package/scripts/run/board/run-board-render-tail.ts +115 -48
- package/scripts/run/board/run-board-render-time.ts +56 -0
- package/scripts/run/board/run-board-render-title.ts +117 -24
- package/scripts/run/board/run-board-render-waits.ts +104 -20
- package/scripts/run/board/run-board-render.ts +264 -258
- package/scripts/run/board/run-board-roots.ts +54 -0
- package/scripts/run/board/run-board-row-yield.ts +9 -4
- package/scripts/run/board/run-board-setup.ts +1 -12
- package/scripts/run/board/run-board-snapshot.ts +111 -0
- package/scripts/run/board/run-board-spin.ts +3 -5
- package/scripts/run/board/run-board-state.ts +22 -33
- package/scripts/run/board/run-board-status.ts +149 -71
- package/scripts/run/board/run-board-thanks-read.ts +2 -2
- package/scripts/run/board/run-board-tick.ts +158 -114
- package/scripts/run/board/run-board-usage-board.ts +78 -0
- package/scripts/run/board/run-board-usage-lanes.ts +113 -0
- package/scripts/run/board/run-board-usage-listing.ts +93 -0
- package/scripts/run/board/run-board-usage-read.ts +120 -150
- package/scripts/run/board/run-board-usage-rusage.ts +19 -7
- package/scripts/run/board/run-board-usage-text.ts +139 -51
- package/scripts/run/board/run-board-usage-top.ts +102 -0
- package/scripts/run/board/run-board-usage.ts +89 -72
- package/scripts/run/board/run-board-usual.ts +20 -9
- package/scripts/run/carry/run-carry-args.ts +4 -7
- package/scripts/run/carry/run-carry-conversation.ts +1 -1
- package/scripts/run/carry/run-carry-ended.ts +3 -2
- package/scripts/run/carry/run-carry.ts +12 -6
- package/scripts/run/cut/run-cut-cli.ts +33 -133
- package/scripts/run/cut/run-cut-digest.ts +152 -0
- package/scripts/run/cut/run-cut-handoff.ts +54 -10
- package/scripts/run/cut/run-cut-report.ts +24 -3
- package/scripts/run/cut/run-cut-resume.ts +129 -0
- package/scripts/run/cut/run-cut-review.ts +105 -0
- package/scripts/run/cut/run-cut.ts +18 -7
- package/scripts/run/detached-launch.ts +1 -1
- package/scripts/run/entry/run-entry-cli.ts +88 -19
- package/scripts/run/entry/run-entry-spill.ts +83 -0
- package/scripts/run/entry/run-entry-stop.ts +5 -1
- package/scripts/run/entry/run-entry-trust.ts +91 -0
- package/scripts/run/event/run-event-baseline.ts +56 -0
- package/scripts/run/event/run-event-cli.ts +1 -5
- package/scripts/run/event/run-event-filed.ts +18 -6
- package/scripts/run/event/run-event-follow.ts +2 -3
- package/scripts/run/event/run-event-overrun.ts +197 -0
- package/scripts/run/event/run-event-render.ts +10 -10
- package/scripts/run/event/run-event-scope.ts +2 -2
- package/scripts/run/event/run-event-stream-emit.ts +82 -22
- package/scripts/run/event/run-event-stream.ts +58 -10
- package/scripts/run/hold/run-hold-adopt.ts +65 -0
- package/scripts/run/hold/run-hold-cli.ts +93 -22
- package/scripts/run/hold/run-hold-main.ts +12 -0
- package/scripts/run/hold/run-hold-member.ts +37 -0
- package/scripts/run/hold/run-stop-notify.ts +178 -0
- package/scripts/run/merge/run-merge-auth.ts +31 -0
- package/scripts/run/merge/run-merge-cap.ts +57 -0
- package/scripts/run/merge/run-merge-cli.ts +119 -62
- package/scripts/run/merge/run-merge-close.ts +74 -0
- package/scripts/run/merge/run-merge-collect.ts +6 -13
- package/scripts/run/merge/run-merge-driver.ts +71 -0
- package/scripts/run/merge/run-merge-main.ts +12 -0
- package/scripts/run/merge/run-merge-outcome.ts +25 -0
- package/scripts/run/merge/run-merge-restart.ts +39 -0
- package/scripts/run/merge/run-merge-ship.ts +33 -7
- package/scripts/run/merge/run-merge-signals.ts +66 -25
- package/scripts/run/merge/run-merge-steps.ts +162 -107
- package/scripts/run/merge/run-merge-usage-limit.ts +53 -0
- package/scripts/run/merge/run-merge-withdrawn.ts +53 -0
- package/scripts/run/merge/run-merge.ts +76 -48
- package/scripts/run/park/run-park-cli.ts +91 -0
- package/scripts/run/park/run-park.ts +88 -0
- package/scripts/run/park/run-stalled.ts +68 -0
- package/scripts/run/pause/run-pause-cli.ts +73 -0
- package/scripts/run/pause/run-pause.ts +251 -0
- package/scripts/run/progress/run-progress-cli.ts +4 -12
- package/scripts/run/progress/run-progress-clock.ts +1 -1
- package/scripts/run/progress/run-progress-config.ts +6 -14
- package/scripts/run/progress/run-progress-main.ts +12 -0
- package/scripts/run/progress/run-progress.ts +1 -4
- package/scripts/run/review/run-review-cli.ts +306 -20
- package/scripts/run/review/run-review-early-push.ts +121 -0
- package/scripts/run/review/run-review-join-read.ts +94 -0
- package/scripts/run/review/run-review-pinned-accepted.ts +126 -0
- package/scripts/run/review/run-review-pinned-join.ts +216 -0
- package/scripts/run/review/run-review-pinned-steps.ts +383 -0
- package/scripts/run/review/run-review-pinned-tree.ts +37 -0
- package/scripts/run/review/run-review-pinned.ts +53 -0
- package/scripts/run/review/run-review-steps.ts +70 -34
- package/scripts/run/review/run-review.ts +28 -7
- package/scripts/run/run-ending.ts +1 -0
- package/scripts/run/run-invocation.ts +5 -6
- package/scripts/run/run-liveness-cli.ts +6 -8
- package/scripts/run/run-liveness.ts +60 -29
- package/scripts/run/run-next.ts +1 -1
- package/scripts/run/run-parent-cut-hook.ts +3 -4
- package/scripts/run/run-preflight.ts +18 -3
- package/scripts/run/run-prep-cli.ts +1 -10
- package/scripts/run/run-prep-locate.ts +7 -50
- package/scripts/run/run-prep-main.ts +12 -0
- package/scripts/run/run-prep.ts +7 -0
- package/scripts/run/run-report-cli.ts +101 -13
- package/scripts/run/run-report-handoff.ts +114 -0
- package/scripts/run/run-stage-read.ts +2 -6
- package/scripts/run/run-step-cli.ts +17 -5
- package/scripts/run/run-step-lane-plan.ts +27 -0
- package/scripts/run/run-step-section.ts +26 -7
- package/scripts/run/run-step.ts +6 -3
- package/scripts/run/run-stranded-detect.ts +13 -0
- package/scripts/run/run-watcher-guard-cli.ts +1 -1
- package/scripts/run/run-watcher-guard.ts +1 -1
- package/scripts/run/ship/run-ship-args.ts +140 -0
- package/scripts/run/ship/run-ship-body-draft.ts +110 -0
- package/scripts/run/ship/run-ship-brokered-review.ts +106 -0
- package/scripts/run/ship/run-ship-cli.ts +181 -166
- package/scripts/run/ship/run-ship-conflict-probe.ts +59 -0
- package/scripts/run/ship/run-ship-detach.ts +29 -12
- package/scripts/run/ship/run-ship-handover.ts +106 -0
- package/scripts/run/ship/run-ship-infra-retry.ts +74 -0
- package/scripts/run/ship/run-ship-lap.ts +63 -0
- package/scripts/run/ship/run-ship-next.ts +44 -27
- package/scripts/run/ship/run-ship-overlap.ts +49 -7
- package/scripts/run/ship/run-ship-place.ts +103 -0
- package/scripts/run/ship/run-ship-planned.ts +92 -0
- package/scripts/run/ship/run-ship-pre-detach-pinned.ts +197 -0
- package/scripts/run/ship/run-ship-pre-detach-timed.ts +42 -0
- package/scripts/run/ship/run-ship-pre-detach.ts +144 -33
- package/scripts/run/ship/run-ship-preflight.ts +150 -33
- package/scripts/run/ship/run-ship-probe.ts +28 -6
- package/scripts/run/ship/run-ship-relaunch-cap.ts +106 -0
- package/scripts/run/ship/run-ship-relaunch.ts +51 -0
- package/scripts/run/ship/run-ship-removed-rows.ts +61 -0
- package/scripts/run/ship/run-ship-return.ts +183 -25
- package/scripts/run/ship/run-ship-review-reason.ts +24 -0
- package/scripts/run/ship/run-ship-review-steps.ts +296 -171
- package/scripts/run/ship/run-ship-review.ts +222 -35
- package/scripts/run/ship/run-ship-reviewer.ts +303 -0
- package/scripts/run/ship/run-ship-scoped.ts +39 -10
- package/scripts/run/ship/run-ship-stage.ts +101 -16
- package/scripts/run/ship/run-ship-steps.ts +68 -17
- package/scripts/run/ship/run-ship-stop-cause.ts +176 -0
- package/scripts/run/ship/run-ship-stop-context.ts +50 -13
- package/scripts/run/ship/run-ship-stop-text.ts +11 -6
- package/scripts/run/ship/run-ship-sync.ts +212 -34
- package/scripts/run/ship/run-ship-synced-scope.ts +178 -0
- package/scripts/run/ship/run-ship-wait-cli.ts +145 -0
- package/scripts/run/ship/run-ship-waiter.ts +114 -0
- package/scripts/run/ship/run-ship.ts +44 -2
- package/scripts/run/tidy/run-tidy-cli.ts +0 -4
- package/scripts/run/tidy/run-tidy-lanes.ts +3 -0
- package/scripts/run/tidy/run-tidy-main.ts +8 -0
- package/scripts/run/wake/run-wake-caffeinate.ts +48 -0
- package/scripts/run/wake/run-wake-cli.ts +121 -209
- package/scripts/run/wake/run-wake-code.ts +125 -0
- package/scripts/run/wake/run-wake-driver.ts +22 -9
- package/scripts/run/wake/run-wake-finish.ts +137 -0
- package/scripts/run/wake/run-wake-loop.ts +36 -3
- package/scripts/run/wake/run-wake-main.ts +13 -0
- package/scripts/run/wake/run-wake-ports.ts +98 -0
- package/scripts/run/wake/run-wake-session.ts +2 -0
- package/scripts/run/wake/run-wake-takeover.ts +66 -0
- package/scripts/run/wake/run-wake.ts +5 -3
- package/scripts/safe-chain/ci-installer-pin.ts +49 -8
- package/scripts/safe-chain/pack-hook.ts +2 -2
- package/scripts/safe-chain/preinstall-command.ts +2 -1
- package/scripts/safe-chain/project-config.ts +6 -11
- package/scripts/security/secretlint-scan.ts +42 -9
- package/scripts/security/security-audit-main.ts +8 -0
- package/scripts/security/security-audit-provision-logic.ts +0 -11
- package/scripts/security/security-audit-provision-main.ts +20 -0
- package/scripts/security/security-audit-provision.ts +12 -27
- package/scripts/security/security-audit.ts +27 -8
- package/scripts/security/sonar-file.ts +10 -5
- package/scripts/self-sync-guard/self-sync-guard-logic.ts +6 -13
- package/scripts/split/split-assess-cli.ts +2 -2
- package/scripts/split/split-assess.ts +25 -1
- package/scripts/split/split-early-notice.ts +116 -0
- package/scripts/split/split-measure.ts +83 -0
- package/scripts/split/split-resolution.ts +107 -0
- package/scripts/sync/claude-settings-merge.ts +8 -15
- package/scripts/sync/directory-copy-guard.ts +4 -9
- package/scripts/sync/file-content.ts +78 -8
- package/scripts/sync/sync-ai-files.ts +3 -5
- package/scripts/sync/sync-configs.ts +11 -23
- package/scripts/sync/sync-hook-safety.ts +4 -10
- package/scripts/sync/sync-main.ts +11 -0
- package/scripts/sync/sync.ts +25 -37
- package/scripts/test/direct-importers.ts +185 -0
- package/scripts/test/pure-files-entries.ts +83 -0
- package/scripts/test/related-heavy-tests.ts +81 -0
- package/scripts/test/test-declared-changed.ts +2 -2
- package/scripts/test/test-declared.ts +1 -1
- package/scripts/test/test-e2e-guard.ts +25 -1
- package/scripts/test/test-e2e-stamp.ts +38 -0
- package/scripts/test/test-no-base.ts +88 -0
- package/scripts/test/test-pinned-cache-logic.ts +363 -0
- package/scripts/test/test-pinned-cache.ts +337 -0
- package/scripts/test/test-pinned-emit.ts +49 -0
- package/scripts/test/test-pinned-functions.ts +116 -0
- package/scripts/test/test-pinned-ledger.ts +80 -0
- package/scripts/test/test-pinned-logic.ts +333 -0
- package/scripts/test/test-pinned-main.ts +144 -0
- package/scripts/test/test-pinned-pool.ts +73 -0
- package/scripts/test/test-pinned-probe.ts +254 -0
- package/scripts/test/test-pinned-prune-logic.ts +118 -0
- package/scripts/test/test-pinned-reach.ts +194 -0
- package/scripts/test/test-pinned-record.ts +196 -0
- package/scripts/test/test-pinned-rewire.ts +148 -0
- package/scripts/test/test-pinned-spawn.ts +81 -0
- package/scripts/test/test-pinned-stage.ts +70 -0
- package/scripts/test/test-pinned.ts +311 -0
- package/scripts/test/test-reach-cli.ts +61 -0
- package/scripts/test/test-read-map.ts +288 -0
- package/scripts/test/test-read-recording.ts +103 -0
- package/scripts/test/test-read-trace.ts +166 -0
- package/scripts/test/test-red-logic.ts +46 -7
- package/scripts/test/test-red-main.ts +12 -0
- package/scripts/test/test-red.ts +39 -37
- package/scripts/test/test-related-claim.ts +37 -0
- package/scripts/test/test-related-main.ts +21 -0
- package/scripts/test/test-related-moved.ts +91 -0
- package/scripts/test/test-related-record.ts +139 -0
- package/scripts/test/test-related-scope.ts +292 -41
- package/scripts/test/test-related-synced.ts +135 -0
- package/scripts/test/test-related-touched.ts +84 -0
- package/scripts/test/test-related.ts +381 -19
- package/scripts/test/test-unit-guard-main.ts +15 -0
- package/scripts/test/test-unit-guard.ts +66 -25
- package/scripts/test/unit-count-file.ts +37 -0
- package/scripts/test/unit-durations.ts +41 -0
- package/scripts/test/unit-run-marker.ts +162 -0
- package/scripts/test/unit-setup-files.ts +51 -0
- package/scripts/test/unit-worker-share.ts +64 -151
- package/scripts/test/vitest-cache-directory.ts +19 -0
- package/scripts/test/vitest-cli-excludes.ts +14 -0
- package/scripts/test/vitest-failure-summary.ts +111 -0
- package/scripts/test/whole-suite-files.ts +74 -0
- package/scripts/time-runtime/time-background.ts +20 -2
- package/scripts/time-runtime/time-batch-guard.ts +42 -4
- package/scripts/time-runtime/time-bundle-call.ts +1 -1
- package/scripts/time-runtime/time-bundles.ts +40 -8
- package/scripts/time-runtime/time-density-hook.ts +8 -6
- package/scripts/time-runtime/time-followup-stage.ts +1 -3
- package/scripts/time-runtime/time-format.ts +5 -28
- package/scripts/time-runtime/time-markers.ts +12 -3
- package/scripts/time-runtime/time-search-call.ts +38 -0
- package/scripts/time-runtime/time-shell.ts +98 -11
- package/scripts/time-runtime/time-transcript-line.ts +65 -66
- package/scripts/uninstall/uninstall.ts +1 -1
- package/scripts/version/bump-version-main.ts +12 -0
- package/scripts/version/bump-version.ts +25 -25
- package/scripts/version/development-engines-verdict.ts +124 -0
- package/scripts/version/effective-upstream.ts +6 -12
- package/scripts/version/latest-corepack.ts +19 -32
- package/scripts/version/latest-if-required-cli.ts +93 -0
- package/scripts/version/latest-lane-guard-main.ts +8 -0
- package/scripts/version/latest-lane-guard.ts +0 -4
- package/scripts/version/latest-scope-cli.ts +0 -9
- package/scripts/version/latest-scope-main.ts +12 -0
- package/scripts/version/latest-update.ts +5 -5
- package/scripts/version/npm-registry.ts +44 -6
- package/scripts/version/publishable-range-check.ts +5 -16
- package/scripts/version/release-age.ts +1 -1
- package/scripts/version/release-hold.ts +1 -1
- package/scripts/version/release-window.ts +38 -0
- package/scripts/version/running-binary.ts +1 -1
- package/scripts/version/safe-chain-version-update.ts +3 -8
- package/scripts/version/version-targets.ts +6 -28
- package/templates/dependabot.yml +29 -0
- package/templates/gitignore +6 -1
- package/templates/pnpm-workspace.basic.yaml +1 -1
- package/templates/sonar-project.properties +3 -2
- package/templates/workflows/ci.yml +53 -4
- package/templates/workflows/github-release.yml +4 -0
- package/tsconfig.sonar.json +1 -1
- package/.ncurc.json +0 -3
- package/dist/hooks/batch-guard.js +0 -29
- package/dist/hooks/chunk-4KKD2UTK.js +0 -66
- package/dist/hooks/chunk-6TS2JD6D.js +0 -237
- package/dist/hooks/chunk-7DSBJVFH.js +0 -50
- package/dist/hooks/chunk-A65Y4YOR.js +0 -79
- package/dist/hooks/chunk-APUO6U4J.js +0 -2451
- package/dist/hooks/chunk-CDY4NFQG.js +0 -15
- package/dist/hooks/chunk-DGT54IH5.js +0 -161
- package/dist/hooks/chunk-EFXE6C37.js +0 -81
- package/dist/hooks/chunk-GP4IEC4O.js +0 -20
- package/dist/hooks/chunk-JP45SOCJ.js +0 -56
- package/dist/hooks/chunk-LAOV7NLM.js +0 -45
- package/dist/hooks/chunk-M4HGZV7U.js +0 -83
- package/dist/hooks/chunk-O6GDRNJB.js +0 -343
- package/dist/hooks/chunk-PF2NZL2A.js +0 -131
- package/dist/hooks/chunk-PTICX4OL.js +0 -358
- package/dist/hooks/chunk-RT27QRJW.js +0 -6247
- package/dist/hooks/chunk-SYOTDYCI.js +0 -3533
- package/dist/hooks/chunk-TNUMY6NL.js +0 -4838
- package/dist/hooks/chunk-UPUZF3AN.js +0 -279
- package/dist/hooks/chunk-WK6SMBIC.js +0 -3180
- package/dist/hooks/duplicate-read-guard.js +0 -30
- package/dist/hooks/investigation-guard.js +0 -29
- package/scripts/backlog/backlog-stalled-cli.ts +0 -30
- package/scripts/cost-runtime/context-cut-threshold.ts +0 -11
- package/scripts/cost-runtime/cost-format.ts +0 -29
- package/scripts/init/basic-path-migration.ts +0 -24
- package/scripts/issue/issue-backlinks-cli.ts +0 -93
- package/scripts/josh/josh-commands-guard.ts +0 -38
- package/scripts/josh/josh-usage-automation.ts +0 -121
- package/scripts/josh/josh-usage-backlog.ts +0 -180
- package/scripts/josh/josh-usage-developer.ts +0 -230
- package/scripts/josh/josh-usage-hooks.ts +0 -38
- package/scripts/josh/josh-usage-issue.ts +0 -205
- package/scripts/josh/josh-usage-review.ts +0 -101
- package/scripts/josh/josh-usage-run.ts +0 -252
- package/scripts/josh/josh-usage-session.ts +0 -238
- package/scripts/josh/josh-usage-workflow.ts +0 -212
- package/scripts/lint/cross-file-recheck.ts +0 -155
- package/scripts/registry-migration/migrate-logic.ts +0 -237
- package/scripts/registry-migration/migrate.ts +0 -292
- package/scripts/registry-migration/user-npmrc.ts +0 -15
- package/scripts/rules/filing-cap.ts +0 -132
- package/scripts/rules/rule-guard.ts +0 -23
- package/scripts/rules/rule-registry-rows.ts +0 -292
- package/scripts/rules/rule-registry.ts +0 -112
- package/scripts/run/run-stranded-cli.ts +0 -27
|
@@ -0,0 +1,1927 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
|
|
3
|
+
// scripts/document/read-set-cli.ts
|
|
4
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
5
|
+
|
|
6
|
+
// scripts/agent/lane-instructions.ts
|
|
7
|
+
import path6 from "node:path";
|
|
8
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
9
|
+
|
|
10
|
+
// scripts/cost-runtime/cost-tokens.ts
|
|
11
|
+
var ASCII_CHARS_PER_TOKEN = 3;
|
|
12
|
+
var WIDE_TOKENS_PER_CHAR = 1;
|
|
13
|
+
var ASCII_LIMIT = 128;
|
|
14
|
+
function count_chars(text) {
|
|
15
|
+
let ascii_chars = 0;
|
|
16
|
+
let wide_chars = 0;
|
|
17
|
+
for (const char of text) {
|
|
18
|
+
if ((char.codePointAt(0) ?? 0) < ASCII_LIMIT) ascii_chars += 1;
|
|
19
|
+
else wide_chars += 1;
|
|
20
|
+
}
|
|
21
|
+
return { ascii_chars, wide_chars };
|
|
22
|
+
}
|
|
23
|
+
function estimate(text) {
|
|
24
|
+
const { ascii_chars, wide_chars } = count_chars(text);
|
|
25
|
+
return Math.round(ascii_chars / ASCII_CHARS_PER_TOKEN) + wide_chars * WIDE_TOKENS_PER_CHAR;
|
|
26
|
+
}
|
|
27
|
+
function ascii_bytes_to_tokens(bytes) {
|
|
28
|
+
return Math.round(bytes / ASCII_CHARS_PER_TOKEN);
|
|
29
|
+
}
|
|
30
|
+
var cost_tokens = {
|
|
31
|
+
ASCII_CHARS_PER_TOKEN,
|
|
32
|
+
count_chars,
|
|
33
|
+
estimate,
|
|
34
|
+
ascii_bytes_to_tokens
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// scripts/lib/read-file.ts
|
|
38
|
+
import { readFileSync } from "node:fs";
|
|
39
|
+
var ABSENT_CODE = "ENOENT";
|
|
40
|
+
function is_absent(error) {
|
|
41
|
+
return error instanceof Error && "code" in error && error.code === ABSENT_CODE;
|
|
42
|
+
}
|
|
43
|
+
function read_optional(path9) {
|
|
44
|
+
try {
|
|
45
|
+
return readFileSync(path9, "utf8");
|
|
46
|
+
} catch (error) {
|
|
47
|
+
if (is_absent(error)) return void 0;
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function read_file_or_empty(path9) {
|
|
52
|
+
return read_optional(path9) ?? "";
|
|
53
|
+
}
|
|
54
|
+
function read_if_readable(path9) {
|
|
55
|
+
try {
|
|
56
|
+
return readFileSync(path9, "utf8");
|
|
57
|
+
} catch {
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
var file_reader = { is_absent, read_optional, read_file_or_empty, read_if_readable };
|
|
62
|
+
|
|
63
|
+
// scripts/document/document-scan.ts
|
|
64
|
+
var COMMAND_PATTERN = /`(?:pnpm )?josh ([a-z][a-z0-9:-]+)/gu;
|
|
65
|
+
var LABEL_PATTERN = /(?:labels\[\]=|\/labels\/|labels -f name=)([a-z][a-z0-9:_-]*)/gu;
|
|
66
|
+
var SECTION_PATTERN = /(?<![\w./:`-])(?<tick>`?)(?<file>[\w./-]+\.md)\k<tick>\s*→\s*(?:§\w+,\s*)?["「](?<heading>[^"」]+)["」]/gu;
|
|
67
|
+
var ADJACENT_PATTERN = /["「](?<heading>[^"「」]+)["」]\s+(?:above|below)\b/gu;
|
|
68
|
+
var BARE_ARROW_PATTERN = /→\s*(?:§\w+,\s*)?["「](?<heading>[^"「」]+)["」]/gu;
|
|
69
|
+
var LINK_TARGET_PATTERN = /\]\([^)\s]*\)/gu;
|
|
70
|
+
var LINK_PATTERN = /\]\(([\w./-]+\.(?:md|png|jpe?g|gif|svg|webp))(?:#[\w-]+)?\)/gu;
|
|
71
|
+
var PLACEHOLDER_FILES = /* @__PURE__ */ new Set(["x.md", "foo.md", "file.md", "path.md"]);
|
|
72
|
+
function matches(text, pattern) {
|
|
73
|
+
return [...text.matchAll(pattern)];
|
|
74
|
+
}
|
|
75
|
+
function command_references(text) {
|
|
76
|
+
return matches(text, COMMAND_PATTERN).map((match) => match[1] ?? "").filter((name) => !name.endsWith(":"));
|
|
77
|
+
}
|
|
78
|
+
function is_real_label(token) {
|
|
79
|
+
return token.length > 0 && !token.endsWith(":") && !token.includes("<");
|
|
80
|
+
}
|
|
81
|
+
function label_references(text) {
|
|
82
|
+
return matches(text, LABEL_PATTERN).map((match) => match[1] ?? "").filter((token) => is_real_label(token));
|
|
83
|
+
}
|
|
84
|
+
function base_name(path9) {
|
|
85
|
+
return path9.split("/").at(-1) ?? path9;
|
|
86
|
+
}
|
|
87
|
+
function is_placeholder_file(name) {
|
|
88
|
+
return name.includes("<") || PLACEHOLDER_FILES.has(base_name(name).toLowerCase());
|
|
89
|
+
}
|
|
90
|
+
function section_references(text) {
|
|
91
|
+
return matches(text.replaceAll(LINK_TARGET_PATTERN, ""), SECTION_PATTERN).map(({ groups }) => ({ file: groups?.["file"] ?? "", heading: groups?.["heading"] ?? "" })).filter((reference) => !is_placeholder_file(reference.file));
|
|
92
|
+
}
|
|
93
|
+
function headings_matching(text, pattern) {
|
|
94
|
+
return matches(text, pattern).map(({ groups }) => groups?.["heading"] ?? "");
|
|
95
|
+
}
|
|
96
|
+
function adjacent_references(text) {
|
|
97
|
+
return headings_matching(text, ADJACENT_PATTERN);
|
|
98
|
+
}
|
|
99
|
+
function bare_arrow_references(text) {
|
|
100
|
+
const unfiled = text.replaceAll(LINK_TARGET_PATTERN, "").replaceAll(SECTION_PATTERN, "");
|
|
101
|
+
return headings_matching(unfiled, BARE_ARROW_PATTERN);
|
|
102
|
+
}
|
|
103
|
+
function link_targets(text) {
|
|
104
|
+
return matches(text, LINK_PATTERN).map((match) => match[1] ?? "").filter((file) => !is_placeholder_file(file));
|
|
105
|
+
}
|
|
106
|
+
function normalize_reference(heading) {
|
|
107
|
+
return heading.replaceAll("`", "").split(/\s+/u).filter((word) => word !== ">").join(" ");
|
|
108
|
+
}
|
|
109
|
+
function reference_forms(title) {
|
|
110
|
+
const normalized = normalize_reference(title);
|
|
111
|
+
return [normalized, normalized.replace(/^\d+[a-z]?\. /u, "")];
|
|
112
|
+
}
|
|
113
|
+
var document_scan = {
|
|
114
|
+
adjacent_references,
|
|
115
|
+
bare_arrow_references,
|
|
116
|
+
command_references,
|
|
117
|
+
label_references,
|
|
118
|
+
link_targets,
|
|
119
|
+
normalize_reference,
|
|
120
|
+
reference_forms,
|
|
121
|
+
section_references
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// scripts/document/document-section.ts
|
|
125
|
+
var HEADING_PATTERN = /^(?<hashes>#{1,6}) (?<title>.*)$/u;
|
|
126
|
+
var FENCE = "```";
|
|
127
|
+
var SINGLE_MATCH = 1;
|
|
128
|
+
var BOLD_LABEL_PATTERN = /\*\*([^*]+?)\*\*/gu;
|
|
129
|
+
var BOLD_DELIMITER = "**";
|
|
130
|
+
var CODE_SPAN_PATTERN = /``[^\n]*?``|`[^`\n]*`/gu;
|
|
131
|
+
var LABEL_LEVEL = 7;
|
|
132
|
+
var LIST_ITEM_PATTERN = /^(?<indent>\s*)(?:[-*]|\d+\.) /u;
|
|
133
|
+
function to_heading(line, index) {
|
|
134
|
+
const groups = HEADING_PATTERN.exec(line)?.groups;
|
|
135
|
+
if (groups === void 0) return void 0;
|
|
136
|
+
const { hashes = "", title = "" } = groups;
|
|
137
|
+
return { level: hashes.length, title: title.trim(), line: index };
|
|
138
|
+
}
|
|
139
|
+
function push_heading(found, line, index) {
|
|
140
|
+
const heading = to_heading(line, index);
|
|
141
|
+
if (heading !== void 0) found.push(heading);
|
|
142
|
+
}
|
|
143
|
+
function fenced_flags(lines) {
|
|
144
|
+
let is_inside_fence = false;
|
|
145
|
+
return lines.map(function is_fenced(line) {
|
|
146
|
+
if (!line.startsWith(FENCE)) return is_inside_fence;
|
|
147
|
+
is_inside_fence = !is_inside_fence;
|
|
148
|
+
return true;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function headings(markdown) {
|
|
152
|
+
const lines = markdown.split("\n");
|
|
153
|
+
const fenced = fenced_flags(lines);
|
|
154
|
+
const found = [];
|
|
155
|
+
for (const [index, line] of lines.entries()) {
|
|
156
|
+
if (fenced[index] !== true) push_heading(found, line, index);
|
|
157
|
+
}
|
|
158
|
+
return found;
|
|
159
|
+
}
|
|
160
|
+
function titles(markdown) {
|
|
161
|
+
return headings(markdown).map((heading) => heading.title);
|
|
162
|
+
}
|
|
163
|
+
function line_starts(markdown) {
|
|
164
|
+
return [...markdown.matchAll(/\n/gu)].map((match) => match.index + SINGLE_MATCH);
|
|
165
|
+
}
|
|
166
|
+
function line_of(starts, offset) {
|
|
167
|
+
return starts.filter((start) => start <= offset).length;
|
|
168
|
+
}
|
|
169
|
+
function unfenced_text(markdown) {
|
|
170
|
+
const lines = markdown.split("\n");
|
|
171
|
+
const fenced = fenced_flags(lines);
|
|
172
|
+
return lines.map((line, index) => fenced[index] === true ? "" : line).join("\n");
|
|
173
|
+
}
|
|
174
|
+
function code_masked(text) {
|
|
175
|
+
return text.replaceAll(CODE_SPAN_PATTERN, (span) => span.replaceAll("*", " "));
|
|
176
|
+
}
|
|
177
|
+
function labels(markdown) {
|
|
178
|
+
const text = unfenced_text(markdown);
|
|
179
|
+
const starts = line_starts(text);
|
|
180
|
+
return [...code_masked(text).matchAll(BOLD_LABEL_PATTERN)].map((match) => ({
|
|
181
|
+
level: LABEL_LEVEL,
|
|
182
|
+
title: text.slice(
|
|
183
|
+
match.index + BOLD_DELIMITER.length,
|
|
184
|
+
match.index + match[0].length - BOLD_DELIMITER.length
|
|
185
|
+
),
|
|
186
|
+
line: line_of(starts, match.index)
|
|
187
|
+
}));
|
|
188
|
+
}
|
|
189
|
+
function is_match(heading, wanted) {
|
|
190
|
+
return document_scan.reference_forms(heading.title).some((form) => form.startsWith(wanted));
|
|
191
|
+
}
|
|
192
|
+
function prefixed(found, wanted) {
|
|
193
|
+
const normalized = document_scan.normalize_reference(wanted);
|
|
194
|
+
return found.filter((heading) => is_match(heading, normalized));
|
|
195
|
+
}
|
|
196
|
+
function is_exact(heading, wanted) {
|
|
197
|
+
return document_scan.reference_forms(heading.title).includes(wanted);
|
|
198
|
+
}
|
|
199
|
+
function select(found, wanted) {
|
|
200
|
+
const normalized = document_scan.normalize_reference(wanted);
|
|
201
|
+
const exact = found.find((heading) => is_exact(heading, normalized));
|
|
202
|
+
if (exact !== void 0) return exact;
|
|
203
|
+
const near = prefixed(found, wanted);
|
|
204
|
+
return near.length === SINGLE_MATCH ? near[0] : void 0;
|
|
205
|
+
}
|
|
206
|
+
function last_line_of(found, chosen, total_lines2) {
|
|
207
|
+
const next = found.find((heading) => heading.line > chosen.line && heading.level <= chosen.level);
|
|
208
|
+
return (next === void 0 ? total_lines2 : next.line) - SINGLE_MATCH;
|
|
209
|
+
}
|
|
210
|
+
function indent_of(line) {
|
|
211
|
+
return line.length - line.trimStart().length;
|
|
212
|
+
}
|
|
213
|
+
function is_sibling_item(line, depth) {
|
|
214
|
+
const { indent } = LIST_ITEM_PATTERN.exec(line)?.groups ?? {};
|
|
215
|
+
return indent !== void 0 && indent.length <= depth;
|
|
216
|
+
}
|
|
217
|
+
function ends_block(line, depth) {
|
|
218
|
+
if (line.trim() === "" || HEADING_PATTERN.test(line)) return true;
|
|
219
|
+
return is_sibling_item(line, depth);
|
|
220
|
+
}
|
|
221
|
+
function label_last_line(lines, label) {
|
|
222
|
+
const depth = indent_of(lines[label.line] ?? "");
|
|
223
|
+
const end = lines.findIndex((line, index) => index > label.line && ends_block(line, depth));
|
|
224
|
+
return (end === -1 ? lines.length : end) - SINGLE_MATCH;
|
|
225
|
+
}
|
|
226
|
+
function choose(markdown, wanted) {
|
|
227
|
+
const found = headings(markdown);
|
|
228
|
+
if (prefixed(found, wanted).length > 0) return select(found, wanted);
|
|
229
|
+
return select(labels(markdown), wanted);
|
|
230
|
+
}
|
|
231
|
+
function extent_of(markdown, chosen) {
|
|
232
|
+
const lines = markdown.split("\n");
|
|
233
|
+
if (chosen.level === LABEL_LEVEL) return label_last_line(lines, chosen);
|
|
234
|
+
return last_line_of(headings(markdown), chosen, lines.length);
|
|
235
|
+
}
|
|
236
|
+
function section(markdown, wanted) {
|
|
237
|
+
const chosen = choose(markdown, wanted);
|
|
238
|
+
if (chosen === void 0) return void 0;
|
|
239
|
+
const last_line = extent_of(markdown, chosen);
|
|
240
|
+
const lines = markdown.split("\n").slice(chosen.line, last_line + SINGLE_MATCH);
|
|
241
|
+
return {
|
|
242
|
+
title: chosen.title,
|
|
243
|
+
level: chosen.level,
|
|
244
|
+
first_line: chosen.line,
|
|
245
|
+
last_line,
|
|
246
|
+
text: lines.join("\n")
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
function candidates(markdown, wanted) {
|
|
250
|
+
const near = prefixed(headings(markdown), wanted);
|
|
251
|
+
const listed = near.length > 0 ? near : prefixed(labels(markdown), wanted);
|
|
252
|
+
return listed.map((heading) => heading.title);
|
|
253
|
+
}
|
|
254
|
+
function read_optional2(file_path) {
|
|
255
|
+
return file_reader.read_if_readable(file_path);
|
|
256
|
+
}
|
|
257
|
+
var document_section = {
|
|
258
|
+
candidates,
|
|
259
|
+
fenced_flags,
|
|
260
|
+
headings,
|
|
261
|
+
read_optional: read_optional2,
|
|
262
|
+
section,
|
|
263
|
+
titles
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
// scripts/init/distributed-paths.ts
|
|
267
|
+
var KIT_PACKAGE_PATH_PREFIX = "node_modules/@joshuafolkken/kit/";
|
|
268
|
+
var PROMPTS_PACKAGE_PREFIX = `${KIT_PACKAGE_PATH_PREFIX}prompts/`;
|
|
269
|
+
var ESLINT_PACKAGE_PREFIX = `${KIT_PACKAGE_PATH_PREFIX}eslint/`;
|
|
270
|
+
var GITHUB_REPO_BLOB_BASE = "https://github.com/joshuafolkken/kit/blob/main/";
|
|
271
|
+
var GITHUB_REPO_TREE_BASE = "https://github.com/joshuafolkken/kit/tree/main/";
|
|
272
|
+
var CLAUDE_MD_IMPORT_LINE = "@node_modules/@joshuafolkken/kit/dist/CLAUDE.md";
|
|
273
|
+
var OLD_CLAUDE_MD_BOOTSTRAP = "> Fresh checkout: if kit is not installed, run `pnpm install` first, then reread this file before doing any other work.";
|
|
274
|
+
var CLAUDE_MD_BOOTSTRAP = '> Fresh checkout: before `pnpm install`, run `pnpm config get "@joshuafolkken:registry"` from the project root to check the effective registry, including user-level settings. If it points to GitHub Packages, [set up authentication](https://github.com/joshuafolkken/kit/blob/main/docs/authentication.md#1-get-a-token-from-the-gh-cli) first. Then run `pnpm install` and reread this file before doing any other work.';
|
|
275
|
+
function transform_prompt_paths(content) {
|
|
276
|
+
return content.replaceAll(
|
|
277
|
+
/`prompts\/([^`*]+)`/gu,
|
|
278
|
+
(_match, prompt_path) => `\`${PROMPTS_PACKAGE_PREFIX}${prompt_path}\``
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
function transform_eslint_paths(content) {
|
|
282
|
+
return content.replaceAll(
|
|
283
|
+
/`eslint\/([^`*]+)`/gu,
|
|
284
|
+
(_match, eslint_path) => `\`${ESLINT_PACKAGE_PREFIX}${eslint_path}\``
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
function transform_test_file_paths(content) {
|
|
288
|
+
return content.replaceAll(
|
|
289
|
+
/`([^`*]+\.(?:test|spec)\.ts)`/gu,
|
|
290
|
+
(_match, test_path) => `\`${GITHUB_REPO_BLOB_BASE}${test_path}\``
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
function github_url_base(reference_path) {
|
|
294
|
+
return reference_path.endsWith("/") ? GITHUB_REPO_TREE_BASE : GITHUB_REPO_BLOB_BASE;
|
|
295
|
+
}
|
|
296
|
+
function transform_documentation_paths(content) {
|
|
297
|
+
return content.replaceAll(
|
|
298
|
+
/`(docs\/[^`*]*)`/gu,
|
|
299
|
+
(_match, documentation_path) => `\`${github_url_base(documentation_path)}${documentation_path}\``
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
function transform_distributed_paths(content) {
|
|
303
|
+
const with_prompts = transform_prompt_paths(content);
|
|
304
|
+
const with_eslint = transform_eslint_paths(with_prompts);
|
|
305
|
+
const with_tests = transform_test_file_paths(with_eslint);
|
|
306
|
+
return transform_documentation_paths(with_tests);
|
|
307
|
+
}
|
|
308
|
+
function ensure_claude_md_import(existing) {
|
|
309
|
+
if (existing === void 0) return `${CLAUDE_MD_BOOTSTRAP}
|
|
310
|
+
|
|
311
|
+
${CLAUDE_MD_IMPORT_LINE}
|
|
312
|
+
`;
|
|
313
|
+
const updated = existing.replace(OLD_CLAUDE_MD_BOOTSTRAP, () => CLAUDE_MD_BOOTSTRAP);
|
|
314
|
+
if (updated.includes(CLAUDE_MD_IMPORT_LINE)) {
|
|
315
|
+
if (updated.includes(CLAUDE_MD_BOOTSTRAP)) return updated;
|
|
316
|
+
return `${CLAUDE_MD_BOOTSTRAP}
|
|
317
|
+
|
|
318
|
+
${updated}`;
|
|
319
|
+
}
|
|
320
|
+
return `${CLAUDE_MD_BOOTSTRAP}
|
|
321
|
+
|
|
322
|
+
${CLAUDE_MD_IMPORT_LINE}
|
|
323
|
+
|
|
324
|
+
${updated}`;
|
|
325
|
+
}
|
|
326
|
+
var FULL_CLAUDE_MD_LINES = /* @__PURE__ */ new Set([
|
|
327
|
+
CLAUDE_MD_BOOTSTRAP,
|
|
328
|
+
OLD_CLAUDE_MD_BOOTSTRAP,
|
|
329
|
+
CLAUDE_MD_IMPORT_LINE
|
|
330
|
+
]);
|
|
331
|
+
function remove_claude_md_import(content) {
|
|
332
|
+
const lines = content.split("\n");
|
|
333
|
+
return lines.filter((line, index) => {
|
|
334
|
+
if (FULL_CLAUDE_MD_LINES.has(line)) return false;
|
|
335
|
+
return line !== "" || !FULL_CLAUDE_MD_LINES.has(lines[index - 1] ?? "");
|
|
336
|
+
}).join("\n");
|
|
337
|
+
}
|
|
338
|
+
var distributed_paths = {
|
|
339
|
+
transform_prompt_paths,
|
|
340
|
+
transform_distributed_paths,
|
|
341
|
+
ensure_claude_md_import,
|
|
342
|
+
remove_claude_md_import,
|
|
343
|
+
CLAUDE_MD_IMPORT_LINE,
|
|
344
|
+
KIT_PACKAGE_PATH_PREFIX
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
// scripts/josh/package-directory.ts
|
|
348
|
+
import { existsSync } from "node:fs";
|
|
349
|
+
|
|
350
|
+
// scripts/lib/ancestor-directories.ts
|
|
351
|
+
import path from "node:path";
|
|
352
|
+
var MAX_DEPTH = 64;
|
|
353
|
+
function list(start_directory) {
|
|
354
|
+
const directories = [];
|
|
355
|
+
let current = path.resolve(start_directory);
|
|
356
|
+
while (directories.length < MAX_DEPTH && !directories.includes(current)) {
|
|
357
|
+
directories.push(current);
|
|
358
|
+
current = path.dirname(current);
|
|
359
|
+
}
|
|
360
|
+
return directories;
|
|
361
|
+
}
|
|
362
|
+
function nearest(start_directory, is_match2) {
|
|
363
|
+
return list(start_directory).find((directory) => is_match2(directory));
|
|
364
|
+
}
|
|
365
|
+
var ancestor_directories = { list, nearest };
|
|
366
|
+
|
|
367
|
+
// scripts/lib/package-manifest.ts
|
|
368
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
369
|
+
import path2 from "node:path";
|
|
370
|
+
|
|
371
|
+
// scripts/lib/json-value.ts
|
|
372
|
+
function parse_or_undefined(text) {
|
|
373
|
+
try {
|
|
374
|
+
return JSON.parse(text);
|
|
375
|
+
} catch {
|
|
376
|
+
return void 0;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
function parse_with(text, schema) {
|
|
380
|
+
const value = parse_or_undefined(text);
|
|
381
|
+
if (value === void 0) return void 0;
|
|
382
|
+
const parsed = schema.safeParse(value);
|
|
383
|
+
return parsed.success ? parsed.data : void 0;
|
|
384
|
+
}
|
|
385
|
+
function parse_array(text) {
|
|
386
|
+
const value = parse_or_undefined(text);
|
|
387
|
+
return Array.isArray(value) ? value : void 0;
|
|
388
|
+
}
|
|
389
|
+
function is_record(value) {
|
|
390
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
391
|
+
}
|
|
392
|
+
var json_value = { parse_or_undefined, parse_with, parse_array, is_record };
|
|
393
|
+
|
|
394
|
+
// scripts/lib/package-manifest.ts
|
|
395
|
+
var PACKAGE_JSON = "package.json";
|
|
396
|
+
function manifest_path(directory) {
|
|
397
|
+
return path2.join(directory, PACKAGE_JSON);
|
|
398
|
+
}
|
|
399
|
+
function read_manifest(directory, schema) {
|
|
400
|
+
const text = readFileSync2(manifest_path(directory), "utf8");
|
|
401
|
+
return schema.parse(JSON.parse(text));
|
|
402
|
+
}
|
|
403
|
+
function read_manifest_if_valid(directory, schema) {
|
|
404
|
+
const text = file_reader.read_if_readable(manifest_path(directory));
|
|
405
|
+
if (text === void 0) return void 0;
|
|
406
|
+
return json_value.parse_with(text, schema);
|
|
407
|
+
}
|
|
408
|
+
var package_manifest = { manifest_path, read_manifest, read_manifest_if_valid };
|
|
409
|
+
|
|
410
|
+
// scripts/josh/package-directory.ts
|
|
411
|
+
function find_package_directory(start_directory) {
|
|
412
|
+
return ancestor_directories.nearest(
|
|
413
|
+
start_directory,
|
|
414
|
+
(directory) => existsSync(package_manifest.manifest_path(directory))
|
|
415
|
+
) ?? start_directory;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// scripts/josh/stamp-file.ts
|
|
419
|
+
import { createHash } from "node:crypto";
|
|
420
|
+
import { lstatSync, readFileSync as readFileSync3, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
421
|
+
import path5 from "node:path";
|
|
422
|
+
|
|
423
|
+
// scripts/init/init-paths.ts
|
|
424
|
+
import path3 from "node:path";
|
|
425
|
+
import { fileURLToPath } from "node:url";
|
|
426
|
+
var PACKAGE_DIR = path3.join(path3.dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
427
|
+
var PROJECT_ROOT = process.cwd();
|
|
428
|
+
|
|
429
|
+
// scripts/josh/platform-temporary.ts
|
|
430
|
+
import { accessSync, constants } from "node:fs";
|
|
431
|
+
import { tmpdir } from "node:os";
|
|
432
|
+
var POSIX_TEMP_ROOT = "/tmp";
|
|
433
|
+
var WINDOWS_PLATFORM = "win32";
|
|
434
|
+
function is_writable_directory(directory) {
|
|
435
|
+
try {
|
|
436
|
+
accessSync(directory, constants.W_OK);
|
|
437
|
+
return true;
|
|
438
|
+
} catch {
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
function resolve_temporary_root(platform, can_write = is_writable_directory) {
|
|
443
|
+
if (platform === WINDOWS_PLATFORM) return tmpdir();
|
|
444
|
+
return can_write(POSIX_TEMP_ROOT) ? POSIX_TEMP_ROOT : tmpdir();
|
|
445
|
+
}
|
|
446
|
+
var TEMP_ROOT_KEY = "JOSH_TEMP_ROOT";
|
|
447
|
+
function temporary_root(override, platform) {
|
|
448
|
+
return override === void 0 || override === "" ? resolve_temporary_root(platform) : override;
|
|
449
|
+
}
|
|
450
|
+
var PLATFORM_TEMP_ROOT = temporary_root(process.env[TEMP_ROOT_KEY], process.platform);
|
|
451
|
+
|
|
452
|
+
// scripts/lib/atomic-write.ts
|
|
453
|
+
import { randomUUID } from "node:crypto";
|
|
454
|
+
import { chmodSync, mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
455
|
+
import path4 from "node:path";
|
|
456
|
+
var STAGING_EXTENSION = ".tmp";
|
|
457
|
+
var CREATE_EXCLUSIVE_FLAG = "wx";
|
|
458
|
+
function staging_path(target, staging_directory) {
|
|
459
|
+
const name = `${path4.basename(target)}.${String(process.pid)}.${randomUUID()}${STAGING_EXTENSION}`;
|
|
460
|
+
return path4.join(staging_directory, name);
|
|
461
|
+
}
|
|
462
|
+
function write_staged(staging, content, mode) {
|
|
463
|
+
writeFileSync(staging, content, {
|
|
464
|
+
flag: CREATE_EXCLUSIVE_FLAG,
|
|
465
|
+
...mode !== void 0 && { mode }
|
|
466
|
+
});
|
|
467
|
+
if (mode !== void 0) chmodSync(staging, mode);
|
|
468
|
+
}
|
|
469
|
+
function replace_file(target, content, options = {}) {
|
|
470
|
+
const directory = options.staging_directory ?? path4.dirname(target);
|
|
471
|
+
const staging = staging_path(target, directory);
|
|
472
|
+
mkdirSync(directory, { recursive: true });
|
|
473
|
+
try {
|
|
474
|
+
write_staged(staging, content, options.mode);
|
|
475
|
+
renameSync(staging, target);
|
|
476
|
+
} finally {
|
|
477
|
+
rmSync(staging, { force: true });
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
var atomic_write = { replace_file };
|
|
481
|
+
|
|
482
|
+
// scripts/josh/stamp-file.ts
|
|
483
|
+
var HASH_ALGORITHM = "sha256";
|
|
484
|
+
var STAMP_SUFFIX = ".json";
|
|
485
|
+
var STAMP_KEY_LENGTH = 16;
|
|
486
|
+
var STAMP_FILE_MODE = 384;
|
|
487
|
+
var STAMP_WRITE_FLAG = "wx";
|
|
488
|
+
var STAMP_CREATE_FLAG = STAMP_WRITE_FLAG;
|
|
489
|
+
var EXISTS_ERROR_CODE = "EEXIST";
|
|
490
|
+
var ACCOUNT_KEY_SEPARATOR = ":";
|
|
491
|
+
function digest(content) {
|
|
492
|
+
return createHash(HASH_ALGORITHM).update(content).digest("hex");
|
|
493
|
+
}
|
|
494
|
+
function account_key() {
|
|
495
|
+
return String(process.getuid?.() ?? "");
|
|
496
|
+
}
|
|
497
|
+
function stamp_name(prefix, root = PACKAGE_DIR, suffix = STAMP_SUFFIX) {
|
|
498
|
+
const key = digest(`${account_key()}${ACCOUNT_KEY_SEPARATOR}${root}`).slice(0, STAMP_KEY_LENGTH);
|
|
499
|
+
return `${prefix}${key}${suffix}`;
|
|
500
|
+
}
|
|
501
|
+
function stamp_path(prefix, root = PACKAGE_DIR, suffix = STAMP_SUFFIX) {
|
|
502
|
+
return path5.join(PLATFORM_TEMP_ROOT, stamp_name(prefix, root, suffix));
|
|
503
|
+
}
|
|
504
|
+
function write_exclusively(target, content) {
|
|
505
|
+
rmSync2(target, { force: true });
|
|
506
|
+
writeFileSync2(target, content, { flag: STAMP_WRITE_FLAG, mode: STAMP_FILE_MODE });
|
|
507
|
+
return target;
|
|
508
|
+
}
|
|
509
|
+
function write_stamp(target, payload) {
|
|
510
|
+
return write_exclusively(target, JSON.stringify(payload));
|
|
511
|
+
}
|
|
512
|
+
function is_own_regular_file(source) {
|
|
513
|
+
const stats = lstatSync(source);
|
|
514
|
+
if (!stats.isFile()) return false;
|
|
515
|
+
const uid = process.getuid?.();
|
|
516
|
+
return uid === void 0 || stats.uid === uid;
|
|
517
|
+
}
|
|
518
|
+
function is_foreign_file(target) {
|
|
519
|
+
try {
|
|
520
|
+
return lstatSync(target).isFile() && !is_own_regular_file(target);
|
|
521
|
+
} catch {
|
|
522
|
+
return false;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
function replace_text_stamp(target, text) {
|
|
526
|
+
if (is_foreign_file(target)) {
|
|
527
|
+
throw new Error(`refusing to replace another account's file: ${target}`);
|
|
528
|
+
}
|
|
529
|
+
atomic_write.replace_file(target, text, { mode: STAMP_FILE_MODE });
|
|
530
|
+
return target;
|
|
531
|
+
}
|
|
532
|
+
function replace_stamp(target, payload) {
|
|
533
|
+
return replace_text_stamp(target, JSON.stringify(payload));
|
|
534
|
+
}
|
|
535
|
+
function write_text_stamp(target, text) {
|
|
536
|
+
return write_exclusively(target, text);
|
|
537
|
+
}
|
|
538
|
+
function create_stamp(target, payload) {
|
|
539
|
+
try {
|
|
540
|
+
writeFileSync2(target, JSON.stringify(payload), {
|
|
541
|
+
flag: STAMP_CREATE_FLAG,
|
|
542
|
+
mode: STAMP_FILE_MODE
|
|
543
|
+
});
|
|
544
|
+
return true;
|
|
545
|
+
} catch (error) {
|
|
546
|
+
if (error.code === EXISTS_ERROR_CODE) return false;
|
|
547
|
+
throw error;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
function remove_stamp(target) {
|
|
551
|
+
rmSync2(target, { force: true });
|
|
552
|
+
}
|
|
553
|
+
function read_stamp_text(source) {
|
|
554
|
+
try {
|
|
555
|
+
if (!is_own_regular_file(source)) return void 0;
|
|
556
|
+
return readFileSync3(source, "utf8");
|
|
557
|
+
} catch {
|
|
558
|
+
return void 0;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
var stamp_file = {
|
|
562
|
+
create_stamp,
|
|
563
|
+
digest,
|
|
564
|
+
is_own_regular_file,
|
|
565
|
+
read_stamp_text,
|
|
566
|
+
replace_stamp,
|
|
567
|
+
replace_text_stamp,
|
|
568
|
+
remove_stamp,
|
|
569
|
+
stamp_name,
|
|
570
|
+
stamp_path,
|
|
571
|
+
write_stamp,
|
|
572
|
+
write_text_stamp
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
// scripts/agent/lane-instructions.ts
|
|
576
|
+
var LANE_DOCUMENT = "prompts/collaboration-workflow/lane-instructions.md";
|
|
577
|
+
var RULES_FILE = "CLAUDE.md";
|
|
578
|
+
var POINTER_FILE = "AGENTS.md";
|
|
579
|
+
var INCLUDE_PATTERN = /^<!-- include: CLAUDE\.md → "(?<wanted>.+)" -->$/u;
|
|
580
|
+
var PROMPT_FILE_FLAG = "--append-system-prompt-file";
|
|
581
|
+
var SETTINGS_FLAG = "--settings";
|
|
582
|
+
var PROMPT_FILE_PREFIX = "josh-lane-instructions-";
|
|
583
|
+
var PROMPT_FILE_SUFFIX = ".md";
|
|
584
|
+
var PACKAGE_DIRECTORY = find_package_directory(path6.dirname(fileURLToPath2(import.meta.url)));
|
|
585
|
+
function expand_line(line, rules) {
|
|
586
|
+
const wanted = INCLUDE_PATTERN.exec(line)?.groups?.["wanted"];
|
|
587
|
+
if (wanted === void 0) return line;
|
|
588
|
+
return document_section.section(rules, wanted)?.text;
|
|
589
|
+
}
|
|
590
|
+
function compose(lane_markdown, rules) {
|
|
591
|
+
const expanded = lane_markdown.split("\n").map((line) => expand_line(line, rules));
|
|
592
|
+
if (expanded.includes(void 0)) return void 0;
|
|
593
|
+
return expanded.join("\n");
|
|
594
|
+
}
|
|
595
|
+
function rules_sources(cwd) {
|
|
596
|
+
const imported = distributed_paths.CLAUDE_MD_IMPORT_LINE.replace(/^@/u, "");
|
|
597
|
+
return [path6.join(cwd, RULES_FILE), path6.join(cwd, imported)];
|
|
598
|
+
}
|
|
599
|
+
function composed_from(lane_markdown, rules_path) {
|
|
600
|
+
const rules = document_section.read_optional(rules_path);
|
|
601
|
+
return rules === void 0 ? void 0 : compose(lane_markdown, rules);
|
|
602
|
+
}
|
|
603
|
+
function composed_set(cwd, package_directory) {
|
|
604
|
+
const lane_markdown = document_section.read_optional(path6.join(package_directory, LANE_DOCUMENT));
|
|
605
|
+
if (lane_markdown === void 0) return void 0;
|
|
606
|
+
for (const rules_path of rules_sources(cwd)) {
|
|
607
|
+
const text = composed_from(lane_markdown, rules_path);
|
|
608
|
+
if (text !== void 0) return { text, rules_path };
|
|
609
|
+
}
|
|
610
|
+
return void 0;
|
|
611
|
+
}
|
|
612
|
+
function composed_in(cwd, package_directory = PACKAGE_DIRECTORY) {
|
|
613
|
+
return composed_set(cwd, package_directory)?.text;
|
|
614
|
+
}
|
|
615
|
+
function written(text) {
|
|
616
|
+
const file_path = stamp_file.stamp_path(PROMPT_FILE_PREFIX, text, PROMPT_FILE_SUFFIX);
|
|
617
|
+
if (stamp_file.read_stamp_text(file_path) === text) return file_path;
|
|
618
|
+
try {
|
|
619
|
+
return stamp_file.replace_text_stamp(file_path, text);
|
|
620
|
+
} catch {
|
|
621
|
+
return void 0;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
function excluded_settings(rules_path, cwd) {
|
|
625
|
+
return JSON.stringify({ claudeMdExcludes: [rules_path, path6.join(cwd, POINTER_FILE)] });
|
|
626
|
+
}
|
|
627
|
+
function flags(cwd = process.cwd()) {
|
|
628
|
+
const set = composed_set(cwd, PACKAGE_DIRECTORY);
|
|
629
|
+
const prompt_file = set === void 0 ? void 0 : written(set.text);
|
|
630
|
+
if (set === void 0 || prompt_file === void 0) return [];
|
|
631
|
+
return [PROMPT_FILE_FLAG, prompt_file, SETTINGS_FLAG, excluded_settings(set.rules_path, cwd)];
|
|
632
|
+
}
|
|
633
|
+
function tokens_of(text) {
|
|
634
|
+
return cost_tokens.estimate(text).toLocaleString("en-US");
|
|
635
|
+
}
|
|
636
|
+
function rules_tokens(rules_path) {
|
|
637
|
+
return tokens_of(document_section.read_optional(rules_path) ?? "");
|
|
638
|
+
}
|
|
639
|
+
function resident_line(cwd = process.cwd()) {
|
|
640
|
+
const set = composed_set(cwd, PACKAGE_DIRECTORY);
|
|
641
|
+
const rules = rules_tokens(set?.rules_path ?? path6.join(cwd, RULES_FILE));
|
|
642
|
+
const lane_tokens = set === void 0 ? "not composed" : `${tokens_of(set.text)} tok`;
|
|
643
|
+
return ` resident: lane instructions ${lane_tokens} in place of ${RULES_FILE} ${rules} tok`;
|
|
644
|
+
}
|
|
645
|
+
var lane_instructions = {
|
|
646
|
+
PROMPT_FILE_FLAG,
|
|
647
|
+
SETTINGS_FLAG,
|
|
648
|
+
compose,
|
|
649
|
+
composed_in,
|
|
650
|
+
flags,
|
|
651
|
+
resident_line
|
|
652
|
+
};
|
|
653
|
+
|
|
654
|
+
// scripts/document/entry-read-set.ts
|
|
655
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
656
|
+
import path8 from "node:path";
|
|
657
|
+
|
|
658
|
+
// scripts/document/bash-output-cap.ts
|
|
659
|
+
import path7 from "node:path";
|
|
660
|
+
var SETTINGS_FILE = path7.join(".claude", "settings.json");
|
|
661
|
+
var HARNESS_DEFAULT_CAP_CHARS = 3e4;
|
|
662
|
+
var ENV_KEY = "env";
|
|
663
|
+
var CAP_KEY = "BASH_MAX_OUTPUT_LENGTH";
|
|
664
|
+
var NONE = 0;
|
|
665
|
+
function property_of(value, key) {
|
|
666
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
667
|
+
return Reflect.get(value, key);
|
|
668
|
+
}
|
|
669
|
+
function declared_cap(text) {
|
|
670
|
+
try {
|
|
671
|
+
return property_of(property_of(JSON.parse(text), ENV_KEY), CAP_KEY);
|
|
672
|
+
} catch {
|
|
673
|
+
return void 0;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
function bash_output_cap(root) {
|
|
677
|
+
const text = document_section.read_optional(path7.join(root, SETTINGS_FILE)) ?? "";
|
|
678
|
+
const chars = Number(declared_cap(text));
|
|
679
|
+
return Number.isSafeInteger(chars) && chars > NONE ? chars : HARNESS_DEFAULT_CAP_CHARS;
|
|
680
|
+
}
|
|
681
|
+
var bash_output_cap_reader = { HARNESS_DEFAULT_CAP_CHARS, bash_output_cap };
|
|
682
|
+
|
|
683
|
+
// scripts/document/read-set-cost.ts
|
|
684
|
+
var NOTHING = 0;
|
|
685
|
+
var ONE_LINE = 1;
|
|
686
|
+
function cost_of(text) {
|
|
687
|
+
return { bytes: Buffer.byteLength(text, "utf8"), tokens: cost_tokens.estimate(text) };
|
|
688
|
+
}
|
|
689
|
+
function total(costs) {
|
|
690
|
+
const running = { bytes: NOTHING, tokens: NOTHING };
|
|
691
|
+
for (const cost of costs) {
|
|
692
|
+
running.bytes += cost.bytes;
|
|
693
|
+
running.tokens += cost.tokens;
|
|
694
|
+
}
|
|
695
|
+
return running;
|
|
696
|
+
}
|
|
697
|
+
function add_range(charged, found) {
|
|
698
|
+
for (let index = found.first_line; index <= found.last_line; index += ONE_LINE) charged.add(index);
|
|
699
|
+
}
|
|
700
|
+
function charged_lines(markdown, headings2) {
|
|
701
|
+
const charged = /* @__PURE__ */ new Set();
|
|
702
|
+
for (const heading of headings2) {
|
|
703
|
+
const found = document_section.section(markdown, heading);
|
|
704
|
+
if (found === void 0) return void 0;
|
|
705
|
+
add_range(charged, found);
|
|
706
|
+
}
|
|
707
|
+
return charged;
|
|
708
|
+
}
|
|
709
|
+
function extend_or_start(runs, index) {
|
|
710
|
+
const current = runs.at(-1);
|
|
711
|
+
if (current?.at(-1) === index - ONE_LINE) current.push(index);
|
|
712
|
+
else runs.push([index]);
|
|
713
|
+
}
|
|
714
|
+
function contiguous_runs(charged) {
|
|
715
|
+
const runs = [];
|
|
716
|
+
const ascending = [...charged].toSorted((left, right) => left - right);
|
|
717
|
+
for (const index of ascending) extend_or_start(runs, index);
|
|
718
|
+
return runs;
|
|
719
|
+
}
|
|
720
|
+
function run_text(lines, run2) {
|
|
721
|
+
return run2.map((index) => lines[index] ?? "").join("\n");
|
|
722
|
+
}
|
|
723
|
+
function scoped_file_cost(markdown, headings2) {
|
|
724
|
+
const charged = charged_lines(markdown, headings2);
|
|
725
|
+
if (charged === void 0) return cost_of(markdown);
|
|
726
|
+
const lines = markdown.split("\n");
|
|
727
|
+
return total(contiguous_runs(charged).map((run2) => cost_of(run_text(lines, run2))));
|
|
728
|
+
}
|
|
729
|
+
var read_set_cost = { cost_of, scoped_file_cost, total };
|
|
730
|
+
|
|
731
|
+
// scripts/document/read-set-point-of-use.ts
|
|
732
|
+
var POINT_OF_USE_FILES = /* @__PURE__ */ new Set([
|
|
733
|
+
"latest-gate.md",
|
|
734
|
+
"followup.md",
|
|
735
|
+
"chain-rule.md",
|
|
736
|
+
"background-commands.md",
|
|
737
|
+
"pre-gate-cut.md",
|
|
738
|
+
"progress-watcher.md",
|
|
739
|
+
"backlogrun-child.md",
|
|
740
|
+
"backlogrun-lanes.md",
|
|
741
|
+
"backlogrun-progress.md",
|
|
742
|
+
"backlogrun-park.md",
|
|
743
|
+
"backlogrun-steps.md",
|
|
744
|
+
// Read only when a delegated unit goes silent or a lane's pull request conflicts with `main` — a
|
|
745
|
+
// failure path, so a run in which nothing fails never reads it.
|
|
746
|
+
"backlogrun-recovery.md",
|
|
747
|
+
// Read only when `run:step` prints `pnpm josh retrospective` at a run's stop position — the very
|
|
748
|
+
// end of a run, never the entry. Kept out of every entry's read for the
|
|
749
|
+
// same reason the phase documents above are: no run that never drains its backlog reaches it.
|
|
750
|
+
"retrospective.md"
|
|
751
|
+
]);
|
|
752
|
+
var DEFERRED_DECISIONS = /* @__PURE__ */ new Set(["delegation.md", "issue-scout.md"]);
|
|
753
|
+
var POINT_OF_USE_BY_ENTRY = /* @__PURE__ */ new Map([
|
|
754
|
+
["kickoff", DEFERRED_DECISIONS],
|
|
755
|
+
["fullrun", DEFERRED_DECISIONS],
|
|
756
|
+
["halfrun", DEFERRED_DECISIONS],
|
|
757
|
+
["prrun", DEFERRED_DECISIONS],
|
|
758
|
+
["backlogrun", /* @__PURE__ */ new Set([...DEFERRED_DECISIONS, "fullrun.md", "split-assessment.md"])]
|
|
759
|
+
]);
|
|
760
|
+
var NO_PER_ENTRY_FILES = /* @__PURE__ */ new Set();
|
|
761
|
+
function is_point_of_use(entry, file) {
|
|
762
|
+
if (POINT_OF_USE_FILES.has(file)) return true;
|
|
763
|
+
return (POINT_OF_USE_BY_ENTRY.get(entry) ?? NO_PER_ENTRY_FILES).has(file);
|
|
764
|
+
}
|
|
765
|
+
function point_of_use_files(entry, cited) {
|
|
766
|
+
const reached = [...POINT_OF_USE_FILES].filter((file) => cited.has(file));
|
|
767
|
+
return [...reached, ...POINT_OF_USE_BY_ENTRY.get(entry) ?? NO_PER_ENTRY_FILES];
|
|
768
|
+
}
|
|
769
|
+
var read_set_point_of_use = {
|
|
770
|
+
POINT_OF_USE_FILES,
|
|
771
|
+
POINT_OF_USE_BY_ENTRY,
|
|
772
|
+
is_point_of_use,
|
|
773
|
+
point_of_use_files
|
|
774
|
+
};
|
|
775
|
+
|
|
776
|
+
// scripts/document/entry-read-set.ts
|
|
777
|
+
var { POINT_OF_USE_FILES: POINT_OF_USE_FILES2, POINT_OF_USE_BY_ENTRY: POINT_OF_USE_BY_ENTRY2, is_point_of_use: is_point_of_use2, point_of_use_files: point_of_use_files2 } = read_set_point_of_use;
|
|
778
|
+
var { cost_of: cost_of2, scoped_file_cost: scoped_file_cost2, total: total2 } = read_set_cost;
|
|
779
|
+
var SKILL_DIRECTORY = path8.join(".claude", "skills", "workflow-commands");
|
|
780
|
+
var SKILL_FILE = "SKILL.md";
|
|
781
|
+
var TABLE_SECTION = "1. Which file to read";
|
|
782
|
+
var NOTHING2 = 0;
|
|
783
|
+
var HEADING_JOINER = '" + "';
|
|
784
|
+
var SUBSECTION_PREFIX = "### ";
|
|
785
|
+
var TABLE_ROW = /^\|(?<entry>[^|]+)\|(?<files>[^|]+)\|\s*$/u;
|
|
786
|
+
var MARKDOWN_NAME = /`(?<name>[\w.-]+\.md)`/gu;
|
|
787
|
+
var ENTRY_KEYWORD = /`(?<keyword>[a-z]+)/u;
|
|
788
|
+
var SECTION_REFERENCE = /`(?<file>[\w.-]+\.md)` *→ *"(?<heading>[^"]+)"/gu;
|
|
789
|
+
var WHITESPACE_RUN = /\s+/gu;
|
|
790
|
+
function document_path(root, name) {
|
|
791
|
+
const in_project = path8.join(root, SKILL_DIRECTORY, name);
|
|
792
|
+
const in_package = path8.join(PACKAGE_DIR, SKILL_DIRECTORY, name);
|
|
793
|
+
const project_manifest = path8.join(root, "package.json");
|
|
794
|
+
if (root !== "" && existsSync2(project_manifest) && existsSync2(in_package)) return in_package;
|
|
795
|
+
return existsSync2(in_project) ? in_project : in_package;
|
|
796
|
+
}
|
|
797
|
+
function read_document(root, name) {
|
|
798
|
+
return document_section.read_optional(document_path(root, name)) ?? "";
|
|
799
|
+
}
|
|
800
|
+
function unique(names) {
|
|
801
|
+
return [...new Set(names)];
|
|
802
|
+
}
|
|
803
|
+
function all_matches(text, pattern) {
|
|
804
|
+
const scanner = new RegExp(pattern.source, pattern.flags);
|
|
805
|
+
const found = [];
|
|
806
|
+
let match = scanner.exec(text);
|
|
807
|
+
while (match !== null) {
|
|
808
|
+
found.push(match);
|
|
809
|
+
match = scanner.exec(text);
|
|
810
|
+
}
|
|
811
|
+
return found;
|
|
812
|
+
}
|
|
813
|
+
function group_of(match, name) {
|
|
814
|
+
return match.groups?.[name] ?? "";
|
|
815
|
+
}
|
|
816
|
+
function names_in(text) {
|
|
817
|
+
return all_matches(text, MARKDOWN_NAME).map((match) => group_of(match, "name"));
|
|
818
|
+
}
|
|
819
|
+
function columns_of(line) {
|
|
820
|
+
const groups = TABLE_ROW.exec(line)?.groups;
|
|
821
|
+
if (groups === void 0) return void 0;
|
|
822
|
+
const { entry = "", files = "" } = groups;
|
|
823
|
+
return { entry, files };
|
|
824
|
+
}
|
|
825
|
+
function to_row(line) {
|
|
826
|
+
const columns = columns_of(line);
|
|
827
|
+
if (columns === void 0) return void 0;
|
|
828
|
+
const { keyword } = ENTRY_KEYWORD.exec(columns.entry)?.groups ?? {};
|
|
829
|
+
return keyword === void 0 ? void 0 : { keyword, files: names_in(columns.files) };
|
|
830
|
+
}
|
|
831
|
+
function push_row(rows, line) {
|
|
832
|
+
const row2 = to_row(line);
|
|
833
|
+
if (row2 !== void 0 && row2.files.length > NOTHING2) rows.set(row2.keyword, row2.files);
|
|
834
|
+
}
|
|
835
|
+
function table_rows(root) {
|
|
836
|
+
const rows = /* @__PURE__ */ new Map();
|
|
837
|
+
const found = document_section.section(read_document(root, SKILL_FILE), TABLE_SECTION);
|
|
838
|
+
const lines = (found?.text ?? "").split("\n");
|
|
839
|
+
for (const line of lines) {
|
|
840
|
+
if (line.startsWith(SUBSECTION_PREFIX)) break;
|
|
841
|
+
push_row(rows, line);
|
|
842
|
+
}
|
|
843
|
+
return rows;
|
|
844
|
+
}
|
|
845
|
+
function files_for(root, entry) {
|
|
846
|
+
const declared = table_rows(root).get(entry) ?? [];
|
|
847
|
+
return unique([SKILL_FILE, ...declared]).filter((file) => !is_point_of_use2(entry, file));
|
|
848
|
+
}
|
|
849
|
+
function fold(text) {
|
|
850
|
+
return text.replaceAll(WHITESPACE_RUN, " ").trim();
|
|
851
|
+
}
|
|
852
|
+
function is_sibling_document(root, name) {
|
|
853
|
+
return document_section.read_optional(document_path(root, name)) !== void 0;
|
|
854
|
+
}
|
|
855
|
+
function is_counted(root, entry, reference, files) {
|
|
856
|
+
if (is_point_of_use2(entry, reference.file)) return false;
|
|
857
|
+
return !files.includes(reference.file) && is_sibling_document(root, reference.file);
|
|
858
|
+
}
|
|
859
|
+
function to_reference(match) {
|
|
860
|
+
return { file: group_of(match, "file"), heading: fold(group_of(match, "heading")) };
|
|
861
|
+
}
|
|
862
|
+
function references_from(root, entry, text, files) {
|
|
863
|
+
return all_matches(text, SECTION_REFERENCE).map((match) => to_reference(match)).filter((reference) => is_counted(root, entry, reference, files));
|
|
864
|
+
}
|
|
865
|
+
function sort_key(reference) {
|
|
866
|
+
return `${reference.file} ${reference.heading}`;
|
|
867
|
+
}
|
|
868
|
+
function dedupe(references) {
|
|
869
|
+
const seen = /* @__PURE__ */ new Map();
|
|
870
|
+
for (const reference of references) seen.set(sort_key(reference), reference);
|
|
871
|
+
return [...seen].map(([, reference]) => reference);
|
|
872
|
+
}
|
|
873
|
+
function sections_for(root, entry, files) {
|
|
874
|
+
const found = files.filter((file) => file !== SKILL_FILE).flatMap((file) => references_from(root, entry, read_document(root, file), files));
|
|
875
|
+
return dedupe(found).toSorted((left, right) => sort_key(left).localeCompare(sort_key(right)));
|
|
876
|
+
}
|
|
877
|
+
function read_set(root, entry) {
|
|
878
|
+
const files = files_for(root, entry);
|
|
879
|
+
return { entry, files, sections: sections_for(root, entry, files) };
|
|
880
|
+
}
|
|
881
|
+
function section_cost(root, reference) {
|
|
882
|
+
const found = document_section.section(read_document(root, reference.file), reference.heading);
|
|
883
|
+
return {
|
|
884
|
+
...reference,
|
|
885
|
+
// **An unresolvable reference is charged at the whole file.** Reporting it at zero would let a
|
|
886
|
+
// broken pointer read as a saving, which is the one direction this measurement must not move.
|
|
887
|
+
cost: cost_of2(found?.text ?? read_document(root, reference.file)),
|
|
888
|
+
is_resolved: found !== void 0
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
function referenced_cost(root, sections) {
|
|
892
|
+
const files = unique(sections.map((reference) => reference.file));
|
|
893
|
+
return total2(files.map((file) => cost_of2(read_document(root, file))));
|
|
894
|
+
}
|
|
895
|
+
function headings_for(sections, file) {
|
|
896
|
+
return sections.filter((reference) => reference.file === file).map((one) => one.heading);
|
|
897
|
+
}
|
|
898
|
+
function scoped_cost(root, sections) {
|
|
899
|
+
const files = unique(sections.map((reference) => reference.file));
|
|
900
|
+
return total2(
|
|
901
|
+
files.map((file) => scoped_file_cost2(read_document(root, file), headings_for(sections, file)))
|
|
902
|
+
);
|
|
903
|
+
}
|
|
904
|
+
function file_costs(root, names) {
|
|
905
|
+
return names.map((file) => ({ file, cost: cost_of2(read_document(root, file)) }));
|
|
906
|
+
}
|
|
907
|
+
function point_of_use_cost(root, file, references) {
|
|
908
|
+
const markdown = read_document(root, file);
|
|
909
|
+
const headings2 = unique(references.filter((one) => one.file === file).map((one) => one.heading));
|
|
910
|
+
if (headings2.length === NOTHING2) {
|
|
911
|
+
return { file, heading: "", cost: cost_of2(markdown), is_resolved: true };
|
|
912
|
+
}
|
|
913
|
+
return {
|
|
914
|
+
file,
|
|
915
|
+
heading: headings2.join(HEADING_JOINER),
|
|
916
|
+
cost: scoped_file_cost2(markdown, headings2),
|
|
917
|
+
is_resolved: headings2.every(
|
|
918
|
+
(heading) => document_section.section(markdown, heading) !== void 0
|
|
919
|
+
)
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
function path_texts(root, entry, table_text) {
|
|
923
|
+
const manifests = files_for(root, entry).filter((file) => file !== SKILL_FILE);
|
|
924
|
+
const rows = table_text.split("\n").filter((line) => line.startsWith("|") && line.includes(`\`${entry}\``));
|
|
925
|
+
return [...manifests.map((file) => read_document(root, file)), ...rows];
|
|
926
|
+
}
|
|
927
|
+
function point_of_use_references(root, entry, table_text) {
|
|
928
|
+
const manifests = files_for(root, entry).filter((file) => file !== SKILL_FILE);
|
|
929
|
+
const texts = [table_text, ...manifests.map((file) => read_document(root, file))];
|
|
930
|
+
return texts.flatMap(
|
|
931
|
+
(text) => all_matches(text, SECTION_REFERENCE).map((match) => to_reference(match))
|
|
932
|
+
);
|
|
933
|
+
}
|
|
934
|
+
function point_of_use_costs(root, entry, also) {
|
|
935
|
+
const table_text = document_section.section(read_document(root, SKILL_FILE), TABLE_SECTION)?.text ?? "";
|
|
936
|
+
const references = point_of_use_references(root, entry, table_text);
|
|
937
|
+
const named = path_texts(root, entry, table_text).flatMap((text) => names_in(text));
|
|
938
|
+
const cited = /* @__PURE__ */ new Set([...also, ...named]);
|
|
939
|
+
return point_of_use_files2(entry, cited).map((file) => point_of_use_cost(root, file, references));
|
|
940
|
+
}
|
|
941
|
+
function costed(root, entry, also = /* @__PURE__ */ new Set()) {
|
|
942
|
+
const { files, sections } = read_set(root, entry);
|
|
943
|
+
const own_costs = file_costs(root, files);
|
|
944
|
+
const section_costs = sections.map((reference) => section_cost(root, reference));
|
|
945
|
+
const own = total2(own_costs.map((row2) => row2.cost));
|
|
946
|
+
return {
|
|
947
|
+
entry,
|
|
948
|
+
files: own_costs,
|
|
949
|
+
sections: section_costs,
|
|
950
|
+
point_of_use: point_of_use_costs(root, entry, also),
|
|
951
|
+
bash_output_cap: bash_output_cap_reader.bash_output_cap(root),
|
|
952
|
+
whole: total2([own, referenced_cost(root, sections)]),
|
|
953
|
+
scoped: total2([own, scoped_cost(root, sections)])
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
function entries(root) {
|
|
957
|
+
return [...table_rows(root)].map(([keyword]) => keyword);
|
|
958
|
+
}
|
|
959
|
+
var entry_read_set = {
|
|
960
|
+
HARNESS_DEFAULT_CAP_CHARS: bash_output_cap_reader.HARNESS_DEFAULT_CAP_CHARS,
|
|
961
|
+
POINT_OF_USE_BY_ENTRY: POINT_OF_USE_BY_ENTRY2,
|
|
962
|
+
POINT_OF_USE_FILES: POINT_OF_USE_FILES2,
|
|
963
|
+
SECTION_REFERENCE,
|
|
964
|
+
SKILL_DIRECTORY,
|
|
965
|
+
SKILL_FILE,
|
|
966
|
+
TABLE_SECTION,
|
|
967
|
+
bash_output_cap: bash_output_cap_reader.bash_output_cap,
|
|
968
|
+
cost_of: cost_of2,
|
|
969
|
+
costed,
|
|
970
|
+
document_path,
|
|
971
|
+
entries,
|
|
972
|
+
read_set,
|
|
973
|
+
total: total2
|
|
974
|
+
};
|
|
975
|
+
|
|
976
|
+
// scripts/document/read-set-trim.ts
|
|
977
|
+
function subtract(left, right) {
|
|
978
|
+
return { bytes: left.bytes - right.bytes, tokens: left.tokens - right.tokens };
|
|
979
|
+
}
|
|
980
|
+
function skill_text(root) {
|
|
981
|
+
const path9 = entry_read_set.document_path(root, entry_read_set.SKILL_FILE);
|
|
982
|
+
return document_section.read_optional(path9) ?? "";
|
|
983
|
+
}
|
|
984
|
+
function section_cost2(text, heading) {
|
|
985
|
+
return entry_read_set.cost_of(document_section.section(text, heading)?.text ?? "");
|
|
986
|
+
}
|
|
987
|
+
function unused_skill_cost(root, sections) {
|
|
988
|
+
const text = skill_text(root);
|
|
989
|
+
return entry_read_set.total(sections.map((heading) => section_cost2(text, heading)));
|
|
990
|
+
}
|
|
991
|
+
function reduce_skill(file, saving) {
|
|
992
|
+
if (file.file !== entry_read_set.SKILL_FILE) return file;
|
|
993
|
+
return { file: file.file, cost: subtract(file.cost, saving) };
|
|
994
|
+
}
|
|
995
|
+
function costed2(root, spec) {
|
|
996
|
+
const base = entry_read_set.costed(root, spec.base_entry, spec.reached_point_of_use);
|
|
997
|
+
const saving = unused_skill_cost(root, spec.unused_skill_sections);
|
|
998
|
+
return {
|
|
999
|
+
...base,
|
|
1000
|
+
entry: spec.label,
|
|
1001
|
+
files: base.files.map((file) => reduce_skill(file, saving)),
|
|
1002
|
+
point_of_use: base.point_of_use.filter((one) => !spec.skipped_point_of_use.has(one.file)),
|
|
1003
|
+
whole: subtract(base.whole, saving),
|
|
1004
|
+
scoped: subtract(base.scoped, saving)
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
var read_set_trim = { costed: costed2 };
|
|
1008
|
+
|
|
1009
|
+
// scripts/document/backlogrun-parent-read-set.ts
|
|
1010
|
+
var BACKLOGRUN = "backlogrun";
|
|
1011
|
+
var UNUSED_SKILL_SECTIONS = [
|
|
1012
|
+
"3. What stays resident, and what is read from here"
|
|
1013
|
+
];
|
|
1014
|
+
var SKIPPED_POINT_OF_USE = /* @__PURE__ */ new Set();
|
|
1015
|
+
var REACHED_POINT_OF_USE = /* @__PURE__ */ new Set([
|
|
1016
|
+
"retrospective.md",
|
|
1017
|
+
"backlogrun-recovery.md"
|
|
1018
|
+
]);
|
|
1019
|
+
function costed3(root) {
|
|
1020
|
+
return read_set_trim.costed(root, {
|
|
1021
|
+
base_entry: BACKLOGRUN,
|
|
1022
|
+
label: BACKLOGRUN,
|
|
1023
|
+
unused_skill_sections: UNUSED_SKILL_SECTIONS,
|
|
1024
|
+
skipped_point_of_use: SKIPPED_POINT_OF_USE,
|
|
1025
|
+
reached_point_of_use: REACHED_POINT_OF_USE
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
var backlogrun_parent_read_set = {
|
|
1029
|
+
BACKLOGRUN,
|
|
1030
|
+
REACHED_POINT_OF_USE,
|
|
1031
|
+
UNUSED_SKILL_SECTIONS,
|
|
1032
|
+
costed: costed3
|
|
1033
|
+
};
|
|
1034
|
+
|
|
1035
|
+
// scripts/document/lane-child-read-set.ts
|
|
1036
|
+
var LANE_CHILD = "lane-child";
|
|
1037
|
+
var FULLRUN = "fullrun";
|
|
1038
|
+
var UNUSED_SKILL_SECTIONS2 = [
|
|
1039
|
+
"0. The rule that fires before any of them \u2014 explicit invocation",
|
|
1040
|
+
"3. What stays resident, and what is read from here"
|
|
1041
|
+
];
|
|
1042
|
+
var SKIPPED_POINT_OF_USE2 = /* @__PURE__ */ new Set([
|
|
1043
|
+
"backlogrun-child.md",
|
|
1044
|
+
"backlogrun-lanes.md",
|
|
1045
|
+
"backlogrun-progress.md",
|
|
1046
|
+
"backlogrun-steps.md",
|
|
1047
|
+
"delegation.md",
|
|
1048
|
+
"issue-scout.md",
|
|
1049
|
+
"latest-gate.md",
|
|
1050
|
+
"progress-watcher.md",
|
|
1051
|
+
"retrospective.md"
|
|
1052
|
+
]);
|
|
1053
|
+
var REACHED_POINT_OF_USE2 = /* @__PURE__ */ new Set(["backlogrun-park.md", "pre-gate-cut.md"]);
|
|
1054
|
+
function costed4(root) {
|
|
1055
|
+
return read_set_trim.costed(root, {
|
|
1056
|
+
base_entry: FULLRUN,
|
|
1057
|
+
label: LANE_CHILD,
|
|
1058
|
+
unused_skill_sections: UNUSED_SKILL_SECTIONS2,
|
|
1059
|
+
skipped_point_of_use: SKIPPED_POINT_OF_USE2,
|
|
1060
|
+
reached_point_of_use: REACHED_POINT_OF_USE2
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
var lane_child_read_set = {
|
|
1064
|
+
LANE_CHILD,
|
|
1065
|
+
REACHED_POINT_OF_USE: REACHED_POINT_OF_USE2,
|
|
1066
|
+
SKIPPED_POINT_OF_USE: SKIPPED_POINT_OF_USE2,
|
|
1067
|
+
UNUSED_SKILL_SECTIONS: UNUSED_SKILL_SECTIONS2,
|
|
1068
|
+
costed: costed4
|
|
1069
|
+
};
|
|
1070
|
+
|
|
1071
|
+
// scripts/agent/agent-role-profile.ts
|
|
1072
|
+
import { z as z2 } from "zod";
|
|
1073
|
+
|
|
1074
|
+
// scripts/josh/agent-session-environment.ts
|
|
1075
|
+
var SESSION_ID_KEY = "CLAUDE_CODE_SESSION_ID";
|
|
1076
|
+
var AGENT_PID_KEY = "CLAUDE_PID";
|
|
1077
|
+
var PARENT_SESSION_KEYS = [
|
|
1078
|
+
"CLAUDE_CODE_MESSAGING_SOCKET",
|
|
1079
|
+
"CLAUDE_CODE_MESSAGING_TOKEN",
|
|
1080
|
+
SESSION_ID_KEY,
|
|
1081
|
+
"CLAUDE_CODE_CHILD_SESSION"
|
|
1082
|
+
];
|
|
1083
|
+
var PROXY_KEYS = [
|
|
1084
|
+
"ALL_PROXY",
|
|
1085
|
+
"HTTP_PROXY",
|
|
1086
|
+
"HTTPS_PROXY",
|
|
1087
|
+
"all_proxy",
|
|
1088
|
+
"http_proxy",
|
|
1089
|
+
"https_proxy",
|
|
1090
|
+
"GLOBAL_AGENT_HTTP_PROXY",
|
|
1091
|
+
"GLOBAL_AGENT_HTTPS_PROXY"
|
|
1092
|
+
];
|
|
1093
|
+
var PROXY_CERTIFICATE_KEY = "NODE_EXTRA_CA_CERTS";
|
|
1094
|
+
var LOOPBACK_HOSTS = ["localhost", "ip6-localhost", "[::1]"];
|
|
1095
|
+
var LOOPBACK_PREFIX = "127.";
|
|
1096
|
+
var NO_HOST = "";
|
|
1097
|
+
function parsed_host(value) {
|
|
1098
|
+
try {
|
|
1099
|
+
return new URL(value).hostname;
|
|
1100
|
+
} catch {
|
|
1101
|
+
return NO_HOST;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
function proxy_host(value) {
|
|
1105
|
+
const direct = parsed_host(value);
|
|
1106
|
+
return direct === NO_HOST ? parsed_host(`http://${value}`) : direct;
|
|
1107
|
+
}
|
|
1108
|
+
function is_loopback_host(host) {
|
|
1109
|
+
return host.startsWith(LOOPBACK_PREFIX) || LOOPBACK_HOSTS.includes(host);
|
|
1110
|
+
}
|
|
1111
|
+
function is_loopback_proxy(value) {
|
|
1112
|
+
if (value === void 0 || value === NO_HOST) return false;
|
|
1113
|
+
return is_loopback_host(proxy_host(value));
|
|
1114
|
+
}
|
|
1115
|
+
function is_declared(value) {
|
|
1116
|
+
return value !== void 0 && value !== NO_HOST;
|
|
1117
|
+
}
|
|
1118
|
+
function loopback_proxy_keys(source, is_removed = is_loopback_proxy) {
|
|
1119
|
+
const declared = PROXY_KEYS.filter((key) => is_declared(source[key]));
|
|
1120
|
+
const matched = declared.filter((key) => is_removed(source[key]));
|
|
1121
|
+
const is_certificate_included = matched.length > 0 && matched.length === declared.length;
|
|
1122
|
+
return is_certificate_included ? [...matched, PROXY_CERTIFICATE_KEY] : matched;
|
|
1123
|
+
}
|
|
1124
|
+
function to_removed(keys) {
|
|
1125
|
+
return Object.fromEntries(keys.map((key) => [key, void 0]));
|
|
1126
|
+
}
|
|
1127
|
+
function removed_environment(source = process.env) {
|
|
1128
|
+
return to_removed([...PARENT_SESSION_KEYS, ...loopback_proxy_keys(source)]);
|
|
1129
|
+
}
|
|
1130
|
+
var SCANNER_DIRECTORY = ".safe-chain";
|
|
1131
|
+
var PATH_SEPARATOR = /[/\\]/u;
|
|
1132
|
+
function is_scanner_certificate(value) {
|
|
1133
|
+
return value?.split(PATH_SEPARATOR).includes(SCANNER_DIRECTORY) ?? false;
|
|
1134
|
+
}
|
|
1135
|
+
var SCANNER_PROXY_KEY = "HTTPS_PROXY";
|
|
1136
|
+
function is_scanner_proxy(source) {
|
|
1137
|
+
const scanner_proxy = source[SCANNER_PROXY_KEY];
|
|
1138
|
+
return function is_match2(value) {
|
|
1139
|
+
return value === scanner_proxy && is_loopback_proxy(value);
|
|
1140
|
+
};
|
|
1141
|
+
}
|
|
1142
|
+
function removed_proxy_environment(source = process.env) {
|
|
1143
|
+
if (!is_scanner_certificate(source[PROXY_CERTIFICATE_KEY])) return {};
|
|
1144
|
+
return to_removed(loopback_proxy_keys(source, is_scanner_proxy(source)));
|
|
1145
|
+
}
|
|
1146
|
+
var agent_session_environment = {
|
|
1147
|
+
AGENT_PID_KEY,
|
|
1148
|
+
LOOPBACK_HOSTS,
|
|
1149
|
+
PARENT_SESSION_KEYS,
|
|
1150
|
+
PROXY_CERTIFICATE_KEY,
|
|
1151
|
+
PROXY_KEYS,
|
|
1152
|
+
SESSION_ID_KEY,
|
|
1153
|
+
removed_environment,
|
|
1154
|
+
removed_proxy_environment
|
|
1155
|
+
};
|
|
1156
|
+
|
|
1157
|
+
// scripts/agent/agent-provider.ts
|
|
1158
|
+
import { z } from "zod";
|
|
1159
|
+
var EMPTY_LENGTH = 0;
|
|
1160
|
+
var PROVIDER_SCHEMA = z.enum(["anthropic", "openai"]);
|
|
1161
|
+
var ANTHROPIC_PROVIDER = "anthropic";
|
|
1162
|
+
var OPENAI_PROVIDER = "openai";
|
|
1163
|
+
var CODEX_SESSION_KEY = "CODEX_THREAD_ID";
|
|
1164
|
+
function trimmed(value) {
|
|
1165
|
+
const result = value?.trim();
|
|
1166
|
+
return result === void 0 || result.length === EMPTY_LENGTH ? void 0 : result;
|
|
1167
|
+
}
|
|
1168
|
+
function rejection(key, value, expected) {
|
|
1169
|
+
return { kind: "rejected", note: `${key}=${value} ${expected}, so the agent was not started` };
|
|
1170
|
+
}
|
|
1171
|
+
function has_session(environment, keys) {
|
|
1172
|
+
return keys.some((key) => trimmed(environment[key]) !== void 0);
|
|
1173
|
+
}
|
|
1174
|
+
var CONFLICTING_SESSIONS = {
|
|
1175
|
+
kind: "rejected",
|
|
1176
|
+
note: "both Codex and Claude Code sessions were detected"
|
|
1177
|
+
};
|
|
1178
|
+
var HANDED_PROVIDER_KEY = "JOSH_AGENT_PROVIDER";
|
|
1179
|
+
var DEFAULT_PROVIDER = {
|
|
1180
|
+
kind: "provider",
|
|
1181
|
+
provider: ANTHROPIC_PROVIDER,
|
|
1182
|
+
is_default: true
|
|
1183
|
+
};
|
|
1184
|
+
var DEFAULT_NOTICE = ` No agent session or ${HANDED_PROVIDER_KEY} was found, so the provider defaulted to ${ANTHROPIC_PROVIDER} (Claude Code).`;
|
|
1185
|
+
function handed_provider(environment) {
|
|
1186
|
+
const value = trimmed(environment[HANDED_PROVIDER_KEY]);
|
|
1187
|
+
if (value === void 0) return DEFAULT_PROVIDER;
|
|
1188
|
+
const parsed = PROVIDER_SCHEMA.safeParse(value);
|
|
1189
|
+
return parsed.success ? { kind: "provider", provider: parsed.data } : rejection(HANDED_PROVIDER_KEY, value, "is not an allowed provider");
|
|
1190
|
+
}
|
|
1191
|
+
function detected_provider(environment) {
|
|
1192
|
+
const has_codex = has_session(environment, [CODEX_SESSION_KEY]);
|
|
1193
|
+
const has_claude = has_session(environment, agent_session_environment.PARENT_SESSION_KEYS);
|
|
1194
|
+
if (has_codex === has_claude) return has_codex ? CONFLICTING_SESSIONS : void 0;
|
|
1195
|
+
return { kind: "provider", provider: has_codex ? OPENAI_PROVIDER : ANTHROPIC_PROVIDER };
|
|
1196
|
+
}
|
|
1197
|
+
function resolve_provider(environment = process.env) {
|
|
1198
|
+
return detected_provider(environment) ?? handed_provider(environment);
|
|
1199
|
+
}
|
|
1200
|
+
function default_notice(environment = process.env) {
|
|
1201
|
+
const selected = resolve_provider(environment);
|
|
1202
|
+
return selected.kind === "provider" && selected.is_default === true ? DEFAULT_NOTICE : "";
|
|
1203
|
+
}
|
|
1204
|
+
function warn_of_default(environment = process.env) {
|
|
1205
|
+
const notice = default_notice(environment).trim();
|
|
1206
|
+
if (notice !== "") console.error(notice);
|
|
1207
|
+
}
|
|
1208
|
+
function has_completion_callback(environment = process.env) {
|
|
1209
|
+
const selected = resolve_provider(environment);
|
|
1210
|
+
return selected.kind !== "provider" || selected.provider !== OPENAI_PROVIDER;
|
|
1211
|
+
}
|
|
1212
|
+
function handoff_environment(environment = process.env) {
|
|
1213
|
+
const selected = resolve_provider(environment);
|
|
1214
|
+
return selected.kind === "provider" ? { [HANDED_PROVIDER_KEY]: selected.provider } : {};
|
|
1215
|
+
}
|
|
1216
|
+
var agent_provider = {
|
|
1217
|
+
ANTHROPIC_PROVIDER,
|
|
1218
|
+
CODEX_SESSION_KEY,
|
|
1219
|
+
HANDED_PROVIDER_KEY,
|
|
1220
|
+
OPENAI_PROVIDER,
|
|
1221
|
+
PROVIDER_SCHEMA,
|
|
1222
|
+
default_notice,
|
|
1223
|
+
handoff_environment,
|
|
1224
|
+
has_completion_callback,
|
|
1225
|
+
rejection,
|
|
1226
|
+
resolve_provider,
|
|
1227
|
+
trimmed,
|
|
1228
|
+
warn_of_default
|
|
1229
|
+
};
|
|
1230
|
+
|
|
1231
|
+
// scripts/agent/agent-safe-text.ts
|
|
1232
|
+
var FIRST_PRINTABLE_CODE = 32;
|
|
1233
|
+
var DELETE_CODE = 127;
|
|
1234
|
+
var FIRST_CODE_POINT = 0;
|
|
1235
|
+
var EMPTY_LENGTH2 = 0;
|
|
1236
|
+
var MAX_VALUE_LENGTH = 4096;
|
|
1237
|
+
var MAX_PROMPT_LENGTH = 65536;
|
|
1238
|
+
var LINE_FEED = "\n";
|
|
1239
|
+
var SPACE = " ";
|
|
1240
|
+
function is_control_character(character) {
|
|
1241
|
+
const code = character.codePointAt(FIRST_CODE_POINT) ?? FIRST_PRINTABLE_CODE;
|
|
1242
|
+
return code < FIRST_PRINTABLE_CODE || code === DELETE_CODE;
|
|
1243
|
+
}
|
|
1244
|
+
function is_line_feed(character) {
|
|
1245
|
+
return character === LINE_FEED;
|
|
1246
|
+
}
|
|
1247
|
+
function is_never_allowed() {
|
|
1248
|
+
return false;
|
|
1249
|
+
}
|
|
1250
|
+
function is_refused(character, is_allowed) {
|
|
1251
|
+
return is_control_character(character) && !is_allowed(character);
|
|
1252
|
+
}
|
|
1253
|
+
function is_safe_text(value, is_allowed, max_length) {
|
|
1254
|
+
if (value.length === EMPTY_LENGTH2 || value.length > max_length) return false;
|
|
1255
|
+
for (const character of value) if (is_refused(character, is_allowed)) return false;
|
|
1256
|
+
return true;
|
|
1257
|
+
}
|
|
1258
|
+
function is_safe_value(value) {
|
|
1259
|
+
return is_safe_text(value, is_never_allowed, MAX_VALUE_LENGTH);
|
|
1260
|
+
}
|
|
1261
|
+
function is_safe_prompt(value) {
|
|
1262
|
+
return is_safe_text(value, is_line_feed, MAX_PROMPT_LENGTH);
|
|
1263
|
+
}
|
|
1264
|
+
function printable_character(character) {
|
|
1265
|
+
return is_refused(character, is_line_feed) ? SPACE : character;
|
|
1266
|
+
}
|
|
1267
|
+
function printable(text) {
|
|
1268
|
+
return Array.from(text, printable_character).join("");
|
|
1269
|
+
}
|
|
1270
|
+
var agent_safe_text = {
|
|
1271
|
+
MAX_PROMPT_LENGTH,
|
|
1272
|
+
MAX_VALUE_LENGTH,
|
|
1273
|
+
is_safe_prompt,
|
|
1274
|
+
is_safe_value,
|
|
1275
|
+
printable
|
|
1276
|
+
};
|
|
1277
|
+
|
|
1278
|
+
// scripts/agent/agent-role-profile.ts
|
|
1279
|
+
var {
|
|
1280
|
+
ANTHROPIC_PROVIDER: ANTHROPIC_PROVIDER2,
|
|
1281
|
+
CODEX_SESSION_KEY: CODEX_SESSION_KEY2,
|
|
1282
|
+
HANDED_PROVIDER_KEY: HANDED_PROVIDER_KEY2,
|
|
1283
|
+
OPENAI_PROVIDER: OPENAI_PROVIDER2,
|
|
1284
|
+
PROVIDER_SCHEMA: PROVIDER_SCHEMA2,
|
|
1285
|
+
default_notice: default_notice2,
|
|
1286
|
+
handoff_environment: handoff_environment2,
|
|
1287
|
+
has_completion_callback: has_completion_callback2,
|
|
1288
|
+
rejection: rejection2,
|
|
1289
|
+
resolve_provider: resolve_provider2,
|
|
1290
|
+
trimmed: trimmed2,
|
|
1291
|
+
warn_of_default: warn_of_default2
|
|
1292
|
+
} = agent_provider;
|
|
1293
|
+
var ROLE_SCHEMA = z2.enum(["scheduler", "worker", "reviewer"]);
|
|
1294
|
+
var EFFORT_SCHEMA = z2.enum(["low", "medium", "high", "xhigh", "max"]);
|
|
1295
|
+
var PHASE_SCHEMA = z2.enum(["implementation", "pre-gate"]);
|
|
1296
|
+
var PROFILE_SCHEMA = z2.object({
|
|
1297
|
+
provider: PROVIDER_SCHEMA2.default("anthropic"),
|
|
1298
|
+
role: ROLE_SCHEMA,
|
|
1299
|
+
model: z2.string(),
|
|
1300
|
+
effort: EFFORT_SCHEMA
|
|
1301
|
+
});
|
|
1302
|
+
var SCHEDULER = "scheduler";
|
|
1303
|
+
var WORKER = "worker";
|
|
1304
|
+
var REVIEWER = "reviewer";
|
|
1305
|
+
var IMPLEMENTATION_PHASE = "implementation";
|
|
1306
|
+
var PRE_GATE_PHASE = "pre-gate";
|
|
1307
|
+
var OPENAI_MODEL = "gpt-6.1-sol";
|
|
1308
|
+
var ANTHROPIC_MODEL = "claude-opus-5-5";
|
|
1309
|
+
var REVIEW_EFFORT = "medium";
|
|
1310
|
+
var VERIFICATION_EFFORT = "high";
|
|
1311
|
+
function role_profiles(provider, model) {
|
|
1312
|
+
return {
|
|
1313
|
+
scheduler: { provider, role: SCHEDULER, model, effort: "medium" },
|
|
1314
|
+
worker: { provider, role: WORKER, model, effort: "medium" },
|
|
1315
|
+
reviewer: { provider, role: REVIEWER, model, effort: REVIEW_EFFORT }
|
|
1316
|
+
};
|
|
1317
|
+
}
|
|
1318
|
+
var DEFAULT_PROFILES = role_profiles(ANTHROPIC_PROVIDER2, ANTHROPIC_MODEL);
|
|
1319
|
+
var OPENAI_PROFILES = role_profiles(OPENAI_PROVIDER2, OPENAI_MODEL);
|
|
1320
|
+
var PROVIDER_PROFILES = { anthropic: DEFAULT_PROFILES, openai: OPENAI_PROFILES };
|
|
1321
|
+
var FIRST_REVIEW_ROUND = 1;
|
|
1322
|
+
var VERIFICATION_MODEL = "claude-sonnet-5-5";
|
|
1323
|
+
var VERIFICATION_PROFILES = {
|
|
1324
|
+
anthropic: {
|
|
1325
|
+
...DEFAULT_PROFILES.reviewer,
|
|
1326
|
+
model: VERIFICATION_MODEL,
|
|
1327
|
+
effort: VERIFICATION_EFFORT
|
|
1328
|
+
},
|
|
1329
|
+
openai: { ...OPENAI_PROFILES.reviewer, effort: VERIFICATION_EFFORT }
|
|
1330
|
+
};
|
|
1331
|
+
var VERIFICATION_KEYS = {
|
|
1332
|
+
model: "JOSH_REVIEWER_VERIFICATION_MODEL",
|
|
1333
|
+
effort: "JOSH_REVIEWER_VERIFICATION_EFFORT"
|
|
1334
|
+
};
|
|
1335
|
+
var SHIP_EFFORT = "low";
|
|
1336
|
+
var PHASE_EFFORT = {
|
|
1337
|
+
worker: { [PRE_GATE_PHASE]: SHIP_EFFORT }
|
|
1338
|
+
};
|
|
1339
|
+
var PHASE_MODEL_KEYS = {
|
|
1340
|
+
worker: { [PRE_GATE_PHASE]: "JOSH_WORKER_SHIP_MODEL" }
|
|
1341
|
+
};
|
|
1342
|
+
var ENV_KEYS = {
|
|
1343
|
+
scheduler: { model: "JOSH_SCHEDULER_MODEL", effort: "JOSH_SCHEDULER_EFFORT" },
|
|
1344
|
+
worker: { model: "JOSH_WORKER_MODEL", effort: "JOSH_WORKER_EFFORT" },
|
|
1345
|
+
reviewer: { model: "JOSH_REVIEWER_MODEL", effort: "JOSH_REVIEWER_EFFORT" }
|
|
1346
|
+
};
|
|
1347
|
+
var LEGACY_WORKER_KEYS = { model: "JOSH_LANE_MODEL", effort: "JOSH_LANE_EFFORT" };
|
|
1348
|
+
var { MAX_VALUE_LENGTH: MAX_VALUE_LENGTH2, is_safe_prompt: is_safe_prompt2, is_safe_value: is_safe_value2, printable: printable2 } = agent_safe_text;
|
|
1349
|
+
function is_verification(role, round) {
|
|
1350
|
+
return role === REVIEWER && round !== void 0 && round > FIRST_REVIEW_ROUND;
|
|
1351
|
+
}
|
|
1352
|
+
function override_keys(role, field, round) {
|
|
1353
|
+
const key = ENV_KEYS[role][field];
|
|
1354
|
+
if (role === WORKER) return [key, LEGACY_WORKER_KEYS[field]];
|
|
1355
|
+
return is_verification(role, round) ? [VERIFICATION_KEYS[field], key] : [key];
|
|
1356
|
+
}
|
|
1357
|
+
function override_value(role, field, environment, round) {
|
|
1358
|
+
const keys = override_keys(role, field, round);
|
|
1359
|
+
const key = keys.find((candidate) => trimmed2(environment[candidate]) !== void 0);
|
|
1360
|
+
return key === void 0 ? { key: keys[0], value: void 0 } : { key, value: trimmed2(environment[key]) };
|
|
1361
|
+
}
|
|
1362
|
+
function phase_entry(table, role, phase) {
|
|
1363
|
+
const parsed = PHASE_SCHEMA.safeParse(phase);
|
|
1364
|
+
return parsed.success ? table[role]?.[parsed.data] : void 0;
|
|
1365
|
+
}
|
|
1366
|
+
function phase_model(role, provider, phase, environment) {
|
|
1367
|
+
const key = provider === OPENAI_PROVIDER2 ? void 0 : phase_entry(PHASE_MODEL_KEYS, role, phase);
|
|
1368
|
+
if (key === void 0) return void 0;
|
|
1369
|
+
const value = trimmed2(environment[key]);
|
|
1370
|
+
return value === void 0 ? void 0 : { key, value };
|
|
1371
|
+
}
|
|
1372
|
+
function model_override(role, environment, provider, stage) {
|
|
1373
|
+
const phased = phase_model(role, provider, stage.phase, environment);
|
|
1374
|
+
if (phased !== void 0) return phased;
|
|
1375
|
+
return provider === OPENAI_PROVIDER2 ? { key: ENV_KEYS[role].model, value: void 0 } : override_value(role, "model", environment, stage.round);
|
|
1376
|
+
}
|
|
1377
|
+
function resolved_effort(override, fallback) {
|
|
1378
|
+
const parsed = EFFORT_SCHEMA.safeParse(override.value ?? fallback);
|
|
1379
|
+
return parsed.success ? { kind: "effort", effort: parsed.data } : rejection2(override.key, override.value ?? "", "is not an allowed effort");
|
|
1380
|
+
}
|
|
1381
|
+
function validate(profile, model_key) {
|
|
1382
|
+
if (!is_safe_value2(profile.model)) {
|
|
1383
|
+
return rejection2(model_key, profile.model, "is not a safe model");
|
|
1384
|
+
}
|
|
1385
|
+
return { kind: "profile", profile };
|
|
1386
|
+
}
|
|
1387
|
+
function phase_effort(role, phase, fallback) {
|
|
1388
|
+
return phase_entry(PHASE_EFFORT, role, phase) ?? fallback;
|
|
1389
|
+
}
|
|
1390
|
+
function overridden_effort(profile, phase, environment) {
|
|
1391
|
+
const parsed = EFFORT_SCHEMA.safeParse(override_value(profile.role, "effort", environment).value);
|
|
1392
|
+
return parsed.success ? parsed.data : phase_effort(profile.role, phase, profile.effort);
|
|
1393
|
+
}
|
|
1394
|
+
function with_phase(profile, phase, environment = process.env) {
|
|
1395
|
+
const effort = overridden_effort(profile, phase, environment);
|
|
1396
|
+
const model = phase_model(profile.role, profile.provider, phase, environment);
|
|
1397
|
+
if (model === void 0) return { kind: "profile", profile: { ...profile, effort } };
|
|
1398
|
+
return validate({ ...profile, model: model.value, effort }, model.key);
|
|
1399
|
+
}
|
|
1400
|
+
function stage_defaults(provider, role, round) {
|
|
1401
|
+
return is_verification(role, round) ? VERIFICATION_PROFILES[provider] : PROVIDER_PROFILES[provider][role];
|
|
1402
|
+
}
|
|
1403
|
+
function resolve_stage(role, environment, stage) {
|
|
1404
|
+
const selected = resolve_provider2(environment);
|
|
1405
|
+
if (selected.kind === "rejected") return selected;
|
|
1406
|
+
const defaults = stage_defaults(selected.provider, role, stage.round);
|
|
1407
|
+
const model = model_override(role, environment, selected.provider, stage);
|
|
1408
|
+
const effort = override_value(role, "effort", environment, stage.round);
|
|
1409
|
+
const resolved = resolved_effort(effort, phase_effort(role, stage.phase, defaults.effort));
|
|
1410
|
+
if (resolved.kind === "rejected") return resolved;
|
|
1411
|
+
const profile = {
|
|
1412
|
+
provider: selected.provider,
|
|
1413
|
+
role,
|
|
1414
|
+
model: model.value ?? defaults.model,
|
|
1415
|
+
effort: resolved.effort
|
|
1416
|
+
};
|
|
1417
|
+
return validate(profile, model.key);
|
|
1418
|
+
}
|
|
1419
|
+
function resolve(role, environment = process.env, phase) {
|
|
1420
|
+
return resolve_stage(role, environment, { phase });
|
|
1421
|
+
}
|
|
1422
|
+
function resolve_review(round, environment = process.env) {
|
|
1423
|
+
return resolve_stage(REVIEWER, environment, { round });
|
|
1424
|
+
}
|
|
1425
|
+
function describe(profile) {
|
|
1426
|
+
return `provider=${profile.provider} role=${profile.role} model=${profile.model} effort=${profile.effort}`;
|
|
1427
|
+
}
|
|
1428
|
+
function describe_review(round, profile) {
|
|
1429
|
+
return `review round ${String(round)} \xB7 ${describe(profile)}`;
|
|
1430
|
+
}
|
|
1431
|
+
function parse(value) {
|
|
1432
|
+
const parsed = PROFILE_SCHEMA.safeParse(value);
|
|
1433
|
+
return parsed.success && is_safe_value2(parsed.data.model) ? parsed.data : void 0;
|
|
1434
|
+
}
|
|
1435
|
+
var agent_role_profile = {
|
|
1436
|
+
CODEX_SESSION_KEY: CODEX_SESSION_KEY2,
|
|
1437
|
+
DEFAULT_PROFILES,
|
|
1438
|
+
HANDED_PROVIDER_KEY: HANDED_PROVIDER_KEY2,
|
|
1439
|
+
IMPLEMENTATION_PHASE,
|
|
1440
|
+
MAX_VALUE_LENGTH: MAX_VALUE_LENGTH2,
|
|
1441
|
+
OPENAI_PROFILES,
|
|
1442
|
+
PRE_GATE_PHASE,
|
|
1443
|
+
PROFILE_SCHEMA,
|
|
1444
|
+
REVIEWER,
|
|
1445
|
+
SCHEDULER,
|
|
1446
|
+
VERIFICATION_PROFILES,
|
|
1447
|
+
WORKER,
|
|
1448
|
+
default_notice: default_notice2,
|
|
1449
|
+
describe,
|
|
1450
|
+
describe_review,
|
|
1451
|
+
handoff_environment: handoff_environment2,
|
|
1452
|
+
has_completion_callback: has_completion_callback2,
|
|
1453
|
+
is_safe_prompt: is_safe_prompt2,
|
|
1454
|
+
is_safe_value: is_safe_value2,
|
|
1455
|
+
parse,
|
|
1456
|
+
printable: printable2,
|
|
1457
|
+
resolve,
|
|
1458
|
+
resolve_provider: resolve_provider2,
|
|
1459
|
+
resolve_review,
|
|
1460
|
+
warn_of_default: warn_of_default2,
|
|
1461
|
+
with_phase
|
|
1462
|
+
};
|
|
1463
|
+
|
|
1464
|
+
// scripts/time-runtime/time-instant.ts
|
|
1465
|
+
function parse_instant(raw) {
|
|
1466
|
+
if (raw === null || raw === void 0) return void 0;
|
|
1467
|
+
const parsed = Date.parse(raw);
|
|
1468
|
+
return Number.isNaN(parsed) ? void 0 : parsed;
|
|
1469
|
+
}
|
|
1470
|
+
var time_instant = { parse_instant };
|
|
1471
|
+
|
|
1472
|
+
// scripts/cost-runtime/cost-usage.ts
|
|
1473
|
+
import { z as z3 } from "zod";
|
|
1474
|
+
var CACHE_CREATION_SCHEMA = z3.object({
|
|
1475
|
+
ephemeral_1h_input_tokens: z3.number().nullish(),
|
|
1476
|
+
ephemeral_5m_input_tokens: z3.number().nullish()
|
|
1477
|
+
});
|
|
1478
|
+
var USAGE_SCHEMA = z3.object({
|
|
1479
|
+
input_tokens: z3.number(),
|
|
1480
|
+
cache_creation_input_tokens: z3.number().nullish(),
|
|
1481
|
+
cache_read_input_tokens: z3.number().nullish(),
|
|
1482
|
+
output_tokens: z3.number(),
|
|
1483
|
+
output_tokens_details: z3.object({ thinking_tokens: z3.number().nullish() }).nullish(),
|
|
1484
|
+
cache_creation: CACHE_CREATION_SCHEMA.nullish()
|
|
1485
|
+
});
|
|
1486
|
+
var MESSAGE_SCHEMA = z3.object({
|
|
1487
|
+
id: z3.string().nullish(),
|
|
1488
|
+
model: z3.string().nullish(),
|
|
1489
|
+
usage: USAGE_SCHEMA.nullish()
|
|
1490
|
+
});
|
|
1491
|
+
var LINE_SCHEMA = z3.object({
|
|
1492
|
+
type: z3.string(),
|
|
1493
|
+
requestId: z3.string().nullish(),
|
|
1494
|
+
uuid: z3.string().nullish(),
|
|
1495
|
+
gitBranch: z3.string().nullish(),
|
|
1496
|
+
timestamp: z3.string().nullish(),
|
|
1497
|
+
message: MESSAGE_SCHEMA.nullish()
|
|
1498
|
+
});
|
|
1499
|
+
var SYNTHETIC_MODEL = "<synthetic>";
|
|
1500
|
+
var EMPTY_TOTALS = {
|
|
1501
|
+
input_tokens: 0,
|
|
1502
|
+
cache_write_5m_tokens: 0,
|
|
1503
|
+
cache_write_1h_tokens: 0,
|
|
1504
|
+
cache_read_tokens: 0,
|
|
1505
|
+
output_tokens: 0,
|
|
1506
|
+
thinking_tokens: 0,
|
|
1507
|
+
thinking_measured: false
|
|
1508
|
+
};
|
|
1509
|
+
var UNKNOWN_MODEL = "unknown";
|
|
1510
|
+
var UNKNOWN_BRANCH = "";
|
|
1511
|
+
function split_cache_write(usage) {
|
|
1512
|
+
const total3 = usage.cache_creation_input_tokens ?? 0;
|
|
1513
|
+
const detail = usage.cache_creation;
|
|
1514
|
+
if (!detail) return { write_5m: total3, write_1h: 0 };
|
|
1515
|
+
const write_1h = detail.ephemeral_1h_input_tokens ?? 0;
|
|
1516
|
+
return { write_5m: detail.ephemeral_5m_input_tokens ?? total3 - write_1h, write_1h };
|
|
1517
|
+
}
|
|
1518
|
+
function thinking_usage(usage) {
|
|
1519
|
+
const raw = usage.output_tokens_details?.thinking_tokens;
|
|
1520
|
+
return { tokens: raw ?? 0, measured: raw !== null && raw !== void 0 };
|
|
1521
|
+
}
|
|
1522
|
+
function to_totals(usage) {
|
|
1523
|
+
const { write_5m, write_1h } = split_cache_write(usage);
|
|
1524
|
+
const thinking = thinking_usage(usage);
|
|
1525
|
+
return {
|
|
1526
|
+
input_tokens: usage.input_tokens,
|
|
1527
|
+
cache_write_5m_tokens: write_5m,
|
|
1528
|
+
cache_write_1h_tokens: write_1h,
|
|
1529
|
+
cache_read_tokens: usage.cache_read_input_tokens ?? 0,
|
|
1530
|
+
output_tokens: usage.output_tokens,
|
|
1531
|
+
thinking_tokens: thinking.tokens,
|
|
1532
|
+
thinking_measured: thinking.measured
|
|
1533
|
+
};
|
|
1534
|
+
}
|
|
1535
|
+
function declared_id(data) {
|
|
1536
|
+
return data.requestId ?? data.message?.id ?? data.uuid ?? void 0;
|
|
1537
|
+
}
|
|
1538
|
+
function request_id_of(data, usage) {
|
|
1539
|
+
const fallback = `${data.timestamp ?? ""}-${String(usage.output_tokens)}`;
|
|
1540
|
+
return declared_id(data) ?? fallback;
|
|
1541
|
+
}
|
|
1542
|
+
function to_record(data, usage) {
|
|
1543
|
+
return {
|
|
1544
|
+
request_id: request_id_of(data, usage),
|
|
1545
|
+
model: data.message?.model ?? UNKNOWN_MODEL,
|
|
1546
|
+
branch: data.gitBranch ?? UNKNOWN_BRANCH,
|
|
1547
|
+
at_ms: time_instant.parse_instant(data.timestamp),
|
|
1548
|
+
totals: to_totals(usage)
|
|
1549
|
+
};
|
|
1550
|
+
}
|
|
1551
|
+
var ASSISTANT_TYPE = "assistant";
|
|
1552
|
+
function is_priced_line(data) {
|
|
1553
|
+
return data.type === ASSISTANT_TYPE && data.message?.model !== SYNTHETIC_MODEL;
|
|
1554
|
+
}
|
|
1555
|
+
function classify(data) {
|
|
1556
|
+
if (!is_priced_line(data)) return { kind: "skipped" };
|
|
1557
|
+
const usage = data.message?.usage;
|
|
1558
|
+
return usage ? { kind: "record", record: to_record(data, usage) } : { kind: "no_usage" };
|
|
1559
|
+
}
|
|
1560
|
+
function parse_line(line) {
|
|
1561
|
+
if (line.trim() === "") return { kind: "skipped" };
|
|
1562
|
+
const parsed = LINE_SCHEMA.safeParse(json_value.parse_or_undefined(line));
|
|
1563
|
+
return parsed.success ? classify(parsed.data) : { kind: "malformed" };
|
|
1564
|
+
}
|
|
1565
|
+
function later_instant(left, right) {
|
|
1566
|
+
if (left === void 0) return right;
|
|
1567
|
+
if (right === void 0) return left;
|
|
1568
|
+
return Math.max(left, right);
|
|
1569
|
+
}
|
|
1570
|
+
function dedupe2(records) {
|
|
1571
|
+
const by_id = /* @__PURE__ */ new Map();
|
|
1572
|
+
for (const record of records) {
|
|
1573
|
+
const seen = by_id.get(record.request_id);
|
|
1574
|
+
const at_ms = later_instant(seen?.at_ms, record.at_ms);
|
|
1575
|
+
by_id.set(record.request_id, { ...seen ?? record, at_ms });
|
|
1576
|
+
}
|
|
1577
|
+
return [...by_id.values()];
|
|
1578
|
+
}
|
|
1579
|
+
function add_totals(left, right) {
|
|
1580
|
+
return {
|
|
1581
|
+
input_tokens: left.input_tokens + right.input_tokens,
|
|
1582
|
+
cache_write_5m_tokens: left.cache_write_5m_tokens + right.cache_write_5m_tokens,
|
|
1583
|
+
cache_write_1h_tokens: left.cache_write_1h_tokens + right.cache_write_1h_tokens,
|
|
1584
|
+
cache_read_tokens: left.cache_read_tokens + right.cache_read_tokens,
|
|
1585
|
+
output_tokens: left.output_tokens + right.output_tokens,
|
|
1586
|
+
thinking_tokens: left.thinking_tokens + right.thinking_tokens,
|
|
1587
|
+
thinking_measured: left.thinking_measured || right.thinking_measured
|
|
1588
|
+
};
|
|
1589
|
+
}
|
|
1590
|
+
function sum_totals(records) {
|
|
1591
|
+
let total3 = EMPTY_TOTALS;
|
|
1592
|
+
for (const record of records) total3 = add_totals(total3, record.totals);
|
|
1593
|
+
return total3;
|
|
1594
|
+
}
|
|
1595
|
+
function billed_input(totals) {
|
|
1596
|
+
return totals.input_tokens + totals.cache_write_5m_tokens + totals.cache_write_1h_tokens + totals.cache_read_tokens;
|
|
1597
|
+
}
|
|
1598
|
+
var cost_usage = {
|
|
1599
|
+
EMPTY_TOTALS,
|
|
1600
|
+
UNKNOWN_MODEL,
|
|
1601
|
+
SYNTHETIC_MODEL,
|
|
1602
|
+
parse_line,
|
|
1603
|
+
dedupe: dedupe2,
|
|
1604
|
+
add_totals,
|
|
1605
|
+
sum_totals,
|
|
1606
|
+
billed_input
|
|
1607
|
+
};
|
|
1608
|
+
|
|
1609
|
+
// scripts/cost-runtime/cost-pricing.ts
|
|
1610
|
+
var CACHE_WRITE_5M_MULTIPLIER = 1.25;
|
|
1611
|
+
var CACHE_WRITE_1H_MULTIPLIER = 2;
|
|
1612
|
+
var DEFAULT_CACHE_READ_MULTIPLIER = 0.1;
|
|
1613
|
+
var HALVED_CACHE_READ_MULTIPLIER = 0.05;
|
|
1614
|
+
var QUARTERED_CACHE_READ_MULTIPLIER = 0.025;
|
|
1615
|
+
var TOKENS_PER_MILLION = 1e6;
|
|
1616
|
+
var LONG_PROMPT_SUFFIX = ":long-prompt";
|
|
1617
|
+
var LONG_PROMPT_THRESHOLD = 1e5;
|
|
1618
|
+
var MODEL_PRICES = {
|
|
1619
|
+
"claude-fable-5-1": {
|
|
1620
|
+
input: 10,
|
|
1621
|
+
output: 50,
|
|
1622
|
+
cache_read_multiplier: QUARTERED_CACHE_READ_MULTIPLIER
|
|
1623
|
+
},
|
|
1624
|
+
"claude-mythos-5-1": {
|
|
1625
|
+
input: 10,
|
|
1626
|
+
output: 50,
|
|
1627
|
+
cache_read_multiplier: QUARTERED_CACHE_READ_MULTIPLIER
|
|
1628
|
+
},
|
|
1629
|
+
"claude-fable-5": { input: 10, output: 50 },
|
|
1630
|
+
"claude-mythos-5": { input: 10, output: 50 },
|
|
1631
|
+
"claude-opus-5-5": { input: 4, output: 20, cache_read_multiplier: HALVED_CACHE_READ_MULTIPLIER },
|
|
1632
|
+
"claude-opus-5": { input: 5, output: 25 },
|
|
1633
|
+
"claude-opus-4-8": { input: 5, output: 25 },
|
|
1634
|
+
"claude-opus-4-7": { input: 5, output: 25 },
|
|
1635
|
+
"claude-opus-4-6": { input: 5, output: 25 },
|
|
1636
|
+
"claude-sonnet-5-5": {
|
|
1637
|
+
input: 2,
|
|
1638
|
+
output: 10,
|
|
1639
|
+
cache_read_multiplier: HALVED_CACHE_READ_MULTIPLIER
|
|
1640
|
+
},
|
|
1641
|
+
"claude-sonnet-5": { input: 2, output: 10 },
|
|
1642
|
+
"claude-sonnet-4-6": { input: 3, output: 15 },
|
|
1643
|
+
"claude-haiku-5-5": { input: 0.1, output: 0.5 },
|
|
1644
|
+
[`claude-haiku-5-5${LONG_PROMPT_SUFFIX}`]: { input: 0.5, output: 2.5 },
|
|
1645
|
+
"claude-haiku-4-5": { input: 1, output: 5 }
|
|
1646
|
+
};
|
|
1647
|
+
var CONTEXT_MARKER = "[";
|
|
1648
|
+
var DATE_SUFFIX = /-\d{8}$/u;
|
|
1649
|
+
function known_id(model) {
|
|
1650
|
+
const base = model.split(CONTEXT_MARKER)[0] ?? model;
|
|
1651
|
+
return [base, base.replace(DATE_SUFFIX, "")].find((id) => Object.hasOwn(MODEL_PRICES, id));
|
|
1652
|
+
}
|
|
1653
|
+
function resolve_price(model) {
|
|
1654
|
+
const id = known_id(model);
|
|
1655
|
+
return id === void 0 ? void 0 : MODEL_PRICES[id];
|
|
1656
|
+
}
|
|
1657
|
+
function cache_read_multiplier(price) {
|
|
1658
|
+
return price.cache_read_multiplier ?? DEFAULT_CACHE_READ_MULTIPLIER;
|
|
1659
|
+
}
|
|
1660
|
+
function cache_read_multiplier_of(model) {
|
|
1661
|
+
const price = model === void 0 ? void 0 : resolve_price(model);
|
|
1662
|
+
return price === void 0 ? DEFAULT_CACHE_READ_MULTIPLIER : cache_read_multiplier(price);
|
|
1663
|
+
}
|
|
1664
|
+
function estimate_cost(totals, price) {
|
|
1665
|
+
const weighted_input = totals.input_tokens + totals.cache_write_5m_tokens * CACHE_WRITE_5M_MULTIPLIER + totals.cache_write_1h_tokens * CACHE_WRITE_1H_MULTIPLIER + totals.cache_read_tokens * cache_read_multiplier(price);
|
|
1666
|
+
return (weighted_input * price.input + totals.output_tokens * price.output) / TOKENS_PER_MILLION;
|
|
1667
|
+
}
|
|
1668
|
+
function priced(tokens, rate) {
|
|
1669
|
+
return tokens * rate / TOKENS_PER_MILLION;
|
|
1670
|
+
}
|
|
1671
|
+
function estimate_composition(totals, price) {
|
|
1672
|
+
return {
|
|
1673
|
+
input_usd: priced(totals.input_tokens, price.input),
|
|
1674
|
+
cache_write_5m_usd: priced(
|
|
1675
|
+
totals.cache_write_5m_tokens * CACHE_WRITE_5M_MULTIPLIER,
|
|
1676
|
+
price.input
|
|
1677
|
+
),
|
|
1678
|
+
cache_write_1h_usd: priced(
|
|
1679
|
+
totals.cache_write_1h_tokens * CACHE_WRITE_1H_MULTIPLIER,
|
|
1680
|
+
price.input
|
|
1681
|
+
),
|
|
1682
|
+
cache_read_usd: priced(totals.cache_read_tokens * cache_read_multiplier(price), price.input),
|
|
1683
|
+
output_usd: priced(totals.output_tokens, price.output)
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
function to_model_cost(model, totals) {
|
|
1687
|
+
const price = resolve_price(model);
|
|
1688
|
+
if (price === void 0) return { model, totals };
|
|
1689
|
+
return { model, totals, cost_usd: estimate_cost(totals, price) };
|
|
1690
|
+
}
|
|
1691
|
+
function billed_model(usage) {
|
|
1692
|
+
const long_id = `${known_id(usage.model) ?? usage.model}${LONG_PROMPT_SUFFIX}`;
|
|
1693
|
+
const is_long = cost_usage.billed_input(usage.totals) > LONG_PROMPT_THRESHOLD;
|
|
1694
|
+
return is_long && Object.hasOwn(MODEL_PRICES, long_id) ? long_id : usage.model;
|
|
1695
|
+
}
|
|
1696
|
+
function cost_by_model(records) {
|
|
1697
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
1698
|
+
for (const record of records) {
|
|
1699
|
+
const model = billed_model(record);
|
|
1700
|
+
const running = grouped.get(model) ?? cost_usage.EMPTY_TOTALS;
|
|
1701
|
+
grouped.set(model, cost_usage.add_totals(running, record.totals));
|
|
1702
|
+
}
|
|
1703
|
+
return [...grouped].map(([model, totals]) => to_model_cost(model, totals));
|
|
1704
|
+
}
|
|
1705
|
+
function total_cost(costs) {
|
|
1706
|
+
return {
|
|
1707
|
+
usd: costs.reduce((sum, entry) => sum + (entry.cost_usd ?? 0), 0),
|
|
1708
|
+
unpriced: costs.filter((entry) => entry.cost_usd === void 0).map((entry) => entry.model)
|
|
1709
|
+
};
|
|
1710
|
+
}
|
|
1711
|
+
function cost_of3(records) {
|
|
1712
|
+
return total_cost(cost_by_model(records)).usd;
|
|
1713
|
+
}
|
|
1714
|
+
var cost_pricing = {
|
|
1715
|
+
CACHE_WRITE_5M_MULTIPLIER,
|
|
1716
|
+
CACHE_WRITE_1H_MULTIPLIER,
|
|
1717
|
+
DEFAULT_CACHE_READ_MULTIPLIER,
|
|
1718
|
+
LONG_PROMPT_THRESHOLD,
|
|
1719
|
+
resolve_price,
|
|
1720
|
+
cache_read_multiplier_of,
|
|
1721
|
+
estimate_cost,
|
|
1722
|
+
estimate_composition,
|
|
1723
|
+
cost_by_model,
|
|
1724
|
+
total_cost,
|
|
1725
|
+
cost_of: cost_of3
|
|
1726
|
+
};
|
|
1727
|
+
|
|
1728
|
+
// scripts/document/read-set-pricing.ts
|
|
1729
|
+
var ASSUMED_REQUESTS = 118;
|
|
1730
|
+
var REFERENCE_MODEL = agent_role_profile.DEFAULT_PROFILES.worker.model;
|
|
1731
|
+
function dollars_per_run(tokens) {
|
|
1732
|
+
const price = cost_pricing.resolve_price(REFERENCE_MODEL);
|
|
1733
|
+
if (price === void 0) return 0;
|
|
1734
|
+
return cost_pricing.estimate_cost(
|
|
1735
|
+
{ ...cost_usage.EMPTY_TOTALS, cache_read_tokens: tokens * ASSUMED_REQUESTS },
|
|
1736
|
+
price
|
|
1737
|
+
);
|
|
1738
|
+
}
|
|
1739
|
+
var read_set_pricing = {
|
|
1740
|
+
ASSUMED_REQUESTS,
|
|
1741
|
+
REFERENCE_MODEL,
|
|
1742
|
+
dollars_per_run
|
|
1743
|
+
};
|
|
1744
|
+
|
|
1745
|
+
// scripts/document/read-set-cli.ts
|
|
1746
|
+
var { BACKLOGRUN: BACKLOGRUN2 } = backlogrun_parent_read_set;
|
|
1747
|
+
var ARGV_OFFSET = 2;
|
|
1748
|
+
var FAILURE_EXIT_CODE = 1;
|
|
1749
|
+
var FLAG_PREFIX = "-";
|
|
1750
|
+
var JSON_FLAG = "--json";
|
|
1751
|
+
var JSON_INDENT = 2;
|
|
1752
|
+
var NOTHING3 = 0;
|
|
1753
|
+
var PERCENT = 100;
|
|
1754
|
+
var LABEL_GUTTER = 4;
|
|
1755
|
+
var NUMBER_WIDTH = 9;
|
|
1756
|
+
var DOLLAR_WIDTH = 7;
|
|
1757
|
+
var DOLLAR_DECIMALS = 2;
|
|
1758
|
+
var PREMISE = ` $ = cost per run, assuming a ${String(read_set_pricing.ASSUMED_REQUESTS)}-request run (each entry-read token re-read from cache per request)`;
|
|
1759
|
+
var USAGE = "Usage: josh read:set [<entry>] [--json]";
|
|
1760
|
+
var WHOLE_LABEL = "whole \u2014 every referenced file read in full";
|
|
1761
|
+
var SCOPED_LABEL = "scoped \u2014 referenced sections only";
|
|
1762
|
+
var TOTAL_READ_LABEL = "total read \u2014 scoped entry plus point-of-use reached";
|
|
1763
|
+
var SECTION_LABEL = "-- sections referenced out of the set --";
|
|
1764
|
+
var POINT_OF_USE_LABEL = "-- read at the point of use, not at the entry --";
|
|
1765
|
+
var LANE_CHILD_NOTE = [
|
|
1766
|
+
" a dispatched lane child (`JOSH_LANE_CHILD`) reads this trimmed set:",
|
|
1767
|
+
" - skips the point-of-use documents the parent owns \u2014 child dispatch, lane opening, the progress watcher and the hand-off",
|
|
1768
|
+
" - omits SKILL.md \xA70/\xA73 \u2014 dispatch already authorized the run and a leaf child edits no rule"
|
|
1769
|
+
];
|
|
1770
|
+
var BACKLOGRUN_PARENT_NOTE = [
|
|
1771
|
+
" the backlogrun parent (scheduler) reads this trimmed set:",
|
|
1772
|
+
" - omits SKILL.md \xA73 \u2014 the parent edits no rule mid-run",
|
|
1773
|
+
" - keeps every point-of-use document \u2014 the parent is the one dispatching children and running lanes"
|
|
1774
|
+
];
|
|
1775
|
+
var FETCH_RULE = "fetch: one `Read` call per file \u2014 never `cat`, and never two files in one command.";
|
|
1776
|
+
var OVER_CAP_NOTE = " Read (over the Bash cap)";
|
|
1777
|
+
var UNDER_CAP_NOTE = " Read";
|
|
1778
|
+
function to_number(value) {
|
|
1779
|
+
return value.toLocaleString("en-US").padStart(NUMBER_WIDTH);
|
|
1780
|
+
}
|
|
1781
|
+
function to_dollars(tokens) {
|
|
1782
|
+
return `$${read_set_pricing.dollars_per_run(tokens).toFixed(DOLLAR_DECIMALS)}`.padStart(
|
|
1783
|
+
DOLLAR_WIDTH
|
|
1784
|
+
);
|
|
1785
|
+
}
|
|
1786
|
+
function row(label, cost, width, note = "") {
|
|
1787
|
+
return ` ${label.padEnd(width)}${to_number(cost.tokens)} tok ${to_number(cost.bytes)} B ${to_dollars(cost.tokens)}${note}`;
|
|
1788
|
+
}
|
|
1789
|
+
function fetch_note(bytes, cap) {
|
|
1790
|
+
return bytes > cap ? OVER_CAP_NOTE : UNDER_CAP_NOTE;
|
|
1791
|
+
}
|
|
1792
|
+
function section_label(section2) {
|
|
1793
|
+
const mark = section2.is_resolved ? "" : " (unresolved \u2014 charged whole)";
|
|
1794
|
+
return `${section2.file} \u2192 "${section2.heading}"${mark}`;
|
|
1795
|
+
}
|
|
1796
|
+
function point_of_use_label(section2) {
|
|
1797
|
+
return section2.heading === "" ? section2.file : section_label(section2);
|
|
1798
|
+
}
|
|
1799
|
+
function saved_percent(report) {
|
|
1800
|
+
if (report.whole.tokens === NOTHING3) return NOTHING3;
|
|
1801
|
+
return Math.round((report.whole.tokens - report.scoped.tokens) / report.whole.tokens * PERCENT);
|
|
1802
|
+
}
|
|
1803
|
+
function labels_of(report) {
|
|
1804
|
+
return [
|
|
1805
|
+
...report.files.map((entry) => entry.file),
|
|
1806
|
+
...report.sections.map((section2) => section_label(section2)),
|
|
1807
|
+
...report.point_of_use.map((entry) => point_of_use_label(entry)),
|
|
1808
|
+
WHOLE_LABEL,
|
|
1809
|
+
SCOPED_LABEL,
|
|
1810
|
+
TOTAL_READ_LABEL
|
|
1811
|
+
];
|
|
1812
|
+
}
|
|
1813
|
+
function total_read(report) {
|
|
1814
|
+
return entry_read_set.total([report.scoped, ...report.point_of_use.map((one) => one.cost)]);
|
|
1815
|
+
}
|
|
1816
|
+
function label_width(report) {
|
|
1817
|
+
return Math.max(...labels_of(report).map((label) => label.length)) + LABEL_GUTTER;
|
|
1818
|
+
}
|
|
1819
|
+
function file_lines(report, width) {
|
|
1820
|
+
return report.files.map(
|
|
1821
|
+
(entry) => row(entry.file, entry.cost, width, fetch_note(entry.cost.bytes, report.bash_output_cap))
|
|
1822
|
+
);
|
|
1823
|
+
}
|
|
1824
|
+
function point_of_use_lines(report, width) {
|
|
1825
|
+
if (report.point_of_use.length === NOTHING3) return [];
|
|
1826
|
+
return [
|
|
1827
|
+
` ${POINT_OF_USE_LABEL}`,
|
|
1828
|
+
...report.point_of_use.map((entry) => row(point_of_use_label(entry), entry.cost, width))
|
|
1829
|
+
];
|
|
1830
|
+
}
|
|
1831
|
+
function fetch_lines(report) {
|
|
1832
|
+
const cap = report.bash_output_cap.toLocaleString("en-US");
|
|
1833
|
+
return [
|
|
1834
|
+
` ${FETCH_RULE}`,
|
|
1835
|
+
` A Bash result is truncated past ${cap} characters, so a \`cat\` of any file marked`,
|
|
1836
|
+
` \`${OVER_CAP_NOTE.trim()}\` returns a preview rather than the file, and it is then read a second time.`,
|
|
1837
|
+
""
|
|
1838
|
+
];
|
|
1839
|
+
}
|
|
1840
|
+
function section_lines(report, width) {
|
|
1841
|
+
if (report.sections.length === NOTHING3) return [];
|
|
1842
|
+
return [
|
|
1843
|
+
` ${SECTION_LABEL}`,
|
|
1844
|
+
...report.sections.map((section2) => row(section_label(section2), section2.cost, width))
|
|
1845
|
+
];
|
|
1846
|
+
}
|
|
1847
|
+
function total_lines(report, width) {
|
|
1848
|
+
const saved = report.whole.tokens - report.scoped.tokens;
|
|
1849
|
+
return [
|
|
1850
|
+
"",
|
|
1851
|
+
row(WHOLE_LABEL, report.whole, width),
|
|
1852
|
+
row(SCOPED_LABEL, report.scoped, width),
|
|
1853
|
+
row(TOTAL_READ_LABEL, total_read(report), width),
|
|
1854
|
+
` saved by reading sections: ${saved.toLocaleString("en-US")} tok (${String(saved_percent(report))}%)`,
|
|
1855
|
+
""
|
|
1856
|
+
];
|
|
1857
|
+
}
|
|
1858
|
+
function note_lines(report) {
|
|
1859
|
+
if (report.entry === lane_child_read_set.LANE_CHILD) {
|
|
1860
|
+
return [...LANE_CHILD_NOTE, lane_instructions.resident_line(), ""];
|
|
1861
|
+
}
|
|
1862
|
+
if (report.entry === BACKLOGRUN2) return [...BACKLOGRUN_PARENT_NOTE, ""];
|
|
1863
|
+
return [];
|
|
1864
|
+
}
|
|
1865
|
+
function report_lines(report) {
|
|
1866
|
+
const width = label_width(report);
|
|
1867
|
+
return [
|
|
1868
|
+
`entry: ${report.entry}`,
|
|
1869
|
+
PREMISE,
|
|
1870
|
+
...note_lines(report),
|
|
1871
|
+
...file_lines(report, width),
|
|
1872
|
+
...section_lines(report, width),
|
|
1873
|
+
...point_of_use_lines(report, width),
|
|
1874
|
+
...total_lines(report, width),
|
|
1875
|
+
...fetch_lines(report)
|
|
1876
|
+
];
|
|
1877
|
+
}
|
|
1878
|
+
function known_entries(root) {
|
|
1879
|
+
return [...entry_read_set.entries(root), lane_child_read_set.LANE_CHILD];
|
|
1880
|
+
}
|
|
1881
|
+
function wanted_entries(argv, root) {
|
|
1882
|
+
const named = argv.filter((value) => !value.startsWith(FLAG_PREFIX));
|
|
1883
|
+
return named.length > NOTHING3 ? named : known_entries(root);
|
|
1884
|
+
}
|
|
1885
|
+
function unknown_entries(wanted, root) {
|
|
1886
|
+
const known = known_entries(root);
|
|
1887
|
+
return wanted.filter((entry) => !known.includes(entry));
|
|
1888
|
+
}
|
|
1889
|
+
function costed_entry(root, entry) {
|
|
1890
|
+
if (entry === lane_child_read_set.LANE_CHILD) return lane_child_read_set.costed(root);
|
|
1891
|
+
if (entry === BACKLOGRUN2) return backlogrun_parent_read_set.costed(root);
|
|
1892
|
+
return entry_read_set.costed(root, entry);
|
|
1893
|
+
}
|
|
1894
|
+
function printed(reports, is_json) {
|
|
1895
|
+
if (is_json) return JSON.stringify(reports, void 0, JSON_INDENT);
|
|
1896
|
+
return reports.flatMap((report) => report_lines(report)).join("\n");
|
|
1897
|
+
}
|
|
1898
|
+
function run(argv, root = process.cwd()) {
|
|
1899
|
+
const wanted = wanted_entries(argv, root);
|
|
1900
|
+
const unknown = unknown_entries(wanted, root);
|
|
1901
|
+
if (wanted.length === NOTHING3 || unknown.length > NOTHING3) {
|
|
1902
|
+
console.error(`${USAGE}
|
|
1903
|
+
Known entries: ${known_entries(root).join(", ")}`);
|
|
1904
|
+
return FAILURE_EXIT_CODE;
|
|
1905
|
+
}
|
|
1906
|
+
const reports = wanted.map((entry) => costed_entry(root, entry));
|
|
1907
|
+
console.info(printed(reports, argv.includes(JSON_FLAG)));
|
|
1908
|
+
return 0;
|
|
1909
|
+
}
|
|
1910
|
+
function main(argv) {
|
|
1911
|
+
process.exitCode = run(argv);
|
|
1912
|
+
}
|
|
1913
|
+
var read_set_cli = {
|
|
1914
|
+
FETCH_RULE,
|
|
1915
|
+
JSON_FLAG,
|
|
1916
|
+
POINT_OF_USE_LABEL,
|
|
1917
|
+
SCOPED_LABEL,
|
|
1918
|
+
TOTAL_READ_LABEL,
|
|
1919
|
+
WHOLE_LABEL,
|
|
1920
|
+
known_entries,
|
|
1921
|
+
run,
|
|
1922
|
+
saved_percent
|
|
1923
|
+
};
|
|
1924
|
+
if (process.argv[1] === fileURLToPath3(import.meta.url)) main(process.argv.slice(ARGV_OFFSET));
|
|
1925
|
+
export {
|
|
1926
|
+
read_set_cli
|
|
1927
|
+
};
|