@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,7 @@
|
|
|
1
|
-
// bkit ledgers commit|union|only-bookkeeping|append|check — stage and
|
|
2
|
-
// by an allow-list, never `git add -A`; append validated rows with
|
|
3
|
-
// check that the ledger rows a plan names are on disk
|
|
1
|
+
// bkit ledgers commit|union|only-bookkeeping|append|check|triage|compact — stage and
|
|
2
|
+
// commit bookkeeping by an allow-list, never `git add -A`; append validated rows with
|
|
3
|
+
// a minted `ts`; check that the ledger rows a plan names are on disk; drop superseded
|
|
4
|
+
// rows from the keyed ledgers.
|
|
4
5
|
//
|
|
5
6
|
// The pathspec is built by `git ls-files` against quoted globs, so git does the
|
|
6
7
|
// matching and an unmatched glob is empty output, never a shell abort. Staging
|
|
@@ -12,9 +13,12 @@ import * as fs from "node:fs";
|
|
|
12
13
|
import * as os from "node:os";
|
|
13
14
|
import * as path from "node:path";
|
|
14
15
|
import { readBkitVersion } from "../../install/version-file.js";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
16
|
+
import { readBkitConfig } from "../../shared/settings.js";
|
|
17
|
+
import { APPEND_LEDGERS, SCHEMA, UNJUSTIFIED_REASON, gitEnv, parse, mintTs, resolveRepoSlug, validate, withLineage, writerProblem, } from "../../ledgers/telemetry.js";
|
|
18
|
+
import { COMPACT_LEDGERS, compactLedgers } from "../../ledgers/compact.js";
|
|
19
|
+
import { CommandError, EXIT, isIgnoredPath, isSharedBranch, parseJson, } from "../lib.js";
|
|
17
20
|
import { str } from "./status.js";
|
|
21
|
+
import { NO_MARKERS_REASON, outOfScope, parsePlanBlocks, reuseInventory, } from "./plan-blocks.js";
|
|
18
22
|
/** Root is not a directory or repo, git is too old, or a ref does not resolve. */
|
|
19
23
|
export const EXIT_ROOT = 3;
|
|
20
24
|
/** `git add` / `git add -u` / mkdir / copy failed. */
|
|
@@ -29,11 +33,16 @@ export const EXIT_NOT_BOOKKEEPING = 7;
|
|
|
29
33
|
export const EXIT_ROW_REFUSED = 8;
|
|
30
34
|
const SCOPES = ["core", "full", "pr"];
|
|
31
35
|
const MODES = ["stage", "commit", "commit-allow-empty"];
|
|
36
|
+
/** `package.json` globs as git pathspecs: `:(glob)` unless an entry carries its own magic. */
|
|
37
|
+
export const globPathspecs = (paths) => paths.map((p) => (p.startsWith(":") ? p : `:(glob)${p}`));
|
|
32
38
|
/**
|
|
33
39
|
* The bookkeeping allow-list. Plain git pathspec `*` crosses `/`, so the
|
|
34
|
-
* top-level-only
|
|
40
|
+
* top-level-only entries use the `:(glob)` magic. `extra` is
|
|
41
|
+
* `bkit.testing.ciSkipPaths` (`ciSkipPaths`), the project docs a repo
|
|
42
|
+
* keeps outside `docs/*.md` (bkit's own: `CHANGELOG.md`, `README.md`); it reaches
|
|
43
|
+
* the `pr` scope only.
|
|
35
44
|
*/
|
|
36
|
-
export function bookPathspecs(month, fid, scope) {
|
|
45
|
+
export function bookPathspecs(month, fid, scope, extra = []) {
|
|
37
46
|
const specs = [
|
|
38
47
|
`docs/plans/${month}/logs/${fid}/*`,
|
|
39
48
|
".bkit/friction.jsonl",
|
|
@@ -47,11 +56,14 @@ export function bookPathspecs(month, fid, scope) {
|
|
|
47
56
|
if (scope === "full" || scope === "pr") {
|
|
48
57
|
specs.push("docs/deferrals.jsonl", "docs/failures.jsonl", "docs/knowledge.jsonl", "docs/decisions.jsonl", "skills-lock.json", ".agents/skills/*", ".claude/skills/*", ".cursor/skills/*", ".opencode/skills/*");
|
|
49
58
|
}
|
|
50
|
-
// `pr` adds the project docs ship's docs sync edits, for the commit that rides
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
// `pr` adds the project docs ship's docs sync edits, for the commit that rides the
|
|
60
|
+
// PR: top-level `docs/*.md`, plus whatever the repo names in `ciSkipPaths` (the
|
|
61
|
+
// engine hardcodes no file name; a glob nothing matches selects nothing). Kept out
|
|
62
|
+
// of `full` so a close on a laptop's dev checkout never sweeps unrelated dirty docs
|
|
63
|
+
// into its commit.
|
|
64
|
+
if (scope === "pr") {
|
|
65
|
+
specs.push(":(glob)docs/*.md", ...globPathspecs(extra));
|
|
66
|
+
}
|
|
55
67
|
return specs;
|
|
56
68
|
}
|
|
57
69
|
/** Ledgers a worktree teardown carries into the destination checkout. */
|
|
@@ -422,6 +434,13 @@ export function commitOwnSet(cwd, set, message, o = {}) {
|
|
|
422
434
|
try {
|
|
423
435
|
const list = path.join(tmp, "list");
|
|
424
436
|
const all = [...set.plain, ...set.ledgers.map((l) => l.path)];
|
|
437
|
+
// `dirtyPaths` drops ignored entries, so `all` never holds one today; name the
|
|
438
|
+
// failure if a future caller passes a gitignored path, rather than let git's
|
|
439
|
+
// ignored-paths guard surface as an opaque stage error.
|
|
440
|
+
const ignored = all.filter((p) => isIgnoredPath(top, p));
|
|
441
|
+
if (ignored.length > 0) {
|
|
442
|
+
return { ok: false, error: `refusing to stage gitignored path(s): ${ignored.join(", ")}` };
|
|
443
|
+
}
|
|
425
444
|
fs.writeFileSync(list, all.map((p) => `${p}\0`).join(""));
|
|
426
445
|
const stagedBefore = new Set(nulList(gitRaw(top, ["diff", "--cached", "--name-only", "-z"]).stdout));
|
|
427
446
|
const tail = ["-m", message];
|
|
@@ -517,10 +536,11 @@ export function retriggerCommit(cwd, rec, message) {
|
|
|
517
536
|
// ---------------------------------------------------------------------------
|
|
518
537
|
export const ledgersCommand = {
|
|
519
538
|
noun: "ledgers",
|
|
520
|
-
summary: "Stage and commit bookkeeping by allow-list; union ledgers; check a range is bookkeeping only.",
|
|
539
|
+
summary: "Stage and commit bookkeeping by allow-list; union ledgers; check a range is bookkeeping only; compact keyed ledgers.",
|
|
521
540
|
verbs: {
|
|
522
541
|
commit: {
|
|
523
542
|
summary: "Stage (and commit) the bookkeeping allow-list for one feature.",
|
|
543
|
+
use: "workflow",
|
|
524
544
|
flags: [
|
|
525
545
|
ROOT_FLAG,
|
|
526
546
|
MONTH_FLAG,
|
|
@@ -577,6 +597,7 @@ export const ledgersCommand = {
|
|
|
577
597
|
},
|
|
578
598
|
union: {
|
|
579
599
|
summary: "Append a worktree's new ledger rows into another checkout (never .bkit/issues.jsonl).",
|
|
600
|
+
use: "workflow",
|
|
580
601
|
flags: [
|
|
581
602
|
{ name: "src", type: "string", required: true, help: "worktree to read ledgers from" },
|
|
582
603
|
{ name: "dst", type: "string", required: true, help: "checkout to append them to" },
|
|
@@ -590,6 +611,7 @@ export const ledgersCommand = {
|
|
|
590
611
|
},
|
|
591
612
|
"only-bookkeeping": {
|
|
592
613
|
summary: "Exit 0 when every path changed in from..to is on the --scope=pr allow-list.",
|
|
614
|
+
use: "by-hand",
|
|
593
615
|
flags: [
|
|
594
616
|
ROOT_FLAG,
|
|
595
617
|
MONTH_FLAG,
|
|
@@ -610,6 +632,7 @@ export const ledgersCommand = {
|
|
|
610
632
|
},
|
|
611
633
|
append: {
|
|
612
634
|
summary: "Append validated rows to one ledger, minting each row's ts at append time.",
|
|
635
|
+
use: "by-hand",
|
|
613
636
|
flags: [
|
|
614
637
|
{ name: "root", type: "string", help: "checkout whose ledger to append to (default: cwd)" },
|
|
615
638
|
{
|
|
@@ -637,8 +660,34 @@ export const ledgersCommand = {
|
|
|
637
660
|
},
|
|
638
661
|
run: (ctx) => append(ctx),
|
|
639
662
|
},
|
|
663
|
+
triage: {
|
|
664
|
+
summary: "Bucket each deferral row the FID declared by the four Deferral Reason tests, and write the unjustified ones.",
|
|
665
|
+
use: "workflow",
|
|
666
|
+
flags: [
|
|
667
|
+
{ name: "root", type: "string", help: "checkout whose deferrals to read (default: cwd)" },
|
|
668
|
+
FID_FLAG,
|
|
669
|
+
{
|
|
670
|
+
name: "plan",
|
|
671
|
+
type: "string",
|
|
672
|
+
required: true,
|
|
673
|
+
help: "plan file whose task surfaces and Out of Scope rows the four tests read",
|
|
674
|
+
},
|
|
675
|
+
],
|
|
676
|
+
output: {
|
|
677
|
+
fid: "the feature id triaged",
|
|
678
|
+
plan: "the plan the tests were read from",
|
|
679
|
+
rows: "each matched deferral's key, bucket (Exempt | Lazy), test results (none for a settled row: closed, LOW, or already adjudicated) and whether a row was written",
|
|
680
|
+
total: "deferral rows the FID matched",
|
|
681
|
+
written: "unjustified rows appended",
|
|
682
|
+
},
|
|
683
|
+
exitCodes: {
|
|
684
|
+
[EXIT_ROW_REFUSED]: "a computed unjustified row fails validation or its writer check — nothing written",
|
|
685
|
+
},
|
|
686
|
+
run: (ctx) => triage(ctx),
|
|
687
|
+
},
|
|
640
688
|
check: {
|
|
641
689
|
summary: "Check that every decision / deferral key on a plan's `**Ledger rows:**` line is on disk.",
|
|
690
|
+
use: "by-hand",
|
|
642
691
|
flags: [
|
|
643
692
|
{ name: "root", type: "string", help: "checkout whose ledgers to read (default: cwd)" },
|
|
644
693
|
{ name: "plan", type: "string", required: true, help: "plan file, relative to --root" },
|
|
@@ -653,6 +702,26 @@ export const ledgersCommand = {
|
|
|
653
702
|
},
|
|
654
703
|
run: (ctx) => check(ctx),
|
|
655
704
|
},
|
|
705
|
+
compact: {
|
|
706
|
+
summary: "Rewrite keyed ledgers to their fold winners, stamping each winner's firstTs + updates.",
|
|
707
|
+
use: "by-hand",
|
|
708
|
+
flags: [
|
|
709
|
+
{ name: "root", type: "string", help: "checkout whose ledgers to compact (default: cwd)" },
|
|
710
|
+
{
|
|
711
|
+
name: "ledger",
|
|
712
|
+
type: "string",
|
|
713
|
+
help: `${Object.keys(COMPACT_LEDGERS).join(" | ")} | all (default: all)`,
|
|
714
|
+
},
|
|
715
|
+
{ name: "dry-run", type: "boolean", help: "count only; write nothing" },
|
|
716
|
+
],
|
|
717
|
+
output: {
|
|
718
|
+
dryRun: "true when nothing was written by design",
|
|
719
|
+
ledgers: "per ledger: ledger, file, rows (keyed rows folded), dropped (superseded rows removed), stamped (winners given firstTs / updates), written",
|
|
720
|
+
dropped: "superseded rows removed across all ledgers",
|
|
721
|
+
},
|
|
722
|
+
exitCodes: { [EXIT_STAGE]: "writing a compacted ledger failed" },
|
|
723
|
+
run: (ctx) => compact(ctx),
|
|
724
|
+
},
|
|
656
725
|
},
|
|
657
726
|
};
|
|
658
727
|
/** Commit one named path alone: `git add` it, then `git commit -- <path>`. */
|
|
@@ -671,6 +740,9 @@ function commitOnePath(o, log) {
|
|
|
671
740
|
squashPaths: [],
|
|
672
741
|
tracked: [],
|
|
673
742
|
});
|
|
743
|
+
if (isIgnoredPath(root, inside)) {
|
|
744
|
+
throw new CommandError(EXIT_STAGE, `--path is gitignored, refusing to stage it: ${inside}`);
|
|
745
|
+
}
|
|
674
746
|
const add = gitRaw(root, ["add", "--", inside]);
|
|
675
747
|
if (add.status !== 0)
|
|
676
748
|
throw new CommandError(EXIT_STAGE, `'git add' failed: ${add.stderr}`);
|
|
@@ -771,7 +843,7 @@ export function commitBookkeeping(o, log) {
|
|
|
771
843
|
tracked = nulList(cached.stdout);
|
|
772
844
|
}
|
|
773
845
|
}
|
|
774
|
-
const specs = bookPathspecs(month, fid, scope);
|
|
846
|
+
const specs = bookPathspecs(month, fid, scope, readBkitConfig(root).ciSkipPaths);
|
|
775
847
|
const listed = gitRaw(root, [
|
|
776
848
|
"ls-files",
|
|
777
849
|
"-z",
|
|
@@ -943,13 +1015,26 @@ function union(ctx) {
|
|
|
943
1015
|
return EXIT.OK;
|
|
944
1016
|
}
|
|
945
1017
|
/** The top section in its written order, then the row's own fields. */
|
|
946
|
-
const TOP_ORDER = [
|
|
1018
|
+
const TOP_ORDER = [
|
|
1019
|
+
"schema",
|
|
1020
|
+
"ts",
|
|
1021
|
+
"firstTs",
|
|
1022
|
+
"updates",
|
|
1023
|
+
"kind",
|
|
1024
|
+
"key",
|
|
1025
|
+
"repo",
|
|
1026
|
+
"bkit",
|
|
1027
|
+
"by",
|
|
1028
|
+
"references",
|
|
1029
|
+
];
|
|
947
1030
|
/**
|
|
948
1031
|
* Append `rows` to one ledger. Every row is checked before any is written, so a
|
|
949
1032
|
* refused row leaves the file byte-identical. Each row gets `schema` and a `ts`
|
|
950
1033
|
* minted now (never supplied), `repo` when it lacks one and `bkit.version` from
|
|
951
|
-
* `.bkit/version
|
|
952
|
-
*
|
|
1034
|
+
* `.bkit/version`; an `AGED_KINDS` row also gets `firstTs` + `updates` carried
|
|
1035
|
+
* forward from its entry's rows already in the ledger (supplied values replaced).
|
|
1036
|
+
* Never rewrites existing rows. Throws a CommandError (USAGE / EXIT_ROW_REFUSED /
|
|
1037
|
+
* EXIT_STAGE).
|
|
953
1038
|
*/
|
|
954
1039
|
export function appendLedgerRows(root, ledger, rows) {
|
|
955
1040
|
if (!Object.hasOwn(APPEND_LEDGERS, ledger)) {
|
|
@@ -964,6 +1049,8 @@ export function appendLedgerRows(root, ledger, rows) {
|
|
|
964
1049
|
let repo;
|
|
965
1050
|
let version;
|
|
966
1051
|
let last;
|
|
1052
|
+
const abs = path.join(root, file);
|
|
1053
|
+
const prior = fs.existsSync(abs) ? parse(fs.readFileSync(abs, "utf-8")).events : [];
|
|
967
1054
|
const out = rows.map((raw, i) => {
|
|
968
1055
|
const refuse = (why) => new CommandError(EXIT_ROW_REFUSED, `row ${i + 1}: ${why}`);
|
|
969
1056
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
@@ -982,13 +1069,13 @@ export function appendLedgerRows(root, ledger, rows) {
|
|
|
982
1069
|
repo ??= resolveRepoSlug(root) || "unknown/repo";
|
|
983
1070
|
version ??= readBkitVersion(path.join(root, ".bkit", "version"))?.pinnedVersion || "unknown";
|
|
984
1071
|
last = mintTs(last);
|
|
985
|
-
const filled = {
|
|
1072
|
+
const filled = withLineage(prior, {
|
|
986
1073
|
repo,
|
|
987
1074
|
...r,
|
|
988
1075
|
schema: SCHEMA,
|
|
989
1076
|
ts: last,
|
|
990
1077
|
bkit: { version },
|
|
991
|
-
};
|
|
1078
|
+
});
|
|
992
1079
|
const row = {};
|
|
993
1080
|
for (const k of TOP_ORDER)
|
|
994
1081
|
if (filled[k] !== undefined)
|
|
@@ -1002,9 +1089,9 @@ export function appendLedgerRows(root, ledger, rows) {
|
|
|
1002
1089
|
const who = writerProblem(row);
|
|
1003
1090
|
if (who !== undefined)
|
|
1004
1091
|
throw refuse(who);
|
|
1092
|
+
prior.push(row);
|
|
1005
1093
|
return row;
|
|
1006
1094
|
});
|
|
1007
|
-
const abs = path.join(root, file);
|
|
1008
1095
|
const made = mkdirp(path.dirname(abs));
|
|
1009
1096
|
if (made)
|
|
1010
1097
|
throw new CommandError(EXIT_STAGE, `mkdir failed for ${path.dirname(file)}: ${made}`);
|
|
@@ -1105,6 +1192,24 @@ function check(ctx) {
|
|
|
1105
1192
|
ctx.log(`${plan}: ${r.keys.length} ledger row(s) on disk`);
|
|
1106
1193
|
return EXIT.OK;
|
|
1107
1194
|
}
|
|
1195
|
+
function compact(ctx) {
|
|
1196
|
+
const root = rootOf(ctx);
|
|
1197
|
+
const named = str(ctx.flags.ledger) ?? "all";
|
|
1198
|
+
if (named !== "all" && !Object.hasOwn(COMPACT_LEDGERS, named)) {
|
|
1199
|
+
throw new CommandError(EXIT.USAGE, `--ledger must be one of ${Object.keys(COMPACT_LEDGERS).join(", ")}, all (got '${named}')`);
|
|
1200
|
+
}
|
|
1201
|
+
const ledgers = (named === "all" ? Object.keys(COMPACT_LEDGERS) : [named]);
|
|
1202
|
+
const dryRun = ctx.flags.dryRun === true;
|
|
1203
|
+
const results = compactOrError(root, ledgers, dryRun);
|
|
1204
|
+
if (typeof results === "string")
|
|
1205
|
+
throw new CommandError(EXIT_STAGE, `compact failed: ${results}`);
|
|
1206
|
+
const dropped = results.reduce((n, r) => n + r.dropped, 0);
|
|
1207
|
+
for (const r of results) {
|
|
1208
|
+
ctx.log(`${r.file}: ${r.dropped} superseded row(s) dropped, ${r.stamped} winner(s) stamped`);
|
|
1209
|
+
}
|
|
1210
|
+
ctx.emit({ dryRun, ledgers: results, dropped });
|
|
1211
|
+
return EXIT.OK;
|
|
1212
|
+
}
|
|
1108
1213
|
/** mkdir -p; the error text, or undefined on success. */
|
|
1109
1214
|
function mkdirp(dir) {
|
|
1110
1215
|
try {
|
|
@@ -1116,6 +1221,16 @@ function mkdirp(dir) {
|
|
|
1116
1221
|
return err.message;
|
|
1117
1222
|
}
|
|
1118
1223
|
}
|
|
1224
|
+
/** {@link compactLedgers}; its results, or the error text. A failed temp write or rename leaves the ledger untouched. */
|
|
1225
|
+
function compactOrError(root, ledgers, dryRun) {
|
|
1226
|
+
try {
|
|
1227
|
+
return compactLedgers(root, ledgers, dryRun);
|
|
1228
|
+
}
|
|
1229
|
+
catch (err) {
|
|
1230
|
+
// Reported as the command's staging exit code, with the reason.
|
|
1231
|
+
return err.message;
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1119
1234
|
/** Append `text` to `file`; the error text, or undefined on success. */
|
|
1120
1235
|
function appendText(file, text) {
|
|
1121
1236
|
try {
|
|
@@ -1160,7 +1275,7 @@ export function checkOnlyBookkeeping(root, o) {
|
|
|
1160
1275
|
if (gitRaw(root, ["merge-base", "--is-ancestor", o.from, o.to]).status !== 0) {
|
|
1161
1276
|
return { kind: "not-ancestor" };
|
|
1162
1277
|
}
|
|
1163
|
-
const diff = changedOutside(root, o.from, o.to, bookPathspecs(o.month, o.fid, "pr"));
|
|
1278
|
+
const diff = changedOutside(root, o.from, o.to, bookPathspecs(o.month, o.fid, "pr", readBkitConfig(root).ciSkipPaths));
|
|
1164
1279
|
if (!diff.ok)
|
|
1165
1280
|
return { kind: "diff-failed", stderr: diff.stderr };
|
|
1166
1281
|
return diff.outside.length ? { kind: "outside", outside: diff.outside } : { kind: "ok" };
|
|
@@ -1222,3 +1337,239 @@ function onlyBookkeeping(ctx) {
|
|
|
1222
1337
|
return EXIT.OK;
|
|
1223
1338
|
}
|
|
1224
1339
|
}
|
|
1340
|
+
// ---------------------------------------------------------------------------
|
|
1341
|
+
// triage — the sweep's deferral tests, computed
|
|
1342
|
+
// ---------------------------------------------------------------------------
|
|
1343
|
+
//
|
|
1344
|
+
// `.bkit/jsonl.md` § Deferral Reason states the four tests: each names a way a
|
|
1345
|
+
// deferral reads as in-scope work that should have been finished, and all four
|
|
1346
|
+
// holding marks the row `unjustified`. The engine decides them from the row, its
|
|
1347
|
+
// own `references`, the plan's task surfaces, its Reuse Inventory and its
|
|
1348
|
+
// Out of Scope table. The sweep keeps the judgement the four cannot reach.
|
|
1349
|
+
/** The four tests, in `.bkit/jsonl.md` order; each holds when the row reads as in-scope work. */
|
|
1350
|
+
export const DEFERRAL_TESTS = [
|
|
1351
|
+
"bounded-remediation",
|
|
1352
|
+
"in-scope-surface",
|
|
1353
|
+
"no-external-blocker",
|
|
1354
|
+
"own-declaration",
|
|
1355
|
+
];
|
|
1356
|
+
/** The issue number a FID leads with (`701-engine-work` → `701`), else "". */
|
|
1357
|
+
const fidIssue = (fid) => /^(\d+)(?=$|[-_])/.exec(fid)?.[1] ?? "";
|
|
1358
|
+
/** A row's `references` entries, as written. */
|
|
1359
|
+
const rowRefs = (row) => Array.isArray(row["references"])
|
|
1360
|
+
? row["references"].filter((x) => typeof x === "string")
|
|
1361
|
+
: [];
|
|
1362
|
+
/** True when `ref` names the feature: the FID, or its leading issue number as `N` / `#N`. */
|
|
1363
|
+
const namesFeature = (ref, fid, issue) => ref.includes(fid) || (issue !== "" && new RegExp(`^#?${issue}(?![0-9])`).test(ref));
|
|
1364
|
+
/** Every well-formed row of a JSONL ledger, as written. */
|
|
1365
|
+
function readLedgerRows(file) {
|
|
1366
|
+
if (!fs.existsSync(file))
|
|
1367
|
+
return [];
|
|
1368
|
+
return fs
|
|
1369
|
+
.readFileSync(file, "utf-8")
|
|
1370
|
+
.split("\n")
|
|
1371
|
+
.flatMap((line) => {
|
|
1372
|
+
if (line.trim() === "")
|
|
1373
|
+
return [];
|
|
1374
|
+
const parsed = parseJson(line);
|
|
1375
|
+
const v = parsed.ok ? parsed.value : null;
|
|
1376
|
+
return typeof v === "object" && v !== null && !Array.isArray(v)
|
|
1377
|
+
? [v]
|
|
1378
|
+
: [];
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
/** The deferral rows `fid` declared, same-`key` folded last-wins, in first-seen order. */
|
|
1382
|
+
export function featureDeferrals(rows, fid) {
|
|
1383
|
+
const issue = fidIssue(fid);
|
|
1384
|
+
const kept = [];
|
|
1385
|
+
const at = new Map();
|
|
1386
|
+
for (const row of rows) {
|
|
1387
|
+
if (row["kind"] !== "deferral")
|
|
1388
|
+
continue;
|
|
1389
|
+
const key = typeof row["key"] === "string" ? row["key"] : "";
|
|
1390
|
+
const named = key !== "" && namesFeature(key, fid, issue);
|
|
1391
|
+
if (!named && !rowRefs(row).some((r) => namesFeature(r, fid, issue)))
|
|
1392
|
+
continue;
|
|
1393
|
+
const seen = key === "" ? undefined : at.get(key);
|
|
1394
|
+
if (seen !== undefined) {
|
|
1395
|
+
kept[seen] = row;
|
|
1396
|
+
continue;
|
|
1397
|
+
}
|
|
1398
|
+
if (key !== "")
|
|
1399
|
+
at.set(key, kept.length);
|
|
1400
|
+
kept.push(row);
|
|
1401
|
+
}
|
|
1402
|
+
return kept;
|
|
1403
|
+
}
|
|
1404
|
+
/** A repo path a token names, with any `:line` suffix cut; null when the token is no path. */
|
|
1405
|
+
function pathToken(token) {
|
|
1406
|
+
const t = token
|
|
1407
|
+
.trim()
|
|
1408
|
+
.replace(/:\d+(?:-\d+)?$/, "")
|
|
1409
|
+
.replace(/[.,;:]+$/, "")
|
|
1410
|
+
.replace(/^\.\//, "");
|
|
1411
|
+
if (t === "" || /\s/.test(t) || t.startsWith("#") || /^[a-z][a-z0-9+.-]*:\/\//i.test(t))
|
|
1412
|
+
return null;
|
|
1413
|
+
if (!t.includes("/") && !/\.[A-Za-z][A-Za-z0-9]{0,5}$/.test(t))
|
|
1414
|
+
return null;
|
|
1415
|
+
return path.posix.normalize(t);
|
|
1416
|
+
}
|
|
1417
|
+
/** The repo paths a row names: backticked spans and bare words of its `remediation`, plus its `references`. */
|
|
1418
|
+
function namedPaths(row) {
|
|
1419
|
+
const texts = [
|
|
1420
|
+
...(typeof row["remediation"] === "string" ? [row["remediation"]] : []),
|
|
1421
|
+
...rowRefs(row),
|
|
1422
|
+
];
|
|
1423
|
+
const tokens = texts.flatMap((t) => [
|
|
1424
|
+
...[...t.matchAll(/`([^`]+)`/g)].map((m) => m[1]),
|
|
1425
|
+
...t.replace(/`[^`]*`/g, " ").split(/[\s,()[\]]+/),
|
|
1426
|
+
]);
|
|
1427
|
+
return [
|
|
1428
|
+
...new Set(tokens.map(pathToken).filter((p) => p !== null && p !== "." && p !== "..")),
|
|
1429
|
+
];
|
|
1430
|
+
}
|
|
1431
|
+
/** True when one of `paths` is a file in `root`. */
|
|
1432
|
+
function existsIn(root, paths) {
|
|
1433
|
+
return paths.some((p) => {
|
|
1434
|
+
const abs = path.resolve(root, p);
|
|
1435
|
+
const rel = path.relative(root, abs);
|
|
1436
|
+
return rel !== "" && !rel.startsWith("..") && !path.isAbsolute(rel) && fs.existsSync(abs);
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
/** True when `a` and `b` name the same path, or one sits inside the other. */
|
|
1440
|
+
const within = (a, b) => a === b || a.startsWith(`${b}/`) || b.startsWith(`${a}/`);
|
|
1441
|
+
const NORMAL = (s) => s.toLowerCase().replace(/\s+/g, " ").trim();
|
|
1442
|
+
/** The items the plan's `Out of Scope` rows declare: their excluded item and every backticked token. */
|
|
1443
|
+
function declaredItems(rows) {
|
|
1444
|
+
const out = new Set();
|
|
1445
|
+
for (const row of rows ?? []) {
|
|
1446
|
+
const item = row.cells[0] ?? "";
|
|
1447
|
+
if (item !== "")
|
|
1448
|
+
out.add(NORMAL(item));
|
|
1449
|
+
for (const cell of row.cells)
|
|
1450
|
+
for (const m of cell.matchAll(/`([^`]+)`/g))
|
|
1451
|
+
if (m[1].trim() !== "")
|
|
1452
|
+
out.add(NORMAL(m[1]));
|
|
1453
|
+
}
|
|
1454
|
+
return out;
|
|
1455
|
+
}
|
|
1456
|
+
/**
|
|
1457
|
+
* True when a reference other than the row's own key or the bare FID names a
|
|
1458
|
+
* pre-existing declaration: a plan `Out of Scope` item, or a doc section declared
|
|
1459
|
+
* out of scope. A row that is its own only declaration names none.
|
|
1460
|
+
*/
|
|
1461
|
+
function declares(row, fid, issue, declared) {
|
|
1462
|
+
const own = typeof row["key"] === "string" ? NORMAL(row["key"]) : "";
|
|
1463
|
+
const self = NORMAL(fid);
|
|
1464
|
+
for (const ref of rowRefs(row)) {
|
|
1465
|
+
const t = ref.trim();
|
|
1466
|
+
if (t === "" || NORMAL(t) === own || NORMAL(t) === self || t === `#${issue}`)
|
|
1467
|
+
continue;
|
|
1468
|
+
if (t.includes("§") && /out[- ]of[- ]scope|non-?goals?/i.test(t))
|
|
1469
|
+
return true;
|
|
1470
|
+
const n = NORMAL(t);
|
|
1471
|
+
if (declared.has(n))
|
|
1472
|
+
return true;
|
|
1473
|
+
for (const d of declared)
|
|
1474
|
+
if (d.length >= 8 && n.includes(d))
|
|
1475
|
+
return true;
|
|
1476
|
+
}
|
|
1477
|
+
return false;
|
|
1478
|
+
}
|
|
1479
|
+
/** The same-`key` row triage appends: every prior field verbatim, the verdict fields replaced. */
|
|
1480
|
+
export function unjustifiedRow(row, fid, held) {
|
|
1481
|
+
const out = {};
|
|
1482
|
+
for (const [k, v] of Object.entries(row)) {
|
|
1483
|
+
if (k === "schema" || k === "ts" || k === "bkit" || k === "by" || k === "description")
|
|
1484
|
+
continue;
|
|
1485
|
+
out[k] = v;
|
|
1486
|
+
}
|
|
1487
|
+
out["kind"] = "deferral";
|
|
1488
|
+
out["reason"] = UNJUSTIFIED_REASON;
|
|
1489
|
+
out["status"] = "TRIAGED";
|
|
1490
|
+
out["description"] =
|
|
1491
|
+
`Adjudicated unjustified by bkit ledgers triage for ${fid}: every deferral test holds (${held.join(", ")}).`;
|
|
1492
|
+
// The ship orchestrator's sweep step is the writer, so the row clears the kind's writer check.
|
|
1493
|
+
out["by"] = { workflow: "ship", step: "ship-deferred-sweep" };
|
|
1494
|
+
return out;
|
|
1495
|
+
}
|
|
1496
|
+
/**
|
|
1497
|
+
* Bucket the FID's deferral rows by the four tests and append a same-`key`
|
|
1498
|
+
* `unjustified` / `TRIAGED` row for each that holds all four. Throws
|
|
1499
|
+
* CommandError(USAGE) on a missing `--plan` or a plan whose task blocks do not
|
|
1500
|
+
* parse, CommandError(NO) on a plan with no task blocks — nothing written either
|
|
1501
|
+
* way — and EXIT_ROW_REFUSED when a computed row fails validation.
|
|
1502
|
+
*/
|
|
1503
|
+
export function triageDeferrals(root, fid, planPath) {
|
|
1504
|
+
const abs = path.resolve(root, planPath);
|
|
1505
|
+
if (!fs.existsSync(abs))
|
|
1506
|
+
throw new CommandError(EXIT.USAGE, `--plan not found: ${planPath}`);
|
|
1507
|
+
const text = fs.readFileSync(abs, "utf-8");
|
|
1508
|
+
const blocks = parsePlanBlocks(text);
|
|
1509
|
+
const error = blocks.errors[0];
|
|
1510
|
+
if (error !== undefined)
|
|
1511
|
+
throw new CommandError(EXIT.USAGE, `${planPath}:${error.line}: ${error.message} — run \`bkit tests plan-check\``);
|
|
1512
|
+
// No task block means no task surface: every row would bucket `Exempt` unread.
|
|
1513
|
+
if (blocks.tasks.length === 0)
|
|
1514
|
+
throw new CommandError(EXIT.NO, `${planPath}: ${NO_MARKERS_REASON}`);
|
|
1515
|
+
const surfaces = new Set();
|
|
1516
|
+
for (const task of blocks.tasks)
|
|
1517
|
+
for (const ref of [...task.create, ...task.read, ...task.update, ...task.delete])
|
|
1518
|
+
surfaces.add(path.posix.normalize(ref.file));
|
|
1519
|
+
for (const row of reuseInventory(text)?.rows ?? [])
|
|
1520
|
+
for (const f of row.files)
|
|
1521
|
+
surfaces.add(f);
|
|
1522
|
+
const scope = [...surfaces];
|
|
1523
|
+
const declared = declaredItems(outOfScope(text));
|
|
1524
|
+
const issue = fidIssue(fid);
|
|
1525
|
+
const rows = featureDeferrals(readLedgerRows(path.join(root, APPEND_LEDGERS.deferrals.file)), fid);
|
|
1526
|
+
const out = [];
|
|
1527
|
+
const write = [];
|
|
1528
|
+
for (const row of rows) {
|
|
1529
|
+
const key = typeof row["key"] === "string" ? row["key"] : null;
|
|
1530
|
+
// Closed work is done: nothing to test, nothing to write.
|
|
1531
|
+
if (row["status"] === "CLOSED") {
|
|
1532
|
+
out.push({ key, bucket: "Exempt", tests: [], written: false });
|
|
1533
|
+
continue;
|
|
1534
|
+
}
|
|
1535
|
+
// A LOW challenge finding holds without the tests, and an adjudicated row is never
|
|
1536
|
+
// re-adjudicated: it keeps the `Lazy` bucket its adjudication earned, so an
|
|
1537
|
+
// outstanding unjustified deferral never reads as `Exempt Deferrals`.
|
|
1538
|
+
if (row["reason"] === UNJUSTIFIED_REASON) {
|
|
1539
|
+
out.push({ key, bucket: "Lazy", tests: [], written: false });
|
|
1540
|
+
continue;
|
|
1541
|
+
}
|
|
1542
|
+
if (row["reason"] === "low-severity" && row["severity"] === "LOW") {
|
|
1543
|
+
out.push({ key, bucket: "Exempt", tests: [], written: false });
|
|
1544
|
+
continue;
|
|
1545
|
+
}
|
|
1546
|
+
const paths = namedPaths(row);
|
|
1547
|
+
const verdicts = {
|
|
1548
|
+
// Test 1 reads "not a new architecture": an `own-cycle` row declares itself plan-sized.
|
|
1549
|
+
"bounded-remediation": row["reason"] !== "own-cycle" && existsIn(root, paths),
|
|
1550
|
+
"in-scope-surface": paths.some((p) => scope.some((s) => within(p, s))),
|
|
1551
|
+
"no-external-blocker": row["reason"] !== "hard-blocked" && row["reason"] !== "needs-decision",
|
|
1552
|
+
"own-declaration": !declares(row, fid, issue, declared),
|
|
1553
|
+
};
|
|
1554
|
+
const tests = DEFERRAL_TESTS.map((test) => ({ test, held: verdicts[test] }));
|
|
1555
|
+
const lazy = tests.every((t) => t.held);
|
|
1556
|
+
if (lazy)
|
|
1557
|
+
write.push(unjustifiedRow(row, fid, tests.map((t) => t.test)));
|
|
1558
|
+
out.push({ key, bucket: lazy ? "Lazy" : "Exempt", tests, written: lazy });
|
|
1559
|
+
}
|
|
1560
|
+
if (write.length > 0)
|
|
1561
|
+
appendLedgerRows(root, "deferrals", write);
|
|
1562
|
+
return { fid, plan: planPath, rows: out, total: out.length, written: write.length };
|
|
1563
|
+
}
|
|
1564
|
+
function triage(ctx) {
|
|
1565
|
+
const r = triageDeferrals(rootOf(ctx), required(ctx, "fid"), required(ctx, "plan"));
|
|
1566
|
+
for (const row of r.rows) {
|
|
1567
|
+
const verdict = row.tests.length === 0
|
|
1568
|
+
? "not tested"
|
|
1569
|
+
: row.tests.map((t) => `${t.test} ${t.held ? "holds" : "fails"}`).join(", ");
|
|
1570
|
+
ctx.log(`${row.key ?? "(no key)"} — ${row.bucket}: ${verdict}`);
|
|
1571
|
+
}
|
|
1572
|
+
ctx.log(`${r.total} deferral row(s) for ${r.fid}, ${r.written} written unjustified`);
|
|
1573
|
+
ctx.emit({ ...r });
|
|
1574
|
+
return EXIT.OK;
|
|
1575
|
+
}
|
|
@@ -213,6 +213,7 @@ export const locksCommand = {
|
|
|
213
213
|
verbs: {
|
|
214
214
|
acquire: {
|
|
215
215
|
summary: "Take the workflow lock, reclaiming a dead holder's.",
|
|
216
|
+
use: "workflow",
|
|
216
217
|
flags: [KIND_FLAG, LOCK_WORKFLOW_FLAG, FID_FLAG, MONTH_FLAG],
|
|
217
218
|
output: {
|
|
218
219
|
kind: "workflow",
|
|
@@ -239,6 +240,7 @@ export const locksCommand = {
|
|
|
239
240
|
},
|
|
240
241
|
release: {
|
|
241
242
|
summary: "Remove a lock this caller owns (and the feature's shared-checkout record); another owner's lock is left in place.",
|
|
243
|
+
use: "workflow",
|
|
242
244
|
flags: [
|
|
243
245
|
KIND_FLAG,
|
|
244
246
|
LOCK_WORKFLOW_FLAG,
|