@cbartens/bkit 0.0.0-stage → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.bkit/README.md +421 -0
- package/.bkit/core/.agents/context.md +95 -0
- package/.bkit/core/.agents/docs.md +62 -0
- package/.bkit/core/.agents/rules.md +147 -0
- package/.bkit/core/.agents/skills.md +43 -0
- package/.bkit/core/.bkit/LICENSE.md +151 -0
- package/.bkit/core/.bkit/README.md +421 -0
- package/.bkit/core/.bkit/cloud.md +502 -0
- package/.bkit/core/.bkit/comparison.md +318 -0
- package/.bkit/core/.bkit/install.md +496 -0
- package/.bkit/core/.bkit/jsonl.md +497 -0
- package/.bkit/core/.bkit/prompts.md +474 -0
- package/.bkit/core/.bkit/providers.md +598 -0
- package/.bkit/core/.bkit/templates.md +471 -0
- package/.bkit/core/.bkit/trackers.md +95 -0
- package/.bkit/core/.bkit/workflows.md +1546 -0
- package/.bkit/core/.claude/hooks/bkit-gateguard.cjs +82 -0
- package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +93 -0
- package/.bkit/core/.claude/hooks/bkit-preflight.sh +74 -0
- package/.bkit/core/.codex/hooks/bkit-gateguard.cjs +115 -0
- package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +135 -0
- package/.bkit/core/.cursor/hooks/bkit-gateguard.cjs +111 -0
- package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +169 -0
- package/.bkit/core/.cursor/hooks/bkit-preflight.sh +63 -0
- package/.bkit/core/.opencode/plugin/bkit-gateguard.js +225 -0
- package/.bkit/core/AGENTS.md +77 -0
- package/.bkit/core/LICENSE.md +149 -0
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +272 -0
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +223 -0
- package/.bkit/core/docs/templates/bkit-audit-agents.md +230 -0
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +227 -0
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +266 -0
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +230 -0
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +270 -0
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +254 -0
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +221 -0
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +241 -0
- package/.bkit/core/docs/templates/bkit-audit-config.md +230 -0
- package/.bkit/core/docs/templates/bkit-audit-cost.md +218 -0
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +221 -0
- package/.bkit/core/docs/templates/bkit-audit-database.md +229 -0
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +251 -0
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +283 -0
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +268 -0
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +280 -0
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +253 -0
- package/.bkit/core/docs/templates/bkit-audit-failures.md +259 -0
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +237 -0
- package/.bkit/core/docs/templates/bkit-audit-gates.md +250 -0
- package/.bkit/core/docs/templates/bkit-audit-issues.md +273 -0
- package/.bkit/core/docs/templates/bkit-audit-llm.md +239 -0
- package/.bkit/core/docs/templates/bkit-audit-logs.md +266 -0
- package/.bkit/core/docs/templates/bkit-audit-models.md +210 -0
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +211 -0
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +216 -0
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +220 -0
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +222 -0
- package/.bkit/core/docs/templates/bkit-audit-repo.md +224 -0
- package/.bkit/core/docs/templates/bkit-audit-security.md +274 -0
- package/.bkit/core/docs/templates/bkit-audit-slop.md +200 -0
- package/.bkit/core/docs/templates/bkit-audit-testing.md +270 -0
- package/.bkit/core/docs/templates/bkit-audit-usability.md +237 -0
- package/.bkit/core/docs/templates/bkit-plan.md +476 -0
- package/.bkit/core/engine/checks/after/auth.ts +247 -0
- package/.bkit/core/engine/checks/after/ci-yml.ts +739 -0
- package/.bkit/core/engine/checks/after/github.ts +424 -0
- package/.bkit/core/engine/checks/after/index.ts +556 -0
- package/.bkit/core/engine/checks/after/managed.ts +217 -0
- package/.bkit/core/engine/checks/after/tools.ts +427 -0
- package/.bkit/core/engine/checks/after/vercel.ts +101 -0
- package/.bkit/core/engine/checks/before/context-fetch.ts +429 -0
- package/.bkit/core/engine/checks/before/env.ts +201 -0
- package/.bkit/core/engine/checks/before/files.ts +202 -0
- package/.bkit/core/engine/checks/before/index.ts +206 -0
- package/.bkit/core/engine/checks/before/mcp.ts +127 -0
- package/.bkit/core/engine/checks/before/repo.ts +77 -0
- package/.bkit/core/engine/checks/before/version.ts +67 -0
- package/.bkit/core/engine/checks/status-holes.ts +479 -0
- package/.bkit/core/engine/cli.ts +871 -0
- package/.bkit/core/engine/commands/analysis.ts +550 -0
- package/.bkit/core/engine/commands/ci/ci.ts +483 -0
- package/.bkit/core/engine/commands/comply.ts +415 -0
- package/.bkit/core/engine/commands/harvest.ts +459 -0
- package/.bkit/core/engine/commands/install/check.ts +70 -0
- package/.bkit/core/engine/commands/install/doctor.ts +247 -0
- package/.bkit/core/engine/commands/install/install.ts +528 -0
- package/.bkit/core/engine/commands/install/uninstall.ts +972 -0
- package/.bkit/core/engine/commands/install/upgrade.ts +1026 -0
- package/.bkit/core/engine/commands/launch.ts +139 -0
- package/.bkit/core/engine/commands/lib.ts +494 -0
- package/.bkit/core/engine/commands/registry.ts +53 -0
- package/.bkit/core/engine/commands/setup/setup.ts +184 -0
- package/.bkit/core/engine/commands/telemetry.ts +32 -0
- package/.bkit/core/engine/commands/workflow/branches.ts +1514 -0
- package/.bkit/core/engine/commands/workflow/context.ts +961 -0
- package/.bkit/core/engine/commands/workflow/counters.ts +268 -0
- package/.bkit/core/engine/commands/workflow/fids.ts +243 -0
- package/.bkit/core/engine/commands/workflow/issues.ts +675 -0
- package/.bkit/core/engine/commands/workflow/ledgers.ts +575 -0
- package/.bkit/core/engine/commands/workflow/locks.ts +478 -0
- package/.bkit/core/engine/commands/workflow/prs.ts +1087 -0
- package/.bkit/core/engine/commands/workflow/repo.ts +220 -0
- package/.bkit/core/engine/commands/workflow/roadmap.ts +576 -0
- package/.bkit/core/engine/commands/workflow/runs.ts +2140 -0
- package/.bkit/core/engine/commands/workflow/runtime.ts +300 -0
- package/.bkit/core/engine/commands/workflow/skills.ts +118 -0
- package/.bkit/core/engine/commands/workflow/status.ts +455 -0
- package/.bkit/core/engine/commands/workflow/steps.ts +1300 -0
- package/.bkit/core/engine/commands/workflow/tests.ts +161 -0
- package/.bkit/core/engine/commands/workflow/workflows.ts +1573 -0
- package/.bkit/core/engine/commands/workflow/workstreams.ts +164 -0
- package/.bkit/core/engine/commands/workflow/worktrees.ts +534 -0
- package/.bkit/core/engine/install/cloud-env.ts +925 -0
- package/.bkit/core/engine/install/managed-block.ts +212 -0
- package/.bkit/core/engine/install/manifest.ts +448 -0
- package/.bkit/core/engine/install/modules/claude.ts +362 -0
- package/.bkit/core/engine/install/modules/cloud.ts +174 -0
- package/.bkit/core/engine/install/modules/codex.ts +219 -0
- package/.bkit/core/engine/install/modules/core.ts +600 -0
- package/.bkit/core/engine/install/modules/cursor.ts +231 -0
- package/.bkit/core/engine/install/modules/index.ts +242 -0
- package/.bkit/core/engine/install/modules/opencode.ts +573 -0
- package/.bkit/core/engine/install/placeholders.ts +108 -0
- package/.bkit/core/engine/install/template-copies.ts +119 -0
- package/.bkit/core/engine/install/version-file.ts +284 -0
- package/.bkit/core/engine/install/write.ts +467 -0
- package/.bkit/core/engine/ledgers/clamp-log.ts +32 -0
- package/.bkit/core/engine/ledgers/status.ts +213 -0
- package/.bkit/core/engine/ledgers/telemetry.ts +1143 -0
- package/.bkit/core/engine/render/hosts.ts +372 -0
- package/.bkit/core/engine/render/models.ts +323 -0
- package/.bkit/core/engine/render/parts.ts +38 -0
- package/.bkit/core/engine/render/trackers.ts +170 -0
- package/.bkit/core/engine/shared/egress.ts +345 -0
- package/.bkit/core/engine/shared/json.ts +16 -0
- package/.bkit/core/engine/shared/log-prefix.ts +9 -0
- package/.bkit/core/engine/shared/package-json.ts +29 -0
- package/.bkit/core/engine/shared/package-manager.ts +38 -0
- package/.bkit/core/engine/shared/package-roots.ts +163 -0
- package/.bkit/core/engine/shared/protected-paths.ts +164 -0
- package/.bkit/core/engine/shared/settings.ts +72 -0
- package/.bkit/core/engine/shared/timeouts.ts +20 -0
- package/.bkit/core/engine/tools/wording.ts +748 -0
- package/.bkit/core/hooks/gateguard-edit-payload.js +18 -0
- package/.bkit/core/hooks/gateguard-engine.js +193 -0
- package/.bkit/core/hooks/guardrails-shell.js +154 -0
- package/.bkit/core/hooks/guardrails-tiers.js +68 -0
- package/.bkit/core/hooks/preflight-linear.sh +73 -0
- package/.bkit/core/prompts/bkit-audit-generate.md +66 -0
- package/.bkit/core/prompts/bkit-build-challenge-1.md +79 -0
- package/.bkit/core/prompts/bkit-build-challenge-2.md +81 -0
- package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +68 -0
- package/.bkit/core/prompts/bkit-build-challenge-remediate.md +70 -0
- package/.bkit/core/prompts/bkit-build-challenge-tests.md +73 -0
- package/.bkit/core/prompts/bkit-build-install-skills.md +67 -0
- package/.bkit/core/prompts/bkit-build-plan-current.md +75 -0
- package/.bkit/core/prompts/bkit-build-plan-execute.md +72 -0
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +73 -0
- package/.bkit/core/prompts/bkit-build-plan-verify.md +88 -0
- package/.bkit/core/prompts/bkit-build-summary.md +93 -0
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +90 -0
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +151 -0
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +78 -0
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +73 -0
- package/.bkit/core/prompts/bkit-debug-summary.md +95 -0
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +72 -0
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +72 -0
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +75 -0
- package/.bkit/core/prompts/bkit-design-generate.md +110 -0
- package/.bkit/core/prompts/bkit-design-organise.md +85 -0
- package/.bkit/core/prompts/bkit-design-review-1.md +121 -0
- package/.bkit/core/prompts/bkit-design-review-2.md +111 -0
- package/.bkit/core/prompts/bkit-design-spike.md +97 -0
- package/.bkit/core/prompts/bkit-design-summary.md +106 -0
- package/.bkit/core/prompts/bkit-design-update.md +66 -0
- package/.bkit/core/prompts/bkit-plan-complexity-check.md +66 -0
- package/.bkit/core/prompts/bkit-plan-complexity-split.md +87 -0
- package/.bkit/core/prompts/bkit-plan-generate.md +74 -0
- package/.bkit/core/prompts/bkit-plan-review-1.md +90 -0
- package/.bkit/core/prompts/bkit-plan-review-2.md +80 -0
- package/.bkit/core/prompts/bkit-plan-review-3.md +92 -0
- package/.bkit/core/prompts/bkit-plan-scope-check-1.md +84 -0
- package/.bkit/core/prompts/bkit-plan-scope-check-2.md +84 -0
- package/.bkit/core/prompts/bkit-plan-summary.md +106 -0
- package/.bkit/core/prompts/bkit-plan-update.md +68 -0
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +90 -0
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +94 -0
- package/.bkit/core/prompts/bkit-ship-summary.md +77 -0
- package/.bkit/core/prompts/bkit-ship-update-docs.md +71 -0
- package/.bkit/core/prompts/bkit-utility-compress-markdown.md +91 -0
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +75 -0
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +76 -0
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +61 -0
- package/.bkit/core/prompts/bkit-utility-update-failures.md +76 -0
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +75 -0
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +82 -0
- package/.bkit/core/workflows/bkit-auto.md +121 -0
- package/.bkit/core/workflows/bkit-build.md +802 -0
- package/.bkit/core/workflows/bkit-debug.md +642 -0
- package/.bkit/core/workflows/bkit-design.md +495 -0
- package/.bkit/core/workflows/bkit-plan.md +510 -0
- package/.bkit/core/workflows/bkit-ship.md +650 -0
- package/.bkit/shared/.bkit/.env.example +108 -0
- package/.bkit/shared/.claude/bkit-cloud.md +117 -0
- package/.bkit/shared/.claude/settings.json +88 -0
- package/.bkit/shared/.codex/hooks.json +26 -0
- package/.bkit/shared/.cursor/bkit-cloud.md +84 -0
- package/.bkit/shared/.cursor/hooks.json +26 -0
- package/.bkit/shared/.cursor/mcp.json +15 -0
- package/.bkit/shared/.cursor/rules/bkit-rules.mdc +12 -0
- package/.bkit/shared/.gitattributes +37 -0
- package/.bkit/shared/.mcp.json +16 -0
- package/.bkit/shared/.opencode/opencode.json +62 -0
- package/.bkit/shared/CLAUDE.md +11 -0
- package/.bkit/shared/LICENSE.md +22 -0
- package/.bkit/shared/docs/architecture.md +19 -0
- package/.bkit/shared/docs/data-schema.md +19 -0
- package/.bkit/shared/docs/deployments.md +438 -0
- package/.bkit/shared/docs/design.md +39 -0
- package/.bkit/shared/docs/noise.md +19 -0
- package/.bkit/shared/docs/observability.md +25 -0
- package/.bkit/shared/docs/security.md +42 -0
- package/.bkit/shared/docs/setup.md +30 -0
- package/.bkit/shared/docs/technology.md +18 -0
- package/.bkit/shared/docs/testing.md +413 -0
- package/.bkit/shared/gitignore +92 -0
- package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +192 -0
- package/.bkit/templates/.cursor/Dockerfile +68 -0
- package/.bkit/templates/.cursor/environment.json +6 -0
- package/.bkit/templates/.cursor/settings.json +11 -0
- package/.bkit/templates/.envrc +7 -0
- package/.bkit/templates/.github/dependabot.yml +52 -0
- package/.bkit/templates/.github/renovate.json5 +239 -0
- package/.bkit/templates/.github/workflows/bkit-ci.yml +1082 -0
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +566 -0
- package/.bkit/templates/.github/workflows/bkit-renovate.yml +107 -0
- package/.bkit/templates/.graphifyignore +108 -0
- package/.bkit/templates/.husky/pre-commit +16 -0
- package/.bkit/templates/.husky/pre-push +91 -0
- package/.bkit/templates/.lintstagedrc.json +3 -0
- package/.bkit/templates/.prettierignore +41 -0
- package/.bkit/templates/.serena/project.yml +243 -0
- package/.bkit/templates/.vale/styles/House/Filler.yml +11 -0
- package/.bkit/templates/.vale/styles/House/Hedging.yml +12 -0
- package/.bkit/templates/.vale/styles/House/LLMSlop.yml +13 -0
- package/.bkit/templates/.vale/styles/House/Verbose.yml +12 -0
- package/.bkit/templates/.vale.ini +67 -0
- package/.bkit/templates/LICENSE.md +22 -0
- package/.bkit/templates/context/bkit-cloudrun.md +84 -0
- package/.bkit/templates/context/bkit-expo.md +186 -0
- package/.bkit/templates/context/bkit-github.md +79 -0
- package/.bkit/templates/context/bkit-inngest.md +45 -0
- package/.bkit/templates/context/bkit-maestro.md +76 -0
- package/.bkit/templates/context/bkit-playwright.md +62 -0
- package/.bkit/templates/context/bkit-resend.md +36 -0
- package/.bkit/templates/context/bkit-sentry.md +65 -0
- package/.bkit/templates/context/bkit-serena.md +33 -0
- package/.bkit/templates/context/bkit-stripe.md +36 -0
- package/.bkit/templates/context/bkit-supabase.md +59 -0
- package/.bkit/templates/context/bkit-tavily.md +49 -0
- package/.bkit/templates/context/bkit-vercel.md +64 -0
- package/.bkit/templates/docs/capabilities.md +72 -0
- package/.bkit/templates/scripts/ci/accepted-divergences.json +21 -0
- package/.bkit/templates/scripts/ci/check-accepted-divergences.mjs +152 -0
- package/.bkit/templates/scripts/ci/check-accepted-divergences.test.mjs +130 -0
- package/.bkit/templates/scripts/ci/lanes/resolve-push-base.mjs +98 -0
- package/.bkit/templates/scripts/ci/lanes/resolve-push-base.test.mjs +86 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-drift-rules.json +23 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-drift.py +208 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-eager-rules.json +35 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-eager.py +236 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-external-rules.json +17 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-imports.py +290 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +19 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-repair.py +120 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-surface.py +232 -0
- package/.bkit/templates/scripts/graphify/bkit-graphify-graphml.py +36 -0
- package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +927 -0
- package/.bkit/templates/scripts/graphify/bkit-graphify.sh +351 -0
- package/.bkit/templates/scripts/launchd/ai.bkit.launchd.plist +26 -0
- package/.bkit/templates/scripts/launchd/bkit-launchd-env.sh +53 -0
- package/.bkit/templates/scripts/launchd/launchd.env.example +13 -0
- package/.bkit/templates/scripts/prettier/bkit-insert-ignore.mjs +275 -0
- package/.bkit/templates/scripts/secrets/bkit-secrets.config.mjs +66 -0
- package/.bkit/templates/scripts/secrets/bkit-secrets.mjs +785 -0
- package/.bkit/templates/scripts/serena/bkit-serena-mcp.sh +30 -0
- package/.bkit/templates/scripts/serena/bkit-serena.mcp.json +9 -0
- package/.bkit/templates/scripts/slop/bkit-slop-type-suppression.mjs +286 -0
- package/.bkit/templates/slop-scan.config.json +120 -0
- package/CHANGELOG.md +1486 -0
- package/LICENSE.md +161 -0
- package/README.md +185 -2
- package/dist/checks/after/auth.js +232 -0
- package/dist/checks/after/ci-yml.js +718 -0
- package/dist/checks/after/github.js +400 -0
- package/dist/checks/after/index.js +447 -0
- package/dist/checks/after/managed.js +187 -0
- package/dist/checks/after/tools.js +351 -0
- package/dist/checks/after/vercel.js +102 -0
- package/dist/checks/before/context-fetch.js +426 -0
- package/dist/checks/before/env.js +173 -0
- package/dist/checks/before/files.js +185 -0
- package/dist/checks/before/index.js +162 -0
- package/dist/checks/before/mcp.js +111 -0
- package/dist/checks/before/repo.js +71 -0
- package/dist/checks/before/version.js +60 -0
- package/dist/checks/status-holes.js +393 -0
- package/dist/cli.js +692 -0
- package/dist/commands/analysis.js +325 -0
- package/dist/commands/ci/ci.js +438 -0
- package/dist/commands/comply.js +310 -0
- package/dist/commands/harvest.js +354 -0
- package/dist/commands/install/check.js +61 -0
- package/dist/commands/install/doctor.js +207 -0
- package/dist/commands/install/install.js +461 -0
- package/dist/commands/install/uninstall.js +815 -0
- package/dist/commands/install/upgrade.js +771 -0
- package/dist/commands/launch.js +118 -0
- package/dist/commands/lib.js +362 -0
- package/dist/commands/registry.js +50 -0
- package/dist/commands/setup/setup.js +158 -0
- package/dist/commands/telemetry.js +29 -0
- package/dist/commands/workflow/branches.js +1265 -0
- package/dist/commands/workflow/context.js +846 -0
- package/dist/commands/workflow/counters.js +227 -0
- package/dist/commands/workflow/fids.js +224 -0
- package/dist/commands/workflow/issues.js +585 -0
- package/dist/commands/workflow/ledgers.js +472 -0
- package/dist/commands/workflow/locks.js +364 -0
- package/dist/commands/workflow/prs.js +904 -0
- package/dist/commands/workflow/repo.js +199 -0
- package/dist/commands/workflow/roadmap.js +495 -0
- package/dist/commands/workflow/runs.js +1717 -0
- package/dist/commands/workflow/runtime.js +257 -0
- package/dist/commands/workflow/skills.js +110 -0
- package/dist/commands/workflow/status.js +392 -0
- package/dist/commands/workflow/steps.js +1093 -0
- package/dist/commands/workflow/tests.js +144 -0
- package/dist/commands/workflow/workflows.js +1342 -0
- package/dist/commands/workflow/workstreams.js +141 -0
- package/dist/commands/workflow/worktrees.js +473 -0
- package/dist/install/cloud-env.js +819 -0
- package/dist/install/managed-block.js +182 -0
- package/dist/install/manifest.js +376 -0
- package/dist/install/modules/claude.js +288 -0
- package/dist/install/modules/cloud.js +152 -0
- package/dist/install/modules/codex.js +193 -0
- package/dist/install/modules/core.js +511 -0
- package/dist/install/modules/cursor.js +186 -0
- package/dist/install/modules/index.js +152 -0
- package/dist/install/modules/opencode.js +504 -0
- package/dist/install/placeholders.js +87 -0
- package/dist/install/template-copies.js +106 -0
- package/dist/install/version-file.js +204 -0
- package/dist/install/write.js +342 -0
- package/dist/ledgers/clamp-log.js +27 -0
- package/dist/ledgers/status.js +156 -0
- package/dist/ledgers/telemetry.js +637 -0
- package/dist/render/hosts.js +339 -0
- package/dist/render/models.js +288 -0
- package/dist/render/parts.js +33 -0
- package/dist/render/trackers.js +135 -0
- package/dist/shared/egress.js +299 -0
- package/dist/shared/json.js +16 -0
- package/dist/shared/log-prefix.js +7 -0
- package/dist/shared/package-json.js +22 -0
- package/dist/shared/package-manager.js +32 -0
- package/dist/shared/package-roots.js +145 -0
- package/dist/shared/protected-paths.js +153 -0
- package/dist/shared/settings.js +44 -0
- package/dist/shared/timeouts.js +19 -0
- package/dist/tools/wording.js +680 -0
- package/package.json +101 -4
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
// install/modules/cursor.ts — the cursor host module: `.cursor/` agents, commands and config.
|
|
2
|
+
|
|
3
|
+
import * as fs from "node:fs";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
import { writeTier2, writeTier2JsonContained, ensureDir } from "../write.js";
|
|
6
|
+
import { stampManagedVersion } from "../version-file.js";
|
|
7
|
+
import { applyT1, applyT2, applyT3 } from "../../render/hosts.js";
|
|
8
|
+
import {
|
|
9
|
+
getCoreRoot,
|
|
10
|
+
getSharedRoot,
|
|
11
|
+
getWorkflowsRoot,
|
|
12
|
+
getPromptsRoot,
|
|
13
|
+
} from "../../shared/package-roots.js";
|
|
14
|
+
import { DEFAULT_ISSUE_TRACKER } from "../manifest.js";
|
|
15
|
+
import { substituteWorkflow } from "../../render/trackers.js";
|
|
16
|
+
import {
|
|
17
|
+
writeCursorCloudDoc,
|
|
18
|
+
writeNetworkAllowlistArtifact,
|
|
19
|
+
writeCursorCliPermissionsArtifact,
|
|
20
|
+
} from "../cloud-env.js";
|
|
21
|
+
import type { ModuleContext } from "./index.js";
|
|
22
|
+
import {
|
|
23
|
+
BKIT_PREFIX,
|
|
24
|
+
installFile,
|
|
25
|
+
listMdFiles,
|
|
26
|
+
readInstallingVersion,
|
|
27
|
+
removeOrphans,
|
|
28
|
+
trackMirrorWrite,
|
|
29
|
+
} from "./core.js";
|
|
30
|
+
import { reconcileMcpJson } from "./claude.js";
|
|
31
|
+
|
|
32
|
+
export function renderCursorAgentsCommands(ctx: ModuleContext): string[] {
|
|
33
|
+
const { dryRun, modelLookup, effortMap, logPrefix } = ctx;
|
|
34
|
+
const tag = dryRun ? "[dry-run] " : "";
|
|
35
|
+
const issueTracker = ctx.issueTracker ?? DEFAULT_ISSUE_TRACKER;
|
|
36
|
+
const version = ctx.version ?? readInstallingVersion();
|
|
37
|
+
const written: string[] = [];
|
|
38
|
+
|
|
39
|
+
// Commands: tracker block resolution → T1 → T2 → managed-version stamp (last)
|
|
40
|
+
{
|
|
41
|
+
const src = getWorkflowsRoot();
|
|
42
|
+
const dest = ".cursor/commands";
|
|
43
|
+
ensureDir(dest);
|
|
44
|
+
const files = listMdFiles(src, BKIT_PREFIX);
|
|
45
|
+
const sourceSet = new Set(files);
|
|
46
|
+
|
|
47
|
+
for (const f of files) {
|
|
48
|
+
const transform = (c: string) =>
|
|
49
|
+
stampManagedVersion(applyT2(applyT1(substituteWorkflow(c, issueTracker).output)), version);
|
|
50
|
+
if (installFile(path.join(src, f), path.join(dest, f), transform, dryRun)) {
|
|
51
|
+
const rel = path.join(dest, f);
|
|
52
|
+
console.log(`${logPrefix} ${tag}write: ${rel}`);
|
|
53
|
+
trackMirrorWrite(ctx, rel, written);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
for (const f of removeOrphans(dest, sourceSet, dryRun, BKIT_PREFIX)) {
|
|
58
|
+
const rel = path.join(dest, f);
|
|
59
|
+
console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
|
|
60
|
+
trackMirrorWrite(ctx, rel, written);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Agents: tracker block resolution → T3
|
|
65
|
+
{
|
|
66
|
+
const src = getPromptsRoot();
|
|
67
|
+
const dest = ".cursor/agents";
|
|
68
|
+
ensureDir(dest);
|
|
69
|
+
const files = listMdFiles(src, BKIT_PREFIX);
|
|
70
|
+
const sourceSet = new Set(files);
|
|
71
|
+
|
|
72
|
+
for (const f of files) {
|
|
73
|
+
const transform = (c: string) =>
|
|
74
|
+
stampManagedVersion(
|
|
75
|
+
applyT3(substituteWorkflow(c, issueTracker).output, modelLookup, effortMap),
|
|
76
|
+
version,
|
|
77
|
+
);
|
|
78
|
+
if (installFile(path.join(src, f), path.join(dest, f), transform, dryRun)) {
|
|
79
|
+
const rel = path.join(dest, f);
|
|
80
|
+
console.log(`${logPrefix} ${tag}write: ${rel}`);
|
|
81
|
+
trackMirrorWrite(ctx, rel, written);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
for (const f of removeOrphans(dest, sourceSet, dryRun, BKIT_PREFIX)) {
|
|
86
|
+
const rel = path.join(dest, f);
|
|
87
|
+
console.log(`${logPrefix} ${tag}delete orphan: ${rel}`);
|
|
88
|
+
trackMirrorWrite(ctx, rel, written);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return written;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ---------------------------------------------------------------------------
|
|
95
|
+
// runCursorModule — T1/T2/T3 transforms from .agents/ → .cursor/
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
|
|
98
|
+
export function runCursorModule(ctx: ModuleContext): void {
|
|
99
|
+
const { dryRun, tokens, advisories, ws, logPrefix } = ctx;
|
|
100
|
+
const tag = dryRun ? "[dry-run] " : "";
|
|
101
|
+
|
|
102
|
+
const issueTracker = ctx.issueTracker ?? DEFAULT_ISSUE_TRACKER;
|
|
103
|
+
|
|
104
|
+
// Source-rendered agents/commands (.cursor/agents T3 from .bkit/prompts, .cursor/commands
|
|
105
|
+
// T1/T2 from .bkit/workflows). Extracted to renderCursorAgentsCommands so `bkit upgrade`
|
|
106
|
+
// re-renders them identically — bkit-owned output, force-overwritten.
|
|
107
|
+
renderCursorAgentsCommands(ctx);
|
|
108
|
+
|
|
109
|
+
// Tier 2 JSON (contained) — deep-containment: hooks.json
|
|
110
|
+
const cursorShared = path.join(getSharedRoot(), ".cursor");
|
|
111
|
+
const cursorHooks = path.join(getCoreRoot(), ".cursor", "hooks");
|
|
112
|
+
const hooksSrc = path.join(cursorShared, "hooks.json");
|
|
113
|
+
const hooksDst = ".cursor/hooks.json";
|
|
114
|
+
if (fs.existsSync(hooksSrc)) {
|
|
115
|
+
const prevLen = ws.writes.length;
|
|
116
|
+
writeTier2JsonContained(hooksSrc, hooksDst, dryRun, ws);
|
|
117
|
+
if (ws.writes.length > prevLen) {
|
|
118
|
+
console.log(`${logPrefix} ${tag}cursor: ${hooksDst}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Markered-text — manifest format: "markered-text" — preflight hook + shared rules.
|
|
123
|
+
// All use html-comment markers (# <!-- bkit:start --> / # <!-- bkit:end -->).
|
|
124
|
+
// Uses writeTier2 to update only the bkit-managed block; consumer content outside
|
|
125
|
+
// markers is preserved. `.cursor/Dockerfile` is a template (`.bkit/templates.md`).
|
|
126
|
+
{
|
|
127
|
+
const markeredFiles: Array<[string, string]> = [
|
|
128
|
+
[path.join(cursorHooks, "bkit-preflight.sh"), ".cursor/hooks/bkit-preflight.sh"],
|
|
129
|
+
[path.join(cursorShared, "rules", "bkit-rules.mdc"), ".cursor/rules/bkit-rules.mdc"],
|
|
130
|
+
];
|
|
131
|
+
for (const [src, dst] of markeredFiles) {
|
|
132
|
+
if (!fs.existsSync(src)) continue;
|
|
133
|
+
const prevLen = ws.writes.length;
|
|
134
|
+
writeTier2(src, dst, tokens, "html-comment", dryRun, ws);
|
|
135
|
+
if (ws.writes.length > prevLen) {
|
|
136
|
+
console.log(`${logPrefix} ${tag}cursor: ${dst}`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// markered-text (slash-comment) — Cursor destructive-op / secret-exposure guardrails
|
|
142
|
+
// (parity with Claude permissions deny/ask and OpenCode permission map). bkit owns
|
|
143
|
+
// only the decision engine between the markers; consumers own the stdin/stdout driver
|
|
144
|
+
// from first install onward, same split as the two GateGuard hooks.
|
|
145
|
+
{
|
|
146
|
+
const src = path.join(cursorHooks, "bkit-guardrails.cjs");
|
|
147
|
+
const dst = ".cursor/hooks/bkit-guardrails.cjs";
|
|
148
|
+
if (fs.existsSync(src)) {
|
|
149
|
+
const prevLen = ws.writes.length;
|
|
150
|
+
writeTier2(src, dst, tokens, "slash-comment", dryRun, ws);
|
|
151
|
+
if (ws.writes.length > prevLen) {
|
|
152
|
+
console.log(`${logPrefix} ${tag}cursor: ${dst}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// markered-text (slash-comment) — GateGuard advisory PreToolUse hook for Cursor.
|
|
158
|
+
// Same managed block as the Claude twin; the driver outside it adapts Cursor's
|
|
159
|
+
// payload (relative file_path, no subagent marker) and emits Cursor's shape.
|
|
160
|
+
{
|
|
161
|
+
const src = path.join(cursorHooks, "bkit-gateguard.cjs");
|
|
162
|
+
const dst = ".cursor/hooks/bkit-gateguard.cjs";
|
|
163
|
+
if (fs.existsSync(src)) {
|
|
164
|
+
const prevLen = ws.writes.length;
|
|
165
|
+
writeTier2(src, dst, tokens, "slash-comment", dryRun, ws);
|
|
166
|
+
if (ws.writes.length > prevLen) {
|
|
167
|
+
console.log(`${logPrefix} ${tag}cursor: ${dst}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// .cursor/mcp.json — same per-entry ownership as .mcp.json (reconcileMcpJson).
|
|
173
|
+
{
|
|
174
|
+
const cursorMcpSrc = path.join(cursorShared, "mcp.json");
|
|
175
|
+
const cursorMcpDst = path.join(".cursor", "mcp.json");
|
|
176
|
+
if (fs.existsSync(cursorMcpSrc)) {
|
|
177
|
+
const prevLen = ws.writes.length;
|
|
178
|
+
reconcileMcpJson(cursorMcpSrc, cursorMcpDst, issueTracker, dryRun, ws);
|
|
179
|
+
if (ws.writes.length > prevLen) {
|
|
180
|
+
console.log(`${logPrefix} ${tag}cursor: ${cursorMcpDst}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Cursor-only runtime curl/wget allowlist (bkit-guardrails.cjs reads `.cursor/allowlist.json`).
|
|
186
|
+
// Same domain set as Claude WebFetch / OpenCode bash allows — sourced from tooling
|
|
187
|
+
// defaults ∪ consumer `allowed-domains`. Not under `.bkit/` (IDE-scoped artifact).
|
|
188
|
+
// Cursor CLI / cloud-agent MCP allows (`.cursor/cli.json`) from consumer `mcp-servers` —
|
|
189
|
+
// same server set as Claude `mcp__…` allows / OpenCode `<server>_*` permission rows.
|
|
190
|
+
for (const art of [
|
|
191
|
+
writeNetworkAllowlistArtifact(process.cwd(), dryRun),
|
|
192
|
+
writeCursorCliPermissionsArtifact(process.cwd(), dryRun),
|
|
193
|
+
]) {
|
|
194
|
+
if (art.wrote) {
|
|
195
|
+
ws.writes.push({ path: art.path, action: "write" });
|
|
196
|
+
console.log(`${logPrefix} ${tag}cursor: ${art.path}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Post-install advisory: macOS GUI-isolation note.
|
|
201
|
+
// MCP token placeholders (${BKIT_GH_TOKEN}, ${BKIT_LINEAR_API_KEY}, …) in .cursor/mcp.json are
|
|
202
|
+
// expanded by Cursor from the process environment. When Cursor is launched from the
|
|
203
|
+
// Dock/Finder (launchd), it does NOT inherit the login-shell / direnv env — tokens
|
|
204
|
+
// resolve empty and MCP calls fail with auth errors.
|
|
205
|
+
advisories.push({
|
|
206
|
+
id: "cursor-gui-isolation",
|
|
207
|
+
severity: "advisory",
|
|
208
|
+
detect:
|
|
209
|
+
"Cursor's MCP token placeholders (${BKIT_GH_TOKEN}, …) resolve from process.env. " +
|
|
210
|
+
"Dock/Finder-launched Cursor does not inherit the login-shell / direnv env.",
|
|
211
|
+
action:
|
|
212
|
+
"[cursor] Use `bkit cursor` to launch Cursor — it execs the binary directly with " +
|
|
213
|
+
".bkit/.env merged into the environment so MCP tokens resolve correctly. " +
|
|
214
|
+
"Quit Cursor first (a running instance will not see the new env). " +
|
|
215
|
+
'Alternative: `launchctl setenv BKIT_GH_TOKEN "$BKIT_GH_TOKEN"` (session-scoped; must re-run after reboot) ' +
|
|
216
|
+
"then relaunch from Dock.",
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// Generated copy-paste-ready Cursor Background Agents setup doc — `.cursor/bkit-cloud.md`.
|
|
220
|
+
// Twin of `.claude/bkit-cloud.md` (runClaudeModule): UNTRACKED + gitignored, inlines REAL
|
|
221
|
+
// secret values resolved from `.envrc` under the Cursor env-var policy (Linear tracker
|
|
222
|
+
// adds BKIT_LINEAR_API_KEY, no autocompact knob). Never enters ws.writes / canonicalHashes /
|
|
223
|
+
// `bkit check` drift — values are machine-local and expected to differ. Skipped on
|
|
224
|
+
// dry-run (`bkit check`) so a read-only check never writes secrets. Upgrade regenerates
|
|
225
|
+
// it via the same helper (see runUpgrade caller).
|
|
226
|
+
if (!dryRun && writeCursorCloudDoc(process.cwd(), tokens, issueTracker)) {
|
|
227
|
+
console.log(
|
|
228
|
+
`${logPrefix} ${tag}cursor: .cursor/bkit-cloud.md (generated — gitignored, holds resolved secrets)`,
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
// install/modules/index.ts — Module registry and per-module install functions.
|
|
2
|
+
// Each module function receives { dryRun, tokens, modelLookup, advisories, ws, … } (ModuleContext)
|
|
3
|
+
// and emits writes into the shared WriteSet.
|
|
4
|
+
//
|
|
5
|
+
// Dispatch order: core → claude → cursor → opencode → codex → cloud
|
|
6
|
+
// .bkit/version is written LAST — in postDispatch after ALL modules complete (MED-4).
|
|
7
|
+
|
|
8
|
+
import * as fs from "node:fs";
|
|
9
|
+
import * as path from "node:path";
|
|
10
|
+
import type { WriteSet } from "../write.js";
|
|
11
|
+
import type { TokenMap } from "../placeholders.js";
|
|
12
|
+
import type { ModuleFlag, CloudVariant } from "../../cli.js";
|
|
13
|
+
import type { EffortMap } from "../../render/models.js";
|
|
14
|
+
import type { PreflightFinding } from "../../checks/before/index.js";
|
|
15
|
+
import { getCoreRoot, getSharedRoot } from "../../shared/package-roots.js";
|
|
16
|
+
import { getInstallManifest, type IssueTracker } from "../manifest.js";
|
|
17
|
+
import {
|
|
18
|
+
BKIT_PREFIX,
|
|
19
|
+
listCoreTemplateFiles,
|
|
20
|
+
listSharedTemplateFiles,
|
|
21
|
+
runBkitDocs,
|
|
22
|
+
runCoreModule,
|
|
23
|
+
seedCorePackageJsonScripts,
|
|
24
|
+
} from "./core.js";
|
|
25
|
+
import { renderClaudeAgentsCommands, runClaudeModule } from "./claude.js";
|
|
26
|
+
import { renderCursorAgentsCommands, runCursorModule } from "./cursor.js";
|
|
27
|
+
import { renderOpencodeAgentsCommands, runOpencodeModule } from "./opencode.js";
|
|
28
|
+
import { CODEX_SKILLS_DIR, renderCodexAgentsSkills, runCodexModule } from "./codex.js";
|
|
29
|
+
import { runCloudModule } from "./cloud.js";
|
|
30
|
+
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Module context
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
export interface ModuleContext {
|
|
36
|
+
dryRun: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Set by runClaudeModule to what enrichClaudeSettingsAllows actually recorded, so
|
|
39
|
+
* core's postDispatch can persist it into `.bkit/version`. `null` or absent means
|
|
40
|
+
* "not determined this run" — the prior record is carried forward, never cleared.
|
|
41
|
+
* Enrich itself never writes `.bkit/version`; there is one writer.
|
|
42
|
+
*/
|
|
43
|
+
claudeAllowRecorded?: readonly string[] | null;
|
|
44
|
+
tokens: TokenMap;
|
|
45
|
+
modelLookup: Map<string, string>;
|
|
46
|
+
/**
|
|
47
|
+
* opencode model lookup for the opencode module, separate from modelLookup (consumed by
|
|
48
|
+
* runCursorModule). Populated only when --opencode is in the module set. Empty map when
|
|
49
|
+
* absent.
|
|
50
|
+
*/
|
|
51
|
+
opencodeModelLookup: Map<string, string>;
|
|
52
|
+
/**
|
|
53
|
+
* name -> BARE § Models `OpenAI` cell, for `.codex/agents/*.toml`. Separate from
|
|
54
|
+
* opencodeModelLookup because they read different gateway columns.
|
|
55
|
+
*/
|
|
56
|
+
codexModelLookup?: Map<string, string>;
|
|
57
|
+
/**
|
|
58
|
+
* Effort → provider thinking map from prompts.md (Default | Claude | Cursor | …).
|
|
59
|
+
* Shared by Claude / Cursor / opencode transforms. Empty map when prompts.md absent.
|
|
60
|
+
*/
|
|
61
|
+
effortMap: EffortMap;
|
|
62
|
+
/**
|
|
63
|
+
* opencode provider chosen via `--opencode=<provider>`. null = not specified.
|
|
64
|
+
* Used by runOpencodeModule to seed the provider block in opencode.json.
|
|
65
|
+
*/
|
|
66
|
+
opencodeProvider?: string | null;
|
|
67
|
+
/** Structured advisory accumulator. */
|
|
68
|
+
advisories: PreflightFinding[];
|
|
69
|
+
ws: WriteSet;
|
|
70
|
+
logPrefix: string;
|
|
71
|
+
/**
|
|
72
|
+
* Deferred callbacks executed by dispatchModules AFTER all modules complete.
|
|
73
|
+
* Use for finalisation work that must run only when the full dispatch succeeds
|
|
74
|
+
* (e.g. writing .bkit/version after all modules return cleanly).
|
|
75
|
+
*/
|
|
76
|
+
postDispatch: Array<() => void>;
|
|
77
|
+
/** Issue tracker for workflow mirror substitution. Default: "none". */
|
|
78
|
+
issueTracker: IssueTracker;
|
|
79
|
+
/**
|
|
80
|
+
* Cloud variant chosen via `--auto=claude|cursor`. null = not specified (cloud module
|
|
81
|
+
* not being installed). Used by `runCloudModule` to dispatch the correct variant.
|
|
82
|
+
*/
|
|
83
|
+
cloudVariant?: CloudVariant | null;
|
|
84
|
+
/**
|
|
85
|
+
* Installing bkit version (package.json `version`) stamped into every rendered agent +
|
|
86
|
+
* command as a managed-version marker. Optional: when absent the render functions fall
|
|
87
|
+
* back to reading the package root directly (readInstallingVersion); production
|
|
88
|
+
* install/upgrade set it explicitly.
|
|
89
|
+
*/
|
|
90
|
+
version?: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export type ModuleFn = (ctx: ModuleContext) => void;
|
|
94
|
+
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
// renderManagedOutputs — re-render the bkit-managed OUTPUT files that the
|
|
97
|
+
// `bkit upgrade` payload walk does NOT cover:
|
|
98
|
+
// host agents/commands (source-rendered), the `.bkit/*.md` canonical docs
|
|
99
|
+
// (runBkitDocs) and core's package.json scripts (seedCorePackageJsonScripts).
|
|
100
|
+
// `.bkit/prompts.md` is markered → runBkitDocs block-merges it (managed block
|
|
101
|
+
// refreshed, consumer `## Model Overrides` below bkit:end preserved).
|
|
102
|
+
//
|
|
103
|
+
// CRITICAL: docs stay single-source PACKAGE-side and are mirrored from
|
|
104
|
+
// getBkitDocsRoot() — they are NEVER relocated into the payload folders.
|
|
105
|
+
//
|
|
106
|
+
// Doc writes land in ctx.ws (runBkitDocs uses the tier writers) so the caller can
|
|
107
|
+
// refresh their canonicalHashes. Agent/command mirrors also push to ws.writes on
|
|
108
|
+
// would-write so `bkit check` exits 1 on content drift (not only managed-version
|
|
109
|
+
// marker stale). They are still re-rendered from source (not the template walk).
|
|
110
|
+
// `modules` should contain only hosts the consumer actually has installed.
|
|
111
|
+
// Returns every consumer-relative path written (for the upgrade summary).
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
113
|
+
|
|
114
|
+
export function renderManagedOutputs(modules: Set<ModuleFlag>, ctx: ModuleContext): string[] {
|
|
115
|
+
const written: string[] = [];
|
|
116
|
+
|
|
117
|
+
// Canonical .bkit/*.md docs — always (core is always present once installed).
|
|
118
|
+
const docsBefore = ctx.ws.writes.length;
|
|
119
|
+
runBkitDocs(ctx.dryRun, ctx.tokens, ctx.ws, ctx.logPrefix);
|
|
120
|
+
for (let i = docsBefore; i < ctx.ws.writes.length; i++) {
|
|
121
|
+
written.push(String(ctx.ws.writes[i].path));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Core package.json scripts — the same pass install runs, so `bkit check` after a
|
|
125
|
+
// clean upgrade finds no missing gate name and no superseded script value.
|
|
126
|
+
written.push(...seedCorePackageJsonScripts(ctx));
|
|
127
|
+
|
|
128
|
+
// Host agents/commands — only for hosts the consumer has installed.
|
|
129
|
+
if (modules.has("claude")) written.push(...renderClaudeAgentsCommands(ctx));
|
|
130
|
+
if (modules.has("cursor")) written.push(...renderCursorAgentsCommands(ctx));
|
|
131
|
+
if (modules.has("opencode")) written.push(...renderOpencodeAgentsCommands(ctx));
|
|
132
|
+
if (modules.has("codex")) written.push(...renderCodexAgentsSkills(ctx));
|
|
133
|
+
|
|
134
|
+
return written;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// ---------------------------------------------------------------------------
|
|
138
|
+
// listStampedFiles — every file bkit writes that carries the managed-version marker
|
|
139
|
+
// ---------------------------------------------------------------------------
|
|
140
|
+
|
|
141
|
+
/** A file bkit writes into the consumer repo carrying the managed-version marker. */
|
|
142
|
+
export interface StampedFile {
|
|
143
|
+
/** Consumer-relative path. */
|
|
144
|
+
path: string;
|
|
145
|
+
/** `block`: the marker is the first line of the file's bkit block. `whole`: bkit owns the file. */
|
|
146
|
+
scope: "block" | "whole";
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Rendered mirror dirs: every `bkit-*` file of the given extension in each is bkit's. */
|
|
150
|
+
const RENDERED_MIRRORS: ReadonlyArray<[dir: string, ext: string]> = [
|
|
151
|
+
[".claude/agents", ".md"],
|
|
152
|
+
[".claude/commands", ".md"],
|
|
153
|
+
[".cursor/agents", ".md"],
|
|
154
|
+
[".cursor/commands", ".md"],
|
|
155
|
+
[".opencode/agents", ".md"],
|
|
156
|
+
[".opencode/commands", ".md"],
|
|
157
|
+
[".codex/agents", ".toml"],
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Every file bkit writes into `cwd` that carries the managed-version marker: the core
|
|
162
|
+
* payload (listCoreTemplateFiles), the non-JSON non-generated manifest entries of every
|
|
163
|
+
* module, and the rendered mirrors present on disk (agents, commands, the codex workflow
|
|
164
|
+
* skills). JSON files carry none. Paths only; whether each exists is the caller's to
|
|
165
|
+
* check.
|
|
166
|
+
*/
|
|
167
|
+
export function listStampedFiles(cwd: string): StampedFile[] {
|
|
168
|
+
const byPath = new Map<string, StampedFile>();
|
|
169
|
+
const add = (p: string, scope: StampedFile["scope"]): void => {
|
|
170
|
+
const rel = path.normalize(p);
|
|
171
|
+
if (!byPath.has(rel)) byPath.set(rel, { path: rel, scope });
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
for (const { dst, scope } of listCoreTemplateFiles(getCoreRoot())) add(dst, scope);
|
|
175
|
+
for (const { dst, scope } of listSharedTemplateFiles(getSharedRoot())) add(dst, scope);
|
|
176
|
+
|
|
177
|
+
for (const entry of getInstallManifest()) {
|
|
178
|
+
if (entry.format === "json" || entry.generated) continue;
|
|
179
|
+
if (entry.path === path.join(".bkit", "version")) continue;
|
|
180
|
+
add(entry.path, entry.format === "markered-text" ? "block" : "whole");
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
for (const [dir, ext] of RENDERED_MIRRORS) {
|
|
184
|
+
const abs = path.join(cwd, dir);
|
|
185
|
+
if (!fs.existsSync(abs)) continue;
|
|
186
|
+
for (const f of fs.readdirSync(abs)) {
|
|
187
|
+
if (f.startsWith(BKIT_PREFIX) && f.endsWith(ext)) add(path.join(dir, f), "whole");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const skills = path.join(cwd, CODEX_SKILLS_DIR);
|
|
191
|
+
if (fs.existsSync(skills)) {
|
|
192
|
+
for (const d of fs.readdirSync(skills)) {
|
|
193
|
+
if (!d.startsWith(BKIT_PREFIX)) continue;
|
|
194
|
+
if (fs.existsSync(path.join(skills, d, "SKILL.md"))) {
|
|
195
|
+
add(path.join(CODEX_SKILLS_DIR, d, "SKILL.md"), "whole");
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return [...byPath.values()];
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// ---------------------------------------------------------------------------
|
|
203
|
+
// MODULE_REGISTRY — maps ModuleFlag → ModuleFn
|
|
204
|
+
// ---------------------------------------------------------------------------
|
|
205
|
+
|
|
206
|
+
export const MODULE_REGISTRY: Partial<Record<ModuleFlag, ModuleFn>> = {
|
|
207
|
+
core: runCoreModule,
|
|
208
|
+
claude: runClaudeModule,
|
|
209
|
+
cursor: runCursorModule,
|
|
210
|
+
opencode: runOpencodeModule,
|
|
211
|
+
codex: runCodexModule,
|
|
212
|
+
cloud: runCloudModule,
|
|
213
|
+
// "full" is never directly in the registry — resolveModules expands it to all modules
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
// Canonical dispatch order
|
|
217
|
+
export const MODULE_DISPATCH_ORDER: ModuleFlag[] = [
|
|
218
|
+
"core",
|
|
219
|
+
"claude",
|
|
220
|
+
"cursor",
|
|
221
|
+
"opencode",
|
|
222
|
+
"codex",
|
|
223
|
+
"cloud",
|
|
224
|
+
];
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Dispatch modules in canonical order.
|
|
228
|
+
* ctx.ws is populated by each module fn; ctx.advisories accumulates findings flushed by caller.
|
|
229
|
+
* After all modules complete, ctx.postDispatch callbacks are run in order.
|
|
230
|
+
*/
|
|
231
|
+
export function dispatchModules(modules: Set<ModuleFlag>, ctx: ModuleContext): void {
|
|
232
|
+
for (const flag of MODULE_DISPATCH_ORDER) {
|
|
233
|
+
if (!modules.has(flag)) continue;
|
|
234
|
+
const fn = MODULE_REGISTRY[flag];
|
|
235
|
+
if (!fn) continue;
|
|
236
|
+
fn(ctx);
|
|
237
|
+
}
|
|
238
|
+
// Run deferred finalisation callbacks (e.g. .bkit/version write) only after all modules succeed.
|
|
239
|
+
for (const cb of ctx.postDispatch) {
|
|
240
|
+
cb();
|
|
241
|
+
}
|
|
242
|
+
}
|