@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
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
// - ADVISORY BY DEFAULT: emits `additionalContext` only, never blocks. Deny mode
|
|
13
13
|
// is wired behind BKIT_GATEGUARD=deny (see MODES).
|
|
14
14
|
// - FAIL OPEN: a single top-level catch swallows every error (the process exits
|
|
15
|
-
// 0 with whatever was already emitted).
|
|
16
|
-
//
|
|
15
|
+
// 0 with whatever was already emitted). The engine catches only its own state
|
|
16
|
+
// write: the checklist is still returned, as advisory.
|
|
17
17
|
// - SUBAGENTS INCLUDED: a subagent edit is an edit. Dedup is per (session, agent,
|
|
18
18
|
// file): a subagent shares its parent's session_id and carries its own agent_id,
|
|
19
19
|
// so it gets its own checklist.
|
|
@@ -57,9 +57,9 @@ function bkitGuardrails(payload) {
|
|
|
57
57
|
if (usesFetch(c) && !curlWgetHostAllowed(c, hookDirs(payload))) {
|
|
58
58
|
notes.push(
|
|
59
59
|
"bkit guardrails: outbound fetch to a host that is not on this repo's network allowlist " +
|
|
60
|
-
"(.agents/context.md § allowed-domains, plus bkit's shipped tooling hosts).
|
|
61
|
-
"
|
|
62
|
-
"
|
|
60
|
+
"(.agents/context.md § allowed-domains, plus bkit's shipped tooling hosts). The command is allowed.\n" +
|
|
61
|
+
"Confirm the destination is intended before you rely on the result.\n" +
|
|
62
|
+
"If the host is a standing dependency, add it to allowed-domains.",
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
65
|
const edits = shellEditTargets(c);
|
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
# HARD STOP instruction) AND `stderr` (visible to the user). Exit code is
|
|
15
15
|
# informational only.
|
|
16
16
|
#
|
|
17
|
-
# bkit generates the managed block at install: the Linear guard
|
|
18
|
-
# Cursor hook (bkit's `hooks/preflight-linear.sh`
|
|
19
|
-
# and the output shape below
|
|
17
|
+
# bkit generates the managed block at install: the Linear guard and the rules-read
|
|
18
|
+
# advisory are shared with the Cursor hook (bkit's `hooks/preflight-linear.sh` and
|
|
19
|
+
# `hooks/preflight-rules.sh`); the trigger, the brew check and the output shape below
|
|
20
|
+
# are Claude's own.
|
|
20
21
|
|
|
21
22
|
# <!-- bkit:start -->
|
|
22
23
|
|
|
@@ -28,21 +29,51 @@ set -euo pipefail
|
|
|
28
29
|
# Claude SessionStart payload: { session_id, transcript_path, cwd, permission_mode } — unused here.
|
|
29
30
|
INPUT=$(cat)
|
|
30
31
|
|
|
31
|
-
# emit_context — Claude SessionStart expects
|
|
32
|
+
# emit_context — Claude SessionStart expects ONE JSON document
|
|
33
|
+
# { hookSpecificOutput: { hookEventName, additionalContext } } on stdout. Each call
|
|
34
|
+
# accumulates its string; the EXIT trap writes the document once, so the advisory and
|
|
35
|
+
# the Linear guard result ride one document (two documents are unparseable).
|
|
32
36
|
# (Cursor variant: emits { additional_context: ... } directly.)
|
|
37
|
+
BKIT_CONTEXT=""
|
|
33
38
|
emit_context() {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
print(json.dumps({
|
|
37
|
-
"hookSpecificOutput": {
|
|
38
|
-
"hookEventName": "SessionStart",
|
|
39
|
-
"additionalContext": sys.argv[1],
|
|
40
|
-
},
|
|
41
|
-
}))
|
|
42
|
-
PY
|
|
39
|
+
[[ -z "$BKIT_CONTEXT" ]] || BKIT_CONTEXT+=$'\n\n'
|
|
40
|
+
BKIT_CONTEXT+="$1"
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
#
|
|
43
|
+
# JSON-escape one string, so a context carrying a quote or a backslash cannot break the
|
|
44
|
+
# document. No python3 on this path: a python3-less IDE session must still get the
|
|
45
|
+
# advisory (Claude cannot block, so a lost advisory would be silent).
|
|
46
|
+
bkit_json_escape() {
|
|
47
|
+
local s=$1 i oct ch esc
|
|
48
|
+
s=${s//\\/\\\\}
|
|
49
|
+
s=${s//\"/\\\"}
|
|
50
|
+
s=${s//$'\n'/\\n}
|
|
51
|
+
s=${s//$'\r'/\\r}
|
|
52
|
+
s=${s//$'\t'/\\t}
|
|
53
|
+
# The rest of the C0 range (U+0000–U+001F) — bash cannot hold NUL, so 1–31 minus the
|
|
54
|
+
# three above. A raw control byte makes the whole document unparseable and the host
|
|
55
|
+
# discards it, taking the advisory and the Linear guard result with it.
|
|
56
|
+
for (( i = 1; i < 32; i++ )); do
|
|
57
|
+
case $i in 9 | 10 | 13) continue ;; esac
|
|
58
|
+
printf -v oct '%03o' "$i"
|
|
59
|
+
printf -v ch "\\$oct"
|
|
60
|
+
printf -v esc '\\u%04x' "$i"
|
|
61
|
+
s=${s//$ch/$esc}
|
|
62
|
+
done
|
|
63
|
+
printf '%s' "$s"
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
bkit_write_document() {
|
|
67
|
+
[[ -n "$BKIT_CONTEXT" ]] || return 0
|
|
68
|
+
printf '{"hookSpecificOutput":{"hookEventName":"SessionStart","additionalContext":"%s"}}\n' \
|
|
69
|
+
"$(bkit_json_escape "$BKIT_CONTEXT")"
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
trap bkit_write_document EXIT
|
|
73
|
+
|
|
74
|
+
# {{BKIT_PART preflight-rules.sh}}
|
|
75
|
+
|
|
76
|
+
# IDE session detection — the advisory above already fired; nothing else runs here.
|
|
46
77
|
# Claude has no native is-background flag, so we use empty LINEAR_ISSUE_ID as the proxy.
|
|
47
78
|
# (Cursor variant: parses `is_background_agent` from stdin JSON.)
|
|
48
79
|
if [[ -z "${LINEAR_ISSUE_ID:-}" ]]; then
|
|
@@ -69,15 +69,15 @@ function decideShell(cmd, dirs) {
|
|
|
69
69
|
case "ask":
|
|
70
70
|
// Advisory on this host (Codex cannot prompt).
|
|
71
71
|
return ask(
|
|
72
|
-
`bkit Codex guardrails: this
|
|
72
|
+
`bkit Codex guardrails: this destructive or privileged command (${v.what}) ran without confirmation, because Codex cannot prompt for one. It is on the PROHIBITED list in every bkit workflow.\nTell the user that you ran it.\nIf the user did not ask for this exact command, NEVER run it again.\n\`git clean\` and \`git checkout -- .\` destroy untracked files and uncommitted work, which no reflog can recover.\nCommand: ${c}`,
|
|
73
73
|
);
|
|
74
74
|
case "secret":
|
|
75
75
|
return ask(
|
|
76
|
-
`bkit Codex guardrails: this command
|
|
76
|
+
`bkit Codex guardrails: this command read ${v.path}, an env, secrets or private-key file, without confirmation, because Codex cannot prompt for one.\nNEVER print secret values.\nPrefer direnv or documented non-secret examples.\nCommand: ${c}`,
|
|
77
77
|
);
|
|
78
78
|
case "fetch":
|
|
79
79
|
return ask(
|
|
80
|
-
`bkit Codex guardrails: outbound fetch to a host that is not on the network allowlist
|
|
80
|
+
`bkit Codex guardrails: outbound fetch to a host that is not on the network allowlist.\nConfirm the destination is intended before you rely on the result.\nCommand: ${c}`,
|
|
81
81
|
);
|
|
82
82
|
default:
|
|
83
83
|
// Shell-as-edit-channel: advisory on every host, never a block.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// bkit-rules.cjs — bkit rules-read advisory PreToolUse hook (Codex CLI).
|
|
3
|
+
//
|
|
4
|
+
// Codex's hook contract is the same family as Claude Code's — same stdin envelope
|
|
5
|
+
// (`tool_name`, `tool_input`, `session_id`, `cwd`), same stdout shape
|
|
6
|
+
// (`hookSpecificOutput` with `additionalContext`). bkit generates the advisory text and
|
|
7
|
+
// its once-per-session helper into it at install (bkit's
|
|
8
|
+
// `core/hooks/session-rules-advisory.js`), the same source as the opencode and
|
|
9
|
+
// Antigravity hooks.
|
|
10
|
+
//
|
|
11
|
+
// Codex has no session-start event, so the advisory rides the FIRST tool call instead:
|
|
12
|
+
// the hook writes it as `additionalContext` once per session, and every later call writes
|
|
13
|
+
// nothing. `additionalContext` is advisory only — no call is ever blocked.
|
|
14
|
+
//
|
|
15
|
+
// REGISTRATION: `.codex/hooks.json`, two single-value `PreToolUse` groups — `apply_patch`
|
|
16
|
+
// and `Bash`, the shape every shipped Codex matcher uses (alternation is not verified on
|
|
17
|
+
// that host). Codex loads project-local hooks only once the project `.codex/` layer is
|
|
18
|
+
// TRUSTED — until then this does not run. See .bkit/providers.md § GateGuard.
|
|
19
|
+
//
|
|
20
|
+
// CONTRACT — do not regress:
|
|
21
|
+
// - ADVISORY ONLY: emits `additionalContext`, never a permission decision.
|
|
22
|
+
// - FAIL OPEN: one top-level catch swallows every error and exits 0.
|
|
23
|
+
// - ONCE PER SESSION: dedup is by `session_id`, state in the OS temp dir, GC'd after
|
|
24
|
+
// 24h. Codex reports the parent's session_id inside a subagent and no agent id, so a
|
|
25
|
+
// subagent can miss an advisory its parent already consumed — the same limit
|
|
26
|
+
// GateGuard records. A payload carrying no session id falls back to one shared bucket.
|
|
27
|
+
//
|
|
28
|
+
// OWNERSHIP: everything between the markers is bkit-managed and overwritten on every
|
|
29
|
+
// `bkit install` / `bkit upgrade`. Add your own logic in the driver below the block.
|
|
30
|
+
|
|
31
|
+
"use strict";
|
|
32
|
+
|
|
33
|
+
// bkit:start
|
|
34
|
+
|
|
35
|
+
// {{BKIT_MANAGED_MARKER}}
|
|
36
|
+
|
|
37
|
+
const fs = require("node:fs");
|
|
38
|
+
const os = require("node:os");
|
|
39
|
+
const path = require("node:path");
|
|
40
|
+
|
|
41
|
+
// {{BKIT_PART session-rules-advisory.js}}
|
|
42
|
+
|
|
43
|
+
// bkit:end
|
|
44
|
+
|
|
45
|
+
function emit(payload) {
|
|
46
|
+
process.stdout.write(JSON.stringify({ hookSpecificOutput: payload }));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
const raw = fs.readFileSync(0, "utf-8");
|
|
51
|
+
if (raw.trim()) {
|
|
52
|
+
const advisory = rulesReadAdviceOnce(JSON.parse(raw).session_id);
|
|
53
|
+
if (advisory) emit({ hookEventName: "PreToolUse", additionalContext: advisory });
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
process.exitCode = 0; // fail open — never block, never error out
|
|
57
|
+
}
|
|
@@ -69,17 +69,17 @@ function decideShell(cmd, dirs) {
|
|
|
69
69
|
return deny(`Blocked: ${v.what} is denied by bkit Cursor guardrails.`, v.fix);
|
|
70
70
|
case "ask":
|
|
71
71
|
return ask(
|
|
72
|
-
`bkit Cursor guardrails: confirm this destructive
|
|
72
|
+
`bkit Cursor guardrails: confirm this destructive or privileged shell command (${v.what}).`,
|
|
73
73
|
`Command requires confirmation: ${c}`,
|
|
74
74
|
);
|
|
75
75
|
case "secret":
|
|
76
76
|
return ask(
|
|
77
|
-
"bkit Cursor guardrails: confirm a shell read of an env
|
|
78
|
-
`Reading ${v.path} through the shell may expose secrets
|
|
77
|
+
"bkit Cursor guardrails: confirm a shell read of an env, secrets or private-key file.",
|
|
78
|
+
`Reading ${v.path} through the shell may expose secrets.\nPrefer direnv or documented non-secret examples.\nCommand: ${c}`,
|
|
79
79
|
);
|
|
80
80
|
case "fetch":
|
|
81
81
|
return ask(
|
|
82
|
-
"bkit Cursor guardrails: confirm outbound curl
|
|
82
|
+
"bkit Cursor guardrails: confirm an outbound curl or wget to a host that is not on the network allowlist.",
|
|
83
83
|
`Command requires confirmation: ${c}`,
|
|
84
84
|
);
|
|
85
85
|
default:
|
|
@@ -96,12 +96,12 @@ function decideRead(filePath) {
|
|
|
96
96
|
if (v.tier === "deny") {
|
|
97
97
|
return deny(
|
|
98
98
|
"Blocked: reading private-key material is denied by bkit Cursor guardrails.",
|
|
99
|
-
`
|
|
99
|
+
`NEVER read ${v.path}.\nAsk the user to supply what you need without putting the key in this conversation.`,
|
|
100
100
|
);
|
|
101
101
|
}
|
|
102
102
|
return ask(
|
|
103
|
-
"bkit Cursor guardrails: confirm reading an env
|
|
104
|
-
`Reading ${v.path} may expose secrets
|
|
103
|
+
"bkit Cursor guardrails: confirm reading an env or secrets file.",
|
|
104
|
+
`Reading ${v.path} may expose secrets.\nPrefer direnv or documented non-secret examples.`,
|
|
105
105
|
);
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
# blocks the session before the agent starts. Failures are also surfaced via
|
|
13
13
|
# `additional_context` so the user sees the reason.
|
|
14
14
|
#
|
|
15
|
-
# bkit generates the managed block at install: the Linear guard
|
|
16
|
-
# Claude hook (bkit's `hooks/preflight-linear.sh`
|
|
17
|
-
# marker and the output shape
|
|
15
|
+
# bkit generates the managed block at install: the Linear guard and the rules-read
|
|
16
|
+
# advisory are shared with the Claude hook (bkit's `hooks/preflight-linear.sh` and
|
|
17
|
+
# `hooks/preflight-rules.sh`); the trigger, the runtime marker and the output shape
|
|
18
|
+
# below are Cursor's own.
|
|
18
19
|
|
|
19
20
|
# <!-- bkit:start -->
|
|
20
21
|
|
|
@@ -26,6 +27,49 @@ set -euo pipefail
|
|
|
26
27
|
# Cursor sessionStart payload: { session_id, is_background_agent, composer_mode } — used for IDE detection below.
|
|
27
28
|
INPUT=$(cat)
|
|
28
29
|
|
|
30
|
+
# emit_context — Cursor sessionStart expects ONE JSON document { additional_context: ... }
|
|
31
|
+
# on stdout. Each call accumulates its string; the EXIT trap writes the document once, so
|
|
32
|
+
# the advisory and the Linear guard result ride one document. Defined above the bail so an
|
|
33
|
+
# IDE session gets the advisory too, and built with no python3: failClosed:true blocks the
|
|
34
|
+
# session on a non-zero exit, and an IDE session may not have python3 at all.
|
|
35
|
+
# (Claude variant: wraps in { hookSpecificOutput: { hookEventName, additionalContext } }.)
|
|
36
|
+
BKIT_CONTEXT=""
|
|
37
|
+
emit_context() {
|
|
38
|
+
[[ -z "$BKIT_CONTEXT" ]] || BKIT_CONTEXT+=$'\n\n'
|
|
39
|
+
BKIT_CONTEXT+="$1"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# JSON-escape one string, so a context carrying a quote or a backslash cannot break the
|
|
43
|
+
# document.
|
|
44
|
+
bkit_json_escape() {
|
|
45
|
+
local s=$1 i oct ch esc
|
|
46
|
+
s=${s//\\/\\\\}
|
|
47
|
+
s=${s//\"/\\\"}
|
|
48
|
+
s=${s//$'\n'/\\n}
|
|
49
|
+
s=${s//$'\r'/\\r}
|
|
50
|
+
s=${s//$'\t'/\\t}
|
|
51
|
+
# The rest of the C0 range (U+0000–U+001F) — bash cannot hold NUL, so 1–31 minus the
|
|
52
|
+
# three above. A raw control byte makes the whole document unparseable and the host
|
|
53
|
+
# discards it, taking the advisory and the Linear guard result with it.
|
|
54
|
+
for (( i = 1; i < 32; i++ )); do
|
|
55
|
+
case $i in 9 | 10 | 13) continue ;; esac
|
|
56
|
+
printf -v oct '%03o' "$i"
|
|
57
|
+
printf -v ch "\\$oct"
|
|
58
|
+
printf -v esc '\\u%04x' "$i"
|
|
59
|
+
s=${s//$ch/$esc}
|
|
60
|
+
done
|
|
61
|
+
printf '%s' "$s"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
bkit_write_document() {
|
|
65
|
+
[[ -n "$BKIT_CONTEXT" ]] || return 0
|
|
66
|
+
printf '{"additional_context":"%s"}\n' "$(bkit_json_escape "$BKIT_CONTEXT")"
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
trap bkit_write_document EXIT
|
|
70
|
+
|
|
71
|
+
# {{BKIT_PART preflight-rules.sh}}
|
|
72
|
+
|
|
29
73
|
# IDE session bailout — grep only, no python3 on the skip path (failClosed:true in
|
|
30
74
|
# .cursor/hooks.json blocks the session if this exits non-zero). Background-agent
|
|
31
75
|
# sessions run inside the bkit Dockerfile, where python3 is present for the code below.
|
|
@@ -44,15 +88,6 @@ if BKIT_REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null) && [[ -d "$BKIT_R
|
|
|
44
88
|
|| echo "[bkit-runtime] could not write .bkit/.runtime-cursor — runtime will resolve as LOCAL" >&2
|
|
45
89
|
fi
|
|
46
90
|
|
|
47
|
-
# emit_context — Cursor sessionStart expects { additional_context: ... } directly.
|
|
48
|
-
# (Claude variant: wraps in { hookSpecificOutput: { hookEventName, additionalContext } }.)
|
|
49
|
-
emit_context() {
|
|
50
|
-
python3 - "$1" <<'PY'
|
|
51
|
-
import json, sys
|
|
52
|
-
print(json.dumps({"additional_context": sys.argv[1]}))
|
|
53
|
-
PY
|
|
54
|
-
}
|
|
55
|
-
|
|
56
91
|
# Brew dep preflight — N/A on Cursor Cloud.
|
|
57
92
|
# Cursor Cloud runs in a containerised env where required CLIs (gh, jq, vale, pnpm, bun) are
|
|
58
93
|
# pre-installed via .cursor/Dockerfile, so the laptop-side brew check makes no sense here.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// bkit-rules.js — bkit rules-read advisory plugin for opencode.
|
|
2
|
+
//
|
|
3
|
+
// Fires on opencode's tool hooks. On the FIRST tool call of a session it appends the
|
|
4
|
+
// rules-read advisory to the tool result, so the model is told to read `.agents/rules.md`
|
|
5
|
+
// before any other action; every later call appends nothing.
|
|
6
|
+
//
|
|
7
|
+
// CONTRACT — do not regress:
|
|
8
|
+
// - ADVISORY ONLY: appends the advisory to the tool RESULT in the after-execute hook —
|
|
9
|
+
// never blocks. stderr is NOT a model channel on 2.0's detached server.
|
|
10
|
+
// - FAIL OPEN: a top-level try/catch swallows every error; the plugin never throws.
|
|
11
|
+
// - ONCE PER SESSION: dedup is by sessionID, state in the OS temp dir, GC'd after 24h.
|
|
12
|
+
// A subagent runs in its own session, so it gets its own advisory; a payload carrying
|
|
13
|
+
// no session id falls back to one shared bucket. The token is spent only once the call
|
|
14
|
+
// is known to carry the advisory, so a call whose result never arrived leaves it for
|
|
15
|
+
// the next call instead of losing the nudge for the whole session.
|
|
16
|
+
// - NO SESSION-START EVENT: opencode has none, so the advisory rides the first tool
|
|
17
|
+
// call's result instead.
|
|
18
|
+
//
|
|
19
|
+
// The advisory text and its once-per-session helper are generated at install from bkit's
|
|
20
|
+
// `core/hooks/session-rules-advisory.js`, the same source as the Codex and Antigravity
|
|
21
|
+
// hooks.
|
|
22
|
+
//
|
|
23
|
+
// OWNERSHIP: everything between the markers below is bkit-managed and is overwritten on
|
|
24
|
+
// every `bkit install` / `bkit upgrade`. It is a pure advisory only — no client calls, no
|
|
25
|
+
// stderr write, no throw — so it composes with your own checks in the exported plugin
|
|
26
|
+
// that follows the managed block.
|
|
27
|
+
|
|
28
|
+
// bkit:start
|
|
29
|
+
|
|
30
|
+
// {{BKIT_MANAGED_MARKER}}
|
|
31
|
+
|
|
32
|
+
import * as fs from "node:fs";
|
|
33
|
+
import * as os from "node:os";
|
|
34
|
+
import * as path from "node:path";
|
|
35
|
+
|
|
36
|
+
// {{BKIT_PART session-rules-advisory.js}}
|
|
37
|
+
|
|
38
|
+
// bkit:end
|
|
39
|
+
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// Driver — the one export shape OpenCode 1.x and 2.0 both load (same as
|
|
42
|
+
// `bkit-gateguard.js`): 2.0 calls `setup(ctx)` and registers `execute.after`; 1.18.29+
|
|
43
|
+
// calls `server()` and uses `"tool.execute.after"`. Both call the shared
|
|
44
|
+
// rulesReadAdviceOnce() above, so once-per-session behaviour is identical across the two.
|
|
45
|
+
// The file deliberately imports NOTHING from `@opencode/plugin`: that package only exists
|
|
46
|
+
// on 2.0, and importing it would break the module load on 1.x.
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
|
|
49
|
+
/** OpenCode 1.x after hook: append the advisory to `output.output`, the result text. */
|
|
50
|
+
async function bkitRulesAfterV1(hookInput, output) {
|
|
51
|
+
try {
|
|
52
|
+
// Check the delivery shape BEFORE spending the session's one advisory: a call that
|
|
53
|
+
// cannot carry it must leave the token for the next call.
|
|
54
|
+
if (!output || typeof output !== "object") return;
|
|
55
|
+
const advisory = rulesReadAdviceOnce(hookInput?.sessionID);
|
|
56
|
+
if (!advisory) return;
|
|
57
|
+
const existing = typeof output.output === "string" ? output.output : "";
|
|
58
|
+
output.output = existing.length > 0 ? `${existing}\n\n${advisory}` : advisory;
|
|
59
|
+
} catch {
|
|
60
|
+
// fail-open: never let an advisory error reach the host
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** OpenCode 2.0 after hook: append the advisory to `event.result.content`. */
|
|
65
|
+
async function bkitRulesAfterV2(event) {
|
|
66
|
+
try {
|
|
67
|
+
// Check the delivery shape BEFORE spending the session's one advisory: a call that
|
|
68
|
+
// cannot carry it must leave the token for the next call.
|
|
69
|
+
if (!event || event.status !== "completed" || !event.result) return;
|
|
70
|
+
const advisory = rulesReadAdviceOnce(event?.sessionID);
|
|
71
|
+
if (!advisory) return;
|
|
72
|
+
const content = Array.isArray(event.result.content) ? event.result.content : [];
|
|
73
|
+
event.result.content = [...content, { type: "text", text: advisory }];
|
|
74
|
+
} catch {
|
|
75
|
+
// fail-open: never let an advisory error reach the host
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const bkitRulesPlugin = {
|
|
80
|
+
id: "bkit-rules",
|
|
81
|
+
async setup(ctx) {
|
|
82
|
+
await ctx.tool.hook("execute.after", bkitRulesAfterV2);
|
|
83
|
+
},
|
|
84
|
+
async server() {
|
|
85
|
+
return { "tool.execute.after": bkitRulesAfterV1 };
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default bkitRulesPlugin;
|
package/.bkit/core/AGENTS.md
CHANGED
|
@@ -5,78 +5,10 @@
|
|
|
5
5
|
{{BKIT_MANAGED_MARKER}}
|
|
6
6
|
|
|
7
7
|
- **Rules file:** Read `.agents/rules.md` → follow all rules.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## Route
|
|
15
|
-
|
|
16
|
-
### Step 1 — Find issue ID in prompt
|
|
17
|
-
|
|
18
|
-
**If** prompt contains `<LINEAR_ISSUE>` XML block (Linear integration) → `ISSUE_ID` ← `<id>` tag value (e.g. `LIN-123` or team-specific prefix).
|
|
19
|
-
|
|
20
|
-
**Else** scan entire session prompt for issue ID — try patterns in order, first match wins:
|
|
21
|
-
|
|
22
|
-
1. `#\d+`, `owner/repo#\d+` or a GitHub issue URL (`…/{owner}/{repo}/issues/\d+`) into this repo (`owner/repo` of the `origin` remote) → GitHub issue number (e.g. `#123`); strip `#`, set `ISSUE_ID` = `123`
|
|
23
|
-
2. `[A-Z][A-Z0-9]*-\d+` carrying the `package.json` `bkit.tracker.linear.team` / `bkit.tracker.jira.project` prefix, a Linear issue URL (`linear.app/…/issue/ID`) with that prefix, or a Jira browse URL (`…/browse/ID`) on the `bkit.tracker.jira.site` host with that prefix → prefixed issue ID (e.g. Linear `LIN-123`, Jira `PROJ-123`)
|
|
24
|
-
|
|
25
|
-
A bare number with no `#` is not an issue ID; neither is a bare key with no team / project set, nor a tracker URL into another repo, team or site; the run is issue-less (same rule as `bkit fids parse`).
|
|
26
|
-
|
|
27
|
-
Set `LABELS`, `DESCRIPTION` = empty.
|
|
28
|
-
|
|
29
|
-
**If** no `ISSUE_ID` → keep `ISSUE_ID` empty → Step 2.
|
|
30
|
-
|
|
31
|
-
### Step 2 — Route from user message
|
|
32
|
-
|
|
33
|
-
In the bottom-most `USER:` entry in `# Message history` scan for commands (case-insensitive: Ship, Debug, Build, Plan, Design) → first match → `COMMAND`. **If** matched → skip Step 3.
|
|
34
|
-
|
|
35
|
-
### Step 3 — Route from issue labels
|
|
36
|
-
|
|
37
|
-
Only if `ISSUE_ID` non-empty: read current issue labels and description via the configured tracker MCP (GitHub: `mcp__github__issue_read({ method: "get", ... })`; Linear: `mcp__linear__get_issue({ id: "{ISSUE_ID}" })`; Jira: `mcp__jira__getJiraIssue({ cloudId: "<package.json bkit.tracker.jira.site>", issueIdOrKey: "{ISSUE_ID}", view: "evidence" })` → `fields.labels`) → `LABELS`, `DESCRIPTION`. **If** the MCP read fails and the prompt holds a `<LINEAR_ISSUE>` block → fallback: `LABELS` ← all `<label name="...">` values in its `<labels>` block, `DESCRIPTION` ← its `<description>` tag content.
|
|
38
|
-
|
|
39
|
-
Scan `LABELS` for commands (Ship, Debug, Build, Plan, Design) → first match → `COMMAND`.
|
|
40
|
-
|
|
41
|
-
### Step 4 — No match
|
|
42
|
-
|
|
43
|
-
Emit: `Workflow not found for issue {ISSUE_ID}. Valid commands: Design / Plan / Build / Debug / Ship.` (drop `for issue {ISSUE_ID}` when `ISSUE_ID` empty) → **STOP**; do not post a tracker comment.
|
|
44
|
-
|
|
45
|
-
### Step 5 — Execute command
|
|
46
|
-
|
|
47
|
-
Read and execute the matched command file for the current IDE.
|
|
48
|
-
|
|
49
|
-
**Cursor** (`.cursor/commands/`):
|
|
50
|
-
|
|
51
|
-
<!-- prettier-ignore -->
|
|
52
|
-
| Label | Command |
|
|
53
|
-
| --- | --- |
|
|
54
|
-
| `Ship` | `.cursor/commands/bkit-ship.md` |
|
|
55
|
-
| `Debug` | `.cursor/commands/bkit-debug.md` |
|
|
56
|
-
| `Build` | `.cursor/commands/bkit-build.md` |
|
|
57
|
-
| `Plan` | `.cursor/commands/bkit-plan.md` |
|
|
58
|
-
| `Design` | `.cursor/commands/bkit-design.md` |
|
|
59
|
-
|
|
60
|
-
**Claude Code** (`.claude/commands/`):
|
|
61
|
-
|
|
62
|
-
<!-- prettier-ignore -->
|
|
63
|
-
| Label | Command |
|
|
64
|
-
| --- | --- |
|
|
65
|
-
| `Ship` | `.claude/commands/bkit-ship.md` |
|
|
66
|
-
| `Debug` | `.claude/commands/bkit-debug.md` |
|
|
67
|
-
| `Build` | `.claude/commands/bkit-build.md` |
|
|
68
|
-
| `Plan` | `.claude/commands/bkit-plan.md` |
|
|
69
|
-
| `Design` | `.claude/commands/bkit-design.md` |
|
|
70
|
-
|
|
71
|
-
**Antigravity** (`.agents/plugins/bkit/skills/`):
|
|
72
|
-
|
|
73
|
-
<!-- prettier-ignore -->
|
|
74
|
-
| Label | Command |
|
|
75
|
-
| --- | --- |
|
|
76
|
-
| `Ship` | `.agents/plugins/bkit/skills/bkit-ship/SKILL.md` |
|
|
77
|
-
| `Debug` | `.agents/plugins/bkit/skills/bkit-debug/SKILL.md` |
|
|
78
|
-
| `Build` | `.agents/plugins/bkit/skills/bkit-build/SKILL.md` |
|
|
79
|
-
| `Plan` | `.agents/plugins/bkit/skills/bkit-plan/SKILL.md` |
|
|
80
|
-
| `Design` | `.agents/plugins/bkit/skills/bkit-design/SKILL.md` |
|
|
8
|
+
- **Workflows:** **If** the prompt contains `bkit-{command}` (`bkit-design`, `bkit-plan`, `bkit-build`, `bkit-debug`, `bkit-ship`, `bkit-auto`) → read `.bkit/router.md` → follow it. **Else** → no workflow routing; handle the request as asked.
|
|
9
|
+
- **Memory hygiene:** Agent memories (notes a host keeps across sessions) are pointers, never copies.
|
|
10
|
+
- For a fact in `docs/*.md` or `.agents/rules.md`, save only its path, its section and a one-line hook.
|
|
11
|
+
- Query the tracker or `docs/roadmap.md` for an issue's state.
|
|
12
|
+
- Never save a snapshot of an issue's state in memory.
|
|
81
13
|
|
|
82
14
|
<!-- bkit:end -->
|