@cbartens/bkit 6.0.0 → 6.1.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/.bkit/README.md +154 -151
- package/.bkit/core/.agents/context.md +95 -29
- package/.bkit/core/.agents/docs.md +17 -15
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-gateguard.cjs +1 -0
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +6 -5
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-readguard.cjs +1 -0
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-rules.cjs +65 -0
- package/.bkit/core/.agents/rules.md +108 -107
- package/.bkit/core/.agents/skills.md +63 -15
- package/.bkit/core/.bkit/README.md +154 -151
- package/.bkit/core/.bkit/authoring.md +714 -84
- package/.bkit/core/.bkit/cli.md +407 -0
- package/.bkit/core/.bkit/cloud.md +281 -193
- package/.bkit/core/.bkit/comparison.md +43 -41
- package/.bkit/core/.bkit/install.md +154 -84
- package/.bkit/core/.bkit/jsonl.md +193 -130
- package/.bkit/core/.bkit/pipeline.md +114 -114
- package/.bkit/core/.bkit/prompts.md +272 -165
- package/.bkit/core/.bkit/providers.md +457 -271
- package/.bkit/core/.bkit/router.md +69 -0
- package/.bkit/core/.bkit/templates.md +529 -256
- package/.bkit/core/.bkit/trackers.md +80 -52
- package/.bkit/core/.bkit/workflows.md +589 -504
- package/.bkit/core/.claude/hooks/bkit-gateguard.cjs +2 -2
- package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +3 -3
- package/.bkit/core/.claude/hooks/bkit-preflight.sh +45 -14
- package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +3 -3
- package/.bkit/core/.codex/hooks/bkit-rules.cjs +57 -0
- package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +7 -7
- package/.bkit/core/.cursor/hooks/bkit-preflight.sh +47 -12
- package/.bkit/core/.opencode/plugin/bkit-rules.js +89 -0
- package/.bkit/core/AGENTS.md +5 -73
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +127 -105
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +104 -70
- package/.bkit/core/docs/templates/bkit-audit-agents.md +94 -72
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +99 -78
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +140 -82
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +98 -72
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +121 -96
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +157 -76
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +113 -71
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +75 -72
- package/.bkit/core/docs/templates/bkit-audit-config.md +122 -76
- package/.bkit/core/docs/templates/bkit-audit-cost.md +85 -74
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +75 -68
- package/.bkit/core/docs/templates/bkit-audit-database.md +101 -70
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +164 -83
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +115 -86
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +264 -88
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +118 -93
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +139 -86
- package/.bkit/core/docs/templates/bkit-audit-failures.md +110 -81
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +99 -74
- package/.bkit/core/docs/templates/bkit-audit-gates.md +105 -77
- package/.bkit/core/docs/templates/bkit-audit-issues.md +104 -80
- package/.bkit/core/docs/templates/bkit-audit-llm.md +131 -58
- package/.bkit/core/docs/templates/bkit-audit-logs.md +123 -100
- package/.bkit/core/docs/templates/bkit-audit-models.md +98 -53
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +56 -52
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +63 -54
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +124 -68
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +95 -70
- package/.bkit/core/docs/templates/bkit-audit-repo.md +169 -73
- package/.bkit/core/docs/templates/bkit-audit-security.md +206 -96
- package/.bkit/core/docs/templates/bkit-audit-slop.md +77 -70
- package/.bkit/core/docs/templates/bkit-audit-testing.md +162 -114
- package/.bkit/core/docs/templates/bkit-audit-usability.md +113 -71
- package/.bkit/core/docs/templates/bkit-plan.md +138 -132
- package/.bkit/core/engine/checks/after/auth.ts +40 -37
- package/.bkit/core/engine/checks/after/ci-yml.ts +65 -2
- package/.bkit/core/engine/checks/after/index.ts +12 -2
- package/.bkit/core/engine/checks/after/tools.ts +80 -33
- package/.bkit/core/engine/checks/before/context-fetch.ts +227 -33
- package/.bkit/core/engine/checks/before/env.ts +1 -1
- package/.bkit/core/engine/checks/before/index.ts +7 -0
- package/.bkit/core/engine/checks/before/repo.ts +40 -0
- package/.bkit/core/engine/checks/status-holes.ts +916 -123
- package/.bkit/core/engine/checks/tips/catalogue.ts +68 -17
- package/.bkit/core/engine/checks/tips/detect.ts +32 -0
- package/.bkit/core/engine/checks/tips/index.ts +47 -6
- package/.bkit/core/engine/cli.ts +238 -84
- package/.bkit/core/engine/commands/analysis.ts +128 -76
- package/.bkit/core/engine/commands/ci/ci.ts +363 -29
- package/.bkit/core/engine/commands/ci/pins.ts +172 -0
- package/.bkit/core/engine/commands/ci/push-gate.ts +223 -0
- package/.bkit/core/engine/commands/install/uninstall.ts +21 -27
- package/.bkit/core/engine/commands/install/upgrade.ts +32 -15
- package/.bkit/core/engine/commands/land.ts +126 -11
- package/.bkit/core/engine/commands/lib.ts +303 -6
- package/.bkit/core/engine/commands/registry.ts +6 -2
- package/.bkit/core/engine/commands/setup/setup.ts +1 -0
- package/.bkit/core/engine/commands/stats.ts +91 -35
- package/.bkit/core/engine/commands/workflow/branches.ts +1477 -117
- package/.bkit/core/engine/commands/workflow/challenge.ts +114 -39
- package/.bkit/core/engine/commands/workflow/completeness.ts +109 -0
- package/.bkit/core/engine/commands/workflow/context.ts +433 -55
- package/.bkit/core/engine/commands/workflow/counters.ts +244 -39
- package/.bkit/core/engine/commands/workflow/decisions.ts +61 -17
- package/.bkit/core/engine/commands/workflow/disk.ts +237 -55
- package/.bkit/core/engine/commands/workflow/fids.ts +19 -1
- package/.bkit/core/engine/commands/workflow/issues.ts +6 -0
- package/.bkit/core/engine/commands/workflow/ledgers.ts +458 -18
- package/.bkit/core/engine/commands/workflow/locks.ts +2 -0
- package/.bkit/core/engine/commands/workflow/plan-blocks.ts +124 -15
- package/.bkit/core/engine/commands/workflow/plans.ts +257 -0
- package/.bkit/core/engine/commands/workflow/prs.ts +12 -3
- package/.bkit/core/engine/commands/workflow/repo.ts +8 -0
- package/.bkit/core/engine/commands/workflow/roadmap.ts +56 -15
- package/.bkit/core/engine/commands/workflow/run-facts.ts +22 -31
- package/.bkit/core/engine/commands/workflow/runs.ts +652 -34
- package/.bkit/core/engine/commands/workflow/runtime.ts +3 -0
- package/.bkit/core/engine/commands/workflow/skills.ts +1 -0
- package/.bkit/core/engine/commands/workflow/status.ts +200 -17
- package/.bkit/core/engine/commands/workflow/step-table.ts +75 -33
- package/.bkit/core/engine/commands/workflow/steps.ts +635 -24
- package/.bkit/core/engine/commands/workflow/summary-findings.ts +177 -0
- package/.bkit/core/engine/commands/workflow/summary.ts +192 -46
- package/.bkit/core/engine/commands/workflow/tasks.ts +409 -0
- package/.bkit/core/engine/commands/workflow/test-blocks.ts +254 -0
- package/.bkit/core/engine/commands/workflow/tests-changed.ts +201 -0
- package/.bkit/core/engine/commands/workflow/tests.ts +1285 -356
- package/.bkit/core/engine/commands/workflow/workflows.ts +228 -43
- package/.bkit/core/engine/commands/workflow/worktrees.ts +389 -47
- package/.bkit/core/engine/install/cloud-env.ts +251 -121
- package/.bkit/core/engine/install/context-ci-workflow.ts +102 -0
- package/.bkit/core/engine/install/manifest.ts +60 -12
- package/.bkit/core/engine/install/modules/antigravity.ts +3 -2
- package/.bkit/core/engine/install/modules/cloud.ts +3 -3
- package/.bkit/core/engine/install/modules/codex.ts +15 -2
- package/.bkit/core/engine/install/modules/core.ts +956 -52
- package/.bkit/core/engine/install/modules/cursor.ts +6 -6
- package/.bkit/core/engine/install/modules/opencode.ts +16 -4
- package/.bkit/core/engine/install/template-notes.ts +130 -0
- package/.bkit/core/engine/install/version-file.ts +3 -2
- package/.bkit/core/engine/install/write.ts +5 -0
- package/.bkit/core/engine/ledgers/compact.ts +124 -0
- package/.bkit/core/engine/ledgers/journal.ts +291 -0
- package/.bkit/core/engine/ledgers/status.ts +160 -9
- package/.bkit/core/engine/ledgers/telemetry.ts +158 -21
- package/.bkit/core/engine/render/hosts.ts +114 -14
- package/.bkit/core/engine/shared/bkit-latest.ts +26 -4
- package/.bkit/core/engine/shared/dep-updater.ts +60 -0
- package/.bkit/core/engine/shared/egress.ts +1 -1
- package/.bkit/core/engine/shared/package-manager.ts +9 -0
- package/.bkit/core/engine/shared/settings.ts +92 -17
- package/.bkit/core/engine/shared/timeouts.ts +2 -0
- package/.bkit/core/engine/tools/cli-doc.ts +111 -0
- package/.bkit/core/engine/tools/grammar-density.ts +1 -1
- package/.bkit/core/engine/tools/instructions-sources.ts +15 -17
- package/.bkit/core/engine/tools/instructions.ts +94 -43
- package/.bkit/core/hooks/antigravity-hook.js +25 -10
- package/.bkit/core/hooks/gateguard-engine.js +53 -29
- package/.bkit/core/hooks/guardrails-shell.js +4 -4
- package/.bkit/core/hooks/guardrails-tiers.js +3 -3
- package/.bkit/core/hooks/preflight-linear.sh +9 -9
- package/.bkit/core/hooks/preflight-rules.sh +8 -0
- package/.bkit/core/hooks/readguard-engine.js +29 -10
- package/.bkit/core/hooks/session-rules-advisory.js +61 -0
- package/.bkit/core/prompts/bkit-audit-generate.md +187 -116
- package/.bkit/core/prompts/bkit-build-challenge-1.md +56 -37
- package/.bkit/core/prompts/bkit-build-challenge-2.md +65 -45
- package/.bkit/core/prompts/bkit-build-install-skills.md +38 -29
- package/.bkit/core/prompts/bkit-build-plan-convert.md +43 -32
- package/.bkit/core/prompts/bkit-build-plan-current.md +49 -39
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +79 -55
- package/.bkit/core/prompts/bkit-build-plan-tasks.md +149 -0
- package/.bkit/core/prompts/bkit-build-plan-tests.md +120 -0
- package/.bkit/core/prompts/bkit-build-plan-verify.md +87 -50
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +36 -35
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +96 -64
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +54 -45
- package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +42 -33
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +53 -37
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +35 -30
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +34 -29
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +32 -28
- package/.bkit/core/prompts/bkit-design-generate.md +68 -52
- package/.bkit/core/prompts/bkit-design-organise.md +73 -35
- package/.bkit/core/prompts/bkit-design-review-1.md +58 -54
- package/.bkit/core/prompts/bkit-design-review-2.md +54 -50
- package/.bkit/core/prompts/bkit-design-spike.md +54 -47
- package/.bkit/core/prompts/bkit-design-update.md +42 -31
- package/.bkit/core/prompts/bkit-plan-generate.md +76 -58
- package/.bkit/core/prompts/bkit-plan-review-1.md +63 -49
- package/.bkit/core/prompts/bkit-plan-review-2.md +60 -48
- package/.bkit/core/prompts/bkit-plan-scope-check.md +53 -46
- package/.bkit/core/prompts/bkit-plan-update.md +70 -52
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +82 -50
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +80 -45
- package/.bkit/core/prompts/bkit-ship-update-docs.md +35 -29
- package/.bkit/core/prompts/bkit-utility-compress-markdown.md +55 -49
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +76 -49
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +70 -41
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +33 -30
- package/.bkit/core/prompts/bkit-utility-update-failures.md +73 -43
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +77 -50
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +77 -45
- package/.bkit/core/prompts/bkit-utility-update-tracker.md +144 -68
- package/.bkit/core/workflows/bkit-auto.md +53 -30
- package/.bkit/core/workflows/bkit-build.md +635 -304
- package/.bkit/core/workflows/bkit-debug.md +301 -148
- package/.bkit/core/workflows/bkit-design.md +167 -95
- package/.bkit/core/workflows/bkit-plan.md +172 -84
- package/.bkit/core/workflows/bkit-ship.md +299 -152
- package/.bkit/shared/.agents/plugins/bkit/hooks.json +10 -0
- package/.bkit/shared/.claude/bkit-cloud.md +12 -10
- package/.bkit/shared/.claude/settings.json +3 -0
- package/.bkit/shared/.codex/bkit-cloud.md +98 -0
- package/.bkit/shared/.codex/hooks.json +20 -0
- package/.bkit/shared/.cursor/bkit-cloud.md +3 -3
- package/.bkit/shared/.opencode/opencode.json +1 -1
- package/.bkit/shared/CLAUDE.md +5 -1
- package/.bkit/shared/GEMINI.md +4 -1
- package/.bkit/shared/docs/architecture.md +4 -7
- package/.bkit/shared/docs/data-schema.md +4 -7
- package/.bkit/shared/docs/deployments.md +239 -166
- package/.bkit/shared/docs/design.md +11 -12
- package/.bkit/shared/docs/noise.md +8 -7
- package/.bkit/shared/docs/observability.md +5 -8
- package/.bkit/shared/docs/security.md +35 -17
- package/.bkit/shared/docs/setup.md +29 -18
- package/.bkit/shared/docs/technology.md +3 -6
- package/.bkit/shared/docs/testing.md +282 -176
- package/.bkit/shared/gitignore +6 -2
- package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +15 -16
- package/.bkit/templates/.cursor/Dockerfile +12 -8
- package/.bkit/templates/.cursor/environment.json +1 -1
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-bug.yml +10 -8
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +24 -12
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-idea.yml +3 -3
- package/.bkit/templates/.github/renovate.json5 +34 -6
- package/.bkit/templates/.github/workflows/bkit-ci.yml +53 -50
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +13 -14
- package/.bkit/templates/.github/workflows/bkit-health.yml +97 -0
- package/.bkit/templates/.github/workflows/bkit-renovate.yml +5 -4
- package/.bkit/templates/.github/workflows/bkit-trivy.yml +5 -4
- package/.bkit/templates/.husky/pre-commit +2 -2
- package/.bkit/templates/.husky/pre-push +95 -35
- package/.bkit/templates/.prettierignore +6 -7
- package/.bkit/templates/.vale.ini +27 -27
- package/.bkit/templates/context/bkit-cloudrun.md +23 -15
- package/.bkit/templates/context/bkit-expo.md +70 -52
- package/.bkit/templates/context/bkit-github.md +93 -56
- package/.bkit/templates/context/bkit-inngest.md +21 -15
- package/.bkit/templates/context/bkit-maestro.md +22 -16
- package/.bkit/templates/context/bkit-playwright.md +23 -17
- package/.bkit/templates/context/bkit-resend.md +12 -10
- package/.bkit/templates/context/bkit-sentry.md +30 -20
- package/.bkit/templates/context/bkit-serena.md +8 -7
- package/.bkit/templates/context/bkit-stripe.md +14 -13
- package/.bkit/templates/context/bkit-supabase.md +16 -13
- package/.bkit/templates/context/bkit-tavily.md +14 -11
- package/.bkit/templates/context/bkit-vercel.md +27 -18
- package/.bkit/templates/docs/capabilities.md +15 -14
- package/.bkit/templates/scripts/ci/{check-accepted-divergences.mjs → bkit-check-accepted-divergences.mjs} +6 -3
- package/.bkit/templates/scripts/ci/{check-accepted-divergences.test.mjs → bkit-check-accepted-divergences.test.mjs} +3 -3
- package/.bkit/templates/scripts/ci/{check-capstone.mjs → bkit-check-capstone.mjs} +2 -2
- package/.bkit/templates/scripts/ci/{check-capstone.test.mjs → bkit-check-capstone.test.mjs} +4 -4
- package/.bkit/templates/scripts/ci/{check-dependency-audit.mjs → bkit-check-dependency-audit.mjs} +103 -18
- package/.bkit/templates/scripts/ci/{check-dependency-audit.test.mjs → bkit-check-dependency-audit.test.mjs} +31 -3
- package/.bkit/templates/scripts/ci/bkit-machine-lock.sh +387 -0
- package/.bkit/templates/scripts/ci/bkit-test-awake.mjs +75 -0
- package/.bkit/templates/scripts/ci/bkit-test-awake.test.mjs +160 -0
- package/.bkit/templates/scripts/ci/lanes/{resolve-push-base.mjs → bkit-resolve-push-base.mjs} +3 -3
- package/.bkit/templates/scripts/ci/lanes/{resolve-push-base.test.mjs → bkit-resolve-push-base.test.mjs} +4 -4
- package/.bkit/templates/scripts/cleanup/bkit-disk-prune.mjs +9 -1
- package/.bkit/templates/scripts/graphify/bkit-graph-drift.py +1 -1
- package/.bkit/templates/scripts/graphify/bkit-graph-eager.py +3 -3
- package/.bkit/templates/scripts/graphify/bkit-graph-embed.py +63 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-imports.py +2 -2
- package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +69 -18
- package/.bkit/templates/scripts/graphify/bkit-graph-repair.py +3 -3
- package/.bkit/templates/scripts/graphify/bkit-graph-surface.py +1 -1
- package/.bkit/templates/scripts/graphify/bkit-graphify-graphml.py +1 -1
- package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +197 -126
- package/.bkit/templates/scripts/graphify/bkit-graphify.sh +64 -41
- package/.bkit/templates/scripts/slop/bkit-slop-type-suppression.mjs +23 -7
- package/.bkit/templates/slop-scan.config.json +9 -2
- package/CHANGELOG.md +119 -0
- package/README.md +250 -76
- package/dist/checks/after/auth.js +36 -33
- package/dist/checks/after/ci-yml.js +52 -2
- package/dist/checks/after/index.js +12 -4
- package/dist/checks/after/tools.js +73 -33
- package/dist/checks/before/context-fetch.js +218 -33
- package/dist/checks/before/env.js +1 -1
- package/dist/checks/before/index.js +6 -2
- package/dist/checks/before/repo.js +35 -1
- package/dist/checks/status-holes.js +739 -114
- package/dist/checks/tips/catalogue.js +59 -17
- package/dist/checks/tips/detect.js +30 -0
- package/dist/checks/tips/index.js +48 -6
- package/dist/cli.js +222 -84
- package/dist/commands/analysis.js +77 -53
- package/dist/commands/ci/ci.js +302 -25
- package/dist/commands/ci/pins.js +142 -0
- package/dist/commands/ci/push-gate.js +194 -0
- package/dist/commands/install/uninstall.js +23 -27
- package/dist/commands/install/upgrade.js +21 -11
- package/dist/commands/land.js +126 -10
- package/dist/commands/lib.js +244 -5
- package/dist/commands/registry.js +6 -2
- package/dist/commands/setup/setup.js +1 -0
- package/dist/commands/stats.js +69 -30
- package/dist/commands/workflow/branches.js +1232 -111
- package/dist/commands/workflow/challenge.js +90 -37
- package/dist/commands/workflow/completeness.js +97 -0
- package/dist/commands/workflow/context.js +371 -51
- package/dist/commands/workflow/counters.js +206 -40
- package/dist/commands/workflow/decisions.js +60 -17
- package/dist/commands/workflow/disk.js +213 -55
- package/dist/commands/workflow/fids.js +18 -1
- package/dist/commands/workflow/issues.js +6 -0
- package/dist/commands/workflow/ledgers.js +372 -21
- package/dist/commands/workflow/locks.js +2 -0
- package/dist/commands/workflow/plan-blocks.js +78 -14
- package/dist/commands/workflow/plans.js +205 -0
- package/dist/commands/workflow/prs.js +12 -3
- package/dist/commands/workflow/repo.js +6 -0
- package/dist/commands/workflow/roadmap.js +50 -17
- package/dist/commands/workflow/run-facts.js +23 -28
- package/dist/commands/workflow/runs.js +530 -33
- package/dist/commands/workflow/runtime.js +3 -0
- package/dist/commands/workflow/skills.js +1 -0
- package/dist/commands/workflow/status.js +166 -19
- package/dist/commands/workflow/step-table.js +61 -29
- package/dist/commands/workflow/steps.js +542 -26
- package/dist/commands/workflow/summary-findings.js +117 -0
- package/dist/commands/workflow/summary.js +154 -41
- package/dist/commands/workflow/tasks.js +378 -0
- package/dist/commands/workflow/test-blocks.js +231 -0
- package/dist/commands/workflow/tests-changed.js +172 -0
- package/dist/commands/workflow/tests.js +1013 -321
- package/dist/commands/workflow/workflows.js +191 -38
- package/dist/commands/workflow/worktrees.js +310 -42
- package/dist/install/cloud-env.js +233 -99
- package/dist/install/context-ci-workflow.js +85 -0
- package/dist/install/manifest.js +57 -12
- package/dist/install/modules/antigravity.js +3 -2
- package/dist/install/modules/cloud.js +3 -3
- package/dist/install/modules/codex.js +12 -2
- package/dist/install/modules/core.js +851 -53
- package/dist/install/modules/cursor.js +6 -6
- package/dist/install/modules/opencode.js +11 -5
- package/dist/install/template-notes.js +116 -0
- package/dist/install/version-file.js +3 -2
- package/dist/ledgers/compact.js +87 -0
- package/dist/ledgers/journal.js +233 -0
- package/dist/ledgers/status.js +115 -5
- package/dist/ledgers/telemetry.js +121 -17
- package/dist/render/hosts.js +100 -14
- package/dist/shared/bkit-latest.js +26 -4
- package/dist/shared/dep-updater.js +49 -0
- package/dist/shared/egress.js +1 -1
- package/dist/shared/package-manager.js +6 -0
- package/dist/shared/settings.js +59 -10
- package/dist/shared/timeouts.js +2 -0
- package/dist/tools/cli-doc.js +97 -0
- package/dist/tools/grammar-density.js +1 -1
- package/dist/tools/instructions-sources.js +15 -16
- package/dist/tools/instructions.js +83 -39
- package/package.json +58 -42
- package/.bkit/core/.bkit/lite.md +0 -73
- package/.bkit/core/engine/commands/workflow/workstreams.ts +0 -172
- package/.bkit/core/prompts/bkit-build-plan-execute.md +0 -124
- package/.bkit/templates/scripts/ci/bkit-local-stack-lock.sh +0 -194
- package/dist/commands/workflow/workstreams.js +0 -149
- /package/.bkit/templates/.vale/styles/{House → Bkit}/Filler.yml +0 -0
- /package/.bkit/templates/.vale/styles/{House → Bkit}/Hedging.yml +0 -0
- /package/.bkit/templates/.vale/styles/{House → Bkit}/LLMSlop.yml +0 -0
- /package/.bkit/templates/.vale/styles/{House → Bkit}/Verbose.yml +0 -0
- /package/.bkit/templates/scripts/ci/{accepted-advisories.json → bkit-accepted-advisories.json} +0 -0
- /package/.bkit/templates/scripts/ci/{accepted-divergences.json → bkit-accepted-divergences.json} +0 -0
- /package/.bkit/templates/scripts/launchd/{launchd.env.example → bkit-launchd.env.example} +0 -0
- /package/.bkit/templates/scripts/launchd/{ai.bkit.launchd.plist → bkit-launchd.plist} +0 -0
|
@@ -12,24 +12,28 @@
|
|
|
12
12
|
// plain push, every other branch `--force-with-lease`, so a shared branch is
|
|
13
13
|
// never force-pushed and a personal one survives the rebase that rewrote it.
|
|
14
14
|
import { spawnSync } from "node:child_process";
|
|
15
|
+
import { createHash } from "node:crypto";
|
|
15
16
|
import * as fs from "node:fs";
|
|
16
17
|
import * as os from "node:os";
|
|
17
18
|
import * as path from "node:path";
|
|
18
19
|
import { gitEnv } from "../../ledgers/telemetry.js";
|
|
19
20
|
import { actionHash, actionKey, alreadyDone, recordAction } from "../../ledgers/status.js";
|
|
20
|
-
import { bodySkipToken, CommandError, DEV, EXIT, ghUnavailable, git, isSharedBranch, OUTPUT_LIMIT, parseJson, repoRoot, runGh, runGit, SKIP_CI_TOKEN, } from "../lib.js";
|
|
21
|
+
import { bodySkipToken, classifyLockExit, CommandError, DEV, EXIT, ghUnavailable, git, isSharedBranch, OUTPUT_LIMIT, parseJson, repoRoot, runGh, runGit, SKIP_CI_TOKEN, testsLockHolder, wholeNumber, } from "../lib.js";
|
|
21
22
|
import { bkitVersionStatus } from "../../shared/bkit-latest.js";
|
|
22
|
-
import {
|
|
23
|
+
import { parseBkitVersion, serializeBkitVersion, } from "../../install/version-file.js";
|
|
24
|
+
import { DEV_REFSPEC, fetchDev, landBackoffMs, landDir, pushToDev, sleep } from "../land.js";
|
|
23
25
|
import { TIMEOUTS } from "../../shared/timeouts.js";
|
|
24
26
|
import { activeRecord, commitBookkeeping, markRecordPushed, recordOnBranch, } from "./ledgers.js";
|
|
25
27
|
import { releaseLock, resolveMonth, workflowLockPath } from "./locks.js";
|
|
26
|
-
import { EXIT_BASE_NOT_DEV, FORCE_BUILD, closeTransportRow, crossCheckRows, mergePr, openPrFor, probePr,
|
|
28
|
+
import { EXIT_BASE_NOT_DEV, FORCE_BUILD, closeTransportRow, crossCheckRows, mergePr, openPrFor, probePr, } from "./prs.js";
|
|
27
29
|
import { AUTO_LABEL, AUTO_ROUTE_SUFFIX } from "./issues.js";
|
|
28
30
|
import { appendFeature } from "./roadmap.js";
|
|
29
31
|
import { detect } from "./runtime.js";
|
|
30
32
|
import { readRuns, readStatusRows, readStatusRowsAt } from "./status.js";
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
+
import { declaredName, testSource } from "./test-blocks.js";
|
|
34
|
+
import { addAllButCopied, copyExcludes, hasLeftovers, recordRebase, removeWorktree, worktreeDir, } from "./worktrees.js";
|
|
35
|
+
import { COULD_NOT_RUN_EXIT_CODES, LOCKFILE_REGENERATE, installCommand, scriptCommand, } from "../../shared/package-manager.js";
|
|
36
|
+
import { readPackageJson } from "../../shared/package-json.js";
|
|
33
37
|
import { str } from "./status.js";
|
|
34
38
|
const REMOTE = "origin";
|
|
35
39
|
const UPSTREAM = `${REMOTE}/${DEV}`;
|
|
@@ -53,6 +57,8 @@ export const EXIT_NO_RECORD = 20;
|
|
|
53
57
|
export const EXIT_NOTHING_TO_PUSH = 21;
|
|
54
58
|
export const EXIT_DIVERGED = 22;
|
|
55
59
|
export const EXIT_DIFF_FAILED = 23;
|
|
60
|
+
export const EXIT_HAND_RESOLVE = 24;
|
|
61
|
+
export const EXIT_GENERATE_FAILED = 25;
|
|
56
62
|
// ---------------------------------------------------------------------------
|
|
57
63
|
// Process helpers
|
|
58
64
|
// ---------------------------------------------------------------------------
|
|
@@ -119,8 +125,56 @@ const globToRegExp = (glob) => new RegExp(`^${glob
|
|
|
119
125
|
.replace(/\*/g, "[^/]*")
|
|
120
126
|
.replace(/\0/g, ".*")}$`);
|
|
121
127
|
const LEDGER_PATTERNS = LEDGERS.map(globToRegExp);
|
|
122
|
-
/**
|
|
123
|
-
export
|
|
128
|
+
/** bkit's install record: merged entry by entry (`recordResolve`), never line by line. */
|
|
129
|
+
export const INSTALL_RECORD = ".bkit/version";
|
|
130
|
+
/**
|
|
131
|
+
* Generated registers a conflict is settled in by taking dev's copy. Each side rebuilt
|
|
132
|
+
* the whole file, so neither side's text is worth a hand merge, and running `script`
|
|
133
|
+
* with `args` after the rebase or merge makes dev's copy current. `keep` brackets the
|
|
134
|
+
* one hand-written region, which the rebuild reads back and re-emits, so a branch's
|
|
135
|
+
* edit to it is carried onto dev's copy. `embed` names the variable in `script` that
|
|
136
|
+
* lists the hand-written docs the rebuild copies a generated block into, and the
|
|
137
|
+
* markers around that block.
|
|
138
|
+
*/
|
|
139
|
+
export const REGISTERS = {
|
|
140
|
+
"docs/capabilities.md": {
|
|
141
|
+
script: "scripts/graphify/bkit-graphify.sh",
|
|
142
|
+
args: ["refresh"],
|
|
143
|
+
keep: ["<!-- overrides:start -->", "<!-- overrides:end -->"],
|
|
144
|
+
embed: {
|
|
145
|
+
variable: "GRAPH_EMBED_DOCS",
|
|
146
|
+
block: ["<!-- graph:packages:start -->", "<!-- graph:packages:end -->"],
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Each doc a register's script in `top` embeds a generated block into, mapped to that
|
|
152
|
+
* register. Read from the script's own `embed.variable` assignment, so a repo whose
|
|
153
|
+
* script lists no docs, or that has no script, gets an empty map.
|
|
154
|
+
*/
|
|
155
|
+
export function embedDocs(top) {
|
|
156
|
+
const out = new Map();
|
|
157
|
+
for (const [register, entry] of Object.entries(REGISTERS)) {
|
|
158
|
+
const script = path.join(top, entry.script);
|
|
159
|
+
if (!fs.existsSync(script))
|
|
160
|
+
continue;
|
|
161
|
+
const assigned = new RegExp(`^${entry.embed.variable}="([^"]*)"`, "m").exec(fs.readFileSync(script, "utf-8"));
|
|
162
|
+
for (const doc of (assigned?.[1] ?? "").split(/\s+/).filter(Boolean))
|
|
163
|
+
out.set(doc, register);
|
|
164
|
+
}
|
|
165
|
+
return out;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* How a conflicted path may be resolved. Only repo-root lockfiles count: the regenerate
|
|
169
|
+
* runs there. `embeds` is the repo's `embedDocs`.
|
|
170
|
+
*/
|
|
171
|
+
export function classifyConflict(file, embeds = new Map()) {
|
|
172
|
+
if (Object.hasOwn(REGISTERS, file))
|
|
173
|
+
return "register";
|
|
174
|
+
if (embeds.has(file))
|
|
175
|
+
return "embed";
|
|
176
|
+
if (file === INSTALL_RECORD)
|
|
177
|
+
return "record";
|
|
124
178
|
if (Object.hasOwn(LOCKFILE_REGENERATE, file))
|
|
125
179
|
return "lockfile";
|
|
126
180
|
if (LEDGER_PATTERNS.some((re) => re.test(file)))
|
|
@@ -184,20 +238,163 @@ export function unionResolve(top, file) {
|
|
|
184
238
|
}
|
|
185
239
|
}
|
|
186
240
|
/**
|
|
187
|
-
* Resolve a lockfile conflict: start from
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
241
|
+
* Resolve a lockfile conflict: start from dev's copy, then regenerate from the
|
|
242
|
+
* manifest, which merged normally (or refused and stopped the rebase or merge
|
|
243
|
+
* before this). During a rebase dev is `--ours` (the branch being rebased ONTO;
|
|
244
|
+
* `--theirs` is the commit being replayed); in a merge of origin/dev it is `--theirs`.
|
|
191
245
|
*/
|
|
192
|
-
function lockfileResolve(top, file) {
|
|
246
|
+
function lockfileResolve(top, file, dev = "ours") {
|
|
193
247
|
const regenerate = LOCKFILE_REGENERATE[file];
|
|
194
248
|
if (!regenerate)
|
|
195
249
|
return false;
|
|
196
|
-
if (!runGit(top, ["checkout",
|
|
250
|
+
if (!runGit(top, ["checkout", `--${dev}`, "--", file]).ok)
|
|
197
251
|
return false;
|
|
198
252
|
const res = spawnSync(regenerate[0], regenerate.slice(1), { cwd: top, stdio: "ignore" });
|
|
199
253
|
return res.status === 0;
|
|
200
254
|
}
|
|
255
|
+
/** The text from `keep`'s open marker through its close marker; null when either is missing. */
|
|
256
|
+
function keptRegion(text, [open, close]) {
|
|
257
|
+
const start = text.indexOf(open);
|
|
258
|
+
if (start === -1)
|
|
259
|
+
return null;
|
|
260
|
+
const end = text.indexOf(close, start + open.length);
|
|
261
|
+
return end === -1 ? null : text.slice(start, end + close.length);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Settle a conflicted register on dev's copy, carrying the branch's edit to the
|
|
265
|
+
* hand-written region when dev left that region as the merge base had it. Refuses when
|
|
266
|
+
* a side deleted the file, or both sides changed the region: that needs a hand merge.
|
|
267
|
+
* During a rebase dev is `ours`; in a merge of origin/dev it is `theirs`.
|
|
268
|
+
*/
|
|
269
|
+
export function registerResolve(top, file, dev) {
|
|
270
|
+
const entry = REGISTERS[file];
|
|
271
|
+
if (entry === undefined)
|
|
272
|
+
return { ok: false, problem: "not a generated register" };
|
|
273
|
+
const base = stageBytes(top, 1, file);
|
|
274
|
+
const devSide = stageBytes(top, dev === "ours" ? 2 : 3, file);
|
|
275
|
+
const branchSide = stageBytes(top, dev === "ours" ? 3 : 2, file);
|
|
276
|
+
if (base === null || devSide === null || branchSide === null)
|
|
277
|
+
return { ok: false, problem: "git show of a conflict stage failed" };
|
|
278
|
+
if (devSide.length === 0 || branchSide.length === 0)
|
|
279
|
+
return { ok: false, problem: "one side deleted the register" };
|
|
280
|
+
let text = devSide.toString("utf-8");
|
|
281
|
+
const baseKept = keptRegion(base.toString("utf-8"), entry.keep);
|
|
282
|
+
const devKept = keptRegion(text, entry.keep);
|
|
283
|
+
const branchKept = keptRegion(branchSide.toString("utf-8"), entry.keep);
|
|
284
|
+
if (branchKept !== baseKept && branchKept !== devKept) {
|
|
285
|
+
if (devKept !== baseKept)
|
|
286
|
+
return { ok: false, problem: "both sides changed the hand-written region" };
|
|
287
|
+
if (devKept === null || branchKept === null)
|
|
288
|
+
return { ok: false, problem: "one side added or removed the hand-written region" };
|
|
289
|
+
text = text.replace(devKept, () => branchKept);
|
|
290
|
+
}
|
|
291
|
+
fs.writeFileSync(path.join(top, file), text);
|
|
292
|
+
return { ok: true };
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Settle a conflicted doc that embeds a register's generated block: give all three
|
|
296
|
+
* stages dev's copy of the block, then merge the rest of the doc as git would. Refuses
|
|
297
|
+
* when a side lacks the block, or when the doc still conflicts outside it: that needs a
|
|
298
|
+
* hand merge. The register's rebuild rewrites the block afterwards.
|
|
299
|
+
*/
|
|
300
|
+
export function embedResolve(top, file, register, dev) {
|
|
301
|
+
const entry = REGISTERS[register];
|
|
302
|
+
if (entry === undefined)
|
|
303
|
+
return { ok: false, problem: "not a generated register" };
|
|
304
|
+
const stages = { base: 1, ours: 2, theirs: 3 };
|
|
305
|
+
const texts = { base: "", ours: "", theirs: "" };
|
|
306
|
+
for (const [name, stage] of Object.entries(stages)) {
|
|
307
|
+
const bytes = stageBytes(top, stage, file);
|
|
308
|
+
if (bytes === null)
|
|
309
|
+
return { ok: false, problem: `git show :${stage}:${file} failed` };
|
|
310
|
+
texts[name] = bytes.toString("utf-8");
|
|
311
|
+
}
|
|
312
|
+
const devBlock = keptRegion(texts[dev], entry.embed.block);
|
|
313
|
+
if (devBlock === null)
|
|
314
|
+
return { ok: false, problem: "a side lacks the generated block" };
|
|
315
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "bkit-embed-"));
|
|
316
|
+
try {
|
|
317
|
+
for (const name of Object.keys(stages)) {
|
|
318
|
+
const block = keptRegion(texts[name], entry.embed.block);
|
|
319
|
+
if (block === null)
|
|
320
|
+
return { ok: false, problem: "a side lacks the generated block" };
|
|
321
|
+
fs.writeFileSync(path.join(tmp, name), texts[name].replace(block, () => devBlock));
|
|
322
|
+
}
|
|
323
|
+
const merged = spawnSync("git", [
|
|
324
|
+
"merge-file",
|
|
325
|
+
"-p",
|
|
326
|
+
path.join(tmp, "ours"),
|
|
327
|
+
path.join(tmp, "base"),
|
|
328
|
+
path.join(tmp, "theirs"),
|
|
329
|
+
], { cwd: top, env: gitEnv(), maxBuffer: OUTPUT_LIMIT });
|
|
330
|
+
// Exit status = conflicts left, capped at 127; above that it failed.
|
|
331
|
+
if (merged.error || merged.status === null || merged.status > 127)
|
|
332
|
+
return { ok: false, problem: "git merge-file failed" };
|
|
333
|
+
if (merged.status > 0)
|
|
334
|
+
return { ok: false, problem: "it conflicts outside the generated block" };
|
|
335
|
+
fs.writeFileSync(path.join(top, file), merged.stdout);
|
|
336
|
+
return { ok: true };
|
|
337
|
+
}
|
|
338
|
+
finally {
|
|
339
|
+
fs.rmSync(tmp, { recursive: true, force: true });
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/** The value one entry takes: the side that changed it, or dev's when both did. */
|
|
343
|
+
function pickEntry(base, dev, branch) {
|
|
344
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
345
|
+
return same(dev, base) ? branch : dev;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Merge a conflicted install record entry by entry: `pinnedVersion`,
|
|
349
|
+
* `claudeAllowDerived` and each `canonicalHashes` path take the side that changed
|
|
350
|
+
* them, and dev's value when both did. A fingerprint left at dev's value makes
|
|
351
|
+
* `bkit upgrade` treat that file as edited by hand until it refreshes the entry, so
|
|
352
|
+
* the record needs no rebuild. Refuses when a side deleted the record or a copy is
|
|
353
|
+
* not a record. During a rebase dev is `ours`; in a merge of origin/dev it is `theirs`.
|
|
354
|
+
*/
|
|
355
|
+
export function recordResolve(top, dev) {
|
|
356
|
+
const copies = [];
|
|
357
|
+
for (const stage of [1, dev === "ours" ? 2 : 3, dev === "ours" ? 3 : 2]) {
|
|
358
|
+
const bytes = stageBytes(top, stage, INSTALL_RECORD);
|
|
359
|
+
if (bytes === null)
|
|
360
|
+
return { ok: false, problem: `git show :${stage}:${INSTALL_RECORD} failed` };
|
|
361
|
+
if (bytes.length === 0 && stage !== 1)
|
|
362
|
+
return { ok: false, problem: "one side deleted the install record" };
|
|
363
|
+
// Both sides adding the record leaves no base: merge against an empty one.
|
|
364
|
+
const parsed = bytes.length === 0
|
|
365
|
+
? { pinnedVersion: "", canonicalHashes: {}, claudeAllowDerived: [] }
|
|
366
|
+
: parseBkitVersion(bytes.toString("utf-8"));
|
|
367
|
+
if (parsed === null)
|
|
368
|
+
return { ok: false, problem: "a copy of the install record is not valid" };
|
|
369
|
+
copies.push(parsed);
|
|
370
|
+
}
|
|
371
|
+
const [base, devSide, branch] = copies;
|
|
372
|
+
const canonicalHashes = {};
|
|
373
|
+
for (const p of new Set([
|
|
374
|
+
...Object.keys(devSide.canonicalHashes),
|
|
375
|
+
...Object.keys(branch.canonicalHashes),
|
|
376
|
+
])) {
|
|
377
|
+
const hash = pickEntry(base.canonicalHashes[p], devSide.canonicalHashes[p], branch.canonicalHashes[p]);
|
|
378
|
+
if (hash !== undefined)
|
|
379
|
+
canonicalHashes[p] = hash;
|
|
380
|
+
}
|
|
381
|
+
const merged = {
|
|
382
|
+
pinnedVersion: pickEntry(base.pinnedVersion, devSide.pinnedVersion, branch.pinnedVersion),
|
|
383
|
+
canonicalHashes,
|
|
384
|
+
claudeAllowDerived: pickEntry(base.claudeAllowDerived, devSide.claudeAllowDerived, branch.claudeAllowDerived),
|
|
385
|
+
};
|
|
386
|
+
fs.writeFileSync(path.join(top, INSTALL_RECORD), serializeBkitVersion(merged));
|
|
387
|
+
return { ok: true };
|
|
388
|
+
}
|
|
389
|
+
const NOT_RESOLVABLE = "not an append-only ledger, a recognised lockfile, a generated register, a doc embedding one or the install record";
|
|
390
|
+
/** How a rebase settled each kind of conflict, for its log. */
|
|
391
|
+
const REBASE_HOW = {
|
|
392
|
+
union: "union (append-only ledger)",
|
|
393
|
+
lockfile: "took rebase target + regenerated",
|
|
394
|
+
register: "took rebase target's copy of a generated register",
|
|
395
|
+
embed: "took rebase target's copy of the generated block, merged the rest",
|
|
396
|
+
record: "merged the install record entry by entry, rebase target's value where both changed",
|
|
397
|
+
};
|
|
201
398
|
/**
|
|
202
399
|
* Drive an in-progress rebase to completion, auto-resolving each stop. Loops
|
|
203
400
|
* because `--continue` replays the next commit, which can conflict in turn; the
|
|
@@ -224,26 +421,40 @@ export function resolveRebase(top, onLog = () => undefined) {
|
|
|
224
421
|
result.reason = reason;
|
|
225
422
|
return result;
|
|
226
423
|
};
|
|
424
|
+
const embeds = embedDocs(top);
|
|
227
425
|
while (result.rounds < 100) {
|
|
228
426
|
result.rounds++;
|
|
229
427
|
const conflicts = unmergedPaths(top);
|
|
230
428
|
if (conflicts.length > 0) {
|
|
231
429
|
// Classify the whole set before resolving any of it, so a refused path
|
|
232
430
|
// never leaves half the set rewritten.
|
|
233
|
-
const refused = conflicts.find((f) => classifyConflict(f) === "refuse");
|
|
431
|
+
const refused = conflicts.find((f) => classifyConflict(f, embeds) === "refuse");
|
|
234
432
|
if (refused !== undefined) {
|
|
235
|
-
return refuse(`REFUSE ${refused} —
|
|
433
|
+
return refuse(`REFUSE ${refused} — ${NOT_RESOLVABLE}; routing to Failure Path`, refused, NOT_RESOLVABLE);
|
|
236
434
|
}
|
|
237
435
|
for (const f of conflicts) {
|
|
238
|
-
const kind = classifyConflict(f);
|
|
239
|
-
const
|
|
436
|
+
const kind = classifyConflict(f, embeds);
|
|
437
|
+
const settled = kind === "register"
|
|
438
|
+
? registerResolve(top, f, "ours")
|
|
439
|
+
: kind === "embed"
|
|
440
|
+
? embedResolve(top, f, embeds.get(f), "ours")
|
|
441
|
+
: kind === "record"
|
|
442
|
+
? recordResolve(top, "ours")
|
|
443
|
+
: null;
|
|
444
|
+
if (settled !== null && !settled.ok)
|
|
445
|
+
return refuse(`REFUSE ${f} — ${settled.problem}`, f, settled.problem);
|
|
446
|
+
const ok = settled !== null ||
|
|
447
|
+
(kind === "ledger" ? unionResolve(top, f).ok : lockfileResolve(top, f));
|
|
240
448
|
if (!ok || !runGit(top, ["add", "--", f]).ok) {
|
|
241
449
|
return refuse(`REFUSE ${f} — resolution failed`, f, "resolution failed");
|
|
242
450
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
451
|
+
const how = kind === "ledger"
|
|
452
|
+
? "union"
|
|
453
|
+
: kind === "register" || kind === "embed" || kind === "record"
|
|
454
|
+
? kind
|
|
455
|
+
: "lockfile";
|
|
456
|
+
result.resolved.push({ path: f, how });
|
|
457
|
+
log(`RESOLVED ${f} — ${REBASE_HOW[how]}`);
|
|
247
458
|
}
|
|
248
459
|
}
|
|
249
460
|
// A resolution can empty the commit (both sides appended the same rows);
|
|
@@ -407,6 +618,7 @@ function rebaseVerb(ctx) {
|
|
|
407
618
|
ctx.log("no rebase in progress");
|
|
408
619
|
return EXIT_NO_REBASE;
|
|
409
620
|
}
|
|
621
|
+
const origHead = rebaseOrigHead(top);
|
|
410
622
|
const result = resolveRebase(top, (line) => ctx.log(line));
|
|
411
623
|
let aborted = false;
|
|
412
624
|
if (!result.ok) {
|
|
@@ -419,6 +631,14 @@ function rebaseVerb(ctx) {
|
|
|
419
631
|
result.log.push(line);
|
|
420
632
|
ctx.log(line);
|
|
421
633
|
}
|
|
634
|
+
let rebuilt = null;
|
|
635
|
+
if (result.ok) {
|
|
636
|
+
const fid = currentBranch(top).replace(/^feat\//, "") || "rebase";
|
|
637
|
+
rebuilt = rebuildRegisters(top, result.resolved, (files) => `chore(${fid}): rebuild ${files.join(" ")} after the rebase`, (line) => {
|
|
638
|
+
result.log.push(line);
|
|
639
|
+
ctx.log(line);
|
|
640
|
+
});
|
|
641
|
+
}
|
|
422
642
|
appendLog(ctx, str(ctx.flags.logFile), result.log);
|
|
423
643
|
if (!result.ok && sentinelPath) {
|
|
424
644
|
fs.mkdirSync(path.dirname(sentinelPath), { recursive: true });
|
|
@@ -433,9 +653,46 @@ function rebaseVerb(ctx) {
|
|
|
433
653
|
reason: result.reason,
|
|
434
654
|
aborted,
|
|
435
655
|
sentinel: !result.ok && sentinel !== undefined ? sentinel : null,
|
|
656
|
+
rebuilt,
|
|
436
657
|
});
|
|
658
|
+
const statusFile = str(ctx.flags.file);
|
|
659
|
+
if (result.ok && statusFile !== undefined)
|
|
660
|
+
recordRebase(path.resolve(ctx.cwd, statusFile), origHead, git(top, ["rev-parse", "HEAD"]));
|
|
437
661
|
return result.ok ? EXIT.OK : EXIT_REFUSED;
|
|
438
662
|
}
|
|
663
|
+
/** The branch tip the in-progress rebase started from. */
|
|
664
|
+
function rebaseOrigHead(top) {
|
|
665
|
+
for (const dir of ["rebase-merge", "rebase-apply"]) {
|
|
666
|
+
const file = git(top, [
|
|
667
|
+
"rev-parse",
|
|
668
|
+
"--path-format=absolute",
|
|
669
|
+
"--git-path",
|
|
670
|
+
`${dir}/orig-head`,
|
|
671
|
+
]);
|
|
672
|
+
if (file !== null && fs.existsSync(file))
|
|
673
|
+
return fs.readFileSync(file, "utf-8").trim();
|
|
674
|
+
}
|
|
675
|
+
return null;
|
|
676
|
+
}
|
|
677
|
+
/** Git collapses a failing pre-push hook's status; classify its exact tests-lock markers. */
|
|
678
|
+
function runPush(cwd, args, branch) {
|
|
679
|
+
const who = `bkit branches push ${branch}`;
|
|
680
|
+
const wait = wholeNumber(process.env.BKIT_LOCK_WAIT_S, "BKIT_LOCK_WAIT_S", 60);
|
|
681
|
+
const res = runGit(cwd, args, {
|
|
682
|
+
LOCAL_STACK_LOCK_WAIT_S: String(wait),
|
|
683
|
+
LOCAL_STACK_LOCK_WHO: who,
|
|
684
|
+
});
|
|
685
|
+
const log = [res.stdout, res.stderr].filter(Boolean).join("\n");
|
|
686
|
+
const lockHolder = res.ok ? null : testsLockHolder(log, who);
|
|
687
|
+
const outcome = res.ok
|
|
688
|
+
? "gate"
|
|
689
|
+
: classifyLockExit({ exitCode: lockHolder === null ? 73 : 75, log, who });
|
|
690
|
+
return {
|
|
691
|
+
...res,
|
|
692
|
+
lockHolder,
|
|
693
|
+
lockExit: outcome === "lock-wait" ? EXIT.AGENT_WAIT : outcome === "could-not-run" ? 4 : null,
|
|
694
|
+
};
|
|
695
|
+
}
|
|
439
696
|
/**
|
|
440
697
|
* Push the current branch with exactly one `git push`: plain for dev / main,
|
|
441
698
|
* `--force-with-lease` otherwise. `abort` never pushes into an open PR (`openPr`:
|
|
@@ -460,6 +717,7 @@ export async function pushBranch(cwd, o, log) {
|
|
|
460
717
|
skipped: null,
|
|
461
718
|
prNumber: null,
|
|
462
719
|
replayed: false,
|
|
720
|
+
mergedDev: false,
|
|
463
721
|
...extra,
|
|
464
722
|
},
|
|
465
723
|
});
|
|
@@ -495,6 +753,19 @@ export async function pushBranch(cwd, o, log) {
|
|
|
495
753
|
}
|
|
496
754
|
if (rec !== null)
|
|
497
755
|
return pushOwnCommits(cwd, rec, o, log, notPushed);
|
|
756
|
+
let mergedDev = false;
|
|
757
|
+
if (mode === "feature" && o.requireCi === true && !shared) {
|
|
758
|
+
const top = topLevel(cwd);
|
|
759
|
+
const fetched = fetchDev(top);
|
|
760
|
+
if (!fetched.ok) {
|
|
761
|
+
log(`git fetch ${REMOTE} ${DEV} failed: ${fetched.stderr}`);
|
|
762
|
+
return notPushed(EXIT_FETCH_FAILED);
|
|
763
|
+
}
|
|
764
|
+
const m = mergeDevDocs(top, { branch, generate: true }, log);
|
|
765
|
+
if (m.code !== EXIT.OK)
|
|
766
|
+
return notPushed(m.code, { mergedDev: m.merged });
|
|
767
|
+
mergedDev = m.merged;
|
|
768
|
+
}
|
|
498
769
|
if (mode === "abort" && !shared) {
|
|
499
770
|
const pr = openPrFlag === undefined
|
|
500
771
|
? openPrNumber(cwd, branch)
|
|
@@ -515,10 +786,10 @@ export async function pushBranch(cwd, o, log) {
|
|
|
515
786
|
REMOTE,
|
|
516
787
|
branch,
|
|
517
788
|
];
|
|
518
|
-
const res =
|
|
789
|
+
const res = runPush(cwd, args, branch);
|
|
519
790
|
if (!res.ok) {
|
|
520
791
|
log(`git ${args.join(" ")} failed: ${res.stderr}`);
|
|
521
|
-
return notPushed(EXIT_PUSH_FAILED);
|
|
792
|
+
return notPushed(res.lockExit ?? EXIT_PUSH_FAILED, { lockHolder: res.lockHolder });
|
|
522
793
|
}
|
|
523
794
|
log(`pushed ${branch}${shared ? "" : " (--force-with-lease)"}`);
|
|
524
795
|
return {
|
|
@@ -531,6 +802,7 @@ export async function pushBranch(cwd, o, log) {
|
|
|
531
802
|
skipped: null,
|
|
532
803
|
prNumber: null,
|
|
533
804
|
replayed: false,
|
|
805
|
+
mergedDev,
|
|
534
806
|
},
|
|
535
807
|
};
|
|
536
808
|
}
|
|
@@ -573,10 +845,10 @@ function pushPlain(cwd, branch, o, log, notPushed) {
|
|
|
573
845
|
return notPushed(EXIT_SKIP_CI, { skipped: "skip-ci" });
|
|
574
846
|
}
|
|
575
847
|
const args = ["push", ...(o.setUpstream === true ? ["-u"] : []), REMOTE, branch];
|
|
576
|
-
const res =
|
|
848
|
+
const res = runPush(cwd, args, branch);
|
|
577
849
|
if (!res.ok) {
|
|
578
850
|
log(`git ${args.join(" ")} failed: ${res.stderr}`);
|
|
579
|
-
return notPushed(EXIT_PUSH_FAILED);
|
|
851
|
+
return notPushed(res.lockExit ?? EXIT_PUSH_FAILED, { lockHolder: res.lockHolder });
|
|
580
852
|
}
|
|
581
853
|
log(`pushed ${branch}`);
|
|
582
854
|
return {
|
|
@@ -589,6 +861,7 @@ function pushPlain(cwd, branch, o, log, notPushed) {
|
|
|
589
861
|
skipped: null,
|
|
590
862
|
prNumber: null,
|
|
591
863
|
replayed: false,
|
|
864
|
+
mergedDev: false,
|
|
592
865
|
},
|
|
593
866
|
};
|
|
594
867
|
}
|
|
@@ -613,7 +886,7 @@ function markerCommit(cwd, o) {
|
|
|
613
886
|
return { sha: prior.ref, deduped: true };
|
|
614
887
|
}
|
|
615
888
|
if (o.addAll) {
|
|
616
|
-
const added =
|
|
889
|
+
const added = addAllButCopied(cwd);
|
|
617
890
|
if (!added.ok)
|
|
618
891
|
throw new CommandError(EXIT_PUSH_FAILED, `git add -A failed: ${added.stderr}`);
|
|
619
892
|
}
|
|
@@ -662,7 +935,7 @@ async function pushOwnCommits(cwd, rec, o, log, notPushed) {
|
|
|
662
935
|
log(`the run's commit(s) ${gone.map((c) => c.slice(0, 12)).join(", ")} are no longer on ${rec.branch} — refusing to push`);
|
|
663
936
|
return notPushed(EXIT_PUSH_FAILED);
|
|
664
937
|
}
|
|
665
|
-
const fetched =
|
|
938
|
+
const fetched = fetchDev(cwd);
|
|
666
939
|
if (!fetched.ok) {
|
|
667
940
|
log(`git fetch ${REMOTE} ${DEV} failed: ${fetched.stderr}`);
|
|
668
941
|
return notPushed(EXIT_FETCH_FAILED);
|
|
@@ -698,7 +971,7 @@ async function pushOwnCommits(cwd, rec, o, log, notPushed) {
|
|
|
698
971
|
REMOTE,
|
|
699
972
|
`${last}:refs/heads/${rec.branch}`,
|
|
700
973
|
];
|
|
701
|
-
const res =
|
|
974
|
+
const res = runPush(cwd, args, rec.branch);
|
|
702
975
|
if (res.ok) {
|
|
703
976
|
log(`pushed ${rec.branch}: the run's ${pending.length} commit(s) are all local dev holds`);
|
|
704
977
|
return {
|
|
@@ -711,9 +984,14 @@ async function pushOwnCommits(cwd, rec, o, log, notPushed) {
|
|
|
711
984
|
skipped: null,
|
|
712
985
|
prNumber: null,
|
|
713
986
|
replayed: false,
|
|
987
|
+
mergedDev: false,
|
|
714
988
|
},
|
|
715
989
|
};
|
|
716
990
|
}
|
|
991
|
+
if (res.lockExit !== null) {
|
|
992
|
+
log(`git ${args.join(" ")} failed: ${res.stderr}`);
|
|
993
|
+
return notPushed(res.lockExit, { lockHolder: res.lockHolder });
|
|
994
|
+
}
|
|
717
995
|
log(`git ${args.join(" ")} failed: ${res.stderr} — replaying onto a fresh ${UPSTREAM}`);
|
|
718
996
|
}
|
|
719
997
|
const root = repoRoot(cwd);
|
|
@@ -746,6 +1024,7 @@ async function pushOwnCommits(cwd, rec, o, log, notPushed) {
|
|
|
746
1024
|
skipped: null,
|
|
747
1025
|
prNumber: null,
|
|
748
1026
|
replayed: true,
|
|
1027
|
+
mergedDev: false,
|
|
749
1028
|
},
|
|
750
1029
|
};
|
|
751
1030
|
case "refused":
|
|
@@ -802,6 +1081,7 @@ async function pushVerb(ctx) {
|
|
|
802
1081
|
skipped: "skip-ci",
|
|
803
1082
|
prNumber: null,
|
|
804
1083
|
replayed: false,
|
|
1084
|
+
mergedDev: false,
|
|
805
1085
|
});
|
|
806
1086
|
return EXIT_SKIP_CI;
|
|
807
1087
|
}
|
|
@@ -824,7 +1104,9 @@ async function pushVerb(ctx) {
|
|
|
824
1104
|
}, ctx.log);
|
|
825
1105
|
// A detached HEAD and a wrong checkout print nothing, as the push never got to run.
|
|
826
1106
|
if (r.code !== EXIT_DETACHED && r.code !== EXIT_NOT_DEV) {
|
|
827
|
-
ctx.emit(marker === undefined
|
|
1107
|
+
ctx.emit(marker === undefined
|
|
1108
|
+
? { lockHolder: null, ...r.out }
|
|
1109
|
+
: { lockHolder: null, ...r.out, commit: marker.sha, deduped: marker.deduped });
|
|
828
1110
|
}
|
|
829
1111
|
return r.code;
|
|
830
1112
|
}
|
|
@@ -857,14 +1139,228 @@ function fastForwardVerb(ctx) {
|
|
|
857
1139
|
}
|
|
858
1140
|
/** Paths a source-change check leaves out: plan logs and the append-only ledgers. */
|
|
859
1141
|
const NOT_CODE = [":(exclude)docs/plans", ":(exclude)docs/*.jsonl", ":(exclude).bkit/*.jsonl"];
|
|
1142
|
+
/** A test file's name at any tier: unit, integration, E2E. */
|
|
1143
|
+
const TEST_FILE = /\.(?:test|spec)\.|_test\.|(^|\/)test_[^/]*\.py$/;
|
|
1144
|
+
/** Added-line markers that disable a test: `bkit-slop-type-suppression.mjs`'s set, widened. */
|
|
1145
|
+
const MARKERS = [
|
|
1146
|
+
/\b(?:describe|context|it|test|suite|bench)\.(?:skip|todo|fixme)\b/,
|
|
1147
|
+
/(?<!\.)\bx(?:it|describe|test|context)\s*\(/,
|
|
1148
|
+
/\bxfail\b/,
|
|
1149
|
+
/\bt\.Skip\(/,
|
|
1150
|
+
/#\[ignore\b/,
|
|
1151
|
+
/@Disabled\b/,
|
|
1152
|
+
/@pytest\.mark\.skip\b/,
|
|
1153
|
+
/@unittest\.skip\b/,
|
|
1154
|
+
/\.skip\s*\(/,
|
|
1155
|
+
];
|
|
1156
|
+
/** The markers that apply to an added line of `file`: only a test file carries them. */
|
|
1157
|
+
const markersFor = (file) => (TEST_FILE.test(file) ? MARKERS : []);
|
|
1158
|
+
/** A quoted span: a marker inside it is prose or a fixture string, not a call. */
|
|
1159
|
+
const QUOTED = /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`/g;
|
|
1160
|
+
/** A line's trailing comment (`#` is one unless it opens a Rust or C attribute). */
|
|
1161
|
+
const COMMENT_TAIL = /(?:^|\s)(?:\/\/|#(?!\[))/;
|
|
1162
|
+
/** A line that opens or continues a block comment. */
|
|
1163
|
+
const BLOCK_COMMENT = /^\s*(?:\/\*|\*)/;
|
|
1164
|
+
/** `line` with its quoted spans and comment removed — the part a marker can be a call in. */
|
|
1165
|
+
function stripProse(line) {
|
|
1166
|
+
if (BLOCK_COMMENT.test(line))
|
|
1167
|
+
return "";
|
|
1168
|
+
const code = line.replace(QUOTED, '""');
|
|
1169
|
+
const cut = code.search(COMMENT_TAIL);
|
|
1170
|
+
return cut === -1 ? code : code.slice(0, cut);
|
|
1171
|
+
}
|
|
1172
|
+
/** An assertion call a change deletes from a test file: `expect(…)`, `assert.equal(…)`, `should(…)`. */
|
|
1173
|
+
const ASSERTION = /(?<![\w$])(?:expect|assert\w*|should_\w+|should)\s*[(.]/;
|
|
1174
|
+
/** Python's bare `assert x` statement, which calls nothing but asserts. */
|
|
1175
|
+
const BARE_ASSERT = /^\s*assert\s+\S/;
|
|
1176
|
+
/** A commented-out line: its words are prose, not a call. */
|
|
1177
|
+
const COMMENT = /^\s*(?:\/\/|\/\*|\*|#|--)/;
|
|
1178
|
+
/** True when a removed `line` takes an assertion, rather than being a comment or an import. */
|
|
1179
|
+
const isAssertion = (line) => !COMMENT.test(line) && (ASSERTION.test(line) || BARE_ASSERT.test(line));
|
|
1180
|
+
/** The test at 1-based `at` in `body`: the nearest declaration above it, else `line` itself. */
|
|
1181
|
+
function testAt(body, line, at) {
|
|
1182
|
+
if (body !== null) {
|
|
1183
|
+
const lines = body.split(/\r?\n/);
|
|
1184
|
+
const from = Math.min(at, lines.length) - 1;
|
|
1185
|
+
// A decorator (`@pytest.mark.skip`) names the test it sits on, which is below it.
|
|
1186
|
+
if (line.trimStart().startsWith("@")) {
|
|
1187
|
+
for (let i = from + 1; i < lines.length; i++) {
|
|
1188
|
+
const name = declaredName(lines[i]);
|
|
1189
|
+
if (name !== null)
|
|
1190
|
+
return name;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
for (let i = from; i >= 0; i--) {
|
|
1194
|
+
const name = declaredName(lines[i]);
|
|
1195
|
+
if (name !== null)
|
|
1196
|
+
return name;
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
return line.trim();
|
|
1200
|
+
}
|
|
1201
|
+
const HUNK = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;
|
|
1202
|
+
/**
|
|
1203
|
+
* The text of the regular file `rel` names under `root`, or null when it is missing, a
|
|
1204
|
+
* symlink, or resolves outside `root` — so a diff path never opens a file the repo does not hold.
|
|
1205
|
+
*/
|
|
1206
|
+
function inRepoFile(root, rel) {
|
|
1207
|
+
const abs = path.resolve(root, rel);
|
|
1208
|
+
const inside = (base, p) => {
|
|
1209
|
+
const r = path.relative(base, p);
|
|
1210
|
+
return r !== "" && !r.startsWith("..") && !path.isAbsolute(r);
|
|
1211
|
+
};
|
|
1212
|
+
if (!inside(root, abs))
|
|
1213
|
+
return null;
|
|
1214
|
+
const stat = fs.lstatSync(abs, { throwIfNoEntry: false });
|
|
1215
|
+
if (stat === undefined || stat.isSymbolicLink() || !stat.isFile())
|
|
1216
|
+
return null;
|
|
1217
|
+
// A symlinked parent directory can still lead outside the repo.
|
|
1218
|
+
if (!inside(fs.realpathSync(root), fs.realpathSync(abs)))
|
|
1219
|
+
return null;
|
|
1220
|
+
return fs.readFileSync(abs, "utf-8");
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Unmatched disabled markers and removed assertion occurrences in a unified diff.
|
|
1224
|
+
* Exact moves consume one added occurrence; cross-file moves require unchanged test context.
|
|
1225
|
+
* Rewritten assertions pair only inside the same file and test. Removed lines retain their
|
|
1226
|
+
* original test name; a deleted file uses old line numbers, otherwise the new hunk position.
|
|
1227
|
+
*/
|
|
1228
|
+
export function disabledTestsIn(diff, root) {
|
|
1229
|
+
const out = [];
|
|
1230
|
+
const bodies = new Map();
|
|
1231
|
+
const body = (rel) => {
|
|
1232
|
+
if (!bodies.has(rel))
|
|
1233
|
+
bodies.set(rel, inRepoFile(root, rel));
|
|
1234
|
+
return bodies.get(rel);
|
|
1235
|
+
};
|
|
1236
|
+
const added = [];
|
|
1237
|
+
const removed = [];
|
|
1238
|
+
const addedMarkers = [];
|
|
1239
|
+
const removedMarkers = [];
|
|
1240
|
+
const patches = new Map();
|
|
1241
|
+
let file = "";
|
|
1242
|
+
let from = "";
|
|
1243
|
+
let deleted = false;
|
|
1244
|
+
let current;
|
|
1245
|
+
let next = 0;
|
|
1246
|
+
let old = 0;
|
|
1247
|
+
for (const raw of diff.split("\n")) {
|
|
1248
|
+
if (raw.startsWith("diff --git ")) {
|
|
1249
|
+
current = undefined;
|
|
1250
|
+
file = "";
|
|
1251
|
+
continue;
|
|
1252
|
+
}
|
|
1253
|
+
if (raw.startsWith("--- ")) {
|
|
1254
|
+
from = raw.replace(/^--- (a\/)?/, "");
|
|
1255
|
+
continue;
|
|
1256
|
+
}
|
|
1257
|
+
if (raw.startsWith("+++ ")) {
|
|
1258
|
+
const plus = raw.replace(/^\+\+\+ (b\/)?/, "");
|
|
1259
|
+
file = plus === "/dev/null" ? from : plus;
|
|
1260
|
+
deleted = plus === "/dev/null";
|
|
1261
|
+
continue;
|
|
1262
|
+
}
|
|
1263
|
+
const hunk = HUNK.exec(raw);
|
|
1264
|
+
if (hunk !== null) {
|
|
1265
|
+
old = Number(hunk[1]);
|
|
1266
|
+
next = Number(hunk[3]);
|
|
1267
|
+
current = { start: next, count: Number(hunk[4] ?? 1), lines: [] };
|
|
1268
|
+
const hunks = patches.get(file) ?? [];
|
|
1269
|
+
hunks.push(current);
|
|
1270
|
+
patches.set(file, hunks);
|
|
1271
|
+
continue;
|
|
1272
|
+
}
|
|
1273
|
+
if (current === undefined)
|
|
1274
|
+
continue;
|
|
1275
|
+
if (raw.startsWith("+")) {
|
|
1276
|
+
const text = raw.slice(1);
|
|
1277
|
+
if (TEST_FILE.test(file)) {
|
|
1278
|
+
const occurrence = { file, line: next, text, test: testAt(body(file), text, next) };
|
|
1279
|
+
if (markersFor(file).some((m) => m.test(stripProse(text))))
|
|
1280
|
+
addedMarkers.push(occurrence);
|
|
1281
|
+
if (isAssertion(text))
|
|
1282
|
+
added.push(occurrence);
|
|
1283
|
+
}
|
|
1284
|
+
next++;
|
|
1285
|
+
}
|
|
1286
|
+
else if (raw.startsWith("-")) {
|
|
1287
|
+
const text = raw.slice(1);
|
|
1288
|
+
current.lines.push(text);
|
|
1289
|
+
if (TEST_FILE.test(file)) {
|
|
1290
|
+
const occurrence = { file, line: deleted ? old : next, old, text };
|
|
1291
|
+
if (isAssertion(text))
|
|
1292
|
+
removed.push(occurrence);
|
|
1293
|
+
if (markersFor(file).some((m) => m.test(stripProse(text))))
|
|
1294
|
+
removedMarkers.push(occurrence);
|
|
1295
|
+
}
|
|
1296
|
+
old++;
|
|
1297
|
+
}
|
|
1298
|
+
else if (raw.startsWith(" ")) {
|
|
1299
|
+
current.lines.push(raw.slice(1));
|
|
1300
|
+
next++;
|
|
1301
|
+
old++;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
const oldBodies = new Map();
|
|
1305
|
+
const original = (r) => {
|
|
1306
|
+
if (!oldBodies.has(r.file)) {
|
|
1307
|
+
const lines = body(r.file)?.split(/\r?\n/) ?? [];
|
|
1308
|
+
for (const hunk of [...(patches.get(r.file) ?? [])].reverse())
|
|
1309
|
+
lines.splice(Math.max(0, hunk.start - 1), hunk.count, ...hunk.lines);
|
|
1310
|
+
oldBodies.set(r.file, lines.join("\n"));
|
|
1311
|
+
}
|
|
1312
|
+
return { ...r, test: testAt(oldBodies.get(r.file), r.text, r.old) };
|
|
1313
|
+
};
|
|
1314
|
+
const contexts = new Map();
|
|
1315
|
+
const context = (occurrence, before) => {
|
|
1316
|
+
const key = JSON.stringify([before, occurrence.file, occurrence.test]);
|
|
1317
|
+
if (!contexts.has(key)) {
|
|
1318
|
+
const source = before ? oldBodies.get(occurrence.file) : body(occurrence.file);
|
|
1319
|
+
const lines = source == null ? null : testSource(source, occurrence.test);
|
|
1320
|
+
contexts.set(key, lines === null
|
|
1321
|
+
? null
|
|
1322
|
+
: lines
|
|
1323
|
+
.filter((line) => stripProse(line).trim() !== "" && !isAssertion(stripProse(line)))
|
|
1324
|
+
.map((line) => line
|
|
1325
|
+
.trim()
|
|
1326
|
+
.replace(/\b(it|test|suite|describe|context|bench)\.(?:skip|todo|fixme)\b/g, "$1"))
|
|
1327
|
+
.join("\n"));
|
|
1328
|
+
}
|
|
1329
|
+
return contexts.get(key);
|
|
1330
|
+
};
|
|
1331
|
+
const exact = (a, b) => a.text.trim() === b.text.trim() &&
|
|
1332
|
+
(a.file === b.file ||
|
|
1333
|
+
(a.test === b.test && context(a, true) !== null && context(a, true) === context(b, false)));
|
|
1334
|
+
const consume = (available, occurrence, match = exact) => {
|
|
1335
|
+
const index = available.findIndex((candidate) => match(occurrence, candidate));
|
|
1336
|
+
if (index === -1)
|
|
1337
|
+
return false;
|
|
1338
|
+
available.splice(index, 1);
|
|
1339
|
+
return true;
|
|
1340
|
+
};
|
|
1341
|
+
for (const r of removedMarkers)
|
|
1342
|
+
consume(addedMarkers, original(r), (a, b) => exact(a, b) &&
|
|
1343
|
+
a.test === b.test &&
|
|
1344
|
+
context(a, true) !== null &&
|
|
1345
|
+
context(a, true) === context(b, false));
|
|
1346
|
+
const drops = removed.map(original).filter((r) => !consume(added, r));
|
|
1347
|
+
for (const r of drops)
|
|
1348
|
+
if (!consume(added, r, (a, b) => a.file === b.file && a.test === b.test))
|
|
1349
|
+
out.push({ file: r.file, line: r.line, test: r.test });
|
|
1350
|
+
out.unshift(...addedMarkers.map(({ file, line, test }) => ({ file, line, test })));
|
|
1351
|
+
return out;
|
|
1352
|
+
}
|
|
860
1353
|
function scanDiffVerb(ctx) {
|
|
861
1354
|
const base = String(ctx.flags.base);
|
|
862
1355
|
const pattern = str(ctx.flags.paths);
|
|
863
1356
|
const marker = str(ctx.flags.marker);
|
|
864
1357
|
const code = ctx.flags.code === true;
|
|
865
|
-
|
|
866
|
-
|
|
1358
|
+
const disabled = ctx.flags.disabledTests === true;
|
|
1359
|
+
if ([pattern !== undefined, marker !== undefined, code, disabled].filter(Boolean).length !== 1) {
|
|
1360
|
+
throw new CommandError(EXIT.USAGE, "give exactly one of --paths, --marker, --code, --disabled-tests");
|
|
867
1361
|
}
|
|
1362
|
+
if (disabled && ctx.flags.expectNone === true)
|
|
1363
|
+
throw new CommandError(EXIT.USAGE, "--disabled-tests inverts the exit already; drop --expect-none");
|
|
868
1364
|
let re;
|
|
869
1365
|
if (pattern !== undefined) {
|
|
870
1366
|
try {
|
|
@@ -885,6 +1381,19 @@ function scanDiffVerb(ctx) {
|
|
|
885
1381
|
return EXIT_DIFF_FAILED;
|
|
886
1382
|
}
|
|
887
1383
|
const range = `${base}...HEAD`;
|
|
1384
|
+
if (disabled) {
|
|
1385
|
+
const diff = quietGit(top, ["diff", "--no-renames", range, "--", ".", ":(exclude)docs/plans"]);
|
|
1386
|
+
if (!diff.ok) {
|
|
1387
|
+
ctx.log(`git diff ${range} failed: ${diff.stderr}`);
|
|
1388
|
+
return EXIT_DIFF_FAILED;
|
|
1389
|
+
}
|
|
1390
|
+
const hits = disabledTestsIn(diff.stdout, top);
|
|
1391
|
+
const files = [...new Set(hits.map((h) => h.file))];
|
|
1392
|
+
ctx.emit({ found: hits.length > 0, paths: files, disabled: hits });
|
|
1393
|
+
if (hits.length > 0)
|
|
1394
|
+
ctx.log(`disabled tests or removed assertions:\n${hits.map((h) => `${h.file}:${h.line} — ${h.test}`).join("\n")}`);
|
|
1395
|
+
return hits.length > 0 ? EXIT.NO : EXIT.OK;
|
|
1396
|
+
}
|
|
888
1397
|
let paths;
|
|
889
1398
|
if (marker !== undefined) {
|
|
890
1399
|
const diff = quietGit(top, ["diff", "--no-renames", range, "--", ".", ":(exclude)docs/plans"]);
|
|
@@ -1000,40 +1509,417 @@ async function forceBuildVerb(ctx) {
|
|
|
1000
1509
|
});
|
|
1001
1510
|
return pushed.code;
|
|
1002
1511
|
}
|
|
1003
|
-
/**
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1512
|
+
/** The paths a feature branch must hold dev's commits for before GitHub reads it: docs/ and every ledger. */
|
|
1513
|
+
const DEV_DOC_PATHSPECS = ["docs/", ...LEDGERS.map((l) => `:(glob)${l}`)];
|
|
1514
|
+
/** Commits on origin/dev not in `head` that touch docs/ or a ledger. */
|
|
1515
|
+
function docsBehindOf(top, head) {
|
|
1516
|
+
return Number(git(top, ["rev-list", "--count", `${head}..${UPSTREAM}`, "--", ...DEV_DOC_PATHSPECS]) ?? "0");
|
|
1517
|
+
}
|
|
1518
|
+
/**
|
|
1519
|
+
* The `docs` merge: bring dev's docs/ and ledger commits onto the feature branch
|
|
1520
|
+
* when it is behind them, so GitHub, which ignores `merge=union`, reads no ledger
|
|
1521
|
+
* conflict and CI runs. Nothing on a shared branch or when docs/ is current.
|
|
1522
|
+
*/
|
|
1523
|
+
function mergeDevDocs(top, o, log) {
|
|
1524
|
+
const docsBehind = docsBehindOf(top, "HEAD");
|
|
1525
|
+
const current = isSharedBranch(o.branch) || docsBehind === 0;
|
|
1526
|
+
if (!current)
|
|
1527
|
+
log(`docs/ and the ledgers are ${docsBehind} commit(s) behind ${UPSTREAM} — merging it in`);
|
|
1528
|
+
const merged = mergeDev(top, { branch: o.branch, policy: "docs", generate: o.generate, current }, log);
|
|
1529
|
+
return { ...merged, docsBehind };
|
|
1530
|
+
}
|
|
1531
|
+
/**
|
|
1532
|
+
* Run the consumer's `bkit:generate` (`.bkit/workflows.md` § Local gate scripts)
|
|
1533
|
+
* and commit what it changed (`commitWhatChanged`). null when the script is undeclared.
|
|
1534
|
+
*/
|
|
1535
|
+
function regenerate(top, branch, log, o = {}) {
|
|
1536
|
+
if (!generateDeclared(top))
|
|
1537
|
+
return null;
|
|
1538
|
+
const fid = o.fid ?? branch.replace(/^feat\//, "");
|
|
1539
|
+
const message = `chore(${fid}): regenerate after merging ${DEV}`;
|
|
1540
|
+
const done = commitWhatChanged(top, "bkit:generate", () => runGenerate(top, log, "after the merge"), message, log);
|
|
1541
|
+
if (done.outcome === "committed")
|
|
1542
|
+
log(`committed bkit:generate's output after merging ${UPSTREAM}`);
|
|
1543
|
+
return done.outcome !== "failed";
|
|
1544
|
+
}
|
|
1545
|
+
/** Whether `top`'s package.json declares a non-empty `bkit:generate` script. */
|
|
1546
|
+
function generateDeclared(top) {
|
|
1547
|
+
const pkg = readPackageJson(top);
|
|
1548
|
+
const scripts = pkg.ok ? pkg.pkg.scripts : undefined;
|
|
1549
|
+
return (typeof scripts === "object" &&
|
|
1550
|
+
scripts !== null &&
|
|
1551
|
+
typeof scripts["bkit:generate"] === "string" &&
|
|
1552
|
+
scripts["bkit:generate"] !== "");
|
|
1553
|
+
}
|
|
1554
|
+
/** Run `bkit:generate` in `top`; false when it failed, logged with its output's last lines. */
|
|
1555
|
+
function runGenerate(top, log, when) {
|
|
1556
|
+
return runLogged(top, scriptCommand("bkit:generate"), log, when);
|
|
1557
|
+
}
|
|
1558
|
+
/** Run `argv` in `top`; false when it failed, logged with its output's last lines. */
|
|
1559
|
+
function runLogged(top, argv, log, when) {
|
|
1560
|
+
const res = spawnSync(argv[0], argv.slice(1), {
|
|
1561
|
+
cwd: top,
|
|
1562
|
+
encoding: "utf-8",
|
|
1563
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
1564
|
+
maxBuffer: 1 << 26,
|
|
1565
|
+
});
|
|
1566
|
+
if (res.status === 0)
|
|
1567
|
+
return true;
|
|
1568
|
+
log(`${argv.join(" ")} exited ${String(res.status ?? res.error?.message)} ${when}`);
|
|
1569
|
+
const out = `${res.stdout ?? ""}${res.stderr ?? ""}`.trim();
|
|
1570
|
+
if (out !== "")
|
|
1571
|
+
for (const line of out.split("\n").slice(-20))
|
|
1572
|
+
log(` ${line}`);
|
|
1573
|
+
return false;
|
|
1574
|
+
}
|
|
1575
|
+
/**
|
|
1576
|
+
* Each changed path in `top` (the entries worktree setup copies in left out), with a hash
|
|
1577
|
+
* of its content ("" when deleted); null when git could not run. Read raw: `--porcelain`
|
|
1578
|
+
* lines start with a status column that may be a space.
|
|
1579
|
+
*/
|
|
1580
|
+
function changedPaths(top) {
|
|
1581
|
+
const res = spawnSync("git", ["status", "--porcelain=v1", "-z", "--untracked-files=all", "--", ".", ...copyExcludes(top)], { cwd: top, env: gitEnv(), encoding: "utf-8", maxBuffer: OUTPUT_LIMIT });
|
|
1582
|
+
if (res.error || res.status !== 0)
|
|
1583
|
+
return null;
|
|
1584
|
+
const out = new Map();
|
|
1585
|
+
const entries = res.stdout.split("\0");
|
|
1586
|
+
for (let i = 0; i < entries.length; i++) {
|
|
1587
|
+
const entry = entries[i];
|
|
1588
|
+
if (entry.length < 4)
|
|
1015
1589
|
continue;
|
|
1016
|
-
|
|
1590
|
+
const file = entry.slice(3);
|
|
1591
|
+
// A staged rename or copy carries its source as the next entry.
|
|
1592
|
+
if (entry[0] === "R" || entry[0] === "C")
|
|
1593
|
+
i++;
|
|
1594
|
+
const abs = path.join(top, file);
|
|
1595
|
+
out.set(file, fs.existsSync(abs) && fs.statSync(abs).isFile()
|
|
1596
|
+
? createHash("sha256").update(fs.readFileSync(abs)).digest("hex")
|
|
1597
|
+
: "");
|
|
1598
|
+
}
|
|
1599
|
+
return out;
|
|
1600
|
+
}
|
|
1601
|
+
/**
|
|
1602
|
+
* What a generator changed between two `changedPaths` reads: `rewritten` were already
|
|
1603
|
+
* changed and changed again, so they cannot be told apart from work that is not
|
|
1604
|
+
* generated; `added` are the paths only the generator changed, sorted.
|
|
1605
|
+
*/
|
|
1606
|
+
function changedSince(dirty, after) {
|
|
1607
|
+
return {
|
|
1608
|
+
rewritten: [...after].filter(([f, h]) => dirty.has(f) && dirty.get(f) !== h).map(([f]) => f),
|
|
1609
|
+
added: [...after.keys()].filter((f) => !dirty.has(f)).sort(),
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
/** Commit exactly `paths`, deletions included; false when the add or the commit failed. */
|
|
1613
|
+
function commitPaths(top, paths, message) {
|
|
1614
|
+
return (runGit(top, ["add", "-A", "--", ...paths]).ok &&
|
|
1615
|
+
quietGit(top, ["commit", "-q", "-m", message, "--", ...paths]).ok);
|
|
1616
|
+
}
|
|
1617
|
+
/**
|
|
1618
|
+
* Run a generator (`run`, named `what` in the log) in `top` and commit exactly the paths
|
|
1619
|
+
* it changed as `message`, so uncommitted work already in the tree stays out of the
|
|
1620
|
+
* commit. `failed` (logged) when `git status` or the commit failed, `run` failed, or it
|
|
1621
|
+
* changed a path that already held uncommitted changes again: that cannot be told apart
|
|
1622
|
+
* from work that is not generated. `unchanged` when it changed nothing.
|
|
1623
|
+
*/
|
|
1624
|
+
function commitWhatChanged(top, what, run, message, log) {
|
|
1625
|
+
const failed = { outcome: "failed", paths: [] };
|
|
1626
|
+
const dirty = changedPaths(top);
|
|
1627
|
+
if (dirty === null) {
|
|
1628
|
+
log(`git status failed — ${what} not run`);
|
|
1629
|
+
return failed;
|
|
1630
|
+
}
|
|
1631
|
+
if (!run())
|
|
1632
|
+
return failed;
|
|
1633
|
+
const after = changedPaths(top);
|
|
1634
|
+
if (after === null) {
|
|
1635
|
+
log(`git status failed after ${what}`);
|
|
1636
|
+
return failed;
|
|
1637
|
+
}
|
|
1638
|
+
const { rewritten, added } = changedSince(dirty, after);
|
|
1639
|
+
if (rewritten.length > 0) {
|
|
1640
|
+
for (const f of rewritten)
|
|
1641
|
+
log(` ${f}`);
|
|
1642
|
+
log(`${what} changed paths that already held uncommitted changes — nothing committed`);
|
|
1643
|
+
return failed;
|
|
1644
|
+
}
|
|
1645
|
+
if (added.length === 0)
|
|
1646
|
+
return { outcome: "unchanged", paths: [] };
|
|
1647
|
+
if (!commitPaths(top, added, message)) {
|
|
1648
|
+
log(`committing the output of ${what} failed`);
|
|
1649
|
+
return failed;
|
|
1650
|
+
}
|
|
1651
|
+
return { outcome: "committed", paths: added };
|
|
1652
|
+
}
|
|
1653
|
+
/**
|
|
1654
|
+
* Rebuild each register a conflict settled on dev's copy (`REGISTERS`), or whose
|
|
1655
|
+
* generated block a conflicted doc took from dev, and commit only the paths the rebuild
|
|
1656
|
+
* changed. null when none was settled, or no settled register's script exists in the
|
|
1657
|
+
* repo; false when a rebuild failed, or changed a path that already held uncommitted
|
|
1658
|
+
* changes. A register not rebuilt keeps dev's copy: the pre-push gate, CI and ship's
|
|
1659
|
+
* `bkit:generate` still judge it.
|
|
1660
|
+
*/
|
|
1661
|
+
function rebuildRegisters(top, resolved, commitMessage, log) {
|
|
1662
|
+
const embeds = embedDocs(top);
|
|
1663
|
+
const settled = [
|
|
1664
|
+
...new Set(resolved.flatMap((r) => {
|
|
1665
|
+
const register = r.how === "register" ? r.path : r.how === "embed" ? embeds.get(r.path) : undefined;
|
|
1666
|
+
return register === undefined ? [] : [register];
|
|
1667
|
+
})),
|
|
1668
|
+
];
|
|
1669
|
+
const due = settled.filter((f) => fs.existsSync(path.join(top, REGISTERS[f].script)));
|
|
1670
|
+
for (const f of settled)
|
|
1671
|
+
if (!due.includes(f))
|
|
1672
|
+
log(`NOT REBUILT ${f} — ${REGISTERS[f].script} is absent`);
|
|
1673
|
+
if (due.length === 0)
|
|
1674
|
+
return null;
|
|
1675
|
+
const which = due.join(", ");
|
|
1676
|
+
const rebuild = () => due.every((f) => {
|
|
1677
|
+
const { script, args } = REGISTERS[f];
|
|
1678
|
+
if (runLogged(top, ["bash", script, ...args], log, `rebuilding ${f}`))
|
|
1679
|
+
return true;
|
|
1680
|
+
log(`NOT REBUILT ${f} — it keeps ${DEV}'s copy`);
|
|
1681
|
+
return false;
|
|
1682
|
+
});
|
|
1683
|
+
const done = commitWhatChanged(top, `the rebuild of ${which}`, rebuild, commitMessage(due), log);
|
|
1684
|
+
if (done.outcome === "failed")
|
|
1685
|
+
return false;
|
|
1686
|
+
log(done.outcome === "unchanged"
|
|
1687
|
+
? `REBUILT ${which} — ${DEV}'s copy was already current`
|
|
1688
|
+
: `REBUILT ${which} — committed as ${git(top, ["rev-parse", "HEAD"])}`);
|
|
1689
|
+
return true;
|
|
1690
|
+
}
|
|
1691
|
+
/**
|
|
1692
|
+
* Ship's regenerate (`.bkit/workflows.md` § `/bkit-ship`): run a declared `bkit:generate`
|
|
1693
|
+
* on the checked-out feature branch and commit only the paths it changed
|
|
1694
|
+
* (`commitWhatChanged`), so the run's own uncommitted bookkeeping (status.jsonl) stays out
|
|
1695
|
+
* of the commit. Step 10 runs it when every failed CI step is one it fixes (`--attempt`).
|
|
1696
|
+
*/
|
|
1697
|
+
function regenerateVerb(ctx) {
|
|
1698
|
+
const top = topLevel(ctx.cwd);
|
|
1699
|
+
const branch = currentBranch(top);
|
|
1700
|
+
if (branch === "") {
|
|
1701
|
+
ctx.log("no branch checked out (detached HEAD) — cannot regenerate");
|
|
1702
|
+
return EXIT_DETACHED;
|
|
1703
|
+
}
|
|
1704
|
+
if (isSharedBranch(branch))
|
|
1705
|
+
throw new CommandError(EXIT.USAGE, `regenerate runs on a feature branch, never on ${branch}`);
|
|
1706
|
+
const attempt = str(ctx.flags.attempt);
|
|
1707
|
+
if (attempt !== undefined && !/^[1-9]\d*$/.test(attempt))
|
|
1708
|
+
throw new CommandError(EXIT.USAGE, "--attempt must be a whole number >= 1");
|
|
1709
|
+
const fid = str(ctx.flags.fid) || branch.replace(/^feat\//, "");
|
|
1710
|
+
const before = git(top, ["rev-parse", "HEAD"]);
|
|
1711
|
+
const out = { outcome: "undeclared", head: before, paths: [] };
|
|
1712
|
+
if (!generateDeclared(top)) {
|
|
1713
|
+
ctx.log("bkit:generate is not declared — nothing regenerated");
|
|
1714
|
+
ctx.emit(out);
|
|
1715
|
+
return EXIT.OK;
|
|
1716
|
+
}
|
|
1717
|
+
const message = attempt === undefined
|
|
1718
|
+
? `chore(${fid}): regenerate before re-validating`
|
|
1719
|
+
: `fix(${fid}): regenerate attempt ${attempt}`;
|
|
1720
|
+
const done = commitWhatChanged(top, "bkit:generate", () => runGenerate(top, ctx.log, "on the branch"), message, ctx.log);
|
|
1721
|
+
if (done.outcome === "failed")
|
|
1722
|
+
return EXIT_GENERATE_FAILED;
|
|
1723
|
+
out.paths = done.paths;
|
|
1724
|
+
if (done.outcome === "unchanged") {
|
|
1725
|
+
out.outcome = "unchanged";
|
|
1726
|
+
ctx.log("bkit:generate changed nothing");
|
|
1727
|
+
ctx.emit(out);
|
|
1728
|
+
return EXIT.OK;
|
|
1729
|
+
}
|
|
1730
|
+
out.outcome = "committed";
|
|
1731
|
+
out.head = git(top, ["rev-parse", "HEAD"]);
|
|
1732
|
+
for (const f of out.paths)
|
|
1733
|
+
ctx.log(`regenerated ${f}`);
|
|
1734
|
+
ctx.log(`committed bkit:generate's output as ${out.head}`);
|
|
1735
|
+
const statusFile = str(ctx.flags.file);
|
|
1736
|
+
if (statusFile !== undefined && before !== null && out.head !== null) {
|
|
1737
|
+
recordAction(path.resolve(ctx.cwd, statusFile), {
|
|
1738
|
+
action: "regenerate",
|
|
1739
|
+
key: actionKey("regenerate", before),
|
|
1740
|
+
hash: actionHash(`${before}..${out.head}`),
|
|
1741
|
+
ref: out.head,
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
ctx.emit(out);
|
|
1745
|
+
return EXIT.OK;
|
|
1746
|
+
}
|
|
1747
|
+
/** Whether a merge is in progress in `top` (its MERGE_HEAD exists). */
|
|
1748
|
+
function mergeInProgress(top) {
|
|
1749
|
+
const p = git(top, ["rev-parse", "--path-format=absolute", "--git-path", "MERGE_HEAD"]);
|
|
1750
|
+
return p !== null && fs.existsSync(p);
|
|
1751
|
+
}
|
|
1752
|
+
/** Settle one conflicted path under `policy`, staging it when it is resolved. */
|
|
1753
|
+
function resolvePath(top, file, policy, embeds) {
|
|
1754
|
+
const kind = classifyConflict(file, embeds);
|
|
1755
|
+
if (kind === "ledger") {
|
|
1756
|
+
const union = unionResolve(top, file);
|
|
1757
|
+
if (!union.ok)
|
|
1758
|
+
return { refused: union.problem };
|
|
1759
|
+
return runGit(top, ["add", "--", file]).ok ? "union" : { refused: "git add failed" };
|
|
1760
|
+
}
|
|
1761
|
+
if (kind === "register") {
|
|
1762
|
+
const settled = registerResolve(top, file, "theirs");
|
|
1763
|
+
if (!settled.ok)
|
|
1764
|
+
return { refused: settled.problem };
|
|
1765
|
+
return runGit(top, ["add", "--", file]).ok ? "register" : { refused: "git add failed" };
|
|
1766
|
+
}
|
|
1767
|
+
if (kind === "embed") {
|
|
1768
|
+
const settled = embedResolve(top, file, embeds.get(file), "theirs");
|
|
1769
|
+
if (!settled.ok)
|
|
1770
|
+
return { refused: settled.problem };
|
|
1771
|
+
return runGit(top, ["add", "--", file]).ok ? "embed" : { refused: "git add failed" };
|
|
1772
|
+
}
|
|
1773
|
+
if (kind === "record") {
|
|
1774
|
+
const settled = recordResolve(top, "theirs");
|
|
1775
|
+
if (!settled.ok)
|
|
1776
|
+
return { refused: settled.problem };
|
|
1777
|
+
return runGit(top, ["add", "--", file]).ok ? "record" : { refused: "git add failed" };
|
|
1778
|
+
}
|
|
1779
|
+
if (policy === "docs") {
|
|
1780
|
+
if (!file.startsWith("docs/"))
|
|
1781
|
+
return { refused: "outside docs/ and the ledgers" };
|
|
1017
1782
|
// In a merge `--theirs` is the branch merged in: dev. Dev deleting the file
|
|
1018
1783
|
// leaves no stage 3, and taking dev's side means deleting it here too.
|
|
1019
|
-
const devHasIt = runGit(top, ["cat-file", "-e", `:3:${
|
|
1784
|
+
const devHasIt = runGit(top, ["cat-file", "-e", `:3:${file}`]).ok;
|
|
1020
1785
|
const ok = devHasIt
|
|
1021
|
-
? runGit(top, ["checkout", "--theirs", "--",
|
|
1022
|
-
: runGit(top, ["rm", "-q", "--",
|
|
1023
|
-
|
|
1024
|
-
return { refused: f };
|
|
1025
|
-
resolved.push({ path: f, how: "dev" });
|
|
1786
|
+
? runGit(top, ["checkout", "--theirs", "--", file]).ok && runGit(top, ["add", "--", file]).ok
|
|
1787
|
+
: runGit(top, ["rm", "-q", "--", file]).ok;
|
|
1788
|
+
return ok ? "dev" : { refused: `taking ${DEV}'s side failed` };
|
|
1026
1789
|
}
|
|
1027
|
-
|
|
1790
|
+
if (kind === "lockfile") {
|
|
1791
|
+
if (!lockfileResolve(top, file, "theirs"))
|
|
1792
|
+
return { refused: "lockfile regenerate failed" };
|
|
1793
|
+
return runGit(top, ["add", "--", file]).ok ? "lockfile" : { refused: "git add failed" };
|
|
1794
|
+
}
|
|
1795
|
+
return "pending";
|
|
1796
|
+
}
|
|
1797
|
+
const RESOLVED_HOW = {
|
|
1798
|
+
union: "union (append-only ledger)",
|
|
1799
|
+
dev: `took ${DEV}`,
|
|
1800
|
+
lockfile: `lockfile regenerated from ${DEV}'s copy`,
|
|
1801
|
+
register: `took ${DEV}'s copy of a generated register`,
|
|
1802
|
+
embed: `took ${DEV}'s copy of the generated block, merged the rest`,
|
|
1803
|
+
record: `merged the install record entry by entry, ${DEV}'s value where both changed`,
|
|
1804
|
+
};
|
|
1805
|
+
/**
|
|
1806
|
+
* Merge origin/dev (already fetched) into the checked-out feature branch under
|
|
1807
|
+
* `policy`. A merge in progress at the start is continued: its remaining conflicts
|
|
1808
|
+
* are settled and it is committed, which is how a `full` hand resolution finishes
|
|
1809
|
+
* (`git add`, then run again). `full` also commits the tree's uncommitted work first
|
|
1810
|
+
* (ship's open status.jsonl). No commit carries a skip token: the merge brings dev's
|
|
1811
|
+
* code, and the pre-push hook refuses a skip-token head that carries code while the
|
|
1812
|
+
* PR is open. Never a rebase: GitHub ignores `merge=union`, so a
|
|
1813
|
+
* branch rebased onto dev still shows as conflicting on every ledger both sides
|
|
1814
|
+
* appended to, while the merge commit is what GitHub's own merge would compute.
|
|
1815
|
+
*/
|
|
1816
|
+
function mergeDev(top, o, log) {
|
|
1817
|
+
const out = {
|
|
1818
|
+
code: EXIT.OK,
|
|
1819
|
+
outcome: "merged",
|
|
1820
|
+
merged: false,
|
|
1821
|
+
carried: null,
|
|
1822
|
+
resolved: [],
|
|
1823
|
+
pending: [],
|
|
1824
|
+
aborted: false,
|
|
1825
|
+
generated: null,
|
|
1826
|
+
rebuilt: null,
|
|
1827
|
+
before: null,
|
|
1828
|
+
};
|
|
1829
|
+
const full = o.policy === "full";
|
|
1830
|
+
const fid = o.fid ?? o.branch.replace(/^feat\//, "");
|
|
1831
|
+
const refuse = (why) => {
|
|
1832
|
+
const abort = runGit(top, ["merge", "--abort"]);
|
|
1833
|
+
out.aborted = abort.ok;
|
|
1834
|
+
log(abort.ok ? `${why} — merge aborted` : `${why} — git merge --abort failed: ${abort.stderr}`);
|
|
1835
|
+
return { ...out, code: EXIT_MERGE_CONFLICT, outcome: "refused" };
|
|
1836
|
+
};
|
|
1837
|
+
if (mergeInProgress(top)) {
|
|
1838
|
+
out.before = git(top, ["rev-parse", "--verify", "--quiet", "ORIG_HEAD"]);
|
|
1839
|
+
log(`a merge of ${UPSTREAM} is in progress — continuing it`);
|
|
1840
|
+
}
|
|
1841
|
+
else {
|
|
1842
|
+
if (o.current)
|
|
1843
|
+
return { ...out, outcome: "current" };
|
|
1844
|
+
if (full && hasLeftovers(top)) {
|
|
1845
|
+
const message = `chore(${fid}): carry uncommitted work before merging ${DEV}`;
|
|
1846
|
+
if (!addAllButCopied(top).ok || !quietGit(top, ["commit", "-q", "-m", message]).ok) {
|
|
1847
|
+
log("the uncommitted work could not be committed before the merge");
|
|
1848
|
+
return { ...out, code: EXIT_REFUSED, outcome: "refused" };
|
|
1849
|
+
}
|
|
1850
|
+
out.carried = git(top, ["rev-parse", "HEAD"]);
|
|
1851
|
+
log(`committed the uncommitted work as ${out.carried} before merging ${UPSTREAM}`);
|
|
1852
|
+
}
|
|
1853
|
+
out.before = git(top, ["rev-parse", "HEAD"]);
|
|
1854
|
+
const message = `chore(${fid}): merge ${DEV}`;
|
|
1855
|
+
const merge = quietGit(top, ["merge", "--no-edit", "-m", message, UPSTREAM]);
|
|
1856
|
+
if (!merge.ok && !mergeInProgress(top)) {
|
|
1857
|
+
// Not a conflict: git refused to start the merge at all.
|
|
1858
|
+
log(`git merge ${UPSTREAM} failed: ${merge.stderr.trim()}`);
|
|
1859
|
+
return { ...out, code: EXIT_MERGE_CONFLICT, outcome: "refused" };
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
if (mergeInProgress(top)) {
|
|
1863
|
+
const embeds = embedDocs(top);
|
|
1864
|
+
for (const f of unmergedPaths(top)) {
|
|
1865
|
+
const r = resolvePath(top, f, o.policy, embeds);
|
|
1866
|
+
if (typeof r === "object")
|
|
1867
|
+
return refuse(`${f}: ${r.refused}`);
|
|
1868
|
+
if (r === "pending") {
|
|
1869
|
+
out.pending.push(f);
|
|
1870
|
+
continue;
|
|
1871
|
+
}
|
|
1872
|
+
out.resolved.push({ path: f, how: r });
|
|
1873
|
+
log(`RESOLVED ${f} — ${RESOLVED_HOW[r]}`);
|
|
1874
|
+
}
|
|
1875
|
+
if (out.pending.length > 0) {
|
|
1876
|
+
for (const p of out.pending)
|
|
1877
|
+
log(`PENDING ${p} — needs a hand resolution; run again after git add`);
|
|
1878
|
+
return { ...out, code: EXIT_HAND_RESOLVE, outcome: "pending" };
|
|
1879
|
+
}
|
|
1880
|
+
if (!quietGit(top, ["commit", "--no-edit"]).ok)
|
|
1881
|
+
return refuse("the merge could not be committed");
|
|
1882
|
+
}
|
|
1883
|
+
out.merged = true;
|
|
1884
|
+
log(`merged ${UPSTREAM} into ${o.branch} as ${git(top, ["rev-parse", "HEAD"])}`);
|
|
1885
|
+
if (o.generate) {
|
|
1886
|
+
out.rebuilt = rebuildRegisters(top, out.resolved, (files) => `chore(${fid}): rebuild ${files.join(" ")} after merging ${DEV}`, log);
|
|
1887
|
+
out.generated = regenerate(top, o.branch, log, { fid });
|
|
1888
|
+
if (out.generated === false)
|
|
1889
|
+
out.code = EXIT_GENERATE_FAILED;
|
|
1890
|
+
}
|
|
1891
|
+
return out;
|
|
1892
|
+
}
|
|
1893
|
+
/**
|
|
1894
|
+
* An engine-action row for a merge of origin/dev that moved the branch, keyed on
|
|
1895
|
+
* the tip it started from, so the run's record shows the integration. Nothing when
|
|
1896
|
+
* HEAD did not move.
|
|
1897
|
+
*/
|
|
1898
|
+
function recordMerge(statusFile, before, after) {
|
|
1899
|
+
if (before === null || after === null || before === after)
|
|
1900
|
+
return;
|
|
1901
|
+
recordAction(statusFile, {
|
|
1902
|
+
action: "merge",
|
|
1903
|
+
key: actionKey("merge", before),
|
|
1904
|
+
hash: actionHash(`${before}..${after}`),
|
|
1905
|
+
ref: after,
|
|
1906
|
+
});
|
|
1028
1907
|
}
|
|
1029
1908
|
function syncVerb(ctx) {
|
|
1030
1909
|
const mergeDocs = ctx.flags.mergeDocs === true;
|
|
1910
|
+
const merge = ctx.flags.merge === true;
|
|
1031
1911
|
const headFlag = str(ctx.flags.head);
|
|
1032
|
-
if (mergeDocs && headFlag !== undefined) {
|
|
1033
|
-
throw new CommandError(EXIT.USAGE, "--merge-docs
|
|
1912
|
+
if ((mergeDocs || merge) && headFlag !== undefined) {
|
|
1913
|
+
throw new CommandError(EXIT.USAGE, "--merge and --merge-docs merge into HEAD; give --head or one of them, not both");
|
|
1034
1914
|
}
|
|
1915
|
+
if (mergeDocs && merge)
|
|
1916
|
+
throw new CommandError(EXIT.USAGE, "give --merge or --merge-docs, not both");
|
|
1917
|
+
const sentinel = str(ctx.flags.sentinel);
|
|
1918
|
+
const sentinelPath = sentinel === undefined ? undefined : path.resolve(ctx.cwd, sentinel);
|
|
1919
|
+
if (merge && sentinelPath)
|
|
1920
|
+
fs.rmSync(sentinelPath, { force: true });
|
|
1035
1921
|
const top = topLevel(ctx.cwd);
|
|
1036
|
-
const fetch =
|
|
1922
|
+
const fetch = fetchDev(top);
|
|
1037
1923
|
if (!fetch.ok) {
|
|
1038
1924
|
ctx.log(`git fetch ${REMOTE} ${DEV} failed: ${fetch.stderr}`);
|
|
1039
1925
|
return EXIT_FETCH_FAILED;
|
|
@@ -1051,7 +1937,7 @@ function syncVerb(ctx) {
|
|
|
1051
1937
|
}
|
|
1052
1938
|
const count = (args) => Number(git(top, ["rev-list", "--count", ...args]) ?? "0");
|
|
1053
1939
|
const behind = count([`${head}..${UPSTREAM}`]);
|
|
1054
|
-
const docsBehind =
|
|
1940
|
+
const docsBehind = docsBehindOf(top, head);
|
|
1055
1941
|
const out = {
|
|
1056
1942
|
branch: branch === "" ? null : branch,
|
|
1057
1943
|
head,
|
|
@@ -1060,33 +1946,59 @@ function syncVerb(ctx) {
|
|
|
1060
1946
|
docsBehind,
|
|
1061
1947
|
merged: false,
|
|
1062
1948
|
resolved: [],
|
|
1949
|
+
generated: null,
|
|
1950
|
+
rebuilt: null,
|
|
1063
1951
|
};
|
|
1064
1952
|
if (mergeDocs) {
|
|
1065
1953
|
if (branch === "") {
|
|
1066
1954
|
ctx.log("no branch checked out (detached HEAD) — cannot merge dev's docs");
|
|
1067
1955
|
return EXIT_DETACHED;
|
|
1068
1956
|
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
}
|
|
1078
|
-
if (unmergedPaths(top).length > 0 || !quietGit(top, ["commit", "--no-edit"]).ok) {
|
|
1079
|
-
runGit(top, ["merge", "--abort"]);
|
|
1080
|
-
ctx.log(`merge of ${UPSTREAM} could not be committed — merge aborted`);
|
|
1081
|
-
return EXIT_MERGE_CONFLICT;
|
|
1082
|
-
}
|
|
1083
|
-
out.resolved = outcome.resolved;
|
|
1084
|
-
for (const r of outcome.resolved)
|
|
1085
|
-
ctx.log(`RESOLVED ${r.path} — ${r.how === "union" ? "union (append-only ledger)" : `took ${DEV}`}`);
|
|
1086
|
-
}
|
|
1087
|
-
out.merged = true;
|
|
1957
|
+
const m = mergeDevDocs(top, { branch, generate: true }, ctx.log);
|
|
1958
|
+
if (m.code === EXIT_MERGE_CONFLICT)
|
|
1959
|
+
return m.code;
|
|
1960
|
+
out.merged = m.merged;
|
|
1961
|
+
out.resolved = m.resolved;
|
|
1962
|
+
out.generated = m.generated;
|
|
1963
|
+
out.rebuilt = m.rebuilt;
|
|
1964
|
+
if (m.merged)
|
|
1088
1965
|
out.head = git(top, ["rev-parse", "HEAD"]) ?? head;
|
|
1966
|
+
ctx.emit(out);
|
|
1967
|
+
return m.code;
|
|
1968
|
+
}
|
|
1969
|
+
if (merge) {
|
|
1970
|
+
if (branch === "") {
|
|
1971
|
+
ctx.log(`no branch checked out (detached HEAD) — cannot merge ${UPSTREAM}`);
|
|
1972
|
+
return EXIT_DETACHED;
|
|
1973
|
+
}
|
|
1974
|
+
if (isSharedBranch(branch)) {
|
|
1975
|
+
throw new CommandError(EXIT.USAGE, `--merge merges ${UPSTREAM} into a feature branch, never into ${branch}`);
|
|
1089
1976
|
}
|
|
1977
|
+
const fid = str(ctx.flags.fid) || branch.replace(/^feat\//, "");
|
|
1978
|
+
const m = mergeDev(top, { branch, policy: "full", fid, generate: true, current: out.basePath === "A" }, ctx.log);
|
|
1979
|
+
const refused = m.outcome === "refused";
|
|
1980
|
+
if (refused && sentinelPath) {
|
|
1981
|
+
fs.mkdirSync(path.dirname(sentinelPath), { recursive: true });
|
|
1982
|
+
fs.writeFileSync(sentinelPath, "");
|
|
1983
|
+
}
|
|
1984
|
+
const newHead = git(top, ["rev-parse", "HEAD"]) ?? head;
|
|
1985
|
+
ctx.emit({
|
|
1986
|
+
...out,
|
|
1987
|
+
head: newHead,
|
|
1988
|
+
merged: m.merged,
|
|
1989
|
+
resolved: m.resolved,
|
|
1990
|
+
generated: m.generated,
|
|
1991
|
+
rebuilt: m.rebuilt,
|
|
1992
|
+
outcome: m.outcome,
|
|
1993
|
+
carried: m.carried,
|
|
1994
|
+
pending: m.pending,
|
|
1995
|
+
aborted: m.aborted,
|
|
1996
|
+
sentinel: refused && sentinel !== undefined ? sentinel : null,
|
|
1997
|
+
});
|
|
1998
|
+
const statusFile = str(ctx.flags.file);
|
|
1999
|
+
if (m.merged && statusFile !== undefined)
|
|
2000
|
+
recordMerge(path.resolve(ctx.cwd, statusFile), m.before, newHead);
|
|
2001
|
+
return m.code;
|
|
1090
2002
|
}
|
|
1091
2003
|
ctx.emit(out);
|
|
1092
2004
|
return EXIT.OK;
|
|
@@ -1098,7 +2010,7 @@ function syncVerb(ctx) {
|
|
|
1098
2010
|
*/
|
|
1099
2011
|
function syncDevVerb(ctx) {
|
|
1100
2012
|
const root = repoRoot(ctx.cwd);
|
|
1101
|
-
const fetch =
|
|
2013
|
+
const fetch = fetchDev(root);
|
|
1102
2014
|
if (!fetch.ok) {
|
|
1103
2015
|
ctx.log(`git fetch ${REMOTE} ${DEV} failed: ${fetch.stderr}`);
|
|
1104
2016
|
return EXIT_FETCH_FAILED;
|
|
@@ -1205,8 +2117,10 @@ function buildClose(ctx, dir, o) {
|
|
|
1205
2117
|
const staged = (git(dir, ["diff", "--cached", "--name-only"]) ?? "")
|
|
1206
2118
|
.split("\n")
|
|
1207
2119
|
.filter((p) => p !== "" && !CLOSE_DOCS.test(p));
|
|
1208
|
-
if (staged.length)
|
|
1209
|
-
|
|
2120
|
+
if (staged.length) {
|
|
2121
|
+
const inherited = localDevCopies(dir, staged, (p) => `:${p}`);
|
|
2122
|
+
throw new Stop(EXIT_LAND_STOPPED, `${o.workflow} close staged non-doc files:\n${staged.join("\n")}${unpushedDevCause(dir, inherited.length, staged.length, ", then re-run the close.")}`);
|
|
2123
|
+
}
|
|
1210
2124
|
const docs = canonicalDocs(dir, o.branch, o.workflow, o.month, o.fid);
|
|
1211
2125
|
const main = `docs/plans/${o.month}/${o.fid}-${o.workflow}.md`;
|
|
1212
2126
|
if (!docs.includes(main))
|
|
@@ -1267,11 +2181,32 @@ function branchTree(root, branch) {
|
|
|
1267
2181
|
}
|
|
1268
2182
|
return null;
|
|
1269
2183
|
}
|
|
2184
|
+
/**
|
|
2185
|
+
* A land retry: merge origin/dev's docs and ledger commits into the PR branch in
|
|
2186
|
+
* the checkout holding it and push, so the PR carries dev's ledger rows. GitHub's
|
|
2187
|
+
* own branch update ignores `merge=union` and fails on the same conflict each time.
|
|
2188
|
+
*/
|
|
2189
|
+
async function mergeDevIntoPrBranch(root, branch, log) {
|
|
2190
|
+
const tree = branchTree(root, branch);
|
|
2191
|
+
if (tree === null)
|
|
2192
|
+
throw new Stop(EXIT_LAND_STOPPED, `no checkout has ${branch} checked out — cannot merge ${DEV} into the PR branch; the PR stays open`);
|
|
2193
|
+
if (!fetchDev(tree).ok)
|
|
2194
|
+
throw new Stop(EXIT_LAND_STOPPED, `fetch of ${UPSTREAM} failed — the PR stays open`);
|
|
2195
|
+
const m = mergeDevDocs(tree, { branch, generate: false }, log);
|
|
2196
|
+
if (m.code !== EXIT.OK)
|
|
2197
|
+
throw new Stop(EXIT_LAND_STOPPED, `merging ${UPSTREAM} into ${branch} stopped on a conflict outside docs/ and the ledgers — the PR stays open`);
|
|
2198
|
+
if (!m.merged)
|
|
2199
|
+
return;
|
|
2200
|
+
const pushed = await pushBranch(tree, { mode: "feature" }, log);
|
|
2201
|
+
if (pushed.code !== EXIT.OK)
|
|
2202
|
+
throw new Stop(EXIT_PUSH_FAILED, `push of ${branch} after merging ${DEV} failed`);
|
|
2203
|
+
log(`merged ${UPSTREAM} into ${branch} and pushed it`);
|
|
2204
|
+
}
|
|
1270
2205
|
/**
|
|
1271
2206
|
* The PR close (the dev push was refused): commit the roadmap row on the branch
|
|
1272
2207
|
* in the checkout holding it, push it, open or reuse the PR, squash-merge it with
|
|
1273
|
-
* an empty body. A merge that does not land on an open PR →
|
|
1274
|
-
*
|
|
2208
|
+
* an empty body. A merge that does not land on an open PR → merge dev into its
|
|
2209
|
+
* branch locally, push, and try again, with backoff, LAND_ATTEMPTS tries in all; then stop with
|
|
1275
2210
|
* the PR left open. gh missing → EXIT.USE_MCP with what to create / merge; re-run
|
|
1276
2211
|
* with `--pr` (and `--merged-sha` once merged).
|
|
1277
2212
|
*/
|
|
@@ -1281,7 +2216,12 @@ async function landPr(ctx, root, o) {
|
|
|
1281
2216
|
const tree = branchTree(root, o.branch);
|
|
1282
2217
|
if (tree === null)
|
|
1283
2218
|
throw new Stop(EXIT_LAND_STOPPED, `no checkout has ${o.branch} checked out — the PR close commits the roadmap row on it; nothing landed`);
|
|
1284
|
-
runGit(tree, [
|
|
2219
|
+
runGit(tree, [
|
|
2220
|
+
"fetch",
|
|
2221
|
+
REMOTE,
|
|
2222
|
+
DEV_REFSPEC,
|
|
2223
|
+
`+refs/heads/${o.branch}:refs/remotes/${REMOTE}/${o.branch}`,
|
|
2224
|
+
]);
|
|
1285
2225
|
appendFeature(tree, { workflow: o.workflow, fid: o.fid }, ctx.log);
|
|
1286
2226
|
commitBookkeeping({
|
|
1287
2227
|
root: tree,
|
|
@@ -1335,9 +2275,9 @@ async function landPr(ctx, root, o) {
|
|
|
1335
2275
|
throw new Stop(EXIT_LAND_STOPPED, `PR ${prNumber} did not reach MERGED (state=${merged.out.state})`);
|
|
1336
2276
|
if (attempt >= TIMEOUTS.LAND_ATTEMPTS)
|
|
1337
2277
|
throw new Stop(EXIT_LAND_STOPPED, `PR ${prNumber} still not merged after ${attempt} tries — left open; merge it, then re-run with --pr=${prNumber} --merged-sha=<merge commit>`);
|
|
1338
|
-
|
|
2278
|
+
await mergeDevIntoPrBranch(root, o.branch, ctx.log);
|
|
1339
2279
|
const wait = landBackoffMs(attempt);
|
|
1340
|
-
ctx.log(`PR ${prNumber} not merged on try ${attempt} of ${TIMEOUTS.LAND_ATTEMPTS} —
|
|
2280
|
+
ctx.log(`PR ${prNumber} not merged on try ${attempt} of ${TIMEOUTS.LAND_ATTEMPTS} — trying again in ${(wait / 1000).toFixed(1)}s`);
|
|
1341
2281
|
await sleep(wait);
|
|
1342
2282
|
}
|
|
1343
2283
|
transport = "gh";
|
|
@@ -1349,17 +2289,18 @@ async function landPr(ctx, root, o) {
|
|
|
1349
2289
|
}
|
|
1350
2290
|
if (sha === "")
|
|
1351
2291
|
throw new Stop(EXIT_LAND_STOPPED, `could not resolve the landed SHA for PR ${prNumber}`);
|
|
1352
|
-
if (!
|
|
2292
|
+
if (!fetchDev(root).ok)
|
|
1353
2293
|
throw new Stop(EXIT_LAND_STOPPED, "fetch of origin/dev after the merge failed");
|
|
1354
2294
|
return { shape: "pr", transport, sha, prNumber: Number(prNumber), pushAttempts: 0 };
|
|
1355
2295
|
}
|
|
1356
2296
|
/**
|
|
1357
2297
|
* Bring local dev up to `sha` when that is a pure fast-forward — `merge
|
|
1358
2298
|
* --ff-only` when the main checkout is on dev, else move the branch pointer
|
|
1359
|
-
* alone; nothing is checked out or pushed. Local
|
|
1360
|
-
*
|
|
1361
|
-
*
|
|
1362
|
-
*
|
|
2299
|
+
* alone; nothing is checked out or pushed. Local dev already past `sha` and on
|
|
2300
|
+
* origin/dev (a later landing fast-forwarded it) is current. Local commits
|
|
2301
|
+
* origin/dev lacks (listed with the command that publishes them), or git refusing
|
|
2302
|
+
* (an uncommitted edit the move would overwrite, dev checked out in another
|
|
2303
|
+
* worktree), skip it with a log line: what landed is on origin/dev either way.
|
|
1363
2304
|
*/
|
|
1364
2305
|
function fastForwardDev(root, sha, log) {
|
|
1365
2306
|
const local = git(root, ["rev-parse", "-q", "--verify", `refs/heads/${DEV}`]);
|
|
@@ -1367,8 +2308,11 @@ function fastForwardDev(root, sha, log) {
|
|
|
1367
2308
|
return "none";
|
|
1368
2309
|
if (local === sha)
|
|
1369
2310
|
return "current";
|
|
1370
|
-
|
|
1371
|
-
|
|
2311
|
+
const isAncestor = (a, b) => runGit(root, ["merge-base", "--is-ancestor", a, b]).ok;
|
|
2312
|
+
if (!isAncestor(local, sha)) {
|
|
2313
|
+
if (isAncestor(sha, local) && isAncestor(local, UPSTREAM))
|
|
2314
|
+
return "current";
|
|
2315
|
+
const ahead = (git(root, ["log", "--format=%h %s", `${UPSTREAM}..${local}`]) ?? "")
|
|
1372
2316
|
.split("\n")
|
|
1373
2317
|
.filter((l) => l !== "");
|
|
1374
2318
|
log(`local ${DEV} has ${ahead.length} commit(s) ${UPSTREAM} does not — not fast-forwarded:`);
|
|
@@ -1410,12 +2354,42 @@ function notOnDev(root, branch) {
|
|
|
1410
2354
|
return lines(branch, p).some((l) => !before.has(l) && !onDev.has(l));
|
|
1411
2355
|
});
|
|
1412
2356
|
}
|
|
1413
|
-
/**
|
|
2357
|
+
/**
|
|
2358
|
+
* Those of `paths` whose content at `spec(p)` is already local `dev`'s: work the
|
|
2359
|
+
* branch carries because `dev` is unpushed, not work a run in this branch made.
|
|
2360
|
+
* `spec` names the side to compare — the index (`:path`) or a commit (`ref:path`).
|
|
2361
|
+
*/
|
|
2362
|
+
function localDevCopies(root, paths, spec) {
|
|
2363
|
+
if (git(root, ["rev-parse", "-q", "--verify", `refs/heads/${DEV}`]) === null)
|
|
2364
|
+
return [];
|
|
2365
|
+
return paths.filter((p) => {
|
|
2366
|
+
const at = git(root, ["rev-parse", "-q", "--verify", `${DEV}:${p}`]);
|
|
2367
|
+
return at !== null && at === git(root, ["rev-parse", "-q", "--verify", spec(p)]);
|
|
2368
|
+
});
|
|
2369
|
+
}
|
|
2370
|
+
/**
|
|
2371
|
+
* What a close refusal adds when some of the paths it names are unpushed `dev`'s
|
|
2372
|
+
* own content: the branch inherited them, and publishing `dev` is what unblocks
|
|
2373
|
+
* the close. Empty when none are, so the refusal reads as it did before.
|
|
2374
|
+
*/
|
|
2375
|
+
function unpushedDevCause(root, inherited, total, then) {
|
|
2376
|
+
if (inherited === 0)
|
|
2377
|
+
return "";
|
|
2378
|
+
const ahead = git(root, ["rev-list", "--count", `${UPSTREAM}..${DEV}`]) ?? "?";
|
|
2379
|
+
const tip = git(root, ["rev-parse", "--short", DEV]) ?? DEV;
|
|
2380
|
+
const which = inherited === total ? "all of them" : `${inherited} of them`;
|
|
2381
|
+
return `\n${which} are local ${DEV}'s content (tip ${tip}, ${ahead} commit(s) ahead of ${UPSTREAM}): this branch carries unpushed ${DEV} work — publish ${DEV} (git push ${REMOTE} ${DEV})${then}`;
|
|
2382
|
+
}
|
|
2383
|
+
/**
|
|
2384
|
+
* Uncommitted or untracked files in the feature worktree; [] when there is no
|
|
2385
|
+
* worktree. The worktree copy entries setup copied in (`copyExcludes`) are never
|
|
2386
|
+
* committed, so they are not work left behind.
|
|
2387
|
+
*/
|
|
1414
2388
|
function uncommitted(root, fid) {
|
|
1415
2389
|
const wt = worktreeDir(root, fid);
|
|
1416
2390
|
if (!fs.existsSync(wt))
|
|
1417
2391
|
return [];
|
|
1418
|
-
const status = runGit(wt, ["status", "--porcelain", "-uall"]);
|
|
2392
|
+
const status = runGit(wt, ["status", "--porcelain", "-uall", "--", ".", ...copyExcludes(wt)]);
|
|
1419
2393
|
if (!status.ok)
|
|
1420
2394
|
return [`git status in ${wt} failed: ${status.stderr}`];
|
|
1421
2395
|
return status.stdout.split("\n").filter((l) => l !== "");
|
|
@@ -1446,7 +2420,7 @@ async function landVerb(ctx) {
|
|
|
1446
2420
|
}));
|
|
1447
2421
|
if (typeof landed === "number")
|
|
1448
2422
|
return landed;
|
|
1449
|
-
|
|
2423
|
+
fetchDev(root);
|
|
1450
2424
|
const localDev = devPushes ? fastForwardDev(root, landed.sha, ctx.log) : null;
|
|
1451
2425
|
// The audit: canonical docs on origin/dev, the landed body clean, the transport recorded.
|
|
1452
2426
|
const docs = canonicalDocs(root, landed.sha, workflow, month, fid);
|
|
@@ -1474,8 +2448,10 @@ async function landVerb(ctx) {
|
|
|
1474
2448
|
if (missing.length)
|
|
1475
2449
|
throw new Stop(EXIT_LANDED_UNVERIFIED, `canonical ${workflow} missing on ${UPSTREAM}: ${missing.join(", ")}`);
|
|
1476
2450
|
const notLanded = notOnDev(root, branch);
|
|
1477
|
-
if (notLanded.length)
|
|
1478
|
-
|
|
2451
|
+
if (notLanded.length) {
|
|
2452
|
+
const inherited = localDevCopies(root, notLanded, (p) => `${branch}:${p}`);
|
|
2453
|
+
throw new Stop(EXIT_LANDED_UNVERIFIED, `${branch} carries work ${UPSTREAM} does not — ${branch} and its worktree kept:\n${notLanded.join("\n")}${unpushedDevCause(root, inherited.length, notLanded.length, "; the close landed without it.")}`);
|
|
2454
|
+
}
|
|
1479
2455
|
let worktree = null;
|
|
1480
2456
|
const left = devPushes ? uncommitted(root, fid) : [];
|
|
1481
2457
|
if (left.length) {
|
|
@@ -1609,38 +2585,156 @@ export const branchesCommand = {
|
|
|
1609
2585
|
noun: "branches",
|
|
1610
2586
|
summary: "Sync, push, land and rebase branches; stamp and read a doc's base-commit anchor.",
|
|
1611
2587
|
verbs: {
|
|
2588
|
+
parse: {
|
|
2589
|
+
summary: "Read an explicitly named or existing branch from the session prompt.",
|
|
2590
|
+
use: "workflow",
|
|
2591
|
+
flags: [
|
|
2592
|
+
{ name: "prompt-file", type: "string", required: true, help: "session prompt" },
|
|
2593
|
+
{
|
|
2594
|
+
name: "workflow",
|
|
2595
|
+
type: "string",
|
|
2596
|
+
help: "debug: validate an explicit debug adoption request",
|
|
2597
|
+
},
|
|
2598
|
+
],
|
|
2599
|
+
output: {
|
|
2600
|
+
branch: "one existing branch, or null",
|
|
2601
|
+
via: "explicit | token | null",
|
|
2602
|
+
where: "local | remote | both | null",
|
|
2603
|
+
},
|
|
2604
|
+
exitCodes: {
|
|
2605
|
+
3: "an explicit branch is invalid or absent",
|
|
2606
|
+
8: "multiple branches were named",
|
|
2607
|
+
},
|
|
2608
|
+
run: (ctx) => {
|
|
2609
|
+
if (ctx.flags.workflow !== undefined && ctx.flags.workflow !== "debug")
|
|
2610
|
+
throw new CommandError(EXIT.USAGE, "--workflow must be debug");
|
|
2611
|
+
const prompt = fs.readFileSync(path.resolve(ctx.cwd, String(ctx.flags.promptFile)), "utf8");
|
|
2612
|
+
const candidates = new Map();
|
|
2613
|
+
for (const token of prompt.split(/\s+/)) {
|
|
2614
|
+
const explicit = token.startsWith("branch=");
|
|
2615
|
+
const branch = explicit ? token.slice("branch=".length) : token;
|
|
2616
|
+
if (!explicit && (!branch.includes("/") || /^[a-z][a-z0-9+.-]*:\/\//i.test(branch)))
|
|
2617
|
+
continue;
|
|
2618
|
+
const valid = runGit(ctx.cwd, ["check-ref-format", "--branch", branch]).ok;
|
|
2619
|
+
const local = valid &&
|
|
2620
|
+
runGit(ctx.cwd, ["show-ref", "--verify", "--quiet", `refs/heads/${branch}`]).ok;
|
|
2621
|
+
const remote = valid &&
|
|
2622
|
+
runGit(ctx.cwd, ["show-ref", "--verify", "--quiet", `refs/remotes/origin/${branch}`])
|
|
2623
|
+
.ok;
|
|
2624
|
+
if (!local && !remote) {
|
|
2625
|
+
if (explicit)
|
|
2626
|
+
throw new CommandError(3, `branch ${branch} is invalid or does not exist`);
|
|
2627
|
+
continue;
|
|
2628
|
+
}
|
|
2629
|
+
candidates.set(branch, {
|
|
2630
|
+
via: explicit ? "explicit" : "token",
|
|
2631
|
+
where: local && remote ? "both" : local ? "local" : "remote",
|
|
2632
|
+
});
|
|
2633
|
+
}
|
|
2634
|
+
if (candidates.size > 1)
|
|
2635
|
+
throw new CommandError(8, `multiple branch selections: ${[...candidates.keys()].join(", ")}`);
|
|
2636
|
+
const selected = [...candidates.entries()][0];
|
|
2637
|
+
ctx.emit(selected
|
|
2638
|
+
? { branch: selected[0], ...selected[1] }
|
|
2639
|
+
: { branch: null, via: null, where: null });
|
|
2640
|
+
return EXIT.OK;
|
|
2641
|
+
},
|
|
2642
|
+
},
|
|
1612
2643
|
sync: {
|
|
1613
|
-
summary: `Fetch ${UPSTREAM}; report whether it is an ancestor of HEAD (Path A/B) and how far docs/
|
|
2644
|
+
summary: `Fetch ${UPSTREAM}; report whether it is an ancestor of HEAD (Path A/B) and how far docs/ and the ledgers are behind; optionally merge it in.`,
|
|
2645
|
+
use: "workflow",
|
|
1614
2646
|
flags: [
|
|
1615
2647
|
{
|
|
1616
2648
|
name: "head",
|
|
1617
2649
|
type: "string",
|
|
1618
2650
|
help: "commit to compare (default HEAD), e.g. ship's ENTRY_HEAD",
|
|
1619
2651
|
},
|
|
2652
|
+
{
|
|
2653
|
+
name: "merge",
|
|
2654
|
+
type: "boolean",
|
|
2655
|
+
help: `ship Step 4: merge ${UPSTREAM} into the checked-out feature branch — the run's uncommitted work is committed first, ledger conflicts union, a lockfile regenerates from ${DEV}'s copy, a generated register takes ${DEV}'s copy and is rebuilt after the merge, a doc embedding the register's generated block takes ${DEV}'s block and merges the rest, the install record (.bkit/version) merges entry by entry with ${DEV}'s value where both changed, any other conflict stays in the tree with the merge in progress for a hand resolution (exit 24; run again after git add), then a declared bkit:generate runs and its output is committed; never a rebase or force-push, never on ${DEV} / main`,
|
|
2656
|
+
},
|
|
1620
2657
|
{
|
|
1621
2658
|
name: "merge-docs",
|
|
1622
2659
|
type: "boolean",
|
|
1623
|
-
help: `on a feature branch whose docs/
|
|
2660
|
+
help: `on a feature branch whose docs/ or ledgers are behind, merge ${UPSTREAM} (ledgers union, a generated register takes ${DEV}'s copy and is rebuilt, a doc embedding its generated block takes ${DEV}'s block and merges the rest, the install record (.bkit/version) merges entry by entry, other docs/ take ${DEV}, anything else aborts), then run a declared bkit:generate and commit its output`,
|
|
2661
|
+
},
|
|
2662
|
+
{
|
|
2663
|
+
name: "fid",
|
|
2664
|
+
type: "string",
|
|
2665
|
+
help: "--merge: the feature id in the commit messages (default: the branch name without feat/)",
|
|
2666
|
+
},
|
|
2667
|
+
{
|
|
2668
|
+
name: "file",
|
|
2669
|
+
type: "string",
|
|
2670
|
+
help: "--merge: the run's status.jsonl: a completed merge appends an engine-action row (action merge, key merge/{old tip}, ref the new HEAD)",
|
|
2671
|
+
},
|
|
2672
|
+
{
|
|
2673
|
+
name: "sentinel",
|
|
2674
|
+
type: "string",
|
|
2675
|
+
help: "--merge: file removed at start and created on refusal, e.g. logs/{FID}/.rebase-failed",
|
|
1624
2676
|
},
|
|
1625
2677
|
],
|
|
1626
2678
|
output: {
|
|
1627
2679
|
branch: "current branch (null when detached)",
|
|
1628
|
-
head: "commit compared (after a merge: the
|
|
2680
|
+
head: "commit compared (after a merge: the new HEAD)",
|
|
1629
2681
|
basePath: `A when ${UPSTREAM} is an ancestor of head (nothing to integrate), else B`,
|
|
1630
2682
|
behind: `commits on ${UPSTREAM} not in head`,
|
|
1631
|
-
docsBehind: `of those, commits touching docs
|
|
1632
|
-
merged: `true when --merge-docs merged ${UPSTREAM}`,
|
|
1633
|
-
resolved: "conflicts the merge resolved: [{path, how: union|dev}]",
|
|
2683
|
+
docsBehind: `of those, commits touching docs/ or a ledger path (LEDGERS)`,
|
|
2684
|
+
merged: `true when --merge or --merge-docs merged ${UPSTREAM}`,
|
|
2685
|
+
resolved: "conflicts the merge resolved: [{path, how: union|lockfile|register|embed|record|dev}]",
|
|
2686
|
+
rebuilt: "a generated register the merge settled on dev's copy, or whose generated block a doc took from dev, rebuilt after the merge: true (rebuilt; output committed), false (failed: it keeps dev's copy), null (not run: none settled, its script absent, or no merge)",
|
|
2687
|
+
generated: "bkit:generate after the merge: true (ran; only the paths it changed committed), false (failed, or it changed a path that already held uncommitted changes; exit 25), null (not run: no merge, or undeclared)",
|
|
2688
|
+
outcome: `--merge: merged | current (${UPSTREAM} already an ancestor; nothing done) | pending (conflicts left for a hand resolution, merge in progress) | refused (merge aborted)`,
|
|
2689
|
+
carried: "--merge: the commit that carried the uncommitted work before the merge (null when the tree was clean)",
|
|
2690
|
+
pending: "--merge: the paths left conflicted for a hand resolution (empty otherwise)",
|
|
2691
|
+
aborted: "--merge: a refused merge was aborted",
|
|
2692
|
+
sentinel: "--merge: the sentinel written on refusal (null otherwise)",
|
|
1634
2693
|
},
|
|
1635
2694
|
exitCodes: {
|
|
1636
|
-
[
|
|
2695
|
+
[EXIT_REFUSED]: "--merge: the uncommitted work could not be committed before the merge",
|
|
2696
|
+
[EXIT_DETACHED]: "--merge / --merge-docs with no branch checked out",
|
|
1637
2697
|
[EXIT_FETCH_FAILED]: `git fetch ${REMOTE} ${DEV} failed`,
|
|
1638
|
-
[EXIT_MERGE_CONFLICT]:
|
|
2698
|
+
[EXIT_MERGE_CONFLICT]: `the merge conflicted where it may not (--merge-docs: outside docs/ and the ledgers; --merge: a ledger union, lockfile regenerate or register resolution failed), could not be committed, or (--merge) ${UPSTREAM} could not be merged at all; merge aborted`,
|
|
2699
|
+
[EXIT_HAND_RESOLVE]: "--merge: conflicts outside the ledgers, lockfiles, generated registers, their generated blocks and the install record are left in the tree with the merge in progress; resolve them, git add, run again",
|
|
2700
|
+
[EXIT_GENERATE_FAILED]: "bkit:generate failed after the merge, or its output could not be committed; the merge commit stays",
|
|
1639
2701
|
},
|
|
1640
2702
|
run: syncVerb,
|
|
1641
2703
|
},
|
|
2704
|
+
regenerate: {
|
|
2705
|
+
summary: "Run a declared bkit:generate on the feature branch and commit only the paths it changed (ship Step 10's fix round).",
|
|
2706
|
+
use: "workflow",
|
|
2707
|
+
flags: [
|
|
2708
|
+
{
|
|
2709
|
+
name: "fid",
|
|
2710
|
+
type: "string",
|
|
2711
|
+
help: "the feature id in the commit message (default: the branch name without feat/)",
|
|
2712
|
+
},
|
|
2713
|
+
{
|
|
2714
|
+
name: "attempt",
|
|
2715
|
+
type: "string",
|
|
2716
|
+
help: "ship Step 10's merge round: the commit is fix({FID}): regenerate attempt {N}; without it, chore({FID}): regenerate before re-validating",
|
|
2717
|
+
},
|
|
2718
|
+
{
|
|
2719
|
+
name: "file",
|
|
2720
|
+
type: "string",
|
|
2721
|
+
help: "the run's status.jsonl: a commit appends an engine-action row (action regenerate, key regenerate/{old tip}, ref the new HEAD)",
|
|
2722
|
+
},
|
|
2723
|
+
],
|
|
2724
|
+
output: {
|
|
2725
|
+
outcome: "committed (bkit:generate changed paths; committed) | unchanged (it changed nothing) | undeclared (no bkit:generate script; nothing run)",
|
|
2726
|
+
head: "HEAD after the verb (the regenerate commit when committed)",
|
|
2727
|
+
paths: "the paths bkit:generate changed and the commit carries (empty otherwise)",
|
|
2728
|
+
},
|
|
2729
|
+
exitCodes: {
|
|
2730
|
+
[EXIT_DETACHED]: "no branch checked out",
|
|
2731
|
+
[EXIT_GENERATE_FAILED]: "bkit:generate failed, changed a path that already held uncommitted changes, or its output could not be committed; nothing committed",
|
|
2732
|
+
},
|
|
2733
|
+
run: regenerateVerb,
|
|
2734
|
+
},
|
|
1642
2735
|
push: {
|
|
1643
|
-
summary: "Push the current branch with exactly one git push: plain for dev/main, --force-with-lease otherwise.",
|
|
2736
|
+
summary: "Push the current branch with exactly one git push: plain for dev/main, --force-with-lease otherwise; 81 tests lock held.",
|
|
2737
|
+
use: "workflow",
|
|
1644
2738
|
flags: [
|
|
1645
2739
|
{
|
|
1646
2740
|
name: "mode",
|
|
@@ -1670,7 +2764,7 @@ export const branchesCommand = {
|
|
|
1670
2764
|
{
|
|
1671
2765
|
name: "require-ci",
|
|
1672
2766
|
type: "boolean",
|
|
1673
|
-
help:
|
|
2767
|
+
help: `this push must start a CI run: refuse when the HEAD message carries a skip-CI token; --mode=feature on a feature branch first merges ${UPSTREAM} in when its docs/ or ledgers are behind (as sync --merge-docs does), so GitHub sees no ledger conflict`,
|
|
1674
2768
|
},
|
|
1675
2769
|
{
|
|
1676
2770
|
name: "open-pr",
|
|
@@ -1685,16 +2779,19 @@ export const branchesCommand = {
|
|
|
1685
2779
|
],
|
|
1686
2780
|
output: {
|
|
1687
2781
|
pushed: "true when the push ran and succeeded",
|
|
2782
|
+
lockHolder: "the tests-lock holder on exit 81 (null otherwise)",
|
|
1688
2783
|
replayed: "true when the run's commits went out as copies cherry-picked onto a fresh origin/dev (an in-place run on dev whose local dev holds other commits); sha is then the landed origin/dev commit",
|
|
1689
2784
|
ref: "the branch pushed — link handover artifacts to this ref; null when nothing was pushed",
|
|
1690
2785
|
sha: "HEAD commit pushed (null when not pushed)",
|
|
1691
2786
|
forced: "true when pushed with --force-with-lease",
|
|
1692
2787
|
skipped: "why the push did not run: open-pr | skip-ci | no-run-commits (an in-place run on dev with nothing new to push) (null otherwise)",
|
|
1693
2788
|
prNumber: "the open PR that stopped an abort push (null otherwise)",
|
|
2789
|
+
mergedDev: `--require-ci: ${UPSTREAM} was merged in before the push`,
|
|
1694
2790
|
commit: "--commit: the marker commit's sha",
|
|
1695
2791
|
deduped: "--commit: the marker commit was already made this run (not made again)",
|
|
1696
2792
|
},
|
|
1697
2793
|
exitCodes: {
|
|
2794
|
+
4: "the pre-push hook could not acquire the tests lock",
|
|
1698
2795
|
[EXIT_DETACHED]: "no branch checked out",
|
|
1699
2796
|
[EXIT_NOTHING_TO_PUSH]: "--mode=plain or --commit on dev / main, or --ahead-of and HEAD has no commits beyond it",
|
|
1700
2797
|
[EXIT_SKIP_CI]: "--require-ci and the HEAD message carries a skip-CI token",
|
|
@@ -1702,13 +2799,15 @@ export const branchesCommand = {
|
|
|
1702
2799
|
[EXIT_PUSH_FAILED]: "git push failed, or dev refused a replayed push (in-place run on dev: the refusal is printed)",
|
|
1703
2800
|
[EXIT_NOT_DEV]: "--mode=dev and the checkout is not on dev",
|
|
1704
2801
|
[EXIT_NO_RECORD]: "--mode=dev, or --fid, on dev with no shared-checkout record for the run: nothing pushed",
|
|
1705
|
-
[EXIT_FETCH_FAILED]: "in-place run on dev
|
|
1706
|
-
[EXIT_MERGE_CONFLICT]: "in-place run on dev: a run commit does not apply onto origin/dev without the local commits it builds on; the conflicting paths are printed, nothing pushed",
|
|
2802
|
+
[EXIT_FETCH_FAILED]: "fetching origin/dev failed (in-place run on dev, or a --require-ci feature push); nothing pushed",
|
|
2803
|
+
[EXIT_MERGE_CONFLICT]: "in-place run on dev: a run commit does not apply onto origin/dev without the local commits it builds on; or a --require-ci feature push: merging origin/dev conflicts outside docs/ and the ledgers (merge aborted). The conflicting paths are printed, nothing pushed",
|
|
2804
|
+
[EXIT_GENERATE_FAILED]: "--require-ci feature push: bkit:generate failed after merging origin/dev; nothing pushed",
|
|
1707
2805
|
},
|
|
1708
2806
|
run: pushVerb,
|
|
1709
2807
|
},
|
|
1710
2808
|
"fast-forward": {
|
|
1711
2809
|
summary: "Fetch a remote branch and fast-forward the checkout onto it; refuse when diverged.",
|
|
2810
|
+
use: "workflow",
|
|
1712
2811
|
flags: [
|
|
1713
2812
|
{
|
|
1714
2813
|
name: "onto",
|
|
@@ -1725,7 +2824,8 @@ export const branchesCommand = {
|
|
|
1725
2824
|
run: fastForwardVerb,
|
|
1726
2825
|
},
|
|
1727
2826
|
"scan-diff": {
|
|
1728
|
-
summary: "Exit 0 when the branch's diff from --base matches (paths, an added marker line, or a
|
|
2827
|
+
summary: "Exit 0 when the branch's diff from --base matches (paths, an added marker line, a source change, or a disabled test); 1 when not — --disabled-tests turns that round: 1 when a test was disabled or lost an assertion, 0 when none was.",
|
|
2828
|
+
use: "by-hand",
|
|
1729
2829
|
flags: [
|
|
1730
2830
|
{
|
|
1731
2831
|
name: "base",
|
|
@@ -1748,13 +2848,22 @@ export const branchesCommand = {
|
|
|
1748
2848
|
type: "boolean",
|
|
1749
2849
|
help: "a path changed outside docs/plans, docs/*.jsonl and .bkit/*.jsonl",
|
|
1750
2850
|
},
|
|
2851
|
+
{
|
|
2852
|
+
name: "disabled-tests",
|
|
2853
|
+
type: "boolean",
|
|
2854
|
+
help: "an added line disables a test (`.skip` / `.todo` / `.fixme` / `xfail`, `t.Skip()`, `#[ignore]`, `@Disabled`, `@pytest.mark.skip`, `@unittest.skip`), outside comments or quotes, or an assertion is removed; matches exact moved occurrences once (unchanged test name, scope and setup across files), and rewritten assertions within the same file and test; unchanged duplicates do not cancel removals; inverts --paths / --marker / --code's polarity, so never pass it with --expect-none",
|
|
2855
|
+
},
|
|
1751
2856
|
{
|
|
1752
2857
|
name: "expect-none",
|
|
1753
2858
|
type: "boolean",
|
|
1754
2859
|
help: "invert the exit: 0 when nothing matched, 1 (naming the paths on stderr) when something did",
|
|
1755
2860
|
},
|
|
1756
2861
|
],
|
|
1757
|
-
output: {
|
|
2862
|
+
output: {
|
|
2863
|
+
found: "something matched",
|
|
2864
|
+
paths: "the matching paths",
|
|
2865
|
+
disabled: "[{file, line, test}]: unmatched added disabling markers and removed assertion occurrences, attributed to their original test (only with --disabled-tests)",
|
|
2866
|
+
},
|
|
1758
2867
|
exitCodes: {
|
|
1759
2868
|
[EXIT_DIFF_FAILED]: "--base does not resolve, or git diff failed",
|
|
1760
2869
|
},
|
|
@@ -1762,6 +2871,7 @@ export const branchesCommand = {
|
|
|
1762
2871
|
},
|
|
1763
2872
|
"force-build": {
|
|
1764
2873
|
summary: `Force a full CI build: put ${FORCE_BUILD} on the open PR's title, then push an empty marker commit (once per run).`,
|
|
2874
|
+
use: "workflow",
|
|
1765
2875
|
flags: [
|
|
1766
2876
|
{ name: "fid", type: "string", required: true, help: "feature id, for the commit subject" },
|
|
1767
2877
|
{
|
|
@@ -1810,7 +2920,8 @@ export const branchesCommand = {
|
|
|
1810
2920
|
run: forceBuildVerb,
|
|
1811
2921
|
},
|
|
1812
2922
|
rebase: {
|
|
1813
|
-
summary: "Drive a rebase to completion, auto-resolving ledger (union)
|
|
2923
|
+
summary: "Drive a rebase to completion, auto-resolving ledger (union), lockfile (regenerate), generated-register (take the target's copy, rebuild after), embedded generated-block (take the target's block, merge the rest, rebuild after) and install-record (merge entry by entry, the target's value where both changed) conflicts; refuse and abort on anything else.",
|
|
2924
|
+
use: "workflow",
|
|
1814
2925
|
flags: [
|
|
1815
2926
|
{
|
|
1816
2927
|
name: "log-file",
|
|
@@ -1822,14 +2933,20 @@ export const branchesCommand = {
|
|
|
1822
2933
|
type: "string",
|
|
1823
2934
|
help: "file removed at start and created on refusal, e.g. logs/{FID}/.rebase-failed",
|
|
1824
2935
|
},
|
|
2936
|
+
{
|
|
2937
|
+
name: "file",
|
|
2938
|
+
type: "string",
|
|
2939
|
+
help: "the run's status.jsonl: a completed rebase appends an engine-action row (action rebase, key rebase/{old tip}, ref the new HEAD)",
|
|
2940
|
+
},
|
|
1825
2941
|
],
|
|
1826
2942
|
output: {
|
|
1827
2943
|
outcome: "resolved | refused (a refused rebase is aborted)",
|
|
1828
|
-
resolved: "conflicts resolved: [{path, how: union|lockfile}]",
|
|
2944
|
+
resolved: "conflicts resolved: [{path, how: union|lockfile|register|embed|record}]",
|
|
2945
|
+
rebuilt: "a generated register settled on the rebase target's copy, or whose generated block a doc took from the target, rebuilt after the rebase: true (rebuilt; output committed), false (failed: it keeps the target's copy), null (not run: none settled, or its script absent)",
|
|
1829
2946
|
skippedCommits: "commits skipped because resolution emptied them",
|
|
1830
2947
|
rounds: "resolve rounds run",
|
|
1831
2948
|
refused: "the path that stopped resolution (null when none, or not path-specific)",
|
|
1832
|
-
reason: "why resolution refused (null on success)",
|
|
2949
|
+
reason: "why resolution refused or stopped (null on success)",
|
|
1833
2950
|
aborted: "a refused rebase was aborted (false on success, or when the abort failed)",
|
|
1834
2951
|
sentinel: "the sentinel written on refusal (null otherwise)",
|
|
1835
2952
|
},
|
|
@@ -1841,6 +2958,7 @@ export const branchesCommand = {
|
|
|
1841
2958
|
},
|
|
1842
2959
|
"sync-dev": {
|
|
1843
2960
|
summary: "After a merge, fast-forward local dev to origin/dev without checking it out or pushing; frozen install when the main checkout is on dev and moved.",
|
|
2961
|
+
use: "workflow",
|
|
1844
2962
|
flags: [],
|
|
1845
2963
|
output: {
|
|
1846
2964
|
devLocal: "fast-forwarded | current | skipped (local dev has commits origin/dev lacks, listed with the publish command, or git refused) | none (no local dev)",
|
|
@@ -1855,6 +2973,7 @@ export const branchesCommand = {
|
|
|
1855
2973
|
},
|
|
1856
2974
|
land: {
|
|
1857
2975
|
summary: "Design / plan close: squash the branch onto origin/dev in a throwaway worktree and push it as dev (retrying with backoff when dev moved), else the PR squash-merge; then audit it, fast-forward local dev on a laptop and release the lock.",
|
|
2976
|
+
use: "workflow",
|
|
1858
2977
|
flags: [
|
|
1859
2978
|
{ name: "workflow", type: "string", required: true, help: "design | plan" },
|
|
1860
2979
|
{ name: "fid", type: "string", required: true, help: "feature id" },
|
|
@@ -1904,6 +3023,7 @@ export const branchesCommand = {
|
|
|
1904
3023
|
},
|
|
1905
3024
|
"anchor-stamp": {
|
|
1906
3025
|
summary: "Put a <!-- bkit:anchor --> block recording the base commit and bkit release on top of a design/plan doc or audit report (idempotent).",
|
|
3026
|
+
use: "workflow",
|
|
1907
3027
|
flags: [
|
|
1908
3028
|
{ name: "file", type: "string", required: true, help: "doc to stamp (must exist)" },
|
|
1909
3029
|
{
|
|
@@ -1940,6 +3060,7 @@ export const branchesCommand = {
|
|
|
1940
3060
|
},
|
|
1941
3061
|
"anchor-read": {
|
|
1942
3062
|
summary: "Read a doc's anchor fields; with --against, decide whether anything landed since its baseSha.",
|
|
3063
|
+
use: "by-hand",
|
|
1943
3064
|
flags: [
|
|
1944
3065
|
{ name: "file", type: "string", required: true, help: "design/plan doc or audit report" },
|
|
1945
3066
|
{
|