@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,268 @@
|
|
|
1
|
+
// bkit counters derive|run|route|max — attempt counters derived from status.jsonl.
|
|
2
|
+
//
|
|
3
|
+
// No counter is stored. Each is counted from the log when needed, at one of three
|
|
4
|
+
// positions — read this before picking `--position`:
|
|
5
|
+
// next at the START of the counted step: count + 1, the attempt the artifact
|
|
6
|
+
// name embeds and the row about to be written records.
|
|
7
|
+
// current AFTER the step's own row was just written: the count, which can never
|
|
8
|
+
// be 0 there, so 0 is refused (it means the row was dropped).
|
|
9
|
+
// count routing on a DIFFERENT step, prior or not yet run: the bare count, and
|
|
10
|
+
// 0 is a legal answer (that step simply has not run).
|
|
11
|
+
|
|
12
|
+
import { activeDoneSteps, runNumber } from "../../ledgers/status.js";
|
|
13
|
+
import { CommandError, EXIT, type CommandSpec, type FlagValue, type RunContext } from "../lib.js";
|
|
14
|
+
import {
|
|
15
|
+
EXIT_NO_STATUS,
|
|
16
|
+
FILE_FLAG,
|
|
17
|
+
STEP_FLAG,
|
|
18
|
+
SUB_PLAN_FLAG,
|
|
19
|
+
WORKFLOW_FLAG,
|
|
20
|
+
positiveInt,
|
|
21
|
+
readRuns,
|
|
22
|
+
readStatusRows,
|
|
23
|
+
statusFile,
|
|
24
|
+
str,
|
|
25
|
+
} from "./status.js";
|
|
26
|
+
|
|
27
|
+
/** Every MAX_* threshold the workflows route on. */
|
|
28
|
+
export const THRESHOLDS: Readonly<Record<string, number>> = {
|
|
29
|
+
// build
|
|
30
|
+
MAX_VERIFY_ATTEMPT: 3,
|
|
31
|
+
MAX_TEST_ATTEMPT: 3,
|
|
32
|
+
MAX_CHALLENGE_REMEDIATE_ATTEMPT: 1,
|
|
33
|
+
// debug — mode-matched pairs
|
|
34
|
+
MAX_DEBUG_ATTEMPT: 3,
|
|
35
|
+
MAX_NORMAL_ATTEMPT: 3,
|
|
36
|
+
MAX_SOAK_ATTEMPT: 3,
|
|
37
|
+
// ship
|
|
38
|
+
MAX_MERGE_ATTEMPT: 3,
|
|
39
|
+
/** gate-refusal (10/11/14) poll-only re-entries into the sweep step */
|
|
40
|
+
MAX_REVALIDATE_ATTEMPT: 3,
|
|
41
|
+
// bkit-cloud.yml
|
|
42
|
+
/** distinct failed dev CI SHAs per FID that may each dispatch a debug run */
|
|
43
|
+
MAX_DEV_DISPATCH_ATTEMPTS: 3,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** Exit code: `--position=current` found no row — the step's own row is missing. */
|
|
47
|
+
export const EXIT_NO_OWN_ROW = 4;
|
|
48
|
+
|
|
49
|
+
const nonNegativeInt = (v: FlagValue, flag: string): number => {
|
|
50
|
+
const s = String(v ?? "");
|
|
51
|
+
if (!/^[0-9]+$/.test(s)) {
|
|
52
|
+
throw new CommandError(
|
|
53
|
+
EXIT.USAGE,
|
|
54
|
+
`--${flag} must be a non-negative integer, got "${s}" — refusing to continue`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
return Number(s);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/** `--of=<step>:<position>` over `--file` / `--workflow`: the counter at that position. */
|
|
61
|
+
function derivedOf(ctx: RunContext): number {
|
|
62
|
+
const [step, position] = String(ctx.flags.of).split(":");
|
|
63
|
+
if (!step || !["next", "current", "count"].includes(position ?? ""))
|
|
64
|
+
throw new CommandError(EXIT.USAGE, "--of must be <step>:<next|current|count>");
|
|
65
|
+
if (ctx.flags.file === undefined || ctx.flags.workflow === undefined)
|
|
66
|
+
throw new CommandError(EXIT.USAGE, "--of needs --file and --workflow");
|
|
67
|
+
const count = activeDoneSteps(
|
|
68
|
+
readRuns(statusFile(ctx)),
|
|
69
|
+
String(ctx.flags.workflow),
|
|
70
|
+
{ step, subPlan: positiveInt(ctx.flags.subPlan, "sub-plan") },
|
|
71
|
+
str(ctx.flags.since),
|
|
72
|
+
).length;
|
|
73
|
+
if (position === "current" && count === 0)
|
|
74
|
+
throw new CommandError(
|
|
75
|
+
EXIT_NO_OWN_ROW,
|
|
76
|
+
`${step}: no DONE row in the active run — the step's own row is missing`,
|
|
77
|
+
);
|
|
78
|
+
return position === "next" ? count + 1 : count;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function threshold(name: string): number {
|
|
82
|
+
const value = THRESHOLDS[name];
|
|
83
|
+
if (value === undefined) {
|
|
84
|
+
throw new CommandError(
|
|
85
|
+
EXIT.USAGE,
|
|
86
|
+
`unknown threshold ${name}; known: ${Object.keys(THRESHOLDS).join(", ")}`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const countersCommand: CommandSpec = {
|
|
93
|
+
noun: "counters",
|
|
94
|
+
summary: "Attempt counters derived from status.jsonl, and the MAX_* thresholds.",
|
|
95
|
+
verbs: {
|
|
96
|
+
derive: {
|
|
97
|
+
summary: "Count a step's DONE rows in the active run, at one of three positions.",
|
|
98
|
+
flags: [
|
|
99
|
+
FILE_FLAG,
|
|
100
|
+
WORKFLOW_FLAG,
|
|
101
|
+
STEP_FLAG,
|
|
102
|
+
SUB_PLAN_FLAG,
|
|
103
|
+
{
|
|
104
|
+
name: "position",
|
|
105
|
+
type: "string",
|
|
106
|
+
required: true,
|
|
107
|
+
help: "next (step start: count+1) | current (after own row: count, 0 refused) | count (other step: 0 legal)",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "since",
|
|
111
|
+
type: "string",
|
|
112
|
+
help: "run field holding a timestamp; only rows after it count (soakEntryAt)",
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
output: { value: "the counter at that position", count: "DONE rows counted" },
|
|
116
|
+
exitCodes: {
|
|
117
|
+
[EXIT_NO_STATUS]: "status.jsonl missing, unreadable, or not valid NDJSON",
|
|
118
|
+
[EXIT_NO_OWN_ROW]: "--position=current counted 0: the step's own row is missing",
|
|
119
|
+
},
|
|
120
|
+
run: (ctx) => {
|
|
121
|
+
const position = String(ctx.flags.position);
|
|
122
|
+
if (!["next", "current", "count"].includes(position)) {
|
|
123
|
+
throw new CommandError(EXIT.USAGE, "--position must be next, current, or count");
|
|
124
|
+
}
|
|
125
|
+
const count = activeDoneSteps(
|
|
126
|
+
readRuns(statusFile(ctx)),
|
|
127
|
+
String(ctx.flags.workflow),
|
|
128
|
+
{ step: String(ctx.flags.step), subPlan: positiveInt(ctx.flags.subPlan, "sub-plan") },
|
|
129
|
+
str(ctx.flags.since),
|
|
130
|
+
).length;
|
|
131
|
+
if (position === "current" && count === 0) {
|
|
132
|
+
ctx.log(
|
|
133
|
+
`${String(ctx.flags.step)}: no DONE row in the active run — the step's own row is missing`,
|
|
134
|
+
);
|
|
135
|
+
return EXIT_NO_OWN_ROW;
|
|
136
|
+
}
|
|
137
|
+
ctx.emit({ value: position === "next" ? count + 1 : count, count });
|
|
138
|
+
return EXIT.OK;
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
run: {
|
|
142
|
+
summary: "Which run of the workflow this invocation is (1-based; a resume keeps its number).",
|
|
143
|
+
flags: [FILE_FLAG, WORKFLOW_FLAG],
|
|
144
|
+
output: { run: "run number" },
|
|
145
|
+
exitCodes: { [EXIT_NO_STATUS]: "status.jsonl missing, unreadable, or not valid NDJSON" },
|
|
146
|
+
run: (ctx) => {
|
|
147
|
+
ctx.emit({ run: runNumber(readRuns(statusFile(ctx)), String(ctx.flags.workflow)) });
|
|
148
|
+
return EXIT.OK;
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
route: {
|
|
152
|
+
summary: "Compare a counter to its max: exit 0 continue, exit 1 exceeded.",
|
|
153
|
+
flags: [
|
|
154
|
+
{ name: "name", type: "string", required: true, help: "counter name, for the log line" },
|
|
155
|
+
{
|
|
156
|
+
name: "value",
|
|
157
|
+
type: "string",
|
|
158
|
+
help: "counter value (non-negative integer), or derive it with --of",
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: "of",
|
|
162
|
+
type: "string",
|
|
163
|
+
help: "<step>:<next|current|count> — derive the value from --file (active run)",
|
|
164
|
+
},
|
|
165
|
+
{ ...FILE_FLAG, required: false, help: "status.jsonl, with --of" },
|
|
166
|
+
{ ...WORKFLOW_FLAG, required: false, help: "workflow, with --of" },
|
|
167
|
+
{ ...SUB_PLAN_FLAG, help: "with --of: only rows for this sub-plan" },
|
|
168
|
+
{
|
|
169
|
+
name: "since",
|
|
170
|
+
type: "string",
|
|
171
|
+
help: "with --of: run field holding a timestamp; only rows after it count (soakEntryAt)",
|
|
172
|
+
},
|
|
173
|
+
{ name: "max", type: "string", help: "max as a number (or use --limit)" },
|
|
174
|
+
{ name: "limit", type: "string", help: "max as a threshold name, e.g. MAX_VERIFY_ATTEMPT" },
|
|
175
|
+
{ name: "continue", type: "string", help: "step to go to when value <= max" },
|
|
176
|
+
{ name: "exceeded", type: "string", help: "step to go to when value > max" },
|
|
177
|
+
],
|
|
178
|
+
output: {
|
|
179
|
+
value: "the counter compared",
|
|
180
|
+
exceeded: "true when value > max",
|
|
181
|
+
next: "--continue or --exceeded step, whichever applies (null when not given)",
|
|
182
|
+
max: "the max compared against",
|
|
183
|
+
},
|
|
184
|
+
exitCodes: {
|
|
185
|
+
[EXIT_NO_STATUS]: "--of: status.jsonl missing, unreadable, or not valid NDJSON",
|
|
186
|
+
[EXIT_NO_OWN_ROW]: "--of=<step>:current counted 0: the step's own row is missing",
|
|
187
|
+
},
|
|
188
|
+
run: (ctx) => {
|
|
189
|
+
const name = String(ctx.flags.name);
|
|
190
|
+
if ((ctx.flags.value === undefined) === (ctx.flags.of === undefined))
|
|
191
|
+
throw new CommandError(EXIT.USAGE, "give exactly one of --value or --of");
|
|
192
|
+
const value =
|
|
193
|
+
ctx.flags.of !== undefined ? derivedOf(ctx) : nonNegativeInt(ctx.flags.value, "value");
|
|
194
|
+
if ((ctx.flags.max === undefined) === (ctx.flags.limit === undefined)) {
|
|
195
|
+
throw new CommandError(EXIT.USAGE, "give exactly one of --max or --limit");
|
|
196
|
+
}
|
|
197
|
+
const max =
|
|
198
|
+
ctx.flags.limit !== undefined
|
|
199
|
+
? threshold(String(ctx.flags.limit))
|
|
200
|
+
: nonNegativeInt(ctx.flags.max, "max");
|
|
201
|
+
const exceeded = value > max;
|
|
202
|
+
if (exceeded) ctx.log(`counter ${name} exceeded max=${max} (value=${value})`);
|
|
203
|
+
ctx.emit({
|
|
204
|
+
value,
|
|
205
|
+
exceeded,
|
|
206
|
+
next: str(exceeded ? ctx.flags.exceeded : ctx.flags.continue) ?? null,
|
|
207
|
+
max,
|
|
208
|
+
});
|
|
209
|
+
return exceeded ? EXIT.NO : EXIT.OK;
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
max: {
|
|
213
|
+
summary: "The MAX_* thresholds: one by --name, or all.",
|
|
214
|
+
flags: [
|
|
215
|
+
{ name: "name", type: "string", help: "threshold name, e.g. MAX_DEV_DISPATCH_ATTEMPTS" },
|
|
216
|
+
],
|
|
217
|
+
output: {
|
|
218
|
+
value: "the named threshold (with --name)",
|
|
219
|
+
thresholds: "every threshold (without --name)",
|
|
220
|
+
},
|
|
221
|
+
run: (ctx) => {
|
|
222
|
+
const name = str(ctx.flags.name);
|
|
223
|
+
ctx.emit(name === undefined ? { thresholds: THRESHOLDS } : { value: threshold(name) });
|
|
224
|
+
return EXIT.OK;
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
rows: {
|
|
228
|
+
summary: "Count rows of one audit type in the active run (since its workflow-started row).",
|
|
229
|
+
flags: [
|
|
230
|
+
FILE_FLAG,
|
|
231
|
+
WORKFLOW_FLAG,
|
|
232
|
+
{
|
|
233
|
+
name: "type",
|
|
234
|
+
type: "string",
|
|
235
|
+
required: true,
|
|
236
|
+
help: "row type, e.g. ship-revalidate-dispatch",
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
name: "position",
|
|
240
|
+
type: "string",
|
|
241
|
+
required: true,
|
|
242
|
+
help: "next (count+1, the attempt about to start) | count",
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
output: { value: "the counter at that position", count: "rows counted" },
|
|
246
|
+
exitCodes: { [EXIT_NO_STATUS]: "status.jsonl missing, unreadable, or not valid NDJSON" },
|
|
247
|
+
run: (ctx) => {
|
|
248
|
+
const position = String(ctx.flags.position);
|
|
249
|
+
if (!["next", "count"].includes(position))
|
|
250
|
+
throw new CommandError(EXIT.USAGE, "--position must be next or count");
|
|
251
|
+
const workflow = String(ctx.flags.workflow);
|
|
252
|
+
const type = String(ctx.flags.type);
|
|
253
|
+
const rows = readStatusRows(statusFile(ctx));
|
|
254
|
+
let start = -1;
|
|
255
|
+
rows.forEach((r, i) => {
|
|
256
|
+
if (r.type === "workflow-started" && r.workflow === workflow) start = i;
|
|
257
|
+
});
|
|
258
|
+
const count = rows
|
|
259
|
+
.slice(start + 1)
|
|
260
|
+
.filter(
|
|
261
|
+
(r) => r.type === type && (r.workflow === undefined || r.workflow === workflow),
|
|
262
|
+
).length;
|
|
263
|
+
ctx.emit({ value: position === "next" ? count + 1 : count, count });
|
|
264
|
+
return EXIT.OK;
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
};
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
// bkit fids check|parse|find — feature-id format per tracker, recovering a FID
|
|
2
|
+
// from a branch name or a PR-body marker, and finding the feature already logged
|
|
3
|
+
// for an issue.
|
|
4
|
+
//
|
|
5
|
+
// A FID names the branch (`feat/{FID}`), the log folder and every artifact, so
|
|
6
|
+
// it is checked before first use. Its shape follows the tracker that minted it:
|
|
7
|
+
// github {N}-{slug} ^[0-9]+-[a-z0-9-]+$
|
|
8
|
+
// linear {team}-{N}-{slug} ^[a-z]+-[0-9]+-[a-z0-9-]+$ (issue id lowercased first)
|
|
9
|
+
// none any slug ^[a-z0-9][a-z0-9-]*$ (no tracker shape; still path-safe)
|
|
10
|
+
// any github or linear ^([0-9]+|[a-z]+-[0-9]+)-[a-z0-9-]+$ (auto's CI_DEV allowlist)
|
|
11
|
+
|
|
12
|
+
import * as fs from "node:fs";
|
|
13
|
+
import * as path from "node:path";
|
|
14
|
+
|
|
15
|
+
import { parseIssueTracker, type IssueTracker } from "../../install/manifest.js";
|
|
16
|
+
import { CommandError, EXIT, git, repoRoot, type CommandSpec, type FlagSpec } from "../lib.js";
|
|
17
|
+
import { readBkitConfig } from "../../shared/settings.js";
|
|
18
|
+
import { str } from "./status.js";
|
|
19
|
+
|
|
20
|
+
export type FidTracker = IssueTracker | "any";
|
|
21
|
+
|
|
22
|
+
export const FID_PATTERNS: Readonly<Record<FidTracker, RegExp>> = {
|
|
23
|
+
github: /^[0-9]+-[a-z0-9-]+$/,
|
|
24
|
+
linear: /^[a-z]+-[0-9]+-[a-z0-9-]+$/,
|
|
25
|
+
none: /^[a-z0-9][a-z0-9-]*$/,
|
|
26
|
+
any: /^([0-9]+|[a-z]+-[0-9]+)-[a-z0-9-]+$/,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** The slug every recovered FID must pass before it touches a path (auto's branch fallback). */
|
|
30
|
+
const SLUG = FID_PATTERNS.none;
|
|
31
|
+
|
|
32
|
+
/** Exit code: no FID could be recovered from the marker or the branch. */
|
|
33
|
+
export const EXIT_NO_FID = 3;
|
|
34
|
+
/** Exit code (find): more than one feature is logged for the issue. */
|
|
35
|
+
export const EXIT_SEVERAL = 4;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Features already logged for an issue: every `docs/plans/{YYYYMM}/logs/{issue}-*`
|
|
39
|
+
* folder, the issue id lowercased (a Linear FID carries it lowercased). Sorted, unique.
|
|
40
|
+
*/
|
|
41
|
+
export function logged(root: string, issue: string): string[] {
|
|
42
|
+
const key = `${issue.replace(/^#/, "").toLowerCase()}-`;
|
|
43
|
+
const plans = path.join(root, "docs", "plans");
|
|
44
|
+
if (!fs.existsSync(plans)) return [];
|
|
45
|
+
const found = new Set<string>();
|
|
46
|
+
for (const month of fs.readdirSync(plans).filter((m) => /^[0-9]{6}$/.test(m))) {
|
|
47
|
+
const logs = path.join(plans, month, "logs");
|
|
48
|
+
if (!fs.existsSync(logs)) continue;
|
|
49
|
+
for (const fid of fs.readdirSync(logs)) {
|
|
50
|
+
if (fid.startsWith(key) && fs.statSync(path.join(logs, fid)).isDirectory()) found.add(fid);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return [...found].sort();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** `package.json` `bkit.issueTracker` at the main checkout (cwd outside git); default `none`. */
|
|
57
|
+
export function readIssueTracker(cwd: string): IssueTracker {
|
|
58
|
+
const common = git(cwd, ["rev-parse", "--path-format=absolute", "--git-common-dir"]);
|
|
59
|
+
return readBkitConfig(common ? path.dirname(common) : cwd).issueTracker;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function trackerFlag(value: string | undefined, cwd: string, allowAny: boolean): FidTracker {
|
|
63
|
+
if (value === undefined) return readIssueTracker(cwd);
|
|
64
|
+
if (value === "any" && allowAny) return "any";
|
|
65
|
+
const t = parseIssueTracker(value);
|
|
66
|
+
if (!t) {
|
|
67
|
+
throw new CommandError(
|
|
68
|
+
EXIT.USAGE,
|
|
69
|
+
`--tracker must be github, linear, none${allowAny ? ", any" : ""}; got "${value}"`,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
return t;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Linear issue ids arrive uppercase (`ABC-123`); the FID carries them lowercased. */
|
|
76
|
+
export const normaliseFid = (fid: string, tracker: FidTracker) =>
|
|
77
|
+
tracker === "linear" ? fid.toLowerCase() : fid;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The tracker issue id a FID embeds, or null when it embeds none:
|
|
81
|
+
* github the leading numeric segment, linear the first two segments uppercased.
|
|
82
|
+
*/
|
|
83
|
+
export function issueIdOf(fid: string, tracker: FidTracker): string | null {
|
|
84
|
+
const [first = "", second = ""] = fid.split("-");
|
|
85
|
+
if (tracker === "github") return /^[0-9]+$/.test(first) ? first : null;
|
|
86
|
+
if (tracker === "linear") {
|
|
87
|
+
const id = `${first}-${second}`.toUpperCase();
|
|
88
|
+
return /^[A-Z]+-[0-9]+$/.test(id) ? id : null;
|
|
89
|
+
}
|
|
90
|
+
if (tracker === "any") {
|
|
91
|
+
const m = /^([0-9]+|[a-z]+-[0-9]+)(?=-)/.exec(fid);
|
|
92
|
+
return m ? m[1]!.toUpperCase() : null;
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The PR-body marker build and ship write, per tracker. Group 1 = issue id (absent for none), last = FID. */
|
|
98
|
+
const MARKERS: Readonly<Record<IssueTracker, RegExp>> = {
|
|
99
|
+
github: /<!-- bkit:issue=#([0-9]+) bkit:fid=(\S+) -->/,
|
|
100
|
+
linear: /<!-- bkit:issue=([A-Za-z]+-[0-9]+) bkit:fid=(\S+) -->/,
|
|
101
|
+
none: /<!-- bkit:fid=(\S+) -->/,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export interface ParsedFid {
|
|
105
|
+
fid: string;
|
|
106
|
+
issueId: string | null;
|
|
107
|
+
source: "marker" | "branch";
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** FID from the marker, when present and well-formed for the tracker. */
|
|
111
|
+
export function fromMarker(text: string, tracker: IssueTracker): ParsedFid | null {
|
|
112
|
+
const m = MARKERS[tracker].exec(text);
|
|
113
|
+
if (!m) return null;
|
|
114
|
+
const fid = normaliseFid(m[m.length - 1]!, tracker);
|
|
115
|
+
if (!FID_PATTERNS[tracker].test(fid)) return null;
|
|
116
|
+
const issueId = tracker === "none" ? null : tracker === "linear" ? m[1]!.toUpperCase() : m[1]!;
|
|
117
|
+
return { fid, issueId, source: "marker" };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** FID from `feat/{FID}`; the slug check, then the issue id the tracker needs. */
|
|
121
|
+
export function fromBranch(
|
|
122
|
+
branch: string,
|
|
123
|
+
tracker: IssueTracker,
|
|
124
|
+
): { ok: true; parsed: ParsedFid } | { ok: false; why: string } {
|
|
125
|
+
if (!branch.startsWith("feat/"))
|
|
126
|
+
return { ok: false, why: `branch "${branch}" is not feat/{FID}` };
|
|
127
|
+
const fid = branch.slice("feat/".length);
|
|
128
|
+
if (!SLUG.test(fid)) return { ok: false, why: `"${fid}" is not a slug (${SLUG.source})` };
|
|
129
|
+
const issueId = issueIdOf(fid, tracker);
|
|
130
|
+
if (tracker !== "none" && issueId === null) {
|
|
131
|
+
return { ok: false, why: `"${fid}" embeds no ${tracker} issue id` };
|
|
132
|
+
}
|
|
133
|
+
return { ok: true, parsed: { fid, issueId, source: "branch" } };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const TRACKER_FLAG: FlagSpec = {
|
|
137
|
+
name: "tracker",
|
|
138
|
+
type: "string",
|
|
139
|
+
help: "github | linear | none (default: package.json bkit.issueTracker, else none)",
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const fidsCommand: CommandSpec = {
|
|
143
|
+
noun: "fids",
|
|
144
|
+
summary: "Feature-id format per tracker, and FID recovery from a branch or PR-body marker.",
|
|
145
|
+
verbs: {
|
|
146
|
+
check: {
|
|
147
|
+
summary: "Validate a FID for the tracker: exit 0 valid, exit 1 not.",
|
|
148
|
+
flags: [
|
|
149
|
+
{ name: "fid", type: "string", required: true, help: "feature id to check" },
|
|
150
|
+
{ ...TRACKER_FLAG, help: `${TRACKER_FLAG.help}; any = github or linear shape (CI_DEV)` },
|
|
151
|
+
],
|
|
152
|
+
output: {
|
|
153
|
+
fid: "the FID as checked (linear: lowercased)",
|
|
154
|
+
tracker: "tracker the shape came from",
|
|
155
|
+
valid: "true when the FID matches",
|
|
156
|
+
pattern: "the regex checked",
|
|
157
|
+
issueId: "issue id the FID embeds (null under none, or when invalid)",
|
|
158
|
+
},
|
|
159
|
+
run: (ctx) => {
|
|
160
|
+
const tracker = trackerFlag(str(ctx.flags.tracker), ctx.cwd, true);
|
|
161
|
+
const fid = normaliseFid(String(ctx.flags.fid), tracker);
|
|
162
|
+
const pattern = FID_PATTERNS[tracker];
|
|
163
|
+
const valid = pattern.test(fid);
|
|
164
|
+
if (!valid) ctx.log(`FID "${fid}" does not match the ${tracker} shape ${pattern.source}`);
|
|
165
|
+
ctx.emit({
|
|
166
|
+
fid,
|
|
167
|
+
tracker,
|
|
168
|
+
valid,
|
|
169
|
+
pattern: pattern.source,
|
|
170
|
+
issueId: valid ? issueIdOf(fid, tracker) : null,
|
|
171
|
+
});
|
|
172
|
+
return valid ? EXIT.OK : EXIT.NO;
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
parse: {
|
|
176
|
+
summary: "Recover FID and issue id: the PR-body marker first, then a feat/{FID} branch.",
|
|
177
|
+
flags: [
|
|
178
|
+
{
|
|
179
|
+
name: "marker",
|
|
180
|
+
type: "string",
|
|
181
|
+
help: "text holding the bkit:fid marker (e.g. the PR body)",
|
|
182
|
+
},
|
|
183
|
+
{ name: "branch", type: "string", help: "branch name, feat/{FID}" },
|
|
184
|
+
TRACKER_FLAG,
|
|
185
|
+
],
|
|
186
|
+
output: {
|
|
187
|
+
fid: "the recovered FID",
|
|
188
|
+
issueId: "tracker issue id (null under none)",
|
|
189
|
+
source: "marker | branch",
|
|
190
|
+
tracker: "tracker the shapes came from",
|
|
191
|
+
},
|
|
192
|
+
exitCodes: { [EXIT_NO_FID]: "neither the marker nor the branch yielded a valid FID" },
|
|
193
|
+
run: (ctx) => {
|
|
194
|
+
const marker = str(ctx.flags.marker);
|
|
195
|
+
const branch = str(ctx.flags.branch);
|
|
196
|
+
if (marker === undefined && branch === undefined) {
|
|
197
|
+
throw new CommandError(EXIT.USAGE, "give --marker, --branch, or both");
|
|
198
|
+
}
|
|
199
|
+
const tracker = trackerFlag(str(ctx.flags.tracker), ctx.cwd, false) as IssueTracker;
|
|
200
|
+
const viaMarker = marker === undefined ? null : fromMarker(marker, tracker);
|
|
201
|
+
if (viaMarker) {
|
|
202
|
+
ctx.emit({ ...viaMarker, tracker });
|
|
203
|
+
return EXIT.OK;
|
|
204
|
+
}
|
|
205
|
+
if (marker !== undefined)
|
|
206
|
+
ctx.log(`no well-formed ${tracker} bkit:fid marker — trying the branch`);
|
|
207
|
+
if (branch === undefined) return EXIT_NO_FID;
|
|
208
|
+
const viaBranch = fromBranch(branch, tracker);
|
|
209
|
+
if (!viaBranch.ok) {
|
|
210
|
+
ctx.log(viaBranch.why);
|
|
211
|
+
return EXIT_NO_FID;
|
|
212
|
+
}
|
|
213
|
+
ctx.emit({ ...viaBranch.parsed, tracker });
|
|
214
|
+
return EXIT.OK;
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
find: {
|
|
218
|
+
summary: "The feature already logged for an issue: exit 0 one, exit 1 none, exit 4 several.",
|
|
219
|
+
flags: [
|
|
220
|
+
{
|
|
221
|
+
name: "issue",
|
|
222
|
+
type: "string",
|
|
223
|
+
required: true,
|
|
224
|
+
help: "tracker issue id (github: 123 or #123; linear: ABC-123)",
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
output: {
|
|
228
|
+
fid: "the one FID logged for the issue, or null",
|
|
229
|
+
fids: "every FID logged for the issue (docs/plans/*/logs/{issue}-*)",
|
|
230
|
+
},
|
|
231
|
+
exitCodes: { [EXIT_SEVERAL]: "several features are logged for the issue — name one" },
|
|
232
|
+
run: (ctx) => {
|
|
233
|
+
const fids = logged(repoRoot(ctx.cwd), String(ctx.flags.issue));
|
|
234
|
+
ctx.emit({ fid: fids.length === 1 ? fids[0] : null, fids });
|
|
235
|
+
if (fids.length > 1) {
|
|
236
|
+
ctx.log(`several features logged for ${String(ctx.flags.issue)}: ${fids.join(", ")}`);
|
|
237
|
+
return EXIT_SEVERAL;
|
|
238
|
+
}
|
|
239
|
+
return fids.length === 1 ? EXIT.OK : EXIT.NO;
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
};
|