@cbartens/bkit 0.0.0-stage → 5.0.1
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 +417 -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 +417 -0
- package/.bkit/core/.bkit/cloud.md +493 -0
- package/.bkit/core/.bkit/comparison.md +321 -0
- package/.bkit/core/.bkit/install.md +401 -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 +470 -0
- package/.bkit/core/.bkit/trackers.md +95 -0
- package/.bkit/core/.bkit/workflows.md +1550 -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 +149 -0
- package/.bkit/core/engine/checks/after/ci-yml.ts +701 -0
- package/.bkit/core/engine/checks/after/github.ts +424 -0
- package/.bkit/core/engine/checks/after/index.ts +530 -0
- package/.bkit/core/engine/checks/after/managed.ts +217 -0
- package/.bkit/core/engine/checks/after/suppression.ts +53 -0
- package/.bkit/core/engine/checks/after/tools.ts +427 -0
- package/.bkit/core/engine/checks/before/context-fetch.ts +429 -0
- package/.bkit/core/engine/checks/before/env.ts +187 -0
- package/.bkit/core/engine/checks/before/files.ts +204 -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 +867 -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 +254 -0
- package/.bkit/core/engine/commands/install/install.ts +550 -0
- package/.bkit/core/engine/commands/install/uninstall.ts +995 -0
- package/.bkit/core/engine/commands/install/upgrade.ts +1037 -0
- package/.bkit/core/engine/commands/launch.ts +139 -0
- package/.bkit/core/engine/commands/lib.ts +495 -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 +924 -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 +173 -0
- package/.bkit/core/engine/install/modules/codex.ts +219 -0
- package/.bkit/core/engine/install/modules/core.ts +620 -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/payload-links.ts +150 -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 +649 -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 +86 -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 +433 -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 +97 -0
- package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +187 -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 +224 -0
- package/.bkit/templates/.github/workflows/bkit-ci.yml +1062 -0
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +564 -0
- package/.bkit/templates/.github/workflows/bkit-renovate.yml +102 -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 +1503 -0
- package/LICENSE.md +161 -0
- package/README.md +184 -2
- package/dist/checks/after/auth.js +140 -0
- package/dist/checks/after/ci-yml.js +681 -0
- package/dist/checks/after/github.js +400 -0
- package/dist/checks/after/index.js +431 -0
- package/dist/checks/after/managed.js +187 -0
- package/dist/checks/after/suppression.js +39 -0
- package/dist/checks/after/tools.js +351 -0
- package/dist/checks/before/context-fetch.js +426 -0
- package/dist/checks/before/env.js +163 -0
- package/dist/checks/before/files.js +187 -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 +688 -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 +209 -0
- package/dist/commands/install/install.js +475 -0
- package/dist/commands/install/uninstall.js +839 -0
- package/dist/commands/install/upgrade.js +782 -0
- package/dist/commands/launch.js +118 -0
- package/dist/commands/lib.js +363 -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 +818 -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 +151 -0
- package/dist/install/modules/codex.js +193 -0
- package/dist/install/modules/core.js +531 -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/payload-links.js +119 -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,118 @@
|
|
|
1
|
+
// commands/launch.ts — `bkit cursor` / `bkit opencode` launcher verbs.
|
|
2
|
+
//
|
|
3
|
+
// Resolves .bkit/.env in the current repo root, merges it over process.env,
|
|
4
|
+
// and exec's the GUI app binary directly so it inherits the per-repo token set.
|
|
5
|
+
//
|
|
6
|
+
// Not `open -a`: `open` routes through launchd, which drops the inherited env.
|
|
7
|
+
import * as fs from "node:fs";
|
|
8
|
+
import * as path from "node:path";
|
|
9
|
+
import { spawnSync, spawn } from "node:child_process";
|
|
10
|
+
import { parseDotenv } from "../install/cloud-env.js";
|
|
11
|
+
/**
|
|
12
|
+
* Default binary paths. Override via BKIT_CURSOR_BIN / BKIT_OPENCODE_BIN env vars.
|
|
13
|
+
*/
|
|
14
|
+
const DEFAULT_BINARY = {
|
|
15
|
+
cursor: "/Applications/Cursor.app/Contents/MacOS/Cursor",
|
|
16
|
+
opencode: "/Applications/opencode.app/Contents/MacOS/opencode",
|
|
17
|
+
};
|
|
18
|
+
const BINARY_OVERRIDE_ENV = {
|
|
19
|
+
cursor: "BKIT_CURSOR_BIN",
|
|
20
|
+
opencode: "BKIT_OPENCODE_BIN",
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Load .bkit/.env from `repoRoot`, merge into `baseEnv`, return merged env.
|
|
24
|
+
* baseEnv wins over file values for keys already set (process.env takes priority;
|
|
25
|
+
* .bkit/.env only fills gaps).
|
|
26
|
+
*/
|
|
27
|
+
export function loadBkitEnv(repoRoot, baseEnv) {
|
|
28
|
+
const envPath = path.join(repoRoot, ".bkit", ".env");
|
|
29
|
+
if (!fs.existsSync(envPath))
|
|
30
|
+
return { ...baseEnv };
|
|
31
|
+
const content = fs.readFileSync(envPath, "utf-8");
|
|
32
|
+
const fileVars = parseDotenv(content);
|
|
33
|
+
const merged = { ...baseEnv };
|
|
34
|
+
for (const [key, value] of fileVars) {
|
|
35
|
+
// process.env wins — only inject if key absent or empty in current env
|
|
36
|
+
const existing = baseEnv[key];
|
|
37
|
+
if (!existing || existing.trim() === "") {
|
|
38
|
+
merged[key] = value;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return merged;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Resolve the binary path for `app`:
|
|
45
|
+
* 1. Override env var (BKIT_CURSOR_BIN / BKIT_OPENCODE_BIN)
|
|
46
|
+
* 2. Default path
|
|
47
|
+
* Returns the path string if found, or null with a user-visible error message.
|
|
48
|
+
*/
|
|
49
|
+
export function resolveBinaryPath(app, env) {
|
|
50
|
+
const overrideKey = BINARY_OVERRIDE_ENV[app];
|
|
51
|
+
const override = env[overrideKey]?.trim();
|
|
52
|
+
const candidate = override || DEFAULT_BINARY[app];
|
|
53
|
+
if (!fs.existsSync(candidate)) {
|
|
54
|
+
const hint = override
|
|
55
|
+
? `(override via ${overrideKey}=${candidate})`
|
|
56
|
+
: `(default path — set ${overrideKey}=/path/to/binary to override)`;
|
|
57
|
+
return {
|
|
58
|
+
error: `[bkit] ${app} binary not found at ${candidate} ${hint}. Install ${app} first, then re-run.`,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return { binPath: candidate };
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Return true if a process matching `binaryPath` is already running.
|
|
65
|
+
* Uses `pgrep -f` which matches against the full command line.
|
|
66
|
+
* Returns false on non-POSIX systems (result.error set when pgrep is absent).
|
|
67
|
+
*/
|
|
68
|
+
export function isAlreadyRunning(binaryPath) {
|
|
69
|
+
const result = spawnSync("pgrep", ["-f", binaryPath], {
|
|
70
|
+
encoding: "utf-8",
|
|
71
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
72
|
+
});
|
|
73
|
+
return !result.error && result.status === 0 && result.stdout.trim().length > 0;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Launch `app` with .bkit/.env merged into its environment.
|
|
77
|
+
*
|
|
78
|
+
* - Loads `.bkit/.env` from `cwd` and merges into process.env (process.env wins).
|
|
79
|
+
* - Detects an already-running instance via pgrep; warns + exits non-zero if found
|
|
80
|
+
* (the running process will not inherit the new env even if the binary hands off).
|
|
81
|
+
* - For Cursor: passes `cwd` as a positional arg so it opens the repo folder.
|
|
82
|
+
* - Spawns detached so the terminal is not blocked by the GUI app.
|
|
83
|
+
*/
|
|
84
|
+
export async function launchApp(app, cwd) {
|
|
85
|
+
const env = loadBkitEnv(cwd, process.env);
|
|
86
|
+
const resolved = resolveBinaryPath(app, env);
|
|
87
|
+
if ("error" in resolved) {
|
|
88
|
+
console.error(resolved.error);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
const { binPath } = resolved;
|
|
92
|
+
if (isAlreadyRunning(binPath)) {
|
|
93
|
+
console.warn(`[bkit] ${app} is already running — opening folder in a new window, but the\n` +
|
|
94
|
+
`environment from .bkit/.env will NOT take effect (the running process keeps\n` +
|
|
95
|
+
`its original env). If you need per-repo tokens, quit ${app} fully (Cmd+Q)\n` +
|
|
96
|
+
`and re-run: pnpm bkit ${app}` +
|
|
97
|
+
(app === "opencode"
|
|
98
|
+
? `\n\n OpenCode 2.0 runs one shared background server for every client (TUI, web,\n` +
|
|
99
|
+
` desktop) and captures its environment once, at first start. A newly opened\n` +
|
|
100
|
+
` window talks to that server and still sees the OLD env, so the per-repo tokens\n` +
|
|
101
|
+
` in .bkit/.env are not picked up. Stop the shared server, then re-launch:\n` +
|
|
102
|
+
` opencode service stop && pnpm bkit opencode\n` +
|
|
103
|
+
` (that stops every opencode window, not just this one; quitting the app fully\n` +
|
|
104
|
+
` and re-running works too)`
|
|
105
|
+
: ""));
|
|
106
|
+
}
|
|
107
|
+
// Cursor: pass repo dir so it opens the folder. opencode: no positional needed
|
|
108
|
+
// (it reads opencode.json from cwd, and cwd is inherited via { cwd } spawn option).
|
|
109
|
+
const args = app === "cursor" ? [cwd] : [];
|
|
110
|
+
const child = spawn(binPath, args, {
|
|
111
|
+
env,
|
|
112
|
+
cwd,
|
|
113
|
+
detached: true,
|
|
114
|
+
stdio: "ignore",
|
|
115
|
+
});
|
|
116
|
+
child.unref();
|
|
117
|
+
console.log(`[bkit] Launched ${app} with environment from .bkit/.env`);
|
|
118
|
+
}
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
// commands/lib.ts — what every `bkit <noun> <verb>` command shares.
|
|
2
|
+
//
|
|
3
|
+
// Flag parsing, one JSON object on stdout, `[bkit-<noun>]`-tagged logs on stderr,
|
|
4
|
+
// the exit-code table, `--help` rendering, and the repo facts several workflow
|
|
5
|
+
// steps each re-derived by hand: repo root, UTC month, where `status.jsonl` lives,
|
|
6
|
+
// and the skip-CI tokens. A command declares its flags, output keys and exit codes
|
|
7
|
+
// in its spec; `--help` and the convention test both read that spec, so the help
|
|
8
|
+
// text cannot drift from what the command accepts.
|
|
9
|
+
import { spawnSync } from "node:child_process";
|
|
10
|
+
import * as fs from "node:fs";
|
|
11
|
+
import * as os from "node:os";
|
|
12
|
+
import * as path from "node:path";
|
|
13
|
+
import { gitEnv } from "../ledgers/telemetry.js";
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// Exit codes
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
/** Codes every command shares. A command's own codes sit in 3-79. */
|
|
18
|
+
export const EXIT = {
|
|
19
|
+
OK: 0,
|
|
20
|
+
/** The answer is "no": gate failed, max attempts exceeded, lock held. */
|
|
21
|
+
NO: 1,
|
|
22
|
+
/** Usage error or missing dependency. */
|
|
23
|
+
USAGE: 2,
|
|
24
|
+
/** Do this through the tracker / GitHub MCP instead (`gh` unavailable in this runtime). */
|
|
25
|
+
USE_MCP: 80,
|
|
26
|
+
/** Hand the wait back to the agent's turn loop. */
|
|
27
|
+
AGENT_WAIT: 81,
|
|
28
|
+
/** A human has to act. */
|
|
29
|
+
NEEDS_HUMAN: 82,
|
|
30
|
+
};
|
|
31
|
+
export const SHARED_EXIT_CODES = {
|
|
32
|
+
[EXIT.OK]: "ok",
|
|
33
|
+
[EXIT.NO]: "the answer is no (gate failed, max attempts exceeded, lock held)",
|
|
34
|
+
[EXIT.USAGE]: "usage error or missing dependency",
|
|
35
|
+
[EXIT.USE_MCP]: "do this through MCP instead (gh unavailable in this runtime)",
|
|
36
|
+
[EXIT.AGENT_WAIT]: "hand the wait back to the agent's turn loop",
|
|
37
|
+
[EXIT.NEEDS_HUMAN]: "needs a human",
|
|
38
|
+
};
|
|
39
|
+
/** Range a command's own exit codes must fall in. */
|
|
40
|
+
export const OWN_EXIT_MIN = 3;
|
|
41
|
+
export const OWN_EXIT_MAX = 79;
|
|
42
|
+
/** Thrown inside a command to exit with `code` and print `message` to stderr. */
|
|
43
|
+
export class CommandError extends Error {
|
|
44
|
+
code;
|
|
45
|
+
constructor(code, message) {
|
|
46
|
+
super(message);
|
|
47
|
+
this.code = code;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
// Flags
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
const camel = (kebab) => kebab.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
|
|
54
|
+
/** An orchestrator placeholder (`{FID}`, `{STATUS}`) the workflow should have substituted. */
|
|
55
|
+
const PLACEHOLDER = /\{[A-Z][A-Z0-9_]*\}/;
|
|
56
|
+
/** Refuse a flag value still carrying a literal `{UPPER}` placeholder. */
|
|
57
|
+
function refuseUnsubstituted(flag, value) {
|
|
58
|
+
const hit = PLACEHOLDER.exec(value);
|
|
59
|
+
if (hit) {
|
|
60
|
+
throw new CommandError(EXIT.USAGE, `--${flag} carries the unsubstituted placeholder ${hit[0]} — substitute it before running`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Parse `--flag=value` / `--flag value` / `--bool` against the verb's spec. Keys
|
|
65
|
+
* are filled in argv order, so a verb may render repeated or free-form flags in
|
|
66
|
+
* the order the caller gave them. A value holding a literal `{UPPER}` placeholder
|
|
67
|
+
* is refused (exit 2): the workflow passed it through unsubstituted.
|
|
68
|
+
*/
|
|
69
|
+
export function parseFlags(argv, specs) {
|
|
70
|
+
const byName = new Map(specs.map((s) => [s.name, s]));
|
|
71
|
+
const positional = specs.find((s) => s.positional);
|
|
72
|
+
const out = {};
|
|
73
|
+
for (let i = 0; i < argv.length; i++) {
|
|
74
|
+
const arg = argv[i];
|
|
75
|
+
if (!arg.startsWith("--")) {
|
|
76
|
+
const key = positional && camel(positional.name);
|
|
77
|
+
if (!key || out[key] !== undefined) {
|
|
78
|
+
throw new CommandError(EXIT.USAGE, `unexpected argument "${arg}" — commands take flags only`);
|
|
79
|
+
}
|
|
80
|
+
refuseUnsubstituted(positional.name, arg);
|
|
81
|
+
out[key] = arg;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const eq = arg.indexOf("=");
|
|
85
|
+
const name = arg.slice(2, eq === -1 ? undefined : eq);
|
|
86
|
+
const spec = byName.get(name);
|
|
87
|
+
if (!spec)
|
|
88
|
+
throw new CommandError(EXIT.USAGE, `unknown flag --${name}`);
|
|
89
|
+
let value;
|
|
90
|
+
if (spec.type === "boolean") {
|
|
91
|
+
if (eq !== -1)
|
|
92
|
+
throw new CommandError(EXIT.USAGE, `--${name} takes no value`);
|
|
93
|
+
value = true;
|
|
94
|
+
}
|
|
95
|
+
else if (eq !== -1) {
|
|
96
|
+
value = arg.slice(eq + 1);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
const next = argv[i + 1];
|
|
100
|
+
if (next === undefined || next.startsWith("--")) {
|
|
101
|
+
throw new CommandError(EXIT.USAGE, `--${name} needs a value`);
|
|
102
|
+
}
|
|
103
|
+
value = next;
|
|
104
|
+
i++;
|
|
105
|
+
}
|
|
106
|
+
if (typeof value === "string")
|
|
107
|
+
refuseUnsubstituted(name, value);
|
|
108
|
+
const key = camel(name);
|
|
109
|
+
if (spec.repeatable) {
|
|
110
|
+
const prior = out[key];
|
|
111
|
+
out[key] = [...(Array.isArray(prior) ? prior : []), String(value)];
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
if (out[key] !== undefined)
|
|
115
|
+
throw new CommandError(EXIT.USAGE, `--${name} given twice`);
|
|
116
|
+
out[key] = value;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
for (const spec of specs) {
|
|
120
|
+
if (!spec.required)
|
|
121
|
+
continue;
|
|
122
|
+
const value = out[camel(spec.name)];
|
|
123
|
+
if (value === undefined) {
|
|
124
|
+
throw new CommandError(EXIT.USAGE, `missing required flag --${spec.name}`);
|
|
125
|
+
}
|
|
126
|
+
if (value === "" || (Array.isArray(value) && value.includes(""))) {
|
|
127
|
+
throw new CommandError(EXIT.USAGE, `required flag --${spec.name} needs a non-empty value`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return out;
|
|
131
|
+
}
|
|
132
|
+
// ---------------------------------------------------------------------------
|
|
133
|
+
// Help
|
|
134
|
+
// ---------------------------------------------------------------------------
|
|
135
|
+
const table = (rows) => {
|
|
136
|
+
const width = Math.max(0, ...rows.map(([k]) => k.length));
|
|
137
|
+
return rows.map(([k, v]) => ` ${k.padEnd(width)} ${v}`).join("\n");
|
|
138
|
+
};
|
|
139
|
+
function exitCodeRows(own = {}) {
|
|
140
|
+
return Object.entries({ ...SHARED_EXIT_CODES, ...own })
|
|
141
|
+
.map(([code, meaning]) => [Number(code), meaning])
|
|
142
|
+
.sort((a, b) => a[0] - b[0])
|
|
143
|
+
.map(([code, meaning]) => [String(code), meaning]);
|
|
144
|
+
}
|
|
145
|
+
export function commandHelp(cmd) {
|
|
146
|
+
const verbs = Object.entries(cmd.verbs).map(([v, s]) => [v, s.summary]);
|
|
147
|
+
return [
|
|
148
|
+
`bkit ${cmd.noun} — ${cmd.summary}`,
|
|
149
|
+
"",
|
|
150
|
+
`Usage: bkit ${cmd.noun} <verb> [flags]`,
|
|
151
|
+
"",
|
|
152
|
+
"Verbs:",
|
|
153
|
+
table(verbs),
|
|
154
|
+
"",
|
|
155
|
+
`Run \`bkit ${cmd.noun} <verb> --help\` for each verb's flags, output keys, and own exit codes.`,
|
|
156
|
+
"",
|
|
157
|
+
"Exit codes:",
|
|
158
|
+
table(exitCodeRows()),
|
|
159
|
+
"",
|
|
160
|
+
].join("\n");
|
|
161
|
+
}
|
|
162
|
+
export function verbHelp(cmd, verb) {
|
|
163
|
+
const spec = cmd.verbs[verb];
|
|
164
|
+
const flags = spec.flags.map((f) => {
|
|
165
|
+
const usage = f.type === "boolean" ? `--${f.name}` : `--${f.name}=<value>`;
|
|
166
|
+
const notes = [
|
|
167
|
+
f.required ? "required" : "",
|
|
168
|
+
f.repeatable ? "repeatable" : "",
|
|
169
|
+
f.positional ? "or as the one bare argument" : "",
|
|
170
|
+
].filter(Boolean);
|
|
171
|
+
return [usage, notes.length ? `${f.help} (${notes.join(", ")})` : f.help];
|
|
172
|
+
});
|
|
173
|
+
return [
|
|
174
|
+
`bkit ${cmd.noun} ${verb} — ${spec.summary}`,
|
|
175
|
+
"",
|
|
176
|
+
`Usage: bkit ${cmd.noun} ${verb} [flags]`,
|
|
177
|
+
"",
|
|
178
|
+
"Flags:",
|
|
179
|
+
flags.length ? table(flags) : " none",
|
|
180
|
+
"",
|
|
181
|
+
"Output (one JSON object on stdout):",
|
|
182
|
+
table(Object.entries(spec.output)),
|
|
183
|
+
"",
|
|
184
|
+
"Exit codes:",
|
|
185
|
+
table(exitCodeRows(spec.exitCodes)),
|
|
186
|
+
"",
|
|
187
|
+
].join("\n");
|
|
188
|
+
}
|
|
189
|
+
// ---------------------------------------------------------------------------
|
|
190
|
+
// Dispatch
|
|
191
|
+
// ---------------------------------------------------------------------------
|
|
192
|
+
export const logTag = (noun) => `[bkit-${noun}]`;
|
|
193
|
+
const processIo = {
|
|
194
|
+
stdout: (t) => process.stdout.write(t),
|
|
195
|
+
stderr: (t) => process.stderr.write(t),
|
|
196
|
+
};
|
|
197
|
+
const isHelp = (arg) => arg === "--help" || arg === "-h";
|
|
198
|
+
/**
|
|
199
|
+
* Run `argv` (without the leading `bkit`) if it names a registered command.
|
|
200
|
+
* Returns the exit code, or null when `argv` is not a command, so the caller falls
|
|
201
|
+
* through to the classic verbs. A noun that is also a classic verb (`status`)
|
|
202
|
+
* routes only when the second word is one of its verbs or a help flag, so
|
|
203
|
+
* `bkit status` keeps its classic meaning while `bkit status --help` still lists
|
|
204
|
+
* the noun's own verbs.
|
|
205
|
+
*/
|
|
206
|
+
export async function runCommand(argv, commands, options) {
|
|
207
|
+
const io = options.io ?? processIo;
|
|
208
|
+
const cmd = commands.find((c) => c.noun === argv[0]);
|
|
209
|
+
if (!cmd)
|
|
210
|
+
return null;
|
|
211
|
+
const verb = argv[1];
|
|
212
|
+
const isVerb = verb !== undefined && Object.hasOwn(cmd.verbs, verb);
|
|
213
|
+
if (!isVerb && options.classicVerbs.has(cmd.noun) && !isHelp(verb))
|
|
214
|
+
return null;
|
|
215
|
+
const tag = logTag(cmd.noun);
|
|
216
|
+
if (!isVerb) {
|
|
217
|
+
if (verb === undefined || isHelp(verb)) {
|
|
218
|
+
io.stdout(commandHelp(cmd));
|
|
219
|
+
return verb === undefined ? EXIT.USAGE : EXIT.OK;
|
|
220
|
+
}
|
|
221
|
+
io.stderr(`${tag} unknown verb "${verb}" — run \`bkit ${cmd.noun} --help\`\n`);
|
|
222
|
+
return EXIT.USAGE;
|
|
223
|
+
}
|
|
224
|
+
const rest = argv.slice(2);
|
|
225
|
+
if (rest.some(isHelp)) {
|
|
226
|
+
io.stdout(verbHelp(cmd, verb));
|
|
227
|
+
return EXIT.OK;
|
|
228
|
+
}
|
|
229
|
+
const spec = cmd.verbs[verb];
|
|
230
|
+
let emitted = false;
|
|
231
|
+
const ctx = {
|
|
232
|
+
flags: {},
|
|
233
|
+
cwd: options.cwd ?? process.cwd(),
|
|
234
|
+
log: (message) => io.stderr(`${tag} ${message}\n`),
|
|
235
|
+
emit: (output) => {
|
|
236
|
+
if (emitted)
|
|
237
|
+
throw new Error(`${tag} ${verb} emitted twice — one JSON object per run`);
|
|
238
|
+
emitted = true;
|
|
239
|
+
io.stdout(`${JSON.stringify(output)}\n`);
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
try {
|
|
243
|
+
ctx.flags = parseFlags(rest, spec.flags);
|
|
244
|
+
return await spec.run(ctx);
|
|
245
|
+
}
|
|
246
|
+
catch (err) {
|
|
247
|
+
if (!(err instanceof CommandError))
|
|
248
|
+
throw err;
|
|
249
|
+
io.stderr(`${tag} ${err.message}\n`);
|
|
250
|
+
return err.code;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
// ---------------------------------------------------------------------------
|
|
254
|
+
// Repo facts
|
|
255
|
+
// ---------------------------------------------------------------------------
|
|
256
|
+
/** `git <args>` in `cwd`, never throwing: exit status plus trimmed stdout / stderr. */
|
|
257
|
+
export function runGit(cwd, args) {
|
|
258
|
+
const res = spawnSync("git", args, { cwd, encoding: "utf-8", env: gitEnv() });
|
|
259
|
+
return {
|
|
260
|
+
ok: res.status === 0,
|
|
261
|
+
stdout: (res.stdout ?? "").trim(),
|
|
262
|
+
stderr: (res.stderr ?? "").trim(),
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
/** `git <args>` in `cwd`; stdout trimmed, or null on a non-zero exit. */
|
|
266
|
+
export function git(cwd, args) {
|
|
267
|
+
const res = runGit(cwd, args);
|
|
268
|
+
return res.ok ? res.stdout : null;
|
|
269
|
+
}
|
|
270
|
+
/** `JSON.parse` as a result instead of a throw; each caller says what bad input means for it. */
|
|
271
|
+
// Shared with the files that are not commands (checks, install): re-exported here
|
|
272
|
+
// for the command modules that already import it from this module.
|
|
273
|
+
export { parseJson } from "../shared/json.js";
|
|
274
|
+
/**
|
|
275
|
+
* Run a tool other than git, never throwing. Hook-exported GIT_* vars are scrubbed
|
|
276
|
+
* so gh and friends answer for `cwd`; `input` goes to stdin.
|
|
277
|
+
*/
|
|
278
|
+
export function runTool(cmd, args, cwd, opts = {}) {
|
|
279
|
+
const res = spawnSync(cmd, args, {
|
|
280
|
+
cwd,
|
|
281
|
+
encoding: "utf-8",
|
|
282
|
+
env: gitEnv(),
|
|
283
|
+
input: opts.input,
|
|
284
|
+
maxBuffer: 1 << 26,
|
|
285
|
+
});
|
|
286
|
+
if (res.error) {
|
|
287
|
+
return { found: false, status: 127, stdout: "", stderr: `${cmd} not found on PATH` };
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
found: true,
|
|
291
|
+
status: res.status ?? 128 + signalNumber(res.signal),
|
|
292
|
+
stdout: res.stdout ?? "",
|
|
293
|
+
stderr: res.stderr ?? "",
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
const signalNumber = (signal) => (signal ? os.constants.signals[signal] : undefined) ?? 1;
|
|
297
|
+
/** `gh <args>` in `cwd`, never throwing; `input` goes to stdin. */
|
|
298
|
+
export function runGh(cwd, args, input) {
|
|
299
|
+
const res = runTool("gh", args, cwd, { input });
|
|
300
|
+
return {
|
|
301
|
+
ok: res.found && res.status === 0,
|
|
302
|
+
stdout: res.stdout.trim(),
|
|
303
|
+
stderr: res.stderr.trim(),
|
|
304
|
+
missing: !res.found,
|
|
305
|
+
status: res.status,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
/** gh cannot serve this call here: not installed, or exit 4 (not logged in). */
|
|
309
|
+
export const ghUnavailable = (res) => res.missing || res.status === 4;
|
|
310
|
+
/**
|
|
311
|
+
* The main checkout's root, from any worktree. `--git-common-dir` points at the
|
|
312
|
+
* shared `.git`, so a linked worktree resolves to the same root as the main one.
|
|
313
|
+
*/
|
|
314
|
+
export function repoRoot(cwd) {
|
|
315
|
+
const common = git(cwd, ["rev-parse", "--path-format=absolute", "--git-common-dir"]);
|
|
316
|
+
if (!common)
|
|
317
|
+
throw new CommandError(EXIT.USAGE, `not inside a git repository: ${cwd}`);
|
|
318
|
+
return path.dirname(common);
|
|
319
|
+
}
|
|
320
|
+
/** `YYYYMM` in UTC, so every workflow picks the same month bucket at a month boundary. */
|
|
321
|
+
export function utcMonth(now = new Date()) {
|
|
322
|
+
return `${now.getUTCFullYear()}${String(now.getUTCMonth() + 1).padStart(2, "0")}`;
|
|
323
|
+
}
|
|
324
|
+
/** `docs/plans/{month}/logs/{fid}/status.jsonl`, relative to whichever root holds it. */
|
|
325
|
+
export const statusRelPath = (month, fid) => path.join("docs", "plans", month, "logs", fid, "status.jsonl");
|
|
326
|
+
/**
|
|
327
|
+
* Where a workflow's `status.jsonl` lives. One rule per workflow kind:
|
|
328
|
+
*
|
|
329
|
+
* - design / plan / build / debug: the feature worktree's copy when it exists
|
|
330
|
+
* (`.worktrees/{fid}`), else the main checkout's.
|
|
331
|
+
* - ship: the main checkout when this runtime pushes to dev, else the current
|
|
332
|
+
* worktree's top (the branch being shipped). An unresolved runtime takes the
|
|
333
|
+
* least-capable answer: current worktree.
|
|
334
|
+
*/
|
|
335
|
+
export function statusLocation(opts) {
|
|
336
|
+
const root = repoRoot(opts.cwd);
|
|
337
|
+
const rel = statusRelPath(opts.month, opts.fid);
|
|
338
|
+
if (opts.workflow === "ship") {
|
|
339
|
+
const bookRoot = opts.devPushes === true ? root : (git(opts.cwd, ["rev-parse", "--show-toplevel"]) ?? root);
|
|
340
|
+
return { bookRoot, path: path.join(bookRoot, rel) };
|
|
341
|
+
}
|
|
342
|
+
const worktree = path.join(root, ".worktrees", opts.fid);
|
|
343
|
+
const bookRoot = fs.existsSync(path.join(worktree, rel)) ? worktree : root;
|
|
344
|
+
return { bookRoot, path: path.join(bookRoot, rel) };
|
|
345
|
+
}
|
|
346
|
+
/** The tokens GitHub Actions honours to skip every workflow run for a commit. */
|
|
347
|
+
export const SKIP_CI_TOKEN = /\[(?:skip ci|ci skip|no ci|skip actions|actions skip)\]/i;
|
|
348
|
+
/** A commit's full message, or null when it cannot be read (`%B` is never empty for a real commit). */
|
|
349
|
+
export function commitMessage(cwd, sha) {
|
|
350
|
+
const res = runGit(cwd, ["log", "-1", "--format=%B", sha]);
|
|
351
|
+
return res.ok && res.stdout !== "" ? res.stdout : null;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* The skip-CI token in a commit's BODY, or null; undefined when the commit cannot
|
|
355
|
+
* be read. The subject is excluded (a docs-only commit carries `[skip ci]` in its
|
|
356
|
+
* subject by convention); the body is where a squash concatenates branch subjects.
|
|
357
|
+
*/
|
|
358
|
+
export function bodySkipToken(cwd, sha) {
|
|
359
|
+
const msg = sha === "" ? null : commitMessage(cwd, sha);
|
|
360
|
+
if (msg === null)
|
|
361
|
+
return undefined;
|
|
362
|
+
return SKIP_CI_TOKEN.exec(msg.split("\n").slice(1).join("\n"))?.[0] ?? null;
|
|
363
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// commands/registry.ts — every `bkit <noun> <verb>` command.
|
|
2
|
+
//
|
|
3
|
+
// Sources live in `commands/workflow/` (called by the phase workflows),
|
|
4
|
+
// `commands/ci/` (`bkit ci ...`) and `commands/setup/` (`bkit setup ...`).
|
|
5
|
+
// `commands/conventions.test.ts` fails on a source file in those folders that is not
|
|
6
|
+
// listed here, so a command cannot exist without being reachable.
|
|
7
|
+
import { ciCommand } from "./ci/ci.js";
|
|
8
|
+
import { setupCommand } from "./setup/setup.js";
|
|
9
|
+
import { branchesCommand } from "./workflow/branches.js";
|
|
10
|
+
import { contextCommand } from "./workflow/context.js";
|
|
11
|
+
import { countersCommand } from "./workflow/counters.js";
|
|
12
|
+
import { fidsCommand } from "./workflow/fids.js";
|
|
13
|
+
import { issuesCommand } from "./workflow/issues.js";
|
|
14
|
+
import { ledgersCommand } from "./workflow/ledgers.js";
|
|
15
|
+
import { locksCommand } from "./workflow/locks.js";
|
|
16
|
+
import { prsCommand } from "./workflow/prs.js";
|
|
17
|
+
import { repoCommand } from "./workflow/repo.js";
|
|
18
|
+
import { roadmapCommand } from "./workflow/roadmap.js";
|
|
19
|
+
import { runsCommand } from "./workflow/runs.js";
|
|
20
|
+
import { runtimeCommand } from "./workflow/runtime.js";
|
|
21
|
+
import { skillsCommand } from "./workflow/skills.js";
|
|
22
|
+
import { statusCommand } from "./workflow/status.js";
|
|
23
|
+
import { stepsCommand } from "./workflow/steps.js";
|
|
24
|
+
import { testsCommand } from "./workflow/tests.js";
|
|
25
|
+
import { workflowsCommand } from "./workflow/workflows.js";
|
|
26
|
+
import { workstreamsCommand } from "./workflow/workstreams.js";
|
|
27
|
+
import { worktreesCommand } from "./workflow/worktrees.js";
|
|
28
|
+
export const COMMANDS = [
|
|
29
|
+
statusCommand,
|
|
30
|
+
countersCommand,
|
|
31
|
+
stepsCommand,
|
|
32
|
+
runtimeCommand,
|
|
33
|
+
repoCommand,
|
|
34
|
+
fidsCommand,
|
|
35
|
+
testsCommand,
|
|
36
|
+
locksCommand,
|
|
37
|
+
workflowsCommand,
|
|
38
|
+
worktreesCommand,
|
|
39
|
+
branchesCommand,
|
|
40
|
+
skillsCommand,
|
|
41
|
+
prsCommand,
|
|
42
|
+
issuesCommand,
|
|
43
|
+
runsCommand,
|
|
44
|
+
ledgersCommand,
|
|
45
|
+
contextCommand,
|
|
46
|
+
roadmapCommand,
|
|
47
|
+
workstreamsCommand,
|
|
48
|
+
ciCommand,
|
|
49
|
+
setupCommand,
|
|
50
|
+
];
|