@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,576 @@
|
|
|
1
|
+
// bkit roadmap fold|feature|mirror — rewrite the generated region of
|
|
2
|
+
// docs/roadmap.md from .bkit/issues.jsonl, its SOLE input; append a feature's
|
|
3
|
+
// row; and copy a build / debug close's row to dev under the dev lock.
|
|
4
|
+
//
|
|
5
|
+
// The status block is a pure projection of the ledger, re-rendered in full, so
|
|
6
|
+
// a close never parses the board back. The two `## Notes` blocks and the
|
|
7
|
+
// analysis block (written by the roadmap review, which a phase close does not
|
|
8
|
+
// run) are carried through verbatim. Everything above the first marker is the
|
|
9
|
+
// consumer's and kept; anything after the last marker is folded into
|
|
10
|
+
// notes-post so that block stays last. A missing notes pair is seeded with a
|
|
11
|
+
// placeholder; a non-empty body is never overwritten. A board with no markers
|
|
12
|
+
// is adopted into notes-post, and a mangled pair self-heals without removing a
|
|
13
|
+
// byte.
|
|
14
|
+
//
|
|
15
|
+
// Tracker issues are NOT rendered. Fail-open: this never exits non-zero for
|
|
16
|
+
// a bad ledger or an unwritable board, and never gates the caller's close.
|
|
17
|
+
|
|
18
|
+
import * as fs from "node:fs";
|
|
19
|
+
import * as path from "node:path";
|
|
20
|
+
|
|
21
|
+
import { compareTs, parse, resolveRepoSlug, validate } from "../../ledgers/telemetry.js";
|
|
22
|
+
import { readBkitVersion } from "../../install/version-file.js";
|
|
23
|
+
import {
|
|
24
|
+
CommandError,
|
|
25
|
+
EXIT,
|
|
26
|
+
git,
|
|
27
|
+
parseJson,
|
|
28
|
+
repoRoot,
|
|
29
|
+
runGit,
|
|
30
|
+
type CommandSpec,
|
|
31
|
+
type RunContext,
|
|
32
|
+
} from "../lib.js";
|
|
33
|
+
import { acquireDevLock, releaseLock } from "./locks.js";
|
|
34
|
+
import { str } from "./status.js";
|
|
35
|
+
|
|
36
|
+
/** Roadmap status each workflow's close moves the feature to. */
|
|
37
|
+
export const FEATURE_STATUS: Readonly<Record<string, string>> = {
|
|
38
|
+
design: "DESIGNED",
|
|
39
|
+
plan: "PLANNED",
|
|
40
|
+
build: "BUILT",
|
|
41
|
+
debug: "DEBUGGED",
|
|
42
|
+
ship: "SHIPPED",
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const MARKERS = {
|
|
46
|
+
notesPreStart: "<!-- bkit:roadmap-notes-pre start -->",
|
|
47
|
+
notesPreEnd: "<!-- bkit:roadmap-notes-pre end -->",
|
|
48
|
+
statusStart: "<!-- bkit:roadmap-status start -->",
|
|
49
|
+
statusEnd: "<!-- bkit:roadmap-status end -->",
|
|
50
|
+
notesPostStart: "<!-- bkit:roadmap-notes-post start -->",
|
|
51
|
+
notesPostEnd: "<!-- bkit:roadmap-notes-post end -->",
|
|
52
|
+
analysisStart: "<!-- bkit:roadmap-analysis start -->",
|
|
53
|
+
analysisEnd: "<!-- bkit:roadmap-analysis end -->",
|
|
54
|
+
} as const;
|
|
55
|
+
|
|
56
|
+
const ANALYSIS_PLACEHOLDER = "_(no analysis yet; run @bkit-utility-update-roadmap to populate)_";
|
|
57
|
+
const NOTES_PRE_PLACEHOLDER = "## Notes\n\n_(above the bkit list — yours, never overwritten)_";
|
|
58
|
+
const NOTES_POST_PLACEHOLDER = "## Notes\n\n_(end of the board — yours, never overwritten)_";
|
|
59
|
+
const BANNER =
|
|
60
|
+
"> Generated tables — do not hand-edit the `bkit` tables; append to `.bkit/issues.jsonl` instead (an `ABANDONED` row hides a FID from every section). `## Notes` blocks are yours and are never overwritten. Everything above the first marker is also yours. notes-post is last. Analysis list length: `package.json` key `bkit.roadmapNext` (positive integer; absent or invalid → 25).";
|
|
61
|
+
|
|
62
|
+
/** Newest SHIPPED rows on the board; older ones stay in the ledger. */
|
|
63
|
+
export const SHIPPED_ON_BOARD = 10;
|
|
64
|
+
|
|
65
|
+
type Row = Record<string, unknown> & { key: string };
|
|
66
|
+
|
|
67
|
+
export interface Projection {
|
|
68
|
+
designed: Row[];
|
|
69
|
+
planned: Row[];
|
|
70
|
+
built: Row[];
|
|
71
|
+
debugged: Row[];
|
|
72
|
+
shipped: Row[];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const SECTIONS: Array<[keyof Projection, string, string]> = [
|
|
76
|
+
["designed", "DESIGNED", "### Design"],
|
|
77
|
+
["planned", "PLANNED", "### Plan"],
|
|
78
|
+
["built", "BUILT", "### Build"],
|
|
79
|
+
["debugged", "DEBUGGED", "### Debug"],
|
|
80
|
+
["shipped", "SHIPPED", `### Shipped _(last ${SHIPPED_ON_BOARD})_`],
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
/** jq's `//`: the right side when the left is null, false or absent. */
|
|
84
|
+
const or = (a: unknown, b: unknown) => (a === undefined || a === null || a === false ? b : a);
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Fold rows by `key`, last write wins (highest `ts`, file order breaking ties),
|
|
88
|
+
* and bucket by folded status. ABANDONED is in no bucket, so it hides a FID from
|
|
89
|
+
* the whole board. SHIPPED ranks on `shippedAt`, falling back to `ts` (append time).
|
|
90
|
+
*/
|
|
91
|
+
export function project(rows: unknown[]): Projection {
|
|
92
|
+
const groups = new Map<string, Row[]>();
|
|
93
|
+
for (const r of rows) {
|
|
94
|
+
if (typeof r !== "object" || r === null || Array.isArray(r)) continue;
|
|
95
|
+
const key = (r as { key?: unknown }).key;
|
|
96
|
+
if (typeof key !== "string") continue;
|
|
97
|
+
groups.set(key, [...(groups.get(key) ?? []), r as Row]);
|
|
98
|
+
}
|
|
99
|
+
const latest = [...groups.keys()]
|
|
100
|
+
.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
|
|
101
|
+
.map((k) => [...groups.get(k)!].sort((a, b) => compareTs({ ts: a.ts }, { ts: b.ts })).at(-1)!);
|
|
102
|
+
const by = (status: string) => latest.filter((r) => r.status === status);
|
|
103
|
+
return {
|
|
104
|
+
designed: by("DESIGNED"),
|
|
105
|
+
planned: by("PLANNED"),
|
|
106
|
+
built: by("BUILT"),
|
|
107
|
+
debugged: by("DEBUGGED"),
|
|
108
|
+
shipped: by("SHIPPED")
|
|
109
|
+
.sort((a, b) => compareTs({ ts: or(b.shippedAt, b.ts) }, { ts: or(a.shippedAt, a.ts) }))
|
|
110
|
+
.slice(0, SHIPPED_ON_BOARD),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** jq's string interpolation of a scalar. */
|
|
115
|
+
const cell = (v: unknown) =>
|
|
116
|
+
typeof v === "string" ? v : v === undefined ? "null" : JSON.stringify(v);
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* `FID | Title | Last-transition (ts)`. Milestone and blocked-by are not on a
|
|
120
|
+
* feature row and are not columns.
|
|
121
|
+
*/
|
|
122
|
+
function table(rows: Row[]): string[] {
|
|
123
|
+
if (rows.length === 0) return ["_(none)_"];
|
|
124
|
+
return [
|
|
125
|
+
"<!-- prettier-ignore -->",
|
|
126
|
+
"| FID | Title | Last-transition (ts) |",
|
|
127
|
+
"| --- | --- | --- |",
|
|
128
|
+
...rows.map(
|
|
129
|
+
(r) => `| ${cell(r.key)} | ${cell(or(r.summary, r.key))} | ${cell(or(r.shippedAt, r.ts))} |`,
|
|
130
|
+
),
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function statusBlock(p: Projection, now: string): string {
|
|
135
|
+
const out = [BANNER, "", "## bkit", "", `_(refreshed ${now})_`];
|
|
136
|
+
for (const [bucket, , heading] of SECTIONS) out.push("", heading, "", ...table(p[bucket]));
|
|
137
|
+
return out.join("\n");
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ---------------------------------------------------------------------------
|
|
141
|
+
// Region surgery on the existing board
|
|
142
|
+
// ---------------------------------------------------------------------------
|
|
143
|
+
|
|
144
|
+
const blank = (s: string) => /^[ \t\n\r\v\f]*$/.test(s);
|
|
145
|
+
const stripTrailingNewlines = (s: string) => s.replace(/\n+$/, "");
|
|
146
|
+
|
|
147
|
+
/** Drop leading and trailing blank lines, so a region read back never gains one per regenerate. */
|
|
148
|
+
function trimBlankLines(lines: string[]): string {
|
|
149
|
+
let a = 0;
|
|
150
|
+
while (a < lines.length && blank(lines[a]!)) a++;
|
|
151
|
+
let b = lines.length;
|
|
152
|
+
while (b > a && blank(lines[b - 1]!)) b--;
|
|
153
|
+
return lines.slice(a, b).join("\n");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Lines as `grep -n` / `sed` number them: a final newline ends the last line. */
|
|
157
|
+
const fileLines = (text: string) => (text === "" ? [] : text.replace(/\n$/, "").split("\n"));
|
|
158
|
+
|
|
159
|
+
const firstWith = (lines: string[], m: string) => lines.findIndex((l) => l.includes(m));
|
|
160
|
+
const lastWith = (lines: string[], m: string) => {
|
|
161
|
+
for (let i = lines.length - 1; i >= 0; i--) if (lines[i]!.includes(m)) return i;
|
|
162
|
+
return -1;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/** Text strictly between the first `start` and the last `end`; undefined when absent or out of order. */
|
|
166
|
+
function between(lines: string[], start: string, end: string): string | undefined {
|
|
167
|
+
const s = firstWith(lines, start);
|
|
168
|
+
const e = lastWith(lines, end);
|
|
169
|
+
if (s === -1 || e === -1 || s >= e) return undefined;
|
|
170
|
+
return stripTrailingNewlines(lines.slice(s + 1, e).join("\n"));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const carried = (lines: string[], start: string, end: string, placeholder: string) => {
|
|
174
|
+
const body = between(lines, start, end) ?? "";
|
|
175
|
+
return blank(body) ? placeholder : body;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/** `extra` under `base`, blank-separated; never drops `base`. */
|
|
179
|
+
function appendNotes(base: string, extra: string): string {
|
|
180
|
+
if (blank(extra)) return stripTrailingNewlines(base);
|
|
181
|
+
if (blank(base)) return stripTrailingNewlines(extra);
|
|
182
|
+
return stripTrailingNewlines(`${base}\n\n${extra}`);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface FoldResult {
|
|
186
|
+
board: string;
|
|
187
|
+
log: string[];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** The whole new docs/roadmap.md, from the ledger rows and the current board (undefined = none). */
|
|
191
|
+
export function foldBoard(p: Projection, current: string | undefined, now: string): FoldResult {
|
|
192
|
+
const log: string[] = [];
|
|
193
|
+
const lines = current === undefined ? [] : fileLines(current);
|
|
194
|
+
const notesPre = carried(
|
|
195
|
+
lines,
|
|
196
|
+
MARKERS.notesPreStart,
|
|
197
|
+
MARKERS.notesPreEnd,
|
|
198
|
+
NOTES_PRE_PLACEHOLDER,
|
|
199
|
+
);
|
|
200
|
+
let notesPost = carried(
|
|
201
|
+
lines,
|
|
202
|
+
MARKERS.notesPostStart,
|
|
203
|
+
MARKERS.notesPostEnd,
|
|
204
|
+
NOTES_POST_PLACEHOLDER,
|
|
205
|
+
);
|
|
206
|
+
const analysisBody = between(lines, MARKERS.analysisStart, MARKERS.analysisEnd) ?? "";
|
|
207
|
+
const analysis = blank(analysisBody) ? ANALYSIS_PLACEHOLDER : analysisBody;
|
|
208
|
+
|
|
209
|
+
let head = "";
|
|
210
|
+
let tail = "";
|
|
211
|
+
let adopted = "";
|
|
212
|
+
if (current !== undefined) {
|
|
213
|
+
const starts = [
|
|
214
|
+
MARKERS.notesPreStart,
|
|
215
|
+
MARKERS.statusStart,
|
|
216
|
+
MARKERS.notesPostStart,
|
|
217
|
+
MARKERS.analysisStart,
|
|
218
|
+
]
|
|
219
|
+
.map((m) => firstWith(lines, m))
|
|
220
|
+
.filter((i) => i !== -1);
|
|
221
|
+
const ends = [MARKERS.notesPreEnd, MARKERS.statusEnd, MARKERS.notesPostEnd, MARKERS.analysisEnd]
|
|
222
|
+
.map((m) => lastWith(lines, m))
|
|
223
|
+
.filter((i) => i !== -1);
|
|
224
|
+
const firstStart = starts.length ? Math.min(...starts) : -1;
|
|
225
|
+
const lastEnd = ends.length ? Math.max(...ends) : -1;
|
|
226
|
+
if (firstStart > 0) head = trimBlankLines(lines.slice(0, firstStart));
|
|
227
|
+
if (lastEnd !== -1) {
|
|
228
|
+
tail = trimBlankLines(lines.slice(lastEnd + 1));
|
|
229
|
+
} else if (firstStart !== -1) {
|
|
230
|
+
// Start marker with no end: where bkit's region stops is unknowable, so
|
|
231
|
+
// everything after it is the consumer's. A self-heal never removes a byte.
|
|
232
|
+
adopted = trimBlankLines(lines.slice(firstStart + 1));
|
|
233
|
+
log.push(
|
|
234
|
+
"repairing mangled marker pair — content below the orphaned start marker preserved under notes-post",
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
if (firstStart === -1 && lastEnd === -1) {
|
|
238
|
+
adopted = stripTrailingNewlines(current);
|
|
239
|
+
log.push(
|
|
240
|
+
"pre-existing docs/roadmap.md had no marker pair — its content is preserved under notes-post",
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
} else {
|
|
244
|
+
log.push("bootstrapping docs/roadmap.md");
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// The head is the consumer's once the file exists: bkit seeds a title and
|
|
248
|
+
// never rewrites it. The generated-tables warning lives in the status block,
|
|
249
|
+
// so its wording stays true as the region's rules change.
|
|
250
|
+
if (blank(head)) head = "# Roadmap";
|
|
251
|
+
|
|
252
|
+
let merge = adopted;
|
|
253
|
+
if (!blank(tail)) merge = appendNotes(merge, tail);
|
|
254
|
+
if (!blank(merge)) notesPost = appendNotes(notesPost, merge);
|
|
255
|
+
|
|
256
|
+
const board = [
|
|
257
|
+
`${head}\n`,
|
|
258
|
+
MARKERS.notesPreStart,
|
|
259
|
+
notesPre,
|
|
260
|
+
`${MARKERS.notesPreEnd}\n`,
|
|
261
|
+
MARKERS.statusStart,
|
|
262
|
+
statusBlock(p, now),
|
|
263
|
+
`${MARKERS.statusEnd}\n`,
|
|
264
|
+
MARKERS.analysisStart,
|
|
265
|
+
analysis,
|
|
266
|
+
`${MARKERS.analysisEnd}\n`,
|
|
267
|
+
MARKERS.notesPostStart,
|
|
268
|
+
notesPost,
|
|
269
|
+
MARKERS.notesPostEnd,
|
|
270
|
+
].join("\n");
|
|
271
|
+
return { board: `${board}\n`, log };
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const EMPTY: Projection = { designed: [], planned: [], built: [], debugged: [], shipped: [] };
|
|
275
|
+
|
|
276
|
+
export interface RoadmapFold {
|
|
277
|
+
path: string;
|
|
278
|
+
written: boolean;
|
|
279
|
+
counts: Record<string, number>;
|
|
280
|
+
malformed: number;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** Re-render `<root>/docs/roadmap.md` from `<root>/.bkit/issues.jsonl`; never throws for a bad ledger or board. */
|
|
284
|
+
export function foldRoadmap(root: string, log: (m: string) => void): RoadmapFold {
|
|
285
|
+
const md = path.join(root, "docs", "roadmap.md");
|
|
286
|
+
const ledger = path.join(root, ".bkit", "issues.jsonl");
|
|
287
|
+
const now = new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
288
|
+
|
|
289
|
+
let projection = EMPTY;
|
|
290
|
+
let malformed = 0;
|
|
291
|
+
const raw =
|
|
292
|
+
fs.existsSync(ledger) && fs.statSync(ledger).isFile() ? fs.readFileSync(ledger, "utf-8") : "";
|
|
293
|
+
if (raw === "") {
|
|
294
|
+
log(".bkit/issues.jsonl absent or empty — status board will be empty (never blocked)");
|
|
295
|
+
} else {
|
|
296
|
+
const parsed = parse(raw);
|
|
297
|
+
malformed = parsed.malformedLineCount;
|
|
298
|
+
// One torn line skips that row only; the board keeps every row that parses.
|
|
299
|
+
if (malformed > 0) log(`.bkit/issues.jsonl: ${malformed} malformed line(s) skipped`);
|
|
300
|
+
projection = project(parsed.events);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const current =
|
|
304
|
+
fs.existsSync(md) && fs.statSync(md).isFile() ? fs.readFileSync(md, "utf-8") : undefined;
|
|
305
|
+
const { board, log: foldLog } = foldBoard(projection, current, now);
|
|
306
|
+
for (const line of foldLog) log(line);
|
|
307
|
+
const problem = writeBoard(md, board);
|
|
308
|
+
if (problem) log(`could not write ${md} — board left as-is (fail-open): ${problem}`);
|
|
309
|
+
return {
|
|
310
|
+
path: md,
|
|
311
|
+
written: problem === undefined,
|
|
312
|
+
counts: Object.fromEntries(SECTIONS.map(([bucket]) => [bucket, projection[bucket].length])),
|
|
313
|
+
malformed,
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function fold(ctx: RunContext): number {
|
|
318
|
+
ctx.emit({ ...foldRoadmap(path.resolve(ctx.cwd, str(ctx.flags.root) ?? "."), ctx.log) });
|
|
319
|
+
return EXIT.OK;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** The `kind: "feature"` ledger row a phase writes when it moves the feature on. */
|
|
323
|
+
export function featureRow(
|
|
324
|
+
root: string,
|
|
325
|
+
o: { workflow: string; fid: string; status: string; step: string },
|
|
326
|
+
): Record<string, unknown> {
|
|
327
|
+
const phase = o.workflow.charAt(0).toUpperCase() + o.workflow.slice(1);
|
|
328
|
+
return {
|
|
329
|
+
ts: Date.now(),
|
|
330
|
+
kind: "feature",
|
|
331
|
+
repo: resolveRepoSlug(root) || "unknown/repo",
|
|
332
|
+
bkitVersion: readBkitVersion(path.join(root, ".bkit", "version"))?.pinnedVersion || "unknown",
|
|
333
|
+
workflow: o.workflow,
|
|
334
|
+
step: o.step,
|
|
335
|
+
key: o.fid,
|
|
336
|
+
category: "agentic",
|
|
337
|
+
description: `${phase} closed for ${o.fid}`,
|
|
338
|
+
status: o.status,
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/** Append one row to `<root>/.bkit/issues.jsonl`; the failure reason, or undefined. Fail-open by contract. */
|
|
343
|
+
function appendLedgerRow(root: string, row: Record<string, unknown>): string | undefined {
|
|
344
|
+
const file = path.join(root, ".bkit", "issues.jsonl");
|
|
345
|
+
try {
|
|
346
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
347
|
+
fs.appendFileSync(file, `${JSON.stringify(row)}\n`);
|
|
348
|
+
return undefined;
|
|
349
|
+
} catch (err) {
|
|
350
|
+
// Fail-open: the caller logs it and the close carries on.
|
|
351
|
+
return (err as Error).message;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export interface FeatureResult {
|
|
356
|
+
row: Record<string, unknown>;
|
|
357
|
+
appended: boolean;
|
|
358
|
+
written: boolean;
|
|
359
|
+
path: string;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Append the feature's roadmap row (built from `workflow` / `fid`, or `row` as
|
|
364
|
+
* given) under `root`, then re-render the board. Fail-open: a failed append or
|
|
365
|
+
* render is logged and reported, never thrown.
|
|
366
|
+
*/
|
|
367
|
+
export function appendFeature(
|
|
368
|
+
root: string,
|
|
369
|
+
o: { workflow?: string; fid?: string; status?: string; step?: string; row?: string },
|
|
370
|
+
log: (m: string) => void,
|
|
371
|
+
): FeatureResult {
|
|
372
|
+
let row: Record<string, unknown>;
|
|
373
|
+
if (o.row !== undefined) {
|
|
374
|
+
const parsed = parseJson(o.row);
|
|
375
|
+
if (!parsed.ok || typeof parsed.value !== "object" || parsed.value === null) {
|
|
376
|
+
throw new CommandError(EXIT.USAGE, "--row must be one JSON object");
|
|
377
|
+
}
|
|
378
|
+
row = parsed.value as Record<string, unknown>;
|
|
379
|
+
} else {
|
|
380
|
+
if (!o.workflow || !o.fid)
|
|
381
|
+
throw new CommandError(EXIT.USAGE, "give --row, or --workflow and --fid");
|
|
382
|
+
const status = o.status ?? FEATURE_STATUS[o.workflow];
|
|
383
|
+
if (!status)
|
|
384
|
+
throw new CommandError(EXIT.USAGE, `--status is required for workflow ${o.workflow}`);
|
|
385
|
+
row = featureRow(root, {
|
|
386
|
+
workflow: o.workflow,
|
|
387
|
+
fid: o.fid,
|
|
388
|
+
status,
|
|
389
|
+
step: o.step ?? `${o.workflow}-close-workflow`,
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
const check = validate(row);
|
|
393
|
+
if (!check.ok) throw new CommandError(EXIT.USAGE, `not a valid feature row: ${check.reason}`);
|
|
394
|
+
const problem = appendLedgerRow(root, row);
|
|
395
|
+
if (problem) log(`append failed: ${path.join(root, ".bkit", "issues.jsonl")} — ${problem}`);
|
|
396
|
+
const board = foldRoadmap(root, log);
|
|
397
|
+
return { row, appended: problem === undefined, written: board.written, path: board.path };
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function feature(ctx: RunContext): number {
|
|
401
|
+
const r = appendFeature(
|
|
402
|
+
path.resolve(ctx.cwd, str(ctx.flags.root) ?? "."),
|
|
403
|
+
{
|
|
404
|
+
workflow: str(ctx.flags.workflow),
|
|
405
|
+
fid: str(ctx.flags.fid),
|
|
406
|
+
status: str(ctx.flags.status),
|
|
407
|
+
step: str(ctx.flags.step),
|
|
408
|
+
row: str(ctx.flags.row),
|
|
409
|
+
},
|
|
410
|
+
ctx.log,
|
|
411
|
+
);
|
|
412
|
+
ctx.emit({ ...r });
|
|
413
|
+
return ctx.flags.strict === true && !r.appended ? EXIT.NO : EXIT.OK;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/** Seconds the mirror waits for a busy dev lock before skipping. */
|
|
417
|
+
export const MIRROR_DEV_LOCK_DEADLINE_S = 60;
|
|
418
|
+
|
|
419
|
+
const ROADMAP_FILES = [".bkit/issues.jsonl", "docs/roadmap.md"];
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Build / debug close: append the feature row in the worktree, then copy the
|
|
423
|
+
* SAME row to `dev` in the main checkout under the dev lock — checkout dev,
|
|
424
|
+
* fast-forward, append, commit the two roadmap files, push, return to the prior
|
|
425
|
+
* branch. Skipped in adopt mode (the worktree IS the main checkout) and when the
|
|
426
|
+
* dev lock stays busy. Fail-open throughout: the feat-side row is already written.
|
|
427
|
+
*/
|
|
428
|
+
async function mirror(ctx: RunContext): Promise<number> {
|
|
429
|
+
const workflow = String(ctx.flags.workflow);
|
|
430
|
+
const fid = String(ctx.flags.fid);
|
|
431
|
+
const wt = git(ctx.cwd, ["rev-parse", "--show-toplevel"]) ?? ctx.cwd;
|
|
432
|
+
const root = repoRoot(ctx.cwd);
|
|
433
|
+
const feat = appendFeature(wt, { workflow, fid }, ctx.log);
|
|
434
|
+
const done = (mirrored: boolean, skipped: string | null) => {
|
|
435
|
+
if (skipped)
|
|
436
|
+
ctx.log(`skipping the dev-side roadmap mirror — ${skipped} (feat-side row already written)`);
|
|
437
|
+
ctx.emit({ row: feat.row, appended: feat.appended, mirrored, skipped });
|
|
438
|
+
return EXIT.OK;
|
|
439
|
+
};
|
|
440
|
+
if (path.resolve(wt) === path.resolve(root)) return done(false, "adopt mode");
|
|
441
|
+
|
|
442
|
+
let lock: { path: string; token: string };
|
|
443
|
+
try {
|
|
444
|
+
lock = await acquireDevLock({
|
|
445
|
+
cwd: root,
|
|
446
|
+
workflow,
|
|
447
|
+
fid,
|
|
448
|
+
deadlineS: MIRROR_DEV_LOCK_DEADLINE_S,
|
|
449
|
+
log: ctx.log,
|
|
450
|
+
});
|
|
451
|
+
} catch (err) {
|
|
452
|
+
// A busy lock skips the mirror; it never fails the close.
|
|
453
|
+
return done(false, `dev lock busy: ${(err as Error).message}`);
|
|
454
|
+
}
|
|
455
|
+
try {
|
|
456
|
+
const prior = git(root, ["branch", "--show-current"]) ?? "";
|
|
457
|
+
if (
|
|
458
|
+
!runGit(root, ["checkout", "dev"]).ok ||
|
|
459
|
+
!runGit(root, ["pull", "--ff-only", "origin", "dev"]).ok
|
|
460
|
+
) {
|
|
461
|
+
if (prior) runGit(root, ["checkout", prior]);
|
|
462
|
+
return done(false, "dev checkout / pull failed");
|
|
463
|
+
}
|
|
464
|
+
const onDev = appendFeature(root, { row: JSON.stringify(feat.row) }, ctx.log);
|
|
465
|
+
if (!onDev.appended) ctx.log("roadmap row skipped on dev");
|
|
466
|
+
runGit(root, ["add", "--", ...ROADMAP_FILES]);
|
|
467
|
+
runGit(root, [
|
|
468
|
+
"commit",
|
|
469
|
+
"--allow-empty",
|
|
470
|
+
"-m",
|
|
471
|
+
`docs(${fid}): ${workflow} roadmap update bkit [skip ci]`,
|
|
472
|
+
"--",
|
|
473
|
+
...ROADMAP_FILES,
|
|
474
|
+
]);
|
|
475
|
+
const pushed = runGit(root, ["push", "origin", "dev"]).ok;
|
|
476
|
+
if (!pushed) ctx.log("dev push failed — feat-side row already written");
|
|
477
|
+
if (prior) runGit(root, ["checkout", prior]);
|
|
478
|
+
return done(pushed, pushed ? null : "dev push failed");
|
|
479
|
+
} finally {
|
|
480
|
+
releaseLock(lock.path, { workflow, fid, token: lock.token });
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
function writeBoard(md: string, board: string): string | undefined {
|
|
485
|
+
const tmp = `${md}.roadmap-tmp.${process.pid}`;
|
|
486
|
+
try {
|
|
487
|
+
fs.mkdirSync(path.dirname(md), { recursive: true });
|
|
488
|
+
fs.writeFileSync(tmp, board);
|
|
489
|
+
fs.renameSync(tmp, md);
|
|
490
|
+
return undefined;
|
|
491
|
+
} catch (err) {
|
|
492
|
+
// Fail-open by contract: the caller logs it and the close carries on.
|
|
493
|
+
fs.rmSync(tmp, { force: true });
|
|
494
|
+
return (err as Error).message;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
export const roadmapCommand: CommandSpec = {
|
|
499
|
+
noun: "roadmap",
|
|
500
|
+
summary: "Re-render docs/roadmap.md's generated region from .bkit/issues.jsonl (fail-open).",
|
|
501
|
+
verbs: {
|
|
502
|
+
fold: {
|
|
503
|
+
summary: "Rewrite the status tables; carry notes, analysis and the consumer's head through.",
|
|
504
|
+
flags: [
|
|
505
|
+
{
|
|
506
|
+
name: "root",
|
|
507
|
+
type: "string",
|
|
508
|
+
help: "checkout holding docs/ and .bkit/ (default: the working directory)",
|
|
509
|
+
},
|
|
510
|
+
],
|
|
511
|
+
output: {
|
|
512
|
+
path: "docs/roadmap.md, absolute",
|
|
513
|
+
written: "false when the board could not be written (left as it was)",
|
|
514
|
+
counts: "rows per section: designed, planned, built, debugged, shipped",
|
|
515
|
+
malformed: "ledger lines that did not parse (skipped)",
|
|
516
|
+
},
|
|
517
|
+
run: (ctx) => fold(ctx),
|
|
518
|
+
},
|
|
519
|
+
feature: {
|
|
520
|
+
summary:
|
|
521
|
+
"Append the feature's roadmap row to .bkit/issues.jsonl, then re-render the board (fail-open).",
|
|
522
|
+
flags: [
|
|
523
|
+
{
|
|
524
|
+
name: "root",
|
|
525
|
+
type: "string",
|
|
526
|
+
help: "checkout holding docs/ and .bkit/ (default: the working directory)",
|
|
527
|
+
},
|
|
528
|
+
{ name: "workflow", type: "string", help: "design|plan|build|debug|ship" },
|
|
529
|
+
{ name: "fid", type: "string", help: "feature id (the row's key)" },
|
|
530
|
+
{
|
|
531
|
+
name: "status",
|
|
532
|
+
type: "string",
|
|
533
|
+
help: "roadmap status (default: the workflow's — DESIGNED, PLANNED, BUILT, DEBUGGED, SHIPPED)",
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
name: "step",
|
|
537
|
+
type: "string",
|
|
538
|
+
help: "step recorded on the row (default <workflow>-close-workflow)",
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
name: "row",
|
|
542
|
+
type: "string",
|
|
543
|
+
help: "append this row as given (a row an earlier call printed), instead of building one",
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
name: "strict",
|
|
547
|
+
type: "boolean",
|
|
548
|
+
help: "exit 1 when the row could not be appended (default: fail-open, exit 0)",
|
|
549
|
+
},
|
|
550
|
+
],
|
|
551
|
+
output: {
|
|
552
|
+
row: "the row appended",
|
|
553
|
+
appended: "false when the ledger could not be written (logged; never fails)",
|
|
554
|
+
written: "false when the board could not be written",
|
|
555
|
+
path: "docs/roadmap.md, absolute",
|
|
556
|
+
},
|
|
557
|
+
run: (ctx) => feature(ctx),
|
|
558
|
+
},
|
|
559
|
+
mirror: {
|
|
560
|
+
summary:
|
|
561
|
+
"Build / debug close: append the feature row in the worktree, then the same row on dev under the dev lock (fail-open).",
|
|
562
|
+
flags: [
|
|
563
|
+
{ name: "workflow", type: "string", required: true, help: "build | debug" },
|
|
564
|
+
{ name: "fid", type: "string", required: true, help: "feature id (the row's key)" },
|
|
565
|
+
],
|
|
566
|
+
output: {
|
|
567
|
+
row: "the row appended (worktree and dev)",
|
|
568
|
+
appended: "false when the worktree ledger could not be written",
|
|
569
|
+
mirrored: "the row was committed and pushed on dev",
|
|
570
|
+
skipped:
|
|
571
|
+
"why the dev side was skipped: adopt mode | dev lock busy | dev checkout / pull failed | dev push failed (null when mirrored)",
|
|
572
|
+
},
|
|
573
|
+
run: (ctx) => mirror(ctx),
|
|
574
|
+
},
|
|
575
|
+
},
|
|
576
|
+
};
|