@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
|
@@ -118,11 +118,17 @@ const LINT_STAGED_CONFIGS = [
|
|
|
118
118
|
".lintstagedrc.yaml",
|
|
119
119
|
".lintstagedrc.yml",
|
|
120
120
|
".lintstagedrc.mjs",
|
|
121
|
-
".lintstagedrc.
|
|
121
|
+
".lintstagedrc.mts",
|
|
122
122
|
".lintstagedrc.js",
|
|
123
|
+
".lintstagedrc.ts",
|
|
124
|
+
".lintstagedrc.cjs",
|
|
125
|
+
".lintstagedrc.cts",
|
|
123
126
|
"lint-staged.config.mjs",
|
|
124
|
-
"lint-staged.config.
|
|
127
|
+
"lint-staged.config.mts",
|
|
125
128
|
"lint-staged.config.js",
|
|
129
|
+
"lint-staged.config.ts",
|
|
130
|
+
"lint-staged.config.cjs",
|
|
131
|
+
"lint-staged.config.cts",
|
|
126
132
|
];
|
|
127
133
|
/** True when any `.github/workflows/*.yml` / `*.yaml` contains `needle`. */
|
|
128
134
|
export function anyWorkflowMentions(cwd, needle) {
|
|
@@ -134,10 +140,12 @@ export function anyWorkflowMentions(cwd, needle) {
|
|
|
134
140
|
.filter((f) => f.endsWith(".yml") || f.endsWith(".yaml"))
|
|
135
141
|
.some((f) => readText(cwd, path.join(".github", "workflows", f)).includes(needle));
|
|
136
142
|
}
|
|
137
|
-
/** True when lint-staged is configured: any of its config files, or `package.
|
|
143
|
+
/** True when lint-staged is configured: any of its config files, `package.json` or `package.yaml` / `package.yml` `lint-staged` key. */
|
|
138
144
|
export function hasLintStagedConfig(cwd) {
|
|
139
145
|
if (LINT_STAGED_CONFIGS.some((rel) => exists(cwd, rel)))
|
|
140
146
|
return true;
|
|
147
|
+
if (["package.yaml", "package.yml"].some((rel) => /^lint-staged\s*:/m.test(readText(cwd, rel))))
|
|
148
|
+
return true;
|
|
141
149
|
const pkg = readPackageJson(cwd);
|
|
142
150
|
return pkg.ok && pkg.pkg["lint-staged"] !== undefined;
|
|
143
151
|
}
|
|
@@ -202,6 +210,30 @@ export function readsBkitText(cwd) {
|
|
|
202
210
|
return text.split("\n").some((line) => READS_BKIT_TEXT.some((re) => re.test(line)));
|
|
203
211
|
});
|
|
204
212
|
}
|
|
213
|
+
/** `.agents/rules.md` below `<!-- bkit:end -->` with HTML comments removed; null without the file. */
|
|
214
|
+
function rulesBelowEnd(cwd) {
|
|
215
|
+
const text = readText(cwd, ".agents/rules.md");
|
|
216
|
+
if (!text)
|
|
217
|
+
return null;
|
|
218
|
+
const end = text.indexOf("<!-- bkit:end -->");
|
|
219
|
+
return (end === -1 ? text : text.slice(end)).replace(/<!--[\s\S]*?-->/g, "");
|
|
220
|
+
}
|
|
221
|
+
/** True when the rules file already has a `## Project Goals` heading below `<!-- bkit:end -->`. */
|
|
222
|
+
export function hasProjectGoalsHeading(cwd) {
|
|
223
|
+
return /^## Project Goals/m.test(rulesBelowEnd(cwd) ?? "");
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* True when `.agents/rules.md` exists and no `## Project Goals` section, read below
|
|
227
|
+
* `<!-- bkit:end -->`, holds a list item (`-`, `*`, `+` or `1.` / `1)`) once HTML comments
|
|
228
|
+
* are removed.
|
|
229
|
+
*/
|
|
230
|
+
export function hasNoProjectGoals(cwd) {
|
|
231
|
+
const below = rulesBelowEnd(cwd);
|
|
232
|
+
if (below === null)
|
|
233
|
+
return false;
|
|
234
|
+
const sections = [...below.matchAll(/^## Project Goals[^\n]*\n([\s\S]*?)(?=^## |(?![\s\S]))/gm)];
|
|
235
|
+
return !sections.some((m) => /^\s*(?:[-*+]|\d+[.)])\s/m.test(m[1] ?? ""));
|
|
236
|
+
}
|
|
205
237
|
/**
|
|
206
238
|
* True when `.bkit/friction.jsonl` holds an entry worth sending to bkit: its fold winner
|
|
207
239
|
* is `OPEN` (or has no status) and its `scope` is not `consumer`. A shared entry gets a
|
|
@@ -94,7 +94,7 @@ export function collectTips(cwd, catalogue = SETUP_TIPS) {
|
|
|
94
94
|
if (isTipSilenced(tip, ignored))
|
|
95
95
|
suppressed.push({ id: tip.id, scope: "." });
|
|
96
96
|
else
|
|
97
|
-
tips.push(tip);
|
|
97
|
+
tips.push(tip.resolve ? { ...tip, ...tip.resolve(base) } : tip);
|
|
98
98
|
}
|
|
99
99
|
const star = !ignored.has(STAR_TIP_ID) && !ignored.has(STAR_TIP_OLD_ID);
|
|
100
100
|
return { tips, suppressed, star };
|
package/dist/cli.js
CHANGED
|
@@ -19,7 +19,7 @@ import { runInstall } from "./commands/install/install.js";
|
|
|
19
19
|
import { OPTIN_MODULES } from "./install/manifest.js";
|
|
20
20
|
import { OPENCODE_PROVIDERS } from "./shared/egress.js";
|
|
21
21
|
/** Cloud-agent variant chosen via `--auto=<variant>`. */
|
|
22
|
-
export const CLOUD_VARIANTS = ["claude", "cursor", "opencode"];
|
|
22
|
+
export const CLOUD_VARIANTS = ["claude", "cursor", "opencode", "codex"];
|
|
23
23
|
/** Narrow an unknown string to `CloudVariant` or return `null` if invalid. */
|
|
24
24
|
export function parseCloudVariant(value) {
|
|
25
25
|
return typeof value === "string" && CLOUD_VARIANTS.includes(value)
|
|
@@ -424,7 +424,7 @@ export const CLASSIC_VERB_HELP = [
|
|
|
424
424
|
"--antigravity",
|
|
425
425
|
"--cursor",
|
|
426
426
|
"--opencode=<provider>",
|
|
427
|
-
"--auto=<claude|cursor|opencode>",
|
|
427
|
+
"--auto=<claude|cursor|opencode|codex>",
|
|
428
428
|
"--tracker=<name>",
|
|
429
429
|
"--auto-revert",
|
|
430
430
|
],
|
|
@@ -480,7 +480,7 @@ export const CLASSIC_VERB_HELP = [
|
|
|
480
480
|
"--antigravity",
|
|
481
481
|
"--cursor",
|
|
482
482
|
"--opencode=<provider>",
|
|
483
|
-
"--auto=<claude|cursor|opencode>",
|
|
483
|
+
"--auto=<claude|cursor|opencode|codex>",
|
|
484
484
|
"--dry-run",
|
|
485
485
|
"--force",
|
|
486
486
|
"--nuke",
|
|
@@ -658,7 +658,7 @@ Module flags (composable; symmetric install ↔ uninstall):
|
|
|
658
658
|
opencode-zen, opencode-go (opencode-native gateways;
|
|
659
659
|
auth via BKIT_OPENCODE_API_KEY).
|
|
660
660
|
Ships .opencode/** (agents, commands, opencode.json, bkit-gateguard.js,
|
|
661
|
-
bkit-readguard.js).
|
|
661
|
+
bkit-readguard.js, bkit-guardrails.js).
|
|
662
662
|
Configure your provider key; verify with \`bkit doctor\`. All installed
|
|
663
663
|
providers tracked in bkit.providers.opencode.installed.
|
|
664
664
|
--codex Codex CLI host. BARE flag — takes no value: Codex runs on one gateway
|
|
@@ -682,14 +682,14 @@ Dependency updaters (copy an example and own it):
|
|
|
682
682
|
blocks when that value and the configs disagree.
|
|
683
683
|
All templates and install steps: .bkit/templates.md
|
|
684
684
|
|
|
685
|
-
--auto=<claude|cursor|opencode>
|
|
686
|
-
Cloud-agent (auto-dispatch) integration (opt-in).
|
|
687
|
-
tracker
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
needs
|
|
691
|
-
|
|
692
|
-
uninstall only.
|
|
685
|
+
--auto=<claude|cursor|opencode|codex>
|
|
686
|
+
Cloud-agent (auto-dispatch) integration (opt-in). Every variant needs
|
|
687
|
+
a wired tracker (github, linear or jira). Claude needs the
|
|
688
|
+
BKIT_ANTHROPIC_API_KEY repo secret or the ANTHROPIC_FEDERATION_RULE_ID
|
|
689
|
+
+ ANTHROPIC_ORGANIZATION_ID repo variables, plus the Claude GitHub App.
|
|
690
|
+
Codex needs --codex and BKIT_OPENAI_API_KEY. OpenCode needs --opencode
|
|
691
|
+
and its configured provider's BKIT_ key. Cursor uses its dashboard
|
|
692
|
+
triggers. Bare --auto is accepted on uninstall only.
|
|
693
693
|
|
|
694
694
|
Cross-cutting / modifiers:
|
|
695
695
|
--tracker=<name> Wire issue tracker integration. Values: github, linear, jira, none
|
|
@@ -786,7 +786,7 @@ export function validateModuleFlagsForVerb(verb, moduleFlags, tracker = null) {
|
|
|
786
786
|
// The CLI entrypoint, run only when this file is executed and driven by real
|
|
787
787
|
// argv/fs/process.exit side effects; install.integration.test.ts exercises it through
|
|
788
788
|
// spawned processes. Pure decision logic lives in exported functions
|
|
789
|
-
// (validateModuleFlagsForVerb above,
|
|
789
|
+
// (validateModuleFlagsForVerb above, validateCloudTrackerWired in commands/install/install.ts)
|
|
790
790
|
// for unit coverage.
|
|
791
791
|
export async function main() {
|
|
792
792
|
const commandExit = await runCommand(process.argv.slice(2), COMMANDS, {
|
package/dist/commands/ci/ci.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
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
|
//
|
|
@@ -36,7 +36,8 @@ import * as path from "node:path";
|
|
|
36
36
|
import { gitEnv } from "../../ledgers/telemetry.js";
|
|
37
37
|
import { readBkitConfig } from "../../shared/settings.js";
|
|
38
38
|
import { CommandError, commitMessage, EXIT, OUTPUT_LIMIT, git, parseJson, runGit, SKIP_CI_TOKEN, } from "../lib.js";
|
|
39
|
-
import { bookPathspecs, changedOutside, checkOnlyBookkeeping, globPathspecs, } from "../workflow/ledgers.js";
|
|
39
|
+
import { bookPathspecs, changedOutside, checkOnlyBookkeeping, gitRaw, globPathspecs, } from "../workflow/ledgers.js";
|
|
40
|
+
import { managedHead } from "../../install/managed-block.js";
|
|
40
41
|
import { pins } from "./pins.js";
|
|
41
42
|
import { hasVerifiedIncrement, runPushGate } from "./push-gate.js";
|
|
42
43
|
/** Exit code: slop-scan could not be started (not installed, not executable). */
|
|
@@ -198,7 +199,7 @@ const tail = (text) => text.trim().split("\n").slice(-20).join("\n");
|
|
|
198
199
|
* the signal would. Without the listeners Node dies on the signal and leaves the base
|
|
199
200
|
* worktree registered in the repo.
|
|
200
201
|
*/
|
|
201
|
-
async function withCleanup(body, cleanup) {
|
|
202
|
+
export async function withCleanup(body, cleanup) {
|
|
202
203
|
const received = [];
|
|
203
204
|
const onSignal = (sig) => received.push(sig);
|
|
204
205
|
for (const sig of CLEANUP_SIGNALS)
|
|
@@ -526,14 +527,14 @@ function skipToken(ctx) {
|
|
|
526
527
|
/**
|
|
527
528
|
* The min-push pathspecs: ship's `pr` bookkeeping allow-list for every month and feature
|
|
528
529
|
* (the same list `bkit ci bookkeeping-push` and the ship gate accept untested, including
|
|
529
|
-
* `bkit.testing.ciSkipPaths`), the plans tree bkit's workflows write, and whatever the repo
|
|
530
|
+
* `bkit.testing.ciSkipPaths`), the plans tree and audit reports bkit's workflows write, and whatever the repo
|
|
530
531
|
* adds in `bkit.testing.minPushPaths` (`:(glob)` unless an entry carries its own magic).
|
|
531
532
|
* The engine hardcodes no consumer file: the floor is what bkit itself writes.
|
|
532
533
|
*/
|
|
533
534
|
export function minPushPathspecs(cfg) {
|
|
534
535
|
return [
|
|
535
536
|
...bookPathspecs("*", "*", "pr", cfg.ciSkipPaths),
|
|
536
|
-
...globPathspecs(["docs/plans/**", ...cfg.minPushPaths]),
|
|
537
|
+
...globPathspecs(["docs/plans/**", "docs/audits/**", ...cfg.minPushPaths]),
|
|
537
538
|
];
|
|
538
539
|
}
|
|
539
540
|
/** Where a pushed commit's range starts: its merge-base with origin/dev, else origin/main. */
|
|
@@ -547,6 +548,36 @@ export function pushBase(cwd, sha) {
|
|
|
547
548
|
}
|
|
548
549
|
return null;
|
|
549
550
|
}
|
|
551
|
+
/** An audit template the project owns below its managed block; no other template qualifies. */
|
|
552
|
+
const AUDIT_TEMPLATE_RE = /^docs\/templates\/bkit-audit-[^/]+\.md$/;
|
|
553
|
+
/**
|
|
554
|
+
* `changedOutside` plus the audit-template exception: a top-level `docs/templates/bkit-audit-*.md`
|
|
555
|
+
* present at both commits whose text through the `bkit:end` line is identical at both (so only
|
|
556
|
+
* the project section below it changed) is moved from `outside` to `sections`.
|
|
557
|
+
*/
|
|
558
|
+
export function minPushOutside(root, from, to, paths) {
|
|
559
|
+
const diff = changedOutside(root, from, to, paths);
|
|
560
|
+
if (!diff.ok)
|
|
561
|
+
return diff;
|
|
562
|
+
const sections = [];
|
|
563
|
+
const outside = [];
|
|
564
|
+
const head = (sha, file) => {
|
|
565
|
+
const res = gitRaw(root, ["cat-file", "blob", `${sha}:${file}`]);
|
|
566
|
+
return res.status === 0 ? managedHead(res.stdout) : null;
|
|
567
|
+
};
|
|
568
|
+
for (const file of diff.outside) {
|
|
569
|
+
if (AUDIT_TEMPLATE_RE.test(file)) {
|
|
570
|
+
const before = head(from, file);
|
|
571
|
+
if (before !== null && before === head(to, file)) {
|
|
572
|
+
sections.push(file);
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
outside.push(file);
|
|
577
|
+
}
|
|
578
|
+
return { ok: true, changed: diff.changed, outside, sections };
|
|
579
|
+
}
|
|
580
|
+
const sectionNote = (file) => `${file}: only its project section below <!-- bkit:end --> changed`;
|
|
550
581
|
function minPush(ctx) {
|
|
551
582
|
const top = runGit(ctx.cwd, ["rev-parse", "--show-toplevel"]);
|
|
552
583
|
if (!top.ok)
|
|
@@ -564,10 +595,11 @@ function minPush(ctx) {
|
|
|
564
595
|
}
|
|
565
596
|
const changed = new Set();
|
|
566
597
|
const outside = new Set();
|
|
598
|
+
const sections = new Set();
|
|
567
599
|
for (const ref of refs) {
|
|
568
600
|
const sha = git(ctx.cwd, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`]);
|
|
569
601
|
const base = sha ? (baseFlag ?? pushBase(ctx.cwd, sha)) : null;
|
|
570
|
-
const diff = sha && base ?
|
|
602
|
+
const diff = sha && base ? minPushOutside(top.stdout, base, sha, paths) : null;
|
|
571
603
|
if (!diff?.ok) {
|
|
572
604
|
const why = !sha
|
|
573
605
|
? `cannot read commit '${ref}'`
|
|
@@ -582,7 +614,11 @@ function minPush(ctx) {
|
|
|
582
614
|
changed.add(p);
|
|
583
615
|
for (const p of diff.outside)
|
|
584
616
|
outside.add(p);
|
|
617
|
+
for (const p of diff.sections)
|
|
618
|
+
sections.add(p);
|
|
585
619
|
}
|
|
620
|
+
for (const p of [...sections].sort())
|
|
621
|
+
ctx.log(sectionNote(p));
|
|
586
622
|
const result = (reason, code, message) => {
|
|
587
623
|
ctx.log(message);
|
|
588
624
|
ctx.emit({
|
|
@@ -606,6 +642,7 @@ function minPush(ctx) {
|
|
|
606
642
|
function minPushUpdates(ctx, cwd, updates, paths) {
|
|
607
643
|
const changed = new Set();
|
|
608
644
|
const outside = new Set();
|
|
645
|
+
const sections = new Set();
|
|
609
646
|
let unknown = false;
|
|
610
647
|
let failed = false;
|
|
611
648
|
for (const update of updates) {
|
|
@@ -620,13 +657,16 @@ function minPushUpdates(ctx, cwd, updates, paths) {
|
|
|
620
657
|
unknown = true;
|
|
621
658
|
continue;
|
|
622
659
|
}
|
|
623
|
-
const increment = isNew ? null :
|
|
660
|
+
const increment = isNew ? null : minPushOutside(cwd, oldSha, newSha, paths);
|
|
624
661
|
const base = pushBase(cwd, newSha);
|
|
625
|
-
const whole = base ?
|
|
626
|
-
if (hasVerifiedIncrement(cwd, oldSha, newSha, paths)) {
|
|
662
|
+
const whole = base ? minPushOutside(cwd, base, newSha, paths) : null;
|
|
663
|
+
if (hasVerifiedIncrement(cwd, oldSha, newSha, (a, b) => minPushOutside(cwd, a, b, paths))) {
|
|
627
664
|
if (increment?.ok)
|
|
628
665
|
for (const file of increment.changed)
|
|
629
666
|
changed.add(file);
|
|
667
|
+
if (increment?.ok)
|
|
668
|
+
for (const file of increment.sections)
|
|
669
|
+
sections.add(file);
|
|
630
670
|
ctx.log(`${oldSha}..${newSha}: covered by a successful full push gate`);
|
|
631
671
|
continue;
|
|
632
672
|
}
|
|
@@ -635,6 +675,8 @@ function minPushUpdates(ctx, cwd, updates, paths) {
|
|
|
635
675
|
changed.add(file);
|
|
636
676
|
for (const file of whole.outside)
|
|
637
677
|
outside.add(file);
|
|
678
|
+
for (const file of whole.sections)
|
|
679
|
+
sections.add(file);
|
|
638
680
|
if (whole.changed.length > 0 &&
|
|
639
681
|
whole.outside.length === 0 &&
|
|
640
682
|
(isNew || (increment?.ok && increment.changed.length > 0)))
|
|
@@ -644,6 +686,8 @@ function minPushUpdates(ctx, cwd, updates, paths) {
|
|
|
644
686
|
unknown = true;
|
|
645
687
|
failed = true;
|
|
646
688
|
}
|
|
689
|
+
for (const file of [...sections].sort())
|
|
690
|
+
ctx.log(sectionNote(file));
|
|
647
691
|
const reason = !failed ? null : unknown ? "unknown" : outside.size ? "outside" : "no-changes";
|
|
648
692
|
ctx.emit({
|
|
649
693
|
minPush: !failed,
|
|
@@ -783,11 +827,11 @@ export const ciCommand = {
|
|
|
783
827
|
},
|
|
784
828
|
],
|
|
785
829
|
output: {
|
|
786
|
-
minPush: "true when every changed file matches a min-push path",
|
|
830
|
+
minPush: "true when every changed file matches a min-push path, or is a docs/templates/bkit-audit-*.md changed only below its <!-- bkit:end -->",
|
|
787
831
|
reason: "null when a min push; else no-changes | outside | unknown",
|
|
788
832
|
changed: "files the push changes, across every ref",
|
|
789
|
-
outside: "the changed files no min-push path matches",
|
|
790
|
-
paths: "the min-push pathspecs in force: ship's pr bookkeeping allow-list (with bkit.testing.ciSkipPaths), docs/plans/**, bkit.testing.minPushPaths",
|
|
833
|
+
outside: "the changed files no min-push path matches (an audit template changed only below its <!-- bkit:end --> is not listed)",
|
|
834
|
+
paths: "the min-push pathspecs in force: ship's pr bookkeeping allow-list (with bkit.testing.ciSkipPaths), docs/plans/**, docs/audits/**, bkit.testing.minPushPaths",
|
|
791
835
|
},
|
|
792
836
|
exitCodes: {
|
|
793
837
|
[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 { runGateUnderLock } from "../workflow/junit.js";
|
|
13
12
|
const UNIT = "bkit:gate:static-unit";
|
|
14
13
|
const INTEGRATION = "bkit:gate:static-unit-integration";
|
|
15
14
|
const SHA = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
|
|
@@ -42,29 +41,48 @@ const receiptPath = (cwd, sha) => {
|
|
|
42
41
|
const outbox = outboxRoot(cwd);
|
|
43
42
|
return outbox ? path.join(outbox, "push-gates", `${sha}.json`) : null;
|
|
44
43
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
const STATUS = [
|
|
45
|
+
"status",
|
|
46
|
+
"--porcelain",
|
|
47
|
+
"--no-renames",
|
|
48
|
+
"--untracked-files=all",
|
|
49
|
+
"--ignore-submodules=none",
|
|
50
|
+
];
|
|
51
|
+
const lineCount = (text) => text === null ? -1 : text === "" ? 0 : text.split("\n").length;
|
|
52
|
+
/** HEAD when every uncommitted path lies inside `tolerated` (none given: the tree must be clean). */
|
|
53
|
+
function cleanHead(cwd, tolerated = []) {
|
|
54
|
+
const all = lineCount(git(cwd, STATUS));
|
|
55
|
+
if (all < 0)
|
|
53
56
|
return null;
|
|
57
|
+
if (all > 0) {
|
|
58
|
+
if (tolerated.length === 0)
|
|
59
|
+
return null;
|
|
60
|
+
if (lineCount(git(cwd, [...STATUS, "--", ...tolerated])) !== all)
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
54
63
|
const sha = git(cwd, ["rev-parse", "--verify", "HEAD^{commit}"]);
|
|
55
64
|
const tree = git(cwd, ["rev-parse", "--verify", "HEAD^{tree}"]);
|
|
56
65
|
return sha && tree ? { sha, tree } : null;
|
|
57
66
|
}
|
|
58
|
-
/**
|
|
59
|
-
|
|
67
|
+
/** The recorded runner's process id of a `.running` attempt file; null when unreadable. */
|
|
68
|
+
function attemptPid(file) {
|
|
69
|
+
const read = readJsonFile(file);
|
|
70
|
+
if (!read.ok || !read.value || typeof read.value !== "object")
|
|
71
|
+
return null;
|
|
72
|
+
const pid = read.value.pid;
|
|
73
|
+
return typeof pid === "number" && Number.isInteger(pid) && pid > 0 ? pid : null;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Run a gate through `run` and record its receipt: the `.running` marker while it runs, a
|
|
77
|
+
* `.failed` marker when it fails, the before/after HEAD and fingerprint check, and the
|
|
78
|
+
* receipt write. An attempt on the same commit whose runner process is gone counts as a
|
|
79
|
+
* failed run and is cleared. Uncommitted paths in `tolerated` do not block the receipt; a
|
|
80
|
+
* lock wait (`waited`, default never) leaves the receipt and markers as they were.
|
|
81
|
+
*/
|
|
82
|
+
export function runWithReceipt(cwd, gate, tolerated, run, log, waited = () => false) {
|
|
60
83
|
const pkg = readPackageJson(cwd);
|
|
61
|
-
const script = pkg.ok ? scriptsOf(pkg.pkg)?.[gate] : null;
|
|
62
|
-
if (typeof script !== "string" || script.trim() === "") {
|
|
63
|
-
log(`package.json must declare a non-empty ${gate} script`);
|
|
64
|
-
return EXIT.USAGE;
|
|
65
|
-
}
|
|
66
84
|
const definition = pkg.ok ? gateDefinition(pkg.pkg) : null;
|
|
67
|
-
const before = cleanHead(cwd);
|
|
85
|
+
const before = cleanHead(cwd, tolerated);
|
|
68
86
|
const head = git(cwd, ["rev-parse", "--verify", "HEAD^{commit}"]);
|
|
69
87
|
const file = head ? receiptPath(cwd, head) : null;
|
|
70
88
|
const attempt = file && definition?.gate === gate ? path.join(`${file}.running`, randomUUID()) : null;
|
|
@@ -76,33 +94,30 @@ export function runPushGate(cwd, gate, log) {
|
|
|
76
94
|
fs.rmSync(file, { force: true });
|
|
77
95
|
};
|
|
78
96
|
if (attempt) {
|
|
79
|
-
|
|
97
|
+
const dir = path.dirname(attempt);
|
|
98
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
99
|
+
for (const entry of fs.readdirSync(dir)) {
|
|
100
|
+
const pid = attemptPid(path.join(dir, entry));
|
|
101
|
+
if (pid === null || pidAlive(pid))
|
|
102
|
+
continue;
|
|
103
|
+
fs.rmSync(path.join(dir, entry), { force: true });
|
|
104
|
+
fail();
|
|
105
|
+
}
|
|
80
106
|
fs.writeFileSync(attempt, JSON.stringify({ pid: process.pid, sha: head }) + "\n");
|
|
81
|
-
fail();
|
|
82
107
|
}
|
|
83
108
|
const finish = (code) => {
|
|
84
109
|
if (attempt)
|
|
85
110
|
fs.rmSync(attempt, { force: true });
|
|
86
111
|
return code;
|
|
87
112
|
};
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
cwd,
|
|
92
|
-
env: gitEnv(),
|
|
93
|
-
stdio: ["ignore", 2, 2],
|
|
94
|
-
});
|
|
95
|
-
const status = result.error
|
|
96
|
-
? 127
|
|
97
|
-
: (result.status ??
|
|
98
|
-
128 + ((result.signal ? os.constants.signals[result.signal] : undefined) ?? 1));
|
|
99
|
-
if (result.error)
|
|
100
|
-
log(result.error.message);
|
|
113
|
+
const status = run();
|
|
114
|
+
if (waited(status))
|
|
115
|
+
return finish(status);
|
|
101
116
|
if (status !== 0 || !before || definition?.gate !== gate) {
|
|
102
117
|
fail();
|
|
103
118
|
return finish(status);
|
|
104
119
|
}
|
|
105
|
-
const after = cleanHead(cwd);
|
|
120
|
+
const after = cleanHead(cwd, tolerated);
|
|
106
121
|
const afterPkg = readPackageJson(cwd);
|
|
107
122
|
if (after?.sha !== before.sha ||
|
|
108
123
|
after.tree !== before.tree ||
|
|
@@ -120,6 +135,26 @@ export function runPushGate(cwd, gate, log) {
|
|
|
120
135
|
}
|
|
121
136
|
return finish(status);
|
|
122
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Execute a consumer gate; only a successful deepest full gate on an unchanged clean tree earns
|
|
140
|
+
* proof. A tests-lock wait (the lock wrapper gave up, exit 75) leaves the receipt and its
|
|
141
|
+
* markers as they were, and its status file is handed on to a caller that asked for one.
|
|
142
|
+
*/
|
|
143
|
+
export function runPushGate(cwd, gate, log) {
|
|
144
|
+
const pkg = readPackageJson(cwd);
|
|
145
|
+
const script = pkg.ok ? scriptsOf(pkg.pkg)?.[gate] : null;
|
|
146
|
+
if (typeof script !== "string" || script.trim() === "") {
|
|
147
|
+
log(`package.json must declare a non-empty ${gate} script`);
|
|
148
|
+
return EXIT.USAGE;
|
|
149
|
+
}
|
|
150
|
+
const env = gitEnv();
|
|
151
|
+
const lock = {};
|
|
152
|
+
return runWithReceipt(cwd, gate, [], () => {
|
|
153
|
+
log(`running ${scriptCommand(gate).join(" ")}`);
|
|
154
|
+
lock.run = runGateUnderLock(scriptCommand(gate), cwd, 2, { LOCAL_STACK_LOCK_WHO: env.LOCAL_STACK_LOCK_WHO || `bkit ci push-gate ${gate}` }, { base: env, forwardStatusTo: env[LOCK_STATUS_FILE_ENV] });
|
|
155
|
+
return lock.run.exitCode;
|
|
156
|
+
}, log, () => lock.run?.lock === "lock-wait");
|
|
157
|
+
}
|
|
123
158
|
/** Pending files survive interrupted runners; one read suffices to block earlier proof. */
|
|
124
159
|
function pendingAttempt(file) {
|
|
125
160
|
const dir = `${file}.running`;
|
|
@@ -163,11 +198,11 @@ function noLaterFailure(cwd, dir, sha, newSha, definition) {
|
|
|
163
198
|
return true;
|
|
164
199
|
}
|
|
165
200
|
/** A bounded ancestor search; absent, malformed or stale proof always requires the full gate. */
|
|
166
|
-
export function hasVerifiedIncrement(cwd, oldSha, newSha,
|
|
167
|
-
|
|
201
|
+
export function hasVerifiedIncrement(cwd, oldSha, newSha, outsideOf) {
|
|
202
|
+
const isNew = /^0+$/.test(oldSha);
|
|
203
|
+
if ((!isNew && !SHA.test(oldSha)) ||
|
|
168
204
|
!SHA.test(newSha) ||
|
|
169
|
-
|
|
170
|
-
!runGit(cwd, ["merge-base", "--is-ancestor", oldSha, newSha]).ok)
|
|
205
|
+
(!isNew && !runGit(cwd, ["merge-base", "--is-ancestor", oldSha, newSha]).ok))
|
|
171
206
|
return false;
|
|
172
207
|
const raw = git(cwd, ["show", `${newSha}:package.json`]);
|
|
173
208
|
const parsed = raw === null ? null : parseJson(raw);
|
|
@@ -177,8 +212,8 @@ export function hasVerifiedIncrement(cwd, oldSha, newSha, paths) {
|
|
|
177
212
|
!localPkg.ok ||
|
|
178
213
|
gateDefinition(localPkg.pkg)?.fingerprint !== definition.fingerprint)
|
|
179
214
|
return false;
|
|
180
|
-
const ancestors = git(cwd, ["rev-list", "--max-count=128", oldSha]);
|
|
181
|
-
const firstFile = receiptPath(cwd,
|
|
215
|
+
const ancestors = git(cwd, ["rev-list", "--max-count=128", isNew ? newSha : oldSha]);
|
|
216
|
+
const firstFile = receiptPath(cwd, newSha);
|
|
182
217
|
if (!ancestors || !firstFile)
|
|
183
218
|
return false;
|
|
184
219
|
const dir = path.dirname(firstFile);
|
|
@@ -186,7 +221,7 @@ export function hasVerifiedIncrement(cwd, oldSha, newSha, paths) {
|
|
|
186
221
|
const file = path.join(dir, `${sha}.json`);
|
|
187
222
|
if (!validReceipt(cwd, file, sha, definition))
|
|
188
223
|
continue;
|
|
189
|
-
const diff =
|
|
224
|
+
const diff = outsideOf(sha, newSha);
|
|
190
225
|
if (diff.ok && diff.outside.length === 0 && noLaterFailure(cwd, dir, sha, newSha, definition))
|
|
191
226
|
return true;
|
|
192
227
|
}
|
|
@@ -5,7 +5,6 @@ import * as path from "node:path";
|
|
|
5
5
|
import { OPENCODE_PROVIDERS } from "../../shared/egress.js";
|
|
6
6
|
import { readInstallingVersion } from "../../shared/package-json.js";
|
|
7
7
|
import { dispatchModules } from "../../install/modules/index.js";
|
|
8
|
-
import { DEFAULT_ISSUE_TRACKER, } from "../../install/manifest.js";
|
|
9
8
|
import { parseJson, readJsonFile } from "../../shared/json.js";
|
|
10
9
|
import { readBkitConfig } from "../../shared/settings.js";
|
|
11
10
|
import { LOG_PREFIX, setLogPrefix } from "../../shared/log-prefix.js";
|
|
@@ -15,6 +14,7 @@ import { formatChecklist, readChangelogVersionDelta, runPostInstallCheck, writeA
|
|
|
15
14
|
import { collectTips } from "../../checks/tips/index.js";
|
|
16
15
|
import { findMissingOwnedHooks, detectOwnedHookMissing } from "../../checks/after/managed.js";
|
|
17
16
|
import { resolveTokens } from "../../install/placeholders.js";
|
|
17
|
+
import { syncProjectDocs } from "../../install/project-docs.js";
|
|
18
18
|
import { parseModelLookup, applyModelOverrides, unknownModelOverrides, buildOpencodeModelLookup, buildAntigravityModelLookup, parseEffortMap, } from "../../render/models.js";
|
|
19
19
|
import { getBkitDocsRoot } from "../../shared/package-roots.js";
|
|
20
20
|
import { migrateBkitLayout, migrateGithubProjectKey, migrateLinearTeamKey, } from "../../install/modules/core.js";
|
|
@@ -81,24 +81,14 @@ export function modulesToCliFlags(mods, opencodeProvider, cloudVariant) {
|
|
|
81
81
|
return out.join(" ");
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* cloud=cursor requires tracker=linear. Mismatch is a hard error — checked BEFORE
|
|
87
|
-
* any package.json write so no state is recorded on mismatch ("no files written
|
|
88
|
-
* on hard error" invariant). Returns the error message to print, or `null` when
|
|
89
|
-
* the tracker matches (or no cloud module/variant is in play).
|
|
84
|
+
* Cloud automation needs a wired tracker. Returns the pre-write error message,
|
|
85
|
+
* or null when a tracker is wired or no cloud module/variant is being installed.
|
|
90
86
|
*/
|
|
91
|
-
export function
|
|
92
|
-
if (cloudVariant === null || !hasCloudModule)
|
|
87
|
+
export function validateCloudTrackerWired(cloudVariant, hasCloudModule, issueTracker) {
|
|
88
|
+
if (cloudVariant === null || !hasCloudModule || issueTracker !== "none")
|
|
93
89
|
return null;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return null;
|
|
97
|
-
return (`[bkit] --auto=${cloudVariant} requires tracker=${requiredTracker}, ` +
|
|
98
|
-
`but the resolved tracker is "${issueTracker}". ` +
|
|
99
|
-
(issueTracker === DEFAULT_ISSUE_TRACKER || issueTracker === "none"
|
|
100
|
-
? `Set the tracker first: bkit install --tracker=${requiredTracker} --auto=${cloudVariant}`
|
|
101
|
-
: `Re-run with the matching tracker: bkit install --tracker=${requiredTracker} --auto=${cloudVariant} (tracker switching is free).`));
|
|
90
|
+
return (`[bkit] --auto=${cloudVariant} needs a wired tracker: ` +
|
|
91
|
+
`bkit install --tracker=<github|linear|jira> --auto=${cloudVariant}`);
|
|
102
92
|
}
|
|
103
93
|
/** `parent[key]` as an object, set to a fresh `{}` first when it is absent or not an object. */
|
|
104
94
|
function section(parent, key) {
|
|
@@ -327,10 +317,8 @@ export async function runInstall(args, upgradeReport = false) {
|
|
|
327
317
|
});
|
|
328
318
|
}
|
|
329
319
|
const postDispatch = [];
|
|
330
|
-
//
|
|
331
|
-
|
|
332
|
-
// package.json write so no state is recorded on mismatch.
|
|
333
|
-
const cloudTrackerError = validateCloudTrackerMatch(cloudVariant, modules.has("cloud"), issueTracker);
|
|
320
|
+
// Reject missing tracker wiring before any package.json write.
|
|
321
|
+
const cloudTrackerError = validateCloudTrackerWired(cloudVariant, modules.has("cloud"), issueTracker);
|
|
334
322
|
if (cloudTrackerError) {
|
|
335
323
|
console.error(cloudTrackerError);
|
|
336
324
|
process.exit(1);
|
|
@@ -338,12 +326,20 @@ export async function runInstall(args, upgradeReport = false) {
|
|
|
338
326
|
if (cloudVariant !== null && modules.has("cloud")) {
|
|
339
327
|
// auto=opencode additionally requires the local opencode host to be installed first
|
|
340
328
|
// (the cloud job runs against the committed .opencode/ — no model is hard-coded in YAML).
|
|
341
|
-
if (cloudVariant === "opencode" &&
|
|
329
|
+
if (cloudVariant === "opencode" &&
|
|
330
|
+
!modules.has("opencode") &&
|
|
331
|
+
!fs.existsSync(path.join(process.cwd(), ".opencode"))) {
|
|
342
332
|
console.error(`[bkit] --auto=opencode requires the local opencode host to be installed first.\n` +
|
|
343
333
|
`Run: bkit install --opencode=<provider> (e.g. --opencode=opencode-zen)\n` +
|
|
344
334
|
`The cloud opencode job runs against the committed .opencode/ config — without it there is nothing to run.`);
|
|
345
335
|
process.exit(1);
|
|
346
336
|
}
|
|
337
|
+
if (cloudVariant === "codex" &&
|
|
338
|
+
!modules.has("codex") &&
|
|
339
|
+
!fs.existsSync(path.join(process.cwd(), ".codex"))) {
|
|
340
|
+
console.error(`[bkit] --auto=codex requires the local Codex host. Run: bkit install --codex`);
|
|
341
|
+
process.exit(1);
|
|
342
|
+
}
|
|
347
343
|
}
|
|
348
344
|
// Persist bkit manifest fields to consumer package.json AFTER all hard-error gates pass.
|
|
349
345
|
// This preserves the "no files written on mismatch" invariant. Two fields are recorded:
|
|
@@ -441,6 +437,11 @@ export async function runInstall(args, upgradeReport = false) {
|
|
|
441
437
|
finally {
|
|
442
438
|
discardAllStaging();
|
|
443
439
|
}
|
|
440
|
+
// The ten project documents belong to the project: drop a legacy ownership wrapper and list
|
|
441
|
+
// each present document in `Project Documents`. Runs after the managed index is rendered and
|
|
442
|
+
// before the advisories read the result. `check` is read-only, so it never gets here.
|
|
443
|
+
if (!dryRun)
|
|
444
|
+
syncProjectDocs(process.cwd(), { dryRun: false });
|
|
444
445
|
const totalWrites = ws.writes.length;
|
|
445
446
|
// Done banner first so the line count is easy to find above the checklist.
|
|
446
447
|
// For check, "would occur" makes intent explicit; for install, writes already happened.
|