@cbartens/bkit 0.0.0-stage → 5.0.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 +421 -0
- package/.bkit/core/.agents/context.md +95 -0
- package/.bkit/core/.agents/docs.md +62 -0
- package/.bkit/core/.agents/rules.md +147 -0
- package/.bkit/core/.agents/skills.md +43 -0
- package/.bkit/core/.bkit/LICENSE.md +151 -0
- package/.bkit/core/.bkit/README.md +421 -0
- package/.bkit/core/.bkit/cloud.md +502 -0
- package/.bkit/core/.bkit/comparison.md +318 -0
- package/.bkit/core/.bkit/install.md +496 -0
- package/.bkit/core/.bkit/jsonl.md +497 -0
- package/.bkit/core/.bkit/prompts.md +474 -0
- package/.bkit/core/.bkit/providers.md +598 -0
- package/.bkit/core/.bkit/templates.md +471 -0
- package/.bkit/core/.bkit/trackers.md +95 -0
- package/.bkit/core/.bkit/workflows.md +1546 -0
- package/.bkit/core/.claude/hooks/bkit-gateguard.cjs +82 -0
- package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +93 -0
- package/.bkit/core/.claude/hooks/bkit-preflight.sh +74 -0
- package/.bkit/core/.codex/hooks/bkit-gateguard.cjs +115 -0
- package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +135 -0
- package/.bkit/core/.cursor/hooks/bkit-gateguard.cjs +111 -0
- package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +169 -0
- package/.bkit/core/.cursor/hooks/bkit-preflight.sh +63 -0
- package/.bkit/core/.opencode/plugin/bkit-gateguard.js +225 -0
- package/.bkit/core/AGENTS.md +77 -0
- package/.bkit/core/LICENSE.md +149 -0
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +272 -0
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +223 -0
- package/.bkit/core/docs/templates/bkit-audit-agents.md +230 -0
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +227 -0
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +266 -0
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +230 -0
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +270 -0
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +254 -0
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +221 -0
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +241 -0
- package/.bkit/core/docs/templates/bkit-audit-config.md +230 -0
- package/.bkit/core/docs/templates/bkit-audit-cost.md +218 -0
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +221 -0
- package/.bkit/core/docs/templates/bkit-audit-database.md +229 -0
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +251 -0
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +283 -0
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +268 -0
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +280 -0
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +253 -0
- package/.bkit/core/docs/templates/bkit-audit-failures.md +259 -0
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +237 -0
- package/.bkit/core/docs/templates/bkit-audit-gates.md +250 -0
- package/.bkit/core/docs/templates/bkit-audit-issues.md +273 -0
- package/.bkit/core/docs/templates/bkit-audit-llm.md +239 -0
- package/.bkit/core/docs/templates/bkit-audit-logs.md +266 -0
- package/.bkit/core/docs/templates/bkit-audit-models.md +210 -0
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +211 -0
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +216 -0
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +220 -0
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +222 -0
- package/.bkit/core/docs/templates/bkit-audit-repo.md +224 -0
- package/.bkit/core/docs/templates/bkit-audit-security.md +274 -0
- package/.bkit/core/docs/templates/bkit-audit-slop.md +200 -0
- package/.bkit/core/docs/templates/bkit-audit-testing.md +270 -0
- package/.bkit/core/docs/templates/bkit-audit-usability.md +237 -0
- package/.bkit/core/docs/templates/bkit-plan.md +476 -0
- package/.bkit/core/engine/checks/after/auth.ts +247 -0
- package/.bkit/core/engine/checks/after/ci-yml.ts +739 -0
- package/.bkit/core/engine/checks/after/github.ts +424 -0
- package/.bkit/core/engine/checks/after/index.ts +556 -0
- package/.bkit/core/engine/checks/after/managed.ts +217 -0
- package/.bkit/core/engine/checks/after/tools.ts +427 -0
- package/.bkit/core/engine/checks/after/vercel.ts +101 -0
- package/.bkit/core/engine/checks/before/context-fetch.ts +429 -0
- package/.bkit/core/engine/checks/before/env.ts +201 -0
- package/.bkit/core/engine/checks/before/files.ts +202 -0
- package/.bkit/core/engine/checks/before/index.ts +206 -0
- package/.bkit/core/engine/checks/before/mcp.ts +127 -0
- package/.bkit/core/engine/checks/before/repo.ts +77 -0
- package/.bkit/core/engine/checks/before/version.ts +67 -0
- package/.bkit/core/engine/checks/status-holes.ts +479 -0
- package/.bkit/core/engine/cli.ts +871 -0
- package/.bkit/core/engine/commands/analysis.ts +550 -0
- package/.bkit/core/engine/commands/ci/ci.ts +483 -0
- package/.bkit/core/engine/commands/comply.ts +415 -0
- package/.bkit/core/engine/commands/harvest.ts +459 -0
- package/.bkit/core/engine/commands/install/check.ts +70 -0
- package/.bkit/core/engine/commands/install/doctor.ts +247 -0
- package/.bkit/core/engine/commands/install/install.ts +528 -0
- package/.bkit/core/engine/commands/install/uninstall.ts +972 -0
- package/.bkit/core/engine/commands/install/upgrade.ts +1026 -0
- package/.bkit/core/engine/commands/launch.ts +139 -0
- package/.bkit/core/engine/commands/lib.ts +494 -0
- package/.bkit/core/engine/commands/registry.ts +53 -0
- package/.bkit/core/engine/commands/setup/setup.ts +184 -0
- package/.bkit/core/engine/commands/telemetry.ts +32 -0
- package/.bkit/core/engine/commands/workflow/branches.ts +1514 -0
- package/.bkit/core/engine/commands/workflow/context.ts +961 -0
- package/.bkit/core/engine/commands/workflow/counters.ts +268 -0
- package/.bkit/core/engine/commands/workflow/fids.ts +243 -0
- package/.bkit/core/engine/commands/workflow/issues.ts +675 -0
- package/.bkit/core/engine/commands/workflow/ledgers.ts +575 -0
- package/.bkit/core/engine/commands/workflow/locks.ts +478 -0
- package/.bkit/core/engine/commands/workflow/prs.ts +1087 -0
- package/.bkit/core/engine/commands/workflow/repo.ts +220 -0
- package/.bkit/core/engine/commands/workflow/roadmap.ts +576 -0
- package/.bkit/core/engine/commands/workflow/runs.ts +2140 -0
- package/.bkit/core/engine/commands/workflow/runtime.ts +300 -0
- package/.bkit/core/engine/commands/workflow/skills.ts +118 -0
- package/.bkit/core/engine/commands/workflow/status.ts +455 -0
- package/.bkit/core/engine/commands/workflow/steps.ts +1300 -0
- package/.bkit/core/engine/commands/workflow/tests.ts +161 -0
- package/.bkit/core/engine/commands/workflow/workflows.ts +1573 -0
- package/.bkit/core/engine/commands/workflow/workstreams.ts +164 -0
- package/.bkit/core/engine/commands/workflow/worktrees.ts +534 -0
- package/.bkit/core/engine/install/cloud-env.ts +925 -0
- package/.bkit/core/engine/install/managed-block.ts +212 -0
- package/.bkit/core/engine/install/manifest.ts +448 -0
- package/.bkit/core/engine/install/modules/claude.ts +362 -0
- package/.bkit/core/engine/install/modules/cloud.ts +174 -0
- package/.bkit/core/engine/install/modules/codex.ts +219 -0
- package/.bkit/core/engine/install/modules/core.ts +600 -0
- package/.bkit/core/engine/install/modules/cursor.ts +231 -0
- package/.bkit/core/engine/install/modules/index.ts +242 -0
- package/.bkit/core/engine/install/modules/opencode.ts +573 -0
- package/.bkit/core/engine/install/placeholders.ts +108 -0
- package/.bkit/core/engine/install/template-copies.ts +119 -0
- package/.bkit/core/engine/install/version-file.ts +284 -0
- package/.bkit/core/engine/install/write.ts +467 -0
- package/.bkit/core/engine/ledgers/clamp-log.ts +32 -0
- package/.bkit/core/engine/ledgers/status.ts +213 -0
- package/.bkit/core/engine/ledgers/telemetry.ts +1143 -0
- package/.bkit/core/engine/render/hosts.ts +372 -0
- package/.bkit/core/engine/render/models.ts +323 -0
- package/.bkit/core/engine/render/parts.ts +38 -0
- package/.bkit/core/engine/render/trackers.ts +170 -0
- package/.bkit/core/engine/shared/egress.ts +345 -0
- package/.bkit/core/engine/shared/json.ts +16 -0
- package/.bkit/core/engine/shared/log-prefix.ts +9 -0
- package/.bkit/core/engine/shared/package-json.ts +29 -0
- package/.bkit/core/engine/shared/package-manager.ts +38 -0
- package/.bkit/core/engine/shared/package-roots.ts +163 -0
- package/.bkit/core/engine/shared/protected-paths.ts +164 -0
- package/.bkit/core/engine/shared/settings.ts +72 -0
- package/.bkit/core/engine/shared/timeouts.ts +20 -0
- package/.bkit/core/engine/tools/wording.ts +748 -0
- package/.bkit/core/hooks/gateguard-edit-payload.js +18 -0
- package/.bkit/core/hooks/gateguard-engine.js +193 -0
- package/.bkit/core/hooks/guardrails-shell.js +154 -0
- package/.bkit/core/hooks/guardrails-tiers.js +68 -0
- package/.bkit/core/hooks/preflight-linear.sh +73 -0
- package/.bkit/core/prompts/bkit-audit-generate.md +66 -0
- package/.bkit/core/prompts/bkit-build-challenge-1.md +79 -0
- package/.bkit/core/prompts/bkit-build-challenge-2.md +81 -0
- package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +68 -0
- package/.bkit/core/prompts/bkit-build-challenge-remediate.md +70 -0
- package/.bkit/core/prompts/bkit-build-challenge-tests.md +73 -0
- package/.bkit/core/prompts/bkit-build-install-skills.md +67 -0
- package/.bkit/core/prompts/bkit-build-plan-current.md +75 -0
- package/.bkit/core/prompts/bkit-build-plan-execute.md +72 -0
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +73 -0
- package/.bkit/core/prompts/bkit-build-plan-verify.md +88 -0
- package/.bkit/core/prompts/bkit-build-summary.md +93 -0
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +90 -0
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +151 -0
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +78 -0
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +73 -0
- package/.bkit/core/prompts/bkit-debug-summary.md +95 -0
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +72 -0
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +72 -0
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +75 -0
- package/.bkit/core/prompts/bkit-design-generate.md +110 -0
- package/.bkit/core/prompts/bkit-design-organise.md +85 -0
- package/.bkit/core/prompts/bkit-design-review-1.md +121 -0
- package/.bkit/core/prompts/bkit-design-review-2.md +111 -0
- package/.bkit/core/prompts/bkit-design-spike.md +97 -0
- package/.bkit/core/prompts/bkit-design-summary.md +106 -0
- package/.bkit/core/prompts/bkit-design-update.md +66 -0
- package/.bkit/core/prompts/bkit-plan-complexity-check.md +66 -0
- package/.bkit/core/prompts/bkit-plan-complexity-split.md +87 -0
- package/.bkit/core/prompts/bkit-plan-generate.md +74 -0
- package/.bkit/core/prompts/bkit-plan-review-1.md +90 -0
- package/.bkit/core/prompts/bkit-plan-review-2.md +80 -0
- package/.bkit/core/prompts/bkit-plan-review-3.md +92 -0
- package/.bkit/core/prompts/bkit-plan-scope-check-1.md +84 -0
- package/.bkit/core/prompts/bkit-plan-scope-check-2.md +84 -0
- package/.bkit/core/prompts/bkit-plan-summary.md +106 -0
- package/.bkit/core/prompts/bkit-plan-update.md +68 -0
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +90 -0
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +94 -0
- package/.bkit/core/prompts/bkit-ship-summary.md +77 -0
- package/.bkit/core/prompts/bkit-ship-update-docs.md +71 -0
- package/.bkit/core/prompts/bkit-utility-compress-markdown.md +91 -0
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +75 -0
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +76 -0
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +61 -0
- package/.bkit/core/prompts/bkit-utility-update-failures.md +76 -0
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +75 -0
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +82 -0
- package/.bkit/core/workflows/bkit-auto.md +121 -0
- package/.bkit/core/workflows/bkit-build.md +802 -0
- package/.bkit/core/workflows/bkit-debug.md +642 -0
- package/.bkit/core/workflows/bkit-design.md +495 -0
- package/.bkit/core/workflows/bkit-plan.md +510 -0
- package/.bkit/core/workflows/bkit-ship.md +650 -0
- package/.bkit/shared/.bkit/.env.example +108 -0
- package/.bkit/shared/.claude/bkit-cloud.md +117 -0
- package/.bkit/shared/.claude/settings.json +88 -0
- package/.bkit/shared/.codex/hooks.json +26 -0
- package/.bkit/shared/.cursor/bkit-cloud.md +84 -0
- package/.bkit/shared/.cursor/hooks.json +26 -0
- package/.bkit/shared/.cursor/mcp.json +15 -0
- package/.bkit/shared/.cursor/rules/bkit-rules.mdc +12 -0
- package/.bkit/shared/.gitattributes +37 -0
- package/.bkit/shared/.mcp.json +16 -0
- package/.bkit/shared/.opencode/opencode.json +62 -0
- package/.bkit/shared/CLAUDE.md +11 -0
- package/.bkit/shared/LICENSE.md +22 -0
- package/.bkit/shared/docs/architecture.md +19 -0
- package/.bkit/shared/docs/data-schema.md +19 -0
- package/.bkit/shared/docs/deployments.md +438 -0
- package/.bkit/shared/docs/design.md +39 -0
- package/.bkit/shared/docs/noise.md +19 -0
- package/.bkit/shared/docs/observability.md +25 -0
- package/.bkit/shared/docs/security.md +42 -0
- package/.bkit/shared/docs/setup.md +30 -0
- package/.bkit/shared/docs/technology.md +18 -0
- package/.bkit/shared/docs/testing.md +413 -0
- package/.bkit/shared/gitignore +92 -0
- package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +192 -0
- package/.bkit/templates/.cursor/Dockerfile +68 -0
- package/.bkit/templates/.cursor/environment.json +6 -0
- package/.bkit/templates/.cursor/settings.json +11 -0
- package/.bkit/templates/.envrc +7 -0
- package/.bkit/templates/.github/dependabot.yml +52 -0
- package/.bkit/templates/.github/renovate.json5 +239 -0
- package/.bkit/templates/.github/workflows/bkit-ci.yml +1082 -0
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +566 -0
- package/.bkit/templates/.github/workflows/bkit-renovate.yml +107 -0
- package/.bkit/templates/.graphifyignore +108 -0
- package/.bkit/templates/.husky/pre-commit +16 -0
- package/.bkit/templates/.husky/pre-push +91 -0
- package/.bkit/templates/.lintstagedrc.json +3 -0
- package/.bkit/templates/.prettierignore +41 -0
- package/.bkit/templates/.serena/project.yml +243 -0
- package/.bkit/templates/.vale/styles/House/Filler.yml +11 -0
- package/.bkit/templates/.vale/styles/House/Hedging.yml +12 -0
- package/.bkit/templates/.vale/styles/House/LLMSlop.yml +13 -0
- package/.bkit/templates/.vale/styles/House/Verbose.yml +12 -0
- package/.bkit/templates/.vale.ini +67 -0
- package/.bkit/templates/LICENSE.md +22 -0
- package/.bkit/templates/context/bkit-cloudrun.md +84 -0
- package/.bkit/templates/context/bkit-expo.md +186 -0
- package/.bkit/templates/context/bkit-github.md +79 -0
- package/.bkit/templates/context/bkit-inngest.md +45 -0
- package/.bkit/templates/context/bkit-maestro.md +76 -0
- package/.bkit/templates/context/bkit-playwright.md +62 -0
- package/.bkit/templates/context/bkit-resend.md +36 -0
- package/.bkit/templates/context/bkit-sentry.md +65 -0
- package/.bkit/templates/context/bkit-serena.md +33 -0
- package/.bkit/templates/context/bkit-stripe.md +36 -0
- package/.bkit/templates/context/bkit-supabase.md +59 -0
- package/.bkit/templates/context/bkit-tavily.md +49 -0
- package/.bkit/templates/context/bkit-vercel.md +64 -0
- package/.bkit/templates/docs/capabilities.md +72 -0
- package/.bkit/templates/scripts/ci/accepted-divergences.json +21 -0
- package/.bkit/templates/scripts/ci/check-accepted-divergences.mjs +152 -0
- package/.bkit/templates/scripts/ci/check-accepted-divergences.test.mjs +130 -0
- package/.bkit/templates/scripts/ci/lanes/resolve-push-base.mjs +98 -0
- package/.bkit/templates/scripts/ci/lanes/resolve-push-base.test.mjs +86 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-drift-rules.json +23 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-drift.py +208 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-eager-rules.json +35 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-eager.py +236 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-external-rules.json +17 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-imports.py +290 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +19 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-repair.py +120 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-surface.py +232 -0
- package/.bkit/templates/scripts/graphify/bkit-graphify-graphml.py +36 -0
- package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +927 -0
- package/.bkit/templates/scripts/graphify/bkit-graphify.sh +351 -0
- package/.bkit/templates/scripts/launchd/ai.bkit.launchd.plist +26 -0
- package/.bkit/templates/scripts/launchd/bkit-launchd-env.sh +53 -0
- package/.bkit/templates/scripts/launchd/launchd.env.example +13 -0
- package/.bkit/templates/scripts/prettier/bkit-insert-ignore.mjs +275 -0
- package/.bkit/templates/scripts/secrets/bkit-secrets.config.mjs +66 -0
- package/.bkit/templates/scripts/secrets/bkit-secrets.mjs +785 -0
- package/.bkit/templates/scripts/serena/bkit-serena-mcp.sh +30 -0
- package/.bkit/templates/scripts/serena/bkit-serena.mcp.json +9 -0
- package/.bkit/templates/scripts/slop/bkit-slop-type-suppression.mjs +286 -0
- package/.bkit/templates/slop-scan.config.json +120 -0
- package/CHANGELOG.md +1486 -0
- package/LICENSE.md +161 -0
- package/README.md +185 -2
- package/dist/checks/after/auth.js +232 -0
- package/dist/checks/after/ci-yml.js +718 -0
- package/dist/checks/after/github.js +400 -0
- package/dist/checks/after/index.js +447 -0
- package/dist/checks/after/managed.js +187 -0
- package/dist/checks/after/tools.js +351 -0
- package/dist/checks/after/vercel.js +102 -0
- package/dist/checks/before/context-fetch.js +426 -0
- package/dist/checks/before/env.js +173 -0
- package/dist/checks/before/files.js +185 -0
- package/dist/checks/before/index.js +162 -0
- package/dist/checks/before/mcp.js +111 -0
- package/dist/checks/before/repo.js +71 -0
- package/dist/checks/before/version.js +60 -0
- package/dist/checks/status-holes.js +393 -0
- package/dist/cli.js +692 -0
- package/dist/commands/analysis.js +325 -0
- package/dist/commands/ci/ci.js +438 -0
- package/dist/commands/comply.js +310 -0
- package/dist/commands/harvest.js +354 -0
- package/dist/commands/install/check.js +61 -0
- package/dist/commands/install/doctor.js +207 -0
- package/dist/commands/install/install.js +461 -0
- package/dist/commands/install/uninstall.js +815 -0
- package/dist/commands/install/upgrade.js +771 -0
- package/dist/commands/launch.js +118 -0
- package/dist/commands/lib.js +362 -0
- package/dist/commands/registry.js +50 -0
- package/dist/commands/setup/setup.js +158 -0
- package/dist/commands/telemetry.js +29 -0
- package/dist/commands/workflow/branches.js +1265 -0
- package/dist/commands/workflow/context.js +846 -0
- package/dist/commands/workflow/counters.js +227 -0
- package/dist/commands/workflow/fids.js +224 -0
- package/dist/commands/workflow/issues.js +585 -0
- package/dist/commands/workflow/ledgers.js +472 -0
- package/dist/commands/workflow/locks.js +364 -0
- package/dist/commands/workflow/prs.js +904 -0
- package/dist/commands/workflow/repo.js +199 -0
- package/dist/commands/workflow/roadmap.js +495 -0
- package/dist/commands/workflow/runs.js +1717 -0
- package/dist/commands/workflow/runtime.js +257 -0
- package/dist/commands/workflow/skills.js +110 -0
- package/dist/commands/workflow/status.js +392 -0
- package/dist/commands/workflow/steps.js +1093 -0
- package/dist/commands/workflow/tests.js +144 -0
- package/dist/commands/workflow/workflows.js +1342 -0
- package/dist/commands/workflow/workstreams.js +141 -0
- package/dist/commands/workflow/worktrees.js +473 -0
- package/dist/install/cloud-env.js +819 -0
- package/dist/install/managed-block.js +182 -0
- package/dist/install/manifest.js +376 -0
- package/dist/install/modules/claude.js +288 -0
- package/dist/install/modules/cloud.js +152 -0
- package/dist/install/modules/codex.js +193 -0
- package/dist/install/modules/core.js +511 -0
- package/dist/install/modules/cursor.js +186 -0
- package/dist/install/modules/index.js +152 -0
- package/dist/install/modules/opencode.js +504 -0
- package/dist/install/placeholders.js +87 -0
- package/dist/install/template-copies.js +106 -0
- package/dist/install/version-file.js +204 -0
- package/dist/install/write.js +342 -0
- package/dist/ledgers/clamp-log.js +27 -0
- package/dist/ledgers/status.js +156 -0
- package/dist/ledgers/telemetry.js +637 -0
- package/dist/render/hosts.js +339 -0
- package/dist/render/models.js +288 -0
- package/dist/render/parts.js +33 -0
- package/dist/render/trackers.js +135 -0
- package/dist/shared/egress.js +299 -0
- package/dist/shared/json.js +16 -0
- package/dist/shared/log-prefix.js +7 -0
- package/dist/shared/package-json.js +22 -0
- package/dist/shared/package-manager.js +32 -0
- package/dist/shared/package-roots.js +145 -0
- package/dist/shared/protected-paths.js +153 -0
- package/dist/shared/settings.js +44 -0
- package/dist/shared/timeouts.js +19 -0
- package/dist/tools/wording.js +680 -0
- package/package.json +101 -4
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Example. Copy into scripts/ci/ and own it. bkit install does not write this file
|
|
3
|
+
// and does not overwrite a copy.
|
|
4
|
+
/**
|
|
5
|
+
* check-accepted-divergences.test.mjs — unit tests for the accepted-divergence guard.
|
|
6
|
+
*
|
|
7
|
+
* Pure Node, no runner: `node scripts/ci/check-accepted-divergences.test.mjs`.
|
|
8
|
+
* Exit: 0 = all tests passed, 1 = at least one test failed.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import fs from "node:fs";
|
|
12
|
+
import os from "node:os";
|
|
13
|
+
import path from "node:path";
|
|
14
|
+
import { collectSites, checkRegistry } from "./check-accepted-divergences.mjs";
|
|
15
|
+
|
|
16
|
+
let passed = 0;
|
|
17
|
+
let failed = 0;
|
|
18
|
+
|
|
19
|
+
function test(name, fn) {
|
|
20
|
+
try {
|
|
21
|
+
fn();
|
|
22
|
+
passed++;
|
|
23
|
+
console.log(` ok ${name}`);
|
|
24
|
+
} catch (err) {
|
|
25
|
+
failed++;
|
|
26
|
+
console.log(` FAIL ${name} — ${err.message}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function assert(cond, message) {
|
|
31
|
+
if (!cond) throw new Error(message);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const WORKFLOW = [
|
|
35
|
+
"name: CI",
|
|
36
|
+
"on:",
|
|
37
|
+
" push:",
|
|
38
|
+
"jobs:",
|
|
39
|
+
" bkit-tests-static:",
|
|
40
|
+
" steps:",
|
|
41
|
+
" - name: Check Default Branch Lags Dev",
|
|
42
|
+
" if: github.event_name == 'push' && github.ref == 'refs/heads/dev'",
|
|
43
|
+
" run: echo hi",
|
|
44
|
+
" bkit-tests-check:",
|
|
45
|
+
" if: ${{ !cancelled() }}",
|
|
46
|
+
" steps:",
|
|
47
|
+
" - name: Assert Test Plan Followed",
|
|
48
|
+
" run: node scripts/ci/assert-test-plan-followed.mjs",
|
|
49
|
+
"",
|
|
50
|
+
].join("\n");
|
|
51
|
+
|
|
52
|
+
function withWorkflows(write, fn) {
|
|
53
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "div-guard-"));
|
|
54
|
+
fs.writeFileSync(path.join(dir, "bkit-ci.yml"), write);
|
|
55
|
+
try {
|
|
56
|
+
fn(dir);
|
|
57
|
+
} finally {
|
|
58
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
test("collects every event-keyed site with its job and step", () => {
|
|
63
|
+
withWorkflows(WORKFLOW, (dir) => {
|
|
64
|
+
const sites = collectSites(dir);
|
|
65
|
+
const keys = sites.map((s) => `${s.job}#${s.step}#${s.field}`).sort();
|
|
66
|
+
assert(
|
|
67
|
+
keys.includes("bkit-tests-static#Check Default Branch Lags Dev#github.event_name"),
|
|
68
|
+
keys.join(", "),
|
|
69
|
+
);
|
|
70
|
+
assert(
|
|
71
|
+
keys.includes("bkit-tests-static#Check Default Branch Lags Dev#github.ref"),
|
|
72
|
+
keys.join(", "),
|
|
73
|
+
);
|
|
74
|
+
assert(sites.length === 2, `expected 2 sites, got ${sites.length}`);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("an unregistered site is reported missing", () => {
|
|
79
|
+
const sites = [
|
|
80
|
+
{ file: ".github/workflows/bkit-ci.yml", job: "j", step: "s", field: "github.event_name" },
|
|
81
|
+
];
|
|
82
|
+
const r = checkRegistry(sites, { decisions: ["one-run-per-branch"], sites: [] });
|
|
83
|
+
assert(r.missing.length === 1, "expected one missing");
|
|
84
|
+
assert(r.stale.length === 0, "expected no stale");
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test("a registry row that no longer exists is stale", () => {
|
|
88
|
+
const rows = [
|
|
89
|
+
{
|
|
90
|
+
file: ".github/workflows/bkit-ci.yml",
|
|
91
|
+
job: "gone",
|
|
92
|
+
step: "gone",
|
|
93
|
+
field: "github.ref",
|
|
94
|
+
decision: "one-run-per-branch",
|
|
95
|
+
reason: "x",
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
const r = checkRegistry([], { decisions: ["one-run-per-branch"], sites: rows });
|
|
99
|
+
assert(r.stale.length === 1, "expected one stale");
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test("a row with an unknown decision or no reason is flagged", () => {
|
|
103
|
+
const site = {
|
|
104
|
+
file: ".github/workflows/bkit-ci.yml",
|
|
105
|
+
job: "j",
|
|
106
|
+
step: "s",
|
|
107
|
+
field: "github.ref",
|
|
108
|
+
};
|
|
109
|
+
const rows = [{ ...site, decision: "not-a-decision", reason: "x" }];
|
|
110
|
+
const r = checkRegistry([site], { decisions: ["one-run-per-branch"], sites: rows });
|
|
111
|
+
assert(r.badDecision.length === 1, "expected one badDecision");
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("a registered, live, reasoned site is clean", () => {
|
|
115
|
+
const site = {
|
|
116
|
+
file: ".github/workflows/bkit-ci.yml",
|
|
117
|
+
job: "j",
|
|
118
|
+
step: "s",
|
|
119
|
+
field: "github.ref",
|
|
120
|
+
};
|
|
121
|
+
const rows = [{ ...site, decision: "one-run-per-branch", reason: "why" }];
|
|
122
|
+
const r = checkRegistry([site], { decisions: ["one-run-per-branch"], sites: rows });
|
|
123
|
+
assert(
|
|
124
|
+
r.missing.length === 0 && r.stale.length === 0 && r.badDecision.length === 0,
|
|
125
|
+
JSON.stringify(r),
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
console.log(`\n${passed} passed, ${failed} failed`);
|
|
130
|
+
process.exit(failed > 0 ? 1 : 0);
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Example. Copy into scripts/ci/lanes/ and own it. bkit install does not write this file
|
|
3
|
+
// and does not overwrite a copy.
|
|
4
|
+
/**
|
|
5
|
+
* resolve-push-base.mjs — the diff base for a push run's test plan.
|
|
6
|
+
*
|
|
7
|
+
* A newer run on a branch cancels the older one, so the previous push's run may never have
|
|
8
|
+
* finished — and `github.event.before` is that previous push. Diffing against it would leave
|
|
9
|
+
* the cancelled push's changes out of every plan. The base is therefore the head of the last
|
|
10
|
+
* push run on this branch that SUCCEEDED: everything since the last green run is in scope,
|
|
11
|
+
* including anything a cancelled or red run carried. When there is no such run, or its head
|
|
12
|
+
* is not an ancestor of HEAD (a force-push rewrote the branch), the base falls back to
|
|
13
|
+
* `event.before`.
|
|
14
|
+
*
|
|
15
|
+
* Usage: node scripts/ci/lanes/resolve-push-base.mjs (env: GH_TOKEN, REPO, BRANCH, BEFORE_SHA, WORKFLOW_FILE)
|
|
16
|
+
* Output: the base SHA on stdout. Exit 0 always — the fallback is itself a valid base.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { spawnSync } from "node:child_process";
|
|
20
|
+
import { pathToFileURL } from "node:url";
|
|
21
|
+
|
|
22
|
+
/** The workflow whose runs establish the base. Set WORKFLOW_FILE if your CI file has another name. */
|
|
23
|
+
export const WORKFLOW_FILE = process.env.WORKFLOW_FILE || "bkit-ci.yml";
|
|
24
|
+
|
|
25
|
+
/** Pure decision. `isAncestor(sha)` answers whether `sha` is an ancestor of HEAD. */
|
|
26
|
+
export function choosePushBase({ lastGreenSha, beforeSha, isAncestor }) {
|
|
27
|
+
if (lastGreenSha && isAncestor(lastGreenSha)) {
|
|
28
|
+
return { base: lastGreenSha, source: "last-green-run" };
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
base: beforeSha ?? "",
|
|
32
|
+
source: lastGreenSha ? "event-before (last green run is not an ancestor)" : "event-before",
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** How far back the run lookup reaches. A green run older than this falls back to event.before. */
|
|
37
|
+
export const LOOKBACK_DAYS = 14;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The newest run in a list, by run number. The list's own order is NOT trusted — pick the
|
|
41
|
+
* highest `run_number`, never the first row returned.
|
|
42
|
+
*/
|
|
43
|
+
export function newestRunSha(runs) {
|
|
44
|
+
let newest = null;
|
|
45
|
+
for (const run of runs ?? []) {
|
|
46
|
+
if (typeof run?.head_sha !== "string" || !Number.isFinite(run?.run_number)) continue;
|
|
47
|
+
if (!newest || run.run_number > newest.run_number) newest = run;
|
|
48
|
+
}
|
|
49
|
+
return newest ? newest.head_sha : "";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function lastGreenPushSha(repo, branch, now = new Date()) {
|
|
53
|
+
const since = new Date(now.getTime() - LOOKBACK_DAYS * 86_400_000).toISOString().slice(0, 10);
|
|
54
|
+
const path =
|
|
55
|
+
`repos/${repo}/actions/workflows/${WORKFLOW_FILE}/runs` +
|
|
56
|
+
`?branch=${encodeURIComponent(branch)}&event=push&status=success` +
|
|
57
|
+
`&created=${encodeURIComponent(`>=${since}`)}&per_page=100`;
|
|
58
|
+
const { status, stdout, stderr, error } = spawnSync(
|
|
59
|
+
"gh",
|
|
60
|
+
["api", path, "--jq", "[.workflow_runs[] | {run_number, head_sha}]"],
|
|
61
|
+
{ encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] },
|
|
62
|
+
);
|
|
63
|
+
// No run list (gh missing, API or auth failure) is not fatal: the caller falls back to
|
|
64
|
+
// event.before. The reason is logged.
|
|
65
|
+
if (error || status !== 0) {
|
|
66
|
+
const reason = error ? error.message : String(stderr).split("\n")[0];
|
|
67
|
+
console.error(
|
|
68
|
+
`[resolve-push-base] could not list ${WORKFLOW_FILE} runs (${reason}) — using event.before`,
|
|
69
|
+
);
|
|
70
|
+
return "";
|
|
71
|
+
}
|
|
72
|
+
return newestRunSha(JSON.parse(stdout || "[]"));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function isAncestorOfHead(sha) {
|
|
76
|
+
const { status, error } = spawnSync("git", ["merge-base", "--is-ancestor", sha, "HEAD"], {
|
|
77
|
+
stdio: "ignore",
|
|
78
|
+
});
|
|
79
|
+
if (error) throw error;
|
|
80
|
+
// 0 = ancestor. 1 = not an ancestor. 128 = the SHA is not in this clone (a force-push dropped
|
|
81
|
+
// it from the branch), which is also "not an ancestor". Anything else is a real git failure.
|
|
82
|
+
if (status === 0) return true;
|
|
83
|
+
if (status === 1 || status === 128) return false;
|
|
84
|
+
throw new Error(`git merge-base --is-ancestor ${sha} HEAD exited ${status}`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function main(env) {
|
|
88
|
+
const lastGreenSha = lastGreenPushSha(env.REPO, env.BRANCH);
|
|
89
|
+
const { base, source } = choosePushBase({
|
|
90
|
+
lastGreenSha,
|
|
91
|
+
beforeSha: env.BEFORE_SHA,
|
|
92
|
+
isAncestor: isAncestorOfHead,
|
|
93
|
+
});
|
|
94
|
+
console.error(`[resolve-push-base] base=${base || "(none)"} source=${source}`);
|
|
95
|
+
process.stdout.write(`${base}\n`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) main(process.env);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Example. Copy into scripts/ci/lanes/ and own it. bkit install does not write this file
|
|
3
|
+
// and does not overwrite a copy.
|
|
4
|
+
/**
|
|
5
|
+
* resolve-push-base.test.mjs — unit tests for the push-run diff base.
|
|
6
|
+
*
|
|
7
|
+
* Pure Node, no runner: `node scripts/ci/lanes/resolve-push-base.test.mjs`.
|
|
8
|
+
* Exit: 0 = all tests passed, 1 = at least one test failed.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { choosePushBase, newestRunSha } from "./resolve-push-base.mjs";
|
|
12
|
+
|
|
13
|
+
let passed = 0;
|
|
14
|
+
let failed = 0;
|
|
15
|
+
|
|
16
|
+
function test(name, fn) {
|
|
17
|
+
try {
|
|
18
|
+
fn();
|
|
19
|
+
passed++;
|
|
20
|
+
console.log(` ok ${name}`);
|
|
21
|
+
} catch (err) {
|
|
22
|
+
failed++;
|
|
23
|
+
console.log(` FAIL ${name} — ${err.message}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function assert(cond, message) {
|
|
28
|
+
if (!cond) throw new Error(message);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const GREEN = "a".repeat(40);
|
|
32
|
+
const BEFORE = "b".repeat(40);
|
|
33
|
+
const ancestors =
|
|
34
|
+
(...shas) =>
|
|
35
|
+
(sha) =>
|
|
36
|
+
shas.includes(sha);
|
|
37
|
+
|
|
38
|
+
test("a cancelled push's changes stay in scope: base is the last green run, not event.before", () => {
|
|
39
|
+
// push 1 (GREEN) passed; push 2 (BEFORE) was cancelled by push 3 (HEAD).
|
|
40
|
+
const r = choosePushBase({
|
|
41
|
+
lastGreenSha: GREEN,
|
|
42
|
+
beforeSha: BEFORE,
|
|
43
|
+
isAncestor: ancestors(GREEN, BEFORE),
|
|
44
|
+
});
|
|
45
|
+
assert(r.base === GREEN, `expected the last green run's head, got ${r.base}`);
|
|
46
|
+
assert(r.source === "last-green-run", r.source);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("no green run on the branch yet → event.before", () => {
|
|
50
|
+
const r = choosePushBase({ lastGreenSha: "", beforeSha: BEFORE, isAncestor: ancestors() });
|
|
51
|
+
assert(r.base === BEFORE, r.base);
|
|
52
|
+
assert(r.source === "event-before", r.source);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("a force-push rewrote the branch (last green head not an ancestor) → event.before", () => {
|
|
56
|
+
const r = choosePushBase({
|
|
57
|
+
lastGreenSha: GREEN,
|
|
58
|
+
beforeSha: BEFORE,
|
|
59
|
+
isAncestor: ancestors(BEFORE),
|
|
60
|
+
});
|
|
61
|
+
assert(r.base === BEFORE, r.base);
|
|
62
|
+
assert(r.source.startsWith("event-before"), r.source);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("nothing at all → empty base (the planner's run-to-be-safe path)", () => {
|
|
66
|
+
const r = choosePushBase({ lastGreenSha: "", beforeSha: undefined, isAncestor: ancestors() });
|
|
67
|
+
assert(r.base === "", JSON.stringify(r));
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test("the newest green run wins by run number, whatever order the API lists them in", () => {
|
|
71
|
+
const runs = [
|
|
72
|
+
{ run_number: 2317, head_sha: "older" },
|
|
73
|
+
{ run_number: 2679, head_sha: "today" },
|
|
74
|
+
{ run_number: 2675, head_sha: "yesterday" },
|
|
75
|
+
];
|
|
76
|
+
assert(newestRunSha(runs) === "today", newestRunSha(runs));
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test("no usable run → empty sha (the caller falls back to event.before)", () => {
|
|
80
|
+
assert(newestRunSha([]) === "", "empty list");
|
|
81
|
+
assert(newestRunSha(undefined) === "", "no list");
|
|
82
|
+
assert(newestRunSha([{ run_number: "x", head_sha: "a" }, { head_sha: 3 }]) === "", "malformed");
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
console.log(`\n${passed} passed, ${failed} failed`);
|
|
86
|
+
process.exit(failed > 0 ? 1 : 0);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": [
|
|
3
|
+
"Example. Copy into the repo and own it.",
|
|
4
|
+
"bkit install does not write this file and does not overwrite a copy.",
|
|
5
|
+
"Capability drift rules — the one hand-maintained input behind docs/capabilities.md.",
|
|
6
|
+
"Each rule is a literal marker for a capability's mechanism, plus the owner module every caller should use.",
|
|
7
|
+
"bkit-graph-drift.py derives status: no owner -> split; owner missing -> gap; owner present and other files match -> bypassed; else one.",
|
|
8
|
+
"Patterns are literal, never regex. A regex metacharacter in the marker matches nothing and reads as a clean result.",
|
|
9
|
+
"Optional scope: array of path prefixes. Optional surface: product (default), tests, or all.",
|
|
10
|
+
"Optional budgets: exact non-owner site count allowed per scope prefix. Measured == declared => budgeted.",
|
|
11
|
+
"Add a rule when a capability gets an owner. Statuses are computed, never typed in.",
|
|
12
|
+
"Replace the example rule. Do not leave it pointing at a file this repo does not have."
|
|
13
|
+
],
|
|
14
|
+
"rules": [
|
|
15
|
+
{
|
|
16
|
+
"capability": "Example client",
|
|
17
|
+
"lane": "Platform",
|
|
18
|
+
"owner": "src/example-owner.ts",
|
|
19
|
+
"pattern": "new ExampleClient(",
|
|
20
|
+
"note": "Replace with a real mechanism marker and the one module every caller should use."
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Example. Copy into the repo and own it.
|
|
2
|
+
# bkit install does not write this file and does not overwrite a copy.
|
|
3
|
+
# Adapt app roots, the workspace package scope, and the rules JSON to this repo.
|
|
4
|
+
|
|
5
|
+
#!/usr/bin/env python3
|
|
6
|
+
"""Compute per-capability drift status by literal-pattern scan, for the generated diagram.
|
|
7
|
+
|
|
8
|
+
Called by `pnpm graph:rollup` (scripts/graphify/bkit-graphify.sh). Reads
|
|
9
|
+
bkit-graph-drift-rules.json, walks the source tree once, and writes an overlay JSON
|
|
10
|
+
that bkit-graphify-rollup.py paints onto the Mermaid nodes.
|
|
11
|
+
|
|
12
|
+
bkit-graph-drift.py <rules.json> <overlay-out.json> [--quiet]
|
|
13
|
+
|
|
14
|
+
Scans source text for a duplicated MECHANISM (a second `new Client()`, a fourth
|
|
15
|
+
hand-rolled send) by literal substring match, not via the code graph. Patterns are
|
|
16
|
+
LITERAL, never regex.
|
|
17
|
+
|
|
18
|
+
TWO SURFACES. A rule's optional "surface" key picks which one it scans:
|
|
19
|
+
"product" (the default), "tests", or "all". See sources().
|
|
20
|
+
|
|
21
|
+
BUDGETED. A rule may declare "budgets": the EXACT number of non-owner sites allowed
|
|
22
|
+
per scope prefix. A row whose measured count matches its declared budget everywhere
|
|
23
|
+
gets the status `budgeted` instead of the amber warning. See budget_state().
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
import argparse
|
|
27
|
+
import json
|
|
28
|
+
import os
|
|
29
|
+
import sys
|
|
30
|
+
|
|
31
|
+
# .js/.mjs/.cjs count too: a script under scripts/ci can carry the same marker,
|
|
32
|
+
# and a .ts-only scan never sees it.
|
|
33
|
+
SRC = (".ts", ".tsx", ".js", ".mjs", ".cjs")
|
|
34
|
+
# dist-plugins/ is compiled output of plugins/*.ts; scanning both counts each site twice.
|
|
35
|
+
SKIP_DIR = {"node_modules", "dist", "dist-plugins", ".next", ".turbo", "coverage", "build", ".git"}
|
|
36
|
+
# *.config.ts is build configuration, not application code.
|
|
37
|
+
SKIP_FILE = (".d.ts", ".config.")
|
|
38
|
+
# What puts a file on the TEST surface rather than the product one. Everything
|
|
39
|
+
# else about the walk is identical, so the two surfaces are a PARTITION of the
|
|
40
|
+
# same file set — see sources().
|
|
41
|
+
TEST_FILE = (".test.", ".spec.")
|
|
42
|
+
# Roots walked; a budget guard reads the same roots. scripts/ is included.
|
|
43
|
+
ROOTS = ("apps", "packages", "tooling", "scripts")
|
|
44
|
+
SURFACES = ("product", "tests", "all")
|
|
45
|
+
|
|
46
|
+
ap = argparse.ArgumentParser()
|
|
47
|
+
ap.add_argument("rules_json")
|
|
48
|
+
ap.add_argument("overlay_out")
|
|
49
|
+
ap.add_argument("--quiet", action="store_true")
|
|
50
|
+
args = ap.parse_args()
|
|
51
|
+
|
|
52
|
+
rules = json.load(open(args.rules_json))["rules"]
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def is_test_path(path):
|
|
56
|
+
"""Test surface membership, for one path. Same two clauses as sources()."""
|
|
57
|
+
parts = path.split("/")
|
|
58
|
+
return "e2e" in parts or any(x in parts[-1] for x in TEST_FILE)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def sources():
|
|
62
|
+
"""Yield (path, surface) for every scannable file, on ONE walk.
|
|
63
|
+
|
|
64
|
+
Two surfaces, and they PARTITION the file set — no file is on both, none is
|
|
65
|
+
on neither:
|
|
66
|
+
|
|
67
|
+
product application code.
|
|
68
|
+
tests anything under an `e2e` directory, plus any `.test.` / `.spec.`
|
|
69
|
+
file anywhere — exactly what the product surface skips.
|
|
70
|
+
|
|
71
|
+
A test HELPER that is neither under `e2e` nor named `.test.`/`.spec.` —
|
|
72
|
+
`packages/utils/src/testing/**`, `packages/api/tests/setup.ts` — is scanned
|
|
73
|
+
as product code.
|
|
74
|
+
"""
|
|
75
|
+
for root in ROOTS:
|
|
76
|
+
for dirpath, dirnames, filenames in os.walk(root):
|
|
77
|
+
dirnames[:] = [d for d in dirnames if d not in SKIP_DIR]
|
|
78
|
+
in_e2e = "/e2e/" in dirpath + "/" or dirpath.endswith("/e2e")
|
|
79
|
+
for f in filenames:
|
|
80
|
+
if not f.endswith(SRC) or any(x in f for x in SKIP_FILE):
|
|
81
|
+
continue
|
|
82
|
+
is_test = in_e2e or any(x in f for x in TEST_FILE)
|
|
83
|
+
yield os.path.join(dirpath, f), ("tests" if is_test else "product")
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# One read of the tree, all rules matched against it. A rule's optional "scope"
|
|
87
|
+
# (path prefixes) narrows the files it matches.
|
|
88
|
+
hits = {r["pattern"]: [] for r in rules}
|
|
89
|
+
scoped = {r["pattern"]: tuple(r["scope"]) for r in rules if r.get("scope")}
|
|
90
|
+
# Which surface each rule is asking about. Absent = "product".
|
|
91
|
+
wants = {r["pattern"]: r.get("surface", "product") for r in rules}
|
|
92
|
+
for pat, want in wants.items():
|
|
93
|
+
if want not in SURFACES:
|
|
94
|
+
raise SystemExit(f'[drift] pattern {pat!r}: "surface" is {want!r}, '
|
|
95
|
+
f"expected one of {', '.join(SURFACES)}")
|
|
96
|
+
seen = {"product": 0, "tests": 0}
|
|
97
|
+
for path, surface in sources():
|
|
98
|
+
seen[surface] += 1
|
|
99
|
+
try:
|
|
100
|
+
text = open(path, encoding="utf-8", errors="ignore").read()
|
|
101
|
+
except OSError:
|
|
102
|
+
continue
|
|
103
|
+
for pat in hits:
|
|
104
|
+
if wants[pat] not in (surface, "all"):
|
|
105
|
+
continue
|
|
106
|
+
if pat in text and (pat not in scoped or path.startswith(scoped[pat])):
|
|
107
|
+
hits[pat].append(path)
|
|
108
|
+
|
|
109
|
+
# A surface that matched 0 files fails the run: every rule on it would pass vacuously.
|
|
110
|
+
for surface, n in seen.items():
|
|
111
|
+
if n == 0:
|
|
112
|
+
raise SystemExit(f"[drift] the {surface} surface matched 0 files. Every rule scoped to "
|
|
113
|
+
f"it would pass vacuously — fix the walk before trusting any count.")
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def budget_state(rule, outside):
|
|
117
|
+
"""Measured sites vs the rule's DECLARED per-prefix budgets.
|
|
118
|
+
|
|
119
|
+
Returns (declared_total, verdict). verdict is None when the rule declares no
|
|
120
|
+
budget at all — the register's default, and the one that stays amber.
|
|
121
|
+
|
|
122
|
+
"at" every prefix holds exactly the number it declared. Settled.
|
|
123
|
+
"over" a prefix holds more than it declared, or a site landed outside
|
|
124
|
+
every declared prefix. A new copy appeared.
|
|
125
|
+
"stale" a prefix holds fewer than it declared. The budget is a ceiling
|
|
126
|
+
nobody lowered.
|
|
127
|
+
|
|
128
|
+
A budget is an exact number with its reason in the rule's `note`; a CI test
|
|
129
|
+
counting the same prefixes fails when the count moves in either direction. A
|
|
130
|
+
site outside every declared prefix reads as "over" here, which that test,
|
|
131
|
+
counting only inside its prefixes, does not see.
|
|
132
|
+
"""
|
|
133
|
+
budgets = rule.get("budgets")
|
|
134
|
+
if not budgets:
|
|
135
|
+
return None, None
|
|
136
|
+
declared = sum(budgets.values())
|
|
137
|
+
counted = dict.fromkeys(budgets, 0)
|
|
138
|
+
unbudgeted = 0
|
|
139
|
+
for path in outside:
|
|
140
|
+
owning = max((b for b in budgets if path.startswith(b)), key=len, default=None)
|
|
141
|
+
if owning is None:
|
|
142
|
+
unbudgeted += 1
|
|
143
|
+
else:
|
|
144
|
+
counted[owning] += 1
|
|
145
|
+
if unbudgeted or any(counted[b] > budgets[b] for b in budgets):
|
|
146
|
+
return declared, "over"
|
|
147
|
+
if any(counted[b] < budgets[b] for b in budgets):
|
|
148
|
+
return declared, "stale"
|
|
149
|
+
return declared, "at"
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
overlay, summary, rows = {}, [], []
|
|
153
|
+
for r in rules:
|
|
154
|
+
owner, users = r.get("owner"), sorted(hits[r["pattern"]])
|
|
155
|
+
outside = [u for u in users if u != owner]
|
|
156
|
+
if owner is None:
|
|
157
|
+
status = "split"
|
|
158
|
+
detail = f"NO OWNER · {len(users)} sites"
|
|
159
|
+
elif not os.path.exists(owner):
|
|
160
|
+
status = "gap"
|
|
161
|
+
detail = "owner declared, file does not exist"
|
|
162
|
+
elif outside:
|
|
163
|
+
status = "bypassed"
|
|
164
|
+
detail = f"{len(outside)} of {len(users)} sites skip the owner"
|
|
165
|
+
else:
|
|
166
|
+
status = "one"
|
|
167
|
+
detail = f"{len(users)} site{'' if len(users) == 1 else 's'}, all via the owner"
|
|
168
|
+
# At budget, `split` / `bypassed` become `budgeted`. `one` and `gap` never do.
|
|
169
|
+
declared, verdict = budget_state(r, outside)
|
|
170
|
+
if verdict == "at" and status in ("split", "bypassed"):
|
|
171
|
+
status = "budgeted"
|
|
172
|
+
detail += f" · at budget {declared}"
|
|
173
|
+
elif verdict == "over":
|
|
174
|
+
detail += f" · OVER BUDGET, {len(outside)} > {declared}"
|
|
175
|
+
elif verdict == "stale":
|
|
176
|
+
detail += f" · BUDGET STALE, {len(outside)} < {declared}"
|
|
177
|
+
if r.get("issue"):
|
|
178
|
+
detail += f" · #{r['issue']}"
|
|
179
|
+
# Keyed on the owner path when there is one, on the busiest bypass otherwise. A
|
|
180
|
+
# row keyed on a TEST path is registered but never painted (bkit-graphify-rollup.py's
|
|
181
|
+
# is_test_code skips it too). The test is on the key PATH, not the rule's surface:
|
|
182
|
+
# an "all" rule paints when its busiest hit is product code.
|
|
183
|
+
key = owner or (outside[0] if outside else None)
|
|
184
|
+
if key and status != "one" and not is_test_path(key):
|
|
185
|
+
overlay[key] = [status, f"{r['capability']} · {detail}"]
|
|
186
|
+
summary.append((status, r["capability"], detail, outside))
|
|
187
|
+
rows.append({"lane": r.get("lane", ""), "capability": r["capability"],
|
|
188
|
+
"owner": owner, "pattern": r["pattern"], "status": status,
|
|
189
|
+
"sites": len(users), "bypasses": len(outside),
|
|
190
|
+
"surface": r.get("surface", "product"),
|
|
191
|
+
"budget": declared, "budget_state": verdict,
|
|
192
|
+
"issue": r.get("issue"), "detail": detail})
|
|
193
|
+
|
|
194
|
+
json.dump({"generated_from": args.rules_json, "overlay": overlay, "rows": rows},
|
|
195
|
+
open(args.overlay_out, "w"), indent=1)
|
|
196
|
+
|
|
197
|
+
if not args.quiet:
|
|
198
|
+
order = {"split": 0, "gap": 1, "bypassed": 2, "budgeted": 3, "one": 4}
|
|
199
|
+
for status, cap, detail, outside in sorted(summary, key=lambda s: order[s[0]]):
|
|
200
|
+
print(f"[drift] {status:9} {cap:34} {detail}")
|
|
201
|
+
for u in outside[:4]:
|
|
202
|
+
print(f"[drift] ↳ {u}")
|
|
203
|
+
counts = {}
|
|
204
|
+
for s, *_ in summary:
|
|
205
|
+
counts[s] = counts.get(s, 0) + 1
|
|
206
|
+
print(f"[drift] {len(rules)} rules → " + " · ".join(f"{v} {k}" for k, v in sorted(counts.items()))
|
|
207
|
+
+ f" (scanned {seen['product']} product + {seen['tests']} test files)")
|
|
208
|
+
print(f"[drift] wrote {args.overlay_out}", file=sys.stderr)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": [
|
|
3
|
+
"Example. Copy into the repo and own it.",
|
|
4
|
+
"bkit install does not write this file and does not overwrite a copy.",
|
|
5
|
+
"Pure-builder allowlist for bkit-graph-eager.py. The list only says what is safe.",
|
|
6
|
+
"A call at module scope is reported unless something here declares it pure.",
|
|
7
|
+
"Pure means evaluating it allocates a value and touches nothing else.",
|
|
8
|
+
"pure: exact callee. pure_prefixes: callee starts with this. pure_methods: callee ends with this. pure_receivers: text before the last dot.",
|
|
9
|
+
"min_downstream: rows below this many downstream files stay in the JSON report and out of docs/capabilities.md."
|
|
10
|
+
],
|
|
11
|
+
"min_downstream": 1,
|
|
12
|
+
"pure": [
|
|
13
|
+
"Array.from",
|
|
14
|
+
"Hono",
|
|
15
|
+
"Map",
|
|
16
|
+
"RegExp",
|
|
17
|
+
"Set",
|
|
18
|
+
"WeakMap",
|
|
19
|
+
"WeakSet",
|
|
20
|
+
"forwardRef",
|
|
21
|
+
"memo"
|
|
22
|
+
],
|
|
23
|
+
"pure_receivers": ["app"],
|
|
24
|
+
"pure_prefixes": ["Intl.", "JSON.", "Object.", "StyleSheet.", "path.", "z."],
|
|
25
|
+
"pure_methods": [
|
|
26
|
+
".and",
|
|
27
|
+
".array",
|
|
28
|
+
".extend",
|
|
29
|
+
".omit",
|
|
30
|
+
".optional",
|
|
31
|
+
".partial",
|
|
32
|
+
".pick",
|
|
33
|
+
".strict"
|
|
34
|
+
]
|
|
35
|
+
}
|