@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,6 +1,6 @@
|
|
|
1
|
-
// bkit context clamp|clamp-log|ledger-scan|diff|brief|list-blocks|run-block|finalise —
|
|
1
|
+
// bkit context clamp|clamp-log|ledger-scan|diff|brief|list-blocks|run-block|finalise|provision —
|
|
2
2
|
// size-bound context artifacts, write the run's diff and a build group's brief,
|
|
3
|
-
//
|
|
3
|
+
// fetch the consumer's evidence, and run its cloud provision recipes.
|
|
4
4
|
//
|
|
5
5
|
// clamp is a runaway backstop, NOT a routine cap: a normal run never fires it.
|
|
6
6
|
// Every removal is marked in place and footered. Profiles:
|
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
// plus every line matching the signal pattern with 2 lines of
|
|
12
12
|
// context. Lines over 2000 bytes are shortened in place. Hard
|
|
13
13
|
// ceiling 12000 lines / 1.5 MB.
|
|
14
|
+
// ci / e2e / the debug-evidence algorithm with their context's own section
|
|
15
|
+
// runtime headers added to the signal pattern, so a header naming a kept
|
|
16
|
+
// block's owner survives without a signal word (`===== job …
|
|
17
|
+
// =====`, `===== file: … =====`, `===== step: …`, `===== vercel
|
|
18
|
+
// …`). `context fetch` picks the profile of the block's
|
|
19
|
+
// `context=`; any other context clamps as debug-evidence.
|
|
14
20
|
//
|
|
15
21
|
// Bytes are counted as raw bytes (as `LC_ALL=C awk` counts them), never as
|
|
16
22
|
// characters, so a multi-byte line is measured by what it costs on disk.
|
|
@@ -27,9 +33,13 @@ import {
|
|
|
27
33
|
CONTEXT_FETCH_CONTEXTS,
|
|
28
34
|
parseContextFetchStart,
|
|
29
35
|
} from "../../checks/before/context-fetch.js";
|
|
30
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
UNAVAILABLE_RELPATH,
|
|
38
|
+
extractContextFetchProvisionRecipes,
|
|
39
|
+
renderCloudContextFetchProvision,
|
|
40
|
+
} from "../../install/cloud-env.js";
|
|
31
41
|
import { clampLogPath, readRecords } from "../../ledgers/clamp-log.js";
|
|
32
|
-
import { lastRun } from "../../ledgers/status.js";
|
|
42
|
+
import { lastRun, validateCiSelection, type CiSelection } from "../../ledgers/status.js";
|
|
33
43
|
import {
|
|
34
44
|
CommandError,
|
|
35
45
|
EXIT,
|
|
@@ -45,15 +55,16 @@ import { parseJson } from "../../shared/json.js";
|
|
|
45
55
|
import { checkedTable } from "../../shared/text.js";
|
|
46
56
|
import { buildComment } from "./issues.js";
|
|
47
57
|
import {
|
|
58
|
+
derivedTestMatrix,
|
|
48
59
|
parsePlanBlocks,
|
|
49
60
|
reuseInventory,
|
|
50
61
|
type PlanGroup,
|
|
51
62
|
type PlanTaskBlock,
|
|
52
63
|
} from "./plan-blocks.js";
|
|
53
64
|
import { COMMENT_FILE_OUTPUT, commentFileOf } from "./tracker.js";
|
|
54
|
-
import { EXIT_NO_STATUS, positiveInt, readRuns, str } from "./status.js";
|
|
65
|
+
import { EXIT_NO_STATUS, FILE_FLAG, positiveInt, readRuns, str } from "./status.js";
|
|
55
66
|
import { EXIT_COMMIT, writeStepRow } from "./steps.js";
|
|
56
|
-
import { doneTasks,
|
|
67
|
+
import { RED_PROVEN, doneTasks, redEntries, redKey, testSpan } from "./tests.js";
|
|
57
68
|
|
|
58
69
|
/** Exit code: the artifact to clamp is missing, unreadable, or could not be replaced. */
|
|
59
70
|
export const EXIT_ARTIFACT = 4;
|
|
@@ -168,13 +179,16 @@ const EVIDENCE = {
|
|
|
168
179
|
hardLines: 12000,
|
|
169
180
|
hardBytes: 1572864,
|
|
170
181
|
};
|
|
171
|
-
export const CLAMP_PROFILES = ["ledger", "debug-evidence"] as const;
|
|
182
|
+
export const CLAMP_PROFILES = ["ledger", "debug-evidence", "ci", "e2e", "runtime"] as const;
|
|
172
183
|
|
|
173
184
|
/**
|
|
174
185
|
* Lowercase substrings matched against a lowercased line. Broad: `error` also covers
|
|
175
|
-
* `##[error]`, `fail` covers `FAILED`; the ceiling bounds over-matching.
|
|
186
|
+
* `##[error]`, `fail` covers `FAILED`; the ceiling bounds over-matching. Every profile keeps
|
|
187
|
+
* `===== TRUNCATED: … =====`, the line `.agents/context.md` asks every block to print when
|
|
188
|
+
* it stops short of its window, so a partial read never looks complete.
|
|
176
189
|
*/
|
|
177
190
|
const SIGNALS = [
|
|
191
|
+
"===== truncated: ",
|
|
178
192
|
"error",
|
|
179
193
|
"fail",
|
|
180
194
|
"exception",
|
|
@@ -190,6 +204,57 @@ const SIGNALS = [
|
|
|
190
204
|
"×",
|
|
191
205
|
].map((s) => Buffer.from(s));
|
|
192
206
|
|
|
207
|
+
/**
|
|
208
|
+
* Section-header markers a context's shipped blocks print, lowercased like them. A profile
|
|
209
|
+
* named for the context adds them, so a header that names a kept block's owner survives
|
|
210
|
+
* without a signal word. Sourced from `.bkit/templates/context/`: `github` (`ci`);
|
|
211
|
+
* `playwright` + `maestro` + `expo-workflows` (`e2e`); every runtime block that prints a
|
|
212
|
+
* banner — `vercel`, `cloudrun`, `supabase`, `inngest`, `resend`, `stripe`, `expo`
|
|
213
|
+
* (`runtime`). `sentry` prints no banner. A context with no entry clamps as
|
|
214
|
+
* `debug-evidence`.
|
|
215
|
+
*/
|
|
216
|
+
const CONTEXT_MARKERS: Record<string, readonly string[]> = {
|
|
217
|
+
ci: ["===== job ", "===== run "],
|
|
218
|
+
e2e: [
|
|
219
|
+
"===== file: ",
|
|
220
|
+
"===== step: ",
|
|
221
|
+
"===== maestro job ",
|
|
222
|
+
"===== playwright report ",
|
|
223
|
+
// `expo-workflows` (`context=e2e`).
|
|
224
|
+
"===== eas workflow runs",
|
|
225
|
+
"===== failing steps",
|
|
226
|
+
"===== screen-hierarchy dumps",
|
|
227
|
+
"===== app js console per flow",
|
|
228
|
+
"===== distinct app messages",
|
|
229
|
+
"===== junit ",
|
|
230
|
+
],
|
|
231
|
+
runtime: [
|
|
232
|
+
"===== vercel ",
|
|
233
|
+
"===== cloud run ",
|
|
234
|
+
"===== supabase ",
|
|
235
|
+
"===== inngest ",
|
|
236
|
+
"===== resend ",
|
|
237
|
+
"===== stripe ",
|
|
238
|
+
"===== webhook deliveries failed",
|
|
239
|
+
"===== eas builds",
|
|
240
|
+
],
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
/** Each context profile's signal set: {@link SIGNALS} plus that context's markers. */
|
|
244
|
+
const PROFILE_SIGNALS: Record<string, readonly Buffer[]> = Object.fromEntries(
|
|
245
|
+
Object.entries(CONTEXT_MARKERS).map(([profile, markers]) => [
|
|
246
|
+
profile,
|
|
247
|
+
[...SIGNALS, ...markers.map((m) => Buffer.from(m))],
|
|
248
|
+
]),
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
/** The signals a profile matches; a profile with no markers of its own is the base set. */
|
|
252
|
+
const signalsFor = (profile: string): readonly Buffer[] => PROFILE_SIGNALS[profile] ?? SIGNALS;
|
|
253
|
+
|
|
254
|
+
/** The clamp profile a block's context selects; any context without its own profile is `debug-evidence`. */
|
|
255
|
+
const contextProfile = (context: string): string =>
|
|
256
|
+
CONTEXT_MARKERS[context] === undefined ? "debug-evidence" : context;
|
|
257
|
+
|
|
193
258
|
/** awk records: a final line with no newline is one, a trailing newline does not start another. */
|
|
194
259
|
function records(buf: Buffer): Buffer[] {
|
|
195
260
|
const out: Buffer[] = [];
|
|
@@ -204,10 +269,10 @@ function records(buf: Buffer): Buffer[] {
|
|
|
204
269
|
return out;
|
|
205
270
|
}
|
|
206
271
|
|
|
207
|
-
function hasSignal(line: Buffer): boolean {
|
|
272
|
+
function hasSignal(line: Buffer, signals: readonly Buffer[]): boolean {
|
|
208
273
|
const lower = Buffer.from(line);
|
|
209
274
|
for (let i = 0; i < lower.length; i++) if (lower[i]! >= 65 && lower[i]! <= 90) lower[i]! += 32;
|
|
210
|
-
return
|
|
275
|
+
return signals.some((s) => lower.includes(s));
|
|
211
276
|
}
|
|
212
277
|
|
|
213
278
|
/** awk's human size: B, rounded KB, or MB to one decimal (ties to even, as printf). */
|
|
@@ -257,7 +322,7 @@ function selectLedger(buf: Buffer): Selection | null {
|
|
|
257
322
|
};
|
|
258
323
|
}
|
|
259
324
|
|
|
260
|
-
function selectEvidence(buf: Buffer): Selection {
|
|
325
|
+
function selectEvidence(buf: Buffer, signals: readonly Buffer[]): Selection {
|
|
261
326
|
const p = EVIDENCE;
|
|
262
327
|
const raw = records(buf);
|
|
263
328
|
const n = raw.length;
|
|
@@ -299,7 +364,7 @@ function selectEvidence(buf: Buffer): Selection {
|
|
|
299
364
|
// otherwise lose its immunity.
|
|
300
365
|
let ceiling = false;
|
|
301
366
|
for (let i = 0; i < n; i++) {
|
|
302
|
-
if (!hasSignal(raw[i]
|
|
367
|
+
if (!hasSignal(raw[i]!, signals)) continue;
|
|
303
368
|
const a = Math.max(0, i - p.context);
|
|
304
369
|
const b = Math.min(n - 1, i + p.context);
|
|
305
370
|
let cl = 0;
|
|
@@ -388,7 +453,7 @@ export function clampFile(
|
|
|
388
453
|
throw new CommandError(EXIT_ARTIFACT, `cannot read artifact '${artifact}': ${read.problem}`);
|
|
389
454
|
}
|
|
390
455
|
const buf = read.buf;
|
|
391
|
-
const sel = profile === "ledger" ? selectLedger(buf) : selectEvidence(buf);
|
|
456
|
+
const sel = profile === "ledger" ? selectLedger(buf) : selectEvidence(buf, signalsFor(profile));
|
|
392
457
|
const source = keep?.source ?? null;
|
|
393
458
|
const fetchedAt = keep?.fetchedAt ?? (source === null ? null : utcNow());
|
|
394
459
|
const untouched = (s: Selection | null): ClampRecord => ({
|
|
@@ -474,6 +539,61 @@ function replaceFile(file: string, tmp: string, content: Buffer): string | undef
|
|
|
474
539
|
}
|
|
475
540
|
}
|
|
476
541
|
|
|
542
|
+
// ---------------------------------------------------------------------------
|
|
543
|
+
// Clamp summary — the saving, per context, for the context-fetch status row
|
|
544
|
+
// ---------------------------------------------------------------------------
|
|
545
|
+
|
|
546
|
+
/** One context's clamp totals: what its blocks wrote, and how much of it survived. */
|
|
547
|
+
export interface ClampSummary {
|
|
548
|
+
/** Artifacts written for this context. */
|
|
549
|
+
artifacts: number;
|
|
550
|
+
/** Lines fetched / kept. */
|
|
551
|
+
origLines: number;
|
|
552
|
+
keptLines: number;
|
|
553
|
+
/** Bytes fetched / kept. */
|
|
554
|
+
origBytes: number;
|
|
555
|
+
keptBytes: number;
|
|
556
|
+
/** Artifacts written as a markdown table / as printed (`render`; a record without one counts as neither). */
|
|
557
|
+
table: number;
|
|
558
|
+
raw: number;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/** The context-fetch context a clamp record belongs to, from its `context-<context>-…` artifact basename. */
|
|
562
|
+
function contextOfArtifact(artifact: string): string | undefined {
|
|
563
|
+
const context = /^context-([a-z0-9]+)-/.exec(path.basename(artifact))?.[1];
|
|
564
|
+
return context !== undefined && CONTEXT_FETCH_CONTEXTS.includes(context) ? context : undefined;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
const numberOr0 = (v: unknown): number => (typeof v === "number" ? v : 0);
|
|
568
|
+
|
|
569
|
+
/** The context-fetch clamp records totalled per context; a record naming no context is skipped. */
|
|
570
|
+
export function summariseRecords(records: readonly unknown[]): Record<string, ClampSummary> {
|
|
571
|
+
const summary: Record<string, ClampSummary> = {};
|
|
572
|
+
for (const value of records) {
|
|
573
|
+
const r = value as Partial<ClampRecord> | null;
|
|
574
|
+
if (r === null || typeof r.artifact !== "string") continue;
|
|
575
|
+
const context = contextOfArtifact(r.artifact);
|
|
576
|
+
if (context === undefined) continue;
|
|
577
|
+
const s = (summary[context] ??= {
|
|
578
|
+
artifacts: 0,
|
|
579
|
+
origLines: 0,
|
|
580
|
+
keptLines: 0,
|
|
581
|
+
origBytes: 0,
|
|
582
|
+
keptBytes: 0,
|
|
583
|
+
table: 0,
|
|
584
|
+
raw: 0,
|
|
585
|
+
});
|
|
586
|
+
s.artifacts++;
|
|
587
|
+
s.origLines += numberOr0(r.origLines);
|
|
588
|
+
s.keptLines += numberOr0(r.keptLines);
|
|
589
|
+
s.origBytes += numberOr0(r.origBytes);
|
|
590
|
+
s.keptBytes += numberOr0(r.keptBytes);
|
|
591
|
+
if (r.render === "table") s.table++;
|
|
592
|
+
else if (r.render === "raw") s.raw++;
|
|
593
|
+
}
|
|
594
|
+
return summary;
|
|
595
|
+
}
|
|
596
|
+
|
|
477
597
|
// ---------------------------------------------------------------------------
|
|
478
598
|
// Clamp log — records cross the gap between the block that writes an artifact
|
|
479
599
|
// and the block that records the step's status row.
|
|
@@ -518,6 +638,7 @@ const RECORD_OUTPUT: Record<string, string> = {
|
|
|
518
638
|
raw: "the untouched original in the outbox ({name}.raw.{ext}), or null when nothing was cut",
|
|
519
639
|
source: "the command that produced the file (--source), or null",
|
|
520
640
|
fetchedAt: "when the source ran (UTC; the clamp time with --source), or null",
|
|
641
|
+
render: "context fetch only: table when the output was rendered as a table, else raw",
|
|
521
642
|
};
|
|
522
643
|
|
|
523
644
|
/** Say so when a cut had nowhere to keep its original. */
|
|
@@ -908,7 +1029,9 @@ export const BRIEF_WORK_WARN_BYTES = 8 * 1024;
|
|
|
908
1029
|
const BRIEF_SECTIONS = ["Context & Goals", "Narrative", "Success Criteria", "Out of Scope"];
|
|
909
1030
|
|
|
910
1031
|
/** The plan-execute logs whose `DONE — TASK N` lines mark a task done. */
|
|
911
|
-
|
|
1032
|
+
// `build-plan-execute-*` is the log's name from before the step rename: a run in flight
|
|
1033
|
+
// across the rename keeps its DONE lines (`docs/migrations.md`).
|
|
1034
|
+
const TASKS_LOG = /^build-plan-(?:tasks|execute)-.+-log\.md$/;
|
|
912
1035
|
|
|
913
1036
|
/** A heading's text without leading emoji and marks. */
|
|
914
1037
|
const headingText = (text: string) => text.replace(/^[^A-Za-z0-9]+/, "").trim();
|
|
@@ -939,7 +1062,7 @@ function planSection(lines: string[], name: string): string | undefined {
|
|
|
939
1062
|
function loggedDone(dir: string): Set<number> {
|
|
940
1063
|
const done = new Set<number>();
|
|
941
1064
|
if (!fs.existsSync(dir)) return done;
|
|
942
|
-
for (const f of fs.readdirSync(dir).filter((f) =>
|
|
1065
|
+
for (const f of fs.readdirSync(dir).filter((f) => TASKS_LOG.test(f)))
|
|
943
1066
|
for (const n of doneTasks(fs.readFileSync(path.join(dir, f), "utf-8"))) done.add(n);
|
|
944
1067
|
return done;
|
|
945
1068
|
}
|
|
@@ -984,15 +1107,19 @@ function architectureEntries(lines: string[], files: Set<string>): string[] {
|
|
|
984
1107
|
});
|
|
985
1108
|
}
|
|
986
1109
|
|
|
987
|
-
/** The next free `
|
|
988
|
-
function nextBriefPath(dir: string, group: number): string {
|
|
989
|
-
const re = new RegExp(
|
|
1110
|
+
/** The next free `{prefix}-{group}-{n}.md` in `dir`: the code briefs and the tests briefs count apart. */
|
|
1111
|
+
function nextBriefPath(dir: string, group: number, prefix = "build-brief"): string {
|
|
1112
|
+
const re = new RegExp(`^${prefix}-${group}-([0-9]+)\\.md$`);
|
|
990
1113
|
const taken = fs.existsSync(dir)
|
|
991
1114
|
? fs.readdirSync(dir).map((f) => Number(re.exec(f)?.[1] ?? 0))
|
|
992
1115
|
: [];
|
|
993
|
-
return path.join(dir,
|
|
1116
|
+
return path.join(dir, `${prefix}-${group}-${Math.max(0, ...taken) + 1}.md`);
|
|
994
1117
|
}
|
|
995
1118
|
|
|
1119
|
+
/** The TEST FIRST tests of `tasks`, in plan order. */
|
|
1120
|
+
export const plannedTests = (tasks: PlanTaskBlock[]) =>
|
|
1121
|
+
tasks.flatMap((t) => (t.testFirst?.tests ?? []).map((x) => ({ task: t.task, ...x })));
|
|
1122
|
+
|
|
996
1123
|
export interface BriefInput {
|
|
997
1124
|
plan: string;
|
|
998
1125
|
/** The plan's path as given, named where left-out entries can be read. */
|
|
@@ -1000,15 +1127,47 @@ export interface BriefInput {
|
|
|
1000
1127
|
group: PlanGroup;
|
|
1001
1128
|
groups: PlanGroup[];
|
|
1002
1129
|
isDone: (t: PlanTaskBlock) => boolean;
|
|
1003
|
-
|
|
1130
|
+
/** The tests step's brief: the Derived Test Matrix rows for the group's tests replace the Reuse Inventory rows and Architecture entries. */
|
|
1131
|
+
testsOnly?: boolean;
|
|
1132
|
+
/** Tests-only: the planned tests a test in their file already carries, with the line that test starts on. */
|
|
1133
|
+
existing?: ExistingTest[];
|
|
1004
1134
|
note?: string;
|
|
1005
1135
|
}
|
|
1006
1136
|
|
|
1137
|
+
/** A planned test whose file already holds a test of that name, at `line` (1-based). */
|
|
1138
|
+
export interface ExistingTest {
|
|
1139
|
+
task: number;
|
|
1140
|
+
test: string;
|
|
1141
|
+
name: string;
|
|
1142
|
+
line: number;
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
/**
|
|
1146
|
+
* The planned tests of `open` that already exist in the tree under `top`: the tests step
|
|
1147
|
+
* updates each one in place (adding expectations, never removing or loosening one) rather
|
|
1148
|
+
* than writing a second test of that name.
|
|
1149
|
+
*/
|
|
1150
|
+
export function existingPlannedTests(top: string, open: PlanTaskBlock[]): ExistingTest[] {
|
|
1151
|
+
const out: ExistingTest[] = [];
|
|
1152
|
+
for (const t of plannedTests(open)) {
|
|
1153
|
+
const abs = path.join(top, t.test);
|
|
1154
|
+
if (!fs.existsSync(abs)) continue;
|
|
1155
|
+
const span = testSpan(fs.readFileSync(abs, "utf-8"), t.name);
|
|
1156
|
+
if (span !== null) out.push({ task: t.task, test: t.test, name: t.name, line: span.start });
|
|
1157
|
+
}
|
|
1158
|
+
return out;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1007
1161
|
/** The brief's text and its work section's size in bytes. */
|
|
1008
1162
|
export function briefText(o: BriefInput): { text: string; workBytes: number } {
|
|
1009
1163
|
const lines = o.plan.split("\n");
|
|
1010
1164
|
const title = lines.find((l) => /^#\s/.test(l))?.replace(/^#\s+/, "") ?? "Plan";
|
|
1011
|
-
const out = [
|
|
1165
|
+
const out = [
|
|
1166
|
+
`# Brief: group ${o.group.group} — ${o.group.title}${o.testsOnly ? " (tests)" : ""}`,
|
|
1167
|
+
"",
|
|
1168
|
+
`Plan: ${title}`,
|
|
1169
|
+
"",
|
|
1170
|
+
];
|
|
1012
1171
|
|
|
1013
1172
|
out.push("## Why and what", "");
|
|
1014
1173
|
for (const name of BRIEF_SECTIONS) {
|
|
@@ -1039,16 +1198,6 @@ export function briefText(o: BriefInput): { text: string; workBytes: number } {
|
|
|
1039
1198
|
const open = o.group.tasks.filter((t) => !o.isDone(t));
|
|
1040
1199
|
const work = ["## The work", ""];
|
|
1041
1200
|
for (const t of open) work.push(t.text.trim(), "");
|
|
1042
|
-
const openNums = new Set(open.map((t) => t.task));
|
|
1043
|
-
const reds = o.reds.filter((r) => openNums.has(Number(r.task)));
|
|
1044
|
-
if (reds.length > 0) {
|
|
1045
|
-
work.push("### Reds already recorded", "");
|
|
1046
|
-
for (const r of reds)
|
|
1047
|
-
work.push(
|
|
1048
|
-
`- TASK ${Number(r.task)}: red already recorded for \`${String(r.test)}\` \`${String(r.testName)}\` — test written and seen failing; code may be partly done in the files it names`,
|
|
1049
|
-
);
|
|
1050
|
-
work.push("");
|
|
1051
|
-
}
|
|
1052
1201
|
const deps = [...new Set(open.flatMap((t) => t.dependsOn))]
|
|
1053
1202
|
.filter((n) => !o.group.tasks.some((t) => t.task === n))
|
|
1054
1203
|
.sort((a, b) => a - b)
|
|
@@ -1065,7 +1214,18 @@ export function briefText(o: BriefInput): { text: string; workBytes: number } {
|
|
|
1065
1214
|
}
|
|
1066
1215
|
work.push("");
|
|
1067
1216
|
}
|
|
1068
|
-
|
|
1217
|
+
if (o.testsOnly) {
|
|
1218
|
+
work.push(...matrixRows(o.plan, open));
|
|
1219
|
+
const existing = (o.existing ?? []).filter((e) => open.some((t) => t.task === e.task));
|
|
1220
|
+
if (existing.length > 0) {
|
|
1221
|
+
work.push("### Planned tests that already exist", "");
|
|
1222
|
+
for (const e of existing)
|
|
1223
|
+
work.push(
|
|
1224
|
+
`- TASK ${e.task} \`${e.test}\` \`${e.name}\` — exists at \`${e.test}:${e.line}\`; update that test in place: add expectations, never remove or loosen one`,
|
|
1225
|
+
);
|
|
1226
|
+
work.push("");
|
|
1227
|
+
}
|
|
1228
|
+
} else work.push(...planEntries(lines, open, work, o.planFile));
|
|
1069
1229
|
out.push(...work);
|
|
1070
1230
|
|
|
1071
1231
|
if (o.note !== undefined) out.push("## Deviations", "", o.note.trim(), "");
|
|
@@ -1075,6 +1235,19 @@ export function briefText(o: BriefInput): { text: string; workBytes: number } {
|
|
|
1075
1235
|
};
|
|
1076
1236
|
}
|
|
1077
1237
|
|
|
1238
|
+
/** The Derived Test Matrix rows naming a TEST FIRST file of `open`, under the table's header. */
|
|
1239
|
+
function matrixRows(plan: string, open: PlanTaskBlock[]): string[] {
|
|
1240
|
+
const matrix = derivedTestMatrix(plan);
|
|
1241
|
+
if (matrix === null) return [];
|
|
1242
|
+
const files = new Set(plannedTests(open).map((t) => path.posix.normalize(t.test)));
|
|
1243
|
+
const rows = matrix.rows.filter((r) =>
|
|
1244
|
+
[...r.line.matchAll(/`([^`]+)`/g)].some((m) => files.has(path.posix.normalize(m[1]!))),
|
|
1245
|
+
);
|
|
1246
|
+
return rows.length === 0
|
|
1247
|
+
? []
|
|
1248
|
+
: ["### Derived Test Matrix rows", "", ...matrix.head, ...rows.map((r) => r.line), ""];
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1078
1251
|
/**
|
|
1079
1252
|
* The Reuse Inventory rows, then the Architecture entries, for the files on the open
|
|
1080
1253
|
* tasks' CREATE / UPDATE / DELETE lines, each in plan order while the work section stays
|
|
@@ -1142,10 +1315,16 @@ const RUN_BLOCK_FLAGS: FlagSpec[] = [
|
|
|
1142
1315
|
FID_FLAG,
|
|
1143
1316
|
MONTH_FLAG,
|
|
1144
1317
|
...ATTEMPT_FLAGS,
|
|
1318
|
+
{
|
|
1319
|
+
name: "ci-selection-file",
|
|
1320
|
+
type: "string",
|
|
1321
|
+
help: "validated CI selection JSON; pin child evidence reads and require a matching complete CI receipt",
|
|
1322
|
+
},
|
|
1145
1323
|
];
|
|
1146
1324
|
|
|
1147
1325
|
const RUN_BLOCK_OUTPUT: Record<string, string> = {
|
|
1148
|
-
outcome:
|
|
1326
|
+
outcome:
|
|
1327
|
+
"checked (validated data written) | unchecked (selected CI evidence invalid) | self-skipped (skip line written) | silent (nothing) | not-run",
|
|
1149
1328
|
artifact: "the artifact path, or null when nothing was written",
|
|
1150
1329
|
skip: "the block's [context-fetch:<name>] stderr line, or null",
|
|
1151
1330
|
clamp: "the payload's clamp record, or null",
|
|
@@ -1159,9 +1338,10 @@ export const contextCommand: CommandSpec = {
|
|
|
1159
1338
|
verbs: {
|
|
1160
1339
|
clamp: {
|
|
1161
1340
|
summary: "Clamp an artifact to a size profile in place (a backstop, not a routine cap).",
|
|
1341
|
+
use: "workflow",
|
|
1162
1342
|
flags: [
|
|
1163
1343
|
{ name: "artifact", type: "string", required: true, help: "file to clamp" },
|
|
1164
|
-
{ name: "profile", type: "string", required: true, help: "
|
|
1344
|
+
{ name: "profile", type: "string", required: true, help: CLAMP_PROFILES.join(" | ") },
|
|
1165
1345
|
{
|
|
1166
1346
|
name: "source",
|
|
1167
1347
|
type: "string",
|
|
@@ -1197,6 +1377,7 @@ export const contextCommand: CommandSpec = {
|
|
|
1197
1377
|
},
|
|
1198
1378
|
"clamp-log": {
|
|
1199
1379
|
summary: "Read a step's clamp records (the status row's clamped array), or reset the log.",
|
|
1380
|
+
use: "workflow",
|
|
1200
1381
|
flags: [
|
|
1201
1382
|
...LOG_FLAGS,
|
|
1202
1383
|
{ name: "reset", type: "boolean", help: "empty the log first (the step's first writer)" },
|
|
@@ -1220,6 +1401,7 @@ export const contextCommand: CommandSpec = {
|
|
|
1220
1401
|
"ledger-scan": {
|
|
1221
1402
|
summary:
|
|
1222
1403
|
"Write a ledger's lines matching query terms, strongest first, then clamp (ledger profile).",
|
|
1404
|
+
use: "workflow",
|
|
1223
1405
|
flags: [
|
|
1224
1406
|
{ name: "terms", type: "string", required: true, help: "space-separated query terms" },
|
|
1225
1407
|
{
|
|
@@ -1274,6 +1456,7 @@ export const contextCommand: CommandSpec = {
|
|
|
1274
1456
|
diff: {
|
|
1275
1457
|
summary:
|
|
1276
1458
|
"Write the run's diff ({base}...HEAD, docs/plans/** excluded) as one artifact — whole, or a per-file budget past the guard — and print its numbers.",
|
|
1459
|
+
use: "workflow",
|
|
1277
1460
|
flags: [
|
|
1278
1461
|
{ name: "artifact", type: "string", required: true, help: "file to write" },
|
|
1279
1462
|
{
|
|
@@ -1355,7 +1538,8 @@ export const contextCommand: CommandSpec = {
|
|
|
1355
1538
|
},
|
|
1356
1539
|
brief: {
|
|
1357
1540
|
summary:
|
|
1358
|
-
"Write one group's brief (why and what, where it fits, its open task blocks, the earlier tasks they depend on, the Reuse Inventory rows and Architecture entries for their files, deviations) as build-brief-{group}-{n}.md, and print only its path and sizes.",
|
|
1541
|
+
"Write one group's brief (why and what, where it fits, its open task blocks, the earlier tasks they depend on, the Reuse Inventory rows and Architecture entries for their files, deviations) as build-brief-{group}-{n}.md, and print only its path and sizes; --tests-only writes the tests step's brief as build-brief-tests-{group}-{n}.md, with the Derived Test Matrix rows for the group's tests in place of the inventory and architecture entries.",
|
|
1542
|
+
use: "workflow",
|
|
1359
1543
|
flags: [
|
|
1360
1544
|
{ name: "plan", type: "string", required: true, help: "the plan file" },
|
|
1361
1545
|
{ name: "group", type: "string", help: "the group to brief" },
|
|
@@ -1368,12 +1552,17 @@ export const contextCommand: CommandSpec = {
|
|
|
1368
1552
|
name: "dir",
|
|
1369
1553
|
type: "string",
|
|
1370
1554
|
required: true,
|
|
1371
|
-
help: "the run's logs folder: the brief is written there, and its build-plan-
|
|
1555
|
+
help: "the run's logs folder: the brief is written there, and its build-plan-tasks-*-log.md DONE lines mark tasks done",
|
|
1372
1556
|
},
|
|
1373
1557
|
{
|
|
1374
|
-
name: "
|
|
1375
|
-
type: "
|
|
1376
|
-
help: "
|
|
1558
|
+
name: "tests-only",
|
|
1559
|
+
type: "boolean",
|
|
1560
|
+
help: "the tests step's brief: build-brief-tests-{group}-{n}.md (a group with no planned test writes nothing, tests 0)",
|
|
1561
|
+
},
|
|
1562
|
+
{
|
|
1563
|
+
...FILE_FLAG,
|
|
1564
|
+
required: false,
|
|
1565
|
+
help: "with --tests-only: the run's status.jsonl; a planned test a build-tests-red row of the group already proved red is left out, and a task with no test left is not briefed",
|
|
1377
1566
|
},
|
|
1378
1567
|
{
|
|
1379
1568
|
name: "note-file",
|
|
@@ -1386,12 +1575,12 @@ export const contextCommand: CommandSpec = {
|
|
|
1386
1575
|
bytes: "the brief's size in bytes",
|
|
1387
1576
|
group: "the group briefed (null when --next finds no open group)",
|
|
1388
1577
|
tasks: "the open task numbers the brief carries",
|
|
1578
|
+
tests: "the TEST FIRST tests of those tasks (0 when --next finds no open group)",
|
|
1389
1579
|
workBytes: "the work section's size in bytes (0 when --next finds no open group)",
|
|
1390
1580
|
workCap: `the work section's cap in bytes (${BRIEF_WORK_WARN_BYTES}): Reuse Inventory rows and Architecture entries past it are left out and counted; task blocks over it warn on stderr`,
|
|
1391
1581
|
},
|
|
1392
1582
|
exitCodes: {
|
|
1393
1583
|
[EXIT_ARTIFACT]: "the plan or note file is missing, or the plan's blocks do not parse",
|
|
1394
|
-
[EXIT_NO_STATUS]: "--file names a missing or malformed status.jsonl",
|
|
1395
1584
|
},
|
|
1396
1585
|
run: (ctx) => {
|
|
1397
1586
|
const groupFlag = positiveInt(ctx.flags.group, "group");
|
|
@@ -1424,6 +1613,32 @@ export const contextCommand: CommandSpec = {
|
|
|
1424
1613
|
bytes: 0,
|
|
1425
1614
|
group: null,
|
|
1426
1615
|
tasks: [],
|
|
1616
|
+
tests: 0,
|
|
1617
|
+
workBytes: 0,
|
|
1618
|
+
workCap: BRIEF_WORK_WARN_BYTES,
|
|
1619
|
+
});
|
|
1620
|
+
return EXIT.OK;
|
|
1621
|
+
}
|
|
1622
|
+
const testsOnly = ctx.flags.testsOnly === true;
|
|
1623
|
+
const statusArg = str(ctx.flags.file);
|
|
1624
|
+
const proven =
|
|
1625
|
+
testsOnly && statusArg !== undefined
|
|
1626
|
+
? redEntries(path.resolve(ctx.cwd, statusArg), "build", group.group)
|
|
1627
|
+
: new Map<string, never>();
|
|
1628
|
+
const left = (t: PlanTaskBlock) =>
|
|
1629
|
+
plannedTests([t]).filter((x) => {
|
|
1630
|
+
const red = proven.get(redKey(x.task, x.test, x.name));
|
|
1631
|
+
return red === undefined || !RED_PROVEN.has(red.state);
|
|
1632
|
+
});
|
|
1633
|
+
const open = group.tasks.filter((t) => !isDone(t) && (!testsOnly || left(t).length > 0));
|
|
1634
|
+
const tests = testsOnly ? open.flatMap(left).length : plannedTests(open).length;
|
|
1635
|
+
if (testsOnly && tests === 0) {
|
|
1636
|
+
ctx.emit({
|
|
1637
|
+
artifact: null,
|
|
1638
|
+
bytes: 0,
|
|
1639
|
+
group: group.group,
|
|
1640
|
+
tasks: open.map((t) => t.task),
|
|
1641
|
+
tests,
|
|
1427
1642
|
workBytes: 0,
|
|
1428
1643
|
workCap: BRIEF_WORK_WARN_BYTES,
|
|
1429
1644
|
});
|
|
@@ -1433,17 +1648,19 @@ export const contextCommand: CommandSpec = {
|
|
|
1433
1648
|
const noteFile = noteFlag === undefined ? undefined : path.resolve(ctx.cwd, noteFlag);
|
|
1434
1649
|
if (noteFile !== undefined && !fs.existsSync(noteFile))
|
|
1435
1650
|
throw new CommandError(EXIT_ARTIFACT, `${noteFlag} does not exist`);
|
|
1436
|
-
const status = str(ctx.flags.file);
|
|
1437
1651
|
const { text, workBytes } = briefText({
|
|
1438
1652
|
plan,
|
|
1439
1653
|
planFile: String(ctx.flags.plan),
|
|
1440
1654
|
group,
|
|
1441
1655
|
groups: blocks.groups,
|
|
1442
|
-
isDone,
|
|
1443
|
-
|
|
1656
|
+
isDone: (t) => isDone(t) || (group.tasks.includes(t) && !open.includes(t)),
|
|
1657
|
+
testsOnly,
|
|
1658
|
+
existing: testsOnly
|
|
1659
|
+
? existingPlannedTests(git(ctx.cwd, ["rev-parse", "--show-toplevel"]) ?? ctx.cwd, open)
|
|
1660
|
+
: undefined,
|
|
1444
1661
|
note: noteFile === undefined ? undefined : fs.readFileSync(noteFile, "utf-8"),
|
|
1445
1662
|
});
|
|
1446
|
-
const out = nextBriefPath(dir, group.group);
|
|
1663
|
+
const out = nextBriefPath(dir, group.group, testsOnly ? "build-brief-tests" : undefined);
|
|
1447
1664
|
fs.mkdirSync(dir, { recursive: true });
|
|
1448
1665
|
fs.writeFileSync(out, text);
|
|
1449
1666
|
if (workBytes > BRIEF_WORK_WARN_BYTES) {
|
|
@@ -1456,7 +1673,8 @@ export const contextCommand: CommandSpec = {
|
|
|
1456
1673
|
artifact,
|
|
1457
1674
|
bytes: Buffer.byteLength(text),
|
|
1458
1675
|
group: group.group,
|
|
1459
|
-
tasks:
|
|
1676
|
+
tasks: open.map((t) => t.task),
|
|
1677
|
+
tests,
|
|
1460
1678
|
workBytes,
|
|
1461
1679
|
workCap: BRIEF_WORK_WARN_BYTES,
|
|
1462
1680
|
});
|
|
@@ -1465,13 +1683,13 @@ export const contextCommand: CommandSpec = {
|
|
|
1465
1683
|
},
|
|
1466
1684
|
"list-blocks": {
|
|
1467
1685
|
summary: "Enumerate the consumer's context-fetch blocks and narrate coverage per context.",
|
|
1686
|
+
use: "by-hand",
|
|
1468
1687
|
flags: [],
|
|
1469
1688
|
output: {
|
|
1470
1689
|
blocks: "[{idx, context, name, known, prefix, suffix, body}] in file order",
|
|
1471
1690
|
coverage: "blocks per context (runtime, ci, diff, e2e, web)",
|
|
1472
1691
|
contextsConfigured: "contexts with at least one block, in narration order",
|
|
1473
|
-
provision:
|
|
1474
|
-
"bash body of each context-fetch:provision block below bkit:end, in file order (bkit-cloud-bootstrap.sh runs them)",
|
|
1692
|
+
provision: "bash body of each context-fetch:provision block below bkit:end, in file order",
|
|
1475
1693
|
},
|
|
1476
1694
|
run: (ctx) => {
|
|
1477
1695
|
const blocks = fetchBlocks(consumerSection(readContextMd(ctx) ?? ""));
|
|
@@ -1504,9 +1722,22 @@ export const contextCommand: CommandSpec = {
|
|
|
1504
1722
|
return EXIT.OK;
|
|
1505
1723
|
},
|
|
1506
1724
|
},
|
|
1725
|
+
provision: {
|
|
1726
|
+
summary:
|
|
1727
|
+
"Run each context-fetch:provision recipe below bkit:end on its own and list the failed ones in .bkit/.unavailable.",
|
|
1728
|
+
use: "by-hand",
|
|
1729
|
+
flags: [],
|
|
1730
|
+
output: {
|
|
1731
|
+
recipes: "recipes run",
|
|
1732
|
+
unavailable: "[{name, reason}] for each failed recipe, in file order",
|
|
1733
|
+
file: "the failure list's path from the repo root; null when none failed",
|
|
1734
|
+
},
|
|
1735
|
+
run: (ctx) => runProvision(ctx),
|
|
1736
|
+
},
|
|
1507
1737
|
"run-block": {
|
|
1508
1738
|
summary:
|
|
1509
1739
|
"Run one customised block; write its output fenced (clamped first), its skip line, or nothing.",
|
|
1740
|
+
use: "workflow",
|
|
1510
1741
|
flags: RUN_BLOCK_FLAGS,
|
|
1511
1742
|
output: RUN_BLOCK_OUTPUT,
|
|
1512
1743
|
textOmit: ["clamp"],
|
|
@@ -1519,6 +1750,7 @@ export const contextCommand: CommandSpec = {
|
|
|
1519
1750
|
fetch: {
|
|
1520
1751
|
summary:
|
|
1521
1752
|
"run-block, with a JSON array of flat objects written as a markdown table; the raw output stays in the outbox.",
|
|
1753
|
+
use: "workflow",
|
|
1522
1754
|
flags: [
|
|
1523
1755
|
...RUN_BLOCK_FLAGS,
|
|
1524
1756
|
{
|
|
@@ -1546,6 +1778,7 @@ export const contextCommand: CommandSpec = {
|
|
|
1546
1778
|
finalise: {
|
|
1547
1779
|
summary:
|
|
1548
1780
|
"The context-fetch status row's fields: verdict, artifacts, contexts configured, clamped; --record writes and commits the row and prints the step comment.",
|
|
1781
|
+
use: "workflow",
|
|
1549
1782
|
flags: [
|
|
1550
1783
|
FID_FLAG,
|
|
1551
1784
|
MONTH_FLAG,
|
|
@@ -1570,15 +1803,20 @@ export const contextCommand: CommandSpec = {
|
|
|
1570
1803
|
artifacts: "those artifacts, relative to the working directory",
|
|
1571
1804
|
contextsConfigured: "contexts with at least one block",
|
|
1572
1805
|
clamped: "this attempt's clamp records",
|
|
1806
|
+
clampSummary:
|
|
1807
|
+
"those records totalled per context: artifacts written, lines and bytes fetched -> kept, and how many were written as a table vs raw",
|
|
1573
1808
|
row: "--record: the step-done row written, else null",
|
|
1574
1809
|
commit: "--record: the new commit's sha, else null",
|
|
1810
|
+
progressLine:
|
|
1811
|
+
"--record: the exact chat progress line after a successful numbered completion",
|
|
1575
1812
|
comment:
|
|
1576
1813
|
"the step comment (with --number): verdict, contexts, artifact links, a NOT CONFIGURED line per context with no block; else null",
|
|
1577
1814
|
commentFile: COMMENT_FILE_OUTPUT,
|
|
1578
1815
|
},
|
|
1579
1816
|
exitCodes: {
|
|
1580
1817
|
[EXIT_NO_STATUS]: "--file: status.jsonl missing, unreadable, or not valid NDJSON",
|
|
1581
|
-
[EXIT_COMMIT]:
|
|
1818
|
+
[EXIT_COMMIT]:
|
|
1819
|
+
"--record: nothing written, nothing committed: the commit failed and the row was rolled back",
|
|
1582
1820
|
},
|
|
1583
1821
|
run: (ctx) => {
|
|
1584
1822
|
const attempt = debugAttempt(ctx);
|
|
@@ -1601,8 +1839,9 @@ export const contextCommand: CommandSpec = {
|
|
|
1601
1839
|
const clamped = readRecords(clampLogPath(ctx.cwd, fid, "context-fetch", attempt), (l) =>
|
|
1602
1840
|
ctx.log(`skipping a malformed clamp record: ${l}`),
|
|
1603
1841
|
);
|
|
1842
|
+
const clampSummary = summariseRecords(clamped);
|
|
1604
1843
|
const verdict = artifacts.length > 0 ? "PASS" : "FAIL";
|
|
1605
|
-
let written:
|
|
1844
|
+
let written: ReturnType<typeof writeStepRow> = {
|
|
1606
1845
|
row: {},
|
|
1607
1846
|
commit: null,
|
|
1608
1847
|
code: EXIT.OK,
|
|
@@ -1611,6 +1850,7 @@ export const contextCommand: CommandSpec = {
|
|
|
1611
1850
|
if (record) {
|
|
1612
1851
|
const file = str(ctx.flags.file);
|
|
1613
1852
|
if (file === undefined) throw new CommandError(EXIT.USAGE, "--record needs --file");
|
|
1853
|
+
const active = lastRun(readRuns(path.resolve(ctx.cwd, file)), "debug");
|
|
1614
1854
|
written = writeStepRow(
|
|
1615
1855
|
ctx.cwd,
|
|
1616
1856
|
{
|
|
@@ -1620,7 +1860,16 @@ export const contextCommand: CommandSpec = {
|
|
|
1620
1860
|
verdict,
|
|
1621
1861
|
attempt,
|
|
1622
1862
|
artifacts,
|
|
1623
|
-
extras: {
|
|
1863
|
+
extras: {
|
|
1864
|
+
contextsConfigured,
|
|
1865
|
+
clamped,
|
|
1866
|
+
clampSummary,
|
|
1867
|
+
...(active &&
|
|
1868
|
+
validateCiSelection(active.ciSelection) &&
|
|
1869
|
+
active.ciSelection.mode === "ci"
|
|
1870
|
+
? { ciGeneration: active.ciGeneration }
|
|
1871
|
+
: {}),
|
|
1872
|
+
},
|
|
1624
1873
|
commit: "auto",
|
|
1625
1874
|
message: str(ctx.flags.message),
|
|
1626
1875
|
},
|
|
@@ -1654,8 +1903,10 @@ export const contextCommand: CommandSpec = {
|
|
|
1654
1903
|
artifacts,
|
|
1655
1904
|
contextsConfigured,
|
|
1656
1905
|
clamped,
|
|
1906
|
+
clampSummary,
|
|
1657
1907
|
row: record ? written.row : null,
|
|
1658
1908
|
commit: written.commit,
|
|
1909
|
+
...(written.progressLine === undefined ? {} : { progressLine: written.progressLine }),
|
|
1659
1910
|
comment,
|
|
1660
1911
|
commentFile: commentFileOf(ctx.cwd, comment),
|
|
1661
1912
|
});
|
|
@@ -1673,6 +1924,44 @@ function tableOf(stdout: Buffer): { text: string } | { reason: string } {
|
|
|
1673
1924
|
return table.ok ? { text: table.text } : { reason: table.reason };
|
|
1674
1925
|
}
|
|
1675
1926
|
|
|
1927
|
+
/** Selected CI evidence is usable only with one complete receipt and actual logs. */
|
|
1928
|
+
function ciEvidenceProblem(
|
|
1929
|
+
stdout: Buffer,
|
|
1930
|
+
selection: Extract<CiSelection, { mode: "ci" }>,
|
|
1931
|
+
): string | null {
|
|
1932
|
+
const lines = stdout.toString("utf-8").split("\n");
|
|
1933
|
+
const receipts = lines.filter((line) => line.startsWith("bkit-ci-evidence: "));
|
|
1934
|
+
if (receipts.length !== 1) return "selected CI evidence needs exactly one identity receipt";
|
|
1935
|
+
const parsed = parseJson(receipts[0]!.slice("bkit-ci-evidence: ".length));
|
|
1936
|
+
if (
|
|
1937
|
+
!parsed.ok ||
|
|
1938
|
+
parsed.value === null ||
|
|
1939
|
+
typeof parsed.value !== "object" ||
|
|
1940
|
+
Array.isArray(parsed.value)
|
|
1941
|
+
)
|
|
1942
|
+
return "selected CI evidence receipt is malformed";
|
|
1943
|
+
const receipt = parsed.value as Record<string, unknown>;
|
|
1944
|
+
for (const field of [
|
|
1945
|
+
"provider",
|
|
1946
|
+
"repo",
|
|
1947
|
+
"runId",
|
|
1948
|
+
"runAttempt",
|
|
1949
|
+
"headSha",
|
|
1950
|
+
"workflowId",
|
|
1951
|
+
] as const) {
|
|
1952
|
+
if (receipt[field] !== selection[field]) return `selected CI evidence ${field} does not match`;
|
|
1953
|
+
}
|
|
1954
|
+
if (receipt.complete !== true) return "selected CI evidence is incomplete";
|
|
1955
|
+
const logs = lines
|
|
1956
|
+
.filter((line) => !line.startsWith("bkit-ci-evidence: "))
|
|
1957
|
+
.join("\n")
|
|
1958
|
+
.trim();
|
|
1959
|
+
if (logs === "") return "selected CI evidence contains no logs";
|
|
1960
|
+
if (/\[context-fetch:[^\n]*skipped|===== TRUNCATED:/i.test(logs))
|
|
1961
|
+
return "selected CI evidence is skipped or partial";
|
|
1962
|
+
return null;
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1676
1965
|
/**
|
|
1677
1966
|
* Run consumer block `--idx` and write what it printed, fenced and clamped. With `render`
|
|
1678
1967
|
* (`context fetch`), a JSON array of flat objects is written as a table instead; the
|
|
@@ -1705,11 +1994,35 @@ function runBlock(ctx: RunContext, render?: Render): number {
|
|
|
1705
1994
|
|
|
1706
1995
|
const repoRoot = git(ctx.cwd, ["rev-parse", "--show-toplevel"]) ?? ctx.cwd;
|
|
1707
1996
|
const fetchedAt = utcNow();
|
|
1997
|
+
const selectionFile = str(ctx.flags.ciSelectionFile);
|
|
1998
|
+
let selection: CiSelection | undefined;
|
|
1999
|
+
if (selectionFile !== undefined) {
|
|
2000
|
+
const file = path.resolve(ctx.cwd, selectionFile);
|
|
2001
|
+
if (!fs.existsSync(file))
|
|
2002
|
+
throw new CommandError(EXIT.USAGE, `--ci-selection-file ${selectionFile} does not exist`);
|
|
2003
|
+
const parsed = parseJson(fs.readFileSync(file, "utf-8"));
|
|
2004
|
+
if (!parsed.ok || !validateCiSelection(parsed.value))
|
|
2005
|
+
throw new CommandError(
|
|
2006
|
+
EXIT.USAGE,
|
|
2007
|
+
"--ci-selection-file must contain a validated CI or local selection",
|
|
2008
|
+
);
|
|
2009
|
+
selection = parsed.value;
|
|
2010
|
+
}
|
|
2011
|
+
const childEnv: NodeJS.ProcessEnv = { ...process.env };
|
|
2012
|
+
for (const key of ["BKIT_CI_RUN_ID", "BKIT_CI_RUN_ATTEMPT", "BKIT_CI_REPO", "BKIT_CI_HEAD_SHA"])
|
|
2013
|
+
delete childEnv[key];
|
|
2014
|
+
if (selection?.mode === "ci")
|
|
2015
|
+
Object.assign(childEnv, {
|
|
2016
|
+
BKIT_CI_RUN_ID: selection.runId,
|
|
2017
|
+
BKIT_CI_RUN_ATTEMPT: String(selection.runAttempt),
|
|
2018
|
+
BKIT_CI_REPO: selection.repo,
|
|
2019
|
+
BKIT_CI_HEAD_SHA: selection.headSha,
|
|
2020
|
+
});
|
|
1708
2021
|
// The inline block ran inside the step's shell, so these were in scope for it.
|
|
1709
2022
|
const res = spawnSync("bash", [script], {
|
|
1710
2023
|
cwd: ctx.cwd,
|
|
1711
2024
|
env: {
|
|
1712
|
-
...
|
|
2025
|
+
...childEnv,
|
|
1713
2026
|
REPO_ROOT: repoRoot,
|
|
1714
2027
|
CONTEXT: block.context,
|
|
1715
2028
|
NAME: block.name,
|
|
@@ -1729,6 +2042,12 @@ function runBlock(ctx: RunContext, render?: Render): number {
|
|
|
1729
2042
|
);
|
|
1730
2043
|
const out = path.resolve(ctx.cwd, artifact);
|
|
1731
2044
|
const shown = `context-fetch context=${block.context} name=${block.name || "default"}`;
|
|
2045
|
+
const evidenceProblem =
|
|
2046
|
+
selection?.mode === "ci" && block.context === "ci"
|
|
2047
|
+
? res.status !== 0 || skip !== undefined
|
|
2048
|
+
? "selected CI evidence command failed or self-skipped"
|
|
2049
|
+
: ciEvidenceProblem(stdout, selection)
|
|
2050
|
+
: null;
|
|
1732
2051
|
|
|
1733
2052
|
if (stdout.some((b) => b !== 0x0a && b !== 0)) {
|
|
1734
2053
|
fs.mkdirSync(path.dirname(out), { recursive: true });
|
|
@@ -1737,7 +2056,8 @@ function runBlock(ctx: RunContext, render?: Render): number {
|
|
|
1737
2056
|
source: fs.readFileSync(script, "utf-8"),
|
|
1738
2057
|
fetchedAt,
|
|
1739
2058
|
};
|
|
1740
|
-
|
|
2059
|
+
const printed = asCaptured(stdout);
|
|
2060
|
+
let payload = printed;
|
|
1741
2061
|
let written: Render | null = null;
|
|
1742
2062
|
if (render !== undefined) {
|
|
1743
2063
|
const table = render === "table" ? tableOf(stdout) : null;
|
|
@@ -1752,17 +2072,34 @@ function runBlock(ctx: RunContext, render?: Render): number {
|
|
|
1752
2072
|
}
|
|
1753
2073
|
}
|
|
1754
2074
|
fs.writeFileSync(out, payload);
|
|
1755
|
-
let clamp = clampFile(out,
|
|
2075
|
+
let clamp = clampFile(out, contextProfile(block.context), artifact, keep);
|
|
1756
2076
|
warnNoRaw(ctx, clamp, keep);
|
|
1757
2077
|
if (written !== null) {
|
|
1758
2078
|
const raw = clamp.raw ?? (keep.original ? outboxRel(path.dirname(out), keep.original) : null);
|
|
1759
2079
|
clamp = { ...clamp, raw, render: written };
|
|
1760
2080
|
}
|
|
2081
|
+
// Fetched is what the block printed; the table is only what the artifact keeps.
|
|
2082
|
+
if (written === "table") {
|
|
2083
|
+
clamp = { ...clamp, origLines: records(printed).length, origBytes: printed.length };
|
|
2084
|
+
}
|
|
1761
2085
|
appendRecord(clampLogPath(ctx.cwd, fid, "context-fetch", attempt), clamp);
|
|
1762
2086
|
fs.writeFileSync(out, fenced(fs.readFileSync(out)));
|
|
1763
|
-
ctx.log(
|
|
2087
|
+
ctx.log(
|
|
2088
|
+
evidenceProblem === null
|
|
2089
|
+
? `${shown} CHECKED — data returned`
|
|
2090
|
+
: `${shown} UNCHECKED — ${evidenceProblem}`,
|
|
2091
|
+
);
|
|
1764
2092
|
ctx.emit(
|
|
1765
|
-
shape(
|
|
2093
|
+
shape(
|
|
2094
|
+
{
|
|
2095
|
+
outcome: evidenceProblem === null ? "checked" : "unchecked",
|
|
2096
|
+
artifact,
|
|
2097
|
+
skip: skip ?? null,
|
|
2098
|
+
clamp,
|
|
2099
|
+
reason: evidenceProblem,
|
|
2100
|
+
},
|
|
2101
|
+
written,
|
|
2102
|
+
),
|
|
1766
2103
|
);
|
|
1767
2104
|
return EXIT.OK;
|
|
1768
2105
|
}
|
|
@@ -1783,3 +2120,44 @@ function runBlock(ctx: RunContext, render?: Render): number {
|
|
|
1783
2120
|
);
|
|
1784
2121
|
return EXIT.OK;
|
|
1785
2122
|
}
|
|
2123
|
+
|
|
2124
|
+
/**
|
|
2125
|
+
* Run the consumer's provision recipes through the same region the cloud setup scripts
|
|
2126
|
+
* inline, with `REPO_ROOT` set so the region rewrites the failure list there. Recipe
|
|
2127
|
+
* output goes to stderr; stdout carries only this command's report. Never fails on a
|
|
2128
|
+
* recipe: a failure is reported, not raised.
|
|
2129
|
+
*/
|
|
2130
|
+
function runProvision(ctx: RunContext): number {
|
|
2131
|
+
const repoRoot = git(ctx.cwd, ["rev-parse", "--show-toplevel"]) ?? ctx.cwd;
|
|
2132
|
+
const file = path.join(repoRoot, UNAVAILABLE_RELPATH);
|
|
2133
|
+
const region = renderCloudContextFetchProvision(ctx.cwd);
|
|
2134
|
+
const recipes = region === "" ? 0 : (region.match(/^bkit_provision '/gm) ?? []).length;
|
|
2135
|
+
if (region === "") {
|
|
2136
|
+
fs.rmSync(file, { force: true });
|
|
2137
|
+
} else {
|
|
2138
|
+
const res = spawnSync("bash", ["-c", `set -uo pipefail\n${region}`], {
|
|
2139
|
+
cwd: ctx.cwd,
|
|
2140
|
+
env: { ...process.env, REPO_ROOT: repoRoot },
|
|
2141
|
+
stdio: ["ignore", 2, 2],
|
|
2142
|
+
});
|
|
2143
|
+
if (res.error) throw new CommandError(EXIT.USAGE, `bash did not run: ${res.error.message}`);
|
|
2144
|
+
}
|
|
2145
|
+
const unavailable = fs.existsSync(file)
|
|
2146
|
+
? fs
|
|
2147
|
+
.readFileSync(file, "utf-8")
|
|
2148
|
+
.split("\n")
|
|
2149
|
+
.filter((l) => l !== "")
|
|
2150
|
+
.map((l) => {
|
|
2151
|
+
const at = l.indexOf(": ");
|
|
2152
|
+
return at === -1
|
|
2153
|
+
? { name: l, reason: "" }
|
|
2154
|
+
: { name: l.slice(0, at), reason: l.slice(at + 2) };
|
|
2155
|
+
})
|
|
2156
|
+
: [];
|
|
2157
|
+
ctx.emit({
|
|
2158
|
+
recipes,
|
|
2159
|
+
unavailable,
|
|
2160
|
+
file: unavailable.length === 0 ? null : UNAVAILABLE_RELPATH,
|
|
2161
|
+
});
|
|
2162
|
+
return EXIT.OK;
|
|
2163
|
+
}
|