@cbartens/bkit 6.1.0 → 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 +43 -33
- 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 +99 -36
- package/.bkit/core/.bkit/templates.md +167 -37
- 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 +161 -37
- package/.bkit/core/engine/checks/after/index.ts +18 -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 +124 -19
- package/.bkit/core/engine/commands/ci/push-gate.ts +101 -43
- package/.bkit/core/engine/commands/install/doctor.ts +5 -5
- 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 +202 -26
- 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 +46 -11
- 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/context/bkit-vercel.md +103 -59
- 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-check-accepted-divergences.mjs +1 -6
- package/.bkit/templates/scripts/ci/bkit-machine-lock.sh +511 -103
- package/.bkit/templates/scripts/ci/bkit-test-awake.mjs +314 -28
- package/.bkit/templates/scripts/ci/bkit-test-awake.test.mjs +500 -1
- package/.bkit/templates/scripts/graphify/bkit-graphify-graphml.py +1 -1
- package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +91 -62
- package/.bkit/templates/scripts/graphify/bkit-graphify.sh +59 -11
- package/.bkit/templates/slop-scan.config.json +2 -0
- package/CHANGELOG.md +79 -0
- package/DETAILS.md +661 -0
- package/README.md +73 -604
- package/dist/checks/after/auth.js +114 -46
- package/dist/checks/after/github.js +138 -35
- package/dist/checks/after/index.js +16 -4
- 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 +113 -20
- package/dist/commands/ci/push-gate.js +79 -44
- package/dist/commands/install/doctor.js +5 -5
- 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 +190 -27
- 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 +21 -12
- 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 +23 -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
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
// zero. The pre-existing baseline is never the change's to fix. On failure it names each
|
|
10
10
|
// net-new or worsened finding (`path:line`, rule, message), with line shifts dropped.
|
|
11
11
|
//
|
|
12
|
-
// `prose` — the prose gate (`bkit:lint:prose`): Vale over
|
|
13
|
-
//
|
|
12
|
+
// `prose` — the prose gate (`bkit:lint:prose`): Vale over tracked and unignored markdown,
|
|
13
|
+
// or explicit globs. Restores the gitignored write-good package from the main worktree (else
|
|
14
14
|
// `vale sync`) when it is missing, and fails when vale or write-good is unavailable.
|
|
15
15
|
//
|
|
16
16
|
// `skip-token` — whether a commit message carries a GitHub skip-CI token
|
|
17
17
|
// (`SKIP_CI_TOKEN`), for the `.husky/pre-push` CI-suppressor guard.
|
|
18
18
|
//
|
|
19
19
|
// `min-push` — whether every file a push changes is one bkit's workflows write (ship's bookkeeping
|
|
20
|
-
// allow-list, the plans tree) or one `bkit.testing.minPushPaths` / `ciSkipPaths` adds, so
|
|
20
|
+
// allow-list, the plans tree, the audit reports) or one `bkit.testing.minPushPaths` / `ciSkipPaths` adds, so
|
|
21
21
|
// `.husky/pre-push` runs `bkit:gate:min`. Files decide, never `[skip ci]` (a typed label
|
|
22
22
|
// GitHub reads off the last commit only).
|
|
23
23
|
//
|
|
@@ -35,11 +35,13 @@ import * as fs from "node:fs";
|
|
|
35
35
|
import * as os from "node:os";
|
|
36
36
|
import * as path from "node:path";
|
|
37
37
|
|
|
38
|
+
import { gitEnv } from "../../ledgers/telemetry.js";
|
|
38
39
|
import { readBkitConfig, type BkitConfig } from "../../shared/settings.js";
|
|
39
40
|
import {
|
|
40
41
|
CommandError,
|
|
41
42
|
commitMessage,
|
|
42
43
|
EXIT,
|
|
44
|
+
OUTPUT_LIMIT,
|
|
43
45
|
git,
|
|
44
46
|
parseJson,
|
|
45
47
|
runGit,
|
|
@@ -51,8 +53,10 @@ import {
|
|
|
51
53
|
bookPathspecs,
|
|
52
54
|
changedOutside,
|
|
53
55
|
checkOnlyBookkeeping,
|
|
56
|
+
gitRaw,
|
|
54
57
|
globPathspecs,
|
|
55
58
|
} from "../workflow/ledgers.js";
|
|
59
|
+
import { managedHead } from "../../install/managed-block.js";
|
|
56
60
|
import { pins } from "./pins.js";
|
|
57
61
|
import { hasVerifiedIncrement, runPushGate } from "./push-gate.js";
|
|
58
62
|
|
|
@@ -245,7 +249,7 @@ const tail = (text: string) => text.trim().split("\n").slice(-20).join("\n");
|
|
|
245
249
|
* the signal would. Without the listeners Node dies on the signal and leaves the base
|
|
246
250
|
* worktree registered in the repo.
|
|
247
251
|
*/
|
|
248
|
-
async function withCleanup<T>(body: () => T, cleanup: () => void): Promise<T> {
|
|
252
|
+
export async function withCleanup<T>(body: () => T, cleanup: () => void): Promise<T> {
|
|
249
253
|
const received: NodeJS.Signals[] = [];
|
|
250
254
|
const onSignal = (sig: NodeJS.Signals) => received.push(sig);
|
|
251
255
|
for (const sig of CLEANUP_SIGNALS) process.on(sig, onSignal);
|
|
@@ -436,11 +440,17 @@ function globWalk(glob: string): { root: string; depth: number } {
|
|
|
436
440
|
* Every file under `root` down to `depth` levels (relative to `cwd`, `/`-separated).
|
|
437
441
|
* Skips WALK_SKIP folders and never follows a symlinked folder.
|
|
438
442
|
*/
|
|
439
|
-
function walkFiles(cwd: string, root: string, depth: number): string[] {
|
|
443
|
+
function walkFiles(cwd: string, root: string, depth: number, skipCheckouts = false): string[] {
|
|
440
444
|
const out: string[] = [];
|
|
441
445
|
const visit = (rel: string, level: number) => {
|
|
442
446
|
const abs = path.join(cwd, rel);
|
|
443
|
-
if (!fs.
|
|
447
|
+
if (!fs.lstatSync(abs, { throwIfNoEntry: false })) return;
|
|
448
|
+
if (
|
|
449
|
+
skipCheckouts &&
|
|
450
|
+
rel !== "." &&
|
|
451
|
+
fs.lstatSync(path.join(abs, ".git"), { throwIfNoEntry: false })
|
|
452
|
+
)
|
|
453
|
+
return;
|
|
444
454
|
for (const ent of fs.readdirSync(abs, { withFileTypes: true })) {
|
|
445
455
|
const child = rel === "." ? ent.name : `${rel}/${ent.name}`;
|
|
446
456
|
if (ent.isDirectory()) {
|
|
@@ -454,8 +464,46 @@ function walkFiles(cwd: string, root: string, depth: number): string[] {
|
|
|
454
464
|
return out;
|
|
455
465
|
}
|
|
456
466
|
|
|
457
|
-
/**
|
|
458
|
-
export function proseFiles(cwd: string, globs
|
|
467
|
+
/** Default prose uses tracked and unignored files; explicit globs select directly from disk. */
|
|
468
|
+
export function proseFiles(cwd: string, globs?: readonly string[]): string[] {
|
|
469
|
+
if (!globs) {
|
|
470
|
+
let ancestor = path.resolve(cwd);
|
|
471
|
+
while (!fs.lstatSync(path.join(ancestor, ".git"), { throwIfNoEntry: false })) {
|
|
472
|
+
const parent = path.dirname(ancestor);
|
|
473
|
+
if (parent === ancestor) {
|
|
474
|
+
return walkFiles(cwd, ".", Infinity, true)
|
|
475
|
+
.filter((rel) => rel.endsWith(".md"))
|
|
476
|
+
.sort();
|
|
477
|
+
}
|
|
478
|
+
ancestor = parent;
|
|
479
|
+
}
|
|
480
|
+
const listed = spawnSync(
|
|
481
|
+
"git",
|
|
482
|
+
["ls-files", "-z", "--cached", "--others", "--exclude-standard"],
|
|
483
|
+
{
|
|
484
|
+
cwd,
|
|
485
|
+
encoding: "utf-8",
|
|
486
|
+
env: gitEnv(),
|
|
487
|
+
maxBuffer: OUTPUT_LIMIT,
|
|
488
|
+
},
|
|
489
|
+
);
|
|
490
|
+
if (listed.error || listed.status !== 0) {
|
|
491
|
+
throw new Error(`cannot list prose sources: ${listed.error?.message ?? listed.stderr}`);
|
|
492
|
+
}
|
|
493
|
+
return [...new Set(listed.stdout.split("\0"))]
|
|
494
|
+
.filter((rel) => {
|
|
495
|
+
if (!rel.endsWith(".md") || rel.split("/").some((part) => WALK_SKIP.has(part)))
|
|
496
|
+
return false;
|
|
497
|
+
for (let parent = path.dirname(rel); parent !== "."; parent = path.dirname(parent)) {
|
|
498
|
+
const dir = fs.lstatSync(path.join(cwd, parent), { throwIfNoEntry: false });
|
|
499
|
+
if (!dir?.isDirectory()) return false;
|
|
500
|
+
if (fs.lstatSync(path.join(cwd, parent, ".git"), { throwIfNoEntry: false })) return false;
|
|
501
|
+
}
|
|
502
|
+
const stat = fs.lstatSync(path.join(cwd, rel), { throwIfNoEntry: false });
|
|
503
|
+
return stat?.isFile() === true || stat?.isSymbolicLink() === true;
|
|
504
|
+
})
|
|
505
|
+
.sort();
|
|
506
|
+
}
|
|
459
507
|
const files = new Set<string>();
|
|
460
508
|
for (const given of globs) {
|
|
461
509
|
const glob = given.replace(/^\.\//, "");
|
|
@@ -513,7 +561,13 @@ function prose(ctx: RunContext): number {
|
|
|
513
561
|
"PROSE LINT UNAVAILABLE: vale is installed but .vale/styles/write-good could not be restored (main-worktree copy and vale sync both failed). Run: vale sync",
|
|
514
562
|
);
|
|
515
563
|
}
|
|
516
|
-
|
|
564
|
+
let files: string[];
|
|
565
|
+
try {
|
|
566
|
+
files = proseFiles(ctx.cwd, globs === DEFAULT_PROSE_GLOBS ? undefined : globs);
|
|
567
|
+
for (const rel of files) fs.accessSync(path.join(ctx.cwd, rel), fs.constants.R_OK);
|
|
568
|
+
} catch (error) {
|
|
569
|
+
return unavailable("source-unavailable", `PROSE LINT UNAVAILABLE: ${String(error)}`);
|
|
570
|
+
}
|
|
517
571
|
if (files.length === 0) {
|
|
518
572
|
return skip("no-files", `no files match ${globs.join(" ")} - nothing to lint`);
|
|
519
573
|
}
|
|
@@ -550,14 +604,14 @@ function skipToken(ctx: RunContext): number {
|
|
|
550
604
|
/**
|
|
551
605
|
* The min-push pathspecs: ship's `pr` bookkeeping allow-list for every month and feature
|
|
552
606
|
* (the same list `bkit ci bookkeeping-push` and the ship gate accept untested, including
|
|
553
|
-
* `bkit.testing.ciSkipPaths`), the plans tree bkit's workflows write, and whatever the repo
|
|
607
|
+
* `bkit.testing.ciSkipPaths`), the plans tree and audit reports bkit's workflows write, and whatever the repo
|
|
554
608
|
* adds in `bkit.testing.minPushPaths` (`:(glob)` unless an entry carries its own magic).
|
|
555
609
|
* The engine hardcodes no consumer file: the floor is what bkit itself writes.
|
|
556
610
|
*/
|
|
557
611
|
export function minPushPathspecs(cfg: Pick<BkitConfig, "minPushPaths" | "ciSkipPaths">): string[] {
|
|
558
612
|
return [
|
|
559
613
|
...bookPathspecs("*", "*", "pr", cfg.ciSkipPaths),
|
|
560
|
-
...globPathspecs(["docs/plans/**", ...cfg.minPushPaths]),
|
|
614
|
+
...globPathspecs(["docs/plans/**", "docs/audits/**", ...cfg.minPushPaths]),
|
|
561
615
|
];
|
|
562
616
|
}
|
|
563
617
|
|
|
@@ -571,6 +625,48 @@ export function pushBase(cwd: string, sha: string): string | null {
|
|
|
571
625
|
return null;
|
|
572
626
|
}
|
|
573
627
|
|
|
628
|
+
/** An audit template the project owns below its managed block; no other template qualifies. */
|
|
629
|
+
const AUDIT_TEMPLATE_RE = /^docs\/templates\/bkit-audit-[^/]+\.md$/;
|
|
630
|
+
|
|
631
|
+
export type MinPushOutside =
|
|
632
|
+
| { ok: true; changed: string[]; outside: string[]; sections: string[] }
|
|
633
|
+
| { ok: false; stderr: string };
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* `changedOutside` plus the audit-template exception: a top-level `docs/templates/bkit-audit-*.md`
|
|
637
|
+
* present at both commits whose text through the `bkit:end` line is identical at both (so only
|
|
638
|
+
* the project section below it changed) is moved from `outside` to `sections`.
|
|
639
|
+
*/
|
|
640
|
+
export function minPushOutside(
|
|
641
|
+
root: string,
|
|
642
|
+
from: string,
|
|
643
|
+
to: string,
|
|
644
|
+
paths: readonly string[],
|
|
645
|
+
): MinPushOutside {
|
|
646
|
+
const diff = changedOutside(root, from, to, paths);
|
|
647
|
+
if (!diff.ok) return diff;
|
|
648
|
+
const sections: string[] = [];
|
|
649
|
+
const outside: string[] = [];
|
|
650
|
+
const head = (sha: string, file: string): string | null => {
|
|
651
|
+
const res = gitRaw(root, ["cat-file", "blob", `${sha}:${file}`]);
|
|
652
|
+
return res.status === 0 ? managedHead(res.stdout) : null;
|
|
653
|
+
};
|
|
654
|
+
for (const file of diff.outside) {
|
|
655
|
+
if (AUDIT_TEMPLATE_RE.test(file)) {
|
|
656
|
+
const before = head(from, file);
|
|
657
|
+
if (before !== null && before === head(to, file)) {
|
|
658
|
+
sections.push(file);
|
|
659
|
+
continue;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
outside.push(file);
|
|
663
|
+
}
|
|
664
|
+
return { ok: true, changed: diff.changed, outside, sections };
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
const sectionNote = (file: string) =>
|
|
668
|
+
`${file}: only its project section below <!-- bkit:end --> changed`;
|
|
669
|
+
|
|
574
670
|
function minPush(ctx: RunContext): number {
|
|
575
671
|
const top = runGit(ctx.cwd, ["rev-parse", "--show-toplevel"]);
|
|
576
672
|
if (!top.ok) throw new CommandError(EXIT.USAGE, `not inside a git repository: ${ctx.cwd}`);
|
|
@@ -588,10 +684,11 @@ function minPush(ctx: RunContext): number {
|
|
|
588
684
|
|
|
589
685
|
const changed = new Set<string>();
|
|
590
686
|
const outside = new Set<string>();
|
|
687
|
+
const sections = new Set<string>();
|
|
591
688
|
for (const ref of refs) {
|
|
592
689
|
const sha = git(ctx.cwd, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`]);
|
|
593
690
|
const base = sha ? (baseFlag ?? pushBase(ctx.cwd, sha)) : null;
|
|
594
|
-
const diff = sha && base ?
|
|
691
|
+
const diff = sha && base ? minPushOutside(top.stdout, base, sha, paths) : null;
|
|
595
692
|
if (!diff?.ok) {
|
|
596
693
|
const why = !sha
|
|
597
694
|
? `cannot read commit '${ref}'`
|
|
@@ -604,7 +701,9 @@ function minPush(ctx: RunContext): number {
|
|
|
604
701
|
}
|
|
605
702
|
for (const p of diff.changed) changed.add(p);
|
|
606
703
|
for (const p of diff.outside) outside.add(p);
|
|
704
|
+
for (const p of diff.sections) sections.add(p);
|
|
607
705
|
}
|
|
706
|
+
for (const p of [...sections].sort()) ctx.log(sectionNote(p));
|
|
608
707
|
|
|
609
708
|
const result = (reason: string | null, code: number, message: string) => {
|
|
610
709
|
ctx.log(message);
|
|
@@ -634,6 +733,7 @@ function minPush(ctx: RunContext): number {
|
|
|
634
733
|
function minPushUpdates(ctx: RunContext, cwd: string, updates: string[], paths: string[]): number {
|
|
635
734
|
const changed = new Set<string>();
|
|
636
735
|
const outside = new Set<string>();
|
|
736
|
+
const sections = new Set<string>();
|
|
637
737
|
let unknown = false;
|
|
638
738
|
let failed = false;
|
|
639
739
|
for (const update of updates) {
|
|
@@ -647,17 +747,19 @@ function minPushUpdates(ctx: RunContext, cwd: string, updates: string[], paths:
|
|
|
647
747
|
unknown = true;
|
|
648
748
|
continue;
|
|
649
749
|
}
|
|
650
|
-
const increment = isNew ? null :
|
|
750
|
+
const increment = isNew ? null : minPushOutside(cwd, oldSha, newSha, paths);
|
|
651
751
|
const base = pushBase(cwd, newSha);
|
|
652
|
-
const whole = base ?
|
|
653
|
-
if (hasVerifiedIncrement(cwd, oldSha, newSha, paths)) {
|
|
752
|
+
const whole = base ? minPushOutside(cwd, base, newSha, paths) : null;
|
|
753
|
+
if (hasVerifiedIncrement(cwd, oldSha, newSha, (a, b) => minPushOutside(cwd, a, b, paths))) {
|
|
654
754
|
if (increment?.ok) for (const file of increment.changed) changed.add(file);
|
|
755
|
+
if (increment?.ok) for (const file of increment.sections) sections.add(file);
|
|
655
756
|
ctx.log(`${oldSha}..${newSha}: covered by a successful full push gate`);
|
|
656
757
|
continue;
|
|
657
758
|
}
|
|
658
759
|
if (whole?.ok) {
|
|
659
760
|
for (const file of whole.changed) changed.add(file);
|
|
660
761
|
for (const file of whole.outside) outside.add(file);
|
|
762
|
+
for (const file of whole.sections) sections.add(file);
|
|
661
763
|
if (
|
|
662
764
|
whole.changed.length > 0 &&
|
|
663
765
|
whole.outside.length === 0 &&
|
|
@@ -667,6 +769,7 @@ function minPushUpdates(ctx: RunContext, cwd: string, updates: string[], paths:
|
|
|
667
769
|
} else unknown = true;
|
|
668
770
|
failed = true;
|
|
669
771
|
}
|
|
772
|
+
for (const file of [...sections].sort()) ctx.log(sectionNote(file));
|
|
670
773
|
const reason = !failed ? null : unknown ? "unknown" : outside.size ? "outside" : "no-changes";
|
|
671
774
|
ctx.emit({
|
|
672
775
|
minPush: !failed,
|
|
@@ -787,7 +890,7 @@ export const ciCommand: CommandSpec = {
|
|
|
787
890
|
},
|
|
788
891
|
prose: {
|
|
789
892
|
summary:
|
|
790
|
-
"Run Vale over
|
|
893
|
+
"Run Vale over tracked and unignored Markdown, or explicit globs; fail when sources, Vale or required styles are unavailable.",
|
|
791
894
|
use: "by-hand",
|
|
792
895
|
flags: [
|
|
793
896
|
{
|
|
@@ -838,12 +941,14 @@ export const ciCommand: CommandSpec = {
|
|
|
838
941
|
},
|
|
839
942
|
],
|
|
840
943
|
output: {
|
|
841
|
-
minPush:
|
|
944
|
+
minPush:
|
|
945
|
+
"true when every changed file matches a min-push path, or is a docs/templates/bkit-audit-*.md changed only below its <!-- bkit:end -->",
|
|
842
946
|
reason: "null when a min push; else no-changes | outside | unknown",
|
|
843
947
|
changed: "files the push changes, across every ref",
|
|
844
|
-
outside:
|
|
948
|
+
outside:
|
|
949
|
+
"the changed files no min-push path matches (an audit template changed only below its <!-- bkit:end --> is not listed)",
|
|
845
950
|
paths:
|
|
846
|
-
"the min-push pathspecs in force: ship's pr bookkeeping allow-list (with bkit.testing.ciSkipPaths), docs/plans/**, bkit.testing.minPushPaths",
|
|
951
|
+
"the min-push pathspecs in force: ship's pr bookkeeping allow-list (with bkit.testing.ciSkipPaths), docs/plans/**, docs/audits/**, bkit.testing.minPushPaths",
|
|
847
952
|
},
|
|
848
953
|
exitCodes: {
|
|
849
954
|
[EXIT_RANGE_UNKNOWN]: "a pushed commit, its base, or its git diff could not be read",
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
// Local full-gate receipts, shared by linked worktrees and bound to committed trees.
|
|
2
|
-
import { spawnSync } from "node:child_process";
|
|
3
2
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
3
|
import * as fs from "node:fs";
|
|
5
|
-
import * as os from "node:os";
|
|
6
4
|
import * as path from "node:path";
|
|
7
5
|
import { gitEnv } from "../../ledgers/telemetry.js";
|
|
8
6
|
import { parseJson, readJsonFile } from "../../shared/json.js";
|
|
9
7
|
import { readPackageJson } from "../../shared/package-json.js";
|
|
10
|
-
import { scriptCommand
|
|
11
|
-
import { EXIT, git, outboxRoot, runGit } from "../lib.js";
|
|
12
|
-
import {
|
|
8
|
+
import { scriptCommand } from "../../shared/package-manager.js";
|
|
9
|
+
import { EXIT, git, LOCK_STATUS_FILE_ENV, outboxRoot, runGit } from "../lib.js";
|
|
10
|
+
import { pidAlive } from "../workflow/disk.js";
|
|
11
|
+
import { type LockedRun, runGateUnderLock } from "../workflow/junit.js";
|
|
13
12
|
|
|
14
13
|
const UNIT = "bkit:gate:static-unit";
|
|
15
14
|
const INTEGRATION = "bkit:gate:static-unit-integration";
|
|
@@ -44,29 +43,58 @@ const receiptPath = (cwd: string, sha: string): string | null => {
|
|
|
44
43
|
return outbox ? path.join(outbox, "push-gates", `${sha}.json`) : null;
|
|
45
44
|
};
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
const STATUS = [
|
|
47
|
+
"status",
|
|
48
|
+
"--porcelain",
|
|
49
|
+
"--no-renames",
|
|
50
|
+
"--untracked-files=all",
|
|
51
|
+
"--ignore-submodules=none",
|
|
52
|
+
];
|
|
53
|
+
const lineCount = (text: string | null): number =>
|
|
54
|
+
text === null ? -1 : text === "" ? 0 : text.split("\n").length;
|
|
55
|
+
|
|
56
|
+
/** HEAD when every uncommitted path lies inside `tolerated` (none given: the tree must be clean). */
|
|
57
|
+
function cleanHead(
|
|
58
|
+
cwd: string,
|
|
59
|
+
tolerated: readonly string[] = [],
|
|
60
|
+
): { sha: string; tree: string } | null {
|
|
61
|
+
const all = lineCount(git(cwd, STATUS));
|
|
62
|
+
if (all < 0) return null;
|
|
63
|
+
if (all > 0) {
|
|
64
|
+
if (tolerated.length === 0) return null;
|
|
65
|
+
if (lineCount(git(cwd, [...STATUS, "--", ...tolerated])) !== all) return null;
|
|
66
|
+
}
|
|
55
67
|
const sha = git(cwd, ["rev-parse", "--verify", "HEAD^{commit}"]);
|
|
56
68
|
const tree = git(cwd, ["rev-parse", "--verify", "HEAD^{tree}"]);
|
|
57
69
|
return sha && tree ? { sha, tree } : null;
|
|
58
70
|
}
|
|
59
71
|
|
|
60
|
-
/**
|
|
61
|
-
|
|
72
|
+
/** The recorded runner's process id of a `.running` attempt file; null when unreadable. */
|
|
73
|
+
function attemptPid(file: string): number | null {
|
|
74
|
+
const read = readJsonFile(file);
|
|
75
|
+
if (!read.ok || !read.value || typeof read.value !== "object") return null;
|
|
76
|
+
const pid = (read.value as Record<string, unknown>).pid;
|
|
77
|
+
return typeof pid === "number" && Number.isInteger(pid) && pid > 0 ? pid : null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Run a gate through `run` and record its receipt: the `.running` marker while it runs, a
|
|
82
|
+
* `.failed` marker when it fails, the before/after HEAD and fingerprint check, and the
|
|
83
|
+
* receipt write. An attempt on the same commit whose runner process is gone counts as a
|
|
84
|
+
* failed run and is cleared. Uncommitted paths in `tolerated` do not block the receipt; a
|
|
85
|
+
* lock wait (`waited`, default never) leaves the receipt and markers as they were.
|
|
86
|
+
*/
|
|
87
|
+
export function runWithReceipt(
|
|
88
|
+
cwd: string,
|
|
89
|
+
gate: string,
|
|
90
|
+
tolerated: readonly string[],
|
|
91
|
+
run: () => number,
|
|
92
|
+
log: (message: string) => void,
|
|
93
|
+
waited: (status: number) => boolean = () => false,
|
|
94
|
+
): number {
|
|
62
95
|
const pkg = readPackageJson(cwd);
|
|
63
|
-
const script = pkg.ok ? scriptsOf(pkg.pkg)?.[gate] : null;
|
|
64
|
-
if (typeof script !== "string" || script.trim() === "") {
|
|
65
|
-
log(`package.json must declare a non-empty ${gate} script`);
|
|
66
|
-
return EXIT.USAGE;
|
|
67
|
-
}
|
|
68
96
|
const definition = pkg.ok ? gateDefinition(pkg.pkg) : null;
|
|
69
|
-
const before = cleanHead(cwd);
|
|
97
|
+
const before = cleanHead(cwd, tolerated);
|
|
70
98
|
const head = git(cwd, ["rev-parse", "--verify", "HEAD^{commit}"]);
|
|
71
99
|
const file = head ? receiptPath(cwd, head) : null;
|
|
72
100
|
const attempt =
|
|
@@ -81,31 +109,27 @@ export function runPushGate(cwd: string, gate: string, log: (message: string) =>
|
|
|
81
109
|
fs.rmSync(file, { force: true });
|
|
82
110
|
};
|
|
83
111
|
if (attempt) {
|
|
84
|
-
|
|
112
|
+
const dir = path.dirname(attempt);
|
|
113
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
114
|
+
for (const entry of fs.readdirSync(dir)) {
|
|
115
|
+
const pid = attemptPid(path.join(dir, entry));
|
|
116
|
+
if (pid === null || pidAlive(pid)) continue;
|
|
117
|
+
fs.rmSync(path.join(dir, entry), { force: true });
|
|
118
|
+
fail();
|
|
119
|
+
}
|
|
85
120
|
fs.writeFileSync(attempt, JSON.stringify({ pid: process.pid, sha: head }) + "\n");
|
|
86
|
-
fail();
|
|
87
121
|
}
|
|
88
122
|
const finish = (code: number) => {
|
|
89
123
|
if (attempt) fs.rmSync(attempt, { force: true });
|
|
90
124
|
return code;
|
|
91
125
|
};
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
const result = spawnSync(argv[0]!, argv.slice(1), {
|
|
95
|
-
cwd,
|
|
96
|
-
env: gitEnv(),
|
|
97
|
-
stdio: ["ignore", 2, 2],
|
|
98
|
-
});
|
|
99
|
-
const status = result.error
|
|
100
|
-
? 127
|
|
101
|
-
: (result.status ??
|
|
102
|
-
128 + ((result.signal ? os.constants.signals[result.signal] : undefined) ?? 1));
|
|
103
|
-
if (result.error) log(result.error.message);
|
|
126
|
+
const status = run();
|
|
127
|
+
if (waited(status)) return finish(status);
|
|
104
128
|
if (status !== 0 || !before || definition?.gate !== gate) {
|
|
105
129
|
fail();
|
|
106
130
|
return finish(status);
|
|
107
131
|
}
|
|
108
|
-
const after = cleanHead(cwd);
|
|
132
|
+
const after = cleanHead(cwd, tolerated);
|
|
109
133
|
const afterPkg = readPackageJson(cwd);
|
|
110
134
|
if (
|
|
111
135
|
after?.sha !== before.sha ||
|
|
@@ -129,6 +153,40 @@ export function runPushGate(cwd: string, gate: string, log: (message: string) =>
|
|
|
129
153
|
return finish(status);
|
|
130
154
|
}
|
|
131
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Execute a consumer gate; only a successful deepest full gate on an unchanged clean tree earns
|
|
158
|
+
* proof. A tests-lock wait (the lock wrapper gave up, exit 75) leaves the receipt and its
|
|
159
|
+
* markers as they were, and its status file is handed on to a caller that asked for one.
|
|
160
|
+
*/
|
|
161
|
+
export function runPushGate(cwd: string, gate: string, log: (message: string) => void): number {
|
|
162
|
+
const pkg = readPackageJson(cwd);
|
|
163
|
+
const script = pkg.ok ? scriptsOf(pkg.pkg)?.[gate] : null;
|
|
164
|
+
if (typeof script !== "string" || script.trim() === "") {
|
|
165
|
+
log(`package.json must declare a non-empty ${gate} script`);
|
|
166
|
+
return EXIT.USAGE;
|
|
167
|
+
}
|
|
168
|
+
const env = gitEnv();
|
|
169
|
+
const lock: { run?: LockedRun } = {};
|
|
170
|
+
return runWithReceipt(
|
|
171
|
+
cwd,
|
|
172
|
+
gate,
|
|
173
|
+
[],
|
|
174
|
+
() => {
|
|
175
|
+
log(`running ${scriptCommand(gate).join(" ")}`);
|
|
176
|
+
lock.run = runGateUnderLock(
|
|
177
|
+
scriptCommand(gate),
|
|
178
|
+
cwd,
|
|
179
|
+
2,
|
|
180
|
+
{ LOCAL_STACK_LOCK_WHO: env.LOCAL_STACK_LOCK_WHO || `bkit ci push-gate ${gate}` },
|
|
181
|
+
{ base: env, forwardStatusTo: env[LOCK_STATUS_FILE_ENV] },
|
|
182
|
+
);
|
|
183
|
+
return lock.run.exitCode;
|
|
184
|
+
},
|
|
185
|
+
log,
|
|
186
|
+
() => lock.run?.lock === "lock-wait",
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
132
190
|
/** Pending files survive interrupted runners; one read suffices to block earlier proof. */
|
|
133
191
|
function pendingAttempt(file: string): boolean {
|
|
134
192
|
const dir = `${file}.running`;
|
|
@@ -189,13 +247,13 @@ export function hasVerifiedIncrement(
|
|
|
189
247
|
cwd: string,
|
|
190
248
|
oldSha: string,
|
|
191
249
|
newSha: string,
|
|
192
|
-
|
|
250
|
+
outsideOf: (from: string, to: string) => { ok: true; outside: string[] } | { ok: false },
|
|
193
251
|
): boolean {
|
|
252
|
+
const isNew = /^0+$/.test(oldSha);
|
|
194
253
|
if (
|
|
195
|
-
!SHA.test(oldSha) ||
|
|
254
|
+
(!isNew && !SHA.test(oldSha)) ||
|
|
196
255
|
!SHA.test(newSha) ||
|
|
197
|
-
|
|
198
|
-
!runGit(cwd, ["merge-base", "--is-ancestor", oldSha, newSha]).ok
|
|
256
|
+
(!isNew && !runGit(cwd, ["merge-base", "--is-ancestor", oldSha, newSha]).ok)
|
|
199
257
|
)
|
|
200
258
|
return false;
|
|
201
259
|
const raw = git(cwd, ["show", `${newSha}:package.json`]);
|
|
@@ -208,14 +266,14 @@ export function hasVerifiedIncrement(
|
|
|
208
266
|
gateDefinition(localPkg.pkg)?.fingerprint !== definition.fingerprint
|
|
209
267
|
)
|
|
210
268
|
return false;
|
|
211
|
-
const ancestors = git(cwd, ["rev-list", "--max-count=128", oldSha]);
|
|
212
|
-
const firstFile = receiptPath(cwd,
|
|
269
|
+
const ancestors = git(cwd, ["rev-list", "--max-count=128", isNew ? newSha : oldSha]);
|
|
270
|
+
const firstFile = receiptPath(cwd, newSha);
|
|
213
271
|
if (!ancestors || !firstFile) return false;
|
|
214
272
|
const dir = path.dirname(firstFile);
|
|
215
273
|
for (const sha of ancestors.split("\n")) {
|
|
216
274
|
const file = path.join(dir, `${sha}.json`);
|
|
217
275
|
if (!validReceipt(cwd, file, sha, definition)) continue;
|
|
218
|
-
const diff =
|
|
276
|
+
const diff = outsideOf(sha, newSha);
|
|
219
277
|
if (diff.ok && diff.outside.length === 0 && noLaterFailure(cwd, dir, sha, newSha, definition))
|
|
220
278
|
return true;
|
|
221
279
|
}
|
|
@@ -90,7 +90,7 @@ export function runStatus(cwd: string, logPrefix: string): void {
|
|
|
90
90
|
|
|
91
91
|
// --- opencode host ---
|
|
92
92
|
const opencodeDir = path.join(cwd, ".opencode");
|
|
93
|
-
const opencodePresent =
|
|
93
|
+
const opencodePresent = detectInstalledHostModules(cwd).has("opencode");
|
|
94
94
|
// Resolve active provider (manifest-first; covers managed-auth gateways like opencode).
|
|
95
95
|
const activeOpencodeProvider = detectOpencodeProvider(cwd);
|
|
96
96
|
// All installed providers.
|
|
@@ -174,13 +174,14 @@ export async function runDoctor(
|
|
|
174
174
|
// Broken install: the opencode host is on disk but neither provider signal survives.
|
|
175
175
|
// `bkit check` and `bkit upgrade` exit 1 with the fix; doctor reports it here and does
|
|
176
176
|
// not enforce.
|
|
177
|
-
|
|
177
|
+
const opencodePresent = detectInstalledHostModules(process.cwd()).has("opencode");
|
|
178
|
+
if (opencodePresent) {
|
|
178
179
|
if (detectOpencodeProvider(process.cwd()) === null) {
|
|
179
180
|
allFindings.push({
|
|
180
181
|
id: "opencode-provider-missing",
|
|
181
182
|
severity: "blocker",
|
|
182
183
|
detect:
|
|
183
|
-
"`.opencode/` is present but no provider is recorded — neither package.json `bkit.providers.opencode.default` nor an `opencode.json` provider block.",
|
|
184
|
+
"`.opencode/agents/` is present but no provider is recorded — neither package.json `bkit.providers.opencode.default` nor an `opencode.json` provider block.",
|
|
184
185
|
action: `Re-run \`bkit install --opencode=<provider>\` (${OPENCODE_PROVIDERS.join(", ")}). Until then \`bkit check\` and \`bkit upgrade\` exit 1 rather than render every agent pin against a substitute provider.`,
|
|
185
186
|
});
|
|
186
187
|
}
|
|
@@ -205,8 +206,7 @@ export async function runDoctor(
|
|
|
205
206
|
|
|
206
207
|
// opencode host diagnostics: report required tools and cred presence per provider.
|
|
207
208
|
// Never echoes key values — only reports present/absent.
|
|
208
|
-
|
|
209
|
-
if (fs.existsSync(opencodeDir) || modules.has("opencode")) {
|
|
209
|
+
if (opencodePresent || modules.has("opencode")) {
|
|
210
210
|
console.log(`${LOG_PREFIX} --- opencode host diagnostics ---`);
|
|
211
211
|
// Check opencode binary
|
|
212
212
|
const { spawnSync: spawnSyncLocal } = await import("node:child_process");
|
|
@@ -7,11 +7,7 @@ import { OPENCODE_PROVIDERS } from "../../shared/egress.js";
|
|
|
7
7
|
import { type ModuleFlag, type CloudVariant } from "../../cli.js";
|
|
8
8
|
import { readInstallingVersion } from "../../shared/package-json.js";
|
|
9
9
|
import { type ModuleContext, dispatchModules } from "../../install/modules/index.js";
|
|
10
|
-
import {
|
|
11
|
-
type IssueTracker,
|
|
12
|
-
DEFAULT_ISSUE_TRACKER,
|
|
13
|
-
type ModuleName,
|
|
14
|
-
} from "../../install/manifest.js";
|
|
10
|
+
import { type IssueTracker, type ModuleName } from "../../install/manifest.js";
|
|
15
11
|
import { parseJson, readJsonFile } from "../../shared/json.js";
|
|
16
12
|
import { readBkitConfig } from "../../shared/settings.js";
|
|
17
13
|
import { LOG_PREFIX, setLogPrefix } from "../../shared/log-prefix.js";
|
|
@@ -28,6 +24,7 @@ import type { SuppressionNote } from "../../checks/after/suppression.js";
|
|
|
28
24
|
import { collectTips } from "../../checks/tips/index.js";
|
|
29
25
|
import { findMissingOwnedHooks, detectOwnedHookMissing } from "../../checks/after/managed.js";
|
|
30
26
|
import { resolveTokens } from "../../install/placeholders.js";
|
|
27
|
+
import { syncProjectDocs } from "../../install/project-docs.js";
|
|
31
28
|
import {
|
|
32
29
|
type EffortMap,
|
|
33
30
|
parseModelLookup,
|
|
@@ -113,27 +110,18 @@ export function modulesToCliFlags(
|
|
|
113
110
|
}
|
|
114
111
|
|
|
115
112
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* cloud=cursor requires tracker=linear. Mismatch is a hard error — checked BEFORE
|
|
119
|
-
* any package.json write so no state is recorded on mismatch ("no files written
|
|
120
|
-
* on hard error" invariant). Returns the error message to print, or `null` when
|
|
121
|
-
* the tracker matches (or no cloud module/variant is in play).
|
|
113
|
+
* Cloud automation needs a wired tracker. Returns the pre-write error message,
|
|
114
|
+
* or null when a tracker is wired or no cloud module/variant is being installed.
|
|
122
115
|
*/
|
|
123
|
-
export function
|
|
116
|
+
export function validateCloudTrackerWired(
|
|
124
117
|
cloudVariant: CloudVariant | null,
|
|
125
118
|
hasCloudModule: boolean,
|
|
126
119
|
issueTracker: IssueTracker,
|
|
127
120
|
): string | null {
|
|
128
|
-
if (cloudVariant === null || !hasCloudModule) return null;
|
|
129
|
-
const requiredTracker: IssueTracker = cloudVariant === "cursor" ? "linear" : "github";
|
|
130
|
-
if (issueTracker === requiredTracker) return null;
|
|
121
|
+
if (cloudVariant === null || !hasCloudModule || issueTracker !== "none") return null;
|
|
131
122
|
return (
|
|
132
|
-
`[bkit] --auto=${cloudVariant}
|
|
133
|
-
`
|
|
134
|
-
(issueTracker === DEFAULT_ISSUE_TRACKER || issueTracker === "none"
|
|
135
|
-
? `Set the tracker first: bkit install --tracker=${requiredTracker} --auto=${cloudVariant}`
|
|
136
|
-
: `Re-run with the matching tracker: bkit install --tracker=${requiredTracker} --auto=${cloudVariant} (tracker switching is free).`)
|
|
123
|
+
`[bkit] --auto=${cloudVariant} needs a wired tracker: ` +
|
|
124
|
+
`bkit install --tracker=<github|linear|jira> --auto=${cloudVariant}`
|
|
137
125
|
);
|
|
138
126
|
}
|
|
139
127
|
|
|
@@ -387,10 +375,8 @@ export async function runInstall(
|
|
|
387
375
|
|
|
388
376
|
const postDispatch: Array<() => void> = [];
|
|
389
377
|
|
|
390
|
-
//
|
|
391
|
-
|
|
392
|
-
// package.json write so no state is recorded on mismatch.
|
|
393
|
-
const cloudTrackerError = validateCloudTrackerMatch(
|
|
378
|
+
// Reject missing tracker wiring before any package.json write.
|
|
379
|
+
const cloudTrackerError = validateCloudTrackerWired(
|
|
394
380
|
cloudVariant,
|
|
395
381
|
modules.has("cloud"),
|
|
396
382
|
issueTracker,
|
|
@@ -402,7 +388,11 @@ export async function runInstall(
|
|
|
402
388
|
if (cloudVariant !== null && modules.has("cloud")) {
|
|
403
389
|
// auto=opencode additionally requires the local opencode host to be installed first
|
|
404
390
|
// (the cloud job runs against the committed .opencode/ — no model is hard-coded in YAML).
|
|
405
|
-
if (
|
|
391
|
+
if (
|
|
392
|
+
cloudVariant === "opencode" &&
|
|
393
|
+
!modules.has("opencode") &&
|
|
394
|
+
!fs.existsSync(path.join(process.cwd(), ".opencode"))
|
|
395
|
+
) {
|
|
406
396
|
console.error(
|
|
407
397
|
`[bkit] --auto=opencode requires the local opencode host to be installed first.\n` +
|
|
408
398
|
`Run: bkit install --opencode=<provider> (e.g. --opencode=opencode-zen)\n` +
|
|
@@ -410,6 +400,14 @@ export async function runInstall(
|
|
|
410
400
|
);
|
|
411
401
|
process.exit(1);
|
|
412
402
|
}
|
|
403
|
+
if (
|
|
404
|
+
cloudVariant === "codex" &&
|
|
405
|
+
!modules.has("codex") &&
|
|
406
|
+
!fs.existsSync(path.join(process.cwd(), ".codex"))
|
|
407
|
+
) {
|
|
408
|
+
console.error(`[bkit] --auto=codex requires the local Codex host. Run: bkit install --codex`);
|
|
409
|
+
process.exit(1);
|
|
410
|
+
}
|
|
413
411
|
}
|
|
414
412
|
|
|
415
413
|
// Persist bkit manifest fields to consumer package.json AFTER all hard-error gates pass.
|
|
@@ -515,6 +513,11 @@ export async function runInstall(
|
|
|
515
513
|
discardAllStaging();
|
|
516
514
|
}
|
|
517
515
|
|
|
516
|
+
// The ten project documents belong to the project: drop a legacy ownership wrapper and list
|
|
517
|
+
// each present document in `Project Documents`. Runs after the managed index is rendered and
|
|
518
|
+
// before the advisories read the result. `check` is read-only, so it never gets here.
|
|
519
|
+
if (!dryRun) syncProjectDocs(process.cwd(), { dryRun: false });
|
|
520
|
+
|
|
518
521
|
const totalWrites = ws.writes.length;
|
|
519
522
|
|
|
520
523
|
// Done banner first so the line count is easy to find above the checklist.
|