@cbartens/bkit 6.1.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.bkit/README.md +14 -12
- package/.bkit/core/.agents/docs.md +1 -11
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-gateguard.cjs +30 -9
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +25 -27
- package/.bkit/core/.agents/rules.md +22 -9
- package/.bkit/core/.bkit/README.md +13 -11
- package/.bkit/core/.bkit/authoring.md +58 -13
- package/.bkit/core/.bkit/cli.md +43 -33
- package/.bkit/core/.bkit/cloud.md +93 -30
- package/.bkit/core/.bkit/install.md +55 -16
- package/.bkit/core/.bkit/jsonl.md +24 -7
- package/.bkit/core/.bkit/pipeline.md +8 -8
- package/.bkit/core/.bkit/prompts.md +160 -43
- package/.bkit/core/.bkit/providers.md +99 -36
- package/.bkit/core/.bkit/templates.md +167 -37
- package/.bkit/core/.bkit/trackers.md +39 -6
- package/.bkit/core/.bkit/workflows.md +344 -136
- package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +50 -27
- package/.bkit/core/.claude/hooks/bkit-preflight.sh +11 -11
- package/.bkit/core/.codex/hooks/bkit-gateguard.cjs +13 -8
- package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +14 -25
- package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +20 -9
- package/.bkit/core/.cursor/hooks/bkit-preflight.sh +8 -8
- package/.bkit/core/.opencode/plugin/bkit-gateguard.js +14 -4
- package/.bkit/core/.opencode/plugin/bkit-guardrails.js +114 -0
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +30 -6
- package/.bkit/core/docs/templates/bkit-audit-agents.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-config.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-cost.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-database.md +3 -3
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +3 -3
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +32 -2
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-failures.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-gates.md +5 -3
- package/.bkit/core/docs/templates/bkit-audit-issues.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-llm.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-logs.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-models.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-repo.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-security.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-slop.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-testing.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-usability.md +1 -1
- package/.bkit/core/docs/templates/bkit-plan.md +38 -8
- package/.bkit/core/engine/checks/after/auth.ts +118 -47
- package/.bkit/core/engine/checks/after/github.ts +161 -37
- package/.bkit/core/engine/checks/after/index.ts +18 -3
- package/.bkit/core/engine/checks/after/tools.ts +245 -1
- package/.bkit/core/engine/checks/before/files.ts +59 -1
- package/.bkit/core/engine/checks/before/index.ts +8 -0
- package/.bkit/core/engine/checks/status-holes.ts +20 -26
- package/.bkit/core/engine/checks/tips/catalogue.ts +107 -10
- package/.bkit/core/engine/checks/tips/detect.ts +36 -3
- package/.bkit/core/engine/checks/tips/index.ts +1 -1
- package/.bkit/core/engine/cli.ts +13 -13
- package/.bkit/core/engine/commands/ci/ci.ts +124 -19
- package/.bkit/core/engine/commands/ci/push-gate.ts +101 -43
- package/.bkit/core/engine/commands/install/doctor.ts +5 -5
- package/.bkit/core/engine/commands/install/install.ts +28 -25
- package/.bkit/core/engine/commands/install/uninstall.ts +42 -30
- package/.bkit/core/engine/commands/install/upgrade.ts +14 -2
- package/.bkit/core/engine/commands/land.ts +2 -3
- package/.bkit/core/engine/commands/lib.ts +394 -39
- package/.bkit/core/engine/commands/registry.ts +1 -1
- package/.bkit/core/engine/commands/workflow/branches.ts +351 -78
- package/.bkit/core/engine/commands/workflow/challenge.ts +63 -14
- package/.bkit/core/engine/commands/workflow/context.ts +71 -10
- package/.bkit/core/engine/commands/workflow/counters.ts +298 -23
- package/.bkit/core/engine/commands/workflow/decisions.ts +260 -125
- package/.bkit/core/engine/commands/workflow/disk.ts +2 -1
- package/.bkit/core/engine/commands/workflow/feature-base.ts +66 -0
- package/.bkit/core/engine/commands/workflow/issues.ts +312 -17
- package/.bkit/core/engine/commands/workflow/junit.ts +204 -0
- package/.bkit/core/engine/commands/workflow/ledgers.ts +904 -99
- package/.bkit/core/engine/commands/workflow/locks.ts +186 -29
- package/.bkit/core/engine/commands/workflow/loops.ts +87 -0
- package/.bkit/core/engine/commands/workflow/open-decision.ts +251 -0
- package/.bkit/core/engine/commands/workflow/plan-blocks.ts +8 -0
- package/.bkit/core/engine/commands/workflow/plans.ts +1 -1
- package/.bkit/core/engine/commands/workflow/prs.ts +311 -16
- package/.bkit/core/engine/commands/workflow/repo.ts +1 -1
- package/.bkit/core/engine/commands/workflow/run-facts.ts +6 -0
- package/.bkit/core/engine/commands/workflow/runs.ts +877 -174
- package/.bkit/core/engine/commands/workflow/runtime.ts +12 -4
- package/.bkit/core/engine/commands/workflow/status.ts +324 -11
- package/.bkit/core/engine/commands/workflow/step-table.ts +41 -15
- package/.bkit/core/engine/commands/workflow/steps.ts +604 -29
- package/.bkit/core/engine/commands/workflow/summary-findings.ts +1 -1
- package/.bkit/core/engine/commands/workflow/summary.ts +314 -8
- package/.bkit/core/engine/commands/workflow/tasks.ts +400 -27
- package/.bkit/core/engine/commands/workflow/tests-base.ts +319 -0
- package/.bkit/core/engine/commands/workflow/tests-changed.ts +138 -74
- package/.bkit/core/engine/commands/workflow/tests-jump.ts +93 -0
- package/.bkit/core/engine/commands/workflow/tests.ts +815 -182
- package/.bkit/core/engine/commands/workflow/tracker.ts +1134 -137
- package/.bkit/core/engine/commands/workflow/workflows.ts +100 -72
- package/.bkit/core/engine/commands/workflow/worktrees.ts +421 -57
- package/.bkit/core/engine/install/cloud-env.ts +38 -10
- package/.bkit/core/engine/install/managed-block.ts +105 -0
- package/.bkit/core/engine/install/manifest.ts +7 -1
- package/.bkit/core/engine/install/modules/claude.ts +6 -2
- package/.bkit/core/engine/install/modules/cloud.ts +84 -95
- package/.bkit/core/engine/install/modules/codex.ts +10 -2
- package/.bkit/core/engine/install/modules/core.ts +202 -26
- package/.bkit/core/engine/install/modules/opencode.ts +18 -23
- package/.bkit/core/engine/install/network-allowlist.ts +8 -3
- package/.bkit/core/engine/install/project-docs.ts +650 -0
- package/.bkit/core/engine/install/template-copies.ts +58 -5
- package/.bkit/core/engine/install/write.ts +128 -7
- package/.bkit/core/engine/ledgers/journal.ts +18 -10
- package/.bkit/core/engine/ledgers/migrate.ts +20 -8
- package/.bkit/core/engine/ledgers/status.ts +604 -8
- package/.bkit/core/engine/ledgers/telemetry.ts +115 -13
- package/.bkit/core/engine/render/trackers.ts +46 -11
- package/.bkit/core/engine/shared/package-manager.ts +7 -3
- package/.bkit/core/engine/shared/settings.ts +12 -1
- package/.bkit/core/engine/shared/text.ts +14 -0
- package/.bkit/core/engine/tools/instructions-sources.ts +1 -0
- package/.bkit/core/engine/tools/instructions.ts +116 -20
- package/.bkit/core/hooks/antigravity-hook.js +20 -4
- package/.bkit/core/hooks/gateguard-edit-payload.js +8 -5
- package/.bkit/core/hooks/gateguard-engine.js +249 -23
- package/.bkit/core/hooks/guardrails-deny.js +167 -0
- package/.bkit/core/hooks/guardrails-read.js +3 -3
- package/.bkit/core/hooks/guardrails-shell.js +1122 -167
- package/.bkit/core/hooks/guardrails-tiers.js +247 -176
- package/.bkit/core/hooks/preflight-tracker.sh +219 -0
- package/.bkit/core/prompts/bkit-audit-generate.md +23 -6
- package/.bkit/core/prompts/bkit-build-challenge-1.md +5 -4
- package/.bkit/core/prompts/bkit-build-challenge-2.md +6 -5
- package/.bkit/core/prompts/bkit-build-install-skills.md +2 -2
- package/.bkit/core/prompts/bkit-build-plan-convert.md +21 -7
- package/.bkit/core/prompts/bkit-build-plan-current.md +5 -4
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +22 -17
- package/.bkit/core/prompts/bkit-build-plan-tasks.md +16 -12
- package/.bkit/core/prompts/bkit-build-plan-tests.md +14 -10
- package/.bkit/core/prompts/bkit-build-plan-verify.md +21 -8
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +10 -5
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +22 -6
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +19 -3
- package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +22 -6
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +10 -7
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +3 -3
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +4 -4
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +3 -3
- package/.bkit/core/prompts/bkit-design-generate.md +6 -4
- package/.bkit/core/prompts/bkit-design-organise.md +4 -3
- package/.bkit/core/prompts/bkit-design-review-1.md +5 -4
- package/.bkit/core/prompts/bkit-design-review-2.md +6 -5
- package/.bkit/core/prompts/bkit-design-spike.md +4 -3
- package/.bkit/core/prompts/bkit-design-update.md +6 -4
- package/.bkit/core/prompts/bkit-plan-generate.md +35 -14
- package/.bkit/core/prompts/bkit-plan-review-1.md +9 -7
- package/.bkit/core/prompts/bkit-plan-review-2.md +9 -7
- package/.bkit/core/prompts/bkit-plan-scope-check.md +8 -6
- package/.bkit/core/prompts/bkit-plan-update.md +22 -8
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +11 -8
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +9 -5
- package/.bkit/core/prompts/bkit-ship-update-docs.md +26 -4
- package/.bkit/core/prompts/bkit-utility-compress-markdown.md +3 -3
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +10 -7
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +8 -5
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +31 -7
- package/.bkit/core/prompts/bkit-utility-update-failures.md +8 -5
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +10 -7
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +4 -4
- package/.bkit/core/prompts/bkit-utility-update-tracker.md +4 -4
- package/.bkit/core/workflows/bkit-auto.md +23 -11
- package/.bkit/core/workflows/bkit-build.md +331 -100
- package/.bkit/core/workflows/bkit-debug.md +135 -64
- package/.bkit/core/workflows/bkit-design.md +58 -32
- package/.bkit/core/workflows/bkit-plan.md +73 -45
- package/.bkit/core/workflows/bkit-ship.md +233 -167
- package/.bkit/shared/.agents/plugins/bkit/hooks.json +1 -1
- package/.bkit/shared/.bkit/.env.example +5 -0
- package/.bkit/shared/.claude/bkit-cloud.md +7 -7
- package/.bkit/shared/.claude/settings.json +5 -1
- package/.bkit/shared/.cursor/bkit-cloud.md +1 -1
- package/.bkit/shared/.cursor/hooks.json +1 -1
- package/.bkit/shared/.opencode/opencode.json +11 -2
- package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +27 -0
- package/.bkit/templates/.cursor/Dockerfile +7 -7
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-idea.yml +1 -1
- package/.bkit/templates/.github/dependabot.yml +5 -0
- package/.bkit/templates/.github/renovate.json5 +5 -3
- package/.bkit/templates/.github/workflows/bkit-ci.yml +11 -11
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +525 -161
- package/.bkit/templates/.github/workflows/bkit-renovate.yml +2 -2
- package/.bkit/templates/.husky/pre-push +123 -6
- package/.bkit/templates/context/bkit-serena.md +1 -1
- package/.bkit/templates/context/bkit-vercel.md +103 -59
- package/.bkit/templates/docs/architecture.md +98 -0
- package/.bkit/templates/docs/capabilities.md +33 -37
- package/.bkit/templates/docs/components.md +142 -0
- package/.bkit/templates/docs/data-schema.md +87 -0
- package/.bkit/{shared → templates}/docs/deployments.md +128 -142
- package/.bkit/templates/docs/design.md +117 -0
- package/.bkit/templates/docs/noise.md +54 -0
- package/.bkit/templates/docs/observability.md +99 -0
- package/.bkit/templates/docs/security.md +137 -0
- package/.bkit/templates/docs/setup.md +93 -0
- package/.bkit/templates/docs/technology.md +70 -0
- package/.bkit/{shared → templates}/docs/testing.md +200 -87
- package/.bkit/templates/scripts/ci/bkit-check-accepted-divergences.mjs +1 -6
- package/.bkit/templates/scripts/ci/bkit-machine-lock.sh +511 -103
- package/.bkit/templates/scripts/ci/bkit-test-awake.mjs +314 -28
- package/.bkit/templates/scripts/ci/bkit-test-awake.test.mjs +500 -1
- package/.bkit/templates/scripts/graphify/bkit-graphify-graphml.py +1 -1
- package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +91 -62
- package/.bkit/templates/scripts/graphify/bkit-graphify.sh +59 -11
- package/.bkit/templates/slop-scan.config.json +2 -0
- package/CHANGELOG.md +79 -0
- package/DETAILS.md +661 -0
- package/README.md +73 -604
- package/dist/checks/after/auth.js +114 -46
- package/dist/checks/after/github.js +138 -35
- package/dist/checks/after/index.js +16 -4
- package/dist/checks/after/tools.js +224 -1
- package/dist/checks/before/files.js +59 -1
- package/dist/checks/before/index.js +7 -1
- package/dist/checks/status-holes.js +20 -21
- package/dist/checks/tips/catalogue.js +99 -10
- package/dist/checks/tips/detect.js +35 -3
- package/dist/checks/tips/index.js +1 -1
- package/dist/cli.js +13 -13
- package/dist/commands/ci/ci.js +113 -20
- package/dist/commands/ci/push-gate.js +79 -44
- package/dist/commands/install/doctor.js +5 -5
- package/dist/commands/install/install.js +23 -22
- package/dist/commands/install/uninstall.js +36 -30
- package/dist/commands/install/upgrade.js +10 -2
- package/dist/commands/land.js +2 -3
- package/dist/commands/lib.js +323 -25
- package/dist/commands/workflow/branches.js +312 -72
- package/dist/commands/workflow/challenge.js +66 -13
- package/dist/commands/workflow/context.js +46 -10
- package/dist/commands/workflow/counters.js +231 -23
- package/dist/commands/workflow/decisions.js +221 -106
- package/dist/commands/workflow/disk.js +2 -1
- package/dist/commands/workflow/feature-base.js +60 -0
- package/dist/commands/workflow/issues.js +243 -15
- package/dist/commands/workflow/junit.js +137 -0
- package/dist/commands/workflow/ledgers.js +726 -112
- package/dist/commands/workflow/locks.js +150 -29
- package/dist/commands/workflow/loops.js +67 -0
- package/dist/commands/workflow/open-decision.js +199 -0
- package/dist/commands/workflow/plan-blocks.js +6 -0
- package/dist/commands/workflow/plans.js +1 -1
- package/dist/commands/workflow/prs.js +272 -16
- package/dist/commands/workflow/repo.js +1 -1
- package/dist/commands/workflow/run-facts.js +6 -0
- package/dist/commands/workflow/runs.js +747 -155
- package/dist/commands/workflow/runtime.js +8 -4
- package/dist/commands/workflow/status.js +259 -13
- package/dist/commands/workflow/step-table.js +41 -15
- package/dist/commands/workflow/steps.js +530 -26
- package/dist/commands/workflow/summary-findings.js +1 -1
- package/dist/commands/workflow/summary.js +289 -8
- package/dist/commands/workflow/tasks.js +294 -27
- package/dist/commands/workflow/tests-base.js +266 -0
- package/dist/commands/workflow/tests-changed.js +130 -56
- package/dist/commands/workflow/tests-jump.js +77 -0
- package/dist/commands/workflow/tests.js +608 -131
- package/dist/commands/workflow/tracker.js +920 -112
- package/dist/commands/workflow/workflows.js +80 -59
- package/dist/commands/workflow/worktrees.js +387 -58
- package/dist/install/cloud-env.js +32 -10
- package/dist/install/managed-block.js +101 -0
- package/dist/install/manifest.js +7 -1
- package/dist/install/modules/claude.js +6 -2
- package/dist/install/modules/cloud.js +73 -86
- package/dist/install/modules/codex.js +9 -2
- package/dist/install/modules/core.js +190 -27
- package/dist/install/modules/opencode.js +18 -23
- package/dist/install/network-allowlist.js +8 -3
- package/dist/install/project-docs.js +551 -0
- package/dist/install/template-copies.js +55 -5
- package/dist/install/write.js +117 -5
- package/dist/ledgers/journal.js +10 -8
- package/dist/ledgers/migrate.js +20 -9
- package/dist/ledgers/status.js +461 -8
- package/dist/ledgers/telemetry.js +71 -13
- package/dist/render/trackers.js +21 -12
- package/dist/shared/package-manager.js +7 -2
- package/dist/shared/settings.js +8 -0
- package/dist/shared/text.js +13 -0
- package/dist/tools/instructions-sources.js +1 -0
- package/dist/tools/instructions.js +97 -24
- package/package.json +23 -15
- package/.bkit/core/hooks/preflight-linear.sh +0 -73
- package/.bkit/shared/docs/architecture.md +0 -16
- package/.bkit/shared/docs/data-schema.md +0 -16
- package/.bkit/shared/docs/design.md +0 -38
- package/.bkit/shared/docs/noise.md +0 -20
- package/.bkit/shared/docs/observability.md +0 -22
- package/.bkit/shared/docs/security.md +0 -62
- package/.bkit/shared/docs/setup.md +0 -52
- package/.bkit/shared/docs/technology.md +0 -15
- /package/.bkit/templates/{.lintstagedrc.json → lintstagedrc.example.json} +0 -0
- /package/.bkit/templates/{.prettierignore → prettierignore.example} +0 -0
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
import * as fs from "node:fs";
|
|
23
23
|
import * as os from "node:os";
|
|
24
24
|
import * as path from "node:path";
|
|
25
|
-
import { appendLine, fold, lastRun, runNumber, runOrStepField, statusTimestamp, } from "../../ledgers/status.js";
|
|
25
|
+
import { appendLine, fold, lastRun, runNumber, runOrStepField, statusTimestamp, withTargetLock, } from "../../ledgers/status.js";
|
|
26
26
|
import { compareTs, foldFrom, normalize, resolveRepoSlug, workflowTelemetry, } from "../../ledgers/telemetry.js";
|
|
27
27
|
import { check as checkCompleteness, deriveContract, parseRows, readCompleteness, } from "../../checks/status-holes.js";
|
|
28
28
|
import { getWorkflowsRoot } from "../../shared/package-roots.js";
|
|
@@ -32,17 +32,18 @@ import { fetchDev, landDir, pushToDev } from "../land.js";
|
|
|
32
32
|
import { CommandError, DEV, EXIT, git, isSharedBranch, parseJson, repoRoot, runGh, runGit, statusLocation, statusRelPath, } from "../lib.js";
|
|
33
33
|
import { anchorBkitStatus, pushBranch, readAnchor, stampAnchor } from "./branches.js";
|
|
34
34
|
import { AUTO_LABEL, AUTO_ROUTE_SUFFIX, buildComment, issueParts, parseComments, sortOldestFirst, trackerState, transitionLabels, } from "./issues.js";
|
|
35
|
-
import { EXIT_EMPTY, activeRecord, commitBookkeeping, ownPathCommit, ownSet, removeRecord, appendLedgerRows, runRows, unionLedgers, } from "./ledgers.js";
|
|
35
|
+
import { EXIT_EMPTY, activeRecord, appendRunCommits, commitBookkeeping, ownPathCommit, ownSet, removeRecord, appendLedgerRows, runRows, unionLedgers, writeParkedCommits, } from "./ledgers.js";
|
|
36
36
|
import { readIssueTracker } from "./fids.js";
|
|
37
37
|
import { agentContextBlock, buildBlock, chatFingerprint, ciList, claudeTranscripts, hostChat, planBlock, planFiles, runChats, runLines, runStatusRows, stepsBlock, timeBlock, } from "./run-facts.js";
|
|
38
38
|
import { buildSummary, refOf, SUMMARY_WORKFLOWS } from "./summary.js";
|
|
39
39
|
import { parsePlans, parseWorkstreams } from "./plans.js";
|
|
40
|
-
import { EXIT_REMOVE_FAILED, EXIT_SPLIT_BUCKET, acquireWorkflowLock, owns, readHolder, releaseLock, resolveMonth, workflowLockPath, } from "./locks.js";
|
|
40
|
+
import { EXIT_LOCK_BUSY, EXIT_REMOVE_FAILED, EXIT_SPLIT_BUCKET, acquireWorkflowLock, owns, readHolder, readRunsLenient, releaseLock, resolveMonth, workflowLockPath, } from "./locks.js";
|
|
41
|
+
import { openDecision } from "./open-decision.js";
|
|
41
42
|
import { highestVersion } from "./plan-versions.js";
|
|
42
43
|
import { mergePr, probePr } from "./prs.js";
|
|
43
44
|
import { FEATURE_STATUS } from "./roadmap.js";
|
|
44
45
|
import { EXIT_NO_STATUS, WORKFLOW_FLAG, positiveInt, readRuns, readStatusEvents, readStatusRows, str, } from "./status.js";
|
|
45
|
-
import { COMMENT_FILE_OUTPUT, POST_FLAG, TRACKER_OUTPUT, attempt, commentFileOf, postForVerb, issueRef, readLabels, endedRunActionKey, skipOf, trackerTarget, writeLabels, } from "./tracker.js";
|
|
46
|
+
import { COMMENT_FILE_OUTPUT, POST_FLAG, TRACKER_OUTPUT, attempt, commentFileOf, postForVerb, bindRunPublication, issueRef, readLabels, endedRunActionKey, skipOf, trackerTarget, writeLabels, } from "./tracker.js";
|
|
46
47
|
import { tipsText } from "../tips.js";
|
|
47
48
|
import { EXIT_NO_RECORD, requireRecordOnShared, writeStepRow } from "./steps.js";
|
|
48
49
|
import { addAllButCopied, removeWorktree } from "./worktrees.js";
|
|
@@ -106,44 +107,6 @@ export function recordChat(file, workflow, env) {
|
|
|
106
107
|
};
|
|
107
108
|
fs.appendFileSync(file, appendLine(row));
|
|
108
109
|
}
|
|
109
|
-
/**
|
|
110
|
-
* The highest-numbered `{workflow}-decision-{run}-{N}.md` in `logDir` whose header holds
|
|
111
|
-
* `Status: OPEN`, or null. Only the given run's files count, so an earlier run's pause
|
|
112
|
-
* never resurfaces. `file` is relative to `tree`.
|
|
113
|
-
*/
|
|
114
|
-
export function openDecision(logDir, tree, workflow, run) {
|
|
115
|
-
if (!fs.existsSync(logDir))
|
|
116
|
-
return null;
|
|
117
|
-
const name = new RegExp(`^${workflow}-decision-${run}-([0-9]+)\\.md$`);
|
|
118
|
-
const found = fs
|
|
119
|
-
.readdirSync(logDir)
|
|
120
|
-
.map((f) => ({ f, m: name.exec(f) }))
|
|
121
|
-
.filter((x) => x.m !== null)
|
|
122
|
-
.map(({ f, m }) => ({ f, n: Number(m[1]) }))
|
|
123
|
-
.sort((a, b) => b.n - a.n);
|
|
124
|
-
for (const { f, n } of found) {
|
|
125
|
-
const text = fs.readFileSync(path.join(logDir, f), "utf-8");
|
|
126
|
-
const field = (key) => new RegExp(`^${key}:[ \\t]*(.+?)[ \\t]*$`, "m").exec(text)?.[1] ?? null;
|
|
127
|
-
if (field("Status") !== "OPEN")
|
|
128
|
-
continue;
|
|
129
|
-
const num = (key) => {
|
|
130
|
-
const v = field(key);
|
|
131
|
-
return v !== null && /^[0-9]+$/.test(v) ? Number(v) : null;
|
|
132
|
-
};
|
|
133
|
-
return {
|
|
134
|
-
file: path.relative(tree, path.join(logDir, f)),
|
|
135
|
-
decision: n,
|
|
136
|
-
question: field("Question"),
|
|
137
|
-
from: field("From"),
|
|
138
|
-
pauseStep: num("Pause step"),
|
|
139
|
-
group: num("Group"),
|
|
140
|
-
verifyAttempt: num("Verify attempt"),
|
|
141
|
-
testAttempt: num("Test attempt"),
|
|
142
|
-
plan: field("Plan"),
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
110
|
const logDirRel = (month, fid) => path.join("docs", "plans", month, "logs", fid);
|
|
148
111
|
const list = (v) => v ?? [];
|
|
149
112
|
// ---------------------------------------------------------------------------
|
|
@@ -234,6 +197,14 @@ function failState(ctx, workflow, fid) {
|
|
|
234
197
|
}
|
|
235
198
|
return { row, rebaseAborted, lock, sentinels, removeFailed, soak, status };
|
|
236
199
|
}
|
|
200
|
+
/** Exit code: `workflows fail` refused `--next-step` before any write; no other usage error of that verb uses it. */
|
|
201
|
+
const EXIT_NEXT_STEP_REFUSED = 6;
|
|
202
|
+
/**
|
|
203
|
+
* The only `--next-step` shape `workflows fail` posts: a `/bkit-` command name, then optional
|
|
204
|
+
* space-separated arguments such as an FID or `#682`. The value goes into a code span in the
|
|
205
|
+
* failure comment, so nothing that could end the span or start markdown or HTML gets through.
|
|
206
|
+
*/
|
|
207
|
+
const NEXT_STEP_SHAPE = /^\/bkit-[a-z0-9-]+(?: [#A-Za-z0-9._-]+)*$/;
|
|
237
208
|
async function failVerb(ctx) {
|
|
238
209
|
const workflow = workflowName(String(ctx.flags.workflow));
|
|
239
210
|
// An empty value is a placeholder not held yet (the failure came before it was set).
|
|
@@ -241,6 +212,10 @@ async function failVerb(ctx) {
|
|
|
241
212
|
const token = str(ctx.flags.token) || undefined;
|
|
242
213
|
if (token !== undefined && fid === undefined)
|
|
243
214
|
throw new CommandError(EXIT.USAGE, "--token needs --fid");
|
|
215
|
+
// Empty is absent; anything else is one /bkit-* command line, checked before any write.
|
|
216
|
+
const nextStep = str(ctx.flags.nextStep) || undefined;
|
|
217
|
+
if (nextStep !== undefined && !NEXT_STEP_SHAPE.test(nextStep))
|
|
218
|
+
throw new CommandError(EXIT_NEXT_STEP_REFUSED, "--next-step must be one /bkit-* command line");
|
|
244
219
|
// State only for a run that took the lock: without the token the failure came
|
|
245
220
|
// before Step 1 locked, and nothing here is this run's to change.
|
|
246
221
|
const state = token === undefined || fid === undefined
|
|
@@ -286,6 +261,7 @@ async function failVerb(ctx) {
|
|
|
286
261
|
subStep: str(ctx.flags.subStep),
|
|
287
262
|
error: state.removeFailed ? `${error}; Lock removal failed` : error,
|
|
288
263
|
stderrFile: str(ctx.flags.stderrFile) || undefined,
|
|
264
|
+
...(nextStep === undefined ? {} : { lines: [`Next step: \`${nextStep}\``] }),
|
|
289
265
|
});
|
|
290
266
|
}
|
|
291
267
|
if (ctx.flags.post === true && comment === null)
|
|
@@ -297,6 +273,7 @@ async function failVerb(ctx) {
|
|
|
297
273
|
fid,
|
|
298
274
|
issue: str(ctx.flags.issue),
|
|
299
275
|
...(key === undefined ? {} : { file: state.status, key }),
|
|
276
|
+
purpose: "attention",
|
|
300
277
|
})
|
|
301
278
|
: undefined;
|
|
302
279
|
const labelsWrite = ctx.flags.post === true ? await writeFailedLabels(ctx, fid, failedSet, failedState) : undefined;
|
|
@@ -312,7 +289,8 @@ async function failVerb(ctx) {
|
|
|
312
289
|
trackerState: failedState,
|
|
313
290
|
prState,
|
|
314
291
|
comment,
|
|
315
|
-
|
|
292
|
+
nextStep: nextStep ?? null,
|
|
293
|
+
commentFile: commentFileOf(ctx.cwd, comment, ctx),
|
|
316
294
|
...(tracker === undefined ? {} : { tracker }),
|
|
317
295
|
...(labelsWrite === undefined ? {} : { labelsWrite }),
|
|
318
296
|
...sessionRemoval(ctx),
|
|
@@ -437,14 +415,19 @@ function carryOwnBook(src, dst, o, log) {
|
|
|
437
415
|
const uncommitted = (file) => runRows(src, file, rec);
|
|
438
416
|
const add = (file, lines) => {
|
|
439
417
|
const to = path.join(dst, file);
|
|
440
|
-
|
|
441
|
-
const
|
|
442
|
-
|
|
418
|
+
fs.mkdirSync(path.dirname(to), { recursive: true });
|
|
419
|
+
const fresh = withTargetLock(to, () => {
|
|
420
|
+
const existing = fs.existsSync(to) ? fs.readFileSync(to, "utf-8") : "";
|
|
421
|
+
const have = new Set(textLines(existing).map((l) => l.trim()));
|
|
422
|
+
const missing = lines.filter((l) => !have.has(l.trim()));
|
|
423
|
+
if (missing.length === 0)
|
|
424
|
+
return missing;
|
|
425
|
+
const sep = existing !== "" && !existing.endsWith("\n") ? "\n" : "";
|
|
426
|
+
fs.appendFileSync(to, `${sep}${missing.join("\n")}\n`);
|
|
427
|
+
return missing;
|
|
428
|
+
});
|
|
443
429
|
if (fresh.length === 0)
|
|
444
430
|
return;
|
|
445
|
-
fs.mkdirSync(path.dirname(to), { recursive: true });
|
|
446
|
-
const sep = existing !== "" && !existing.endsWith("\n") ? "\n" : "";
|
|
447
|
-
fs.appendFileSync(to, `${sep}${fresh.join("\n")}\n`);
|
|
448
431
|
carried.lines.set(file, fresh);
|
|
449
432
|
};
|
|
450
433
|
const listed = (specs) => (git(src, ["ls-files", "--cached", "--others", "--exclude-standard", "--", ...specs]) ?? "")
|
|
@@ -666,6 +649,15 @@ async function handoverVerb(ctx) {
|
|
|
666
649
|
}
|
|
667
650
|
let handed;
|
|
668
651
|
const rec = shared && (push || flush) ? activeRecord(tree, fid) : null;
|
|
652
|
+
// A run that stays open keeps its commit list, because the record goes below: a parked
|
|
653
|
+
// copy in this clone's git dir, and a row in its status log that lands with the handover.
|
|
654
|
+
const statusAbs = path.join(tree, statusRelPath(month, fid));
|
|
655
|
+
if (rec !== null &&
|
|
656
|
+
fs.existsSync(statusAbs) &&
|
|
657
|
+
lastRun(readRunsLenient(statusAbs), workflow)?.status === "IN_PROGRESS") {
|
|
658
|
+
appendRunCommits(statusAbs, workflow, rec);
|
|
659
|
+
writeParkedCommits(tree, workflow, rec);
|
|
660
|
+
}
|
|
669
661
|
if (push && shared) {
|
|
670
662
|
const r = await landFailedRecord(ctx, { workflow, fid, month, book: tree, shared });
|
|
671
663
|
if (r.sha !== undefined && r.carried !== undefined)
|
|
@@ -721,16 +713,23 @@ async function handoverVerb(ctx) {
|
|
|
721
713
|
if (rec !== null)
|
|
722
714
|
removeRecord(tree, fid);
|
|
723
715
|
const tracker = ctx.flags.post === true && comment !== null
|
|
724
|
-
? await postForVerb(ctx, comment, { fid })
|
|
716
|
+
? await postForVerb(ctx, comment, { fid, purpose: "attention" })
|
|
725
717
|
: undefined;
|
|
718
|
+
// Every exit this verb reaches keeps the record somewhere, so the run stops either way: an
|
|
719
|
+
// open PR (9), a refused push (10) or a failed dev landing (11) only add the closing line.
|
|
720
|
+
const message = code === EXIT.OK
|
|
721
|
+
? ""
|
|
722
|
+
: `Record not pushed: the handover commit is only in ${tree}, and the links in this run's comments open once it is pushed`;
|
|
726
723
|
ctx.emit({
|
|
727
724
|
handover: present ? artifact : null,
|
|
728
725
|
pushed,
|
|
729
726
|
ref: pushed ? ref : null,
|
|
730
727
|
skipped,
|
|
731
728
|
comment,
|
|
732
|
-
commentFile: commentFileOf(ctx.cwd, comment),
|
|
729
|
+
commentFile: commentFileOf(ctx.cwd, comment, ctx),
|
|
733
730
|
...(tracker === undefined ? {} : { tracker }),
|
|
731
|
+
route: "stop",
|
|
732
|
+
message,
|
|
734
733
|
});
|
|
735
734
|
return code;
|
|
736
735
|
}
|
|
@@ -1230,7 +1229,7 @@ async function shipClose(ctx, o, token) {
|
|
|
1230
1229
|
if (landed.via === "close-pr" && !fetchDev(root).ok)
|
|
1231
1230
|
ctx.log(`fetch of dev after the close PR failed — origin/${DEV} is stale until the next fetch`);
|
|
1232
1231
|
try {
|
|
1233
|
-
worktree = removeWorktree(root, o.fid, o.branch, ctx.log);
|
|
1232
|
+
worktree = removeWorktree(root, o.fid, o.branch, ctx.log, { landed: true });
|
|
1234
1233
|
}
|
|
1235
1234
|
catch (err) {
|
|
1236
1235
|
ctx.log(`${err.message} — remove ${book} by hand`);
|
|
@@ -1632,8 +1631,12 @@ function inputVerb(ctx) {
|
|
|
1632
1631
|
const text = inputText(ctx.cwd, audit, "audit");
|
|
1633
1632
|
sections.push([`Audit Report — ${audit} — ${fileDate(ctx.cwd, audit)}`, text]);
|
|
1634
1633
|
}
|
|
1635
|
-
const body = sections.map(([h, text]) => `## ${h}\n\n${text}\n`).join("\n");
|
|
1636
1634
|
const abs = path.join(path.dirname(status), `${workflow}-input-${run}.md`);
|
|
1635
|
+
const grill = path.join(path.dirname(status), `${workflow}-grill-${run}.md`);
|
|
1636
|
+
const sectionText = sections.map(([h, text]) => `## ${h}\n\n${text}\n`).join("\n");
|
|
1637
|
+
const body = fs.existsSync(grill)
|
|
1638
|
+
? `${sectionText}\n${fs.readFileSync(grill, "utf-8")}`
|
|
1639
|
+
: sectionText;
|
|
1637
1640
|
fs.mkdirSync(path.dirname(abs), { recursive: true });
|
|
1638
1641
|
fs.writeFileSync(abs, body);
|
|
1639
1642
|
ctx.emit({
|
|
@@ -1650,12 +1653,12 @@ function inputVerb(ctx) {
|
|
|
1650
1653
|
*/
|
|
1651
1654
|
async function postClose(ctx, fid, out) {
|
|
1652
1655
|
const comment = typeof out.comment === "string" ? out.comment : null;
|
|
1653
|
-
const withFile = { ...out, commentFile: commentFileOf(ctx.cwd, comment) };
|
|
1656
|
+
const withFile = { ...out, commentFile: commentFileOf(ctx.cwd, comment, ctx) };
|
|
1654
1657
|
if (ctx.flags.post !== true)
|
|
1655
1658
|
return withFile;
|
|
1656
1659
|
if (comment === null)
|
|
1657
1660
|
throw new CommandError(EXIT.USAGE, "--post needs --number");
|
|
1658
|
-
return { ...withFile, tracker: await postForVerb(ctx, comment, { fid }) };
|
|
1661
|
+
return { ...withFile, tracker: await postForVerb(ctx, comment, { fid, purpose: "terminal" }) };
|
|
1659
1662
|
}
|
|
1660
1663
|
export const workflowsCommand = {
|
|
1661
1664
|
noun: "workflows",
|
|
@@ -1669,6 +1672,7 @@ export const workflowsCommand = {
|
|
|
1669
1672
|
FID_FLAG,
|
|
1670
1673
|
MONTH_FLAG,
|
|
1671
1674
|
STATUS_FILE_FLAG,
|
|
1675
|
+
SESSION_DIR_FLAG,
|
|
1672
1676
|
{
|
|
1673
1677
|
name: "lock-held",
|
|
1674
1678
|
type: "boolean",
|
|
@@ -1688,12 +1692,13 @@ export const workflowsCommand = {
|
|
|
1688
1692
|
row: "the appended workflow-started row, with `limits` (the workflow's ask points from bkit.workflows, frozen for the run), or null when resuming",
|
|
1689
1693
|
run: "which run of the workflow this is (1-based)",
|
|
1690
1694
|
lastDoneStep: "the current run's last DONE step: resume after it (null on a new run)",
|
|
1691
|
-
openDecision: "{file, decision, question, from, pauseStep, group, verifyAttempt, testAttempt, plan} of the current run's highest {workflow}-decision-{run}-{N}.md holding Status: OPEN, else null",
|
|
1695
|
+
openDecision: "{file, decision, question, from, pauseStep, group, verifyAttempt, testAttempt, plan, gate, sourceChanged, status} of the current run's highest {workflow}-decision-{run}-{N}.md holding Status: OPEN, or DECIDED / ASSUMED when no {workflow}-decision row names it, else null",
|
|
1692
1696
|
},
|
|
1693
1697
|
textOmit: ["row"],
|
|
1694
1698
|
exitCodes: {
|
|
1695
1699
|
[EXIT_NO_STATUS]: "status.jsonl is not valid",
|
|
1696
1700
|
[EXIT_SPLIT_BUCKET]: "the feature has logs in more than one month bucket",
|
|
1701
|
+
[EXIT_LOCK_BUSY]: "without --lock-held: another run of the feature holds the lock and is still stepping",
|
|
1697
1702
|
[EXIT_LOCK_NOT_HELD]: "--lock-held: the lock is missing or belongs to another owner",
|
|
1698
1703
|
[EXIT_WRONG_BRANCH]: "--branch: the checkout is on another branch",
|
|
1699
1704
|
},
|
|
@@ -1769,6 +1774,7 @@ export const workflowsCommand = {
|
|
|
1769
1774
|
recordChat(file, workflow, process.env);
|
|
1770
1775
|
const runs = fold(readStatusEvents(file));
|
|
1771
1776
|
const run = runNumber(runs, workflow);
|
|
1777
|
+
bindRunPublication(ctx, file, workflow, run);
|
|
1772
1778
|
const current = resumed ? lastRun(runs, workflow) : undefined;
|
|
1773
1779
|
ctx.emit({
|
|
1774
1780
|
lock,
|
|
@@ -1778,7 +1784,9 @@ export const workflowsCommand = {
|
|
|
1778
1784
|
run,
|
|
1779
1785
|
lastDoneStep: current?.steps.filter((s) => s.status === "DONE").at(-1)?.step ?? null,
|
|
1780
1786
|
openDecision: resumed
|
|
1781
|
-
? openDecision(path.dirname(file), where.tree, workflow, run)
|
|
1787
|
+
? openDecision(path.dirname(file), where.tree, workflow, run, (current?.steps ?? [])
|
|
1788
|
+
.filter((s) => s.step === `${workflow}-decision`)
|
|
1789
|
+
.flatMap((s) => s.artifacts))
|
|
1782
1790
|
: null,
|
|
1783
1791
|
});
|
|
1784
1792
|
return EXIT.OK;
|
|
@@ -1830,6 +1838,12 @@ export const workflowsCommand = {
|
|
|
1830
1838
|
type: "string",
|
|
1831
1839
|
help: "the failed shell command's stderr (last 20 lines kept)",
|
|
1832
1840
|
},
|
|
1841
|
+
{
|
|
1842
|
+
name: "next-step",
|
|
1843
|
+
type: "string",
|
|
1844
|
+
placeholderExit: EXIT_NEXT_STEP_REFUSED,
|
|
1845
|
+
help: "one /bkit-* command line to name as the next step: adds a `Next step:` line to the failure comment (empty = none)",
|
|
1846
|
+
},
|
|
1833
1847
|
{
|
|
1834
1848
|
...POST_FLAG,
|
|
1835
1849
|
help: "post the failure comment (needs --step-number) to the --fid / --issue issue and write its failed labels; prints `tracker` and `labelsWrite`",
|
|
@@ -1852,6 +1866,7 @@ export const workflowsCommand = {
|
|
|
1852
1866
|
trackerState: "the Linear or Jira state for the failed issue (null under github, none)",
|
|
1853
1867
|
prState: "the --pr PR's state, or null",
|
|
1854
1868
|
comment: "the failure comment body (with --step-number), else null",
|
|
1869
|
+
nextStep: "the --next-step command line, or null",
|
|
1855
1870
|
commentFile: COMMENT_FILE_OUTPUT,
|
|
1856
1871
|
tracker: TRACKER_OUTPUT,
|
|
1857
1872
|
labelsWrite: "with --post: the label and state write, read fresh from the issue: {done: true, action: labels} | {done: false, action, reason} (write `labels` / `trackerState` via the tracker MCP) | {skipped}",
|
|
@@ -1859,6 +1874,7 @@ export const workflowsCommand = {
|
|
|
1859
1874
|
},
|
|
1860
1875
|
textOmit: ["row"],
|
|
1861
1876
|
exitCodes: {
|
|
1877
|
+
[EXIT_NEXT_STEP_REFUSED]: "a refused --next-step (not one /bkit-* command line, or an unsubstituted placeholder): refused before any write, so the call can run again without it",
|
|
1862
1878
|
[EXIT_SPLIT_BUCKET]: "no --month and the feature has logs in more than one month bucket",
|
|
1863
1879
|
[EXIT_REMOVE_FAILED]: "the lock file is still there after removing it (everything else was done; the comment says so)",
|
|
1864
1880
|
},
|
|
@@ -1908,6 +1924,8 @@ export const workflowsCommand = {
|
|
|
1908
1924
|
comment: "the handover comment body (null when there is no handover); links only when pushed",
|
|
1909
1925
|
commentFile: COMMENT_FILE_OUTPUT,
|
|
1910
1926
|
tracker: `${TRACKER_OUTPUT}; absent when there is no handover`,
|
|
1927
|
+
route: "stop: the record is kept (pushed, or left in the run's tree on exit 9, 10 or 11) and the run ends here; workflows route on this, not on the exit code",
|
|
1928
|
+
message: "the line to add to the owner's final message: `Record not pushed: …` on exit 9, 10 or 11, empty otherwise",
|
|
1911
1929
|
shared: "--list-stray: the checkout is dev / main / detached (remove nothing)",
|
|
1912
1930
|
modified: "--list-stray: tracked paths with changes, outside the run's logs",
|
|
1913
1931
|
untracked: "--list-stray: untracked paths, outside the run's logs",
|
|
@@ -2070,7 +2088,10 @@ export const workflowsCommand = {
|
|
|
2070
2088
|
squashSha: str(f.squashSha),
|
|
2071
2089
|
ref: str(f.ref),
|
|
2072
2090
|
ownerRepo: str(f.ownerRepo),
|
|
2073
|
-
outbox: str(f.outbox)
|
|
2091
|
+
outbox: str(f.outbox) ??
|
|
2092
|
+
(str(f.sessionDir)
|
|
2093
|
+
? path.join(path.dirname(path.dirname(path.resolve(ctx.cwd, String(f.sessionDir)))), String(f.fid))
|
|
2094
|
+
: undefined),
|
|
2074
2095
|
recordStep: f.recordStep === true,
|
|
2075
2096
|
message: str(f.message),
|
|
2076
2097
|
labels: list(f.label),
|
|
@@ -2102,7 +2123,7 @@ export const workflowsCommand = {
|
|
|
2102
2123
|
},
|
|
2103
2124
|
},
|
|
2104
2125
|
input: {
|
|
2105
|
-
summary: "Write logs/{FID}/{workflow}-input-{run}.md: the session prompt, the issue description and each human comment, then the plan, design and audit reports, each section dated.",
|
|
2126
|
+
summary: "Write logs/{FID}/{workflow}-input-{run}.md: the session prompt, the issue description and each human comment, then the plan, design and audit reports, each section dated. An existing {workflow}-grill-{run}.md in the same folder is appended at the end.",
|
|
2106
2127
|
use: "workflow",
|
|
2107
2128
|
flags: [
|
|
2108
2129
|
WORKFLOW_FLAG,
|