@cbartens/bkit 6.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.bkit/README.md +154 -151
- package/.bkit/core/.agents/context.md +95 -29
- package/.bkit/core/.agents/docs.md +17 -15
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-gateguard.cjs +1 -0
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +6 -5
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-readguard.cjs +1 -0
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-rules.cjs +65 -0
- package/.bkit/core/.agents/rules.md +108 -107
- package/.bkit/core/.agents/skills.md +63 -15
- package/.bkit/core/.bkit/README.md +154 -151
- package/.bkit/core/.bkit/authoring.md +714 -84
- package/.bkit/core/.bkit/cli.md +407 -0
- package/.bkit/core/.bkit/cloud.md +281 -193
- package/.bkit/core/.bkit/comparison.md +43 -41
- package/.bkit/core/.bkit/install.md +154 -84
- package/.bkit/core/.bkit/jsonl.md +193 -130
- package/.bkit/core/.bkit/pipeline.md +114 -114
- package/.bkit/core/.bkit/prompts.md +272 -165
- package/.bkit/core/.bkit/providers.md +457 -271
- package/.bkit/core/.bkit/router.md +69 -0
- package/.bkit/core/.bkit/templates.md +529 -256
- package/.bkit/core/.bkit/trackers.md +80 -52
- package/.bkit/core/.bkit/workflows.md +589 -504
- package/.bkit/core/.claude/hooks/bkit-gateguard.cjs +2 -2
- package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +3 -3
- package/.bkit/core/.claude/hooks/bkit-preflight.sh +45 -14
- package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +3 -3
- package/.bkit/core/.codex/hooks/bkit-rules.cjs +57 -0
- package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +7 -7
- package/.bkit/core/.cursor/hooks/bkit-preflight.sh +47 -12
- package/.bkit/core/.opencode/plugin/bkit-rules.js +89 -0
- package/.bkit/core/AGENTS.md +5 -73
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +127 -105
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +104 -70
- package/.bkit/core/docs/templates/bkit-audit-agents.md +94 -72
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +99 -78
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +140 -82
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +98 -72
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +121 -96
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +157 -76
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +113 -71
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +75 -72
- package/.bkit/core/docs/templates/bkit-audit-config.md +122 -76
- package/.bkit/core/docs/templates/bkit-audit-cost.md +85 -74
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +75 -68
- package/.bkit/core/docs/templates/bkit-audit-database.md +101 -70
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +164 -83
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +115 -86
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +264 -88
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +118 -93
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +139 -86
- package/.bkit/core/docs/templates/bkit-audit-failures.md +110 -81
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +99 -74
- package/.bkit/core/docs/templates/bkit-audit-gates.md +105 -77
- package/.bkit/core/docs/templates/bkit-audit-issues.md +104 -80
- package/.bkit/core/docs/templates/bkit-audit-llm.md +131 -58
- package/.bkit/core/docs/templates/bkit-audit-logs.md +123 -100
- package/.bkit/core/docs/templates/bkit-audit-models.md +98 -53
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +56 -52
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +63 -54
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +124 -68
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +95 -70
- package/.bkit/core/docs/templates/bkit-audit-repo.md +169 -73
- package/.bkit/core/docs/templates/bkit-audit-security.md +206 -96
- package/.bkit/core/docs/templates/bkit-audit-slop.md +77 -70
- package/.bkit/core/docs/templates/bkit-audit-testing.md +162 -114
- package/.bkit/core/docs/templates/bkit-audit-usability.md +113 -71
- package/.bkit/core/docs/templates/bkit-plan.md +138 -132
- package/.bkit/core/engine/checks/after/auth.ts +40 -37
- package/.bkit/core/engine/checks/after/ci-yml.ts +65 -2
- package/.bkit/core/engine/checks/after/index.ts +12 -2
- package/.bkit/core/engine/checks/after/tools.ts +80 -33
- package/.bkit/core/engine/checks/before/context-fetch.ts +227 -33
- package/.bkit/core/engine/checks/before/env.ts +1 -1
- package/.bkit/core/engine/checks/before/index.ts +7 -0
- package/.bkit/core/engine/checks/before/repo.ts +40 -0
- package/.bkit/core/engine/checks/status-holes.ts +916 -123
- package/.bkit/core/engine/checks/tips/catalogue.ts +68 -17
- package/.bkit/core/engine/checks/tips/detect.ts +32 -0
- package/.bkit/core/engine/checks/tips/index.ts +47 -6
- package/.bkit/core/engine/cli.ts +238 -84
- package/.bkit/core/engine/commands/analysis.ts +128 -76
- package/.bkit/core/engine/commands/ci/ci.ts +363 -29
- package/.bkit/core/engine/commands/ci/pins.ts +172 -0
- package/.bkit/core/engine/commands/ci/push-gate.ts +223 -0
- package/.bkit/core/engine/commands/install/uninstall.ts +21 -27
- package/.bkit/core/engine/commands/install/upgrade.ts +32 -15
- package/.bkit/core/engine/commands/land.ts +126 -11
- package/.bkit/core/engine/commands/lib.ts +303 -6
- package/.bkit/core/engine/commands/registry.ts +6 -2
- package/.bkit/core/engine/commands/setup/setup.ts +1 -0
- package/.bkit/core/engine/commands/stats.ts +91 -35
- package/.bkit/core/engine/commands/workflow/branches.ts +1477 -117
- package/.bkit/core/engine/commands/workflow/challenge.ts +114 -39
- package/.bkit/core/engine/commands/workflow/completeness.ts +109 -0
- package/.bkit/core/engine/commands/workflow/context.ts +433 -55
- package/.bkit/core/engine/commands/workflow/counters.ts +244 -39
- package/.bkit/core/engine/commands/workflow/decisions.ts +61 -17
- package/.bkit/core/engine/commands/workflow/disk.ts +237 -55
- package/.bkit/core/engine/commands/workflow/fids.ts +19 -1
- package/.bkit/core/engine/commands/workflow/issues.ts +6 -0
- package/.bkit/core/engine/commands/workflow/ledgers.ts +458 -18
- package/.bkit/core/engine/commands/workflow/locks.ts +2 -0
- package/.bkit/core/engine/commands/workflow/plan-blocks.ts +124 -15
- package/.bkit/core/engine/commands/workflow/plans.ts +257 -0
- package/.bkit/core/engine/commands/workflow/prs.ts +12 -3
- package/.bkit/core/engine/commands/workflow/repo.ts +8 -0
- package/.bkit/core/engine/commands/workflow/roadmap.ts +56 -15
- package/.bkit/core/engine/commands/workflow/run-facts.ts +22 -31
- package/.bkit/core/engine/commands/workflow/runs.ts +652 -34
- package/.bkit/core/engine/commands/workflow/runtime.ts +3 -0
- package/.bkit/core/engine/commands/workflow/skills.ts +1 -0
- package/.bkit/core/engine/commands/workflow/status.ts +200 -17
- package/.bkit/core/engine/commands/workflow/step-table.ts +75 -33
- package/.bkit/core/engine/commands/workflow/steps.ts +635 -24
- package/.bkit/core/engine/commands/workflow/summary-findings.ts +177 -0
- package/.bkit/core/engine/commands/workflow/summary.ts +192 -46
- package/.bkit/core/engine/commands/workflow/tasks.ts +409 -0
- package/.bkit/core/engine/commands/workflow/test-blocks.ts +254 -0
- package/.bkit/core/engine/commands/workflow/tests-changed.ts +201 -0
- package/.bkit/core/engine/commands/workflow/tests.ts +1285 -356
- package/.bkit/core/engine/commands/workflow/workflows.ts +228 -43
- package/.bkit/core/engine/commands/workflow/worktrees.ts +389 -47
- package/.bkit/core/engine/install/cloud-env.ts +251 -121
- package/.bkit/core/engine/install/context-ci-workflow.ts +102 -0
- package/.bkit/core/engine/install/manifest.ts +60 -12
- package/.bkit/core/engine/install/modules/antigravity.ts +3 -2
- package/.bkit/core/engine/install/modules/cloud.ts +3 -3
- package/.bkit/core/engine/install/modules/codex.ts +15 -2
- package/.bkit/core/engine/install/modules/core.ts +956 -52
- package/.bkit/core/engine/install/modules/cursor.ts +6 -6
- package/.bkit/core/engine/install/modules/opencode.ts +16 -4
- package/.bkit/core/engine/install/template-notes.ts +130 -0
- package/.bkit/core/engine/install/version-file.ts +3 -2
- package/.bkit/core/engine/install/write.ts +5 -0
- package/.bkit/core/engine/ledgers/compact.ts +124 -0
- package/.bkit/core/engine/ledgers/journal.ts +291 -0
- package/.bkit/core/engine/ledgers/status.ts +160 -9
- package/.bkit/core/engine/ledgers/telemetry.ts +158 -21
- package/.bkit/core/engine/render/hosts.ts +114 -14
- package/.bkit/core/engine/shared/bkit-latest.ts +26 -4
- package/.bkit/core/engine/shared/dep-updater.ts +60 -0
- package/.bkit/core/engine/shared/egress.ts +1 -1
- package/.bkit/core/engine/shared/package-manager.ts +9 -0
- package/.bkit/core/engine/shared/settings.ts +92 -17
- package/.bkit/core/engine/shared/timeouts.ts +2 -0
- package/.bkit/core/engine/tools/cli-doc.ts +111 -0
- package/.bkit/core/engine/tools/grammar-density.ts +1 -1
- package/.bkit/core/engine/tools/instructions-sources.ts +15 -17
- package/.bkit/core/engine/tools/instructions.ts +94 -43
- package/.bkit/core/hooks/antigravity-hook.js +25 -10
- package/.bkit/core/hooks/gateguard-engine.js +53 -29
- package/.bkit/core/hooks/guardrails-shell.js +4 -4
- package/.bkit/core/hooks/guardrails-tiers.js +3 -3
- package/.bkit/core/hooks/preflight-linear.sh +9 -9
- package/.bkit/core/hooks/preflight-rules.sh +8 -0
- package/.bkit/core/hooks/readguard-engine.js +29 -10
- package/.bkit/core/hooks/session-rules-advisory.js +61 -0
- package/.bkit/core/prompts/bkit-audit-generate.md +187 -116
- package/.bkit/core/prompts/bkit-build-challenge-1.md +56 -37
- package/.bkit/core/prompts/bkit-build-challenge-2.md +65 -45
- package/.bkit/core/prompts/bkit-build-install-skills.md +38 -29
- package/.bkit/core/prompts/bkit-build-plan-convert.md +43 -32
- package/.bkit/core/prompts/bkit-build-plan-current.md +49 -39
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +79 -55
- package/.bkit/core/prompts/bkit-build-plan-tasks.md +149 -0
- package/.bkit/core/prompts/bkit-build-plan-tests.md +120 -0
- package/.bkit/core/prompts/bkit-build-plan-verify.md +87 -50
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +36 -35
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +96 -64
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +54 -45
- package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +42 -33
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +53 -37
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +35 -30
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +34 -29
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +32 -28
- package/.bkit/core/prompts/bkit-design-generate.md +68 -52
- package/.bkit/core/prompts/bkit-design-organise.md +73 -35
- package/.bkit/core/prompts/bkit-design-review-1.md +58 -54
- package/.bkit/core/prompts/bkit-design-review-2.md +54 -50
- package/.bkit/core/prompts/bkit-design-spike.md +54 -47
- package/.bkit/core/prompts/bkit-design-update.md +42 -31
- package/.bkit/core/prompts/bkit-plan-generate.md +76 -58
- package/.bkit/core/prompts/bkit-plan-review-1.md +63 -49
- package/.bkit/core/prompts/bkit-plan-review-2.md +60 -48
- package/.bkit/core/prompts/bkit-plan-scope-check.md +53 -46
- package/.bkit/core/prompts/bkit-plan-update.md +70 -52
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +82 -50
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +80 -45
- package/.bkit/core/prompts/bkit-ship-update-docs.md +35 -29
- package/.bkit/core/prompts/bkit-utility-compress-markdown.md +55 -49
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +76 -49
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +70 -41
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +33 -30
- package/.bkit/core/prompts/bkit-utility-update-failures.md +73 -43
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +77 -50
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +77 -45
- package/.bkit/core/prompts/bkit-utility-update-tracker.md +144 -68
- package/.bkit/core/workflows/bkit-auto.md +53 -30
- package/.bkit/core/workflows/bkit-build.md +635 -304
- package/.bkit/core/workflows/bkit-debug.md +301 -148
- package/.bkit/core/workflows/bkit-design.md +167 -95
- package/.bkit/core/workflows/bkit-plan.md +172 -84
- package/.bkit/core/workflows/bkit-ship.md +299 -152
- package/.bkit/shared/.agents/plugins/bkit/hooks.json +10 -0
- package/.bkit/shared/.claude/bkit-cloud.md +12 -10
- package/.bkit/shared/.claude/settings.json +3 -0
- package/.bkit/shared/.codex/bkit-cloud.md +98 -0
- package/.bkit/shared/.codex/hooks.json +20 -0
- package/.bkit/shared/.cursor/bkit-cloud.md +3 -3
- package/.bkit/shared/.opencode/opencode.json +1 -1
- package/.bkit/shared/CLAUDE.md +5 -1
- package/.bkit/shared/GEMINI.md +4 -1
- package/.bkit/shared/docs/architecture.md +4 -7
- package/.bkit/shared/docs/data-schema.md +4 -7
- package/.bkit/shared/docs/deployments.md +239 -166
- package/.bkit/shared/docs/design.md +11 -12
- package/.bkit/shared/docs/noise.md +8 -7
- package/.bkit/shared/docs/observability.md +5 -8
- package/.bkit/shared/docs/security.md +35 -17
- package/.bkit/shared/docs/setup.md +29 -18
- package/.bkit/shared/docs/technology.md +3 -6
- package/.bkit/shared/docs/testing.md +282 -176
- package/.bkit/shared/gitignore +6 -2
- package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +15 -16
- package/.bkit/templates/.cursor/Dockerfile +12 -8
- package/.bkit/templates/.cursor/environment.json +1 -1
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-bug.yml +10 -8
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +24 -12
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-idea.yml +3 -3
- package/.bkit/templates/.github/renovate.json5 +34 -6
- package/.bkit/templates/.github/workflows/bkit-ci.yml +53 -50
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +13 -14
- package/.bkit/templates/.github/workflows/bkit-health.yml +97 -0
- package/.bkit/templates/.github/workflows/bkit-renovate.yml +5 -4
- package/.bkit/templates/.github/workflows/bkit-trivy.yml +5 -4
- package/.bkit/templates/.husky/pre-commit +2 -2
- package/.bkit/templates/.husky/pre-push +95 -35
- package/.bkit/templates/.prettierignore +6 -7
- package/.bkit/templates/.vale.ini +27 -27
- package/.bkit/templates/context/bkit-cloudrun.md +23 -15
- package/.bkit/templates/context/bkit-expo.md +70 -52
- package/.bkit/templates/context/bkit-github.md +93 -56
- package/.bkit/templates/context/bkit-inngest.md +21 -15
- package/.bkit/templates/context/bkit-maestro.md +22 -16
- package/.bkit/templates/context/bkit-playwright.md +23 -17
- package/.bkit/templates/context/bkit-resend.md +12 -10
- package/.bkit/templates/context/bkit-sentry.md +30 -20
- package/.bkit/templates/context/bkit-serena.md +8 -7
- package/.bkit/templates/context/bkit-stripe.md +14 -13
- package/.bkit/templates/context/bkit-supabase.md +16 -13
- package/.bkit/templates/context/bkit-tavily.md +14 -11
- package/.bkit/templates/context/bkit-vercel.md +27 -18
- package/.bkit/templates/docs/capabilities.md +15 -14
- package/.bkit/templates/scripts/ci/{check-accepted-divergences.mjs → bkit-check-accepted-divergences.mjs} +6 -3
- package/.bkit/templates/scripts/ci/{check-accepted-divergences.test.mjs → bkit-check-accepted-divergences.test.mjs} +3 -3
- package/.bkit/templates/scripts/ci/{check-capstone.mjs → bkit-check-capstone.mjs} +2 -2
- package/.bkit/templates/scripts/ci/{check-capstone.test.mjs → bkit-check-capstone.test.mjs} +4 -4
- package/.bkit/templates/scripts/ci/{check-dependency-audit.mjs → bkit-check-dependency-audit.mjs} +103 -18
- package/.bkit/templates/scripts/ci/{check-dependency-audit.test.mjs → bkit-check-dependency-audit.test.mjs} +31 -3
- package/.bkit/templates/scripts/ci/bkit-machine-lock.sh +387 -0
- package/.bkit/templates/scripts/ci/bkit-test-awake.mjs +75 -0
- package/.bkit/templates/scripts/ci/bkit-test-awake.test.mjs +160 -0
- package/.bkit/templates/scripts/ci/lanes/{resolve-push-base.mjs → bkit-resolve-push-base.mjs} +3 -3
- package/.bkit/templates/scripts/ci/lanes/{resolve-push-base.test.mjs → bkit-resolve-push-base.test.mjs} +4 -4
- package/.bkit/templates/scripts/cleanup/bkit-disk-prune.mjs +9 -1
- package/.bkit/templates/scripts/graphify/bkit-graph-drift.py +1 -1
- package/.bkit/templates/scripts/graphify/bkit-graph-eager.py +3 -3
- package/.bkit/templates/scripts/graphify/bkit-graph-embed.py +63 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-imports.py +2 -2
- package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +69 -18
- package/.bkit/templates/scripts/graphify/bkit-graph-repair.py +3 -3
- package/.bkit/templates/scripts/graphify/bkit-graph-surface.py +1 -1
- package/.bkit/templates/scripts/graphify/bkit-graphify-graphml.py +1 -1
- package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +197 -126
- package/.bkit/templates/scripts/graphify/bkit-graphify.sh +64 -41
- package/.bkit/templates/scripts/slop/bkit-slop-type-suppression.mjs +23 -7
- package/.bkit/templates/slop-scan.config.json +9 -2
- package/CHANGELOG.md +119 -0
- package/README.md +250 -76
- package/dist/checks/after/auth.js +36 -33
- package/dist/checks/after/ci-yml.js +52 -2
- package/dist/checks/after/index.js +12 -4
- package/dist/checks/after/tools.js +73 -33
- package/dist/checks/before/context-fetch.js +218 -33
- package/dist/checks/before/env.js +1 -1
- package/dist/checks/before/index.js +6 -2
- package/dist/checks/before/repo.js +35 -1
- package/dist/checks/status-holes.js +739 -114
- package/dist/checks/tips/catalogue.js +59 -17
- package/dist/checks/tips/detect.js +30 -0
- package/dist/checks/tips/index.js +48 -6
- package/dist/cli.js +222 -84
- package/dist/commands/analysis.js +77 -53
- package/dist/commands/ci/ci.js +302 -25
- package/dist/commands/ci/pins.js +142 -0
- package/dist/commands/ci/push-gate.js +194 -0
- package/dist/commands/install/uninstall.js +23 -27
- package/dist/commands/install/upgrade.js +21 -11
- package/dist/commands/land.js +126 -10
- package/dist/commands/lib.js +244 -5
- package/dist/commands/registry.js +6 -2
- package/dist/commands/setup/setup.js +1 -0
- package/dist/commands/stats.js +69 -30
- package/dist/commands/workflow/branches.js +1232 -111
- package/dist/commands/workflow/challenge.js +90 -37
- package/dist/commands/workflow/completeness.js +97 -0
- package/dist/commands/workflow/context.js +371 -51
- package/dist/commands/workflow/counters.js +206 -40
- package/dist/commands/workflow/decisions.js +60 -17
- package/dist/commands/workflow/disk.js +213 -55
- package/dist/commands/workflow/fids.js +18 -1
- package/dist/commands/workflow/issues.js +6 -0
- package/dist/commands/workflow/ledgers.js +372 -21
- package/dist/commands/workflow/locks.js +2 -0
- package/dist/commands/workflow/plan-blocks.js +78 -14
- package/dist/commands/workflow/plans.js +205 -0
- package/dist/commands/workflow/prs.js +12 -3
- package/dist/commands/workflow/repo.js +6 -0
- package/dist/commands/workflow/roadmap.js +50 -17
- package/dist/commands/workflow/run-facts.js +23 -28
- package/dist/commands/workflow/runs.js +530 -33
- package/dist/commands/workflow/runtime.js +3 -0
- package/dist/commands/workflow/skills.js +1 -0
- package/dist/commands/workflow/status.js +166 -19
- package/dist/commands/workflow/step-table.js +61 -29
- package/dist/commands/workflow/steps.js +542 -26
- package/dist/commands/workflow/summary-findings.js +117 -0
- package/dist/commands/workflow/summary.js +154 -41
- package/dist/commands/workflow/tasks.js +378 -0
- package/dist/commands/workflow/test-blocks.js +231 -0
- package/dist/commands/workflow/tests-changed.js +172 -0
- package/dist/commands/workflow/tests.js +1013 -321
- package/dist/commands/workflow/workflows.js +191 -38
- package/dist/commands/workflow/worktrees.js +310 -42
- package/dist/install/cloud-env.js +233 -99
- package/dist/install/context-ci-workflow.js +85 -0
- package/dist/install/manifest.js +57 -12
- package/dist/install/modules/antigravity.js +3 -2
- package/dist/install/modules/cloud.js +3 -3
- package/dist/install/modules/codex.js +12 -2
- package/dist/install/modules/core.js +851 -53
- package/dist/install/modules/cursor.js +6 -6
- package/dist/install/modules/opencode.js +11 -5
- package/dist/install/template-notes.js +116 -0
- package/dist/install/version-file.js +3 -2
- package/dist/ledgers/compact.js +87 -0
- package/dist/ledgers/journal.js +233 -0
- package/dist/ledgers/status.js +115 -5
- package/dist/ledgers/telemetry.js +121 -17
- package/dist/render/hosts.js +100 -14
- package/dist/shared/bkit-latest.js +26 -4
- package/dist/shared/dep-updater.js +49 -0
- package/dist/shared/egress.js +1 -1
- package/dist/shared/package-manager.js +6 -0
- package/dist/shared/settings.js +59 -10
- package/dist/shared/timeouts.js +2 -0
- package/dist/tools/cli-doc.js +97 -0
- package/dist/tools/grammar-density.js +1 -1
- package/dist/tools/instructions-sources.js +15 -16
- package/dist/tools/instructions.js +83 -39
- package/package.json +58 -42
- package/.bkit/core/.bkit/lite.md +0 -73
- package/.bkit/core/engine/commands/workflow/workstreams.ts +0 -172
- package/.bkit/core/prompts/bkit-build-plan-execute.md +0 -124
- package/.bkit/templates/scripts/ci/bkit-local-stack-lock.sh +0 -194
- package/dist/commands/workflow/workstreams.js +0 -149
- /package/.bkit/templates/.vale/styles/{House → Bkit}/Filler.yml +0 -0
- /package/.bkit/templates/.vale/styles/{House → Bkit}/Hedging.yml +0 -0
- /package/.bkit/templates/.vale/styles/{House → Bkit}/LLMSlop.yml +0 -0
- /package/.bkit/templates/.vale/styles/{House → Bkit}/Verbose.yml +0 -0
- /package/.bkit/templates/scripts/ci/{accepted-advisories.json → bkit-accepted-advisories.json} +0 -0
- /package/.bkit/templates/scripts/ci/{accepted-divergences.json → bkit-accepted-divergences.json} +0 -0
- /package/.bkit/templates/scripts/launchd/{launchd.env.example → bkit-launchd.env.example} +0 -0
- /package/.bkit/templates/scripts/launchd/{ai.bkit.launchd.plist → bkit-launchd.plist} +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
// install/cloud-env.ts — resolve a copy-paste-ready
|
|
2
|
-
//
|
|
1
|
+
// install/cloud-env.ts — resolve a copy-paste-ready cloud env-var block by *following
|
|
2
|
+
// the consumer's `.envrc`*.
|
|
3
3
|
//
|
|
4
|
-
// The generated `.claude/bkit-cloud.md`
|
|
5
|
-
//
|
|
4
|
+
// The generated `.claude/bkit-cloud.md`, `.cursor/bkit-cloud.md` and
|
|
5
|
+
// `.codex/bkit-cloud.md` (see the claude / cursor / codex host modules) inline REAL
|
|
6
|
+
// SECRET VALUES so they are gitignored + chmod 600 and never committed. All three carry
|
|
7
|
+
// the same env block whatever the issue tracker. This module owns the
|
|
6
8
|
// stack-agnostic resolution: it reads whatever dotenv files the repo's `.envrc`
|
|
7
9
|
// sources, honours the `.envrc` `unset` lines, and drops session-hijack keys.
|
|
8
10
|
// bkit hardcodes NO stack-specific key lists — the stack knowledge lives in the
|
|
@@ -15,49 +17,36 @@ import * as path from "node:path";
|
|
|
15
17
|
import { readJsonFile } from "../shared/json.js";
|
|
16
18
|
import { getSharedRoot } from "../shared/package-roots.js";
|
|
17
19
|
import { applyTokens } from "./placeholders.js";
|
|
18
|
-
import { BKIT_EGRESS_SOURCES } from "../shared/egress.js";
|
|
20
|
+
import { BKIT_EGRESS_SOURCES, MULTI_TENANT_APEXES } from "../shared/egress.js";
|
|
19
21
|
import { sha256 } from "./version-file.js";
|
|
20
22
|
// Consumer-relative paths of the generated docs. Shared so the upgrade template walk
|
|
21
23
|
// (commands/install/install.ts) can exclude them — they are generated OUTPUT files, never
|
|
22
24
|
// templates to reconcile. One per cloud host (Claude Code on the web / Cursor
|
|
23
|
-
// Background Agents);
|
|
25
|
+
// Background Agents / Codex Cloud); all inline resolved secrets, all gitignored + chmod 600.
|
|
24
26
|
export const CLAUDE_CLOUD_RELPATH = path.join(".claude", "bkit-cloud.md");
|
|
25
27
|
export const CURSOR_CLOUD_RELPATH = path.join(".cursor", "bkit-cloud.md");
|
|
28
|
+
export const CODEX_CLOUD_RELPATH = path.join(".codex", "bkit-cloud.md");
|
|
26
29
|
// Session-hijack keys: exporting these into a cloud env redirects Claude Code's
|
|
27
30
|
// OWN model calls onto API-key billing instead of the user's subscription
|
|
28
|
-
// (`.bkit/cloud.md` §
|
|
31
|
+
// (`.bkit/cloud.md` § Tokens by session type). Always dropped from the paste block.
|
|
29
32
|
export const SESSION_HIJACK_KEYS = [
|
|
30
33
|
"ANTHROPIC_API_KEY",
|
|
31
34
|
"BKIT_ANTHROPIC_API_KEY",
|
|
32
35
|
"ANTHROPIC_AUTH_TOKEN",
|
|
33
36
|
];
|
|
34
|
-
// bkit baseline env-var NAMES every
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
+
// bkit baseline env-var NAMES every cloud environment needs, whatever the tracker:
|
|
38
|
+
// `gh` and the GitHub MCP server read BKIT_GH_TOKEN on every host. Emitted as a
|
|
39
|
+
// placeholder ONLY when absent from the resolved `.envrc` set — a present value keeps
|
|
40
|
+
// its real resolved value. Tracker keys (BKIT_LINEAR_API_KEY, BKIT_JIRA_API_KEY) are
|
|
41
|
+
// never baseline: a consumer on that tracker already sets them in `.envrc`, so they
|
|
42
|
+
// arrive with the resolved set. One baseline for every host keeps the generated docs
|
|
43
|
+
// describing the SAME cloud environment — just different mechanics.
|
|
37
44
|
const BASELINE_TOKEN_PLACEHOLDERS = [
|
|
38
45
|
[
|
|
39
46
|
"BKIT_GH_TOKEN",
|
|
40
47
|
"<PAT — fine-grained one owner / classic across owners; see .bkit/cloud.md § BKIT_GH_TOKEN token permissions>",
|
|
41
48
|
],
|
|
42
49
|
];
|
|
43
|
-
// Claude Code on the web: GitHub tracker.
|
|
44
|
-
export const CLAUDE_CLOUD_POLICY = {
|
|
45
|
-
baseline: BASELINE_TOKEN_PLACEHOLDERS,
|
|
46
|
-
};
|
|
47
|
-
// Cursor Background Agents: `BKIT_LINEAR_API_KEY` prepended for the Linear tracker
|
|
48
|
-
// (bkit-preflight.sh calls the Linear GraphQL API and hard-fails without it); GitHub
|
|
49
|
-
// tracker uses the same GH baseline as Claude.
|
|
50
|
-
const CURSOR_LINEAR_PLACEHOLDER = [
|
|
51
|
-
"BKIT_LINEAR_API_KEY",
|
|
52
|
-
"<Linear personal API key — https://linear.app/settings/api>",
|
|
53
|
-
];
|
|
54
|
-
export function cursorCloudPolicy(tracker) {
|
|
55
|
-
return {
|
|
56
|
-
baseline: tracker === "linear"
|
|
57
|
-
? [CURSOR_LINEAR_PLACEHOLDER, ...BASELINE_TOKEN_PLACEHOLDERS]
|
|
58
|
-
: BASELINE_TOKEN_PLACEHOLDERS,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
50
|
/** Strip one layer of matching surrounding single/double quotes. */
|
|
62
51
|
function stripQuotes(v) {
|
|
63
52
|
const t = v.trim();
|
|
@@ -117,7 +106,7 @@ export function parseDotenv(content) {
|
|
|
117
106
|
* Applies `.envrc` unsets, then drops session-hijack keys. Returns empty when no
|
|
118
107
|
* `.envrc` exists — the caller still emits a usable placeholder doc.
|
|
119
108
|
*/
|
|
120
|
-
export function resolveCloudEnvVars(cwd
|
|
109
|
+
export function resolveCloudEnvVars(cwd) {
|
|
121
110
|
const res = {
|
|
122
111
|
included: [],
|
|
123
112
|
unset: [],
|
|
@@ -171,7 +160,7 @@ export function resolveCloudEnvVars(cwd, policy = CLAUDE_CLOUD_POLICY) {
|
|
|
171
160
|
}
|
|
172
161
|
// Baseline names absent from the resolved set → emitted as placeholders.
|
|
173
162
|
const present = new Set(res.included.map(([k]) => k));
|
|
174
|
-
for (const [name] of
|
|
163
|
+
for (const [name] of BASELINE_TOKEN_PLACEHOLDERS) {
|
|
175
164
|
if (!present.has(name))
|
|
176
165
|
res.placeholders.push(name);
|
|
177
166
|
}
|
|
@@ -181,11 +170,11 @@ export function resolveCloudEnvVars(cwd, policy = CLAUDE_CLOUD_POLICY) {
|
|
|
181
170
|
* Render the `.env`-format paste block: resolved KEY=value lines, then placeholder
|
|
182
171
|
* lines for any absent baseline token.
|
|
183
172
|
*/
|
|
184
|
-
export function renderCloudEnvBlock(res
|
|
173
|
+
export function renderCloudEnvBlock(res) {
|
|
185
174
|
const lines = [];
|
|
186
175
|
for (const [k, v] of res.included)
|
|
187
176
|
lines.push(`${k}=${v}`);
|
|
188
|
-
for (const [name, placeholder] of
|
|
177
|
+
for (const [name, placeholder] of BASELINE_TOKEN_PLACEHOLDERS) {
|
|
189
178
|
if (res.placeholders.includes(name))
|
|
190
179
|
lines.push(`${name}=${placeholder}`);
|
|
191
180
|
}
|
|
@@ -244,11 +233,19 @@ export function renderCorepackLine(cwd) {
|
|
|
244
233
|
* enabled below `<!-- bkit:end -->` in `.agents/context.md`. Stack-agnostic: bkit
|
|
245
234
|
* hardcodes no CLI names — the install recipe lives in the consumer's context.md,
|
|
246
235
|
* co-located with the fetch block that needs the CLI. `bkit context list-blocks` returns
|
|
247
|
-
* the same list as `provision`,
|
|
248
|
-
*
|
|
249
|
-
* string per block (bash body).
|
|
236
|
+
* the same list as `provision`, so the web setup-script snapshot and the per-session
|
|
237
|
+
* hook provision the same CLIs. Returns one string per block (bash body).
|
|
250
238
|
*/
|
|
251
239
|
export function extractContextFetchProvisionRecipes(cwd) {
|
|
240
|
+
return extractContextFetchProvisionBlocks(cwd).map((b) => b.body);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* {@link extractContextFetchProvisionRecipes} with each block's name — the word after
|
|
244
|
+
* `context-fetch:provision` in its opening marker, limited to `[A-Za-z0-9._-]` so it is
|
|
245
|
+
* safe inside a quoted shell string; "" when the marker names none.
|
|
246
|
+
* {@link renderCloudContextFetchProvision} reports a failing recipe by this name.
|
|
247
|
+
*/
|
|
248
|
+
export function extractContextFetchProvisionBlocks(cwd) {
|
|
252
249
|
const filePath = path.join(cwd, ".agents", "context.md");
|
|
253
250
|
if (!fs.existsSync(filePath))
|
|
254
251
|
return [];
|
|
@@ -258,11 +255,14 @@ export function extractContextFetchProvisionRecipes(cwd) {
|
|
|
258
255
|
return [];
|
|
259
256
|
const consumer = content.slice(endIdx);
|
|
260
257
|
const recipes = [];
|
|
258
|
+
let name = "";
|
|
261
259
|
let cur = null;
|
|
262
260
|
let inProv = false;
|
|
263
261
|
let inFence = false;
|
|
264
262
|
for (const line of consumer.split("\n")) {
|
|
265
|
-
|
|
263
|
+
const opening = /^<!-- context-fetch:provision\b\s*([A-Za-z0-9][A-Za-z0-9._-]*)?/.exec(line);
|
|
264
|
+
if (opening) {
|
|
265
|
+
name = opening[1] ?? "";
|
|
266
266
|
inProv = true;
|
|
267
267
|
inFence = false;
|
|
268
268
|
cur = [];
|
|
@@ -270,7 +270,7 @@ export function extractContextFetchProvisionRecipes(cwd) {
|
|
|
270
270
|
}
|
|
271
271
|
if (/^<!-- context-fetch:(start|end|none)/.test(line)) {
|
|
272
272
|
if (inProv && cur && cur.length > 0)
|
|
273
|
-
recipes.push(cur.join("\n"));
|
|
273
|
+
recipes.push({ name, body: cur.join("\n") });
|
|
274
274
|
inProv = false;
|
|
275
275
|
inFence = false;
|
|
276
276
|
cur = null;
|
|
@@ -319,30 +319,70 @@ export function renderCloudCacheBust(cwd, today) {
|
|
|
319
319
|
const CLOUD_PNPM_GLOBAL_PATH_SETUP = "# pnpm refuses `add -g` unless its global-bin dir is on PATH (corepack pnpm skips `pnpm setup`).\n" +
|
|
320
320
|
'export PNPM_HOME="${PNPM_HOME:-$HOME/.local/share/pnpm}"\n' +
|
|
321
321
|
'export PATH="$PNPM_HOME:$PNPM_HOME/bin:$PATH"';
|
|
322
|
+
/** Where a cloud environment lists the provision recipes that failed in it, from the repo root. */
|
|
323
|
+
export const UNAVAILABLE_RELPATH = ".bkit/.unavailable";
|
|
324
|
+
/**
|
|
325
|
+
* Runs one provision recipe (a function named in `$2`) in its own `set -e` subshell. Its
|
|
326
|
+
* stdout goes to stderr, so a caller's stdout carries only its own report. A failure is
|
|
327
|
+
* named on stderr with the recipe's last error line, added to `$BKIT_UNAVAILABLE`, and
|
|
328
|
+
* appended to `$BKIT_UNAVAILABLE_FILE` as `<name>: <reason>` when that is set. The
|
|
329
|
+
* subshell is never the left side of `||`: bash ignores `set -e` there, so only the
|
|
330
|
+
* recipe's last command would count.
|
|
331
|
+
*/
|
|
332
|
+
const CLOUD_PROVISION_RUNNER = "bkit_provision() {\n" +
|
|
333
|
+
" bkit_err=$(mktemp)\n" +
|
|
334
|
+
' ( set -e; "$2" ) >&2 2>"$bkit_err"\n' +
|
|
335
|
+
" bkit_rc=$?\n" +
|
|
336
|
+
' cat "$bkit_err" >&2\n' +
|
|
337
|
+
' if [ "$bkit_rc" -ne 0 ]; then\n' +
|
|
338
|
+
" bkit_why=$(grep -v '^[[:space:]]*$' \"$bkit_err\" | tail -n 1 | cut -c 1-300)\n" +
|
|
339
|
+
' [ -n "$bkit_why" ] || bkit_why="exit $bkit_rc"\n' +
|
|
340
|
+
" echo \"[cloud-setup] provision '$1' failed (non-blocking): $bkit_why\" >&2\n" +
|
|
341
|
+
' BKIT_UNAVAILABLE="${BKIT_UNAVAILABLE:+$BKIT_UNAVAILABLE, }$1"\n' +
|
|
342
|
+
' [ -z "$BKIT_UNAVAILABLE_FILE" ] || printf \'%s: %s\\n\' "$1" "$bkit_why" >> "$BKIT_UNAVAILABLE_FILE"\n' +
|
|
343
|
+
" fi\n" +
|
|
344
|
+
' rm -f "$bkit_err"\n' +
|
|
345
|
+
"}";
|
|
322
346
|
/**
|
|
323
347
|
* Render the `@@CLOUD_CONTEXT_FETCH_PROVISION@@` setup-script region: the consumer's
|
|
324
348
|
* `context-fetch:provision` recipes, or "" when none are enabled. Placed AFTER the
|
|
325
|
-
* corepack line in the template so `pnpm add -g …` recipes have pnpm available.
|
|
349
|
+
* corepack line in the template so `pnpm add -g …` recipes have pnpm available. `bkit
|
|
350
|
+
* context provision` runs the same region, so every cloud platform runs the recipes one way.
|
|
326
351
|
*
|
|
327
|
-
*
|
|
328
|
-
* `
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
352
|
+
* The setup script is `set -euo pipefail`, so a bare failing recipe (e.g. a heavy
|
|
353
|
+
* `curl | bash` CLI installer that trips over a missing base-image dep) would abort the
|
|
354
|
+
* whole snapshot build and discard every CLI provisioned before it. So errexit is off
|
|
355
|
+
* around the region and back on after it, and each recipe runs on its own through
|
|
356
|
+
* {@link CLOUD_PROVISION_RUNNER}: a failing command stops only its own recipe.
|
|
357
|
+
*
|
|
358
|
+
* With `$REPO_ROOT` set, the region rewrites {@link UNAVAILABLE_RELPATH} under it
|
|
359
|
+
* (removed when nothing failed) for the cloud agent to read. The Claude setup script runs
|
|
360
|
+
* before the clone, with no `$REPO_ROOT`; there the session hook writes the file. The
|
|
361
|
+
* region leaves `$BKIT_UNAVAILABLE` set for the script's closing line.
|
|
333
362
|
*/
|
|
334
363
|
export function renderCloudContextFetchProvision(cwd) {
|
|
335
|
-
const recipes =
|
|
364
|
+
const recipes = extractContextFetchProvisionBlocks(cwd)
|
|
365
|
+
.map(({ name, body }, i) => ({ label: name === "" ? `#${i + 1}` : name, body }))
|
|
366
|
+
.filter(({ body }) => body.trim() !== "");
|
|
336
367
|
if (recipes.length === 0)
|
|
337
368
|
return "";
|
|
338
|
-
|
|
369
|
+
const runs = recipes.map(({ label, body }, i) => `bkit_provision_${i + 1}() {\n${body}\n}\nbkit_provision '${label}' bkit_provision_${i + 1}`);
|
|
370
|
+
return ("# context-fetch provision recipes (from .agents/context.md) — each runs on its own. A\n" +
|
|
371
|
+
"# failing one is named with its last error line and never stops this script.\n" +
|
|
339
372
|
CLOUD_PNPM_GLOBAL_PATH_SETUP +
|
|
373
|
+
"\nset +e\n" +
|
|
374
|
+
'BKIT_UNAVAILABLE=""\n' +
|
|
375
|
+
`BKIT_UNAVAILABLE_FILE="\${REPO_ROOT:+$REPO_ROOT/${UNAVAILABLE_RELPATH}}"\n` +
|
|
376
|
+
'[ -z "$BKIT_UNAVAILABLE_FILE" ] || { mkdir -p "${BKIT_UNAVAILABLE_FILE%/*}"; : > "$BKIT_UNAVAILABLE_FILE"; }\n' +
|
|
377
|
+
CLOUD_PROVISION_RUNNER +
|
|
340
378
|
"\n" +
|
|
341
|
-
"
|
|
342
|
-
"
|
|
343
|
-
|
|
344
|
-
"\n" +
|
|
345
|
-
'
|
|
379
|
+
runs.join("\n") +
|
|
380
|
+
'\nif [ -n "$BKIT_UNAVAILABLE" ]; then\n' +
|
|
381
|
+
' echo "[cloud-setup] UNAVAILABLE in this environment: $BKIT_UNAVAILABLE. Their setup failed: treat them as absent and do not retry the install." >&2\n' +
|
|
382
|
+
"else\n" +
|
|
383
|
+
' [ -z "$BKIT_UNAVAILABLE_FILE" ] || rm -f "$BKIT_UNAVAILABLE_FILE"\n' +
|
|
384
|
+
"fi\n" +
|
|
385
|
+
"set -e");
|
|
346
386
|
}
|
|
347
387
|
/**
|
|
348
388
|
* Entries of every `<!-- {tag}:start --> … <!-- {tag}:end -->` list block BELOW
|
|
@@ -537,6 +577,21 @@ export function egressFingerprint() {
|
|
|
537
577
|
].sort();
|
|
538
578
|
return sha256(derived.join("\n")).slice(0, 8);
|
|
539
579
|
}
|
|
580
|
+
/**
|
|
581
|
+
* The "where these came from" clause of a network list's count note. A declared entry
|
|
582
|
+
* bkit already ships adds nothing to the list, so it counts once, as shipped, and the
|
|
583
|
+
* clause names how many declared entries that was. `declared` and `shipped` are in the
|
|
584
|
+
* list's own unit: apex bases for the Claude list, exact hosts for Cursor and Codex.
|
|
585
|
+
*/
|
|
586
|
+
function networkSourceCounts(declared, shipped) {
|
|
587
|
+
const shippedSet = new Set(shipped);
|
|
588
|
+
const declaredSet = new Set(declared);
|
|
589
|
+
const added = [...declaredSet].filter((d) => !shippedSet.has(d)).length;
|
|
590
|
+
const overlap = declaredSet.size - added;
|
|
591
|
+
return (`${shippedSet.size} from bkit's shipped egress registry and ${added} more from ` +
|
|
592
|
+
"`allowed-domains` in `.agents/context.md`" +
|
|
593
|
+
(overlap > 0 ? ` (${overlap} of its ${declaredSet.size} entries already shipped)` : ""));
|
|
594
|
+
}
|
|
540
595
|
/**
|
|
541
596
|
* Render the `@@CLOUD_NETWORK_ALLOWLIST@@` region — the whole `## Network access`
|
|
542
597
|
* body. Always emits a **Custom** paste block: the list is the derived shipped bases
|
|
@@ -547,7 +602,6 @@ export function egressFingerprint() {
|
|
|
547
602
|
export function renderCloudNetworkAllowlist(cwd) {
|
|
548
603
|
const declared = extractAllowedDomains(cwd);
|
|
549
604
|
const domains = resolveNetworkAllowlist(cwd);
|
|
550
|
-
const derivedCount = BKIT_SHIPPED_NETWORK_DOMAINS.length;
|
|
551
605
|
const declaredNote = declared.length === 0
|
|
552
606
|
? "\n\n_No `allowed-domains` block is declared in `.agents/context.md`. The list above is\n" +
|
|
553
607
|
"bkit's own shipped hosts. If you run cloud `/bkit-debug` or e2e against a deployment,\n" +
|
|
@@ -560,9 +614,9 @@ export function renderCloudNetworkAllowlist(cwd) {
|
|
|
560
614
|
"```text\n" +
|
|
561
615
|
domains.join("\n") +
|
|
562
616
|
"\n```\n\n" +
|
|
563
|
-
`_${domains.length} entries
|
|
564
|
-
|
|
565
|
-
"
|
|
617
|
+
`_${domains.length} entries (${domains.length / 2} domains, each as apex + \`*.\` wildcard): ` +
|
|
618
|
+
networkSourceCounts(networkAllowlistBases(declared), BKIT_SHIPPED_NETWORK_DOMAINS) +
|
|
619
|
+
". Derived set fingerprint `" +
|
|
566
620
|
egressFingerprint() +
|
|
567
621
|
"`._" +
|
|
568
622
|
declaredNote +
|
|
@@ -665,6 +719,23 @@ export function renderCloudUserSettings(cwd) {
|
|
|
665
719
|
`jq --argjson e '${env}' '.autoMode.environment //= $e' \\\n` +
|
|
666
720
|
' "$CLAUDE_SETTINGS" > "$CLAUDE_SETTINGS.tmp" && mv "$CLAUDE_SETTINGS.tmp" "$CLAUDE_SETTINGS"');
|
|
667
721
|
}
|
|
722
|
+
/** `# bkit-toolchain:start|end` marker lines in the Claude template's setup script. */
|
|
723
|
+
const TOOLCHAIN_MARKER_LINE = /^# bkit-toolchain:(?:start|end)\n/gm;
|
|
724
|
+
/**
|
|
725
|
+
* The pinned toolchain installs (Node, vale, gh, jq + the PATH lead) from the Claude
|
|
726
|
+
* template's setup script — the region between the `# bkit-toolchain:start` / `:end`
|
|
727
|
+
* markers, markers stripped. The pins live once, in `.bkit/shared/.claude/bkit-cloud.md`
|
|
728
|
+
* (where Renovate's regex manager bumps them); every other pasted install script inlines
|
|
729
|
+
* this slice so the cloud toolchains never diverge. Throws when the markers are absent:
|
|
730
|
+
* a Codex doc without its toolchain is a broken paste, not an empty one.
|
|
731
|
+
*/
|
|
732
|
+
export function extractCloudToolchainScript() {
|
|
733
|
+
const src = fs.readFileSync(path.join(getSharedRoot(), ".claude", "bkit-cloud.md"), "utf-8");
|
|
734
|
+
const m = /^# bkit-toolchain:start\n([\s\S]*?)^# bkit-toolchain:end$/m.exec(src);
|
|
735
|
+
if (!m)
|
|
736
|
+
throw new Error(".claude/bkit-cloud.md template lacks the bkit-toolchain markers");
|
|
737
|
+
return m[1].trim();
|
|
738
|
+
}
|
|
668
739
|
/**
|
|
669
740
|
* Generate `.claude/bkit-cloud.md` — a copy-paste-ready Claude Code on the web setup doc
|
|
670
741
|
* with the env-var block resolved to REAL VALUES from the consumer's `.envrc`.
|
|
@@ -689,6 +760,7 @@ export function writeClaudeCloudDoc(cwd, tokens) {
|
|
|
689
760
|
// Function-form replacers: resolved secret values may contain `$`, which a string
|
|
690
761
|
// replacement would interpret ($&, $1, …).
|
|
691
762
|
const content = applyTokens(fs.readFileSync(src, "utf-8"), tokens)
|
|
763
|
+
.replace(TOOLCHAIN_MARKER_LINE, "")
|
|
692
764
|
.replace(/@@CLOUD_CACHE_BUST@@/g, () => renderCloudCacheBust(cwd, today))
|
|
693
765
|
.replace(/@@CLOUD_NETWORK_ALLOWLIST@@/g, () => renderCloudNetworkAllowlist(cwd))
|
|
694
766
|
.replace(/@@CLOUD_WORKSPACE_TRUST@@/g, () => renderCloudWorkspaceTrust(cwd))
|
|
@@ -705,58 +777,71 @@ export function writeClaudeCloudDoc(cwd, tokens) {
|
|
|
705
777
|
}
|
|
706
778
|
/**
|
|
707
779
|
* Render the `@@CURSOR_CONTEXT_FETCH@@` region of `.cursor/bkit-cloud.md`: the consumer's
|
|
708
|
-
* `context-fetch:provision` recipes
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
* the
|
|
713
|
-
* already idempotent (`command -v X || pnpm add -g X`), so they are safe to re-run on
|
|
714
|
-
* every snapshot build. Reuses the SAME extractor as the Claude path so the two clouds
|
|
715
|
-
* never diverge on which CLIs they provision.
|
|
780
|
+
* `context-fetch:provision` recipes by name, or "" when none are enabled. On Claude and
|
|
781
|
+
* Codex they are inlined into the pasted script ({@link renderCloudContextFetchProvision});
|
|
782
|
+
* Cursor has no pasted script, so the `install` command in `.cursor/environment.json` runs
|
|
783
|
+
* `bkit context provision`, which runs that same region. The section names the recipes and
|
|
784
|
+
* the line a copy of `environment.json` without it needs.
|
|
716
785
|
*/
|
|
717
786
|
export function renderCursorContextFetchProvision(cwd) {
|
|
718
|
-
const
|
|
787
|
+
const blocks = extractContextFetchProvisionBlocks(cwd);
|
|
719
788
|
// Empty → "" and the template's sentinel line collapses to a single blank between
|
|
720
789
|
// sections; non-empty → a self-contained section with its own leading/trailing blank.
|
|
721
|
-
if (
|
|
790
|
+
if (blocks.length === 0)
|
|
722
791
|
return "";
|
|
792
|
+
const names = blocks.map(({ name }, i) => `\`${name === "" ? `#${i + 1}` : name}\``);
|
|
723
793
|
return ("\n## Context-fetch CLIs (parity with the Claude setup script)\n\n" +
|
|
724
|
-
|
|
725
|
-
"
|
|
726
|
-
"`install
|
|
794
|
+
`Your \`.agents/context.md\` declares these provision recipes: ${names.join(", ")}. The\n` +
|
|
795
|
+
"`install` command in `.cursor/environment.json` runs them each snapshot build, after\n" +
|
|
796
|
+
"`pnpm install`, by ending with:\n\n" +
|
|
727
797
|
"```bash\n" +
|
|
728
|
-
|
|
729
|
-
"\n
|
|
798
|
+
"&& pnpm exec bkit context provision\n" +
|
|
799
|
+
"```\n\n" +
|
|
800
|
+
"A recipe that fails is named in the install log and listed in `.bkit/.unavailable`\n" +
|
|
801
|
+
"for the agent; the install still succeeds.\n");
|
|
730
802
|
}
|
|
731
803
|
/**
|
|
732
|
-
*
|
|
733
|
-
*
|
|
734
|
-
*
|
|
735
|
-
*
|
|
736
|
-
*
|
|
737
|
-
*
|
|
738
|
-
*
|
|
804
|
+
* The Cursor and Codex allowlist: the fenced paste block and the notes under it. bkit's
|
|
805
|
+
* shipped HOSTS are listed exactly; each declared `allowed-domains` entry bkit does not
|
|
806
|
+
* already ship is listed as the domain and its `*.` wildcard, like the Claude side, since
|
|
807
|
+
* the CLIs and APIs a consumer declares call subdomains (`api.vercel.com` under
|
|
808
|
+
* `vercel.com`). A declared {@link MULTI_TENANT_APEXES} entry is widened the same way,
|
|
809
|
+
* with a note that its wildcard reaches every tenant on the platform, the exfiltration
|
|
810
|
+
* path Cursor's docs warn about.
|
|
739
811
|
*/
|
|
740
|
-
|
|
812
|
+
function renderWidenedNetworkList(cwd) {
|
|
741
813
|
const declared = extractAllowedDomains(cwd);
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
const entries =
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
814
|
+
const names = [...new Set([...BKIT_SHIPPED_NETWORK_HOSTS, ...declared])].sort();
|
|
815
|
+
const shipped = new Set(BKIT_SHIPPED_NETWORK_HOSTS);
|
|
816
|
+
const widened = (n) => declared.includes(n) && !shipped.has(n);
|
|
817
|
+
const entries = names.flatMap((n) => (widened(n) ? [n, `*.${n}`] : [n]));
|
|
818
|
+
const shared = [...new Set(declared)].filter((d) => MULTI_TENANT_APEXES.includes(d));
|
|
819
|
+
const sharedNote = shared.length === 0
|
|
820
|
+
? ""
|
|
821
|
+
: `\n\n${shared.map((d) => `\`${d}\``).join(", ")}: shared by many tenants, so the ` +
|
|
822
|
+
"`*.` wildcard reaches every tenant on it. To narrow it, declare the exact hosts you " +
|
|
823
|
+
`call there instead (e.g. \`<name>.${shared[0]}\`).`;
|
|
824
|
+
return ("```text\n" +
|
|
750
825
|
entries.join("\n") +
|
|
751
826
|
"\n```\n\n" +
|
|
752
|
-
`_${entries.length}
|
|
753
|
-
|
|
754
|
-
|
|
827
|
+
`_${entries.length} entries (${names.length} hosts and domains, each declared domain ` +
|
|
828
|
+
"also as a `*.` wildcard): " +
|
|
829
|
+
networkSourceCounts(declared, BKIT_SHIPPED_NETWORK_HOSTS) +
|
|
830
|
+
". Derived set fingerprint `" +
|
|
755
831
|
egressFingerprint() +
|
|
756
|
-
"`._
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
832
|
+
"`._" +
|
|
833
|
+
sharedNote);
|
|
834
|
+
}
|
|
835
|
+
/**
|
|
836
|
+
* Render the `@@CURSOR_NETWORK@@` region — Cursor Cloud Agents' egress allowlist
|
|
837
|
+
* (dashboard → Security: "Allow all" / "Default + allowlist" / "Allowlist only"), which
|
|
838
|
+
* takes `*.` patterns (Cursor's own default list is written that way).
|
|
839
|
+
*/
|
|
840
|
+
export function renderCursorNetworkAllowlist(cwd) {
|
|
841
|
+
return ("If your org runs Cloud Agents in **Allowlist only** / **Default + allowlist** mode\n" +
|
|
842
|
+
"(dashboard → **Security**), add these hosts so cloud `/bkit-debug` + e2e can reach\n" +
|
|
843
|
+
"bkit's own tooling and your app and log backends:\n\n" +
|
|
844
|
+
renderWidenedNetworkList(cwd));
|
|
760
845
|
}
|
|
761
846
|
/**
|
|
762
847
|
* Generate `.cursor/bkit-cloud.md` — the Cursor Cloud Agents analogue of
|
|
@@ -765,8 +850,8 @@ export function renderCursorNetworkAllowlist(cwd) {
|
|
|
765
850
|
* selector; on Cursor the toolchain lives in `.cursor/Dockerfile` + the per-snapshot
|
|
766
851
|
* `.cursor/environment.json` `install` (both committed, nothing to paste), so this doc
|
|
767
852
|
* is narrower: it resolves the **dashboard environment variables** to real values from
|
|
768
|
-
* the consumer's `.envrc` (
|
|
769
|
-
*
|
|
853
|
+
* the consumer's `.envrc` (the same tracker-independent set as the Claude doc) and
|
|
854
|
+
* surfaces any context-fetch CLIs for parity.
|
|
770
855
|
*
|
|
771
856
|
* Like `.claude/bkit-cloud.md` it is gitignored + chmod 600 and UNTRACKED (never pushed to
|
|
772
857
|
* any WriteSet / manifest / canonicalHashes) — its values are machine-local and
|
|
@@ -776,16 +861,15 @@ export function renderCursorNetworkAllowlist(cwd) {
|
|
|
776
861
|
* host being installed. Returns true when a file was written (false when the template
|
|
777
862
|
* is absent). Never logs the resolved values.
|
|
778
863
|
*/
|
|
779
|
-
export function writeCursorCloudDoc(cwd, tokens
|
|
864
|
+
export function writeCursorCloudDoc(cwd, tokens) {
|
|
780
865
|
const src = path.join(getSharedRoot(), ".cursor", "bkit-cloud.md");
|
|
781
866
|
if (!fs.existsSync(src))
|
|
782
867
|
return false;
|
|
783
|
-
const
|
|
784
|
-
const res = resolveCloudEnvVars(cwd, policy);
|
|
868
|
+
const res = resolveCloudEnvVars(cwd);
|
|
785
869
|
// Function-form replacers: resolved secret values may contain `$`, which a string
|
|
786
870
|
// replacement would interpret ($&, $1, …).
|
|
787
871
|
const content = applyTokens(fs.readFileSync(src, "utf-8"), tokens)
|
|
788
|
-
.replace(/@@CLOUD_ENV_VARS@@/g, () => renderCloudEnvBlock(res
|
|
872
|
+
.replace(/@@CLOUD_ENV_VARS@@/g, () => renderCloudEnvBlock(res))
|
|
789
873
|
.replace(/@@CLOUD_ENV_NOTES@@/g, () => renderCloudEnvNotes(res))
|
|
790
874
|
.replace(/@@CURSOR_NETWORK@@/g, () => renderCursorNetworkAllowlist(cwd))
|
|
791
875
|
.replace(/@@CURSOR_CONTEXT_FETCH@@/g, () => renderCursorContextFetchProvision(cwd));
|
|
@@ -795,3 +879,53 @@ export function writeCursorCloudDoc(cwd, tokens, tracker) {
|
|
|
795
879
|
fs.chmodSync(dst, 0o600);
|
|
796
880
|
return true;
|
|
797
881
|
}
|
|
882
|
+
/**
|
|
883
|
+
* Render the `@@CODEX_NETWORK@@` region — Codex Cloud's **Internet access** settings
|
|
884
|
+
* for the environment: the same list as the Cursor doc. Codex's docs describe
|
|
885
|
+
* **Additional allowed domains** as exact hosts (a root domain also allows `www.`) and
|
|
886
|
+
* say nothing of `*.`, so the note marks the wildcard entries untested and names the
|
|
887
|
+
* setting that gets past a host they miss.
|
|
888
|
+
*/
|
|
889
|
+
export function renderCodexNetworkAllowlist(cwd) {
|
|
890
|
+
return ("Under **Internet access**, keep **Enable package manager domains** on and paste these\n" +
|
|
891
|
+
"into **Additional allowed domains** (one per line) so cloud `/bkit-debug` + e2e can\n" +
|
|
892
|
+
"reach bkit's own tooling and your app and log backends:\n\n" +
|
|
893
|
+
renderWidenedNetworkList(cwd) +
|
|
894
|
+
"\n\nThe `*.` entries are untested on Codex: its docs list exact hosts only. If a task\n" +
|
|
895
|
+
"still cannot reach a subdomain, switch to **Enable all public internet access** (opens\n" +
|
|
896
|
+
"all egress) or add that exact host.");
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* Generate `.codex/bkit-cloud.md` — the Codex Cloud analogue of `.claude/bkit-cloud.md`:
|
|
900
|
+
* the SAME bkit cloud environment, built by Codex's mechanics. Codex runs a pasted
|
|
901
|
+
* **Install script** (like Claude's setup script) plus the environment's variables, so
|
|
902
|
+
* this doc carries the Claude template's pinned toolchain slice
|
|
903
|
+
* ({@link extractCloudToolchainScript}), the consumer's corepack pnpm and context-fetch
|
|
904
|
+
* provision recipes, the per-snapshot `pnpm install`, the exact-host network list, and
|
|
905
|
+
* the resolved env block.
|
|
906
|
+
*
|
|
907
|
+
* Gitignored + chmod 600 and UNTRACKED like its siblings. Shared by install
|
|
908
|
+
* (runCodexModule) and upgrade. Callers MUST guard on `!dryRun` and on the codex host
|
|
909
|
+
* being installed. Returns true when a file was written (false when the template is
|
|
910
|
+
* absent). Never logs the resolved values.
|
|
911
|
+
*/
|
|
912
|
+
export function writeCodexCloudDoc(cwd, tokens) {
|
|
913
|
+
const src = path.join(getSharedRoot(), ".codex", "bkit-cloud.md");
|
|
914
|
+
if (!fs.existsSync(src))
|
|
915
|
+
return false;
|
|
916
|
+
const res = resolveCloudEnvVars(cwd);
|
|
917
|
+
// Function-form replacers: resolved secret values may contain `$`, which a string
|
|
918
|
+
// replacement would interpret ($&, $1, …).
|
|
919
|
+
const content = applyTokens(fs.readFileSync(src, "utf-8"), tokens)
|
|
920
|
+
.replace(/@@CODEX_TOOLCHAIN@@/g, () => extractCloudToolchainScript())
|
|
921
|
+
.replace(/@@CODEX_NETWORK@@/g, () => renderCodexNetworkAllowlist(cwd))
|
|
922
|
+
.replace(/@@CLOUD_COREPACK@@/g, () => renderCorepackLine(cwd))
|
|
923
|
+
.replace(/@@CLOUD_CONTEXT_FETCH_PROVISION@@/g, () => renderCloudContextFetchProvision(cwd))
|
|
924
|
+
.replace(/@@CLOUD_ENV_VARS@@/g, () => renderCloudEnvBlock(res))
|
|
925
|
+
.replace(/@@CLOUD_ENV_NOTES@@/g, () => renderCloudEnvNotes(res));
|
|
926
|
+
const dst = path.join(cwd, CODEX_CLOUD_RELPATH);
|
|
927
|
+
fs.mkdirSync(path.dirname(dst), { recursive: true });
|
|
928
|
+
fs.writeFileSync(dst, content, "utf-8");
|
|
929
|
+
fs.chmodSync(dst, 0o600);
|
|
930
|
+
return true;
|
|
931
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// install/context-ci-workflow.ts — the CI-run lookup in the consumer's `context=ci` and
|
|
2
|
+
// `context=e2e` blocks in `.agents/context.md`.
|
|
3
|
+
//
|
|
4
|
+
// A lookup without `--workflow` takes the newest run of any workflow on the branch. Other
|
|
5
|
+
// workflows (a security scan, a cloud agent) often finish after CI and pass, so the block reads
|
|
6
|
+
// their run and reports nothing failing. The consumer owns the copies below
|
|
7
|
+
// `<!-- bkit:end -->`, so upgrade rewrites a lookup only when it is byte-identical to the line
|
|
8
|
+
// an older bkit template carried. Register: docs/migrations.md.
|
|
9
|
+
import * as fs from "node:fs";
|
|
10
|
+
import * as path from "node:path";
|
|
11
|
+
import { readBkitConfig } from "../shared/settings.js";
|
|
12
|
+
import { findLineAnchoredMarkers, selectMarkers } from "./managed-block.js";
|
|
13
|
+
const CONTEXT_FILE = path.join(".agents", "context.md");
|
|
14
|
+
const LOOKUP_TAIL = '=$(gh run list --branch "$(git branch --show-current)" --limit 1 \\';
|
|
15
|
+
/** The shipped lookup's first line: `RUN_JSON` in `bkit-github.md`, `RUN_ID` in the e2e blocks. */
|
|
16
|
+
const SHIPPED_LOOKUP = new RegExp(`^(RUN_JSON|RUN_ID)${LOOKUP_TAIL.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`);
|
|
17
|
+
/** Any lookup of the current branch's runs, shipped or edited. */
|
|
18
|
+
const ANY_LOOKUP = /gh run list --branch "\$\(git branch --show-current\)"/;
|
|
19
|
+
const NAMES_WORKFLOW = /(?:^|\s)(?:--workflow|-w)(?:\s|=)/;
|
|
20
|
+
const PLAIN_FILE_NAME = /^[\w.-]+$/;
|
|
21
|
+
/**
|
|
22
|
+
* Rewrites each shipped CI-run lookup below the first line-anchored `<!-- bkit:end -->` so it
|
|
23
|
+
* reads only `workflow`'s runs: a `CI_WORKFLOW="${CI_WORKFLOW:-<workflow>}"` line goes above
|
|
24
|
+
* it, and the lookup gains `--workflow "$CI_WORKFLOW"`. A lookup that names a workflow on
|
|
25
|
+
* either line is already scoped and stays. An edited lookup, or any lookup when `workflow` is
|
|
26
|
+
* not a plain file name, stays and is listed in `unscoped`. A line ending in CR keeps it.
|
|
27
|
+
*/
|
|
28
|
+
export function scopeCiRunLookups(content, workflow) {
|
|
29
|
+
const endAt = findLineAnchoredMarkers(content, selectMarkers("html-comment")[1])[0];
|
|
30
|
+
if (endAt === undefined)
|
|
31
|
+
return { content, rewritten: 0, unscoped: [] };
|
|
32
|
+
const lines = content.slice(endAt).split("\n");
|
|
33
|
+
const plainName = PLAIN_FILE_NAME.test(workflow);
|
|
34
|
+
const out = [];
|
|
35
|
+
const unscoped = [];
|
|
36
|
+
let rewritten = 0;
|
|
37
|
+
lines.forEach((line, i) => {
|
|
38
|
+
const bare = line.replace(/\r$/, "");
|
|
39
|
+
const next = lines[i + 1] ?? "";
|
|
40
|
+
if (!ANY_LOOKUP.test(bare) || NAMES_WORKFLOW.test(bare) || NAMES_WORKFLOW.test(next)) {
|
|
41
|
+
out.push(line);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (!plainName || !SHIPPED_LOOKUP.test(bare)) {
|
|
45
|
+
unscoped.push(bare);
|
|
46
|
+
out.push(line);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const cr = line.endsWith("\r") ? "\r" : "";
|
|
50
|
+
out.push(`CI_WORKFLOW="\${CI_WORKFLOW:-${workflow}}"${cr}`);
|
|
51
|
+
out.push(line.replace(" --limit 1 ", ' --workflow "$CI_WORKFLOW" --limit 1 '));
|
|
52
|
+
rewritten++;
|
|
53
|
+
});
|
|
54
|
+
if (rewritten === 0)
|
|
55
|
+
return { content, rewritten, unscoped };
|
|
56
|
+
return { content: content.slice(0, endAt) + out.join("\n"), rewritten, unscoped };
|
|
57
|
+
}
|
|
58
|
+
/** Absolute paths already named in this process. */
|
|
59
|
+
const warned = new Set();
|
|
60
|
+
/**
|
|
61
|
+
* Migration (installs up to 6.0.x, `docs/migrations.md`): scopes each shipped CI-run lookup in
|
|
62
|
+
* `.agents/context.md` to the workflow file `bkit.testing.ciWorkflow` names. Recorded in ws as
|
|
63
|
+
* an update; the canonical hash covers the managed block only. A lookup it leaves unscoped is
|
|
64
|
+
* named once per process, so the consumer can add `--workflow` by hand.
|
|
65
|
+
*/
|
|
66
|
+
export function migrateContextCiWorkflow(dryRun, ws, logPrefix) {
|
|
67
|
+
if (!fs.lstatSync(CONTEXT_FILE, { throwIfNoEntry: false })?.isFile())
|
|
68
|
+
return;
|
|
69
|
+
const workflow = readBkitConfig(process.cwd()).ciWorkflow;
|
|
70
|
+
const result = scopeCiRunLookups(fs.readFileSync(CONTEXT_FILE, "utf-8"), workflow);
|
|
71
|
+
// Upgrade runs this pass again as its closing dry-run check, so each file is named once.
|
|
72
|
+
const abs = path.resolve(CONTEXT_FILE);
|
|
73
|
+
if (result.unscoped.length > 0 && !warned.has(abs)) {
|
|
74
|
+
warned.add(abs);
|
|
75
|
+
console.warn(`${logPrefix} ${CONTEXT_FILE}: ${result.unscoped.length} CI run lookup(s) read the newest run of every workflow on the branch, so a later passing workflow hides a failed ${workflow} run. Add \`--workflow "${workflow}"\` to each \`gh run list --branch\` line by hand (the shipped form in .bkit/templates/context/bkit-github.md shows how).`);
|
|
76
|
+
}
|
|
77
|
+
if (result.rewritten === 0)
|
|
78
|
+
return;
|
|
79
|
+
if (!dryRun)
|
|
80
|
+
fs.writeFileSync(CONTEXT_FILE, result.content, "utf-8");
|
|
81
|
+
if (!ws.writes.some((w) => path.normalize(w.path) === CONTEXT_FILE)) {
|
|
82
|
+
ws.writes.push({ path: CONTEXT_FILE, action: "update" });
|
|
83
|
+
}
|
|
84
|
+
console.log(`${logPrefix} ${dryRun ? "[dry-run] " : ""}core: ${CONTEXT_FILE} — CI run lookups now read only ${workflow} runs (${result.rewritten})`);
|
|
85
|
+
}
|