@cbartens/bkit 6.1.1 → 6.2.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 +14 -12
- package/.bkit/core/.agents/docs.md +1 -11
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-gateguard.cjs +30 -9
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +25 -27
- package/.bkit/core/.agents/rules.md +22 -9
- package/.bkit/core/.bkit/README.md +13 -11
- package/.bkit/core/.bkit/authoring.md +58 -13
- package/.bkit/core/.bkit/cli.md +42 -32
- package/.bkit/core/.bkit/cloud.md +93 -30
- package/.bkit/core/.bkit/install.md +55 -16
- package/.bkit/core/.bkit/jsonl.md +24 -7
- package/.bkit/core/.bkit/pipeline.md +8 -8
- package/.bkit/core/.bkit/prompts.md +160 -43
- package/.bkit/core/.bkit/providers.md +97 -36
- package/.bkit/core/.bkit/templates.md +162 -34
- package/.bkit/core/.bkit/trackers.md +39 -6
- package/.bkit/core/.bkit/workflows.md +344 -136
- package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +50 -27
- package/.bkit/core/.claude/hooks/bkit-preflight.sh +11 -11
- package/.bkit/core/.codex/hooks/bkit-gateguard.cjs +13 -8
- package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +14 -25
- package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +20 -9
- package/.bkit/core/.cursor/hooks/bkit-preflight.sh +8 -8
- package/.bkit/core/.opencode/plugin/bkit-gateguard.js +14 -4
- package/.bkit/core/.opencode/plugin/bkit-guardrails.js +114 -0
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +30 -6
- package/.bkit/core/docs/templates/bkit-audit-agents.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-config.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-cost.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-database.md +3 -3
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +3 -3
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +32 -2
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-failures.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-gates.md +5 -3
- package/.bkit/core/docs/templates/bkit-audit-issues.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-llm.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-logs.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-models.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-repo.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-security.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-slop.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-testing.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-usability.md +1 -1
- package/.bkit/core/docs/templates/bkit-plan.md +38 -8
- package/.bkit/core/engine/checks/after/auth.ts +118 -47
- package/.bkit/core/engine/checks/after/github.ts +89 -37
- package/.bkit/core/engine/checks/after/index.ts +15 -3
- package/.bkit/core/engine/checks/after/tools.ts +245 -1
- package/.bkit/core/engine/checks/before/files.ts +59 -1
- package/.bkit/core/engine/checks/before/index.ts +8 -0
- package/.bkit/core/engine/checks/status-holes.ts +20 -26
- package/.bkit/core/engine/checks/tips/catalogue.ts +107 -10
- package/.bkit/core/engine/checks/tips/detect.ts +36 -3
- package/.bkit/core/engine/checks/tips/index.ts +1 -1
- package/.bkit/core/engine/cli.ts +13 -13
- package/.bkit/core/engine/commands/ci/ci.ts +64 -11
- package/.bkit/core/engine/commands/ci/push-gate.ts +101 -43
- package/.bkit/core/engine/commands/install/install.ts +28 -25
- package/.bkit/core/engine/commands/install/uninstall.ts +42 -30
- package/.bkit/core/engine/commands/install/upgrade.ts +14 -2
- package/.bkit/core/engine/commands/land.ts +2 -3
- package/.bkit/core/engine/commands/lib.ts +394 -39
- package/.bkit/core/engine/commands/registry.ts +1 -1
- package/.bkit/core/engine/commands/workflow/branches.ts +351 -78
- package/.bkit/core/engine/commands/workflow/challenge.ts +63 -14
- package/.bkit/core/engine/commands/workflow/context.ts +71 -10
- package/.bkit/core/engine/commands/workflow/counters.ts +298 -23
- package/.bkit/core/engine/commands/workflow/decisions.ts +260 -125
- package/.bkit/core/engine/commands/workflow/disk.ts +2 -1
- package/.bkit/core/engine/commands/workflow/feature-base.ts +66 -0
- package/.bkit/core/engine/commands/workflow/issues.ts +312 -17
- package/.bkit/core/engine/commands/workflow/junit.ts +204 -0
- package/.bkit/core/engine/commands/workflow/ledgers.ts +904 -99
- package/.bkit/core/engine/commands/workflow/locks.ts +186 -29
- package/.bkit/core/engine/commands/workflow/loops.ts +87 -0
- package/.bkit/core/engine/commands/workflow/open-decision.ts +251 -0
- package/.bkit/core/engine/commands/workflow/plan-blocks.ts +8 -0
- package/.bkit/core/engine/commands/workflow/plans.ts +1 -1
- package/.bkit/core/engine/commands/workflow/prs.ts +311 -16
- package/.bkit/core/engine/commands/workflow/repo.ts +1 -1
- package/.bkit/core/engine/commands/workflow/run-facts.ts +6 -0
- package/.bkit/core/engine/commands/workflow/runs.ts +877 -174
- package/.bkit/core/engine/commands/workflow/runtime.ts +12 -4
- package/.bkit/core/engine/commands/workflow/status.ts +324 -11
- package/.bkit/core/engine/commands/workflow/step-table.ts +41 -15
- package/.bkit/core/engine/commands/workflow/steps.ts +604 -29
- package/.bkit/core/engine/commands/workflow/summary-findings.ts +1 -1
- package/.bkit/core/engine/commands/workflow/summary.ts +314 -8
- package/.bkit/core/engine/commands/workflow/tasks.ts +400 -27
- package/.bkit/core/engine/commands/workflow/tests-base.ts +319 -0
- package/.bkit/core/engine/commands/workflow/tests-changed.ts +138 -74
- package/.bkit/core/engine/commands/workflow/tests-jump.ts +93 -0
- package/.bkit/core/engine/commands/workflow/tests.ts +815 -182
- package/.bkit/core/engine/commands/workflow/tracker.ts +1134 -137
- package/.bkit/core/engine/commands/workflow/workflows.ts +100 -72
- package/.bkit/core/engine/commands/workflow/worktrees.ts +421 -57
- package/.bkit/core/engine/install/cloud-env.ts +38 -10
- package/.bkit/core/engine/install/managed-block.ts +105 -0
- package/.bkit/core/engine/install/manifest.ts +7 -1
- package/.bkit/core/engine/install/modules/claude.ts +6 -2
- package/.bkit/core/engine/install/modules/cloud.ts +84 -95
- package/.bkit/core/engine/install/modules/codex.ts +10 -2
- package/.bkit/core/engine/install/modules/core.ts +148 -14
- package/.bkit/core/engine/install/modules/opencode.ts +18 -23
- package/.bkit/core/engine/install/network-allowlist.ts +8 -3
- package/.bkit/core/engine/install/project-docs.ts +650 -0
- package/.bkit/core/engine/install/template-copies.ts +58 -5
- package/.bkit/core/engine/install/write.ts +128 -7
- package/.bkit/core/engine/ledgers/journal.ts +18 -10
- package/.bkit/core/engine/ledgers/migrate.ts +20 -8
- package/.bkit/core/engine/ledgers/status.ts +604 -8
- package/.bkit/core/engine/ledgers/telemetry.ts +115 -13
- package/.bkit/core/engine/render/trackers.ts +3 -1
- package/.bkit/core/engine/shared/package-manager.ts +7 -3
- package/.bkit/core/engine/shared/settings.ts +12 -1
- package/.bkit/core/engine/shared/text.ts +14 -0
- package/.bkit/core/engine/tools/instructions-sources.ts +1 -0
- package/.bkit/core/engine/tools/instructions.ts +116 -20
- package/.bkit/core/hooks/antigravity-hook.js +20 -4
- package/.bkit/core/hooks/gateguard-edit-payload.js +8 -5
- package/.bkit/core/hooks/gateguard-engine.js +249 -23
- package/.bkit/core/hooks/guardrails-deny.js +167 -0
- package/.bkit/core/hooks/guardrails-read.js +3 -3
- package/.bkit/core/hooks/guardrails-shell.js +1122 -167
- package/.bkit/core/hooks/guardrails-tiers.js +247 -176
- package/.bkit/core/hooks/preflight-tracker.sh +219 -0
- package/.bkit/core/prompts/bkit-audit-generate.md +23 -6
- package/.bkit/core/prompts/bkit-build-challenge-1.md +5 -4
- package/.bkit/core/prompts/bkit-build-challenge-2.md +6 -5
- package/.bkit/core/prompts/bkit-build-install-skills.md +2 -2
- package/.bkit/core/prompts/bkit-build-plan-convert.md +21 -7
- package/.bkit/core/prompts/bkit-build-plan-current.md +5 -4
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +22 -17
- package/.bkit/core/prompts/bkit-build-plan-tasks.md +16 -12
- package/.bkit/core/prompts/bkit-build-plan-tests.md +14 -10
- package/.bkit/core/prompts/bkit-build-plan-verify.md +21 -8
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +10 -5
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +22 -6
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +19 -3
- package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +22 -6
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +10 -7
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +3 -3
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +4 -4
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +3 -3
- package/.bkit/core/prompts/bkit-design-generate.md +6 -4
- package/.bkit/core/prompts/bkit-design-organise.md +4 -3
- package/.bkit/core/prompts/bkit-design-review-1.md +5 -4
- package/.bkit/core/prompts/bkit-design-review-2.md +6 -5
- package/.bkit/core/prompts/bkit-design-spike.md +4 -3
- package/.bkit/core/prompts/bkit-design-update.md +6 -4
- package/.bkit/core/prompts/bkit-plan-generate.md +35 -14
- package/.bkit/core/prompts/bkit-plan-review-1.md +9 -7
- package/.bkit/core/prompts/bkit-plan-review-2.md +9 -7
- package/.bkit/core/prompts/bkit-plan-scope-check.md +8 -6
- package/.bkit/core/prompts/bkit-plan-update.md +22 -8
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +11 -8
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +9 -5
- package/.bkit/core/prompts/bkit-ship-update-docs.md +26 -4
- package/.bkit/core/prompts/bkit-utility-compress-markdown.md +3 -3
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +10 -7
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +8 -5
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +31 -7
- package/.bkit/core/prompts/bkit-utility-update-failures.md +8 -5
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +10 -7
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +4 -4
- package/.bkit/core/prompts/bkit-utility-update-tracker.md +4 -4
- package/.bkit/core/workflows/bkit-auto.md +23 -11
- package/.bkit/core/workflows/bkit-build.md +331 -100
- package/.bkit/core/workflows/bkit-debug.md +135 -64
- package/.bkit/core/workflows/bkit-design.md +58 -32
- package/.bkit/core/workflows/bkit-plan.md +73 -45
- package/.bkit/core/workflows/bkit-ship.md +233 -167
- package/.bkit/shared/.agents/plugins/bkit/hooks.json +1 -1
- package/.bkit/shared/.bkit/.env.example +5 -0
- package/.bkit/shared/.claude/bkit-cloud.md +7 -7
- package/.bkit/shared/.claude/settings.json +5 -1
- package/.bkit/shared/.cursor/bkit-cloud.md +1 -1
- package/.bkit/shared/.cursor/hooks.json +1 -1
- package/.bkit/shared/.opencode/opencode.json +11 -2
- package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +27 -0
- package/.bkit/templates/.cursor/Dockerfile +7 -7
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-idea.yml +1 -1
- package/.bkit/templates/.github/dependabot.yml +5 -0
- package/.bkit/templates/.github/renovate.json5 +5 -3
- package/.bkit/templates/.github/workflows/bkit-ci.yml +11 -11
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +525 -161
- package/.bkit/templates/.github/workflows/bkit-renovate.yml +2 -2
- package/.bkit/templates/.husky/pre-push +123 -6
- package/.bkit/templates/context/bkit-serena.md +1 -1
- package/.bkit/templates/docs/architecture.md +98 -0
- package/.bkit/templates/docs/capabilities.md +33 -37
- package/.bkit/templates/docs/components.md +142 -0
- package/.bkit/templates/docs/data-schema.md +87 -0
- package/.bkit/{shared → templates}/docs/deployments.md +128 -142
- package/.bkit/templates/docs/design.md +117 -0
- package/.bkit/templates/docs/noise.md +54 -0
- package/.bkit/templates/docs/observability.md +99 -0
- package/.bkit/templates/docs/security.md +137 -0
- package/.bkit/templates/docs/setup.md +93 -0
- package/.bkit/templates/docs/technology.md +70 -0
- package/.bkit/{shared → templates}/docs/testing.md +200 -87
- package/.bkit/templates/scripts/ci/bkit-machine-lock.sh +511 -103
- package/.bkit/templates/scripts/ci/bkit-test-awake.mjs +228 -35
- package/.bkit/templates/scripts/ci/bkit-test-awake.test.mjs +270 -2
- package/.bkit/templates/scripts/graphify/bkit-graphify-graphml.py +1 -1
- package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +92 -63
- package/.bkit/templates/scripts/graphify/bkit-graphify.sh +59 -11
- package/.bkit/templates/slop-scan.config.json +2 -0
- package/CHANGELOG.md +64 -0
- package/DETAILS.md +24 -19
- package/README.md +1 -1
- package/dist/checks/after/auth.js +114 -46
- package/dist/checks/after/github.js +77 -35
- package/dist/checks/after/index.js +12 -3
- package/dist/checks/after/tools.js +224 -1
- package/dist/checks/before/files.js +59 -1
- package/dist/checks/before/index.js +7 -1
- package/dist/checks/status-holes.js +20 -21
- package/dist/checks/tips/catalogue.js +99 -10
- package/dist/checks/tips/detect.js +35 -3
- package/dist/checks/tips/index.js +1 -1
- package/dist/cli.js +13 -13
- package/dist/commands/ci/ci.js +56 -12
- package/dist/commands/ci/push-gate.js +79 -44
- package/dist/commands/install/install.js +23 -22
- package/dist/commands/install/uninstall.js +36 -30
- package/dist/commands/install/upgrade.js +10 -2
- package/dist/commands/land.js +2 -3
- package/dist/commands/lib.js +323 -25
- package/dist/commands/workflow/branches.js +312 -72
- package/dist/commands/workflow/challenge.js +66 -13
- package/dist/commands/workflow/context.js +46 -10
- package/dist/commands/workflow/counters.js +231 -23
- package/dist/commands/workflow/decisions.js +221 -106
- package/dist/commands/workflow/disk.js +2 -1
- package/dist/commands/workflow/feature-base.js +60 -0
- package/dist/commands/workflow/issues.js +243 -15
- package/dist/commands/workflow/junit.js +137 -0
- package/dist/commands/workflow/ledgers.js +726 -112
- package/dist/commands/workflow/locks.js +150 -29
- package/dist/commands/workflow/loops.js +67 -0
- package/dist/commands/workflow/open-decision.js +199 -0
- package/dist/commands/workflow/plan-blocks.js +6 -0
- package/dist/commands/workflow/plans.js +1 -1
- package/dist/commands/workflow/prs.js +272 -16
- package/dist/commands/workflow/repo.js +1 -1
- package/dist/commands/workflow/run-facts.js +6 -0
- package/dist/commands/workflow/runs.js +747 -155
- package/dist/commands/workflow/runtime.js +8 -4
- package/dist/commands/workflow/status.js +259 -13
- package/dist/commands/workflow/step-table.js +41 -15
- package/dist/commands/workflow/steps.js +530 -26
- package/dist/commands/workflow/summary-findings.js +1 -1
- package/dist/commands/workflow/summary.js +289 -8
- package/dist/commands/workflow/tasks.js +294 -27
- package/dist/commands/workflow/tests-base.js +266 -0
- package/dist/commands/workflow/tests-changed.js +130 -56
- package/dist/commands/workflow/tests-jump.js +77 -0
- package/dist/commands/workflow/tests.js +608 -131
- package/dist/commands/workflow/tracker.js +920 -112
- package/dist/commands/workflow/workflows.js +80 -59
- package/dist/commands/workflow/worktrees.js +387 -58
- package/dist/install/cloud-env.js +32 -10
- package/dist/install/managed-block.js +101 -0
- package/dist/install/manifest.js +7 -1
- package/dist/install/modules/claude.js +6 -2
- package/dist/install/modules/cloud.js +73 -86
- package/dist/install/modules/codex.js +9 -2
- package/dist/install/modules/core.js +133 -14
- package/dist/install/modules/opencode.js +18 -23
- package/dist/install/network-allowlist.js +8 -3
- package/dist/install/project-docs.js +551 -0
- package/dist/install/template-copies.js +55 -5
- package/dist/install/write.js +117 -5
- package/dist/ledgers/journal.js +10 -8
- package/dist/ledgers/migrate.js +20 -9
- package/dist/ledgers/status.js +461 -8
- package/dist/ledgers/telemetry.js +71 -13
- package/dist/render/trackers.js +3 -1
- package/dist/shared/package-manager.js +7 -2
- package/dist/shared/settings.js +8 -0
- package/dist/shared/text.js +13 -0
- package/dist/tools/instructions-sources.js +1 -0
- package/dist/tools/instructions.js +97 -24
- package/package.json +22 -15
- package/.bkit/core/hooks/preflight-linear.sh +0 -73
- package/.bkit/shared/docs/architecture.md +0 -16
- package/.bkit/shared/docs/data-schema.md +0 -16
- package/.bkit/shared/docs/design.md +0 -38
- package/.bkit/shared/docs/noise.md +0 -20
- package/.bkit/shared/docs/observability.md +0 -22
- package/.bkit/shared/docs/security.md +0 -62
- package/.bkit/shared/docs/setup.md +0 -52
- package/.bkit/shared/docs/technology.md +0 -15
- /package/.bkit/templates/{.lintstagedrc.json → lintstagedrc.example.json} +0 -0
- /package/.bkit/templates/{.prettierignore → prettierignore.example} +0 -0
|
@@ -17,21 +17,23 @@ import * as fs from "node:fs";
|
|
|
17
17
|
import * as os from "node:os";
|
|
18
18
|
import * as path from "node:path";
|
|
19
19
|
import { gitEnv } from "../../ledgers/telemetry.js";
|
|
20
|
-
import { actionHash, actionKey, alreadyDone, recordAction } from "../../ledgers/status.js";
|
|
21
|
-
import { bodySkipToken,
|
|
20
|
+
import { actionHash, actionKey, alreadyDone, recordAction, withTargetLock, } from "../../ledgers/status.js";
|
|
21
|
+
import { bodySkipToken, CommandError, DEV, EXIT, ghUnavailable, git, isSharedBranch, OUTPUT_LIMIT, parseJson, repoRoot, runGh, runGit, SKIP_CI_TOKEN, wholeNumber, } from "../lib.js";
|
|
22
22
|
import { bkitVersionStatus } from "../../shared/bkit-latest.js";
|
|
23
23
|
import { parseBkitVersion, serializeBkitVersion, } from "../../install/version-file.js";
|
|
24
24
|
import { DEV_REFSPEC, fetchDev, landBackoffMs, landDir, pushToDev, sleep } from "../land.js";
|
|
25
25
|
import { TIMEOUTS } from "../../shared/timeouts.js";
|
|
26
|
-
import { activeRecord, commitBookkeeping, markRecordPushed, recordOnBranch, } from "./ledgers.js";
|
|
26
|
+
import { activeRecord, bookPathspecs, checkOnlyBookkeeping, commitBookkeeping, markRecordPushed, recordOnBranch, } from "./ledgers.js";
|
|
27
27
|
import { releaseLock, resolveMonth, workflowLockPath } from "./locks.js";
|
|
28
|
+
import { underTestsLock } from "./junit.js";
|
|
28
29
|
import { EXIT_BASE_NOT_DEV, FORCE_BUILD, closeTransportRow, crossCheckRows, mergePr, openPrFor, probePr, } from "./prs.js";
|
|
29
30
|
import { AUTO_LABEL, AUTO_ROUTE_SUFFIX } from "./issues.js";
|
|
30
31
|
import { appendFeature } from "./roadmap.js";
|
|
31
32
|
import { detect } from "./runtime.js";
|
|
33
|
+
import { defaultRange } from "./feature-base.js";
|
|
32
34
|
import { readRuns, readStatusRows, readStatusRowsAt } from "./status.js";
|
|
33
35
|
import { declaredName, testSource } from "./test-blocks.js";
|
|
34
|
-
import { addAllButCopied, copyExcludes, hasLeftovers, recordRebase, removeWorktree, worktreeDir, } from "./worktrees.js";
|
|
36
|
+
import { addAllButCopied, assertShipEligible, copyExcludes, hasLeftovers, notOnDev, rebaseNoteFile, recordRebase, removeWorktree, worktreeDir, } from "./worktrees.js";
|
|
35
37
|
import { COULD_NOT_RUN_EXIT_CODES, LOCKFILE_REGENERATE, installCommand, scriptCommand, } from "../../shared/package-manager.js";
|
|
36
38
|
import { readPackageJson } from "../../shared/package-json.js";
|
|
37
39
|
import { str } from "./status.js";
|
|
@@ -472,12 +474,16 @@ export function resolveRebase(top, onLog = () => undefined) {
|
|
|
472
474
|
return refuse("REFUSE — git rebase --skip failed", null, "git rebase --skip failed");
|
|
473
475
|
}
|
|
474
476
|
}
|
|
475
|
-
else
|
|
477
|
+
else {
|
|
478
|
+
const cont = quietGit(top, ["rebase", "--continue"]);
|
|
476
479
|
// The next commit conflicted (next round handles it), or the rebase is stuck.
|
|
477
|
-
if (unmergedPaths(top).length === 0) {
|
|
478
|
-
|
|
480
|
+
if (!cont.ok && unmergedPaths(top).length === 0) {
|
|
481
|
+
const why = (cont.stderr || cont.stdout).replace(/\s*\n\s*/g, " ");
|
|
482
|
+
const reason = `git rebase --continue failed with no unmerged paths: ${why || "git gave no reason"}`;
|
|
483
|
+
return refuse(`REFUSE — ${reason}`, null, reason);
|
|
479
484
|
}
|
|
480
|
-
|
|
485
|
+
if (!cont.ok)
|
|
486
|
+
continue;
|
|
481
487
|
}
|
|
482
488
|
if (!rebaseInProgress(top)) {
|
|
483
489
|
log(`COMPLETE — rebase finished after ${result.rounds} auto-resolved round(s)`);
|
|
@@ -601,12 +607,23 @@ function topLevel(cwd) {
|
|
|
601
607
|
throw new CommandError(EXIT.USAGE, `not inside a git work tree: ${cwd}`);
|
|
602
608
|
return top;
|
|
603
609
|
}
|
|
604
|
-
|
|
605
|
-
|
|
610
|
+
/**
|
|
611
|
+
* Appends the resolution lines to the run's log, after the note `worktrees setup`
|
|
612
|
+
* held outside the tree while the rebase was paused (`rebaseNoteFile`), then drops
|
|
613
|
+
* the note. Called only once the rebase has finished or been aborted.
|
|
614
|
+
*/
|
|
615
|
+
function appendLog(ctx, top, file, lines) {
|
|
616
|
+
if (file === undefined)
|
|
617
|
+
return;
|
|
618
|
+
const noteFile = rebaseNoteFile(top);
|
|
619
|
+
const note = noteFile !== null && fs.existsSync(noteFile) ? fs.readFileSync(noteFile, "utf-8") : "";
|
|
620
|
+
if (note === "" && lines.length === 0)
|
|
606
621
|
return;
|
|
607
622
|
const abs = path.resolve(ctx.cwd, file);
|
|
608
623
|
fs.mkdirSync(path.dirname(abs), { recursive: true });
|
|
609
|
-
fs.appendFileSync(abs, lines.map((l) => `[bkit-rebase] ${l}\n`).join(""));
|
|
624
|
+
fs.appendFileSync(abs, note + lines.map((l) => `[bkit-rebase] ${l}\n`).join(""));
|
|
625
|
+
if (noteFile !== null)
|
|
626
|
+
fs.rmSync(noteFile, { force: true });
|
|
610
627
|
}
|
|
611
628
|
function rebaseVerb(ctx) {
|
|
612
629
|
const top = topLevel(ctx.cwd);
|
|
@@ -639,7 +656,7 @@ function rebaseVerb(ctx) {
|
|
|
639
656
|
ctx.log(line);
|
|
640
657
|
});
|
|
641
658
|
}
|
|
642
|
-
appendLog(ctx, str(ctx.flags.logFile), result.log);
|
|
659
|
+
appendLog(ctx, top, str(ctx.flags.logFile), result.log);
|
|
643
660
|
if (!result.ok && sentinelPath) {
|
|
644
661
|
fs.mkdirSync(path.dirname(sentinelPath), { recursive: true });
|
|
645
662
|
fs.writeFileSync(sentinelPath, "");
|
|
@@ -674,23 +691,23 @@ function rebaseOrigHead(top) {
|
|
|
674
691
|
}
|
|
675
692
|
return null;
|
|
676
693
|
}
|
|
677
|
-
/** Git collapses a failing pre-push hook's status
|
|
694
|
+
/** Git collapses a failing pre-push hook's status, so the hook's tests-lock status file alone decides. */
|
|
678
695
|
function runPush(cwd, args, branch) {
|
|
679
696
|
const who = `bkit branches push ${branch}`;
|
|
680
697
|
const wait = wholeNumber(process.env.BKIT_LOCK_WAIT_S, "BKIT_LOCK_WAIT_S", 60);
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
698
|
+
let res;
|
|
699
|
+
const { status, lock } = underTestsLock((lockEnv) => {
|
|
700
|
+
res = runGit(cwd, args, {
|
|
701
|
+
LOCAL_STACK_LOCK_WAIT_S: String(wait),
|
|
702
|
+
LOCAL_STACK_LOCK_WHO: who,
|
|
703
|
+
...lockEnv,
|
|
704
|
+
});
|
|
705
|
+
return res.ok ? 0 : null;
|
|
684
706
|
});
|
|
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
707
|
return {
|
|
691
708
|
...res,
|
|
692
|
-
lockHolder,
|
|
693
|
-
lockExit:
|
|
709
|
+
lockHolder: lock === "lock-wait" ? (status?.holder ?? null) : null,
|
|
710
|
+
lockExit: lock === "lock-wait" ? EXIT.AGENT_WAIT : lock === "could-not-run" ? 4 : null,
|
|
694
711
|
};
|
|
695
712
|
}
|
|
696
713
|
/**
|
|
@@ -1351,7 +1368,7 @@ export function disabledTestsIn(diff, root) {
|
|
|
1351
1368
|
return out;
|
|
1352
1369
|
}
|
|
1353
1370
|
function scanDiffVerb(ctx) {
|
|
1354
|
-
const
|
|
1371
|
+
const explicitBase = str(ctx.flags.base);
|
|
1355
1372
|
const pattern = str(ctx.flags.paths);
|
|
1356
1373
|
const marker = str(ctx.flags.marker);
|
|
1357
1374
|
const code = ctx.flags.code === true;
|
|
@@ -1372,7 +1389,9 @@ function scanDiffVerb(ctx) {
|
|
|
1372
1389
|
}
|
|
1373
1390
|
}
|
|
1374
1391
|
const top = topLevel(ctx.cwd);
|
|
1375
|
-
const
|
|
1392
|
+
const fallback = explicitBase === undefined ? defaultRange(top, ctx.log) : null;
|
|
1393
|
+
const base = explicitBase ?? fallback.base;
|
|
1394
|
+
const fetched = explicitBase === undefined ? null : fetchRemoteRef(top, base);
|
|
1376
1395
|
if (fetched !== null && !fetched.ok) {
|
|
1377
1396
|
ctx.log(`git fetch for ${base} failed: ${fetched.stderr} — diffing against the local ref`);
|
|
1378
1397
|
}
|
|
@@ -1380,7 +1399,7 @@ function scanDiffVerb(ctx) {
|
|
|
1380
1399
|
ctx.log(`unknown base: ${base}`);
|
|
1381
1400
|
return EXIT_DIFF_FAILED;
|
|
1382
1401
|
}
|
|
1383
|
-
const range = `${base}...HEAD`;
|
|
1402
|
+
const range = fallback?.range ?? `${base}...HEAD`;
|
|
1384
1403
|
if (disabled) {
|
|
1385
1404
|
const diff = quietGit(top, ["diff", "--no-renames", range, "--", ".", ":(exclude)docs/plans"]);
|
|
1386
1405
|
if (!diff.ok) {
|
|
@@ -1827,6 +1846,8 @@ function mergeDev(top, o, log) {
|
|
|
1827
1846
|
before: null,
|
|
1828
1847
|
};
|
|
1829
1848
|
const full = o.policy === "full";
|
|
1849
|
+
const target = o.target ?? UPSTREAM;
|
|
1850
|
+
const targetName = o.target ?? DEV;
|
|
1830
1851
|
const fid = o.fid ?? o.branch.replace(/^feat\//, "");
|
|
1831
1852
|
const refuse = (why) => {
|
|
1832
1853
|
const abort = runGit(top, ["merge", "--abort"]);
|
|
@@ -1835,27 +1856,33 @@ function mergeDev(top, o, log) {
|
|
|
1835
1856
|
return { ...out, code: EXIT_MERGE_CONFLICT, outcome: "refused" };
|
|
1836
1857
|
};
|
|
1837
1858
|
if (mergeInProgress(top)) {
|
|
1859
|
+
const merging = git(top, ["rev-parse", "--verify", "MERGE_HEAD"]);
|
|
1860
|
+
const expected = git(top, ["rev-parse", "--verify", `${target}^{commit}`]);
|
|
1861
|
+
if (merging === null || expected === null || merging !== expected) {
|
|
1862
|
+
log(`the pending merge targets ${merging ?? "an unreadable ref"}, not ${target}; finish that merge first`);
|
|
1863
|
+
return { ...out, code: EXIT_REFUSED, outcome: "refused" };
|
|
1864
|
+
}
|
|
1838
1865
|
out.before = git(top, ["rev-parse", "--verify", "--quiet", "ORIG_HEAD"]);
|
|
1839
|
-
log(`a merge of ${
|
|
1866
|
+
log(`a merge of ${target} is in progress — continuing it`);
|
|
1840
1867
|
}
|
|
1841
1868
|
else {
|
|
1842
1869
|
if (o.current)
|
|
1843
1870
|
return { ...out, outcome: "current" };
|
|
1844
1871
|
if (full && hasLeftovers(top)) {
|
|
1845
|
-
const message = `chore(${fid}): carry uncommitted work before merging ${
|
|
1872
|
+
const message = `chore(${fid}): carry uncommitted work before merging ${targetName}`;
|
|
1846
1873
|
if (!addAllButCopied(top).ok || !quietGit(top, ["commit", "-q", "-m", message]).ok) {
|
|
1847
1874
|
log("the uncommitted work could not be committed before the merge");
|
|
1848
1875
|
return { ...out, code: EXIT_REFUSED, outcome: "refused" };
|
|
1849
1876
|
}
|
|
1850
1877
|
out.carried = git(top, ["rev-parse", "HEAD"]);
|
|
1851
|
-
log(`committed the uncommitted work as ${out.carried} before merging ${
|
|
1878
|
+
log(`committed the uncommitted work as ${out.carried} before merging ${target}`);
|
|
1852
1879
|
}
|
|
1853
1880
|
out.before = git(top, ["rev-parse", "HEAD"]);
|
|
1854
|
-
const message = `chore(${fid}): merge ${
|
|
1855
|
-
const merge = quietGit(top, ["merge", "--no-edit", "-m", message,
|
|
1881
|
+
const message = `chore(${fid}): merge ${targetName}`;
|
|
1882
|
+
const merge = quietGit(top, ["merge", "--no-edit", "-m", message, target]);
|
|
1856
1883
|
if (!merge.ok && !mergeInProgress(top)) {
|
|
1857
1884
|
// Not a conflict: git refused to start the merge at all.
|
|
1858
|
-
log(`git merge ${
|
|
1885
|
+
log(`git merge ${target} failed: ${merge.stderr.trim()}`);
|
|
1859
1886
|
return { ...out, code: EXIT_MERGE_CONFLICT, outcome: "refused" };
|
|
1860
1887
|
}
|
|
1861
1888
|
}
|
|
@@ -1881,9 +1908,9 @@ function mergeDev(top, o, log) {
|
|
|
1881
1908
|
return refuse("the merge could not be committed");
|
|
1882
1909
|
}
|
|
1883
1910
|
out.merged = true;
|
|
1884
|
-
log(`merged ${
|
|
1911
|
+
log(`merged ${target} into ${o.branch} as ${git(top, ["rev-parse", "HEAD"])}`);
|
|
1885
1912
|
if (o.generate) {
|
|
1886
|
-
out.rebuilt = rebuildRegisters(top, out.resolved, (files) => `chore(${fid}): rebuild ${files.join(" ")} after merging ${
|
|
1913
|
+
out.rebuilt = rebuildRegisters(top, out.resolved, (files) => `chore(${fid}): rebuild ${files.join(" ")} after merging ${targetName}`, log);
|
|
1887
1914
|
out.generated = regenerate(top, o.branch, log, { fid });
|
|
1888
1915
|
if (out.generated === false)
|
|
1889
1916
|
out.code = EXIT_GENERATE_FAILED;
|
|
@@ -1905,9 +1932,192 @@ function recordMerge(statusFile, before, after) {
|
|
|
1905
1932
|
ref: after,
|
|
1906
1933
|
});
|
|
1907
1934
|
}
|
|
1935
|
+
function reconcileFeature(ctx, top, branch, observed) {
|
|
1936
|
+
if (branch === "" || isSharedBranch(branch)) {
|
|
1937
|
+
throw new CommandError(EXIT.USAGE, "feature reconciliation needs a checked-out feature branch");
|
|
1938
|
+
}
|
|
1939
|
+
const remote = `${REMOTE}/${branch}`;
|
|
1940
|
+
const probeResult = spawnSync("git", ["ls-remote", "--exit-code", "--heads", REMOTE, branch], {
|
|
1941
|
+
cwd: top,
|
|
1942
|
+
encoding: "utf-8",
|
|
1943
|
+
env: gitEnv(),
|
|
1944
|
+
});
|
|
1945
|
+
const probe = { ok: probeResult.status === 0, stderr: probeResult.stderr ?? "" };
|
|
1946
|
+
if (!probe.ok && probeResult.status !== 2) {
|
|
1947
|
+
ctx.log(`cannot fetch ${remote}: ${probe.stderr}`);
|
|
1948
|
+
return EXIT_FETCH_FAILED;
|
|
1949
|
+
}
|
|
1950
|
+
if (probe.ok) {
|
|
1951
|
+
const fetched = fetchRemoteRef(top, remote);
|
|
1952
|
+
if (fetched === null || !fetched.ok) {
|
|
1953
|
+
ctx.log(`git fetch ${remote} failed: ${fetched?.stderr ?? "unknown remote ref"}`);
|
|
1954
|
+
return EXIT_FETCH_FAILED;
|
|
1955
|
+
}
|
|
1956
|
+
observed.remoteHead = git(top, [
|
|
1957
|
+
"rev-parse",
|
|
1958
|
+
"--verify",
|
|
1959
|
+
"--quiet",
|
|
1960
|
+
`refs/remotes/${remote}^{commit}`,
|
|
1961
|
+
]);
|
|
1962
|
+
if (observed.remoteHead === null) {
|
|
1963
|
+
ctx.log(`cannot read the freshly fetched feature ${remote}`);
|
|
1964
|
+
return EXIT_FETCH_FAILED;
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
assertShipEligible(top, "HEAD");
|
|
1968
|
+
if (probe.ok)
|
|
1969
|
+
assertShipEligible(top, remote);
|
|
1970
|
+
const headFlag = str(ctx.flags.head);
|
|
1971
|
+
if (headFlag !== undefined &&
|
|
1972
|
+
git(top, ["rev-parse", "--verify", "--quiet", `${headFlag}^{commit}`]) === null) {
|
|
1973
|
+
throw new CommandError(EXIT.USAGE, `--head ${headFlag} does not name a commit`);
|
|
1974
|
+
}
|
|
1975
|
+
if (!mergeInProgress(top) && hasLeftovers(top)) {
|
|
1976
|
+
const statusFile = str(ctx.flags.file);
|
|
1977
|
+
const relative = statusFile && path.relative(top, path.resolve(ctx.cwd, statusFile)).split(path.sep).join("/");
|
|
1978
|
+
const scope = relative && /^docs\/plans\/(\d{6})\/logs\/([^/]+)\/status\.jsonl$/.exec(relative);
|
|
1979
|
+
const fid = str(ctx.flags.fid) || branch.replace(/^feat\//, "");
|
|
1980
|
+
if (!scope || scope[2] !== fid) {
|
|
1981
|
+
ctx.log("feature branch has uncommitted work — commit that work before reconciliation");
|
|
1982
|
+
return EXIT_REFUSED;
|
|
1983
|
+
}
|
|
1984
|
+
const outside = runGit(top, [
|
|
1985
|
+
"status",
|
|
1986
|
+
"--porcelain=v1",
|
|
1987
|
+
"-z",
|
|
1988
|
+
"--untracked-files=all",
|
|
1989
|
+
"--",
|
|
1990
|
+
".",
|
|
1991
|
+
...copyExcludes(top),
|
|
1992
|
+
...bookPathspecs(scope[1], fid, "core").map((spec) => `:(exclude)${spec}`),
|
|
1993
|
+
]);
|
|
1994
|
+
if (!outside.ok || outside.stdout !== "") {
|
|
1995
|
+
ctx.log("feature branch has unrelated uncommitted work — commit that work before reconciliation");
|
|
1996
|
+
return EXIT_REFUSED;
|
|
1997
|
+
}
|
|
1998
|
+
const carried = commitBookkeeping({
|
|
1999
|
+
root: top,
|
|
2000
|
+
month: scope[1],
|
|
2001
|
+
fid,
|
|
2002
|
+
scope: "core",
|
|
2003
|
+
mode: "commit",
|
|
2004
|
+
message: `chore(${fid}): carry ship bookkeeping before reconciliation`,
|
|
2005
|
+
}, ctx.log);
|
|
2006
|
+
if (carried.outcome !== "committed") {
|
|
2007
|
+
ctx.log("the workflow bookkeeping could not be committed before reconciliation");
|
|
2008
|
+
return EXIT_REFUSED;
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
const fid = str(ctx.flags.fid) || branch.replace(/^feat\//, "");
|
|
2012
|
+
const merge = (target, current) => {
|
|
2013
|
+
const m = mergeDev(top, { branch, target, policy: "full", fid, generate: true, current }, ctx.log);
|
|
2014
|
+
const after = git(top, ["rev-parse", "HEAD"]);
|
|
2015
|
+
const file = str(ctx.flags.file);
|
|
2016
|
+
if (m.merged && file !== undefined)
|
|
2017
|
+
recordMerge(path.resolve(ctx.cwd, file), m.before, after);
|
|
2018
|
+
if (m.code !== EXIT.OK) {
|
|
2019
|
+
ctx.emit({ branch, head: after, remoteHead: observed.remoteHead, ...m, target });
|
|
2020
|
+
}
|
|
2021
|
+
return m.code;
|
|
2022
|
+
};
|
|
2023
|
+
if (mergeInProgress(top)) {
|
|
2024
|
+
const pending = git(top, ["rev-parse", "--verify", "MERGE_HEAD"]);
|
|
2025
|
+
if (pending === null ||
|
|
2026
|
+
!probe.ok ||
|
|
2027
|
+
!runGit(top, ["merge-base", "--is-ancestor", pending, remote]).ok) {
|
|
2028
|
+
ctx.log("the pending merge is not the fetched feature merge — finish it before reconciliation");
|
|
2029
|
+
return EXIT_REFUSED;
|
|
2030
|
+
}
|
|
2031
|
+
const code = merge(pending, false);
|
|
2032
|
+
if (code !== EXIT.OK)
|
|
2033
|
+
return code;
|
|
2034
|
+
}
|
|
2035
|
+
if (probe.ok) {
|
|
2036
|
+
const local = git(top, ["rev-parse", "HEAD"]);
|
|
2037
|
+
if (local === null)
|
|
2038
|
+
return EXIT_REFUSED;
|
|
2039
|
+
const ancestor = (a, b) => spawnSync("git", ["merge-base", "--is-ancestor", a, b], { cwd: top, env: gitEnv() }).status;
|
|
2040
|
+
const behind = ancestor("HEAD", remote);
|
|
2041
|
+
const ahead = ancestor(remote, "HEAD");
|
|
2042
|
+
if ((behind !== 0 && behind !== 1) || (ahead !== 0 && ahead !== 1)) {
|
|
2043
|
+
ctx.log(`cannot compare the local feature with ${remote}`);
|
|
2044
|
+
return EXIT_REFUSED;
|
|
2045
|
+
}
|
|
2046
|
+
if (behind === 0 && ahead !== 0) {
|
|
2047
|
+
const ff = quietGit(top, ["merge", "--ff-only", remote]);
|
|
2048
|
+
if (!ff.ok) {
|
|
2049
|
+
ctx.log(`cannot fast-forward the feature: ${ff.stderr}`);
|
|
2050
|
+
return EXIT_REFUSED;
|
|
2051
|
+
}
|
|
2052
|
+
const file = str(ctx.flags.file);
|
|
2053
|
+
if (file !== undefined)
|
|
2054
|
+
recordMerge(path.resolve(ctx.cwd, file), local, git(top, ["rev-parse", "HEAD"]));
|
|
2055
|
+
}
|
|
2056
|
+
else if (ahead !== 0) {
|
|
2057
|
+
const code = merge(remote, false);
|
|
2058
|
+
if (code !== EXIT.OK)
|
|
2059
|
+
return code;
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
assertShipEligible(top, "HEAD");
|
|
2063
|
+
const unpublished = !probe.ok || commitsAhead(top, remote) > 0;
|
|
2064
|
+
if (unpublished && SKIP_CI_TOKEN.test(git(top, ["log", "-1", "--format=%B"]) ?? "")) {
|
|
2065
|
+
const trigger = quietGit(top, [
|
|
2066
|
+
"commit",
|
|
2067
|
+
"--allow-empty",
|
|
2068
|
+
"-m",
|
|
2069
|
+
`chore(${fid}): validate reconciled feature`,
|
|
2070
|
+
]);
|
|
2071
|
+
if (!trigger.ok) {
|
|
2072
|
+
ctx.log(`cannot create a CI-running feature head: ${trigger.stderr}`);
|
|
2073
|
+
return EXIT_REFUSED;
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
return EXIT.OK;
|
|
2077
|
+
}
|
|
2078
|
+
/** Merge-aware coverage identity; omit a dev merge only when Git proves its result automatic. */
|
|
2079
|
+
function featureCodeState(top, head, month, fid) {
|
|
2080
|
+
const commits = runGit(top, ["rev-list", "--parents", `${UPSTREAM}..${head}`]);
|
|
2081
|
+
if (!commits.ok)
|
|
2082
|
+
throw new CommandError(EXIT_DIFF_FAILED, commits.stderr);
|
|
2083
|
+
const retained = [];
|
|
2084
|
+
for (const line of commits.stdout.split("\n").filter(Boolean)) {
|
|
2085
|
+
const [sha, first, second, ...other] = line.split(" ");
|
|
2086
|
+
if (!sha || !first)
|
|
2087
|
+
throw new CommandError(EXIT_DIFF_FAILED, "feature coverage needs readable commit parents");
|
|
2088
|
+
const bookkeeping = checkOnlyBookkeeping(top, { month, fid, from: first, to: sha });
|
|
2089
|
+
if (bookkeeping.kind === "ok")
|
|
2090
|
+
continue;
|
|
2091
|
+
if (bookkeeping.kind !== "outside")
|
|
2092
|
+
throw new CommandError(EXIT_DIFF_FAILED, `feature coverage classification: ${bookkeeping.kind}`);
|
|
2093
|
+
if (second && other.length === 0) {
|
|
2094
|
+
const devParent = runGit(top, ["merge-base", "--is-ancestor", second, UPSTREAM]);
|
|
2095
|
+
if (devParent.ok) {
|
|
2096
|
+
const automatic = git(top, ["merge-tree", "--write-tree", first, second]);
|
|
2097
|
+
const tree = git(top, ["rev-parse", `${sha}^{tree}`]);
|
|
2098
|
+
if (automatic && tree && automatic.split("\n")[0] === tree)
|
|
2099
|
+
continue;
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
retained.push(sha);
|
|
2103
|
+
}
|
|
2104
|
+
return `v1:${retained.sort().join(",")}`;
|
|
2105
|
+
}
|
|
1908
2106
|
function syncVerb(ctx) {
|
|
1909
2107
|
const mergeDocs = ctx.flags.mergeDocs === true;
|
|
1910
2108
|
const merge = ctx.flags.merge === true;
|
|
2109
|
+
const reconcile = ctx.flags.reconcileFeature === true;
|
|
2110
|
+
const featureState = ctx.flags.featureState === true;
|
|
2111
|
+
const month = str(ctx.flags.month);
|
|
2112
|
+
const coverageFid = str(ctx.flags.fid);
|
|
2113
|
+
if (featureState &&
|
|
2114
|
+
(mergeDocs || merge || reconcile || !month || !/^\d{6}$/.test(month) || !coverageFid))
|
|
2115
|
+
throw new CommandError(EXIT.USAGE, "--feature-state needs --month=YYYYMM and --fid, separately from reconciliation or merging");
|
|
2116
|
+
const targetFlag = str(ctx.flags.target);
|
|
2117
|
+
if (targetFlag !== undefined && (!merge || targetFlag === "" || targetFlag.startsWith("-")))
|
|
2118
|
+
throw new CommandError(EXIT.USAGE, "--target needs --merge and a commit ref");
|
|
2119
|
+
if (reconcile && (mergeDocs || merge))
|
|
2120
|
+
throw new CommandError(EXIT.USAGE, "give --reconcile-feature separately from --merge or --merge-docs");
|
|
1911
2121
|
const headFlag = str(ctx.flags.head);
|
|
1912
2122
|
if ((mergeDocs || merge) && headFlag !== undefined) {
|
|
1913
2123
|
throw new CommandError(EXIT.USAGE, "--merge and --merge-docs merge into HEAD; give --head or one of them, not both");
|
|
@@ -1919,15 +2129,31 @@ function syncVerb(ctx) {
|
|
|
1919
2129
|
if (merge && sentinelPath)
|
|
1920
2130
|
fs.rmSync(sentinelPath, { force: true });
|
|
1921
2131
|
const top = topLevel(ctx.cwd);
|
|
2132
|
+
const target = targetFlag === undefined
|
|
2133
|
+
? undefined
|
|
2134
|
+
: git(top, ["rev-parse", "--verify", "--quiet", `${targetFlag}^{commit}`]);
|
|
2135
|
+
if (targetFlag !== undefined && !target)
|
|
2136
|
+
throw new CommandError(EXIT.USAGE, `--target ${targetFlag} does not name a commit`);
|
|
1922
2137
|
const fetch = fetchDev(top);
|
|
1923
2138
|
if (!fetch.ok) {
|
|
1924
2139
|
ctx.log(`git fetch ${REMOTE} ${DEV} failed: ${fetch.stderr}`);
|
|
1925
2140
|
return EXIT_FETCH_FAILED;
|
|
1926
2141
|
}
|
|
1927
|
-
const
|
|
2142
|
+
const branch = currentBranch(top);
|
|
2143
|
+
const observed = { remoteHead: null };
|
|
2144
|
+
if (reconcile) {
|
|
2145
|
+
const code = reconcileFeature(ctx, top, branch, observed);
|
|
2146
|
+
if (code !== EXIT.OK)
|
|
2147
|
+
return code;
|
|
2148
|
+
}
|
|
2149
|
+
const head = git(top, [
|
|
2150
|
+
"rev-parse",
|
|
2151
|
+
"--verify",
|
|
2152
|
+
"--quiet",
|
|
2153
|
+
`${reconcile ? "HEAD" : (headFlag ?? "HEAD")}^{commit}`,
|
|
2154
|
+
]);
|
|
1928
2155
|
if (!head)
|
|
1929
2156
|
throw new CommandError(EXIT.USAGE, `--head ${headFlag ?? "HEAD"} does not name a commit`);
|
|
1930
|
-
const branch = currentBranch(top);
|
|
1931
2157
|
const ancestor = spawnSync("git", ["merge-base", "--is-ancestor", UPSTREAM, head], {
|
|
1932
2158
|
cwd: top,
|
|
1933
2159
|
env: gitEnv(),
|
|
@@ -1941,6 +2167,10 @@ function syncVerb(ctx) {
|
|
|
1941
2167
|
const out = {
|
|
1942
2168
|
branch: branch === "" ? null : branch,
|
|
1943
2169
|
head,
|
|
2170
|
+
...(reconcile ? { remoteHead: observed.remoteHead, reconciledHead: head } : {}),
|
|
2171
|
+
...(featureState
|
|
2172
|
+
? { featureCodeState: featureCodeState(top, head, month, coverageFid) }
|
|
2173
|
+
: {}),
|
|
1944
2174
|
basePath: ancestor.status === 0 ? "A" : "B",
|
|
1945
2175
|
behind,
|
|
1946
2176
|
docsBehind,
|
|
@@ -1975,7 +2205,16 @@ function syncVerb(ctx) {
|
|
|
1975
2205
|
throw new CommandError(EXIT.USAGE, `--merge merges ${UPSTREAM} into a feature branch, never into ${branch}`);
|
|
1976
2206
|
}
|
|
1977
2207
|
const fid = str(ctx.flags.fid) || branch.replace(/^feat\//, "");
|
|
1978
|
-
const m = mergeDev(top, {
|
|
2208
|
+
const m = mergeDev(top, {
|
|
2209
|
+
branch,
|
|
2210
|
+
policy: "full",
|
|
2211
|
+
fid,
|
|
2212
|
+
generate: true,
|
|
2213
|
+
...(target ? { target } : {}),
|
|
2214
|
+
current: target
|
|
2215
|
+
? runGit(top, ["merge-base", "--is-ancestor", target, "HEAD"]).ok
|
|
2216
|
+
: out.basePath === "A",
|
|
2217
|
+
}, ctx.log);
|
|
1979
2218
|
const refused = m.outcome === "refused";
|
|
1980
2219
|
if (refused && sentinelPath) {
|
|
1981
2220
|
fs.mkdirSync(path.dirname(sentinelPath), { recursive: true });
|
|
@@ -1984,6 +2223,7 @@ function syncVerb(ctx) {
|
|
|
1984
2223
|
const newHead = git(top, ["rev-parse", "HEAD"]) ?? head;
|
|
1985
2224
|
ctx.emit({
|
|
1986
2225
|
...out,
|
|
2226
|
+
...(target ? { target } : {}),
|
|
1987
2227
|
head: newHead,
|
|
1988
2228
|
merged: m.merged,
|
|
1989
2229
|
resolved: m.resolved,
|
|
@@ -2004,7 +2244,7 @@ function syncVerb(ctx) {
|
|
|
2004
2244
|
return EXIT.OK;
|
|
2005
2245
|
}
|
|
2006
2246
|
/**
|
|
2007
|
-
* Ship Step
|
|
2247
|
+
* Ship Step 11: after the merge, bring local dev up to origin/dev by a pure
|
|
2008
2248
|
* fast-forward without checking anything out, then a frozen install when the
|
|
2009
2249
|
* main checkout is on dev and moved. Never pushes.
|
|
2010
2250
|
*/
|
|
@@ -2092,14 +2332,18 @@ function restoreBranchRows(dir, branch) {
|
|
|
2092
2332
|
for (const p of changed) {
|
|
2093
2333
|
const before = new Set(revLines(dir, base, p));
|
|
2094
2334
|
const file = path.join(dir, p);
|
|
2095
|
-
const
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2335
|
+
const wrote = withTargetLock(file, () => {
|
|
2336
|
+
const text = fs.existsSync(file) ? fs.readFileSync(file, "utf-8") : "";
|
|
2337
|
+
const have = new Set(text.split("\n").map((l) => l.trim()));
|
|
2338
|
+
const missing = revLines(dir, branch, p).filter((l) => !before.has(l) && !have.has(l));
|
|
2339
|
+
if (missing.length === 0)
|
|
2340
|
+
return false;
|
|
2341
|
+
const sep = text !== "" && !text.endsWith("\n") ? "\n" : "";
|
|
2342
|
+
fs.appendFileSync(file, `${sep}${missing.join("\n")}\n`);
|
|
2343
|
+
return true;
|
|
2344
|
+
});
|
|
2345
|
+
if (!wrote)
|
|
2099
2346
|
continue;
|
|
2100
|
-
const sep = text !== "" && !text.endsWith("\n") ? "\n" : "";
|
|
2101
|
-
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
2102
|
-
fs.appendFileSync(file, `${sep}${missing.join("\n")}\n`);
|
|
2103
2347
|
runGit(dir, ["add", "--", p]);
|
|
2104
2348
|
}
|
|
2105
2349
|
}
|
|
@@ -2330,30 +2574,6 @@ function fastForwardDev(root, sha, log) {
|
|
|
2330
2574
|
}
|
|
2331
2575
|
return "fast-forwarded";
|
|
2332
2576
|
}
|
|
2333
|
-
/**
|
|
2334
|
-
* What `branch` changed that origin/dev does not hold, compared file by file
|
|
2335
|
-
* against the branch's fork point: a file whose dev copy differs from the
|
|
2336
|
-
* branch's, or (a `.jsonl` ledger, union-merged) a line the branch added that
|
|
2337
|
-
* dev's copy lacks. `docs/roadmap.md` is re-rendered on every close, so it is
|
|
2338
|
-
* not compared. The branch and its worktree are deleted only when this is empty.
|
|
2339
|
-
*/
|
|
2340
|
-
function notOnDev(root, branch) {
|
|
2341
|
-
const base = git(root, ["merge-base", UPSTREAM, branch]);
|
|
2342
|
-
if (base === null)
|
|
2343
|
-
return [`${branch}: no common history with ${UPSTREAM}`];
|
|
2344
|
-
const lines = (rev, p) => revLines(root, rev, p);
|
|
2345
|
-
return (git(root, ["diff", "--name-only", "--no-renames", "--diff-filter=d", base, branch]) ?? "")
|
|
2346
|
-
.split("\n")
|
|
2347
|
-
.filter((p) => p !== "" && p !== "docs/roadmap.md")
|
|
2348
|
-
.filter((p) => {
|
|
2349
|
-
if (!p.endsWith(".jsonl"))
|
|
2350
|
-
return (git(root, ["rev-parse", `${branch}:${p}`]) !==
|
|
2351
|
-
git(root, ["rev-parse", "-q", "--verify", `${UPSTREAM}:${p}`]));
|
|
2352
|
-
const before = new Set(lines(base, p));
|
|
2353
|
-
const onDev = new Set(lines(UPSTREAM, p));
|
|
2354
|
-
return lines(branch, p).some((l) => !before.has(l) && !onDev.has(l));
|
|
2355
|
-
});
|
|
2356
|
-
}
|
|
2357
2577
|
/**
|
|
2358
2578
|
* Those of `paths` whose content at `spec(p)` is already local `dev`'s: work the
|
|
2359
2579
|
* branch carries because `dev` is unpushed, not work a run in this branch made.
|
|
@@ -2644,6 +2864,17 @@ export const branchesCommand = {
|
|
|
2644
2864
|
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
2865
|
use: "workflow",
|
|
2646
2866
|
flags: [
|
|
2867
|
+
{
|
|
2868
|
+
name: "feature-state",
|
|
2869
|
+
type: "boolean",
|
|
2870
|
+
help: "report merge-aware feature coverage, excluding bookkeeping and proven automatic dev-only merges; needs --month and --fid",
|
|
2871
|
+
},
|
|
2872
|
+
{ name: "month", type: "string", help: "--feature-state: bookkeeping month YYYYMM" },
|
|
2873
|
+
{
|
|
2874
|
+
name: "reconcile-feature",
|
|
2875
|
+
type: "boolean",
|
|
2876
|
+
help: "ship: fetch and reconcile the feature branch before classifying its base; preserve divergent work through a merge and ensure unpublished work has a CI-running head",
|
|
2877
|
+
},
|
|
2647
2878
|
{
|
|
2648
2879
|
name: "head",
|
|
2649
2880
|
type: "string",
|
|
@@ -2654,6 +2885,11 @@ export const branchesCommand = {
|
|
|
2654
2885
|
type: "boolean",
|
|
2655
2886
|
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
2887
|
},
|
|
2888
|
+
{
|
|
2889
|
+
name: "target",
|
|
2890
|
+
type: "string",
|
|
2891
|
+
help: "--merge: exact recorded merge target (default origin/dev); continuation refuses a different MERGE_HEAD",
|
|
2892
|
+
},
|
|
2657
2893
|
{
|
|
2658
2894
|
name: "merge-docs",
|
|
2659
2895
|
type: "boolean",
|
|
@@ -2678,6 +2914,10 @@ export const branchesCommand = {
|
|
|
2678
2914
|
output: {
|
|
2679
2915
|
branch: "current branch (null when detached)",
|
|
2680
2916
|
head: "commit compared (after a merge: the new HEAD)",
|
|
2917
|
+
remoteHead: "--reconcile-feature: the freshly observed remote feature commit, or null when absent",
|
|
2918
|
+
reconciledHead: "--reconcile-feature: the resulting local feature commit used for base classification",
|
|
2919
|
+
featureCodeState: "--feature-state: versioned identity of feature commits and semantic merge results",
|
|
2920
|
+
target: "--merge --target: the resolved commit being merged or continued",
|
|
2681
2921
|
basePath: `A when ${UPSTREAM} is an ancestor of head (nothing to integrate), else B`,
|
|
2682
2922
|
behind: `commits on ${UPSTREAM} not in head`,
|
|
2683
2923
|
docsBehind: `of those, commits touching docs/ or a ledger path (LEDGERS)`,
|
|
@@ -2692,6 +2932,7 @@ export const branchesCommand = {
|
|
|
2692
2932
|
sentinel: "--merge: the sentinel written on refusal (null otherwise)",
|
|
2693
2933
|
},
|
|
2694
2934
|
exitCodes: {
|
|
2935
|
+
[EXIT_DIFF_FAILED]: "--feature-state: commit ancestry or bookkeeping classification could not be read",
|
|
2695
2936
|
[EXIT_REFUSED]: "--merge: the uncommitted work could not be committed before the merge",
|
|
2696
2937
|
[EXIT_DETACHED]: "--merge / --merge-docs with no branch checked out",
|
|
2697
2938
|
[EXIT_FETCH_FAILED]: `git fetch ${REMOTE} ${DEV} failed`,
|
|
@@ -2733,7 +2974,7 @@ export const branchesCommand = {
|
|
|
2733
2974
|
run: regenerateVerb,
|
|
2734
2975
|
},
|
|
2735
2976
|
push: {
|
|
2736
|
-
summary: "Push the current branch with exactly one git push: plain for dev/main, --force-with-lease otherwise; 81 tests lock held.",
|
|
2977
|
+
summary: "Push the current branch with exactly one git push: plain for dev/main, --force-with-lease otherwise; when the pre-push hook's lock status file says so, 81 tests lock held, 4 tests lock refused the run or stopped it at the hold limit.",
|
|
2737
2978
|
use: "workflow",
|
|
2738
2979
|
flags: [
|
|
2739
2980
|
{
|
|
@@ -2830,8 +3071,7 @@ export const branchesCommand = {
|
|
|
2830
3071
|
{
|
|
2831
3072
|
name: "base",
|
|
2832
3073
|
type: "string",
|
|
2833
|
-
|
|
2834
|
-
help: "diff <base>...HEAD; an origin/<branch> base is fetched first",
|
|
3074
|
+
help: "diff <base>...HEAD; an origin/<branch> base is fetched first (default: the feature base, where the branch's own work starts)",
|
|
2835
3075
|
},
|
|
2836
3076
|
{
|
|
2837
3077
|
name: "paths",
|