@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
|
@@ -26,10 +26,11 @@ import * as path from "node:path";
|
|
|
26
26
|
|
|
27
27
|
import { appendLine, statusTimestamp } from "../../ledgers/status.js";
|
|
28
28
|
import { CommandError, DEV, EXIT, git, runGit, type CommandSpec } from "../lib.js";
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
29
|
+
import { EXIT_BASE, diffNumstat, type DiffStat } from "./context.js";
|
|
30
|
+
import { defaultRange } from "./feature-base.js";
|
|
31
|
+
import { parseDecisionItems } from "./open-decision.js";
|
|
31
32
|
import { EXIT_ROW_REFUSED, EXIT_STAGE, appendLedgerRows } from "./ledgers.js";
|
|
32
|
-
import { derivedTestMatrix, parsePlanBlocks, type PlanTaskBlock } from "./plan-blocks.js";
|
|
33
|
+
import { derivedTestMatrix, parsePlanBlocks, type PlanTaskBlock, testTier } from "./plan-blocks.js";
|
|
33
34
|
import { readBkitConfig, type TaskCaps } from "../../shared/settings.js";
|
|
34
35
|
import { grantCount } from "./counters.js";
|
|
35
36
|
import { checkPlanText, planCaps, readTestFirst } from "./tests.js";
|
|
@@ -255,13 +256,59 @@ const taskBlock = (n: number, f: Finding, round: number) => [
|
|
|
255
256
|
`<!-- bkit:task ${n} end -->`,
|
|
256
257
|
];
|
|
257
258
|
|
|
258
|
-
/**
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
259
|
+
/**
|
|
260
|
+
* Findings given as structured data (a step result file), checked by the rules
|
|
261
|
+
* {@link parseFindings} applies to a written report. Severity, fixable, location and
|
|
262
|
+
* done-when are the reviewer's judgments: a missing one is refused, never defaulted.
|
|
263
|
+
* Throws a CommandError (EXIT_OLD_FORMAT) naming the finding and field.
|
|
264
|
+
*/
|
|
265
|
+
export function structuredFindings(input: unknown, cwd: string): Finding[] {
|
|
266
|
+
if (!Array.isArray(input)) throw new CommandError(EXIT_OLD_FORMAT, "findings must be an array");
|
|
267
|
+
return input.map((raw, i) => {
|
|
268
|
+
const refuse = (why: string) => new CommandError(EXIT_OLD_FORMAT, `finding ${i + 1} ${why}`);
|
|
269
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
270
|
+
throw refuse("is not an object");
|
|
271
|
+
const f = raw as Record<string, unknown>;
|
|
272
|
+
if (!SEVERITY_ORDER.includes(f["severity"] as Severity))
|
|
273
|
+
throw refuse("has no severity CRITICAL|HIGH|MEDIUM|LOW");
|
|
274
|
+
if (typeof f["fixable"] !== "boolean") throw refuse("has no fixable true|false");
|
|
275
|
+
const location = normalizeLocation(typeof f["location"] === "string" ? f["location"] : "", cwd);
|
|
276
|
+
if (location === null) throw refuse("has no location path:line");
|
|
277
|
+
if (typeof f["doneWhen"] !== "string" || f["doneWhen"].trim() === "")
|
|
278
|
+
throw refuse("has no doneWhen");
|
|
279
|
+
const tests = f["tests"] ?? [];
|
|
280
|
+
if (!Array.isArray(tests) || tests.some((t) => typeof t !== "string"))
|
|
281
|
+
throw refuse("has tests that are not an array of strings");
|
|
282
|
+
if (f["cls"] !== undefined && typeof f["cls"] !== "string") throw refuse("has a non-text cls");
|
|
283
|
+
// Each value renders into one line of the task block: a line break would forge plan lines.
|
|
284
|
+
const lineBreak = /[\r\n]/;
|
|
285
|
+
for (const field of ["title", "cls", "doneWhen"] as const) {
|
|
286
|
+
const v = f[field];
|
|
287
|
+
if (typeof v === "string" && lineBreak.test(v))
|
|
288
|
+
throw refuse(`has a ${field} that must be a single line`);
|
|
289
|
+
}
|
|
290
|
+
const brokenTest = (tests as string[]).findIndex((t) => lineBreak.test(t));
|
|
291
|
+
if (brokenTest !== -1)
|
|
292
|
+
throw refuse(`has tests entry ${brokenTest + 1} that must be a single line`);
|
|
293
|
+
const title = typeof f["title"] === "string" && f["title"] !== "" ? f["title"] : "";
|
|
294
|
+
return {
|
|
295
|
+
severity: f["severity"] as Severity,
|
|
296
|
+
...(typeof f["cls"] === "string" && f["cls"] !== "" ? { cls: f["cls"] } : {}),
|
|
297
|
+
fixable: f["fixable"],
|
|
298
|
+
location,
|
|
299
|
+
title: title || `Challenge finding at ${location}`,
|
|
300
|
+
doneWhen: f["doneWhen"],
|
|
301
|
+
tests: tests as string[],
|
|
302
|
+
};
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/** The `## Findings Log` section for `findings`, in the task-block form {@link parseFindings} reads. */
|
|
307
|
+
export function renderFindingsLog(findings: Finding[], round = 1): string {
|
|
308
|
+
return ["## Findings Log", "", ...findings.flatMap((f, i) => [...taskBlock(i + 1, f, round), ""])]
|
|
309
|
+
.join("\n")
|
|
310
|
+
.replace(/\n+$/, "");
|
|
311
|
+
}
|
|
265
312
|
|
|
266
313
|
/**
|
|
267
314
|
* One `Derived Test Matrix` row per test a finding task appends: the test's own name and
|
|
@@ -505,7 +552,7 @@ export const challengeCommand: CommandSpec = {
|
|
|
505
552
|
{
|
|
506
553
|
name: "base",
|
|
507
554
|
type: "string",
|
|
508
|
-
help:
|
|
555
|
+
help: "merge base (default: the feature base, after fetching origin dev; a failed fetch is logged, not fatal)",
|
|
509
556
|
},
|
|
510
557
|
],
|
|
511
558
|
output: {
|
|
@@ -518,17 +565,19 @@ export const challengeCommand: CommandSpec = {
|
|
|
518
565
|
},
|
|
519
566
|
exitCodes: { [EXIT_BASE]: "--base does not name a commit" },
|
|
520
567
|
run: (ctx) => {
|
|
521
|
-
const
|
|
522
|
-
if (
|
|
568
|
+
const explicitBase = typeof ctx.flags.base === "string" ? ctx.flags.base : undefined;
|
|
569
|
+
if (explicitBase === undefined) {
|
|
523
570
|
const res = runGit(ctx.cwd, ["fetch", "origin", DEV]);
|
|
524
571
|
if (!res.ok)
|
|
525
572
|
ctx.log(
|
|
526
573
|
`git fetch origin dev failed — measuring against the last fetch: ${res.stderr}`,
|
|
527
574
|
);
|
|
528
575
|
}
|
|
576
|
+
const fallback = explicitBase === undefined ? defaultRange(ctx.cwd, ctx.log) : null;
|
|
577
|
+
const base = explicitBase ?? fallback!.base;
|
|
529
578
|
if (git(ctx.cwd, ["rev-parse", "-q", "--verify", `${base}^{commit}`]) === null)
|
|
530
579
|
throw new CommandError(EXIT_BASE, `--base ${base} does not name a commit (fetch origin)`);
|
|
531
|
-
const range = `${base}...HEAD`;
|
|
580
|
+
const range = fallback?.range ?? `${base}...HEAD`;
|
|
532
581
|
const { stat } = diffNumstat(ctx.cwd, range);
|
|
533
582
|
const gate = challengeGate(stat);
|
|
534
583
|
const file = path.resolve(ctx.cwd, String(ctx.flags.file));
|
|
@@ -53,6 +53,9 @@ import {
|
|
|
53
53
|
import { gitEnv, resolveRepoSlug } from "../../ledgers/telemetry.js";
|
|
54
54
|
import { parseJson } from "../../shared/json.js";
|
|
55
55
|
import { checkedTable } from "../../shared/text.js";
|
|
56
|
+
import { defaultRange } from "./feature-base.js";
|
|
57
|
+
|
|
58
|
+
export { defaultRange, featureBase } from "./feature-base.js";
|
|
56
59
|
import { buildComment } from "./issues.js";
|
|
57
60
|
import {
|
|
58
61
|
derivedTestMatrix,
|
|
@@ -64,7 +67,17 @@ import {
|
|
|
64
67
|
import { COMMENT_FILE_OUTPUT, commentFileOf } from "./tracker.js";
|
|
65
68
|
import { EXIT_NO_STATUS, FILE_FLAG, positiveInt, readRuns, str } from "./status.js";
|
|
66
69
|
import { EXIT_COMMIT, writeStepRow } from "./steps.js";
|
|
67
|
-
import {
|
|
70
|
+
import { activeRunStart } from "./counters.js";
|
|
71
|
+
import {
|
|
72
|
+
RED_PROVEN,
|
|
73
|
+
doneTasks,
|
|
74
|
+
planTakeovers,
|
|
75
|
+
redEntries,
|
|
76
|
+
redKey,
|
|
77
|
+
testBlock,
|
|
78
|
+
testSpan,
|
|
79
|
+
type Takeover,
|
|
80
|
+
} from "./tests.js";
|
|
68
81
|
|
|
69
82
|
/** Exit code: the artifact to clamp is missing, unreadable, or could not be replaced. */
|
|
70
83
|
export const EXIT_ARTIFACT = 4;
|
|
@@ -830,7 +843,6 @@ function asCaptured(out: Buffer): Buffer {
|
|
|
830
843
|
/** Exit code: --base does not name a commit. */
|
|
831
844
|
export const EXIT_BASE = 5;
|
|
832
845
|
|
|
833
|
-
export const DIFF_BASE = "origin/dev";
|
|
834
846
|
export const DIFF_EXCLUDES = ["docs/plans/**"];
|
|
835
847
|
export const PARTIAL_MARK = "partial diff coverage";
|
|
836
848
|
|
|
@@ -1131,6 +1143,8 @@ export interface BriefInput {
|
|
|
1131
1143
|
testsOnly?: boolean;
|
|
1132
1144
|
/** Tests-only: the planned tests a test in their file already carries, with the line that test starts on. */
|
|
1133
1145
|
existing?: ExistingTest[];
|
|
1146
|
+
/** Tests-only: the planned tests the group takes over from an earlier task, built in this run. */
|
|
1147
|
+
takenOver?: Takeover[];
|
|
1134
1148
|
note?: string;
|
|
1135
1149
|
}
|
|
1136
1150
|
|
|
@@ -1158,6 +1172,30 @@ export function existingPlannedTests(top: string, open: PlanTaskBlock[]): Existi
|
|
|
1158
1172
|
return out;
|
|
1159
1173
|
}
|
|
1160
1174
|
|
|
1175
|
+
/**
|
|
1176
|
+
* The group's takeovers split by the run start: a taken-over test whose block the run-start
|
|
1177
|
+
* commit `runStart` already held stays in `existing` (add-only); every other one leaves
|
|
1178
|
+
* `existing` and is `takenOver`, which the tests step may rewrite. With no run start, no
|
|
1179
|
+
* takeover counts as pre-run.
|
|
1180
|
+
*/
|
|
1181
|
+
export function splitTakeovers(
|
|
1182
|
+
top: string,
|
|
1183
|
+
existing: ExistingTest[],
|
|
1184
|
+
takeovers: Takeover[],
|
|
1185
|
+
runStart: string | undefined,
|
|
1186
|
+
): { existing: ExistingTest[]; takenOver: Takeover[] } {
|
|
1187
|
+
const atStart = (k: Takeover) => {
|
|
1188
|
+
if (runStart === undefined) return false;
|
|
1189
|
+
return testBlock(git(top, ["show", `${runStart}:${k.test}`]), k.name) !== null;
|
|
1190
|
+
};
|
|
1191
|
+
const takenOver = takeovers.filter((k) => !atStart(k));
|
|
1192
|
+
const moved = new Set(takenOver.map((k) => redKey(k.task, k.test, k.name)));
|
|
1193
|
+
return {
|
|
1194
|
+
existing: existing.filter((e) => !moved.has(redKey(e.task, e.test, e.name))),
|
|
1195
|
+
takenOver,
|
|
1196
|
+
};
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1161
1199
|
/** The brief's text and its work section's size in bytes. */
|
|
1162
1200
|
export function briefText(o: BriefInput): { text: string; workBytes: number } {
|
|
1163
1201
|
const lines = o.plan.split("\n");
|
|
@@ -1225,6 +1263,15 @@ export function briefText(o: BriefInput): { text: string; workBytes: number } {
|
|
|
1225
1263
|
);
|
|
1226
1264
|
work.push("");
|
|
1227
1265
|
}
|
|
1266
|
+
const takenOver = (o.takenOver ?? []).filter((k) => open.some((t) => t.task === k.task));
|
|
1267
|
+
if (takenOver.length > 0) {
|
|
1268
|
+
work.push("### Planned tests taken over from earlier tasks", "");
|
|
1269
|
+
for (const k of takenOver)
|
|
1270
|
+
work.push(
|
|
1271
|
+
`- TASK ${k.task} \`${k.test}\` \`${k.name}\` — taken over from TASK ${k.from}; rewrite that test case so it fails until this task's code exists`,
|
|
1272
|
+
);
|
|
1273
|
+
work.push("");
|
|
1274
|
+
}
|
|
1228
1275
|
} else work.push(...planEntries(lines, open, work, o.planFile));
|
|
1229
1276
|
out.push(...work);
|
|
1230
1277
|
|
|
@@ -1462,7 +1509,7 @@ export const contextCommand: CommandSpec = {
|
|
|
1462
1509
|
{
|
|
1463
1510
|
name: "base",
|
|
1464
1511
|
type: "string",
|
|
1465
|
-
help:
|
|
1512
|
+
help: "merge base or a group's start commit (default: the feature base, where the branch's own work starts)",
|
|
1466
1513
|
},
|
|
1467
1514
|
...LOG_FLAGS,
|
|
1468
1515
|
{
|
|
@@ -1492,7 +1539,9 @@ export const contextCommand: CommandSpec = {
|
|
|
1492
1539
|
[EXIT_ARTIFACT]: "the artifact could not be written",
|
|
1493
1540
|
},
|
|
1494
1541
|
run: (ctx) => {
|
|
1495
|
-
const
|
|
1542
|
+
const explicitBase = str(ctx.flags.base);
|
|
1543
|
+
const fallback = explicitBase === undefined ? defaultRange(ctx.cwd, ctx.log) : null;
|
|
1544
|
+
const base = explicitBase ?? fallback!.base;
|
|
1496
1545
|
if (git(ctx.cwd, ["rev-parse", "-q", "--verify", `${base}^{commit}`]) === null) {
|
|
1497
1546
|
throw new CommandError(
|
|
1498
1547
|
EXIT_BASE,
|
|
@@ -1511,7 +1560,7 @@ export const contextCommand: CommandSpec = {
|
|
|
1511
1560
|
ctx.cwd,
|
|
1512
1561
|
path.resolve(ctx.cwd, artifact),
|
|
1513
1562
|
artifact,
|
|
1514
|
-
`${base}...HEAD`,
|
|
1563
|
+
fallback?.range ?? `${base}...HEAD`,
|
|
1515
1564
|
DIFF_GUARD,
|
|
1516
1565
|
{ rawDir: rawDirFor(ctx.cwd, str(ctx.flags.fid)) },
|
|
1517
1566
|
);
|
|
@@ -1538,7 +1587,7 @@ export const contextCommand: CommandSpec = {
|
|
|
1538
1587
|
},
|
|
1539
1588
|
brief: {
|
|
1540
1589
|
summary:
|
|
1541
|
-
"Write one group's brief (why and what, where it fits, its open task blocks, the earlier tasks they depend on, the Reuse Inventory rows and Architecture entries for their files, deviations) as build-brief-{group}-{n}.md, and print only its path and sizes; --tests-only writes the tests step's brief as build-brief-tests-{group}-{n}.md, with the Derived Test Matrix rows for the group's tests in place of the inventory and architecture entries.",
|
|
1590
|
+
"Write one group's brief (why and what, where it fits, its open task blocks, the earlier tasks they depend on, the Reuse Inventory rows and Architecture entries for their files, deviations) as build-brief-{group}-{n}.md, and print only its path and sizes; --tests-only writes the tests step's brief as build-brief-tests-{group}-{n}.md, with the Derived Test Matrix rows for the group's tests in place of the inventory and architecture entries, and the tests the group takes over from earlier tasks under their own section.",
|
|
1542
1591
|
use: "workflow",
|
|
1543
1592
|
flags: [
|
|
1544
1593
|
{ name: "plan", type: "string", required: true, help: "the plan file" },
|
|
@@ -1648,6 +1697,19 @@ export const contextCommand: CommandSpec = {
|
|
|
1648
1697
|
const noteFile = noteFlag === undefined ? undefined : path.resolve(ctx.cwd, noteFlag);
|
|
1649
1698
|
if (noteFile !== undefined && !fs.existsSync(noteFile))
|
|
1650
1699
|
throw new CommandError(EXIT_ARTIFACT, `${noteFlag} does not exist`);
|
|
1700
|
+
const top = git(ctx.cwd, ["rev-parse", "--show-toplevel"]) ?? ctx.cwd;
|
|
1701
|
+
const runStart =
|
|
1702
|
+
statusArg === undefined
|
|
1703
|
+
? undefined
|
|
1704
|
+
: activeRunStart(path.resolve(ctx.cwd, statusArg), "build")?.parentSha;
|
|
1705
|
+
const split = testsOnly
|
|
1706
|
+
? splitTakeovers(
|
|
1707
|
+
top,
|
|
1708
|
+
existingPlannedTests(top, open),
|
|
1709
|
+
planTakeovers(plan).filter((k) => open.some((t) => t.task === k.task)),
|
|
1710
|
+
typeof runStart === "string" ? runStart : undefined,
|
|
1711
|
+
)
|
|
1712
|
+
: undefined;
|
|
1651
1713
|
const { text, workBytes } = briefText({
|
|
1652
1714
|
plan,
|
|
1653
1715
|
planFile: String(ctx.flags.plan),
|
|
@@ -1655,9 +1717,8 @@ export const contextCommand: CommandSpec = {
|
|
|
1655
1717
|
groups: blocks.groups,
|
|
1656
1718
|
isDone: (t) => isDone(t) || (group.tasks.includes(t) && !open.includes(t)),
|
|
1657
1719
|
testsOnly,
|
|
1658
|
-
existing:
|
|
1659
|
-
|
|
1660
|
-
: undefined,
|
|
1720
|
+
existing: split?.existing,
|
|
1721
|
+
takenOver: split?.takenOver,
|
|
1661
1722
|
note: noteFile === undefined ? undefined : fs.readFileSync(noteFile, "utf-8"),
|
|
1662
1723
|
});
|
|
1663
1724
|
const out = nextBriefPath(dir, group.group, testsOnly ? "build-brief-tests" : undefined);
|
|
@@ -1908,7 +1969,7 @@ export const contextCommand: CommandSpec = {
|
|
|
1908
1969
|
commit: written.commit,
|
|
1909
1970
|
...(written.progressLine === undefined ? {} : { progressLine: written.progressLine }),
|
|
1910
1971
|
comment,
|
|
1911
|
-
commentFile: commentFileOf(ctx.cwd, comment),
|
|
1972
|
+
commentFile: commentFileOf(ctx.cwd, comment, ctx),
|
|
1912
1973
|
});
|
|
1913
1974
|
return written.code;
|
|
1914
1975
|
},
|