@cbartens/bkit 5.5.1 → 6.0.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 +30 -20
- package/.bkit/core/.agents/docs.md +1 -0
- package/.bkit/core/.agents/rules.md +35 -26
- package/.bkit/core/.bkit/README.md +29 -19
- package/.bkit/core/.bkit/authoring.md +117 -0
- package/.bkit/core/.bkit/cloud.md +11 -11
- package/.bkit/core/.bkit/comparison.md +5 -5
- package/.bkit/core/.bkit/install.md +19 -18
- package/.bkit/core/.bkit/jsonl.md +202 -122
- package/.bkit/core/.bkit/lite.md +1 -1
- package/.bkit/core/.bkit/pipeline.md +49 -52
- package/.bkit/core/.bkit/prompts.md +91 -167
- package/.bkit/core/.bkit/providers.md +29 -32
- package/.bkit/core/.bkit/templates.md +12 -11
- package/.bkit/core/.bkit/trackers.md +51 -28
- package/.bkit/core/.bkit/workflows.md +394 -355
- package/.bkit/core/AGENTS.md +16 -22
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +14 -38
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-agents.md +19 -43
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +14 -38
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +11 -35
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +12 -36
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-config.md +18 -42
- package/.bkit/core/docs/templates/bkit-audit-cost.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-database.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +15 -38
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +11 -35
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +18 -42
- package/.bkit/core/docs/templates/bkit-audit-failures.md +13 -37
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +12 -36
- package/.bkit/core/docs/templates/bkit-audit-gates.md +14 -38
- package/.bkit/core/docs/templates/bkit-audit-issues.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-llm.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-logs.md +14 -38
- package/.bkit/core/docs/templates/bkit-audit-models.md +12 -36
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +12 -36
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-repo.md +12 -36
- package/.bkit/core/docs/templates/bkit-audit-security.md +13 -37
- package/.bkit/core/docs/templates/bkit-audit-slop.md +14 -38
- package/.bkit/core/docs/templates/bkit-audit-testing.md +12 -36
- package/.bkit/core/docs/templates/bkit-audit-usability.md +16 -40
- package/.bkit/core/docs/templates/bkit-plan.md +97 -226
- package/.bkit/core/engine/checks/after/ci-yml.ts +39 -29
- package/.bkit/core/engine/checks/after/github.ts +95 -17
- package/.bkit/core/engine/checks/after/index.ts +10 -7
- package/.bkit/core/engine/checks/after/suppression.ts +8 -5
- package/.bkit/core/engine/checks/after/tools.ts +46 -91
- package/.bkit/core/engine/checks/before/env.ts +2 -2
- package/.bkit/core/engine/checks/before/files.ts +5 -4
- package/.bkit/core/engine/checks/before/index.ts +18 -1
- package/.bkit/core/engine/checks/before/repo.ts +168 -2
- package/.bkit/core/engine/checks/tips/catalogue.ts +16 -5
- package/.bkit/core/engine/checks/tips/detect.ts +34 -0
- package/.bkit/core/engine/checks/tips/index.ts +6 -6
- package/.bkit/core/engine/cli.ts +20 -53
- package/.bkit/core/engine/commands/analysis.ts +171 -140
- package/.bkit/core/engine/commands/ci/ci.ts +6 -6
- package/.bkit/core/engine/commands/comply.ts +77 -103
- package/.bkit/core/engine/commands/install/doctor.ts +2 -2
- package/.bkit/core/engine/commands/install/install.ts +57 -18
- package/.bkit/core/engine/commands/install/uninstall.ts +65 -28
- package/.bkit/core/engine/commands/land.ts +18 -12
- package/.bkit/core/engine/commands/lib.ts +79 -17
- package/.bkit/core/engine/commands/registry.ts +4 -0
- package/.bkit/core/engine/commands/setup/setup.ts +7 -7
- package/.bkit/core/engine/commands/stats.ts +204 -0
- package/.bkit/core/engine/commands/tips.ts +10 -5
- package/.bkit/core/engine/commands/workflow/branches.ts +741 -62
- package/.bkit/core/engine/commands/workflow/challenge.ts +673 -0
- package/.bkit/core/engine/commands/workflow/context.ts +853 -29
- package/.bkit/core/engine/commands/workflow/counters.ts +267 -84
- package/.bkit/core/engine/commands/workflow/decisions.ts +541 -0
- package/.bkit/core/engine/commands/workflow/disk.ts +2 -2
- package/.bkit/core/engine/commands/workflow/fids.ts +793 -33
- package/.bkit/core/engine/commands/workflow/issues.ts +407 -64
- package/.bkit/core/engine/commands/workflow/ledgers.ts +884 -27
- package/.bkit/core/engine/commands/workflow/locks.ts +26 -2
- package/.bkit/core/engine/commands/workflow/plan-blocks.ts +582 -0
- package/.bkit/core/engine/commands/workflow/plan-versions.ts +21 -0
- package/.bkit/core/engine/commands/workflow/prs.ts +166 -30
- package/.bkit/core/engine/commands/workflow/repo.ts +58 -8
- package/.bkit/core/engine/commands/workflow/roadmap.ts +16 -7
- package/.bkit/core/engine/commands/workflow/run-facts.ts +501 -0
- package/.bkit/core/engine/commands/workflow/runs.ts +179 -49
- package/.bkit/core/engine/commands/workflow/runtime.ts +22 -1
- package/.bkit/core/engine/commands/workflow/status.ts +142 -29
- package/.bkit/core/engine/commands/workflow/step-table.ts +339 -0
- package/.bkit/core/engine/commands/workflow/steps.ts +213 -88
- package/.bkit/core/engine/commands/workflow/summary.ts +398 -0
- package/.bkit/core/engine/commands/workflow/tests.ts +1013 -148
- package/.bkit/core/engine/commands/workflow/tracker.ts +1195 -0
- package/.bkit/core/engine/commands/workflow/workflows.ts +984 -207
- package/.bkit/core/engine/commands/workflow/workstreams.ts +11 -5
- package/.bkit/core/engine/commands/workflow/worktrees.ts +185 -8
- package/.bkit/core/engine/install/manifest.ts +11 -9
- package/.bkit/core/engine/install/modules/cloud.ts +21 -13
- package/.bkit/core/engine/install/modules/core.ts +250 -3
- package/.bkit/core/engine/install/modules/opencode.ts +2 -2
- package/.bkit/core/engine/install/version-file.ts +6 -2
- package/.bkit/core/engine/ledgers/migrate.ts +92 -0
- package/.bkit/core/engine/ledgers/status.ts +92 -15
- package/.bkit/core/engine/ledgers/telemetry.ts +1261 -254
- package/.bkit/core/engine/render/hosts.ts +4 -0
- package/.bkit/core/engine/render/models.ts +12 -0
- package/.bkit/core/engine/shared/branches.ts +4 -1
- package/.bkit/core/engine/shared/egress.ts +7 -0
- package/.bkit/core/engine/shared/json.ts +25 -7
- package/.bkit/core/engine/shared/settings.ts +157 -20
- package/.bkit/core/engine/shared/text.ts +361 -0
- package/.bkit/core/engine/tools/grammar-density.ts +215 -0
- package/.bkit/core/engine/tools/instructions-sources.ts +834 -0
- package/.bkit/core/engine/tools/instructions.ts +1751 -0
- package/.bkit/core/hooks/gateguard-engine.js +24 -23
- package/.bkit/core/hooks/guardrails-shell.js +2 -3
- package/.bkit/core/hooks/guardrails-tiers.js +7 -1
- package/.bkit/core/hooks/readguard-engine.js +2 -2
- package/.bkit/core/prompts/bkit-audit-generate.md +62 -25
- package/.bkit/core/prompts/bkit-build-challenge-1.md +40 -17
- package/.bkit/core/prompts/bkit-build-challenge-2.md +44 -17
- package/.bkit/core/prompts/bkit-build-install-skills.md +26 -13
- package/.bkit/core/prompts/bkit-build-plan-convert.md +74 -0
- package/.bkit/core/prompts/bkit-build-plan-current.md +26 -13
- package/.bkit/core/prompts/bkit-build-plan-execute.md +74 -26
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +64 -23
- package/.bkit/core/prompts/bkit-build-plan-verify.md +57 -33
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +29 -15
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +34 -14
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +34 -17
- package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +26 -13
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +31 -16
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +21 -11
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +20 -11
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +20 -11
- package/.bkit/core/prompts/bkit-design-generate.md +32 -14
- package/.bkit/core/prompts/bkit-design-organise.md +25 -12
- package/.bkit/core/prompts/bkit-design-review-1.md +31 -15
- package/.bkit/core/prompts/bkit-design-review-2.md +28 -13
- package/.bkit/core/prompts/bkit-design-spike.md +30 -13
- package/.bkit/core/prompts/bkit-design-update.md +33 -19
- package/.bkit/core/prompts/bkit-plan-generate.md +72 -18
- package/.bkit/core/prompts/bkit-plan-review-1.md +50 -27
- package/.bkit/core/prompts/bkit-plan-review-2.md +59 -28
- package/.bkit/core/prompts/bkit-plan-scope-check.md +109 -0
- package/.bkit/core/prompts/bkit-plan-update.md +61 -24
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +27 -15
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +31 -16
- package/.bkit/core/prompts/bkit-ship-update-docs.md +29 -14
- package/.bkit/core/prompts/bkit-utility-compress-markdown.md +24 -14
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +32 -14
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +29 -14
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +27 -12
- package/.bkit/core/prompts/bkit-utility-update-failures.md +31 -14
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +33 -14
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +38 -17
- package/.bkit/core/prompts/bkit-utility-update-tracker.md +41 -18
- package/.bkit/core/workflows/bkit-auto.md +54 -46
- package/.bkit/core/workflows/bkit-build.md +577 -458
- package/.bkit/core/workflows/bkit-debug.md +348 -333
- package/.bkit/core/workflows/bkit-design.md +201 -237
- package/.bkit/core/workflows/bkit-plan.md +210 -321
- package/.bkit/core/workflows/bkit-ship.md +328 -278
- package/.bkit/shared/.bkit/.env.example +2 -2
- package/.bkit/shared/.claude/settings.json +11 -0
- package/.bkit/shared/.cursor/mcp.json +1 -1
- package/.bkit/shared/.cursor/rules/bkit-rules.mdc +1 -1
- package/.bkit/shared/.gitattributes +1 -1
- package/.bkit/shared/.mcp.json +1 -1
- package/.bkit/shared/.opencode/opencode.json +11 -0
- package/.bkit/shared/CLAUDE.md +2 -2
- package/.bkit/shared/GEMINI.md +2 -2
- package/.bkit/shared/docs/architecture.md +1 -1
- package/.bkit/shared/docs/data-schema.md +1 -1
- package/.bkit/shared/docs/deployments.md +11 -11
- package/.bkit/shared/docs/design.md +1 -1
- package/.bkit/shared/docs/noise.md +1 -1
- package/.bkit/shared/docs/observability.md +2 -2
- package/.bkit/shared/docs/security.md +1 -1
- package/.bkit/shared/docs/setup.md +1 -1
- package/.bkit/shared/docs/technology.md +1 -1
- package/.bkit/shared/docs/testing.md +16 -7
- package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +1 -1
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +26 -5
- package/.bkit/templates/.github/workflows/bkit-ci.yml +1 -1
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +21 -19
- package/.bkit/templates/.husky/pre-push +4 -4
- package/.bkit/templates/.prettierignore +7 -0
- package/.bkit/templates/scripts/cleanup/bkit-disk-prune.mjs +1 -1
- package/CHANGELOG.md +112 -0
- package/README.md +50 -35
- package/dist/checks/after/ci-yml.js +39 -28
- package/dist/checks/after/github.js +91 -17
- package/dist/checks/after/index.js +11 -8
- package/dist/checks/after/suppression.js +8 -5
- package/dist/checks/after/tools.js +39 -82
- package/dist/checks/before/env.js +2 -2
- package/dist/checks/before/files.js +5 -3
- package/dist/checks/before/index.js +15 -2
- package/dist/checks/before/repo.js +163 -2
- package/dist/checks/tips/catalogue.js +14 -5
- package/dist/checks/tips/detect.js +32 -0
- package/dist/checks/tips/index.js +4 -4
- package/dist/cli.js +19 -47
- package/dist/commands/analysis.js +109 -100
- package/dist/commands/ci/ci.js +6 -6
- package/dist/commands/comply.js +54 -91
- package/dist/commands/install/doctor.js +2 -2
- package/dist/commands/install/install.js +50 -19
- package/dist/commands/install/uninstall.js +59 -28
- package/dist/commands/land.js +16 -12
- package/dist/commands/lib.js +51 -16
- package/dist/commands/registry.js +4 -0
- package/dist/commands/setup/setup.js +7 -7
- package/dist/commands/stats.js +136 -0
- package/dist/commands/tips.js +7 -3
- package/dist/commands/workflow/branches.js +656 -56
- package/dist/commands/workflow/challenge.js +556 -0
- package/dist/commands/workflow/context.js +709 -30
- package/dist/commands/workflow/counters.js +208 -75
- package/dist/commands/workflow/decisions.js +441 -0
- package/dist/commands/workflow/disk.js +2 -2
- package/dist/commands/workflow/fids.js +689 -33
- package/dist/commands/workflow/issues.js +343 -59
- package/dist/commands/workflow/ledgers.js +762 -27
- package/dist/commands/workflow/locks.js +24 -2
- package/dist/commands/workflow/plan-blocks.js +437 -0
- package/dist/commands/workflow/plan-versions.js +22 -0
- package/dist/commands/workflow/prs.js +142 -32
- package/dist/commands/workflow/repo.js +52 -8
- package/dist/commands/workflow/roadmap.js +9 -7
- package/dist/commands/workflow/run-facts.js +426 -0
- package/dist/commands/workflow/runs.js +144 -43
- package/dist/commands/workflow/runtime.js +12 -1
- package/dist/commands/workflow/status.js +130 -29
- package/dist/commands/workflow/step-table.js +276 -0
- package/dist/commands/workflow/steps.js +171 -80
- package/dist/commands/workflow/summary.js +275 -0
- package/dist/commands/workflow/tests.js +834 -136
- package/dist/commands/workflow/tracker.js +983 -0
- package/dist/commands/workflow/workflows.js +834 -195
- package/dist/commands/workflow/workstreams.js +11 -5
- package/dist/commands/workflow/worktrees.js +147 -9
- package/dist/install/manifest.js +11 -9
- package/dist/install/modules/cloud.js +22 -13
- package/dist/install/modules/core.js +247 -3
- package/dist/install/modules/opencode.js +2 -2
- package/dist/install/version-file.js +6 -2
- package/dist/ledgers/migrate.js +81 -0
- package/dist/ledgers/status.js +61 -8
- package/dist/ledgers/telemetry.js +905 -124
- package/dist/render/hosts.js +4 -0
- package/dist/render/models.js +12 -0
- package/dist/shared/branches.js +3 -1
- package/dist/shared/egress.js +7 -0
- package/dist/shared/json.js +20 -7
- package/dist/shared/settings.js +125 -17
- package/dist/shared/text.js +333 -0
- package/dist/tools/grammar-density.js +183 -0
- package/dist/tools/instructions-sources.js +721 -0
- package/dist/tools/instructions.js +1579 -0
- package/package.json +113 -24
- package/.bkit/core/engine/commands/harvest.ts +0 -459
- package/.bkit/core/engine/tools/wording.ts +0 -748
- package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +0 -69
- package/.bkit/core/prompts/bkit-build-challenge-remediate.md +0 -71
- package/.bkit/core/prompts/bkit-build-challenge-tests.md +0 -74
- package/.bkit/core/prompts/bkit-build-summary.md +0 -94
- package/.bkit/core/prompts/bkit-debug-summary.md +0 -96
- package/.bkit/core/prompts/bkit-design-summary.md +0 -107
- package/.bkit/core/prompts/bkit-plan-complexity-check.md +0 -67
- package/.bkit/core/prompts/bkit-plan-complexity-split.md +0 -88
- package/.bkit/core/prompts/bkit-plan-review-3.md +0 -93
- package/.bkit/core/prompts/bkit-plan-scope-check-1.md +0 -85
- package/.bkit/core/prompts/bkit-plan-scope-check-2.md +0 -85
- package/.bkit/core/prompts/bkit-plan-summary.md +0 -107
- package/.bkit/core/prompts/bkit-ship-summary.md +0 -78
- package/dist/commands/harvest.js +0 -353
- package/dist/tools/wording.js +0 -680
|
@@ -9,13 +9,37 @@
|
|
|
9
9
|
// count routing on a DIFFERENT step, prior or not yet run: the bare count, and
|
|
10
10
|
// 0 is a legal answer (that step simply has not run).
|
|
11
11
|
|
|
12
|
-
import
|
|
13
|
-
|
|
12
|
+
import * as path from "node:path";
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
activeDoneSteps,
|
|
16
|
+
allRunsDoneSteps,
|
|
17
|
+
lastDoneStepAllRuns,
|
|
18
|
+
nextStrategy,
|
|
19
|
+
runNumber,
|
|
20
|
+
type Step,
|
|
21
|
+
} from "../../ledgers/status.js";
|
|
22
|
+
import {
|
|
23
|
+
ASK_POINTS,
|
|
24
|
+
readBkitConfig,
|
|
25
|
+
type AskPoint,
|
|
26
|
+
type AskSetting,
|
|
27
|
+
} from "../../shared/settings.js";
|
|
28
|
+
import { headlessRun } from "./runtime.js";
|
|
29
|
+
import {
|
|
30
|
+
CommandError,
|
|
31
|
+
EXIT,
|
|
32
|
+
git,
|
|
33
|
+
runGit,
|
|
34
|
+
type CommandSpec,
|
|
35
|
+
type FlagValue,
|
|
36
|
+
type RunContext,
|
|
37
|
+
} from "../lib.js";
|
|
14
38
|
import {
|
|
15
39
|
EXIT_NO_STATUS,
|
|
16
40
|
FILE_FLAG,
|
|
41
|
+
GROUP_FLAG,
|
|
17
42
|
STEP_FLAG,
|
|
18
|
-
SUB_PLAN_FLAG,
|
|
19
43
|
WORKFLOW_FLAG,
|
|
20
44
|
positiveInt,
|
|
21
45
|
readRuns,
|
|
@@ -24,24 +48,28 @@ import {
|
|
|
24
48
|
str,
|
|
25
49
|
} from "./status.js";
|
|
26
50
|
|
|
27
|
-
/**
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
/** An ask point by name (`build.verify`); an unknown name is a usage error. */
|
|
52
|
+
export function askPoint(name: string): AskPoint {
|
|
53
|
+
if (!(ASK_POINTS as readonly string[]).includes(name))
|
|
54
|
+
throw new CommandError(EXIT.USAGE, `unknown point ${name}; known: ${ASK_POINTS.join(", ")}`);
|
|
55
|
+
return name as AskPoint;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The checkout `cwd` sits in. */
|
|
59
|
+
const checkoutRoot = (cwd: string): string => git(cwd, ["rev-parse", "--show-toplevel"]) ?? cwd;
|
|
60
|
+
|
|
61
|
+
/** `bkit.workflows.<point>` for the checkout `cwd` sits in. */
|
|
62
|
+
export function askSetting(cwd: string, point: AskPoint): AskSetting {
|
|
63
|
+
return readBkitConfig(checkoutRoot(cwd)).asks[point];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Paths a fix round's code change is judged on: everything but plan logs and ledgers. */
|
|
67
|
+
const SOURCE_PATHS = [
|
|
68
|
+
".",
|
|
69
|
+
":(exclude)docs/plans",
|
|
70
|
+
":(exclude)docs/*.jsonl",
|
|
71
|
+
":(exclude).bkit/*.jsonl",
|
|
72
|
+
];
|
|
45
73
|
|
|
46
74
|
/** Exit code: `--position=current` found no row — the step's own row is missing. */
|
|
47
75
|
export const EXIT_NO_OWN_ROW = 4;
|
|
@@ -59,7 +87,8 @@ const nonNegativeInt = (v: FlagValue, flag: string): number => {
|
|
|
59
87
|
|
|
60
88
|
/**
|
|
61
89
|
* `--of=<step>:<position>` over `--file` / `--workflow`: the counter at that position.
|
|
62
|
-
* `--of=<step>,<step>...:count` sums the DONE rows of every listed step.
|
|
90
|
+
* `--of=<step>,<step>...:count` sums the DONE rows of every listed step. `--all-runs`
|
|
91
|
+
* counts every run of the workflow in the file, not only the active one.
|
|
63
92
|
*/
|
|
64
93
|
function derivedOf(ctx: RunContext): number {
|
|
65
94
|
const [list, position] = String(ctx.flags.of).split(":");
|
|
@@ -71,12 +100,10 @@ function derivedOf(ctx: RunContext): number {
|
|
|
71
100
|
if (ctx.flags.file === undefined || ctx.flags.workflow === undefined)
|
|
72
101
|
throw new CommandError(EXIT.USAGE, "--of needs --file and --workflow");
|
|
73
102
|
const runs = readRuns(statusFile(ctx));
|
|
74
|
-
const
|
|
103
|
+
const group = positiveInt(ctx.flags.group, "group");
|
|
104
|
+
const doneSteps = ctx.flags.allRuns === true ? allRunsDoneSteps : activeDoneSteps;
|
|
75
105
|
const count = steps.reduce(
|
|
76
|
-
(n, step) =>
|
|
77
|
-
n +
|
|
78
|
-
activeDoneSteps(runs, String(ctx.flags.workflow), { step, subPlan }, str(ctx.flags.since))
|
|
79
|
-
.length,
|
|
106
|
+
(n, step) => n + doneSteps(runs, String(ctx.flags.workflow), { step, group }).length,
|
|
80
107
|
0,
|
|
81
108
|
);
|
|
82
109
|
if (position === "current" && count === 0)
|
|
@@ -87,20 +114,124 @@ function derivedOf(ctx: RunContext): number {
|
|
|
87
114
|
return position === "next" ? count + 1 : count;
|
|
88
115
|
}
|
|
89
116
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
117
|
+
/** `--all-runs`: count every run of the workflow in `--file`, not only the active one. */
|
|
118
|
+
const ALL_RUNS_FLAG = {
|
|
119
|
+
name: "all-runs",
|
|
120
|
+
type: "boolean",
|
|
121
|
+
help: "count every run of the workflow in --file, not only the active one",
|
|
122
|
+
} as const;
|
|
123
|
+
|
|
124
|
+
/** Rows of `type` in `workflow`'s active run (since its last workflow-started row). */
|
|
125
|
+
function typedRowCount(file: string, workflow: string, type: string): number {
|
|
126
|
+
const rows = readStatusRows(file);
|
|
127
|
+
let start = -1;
|
|
128
|
+
rows.forEach((r, i) => {
|
|
129
|
+
if (r.type === "workflow-started" && r.workflow === workflow) start = i;
|
|
130
|
+
});
|
|
131
|
+
return rows
|
|
132
|
+
.slice(start + 1)
|
|
133
|
+
.filter((r) => r.type === type && (r.workflow === undefined || r.workflow === workflow)).length;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** `route --rows=<type>:count`: rows of that type in the active run. */
|
|
137
|
+
function derivedRows(ctx: RunContext): number {
|
|
138
|
+
const [type, position] = String(ctx.flags.rows).split(":");
|
|
139
|
+
if (!type || position !== "count")
|
|
140
|
+
throw new CommandError(EXIT.USAGE, "--rows must be <row type>:count");
|
|
141
|
+
if (ctx.flags.file === undefined || ctx.flags.workflow === undefined)
|
|
142
|
+
throw new CommandError(EXIT.USAGE, "--rows needs --file and --workflow");
|
|
143
|
+
return typedRowCount(statusFile(ctx), String(ctx.flags.workflow), type);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** The checkout a status.jsonl under `docs/plans/` belongs to; `cwd` when it is elsewhere. */
|
|
147
|
+
function checkoutOf(file: string, cwd: string): string {
|
|
148
|
+
const abs = path.resolve(cwd, file);
|
|
149
|
+
const at = abs.lastIndexOf(`${path.sep}docs${path.sep}plans${path.sep}`);
|
|
150
|
+
return at < 0 ? cwd : abs.slice(0, at);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export type LoopTrend = "first-round" | "closing" | "stuck" | "worse";
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The loop's direction from its check rounds: `worse` when the problem count rose,
|
|
157
|
+
* `closing` when it fell and the rounds changed code, `stuck` otherwise.
|
|
158
|
+
*/
|
|
159
|
+
export function loopTrend(rounds: Step[], codeChanged: boolean | null): LoopTrend {
|
|
160
|
+
if (rounds.length < 2) return "first-round";
|
|
161
|
+
const first = rounds[0]?.failures;
|
|
162
|
+
const last = rounds.at(-1)?.failures;
|
|
163
|
+
if (first === undefined || last === undefined) return "stuck";
|
|
164
|
+
if (last > first) return "worse";
|
|
165
|
+
if (last < first && codeChanged !== false) return "closing";
|
|
166
|
+
return "stuck";
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface LoopProgress {
|
|
170
|
+
rounds: { attempt: number | null; failures: number | null; at: string }[];
|
|
171
|
+
counts: string;
|
|
172
|
+
codeChanged: boolean | null;
|
|
173
|
+
lastStrategy: string | null;
|
|
174
|
+
nextStrategy: string;
|
|
175
|
+
finalSpent: boolean;
|
|
176
|
+
minutesPerRound: number | null;
|
|
177
|
+
trend: LoopTrend;
|
|
178
|
+
recommend: "try-again" | "stop" | null;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** A fix loop's progress in the active run: `check` counts problems, `fix` fixes them. */
|
|
182
|
+
export function loopProgress(
|
|
183
|
+
file: string,
|
|
184
|
+
cwd: string,
|
|
185
|
+
workflow: string,
|
|
186
|
+
check: string,
|
|
187
|
+
fix: string,
|
|
188
|
+
group: number | undefined,
|
|
189
|
+
): LoopProgress {
|
|
190
|
+
const runs = readRuns(file);
|
|
191
|
+
const rounds = activeDoneSteps(runs, workflow, { step: check, group });
|
|
192
|
+
const fixes = activeDoneSteps(runs, workflow, { step: fix, group });
|
|
193
|
+
const first = rounds[0];
|
|
194
|
+
const last = rounds.at(-1);
|
|
195
|
+
let codeChanged: boolean | null = null;
|
|
196
|
+
if (first && last && first !== last && first.parentSha && last.parentSha) {
|
|
197
|
+
const diff = runGit(checkoutOf(file, cwd), [
|
|
198
|
+
"diff",
|
|
199
|
+
"--quiet",
|
|
200
|
+
first.parentSha,
|
|
201
|
+
last.parentSha,
|
|
202
|
+
"--",
|
|
203
|
+
...SOURCE_PATHS,
|
|
204
|
+
]);
|
|
205
|
+
// --quiet: exit 0 = no change, 1 = changed; anything else (unknown sha) leaves null.
|
|
206
|
+
if (diff.ok) codeChanged = false;
|
|
207
|
+
else if (diff.stderr === "") codeChanged = true;
|
|
97
208
|
}
|
|
98
|
-
|
|
209
|
+
const ladder = lastDoneStepAllRuns(runs, workflow, { step: fix, group })?.strategy;
|
|
210
|
+
const trend = loopTrend(rounds, codeChanged);
|
|
211
|
+
const span =
|
|
212
|
+
first && last && rounds.length > 1
|
|
213
|
+
? (Date.parse(last.at) - Date.parse(first.at)) / 60000 / (rounds.length - 1)
|
|
214
|
+
: null;
|
|
215
|
+
return {
|
|
216
|
+
rounds: rounds.map((r) => ({
|
|
217
|
+
attempt: r.attempt ?? null,
|
|
218
|
+
failures: r.failures ?? null,
|
|
219
|
+
at: r.at,
|
|
220
|
+
})),
|
|
221
|
+
counts: rounds.map((r) => (r.failures === undefined ? "?" : String(r.failures))).join(" → "),
|
|
222
|
+
codeChanged,
|
|
223
|
+
lastStrategy: fixes.at(-1)?.strategy ?? null,
|
|
224
|
+
nextStrategy: nextStrategy(ladder),
|
|
225
|
+
finalSpent: fixes.some((r) => r.strategy === "FINAL") || ladder === "FINAL",
|
|
226
|
+
minutesPerRound: span === null || Number.isNaN(span) ? null : Math.round(span),
|
|
227
|
+
trend,
|
|
228
|
+
recommend: trend === "first-round" ? null : trend === "closing" ? "try-again" : "stop",
|
|
229
|
+
};
|
|
99
230
|
}
|
|
100
231
|
|
|
101
232
|
export const countersCommand: CommandSpec = {
|
|
102
233
|
noun: "counters",
|
|
103
|
-
summary: "Attempt counters derived from status.jsonl, and the
|
|
234
|
+
summary: "Attempt counters derived from status.jsonl, and the ask points' limits.",
|
|
104
235
|
verbs: {
|
|
105
236
|
derive: {
|
|
106
237
|
summary: "Count a step's DONE rows in the active run, at one of three positions.",
|
|
@@ -108,18 +239,14 @@ export const countersCommand: CommandSpec = {
|
|
|
108
239
|
FILE_FLAG,
|
|
109
240
|
WORKFLOW_FLAG,
|
|
110
241
|
STEP_FLAG,
|
|
111
|
-
|
|
242
|
+
GROUP_FLAG,
|
|
112
243
|
{
|
|
113
244
|
name: "position",
|
|
114
245
|
type: "string",
|
|
115
246
|
required: true,
|
|
116
247
|
help: "next (step start: count+1) | current (after own row: count, 0 refused) | count (other step: 0 legal)",
|
|
117
248
|
},
|
|
118
|
-
|
|
119
|
-
name: "since",
|
|
120
|
-
type: "string",
|
|
121
|
-
help: "run field holding a timestamp; only rows after it count (soakEntryAt)",
|
|
122
|
-
},
|
|
249
|
+
ALL_RUNS_FLAG,
|
|
123
250
|
],
|
|
124
251
|
output: { value: "the counter at that position", count: "DONE rows counted" },
|
|
125
252
|
exitCodes: {
|
|
@@ -131,11 +258,10 @@ export const countersCommand: CommandSpec = {
|
|
|
131
258
|
if (!["next", "current", "count"].includes(position)) {
|
|
132
259
|
throw new CommandError(EXIT.USAGE, "--position must be next, current, or count");
|
|
133
260
|
}
|
|
134
|
-
const count = activeDoneSteps(
|
|
261
|
+
const count = (ctx.flags.allRuns === true ? allRunsDoneSteps : activeDoneSteps)(
|
|
135
262
|
readRuns(statusFile(ctx)),
|
|
136
263
|
String(ctx.flags.workflow),
|
|
137
|
-
{ step: String(ctx.flags.step),
|
|
138
|
-
str(ctx.flags.since),
|
|
264
|
+
{ step: String(ctx.flags.step), group: positiveInt(ctx.flags.group, "group") },
|
|
139
265
|
).length;
|
|
140
266
|
if (position === "current" && count === 0) {
|
|
141
267
|
ctx.log(
|
|
@@ -158,29 +284,35 @@ export const countersCommand: CommandSpec = {
|
|
|
158
284
|
},
|
|
159
285
|
},
|
|
160
286
|
route: {
|
|
161
|
-
summary:
|
|
287
|
+
summary:
|
|
288
|
+
"Compare a counter to its max: exit 0 continue, exit 1 exceeded; with --point, also whether to ask.",
|
|
162
289
|
flags: [
|
|
163
290
|
{ name: "name", type: "string", required: true, help: "counter name, for the log line" },
|
|
164
291
|
{
|
|
165
292
|
name: "value",
|
|
166
293
|
type: "string",
|
|
167
|
-
help: "counter value (non-negative integer), or derive it with --of",
|
|
294
|
+
help: "counter value (non-negative integer), or derive it with --of / --rows",
|
|
168
295
|
},
|
|
169
296
|
{
|
|
170
297
|
name: "of",
|
|
171
298
|
type: "string",
|
|
172
299
|
help: "<step>:<next|current|count> — derive the value from --file (active run); <step>,<step>...:count sums the listed steps",
|
|
173
300
|
},
|
|
174
|
-
{ ...FILE_FLAG, required: false, help: "status.jsonl, with --of" },
|
|
175
|
-
{ ...WORKFLOW_FLAG, required: false, help: "workflow, with --of" },
|
|
176
|
-
{ ...SUB_PLAN_FLAG, help: "with --of: only rows for this sub-plan" },
|
|
177
301
|
{
|
|
178
|
-
name: "
|
|
302
|
+
name: "rows",
|
|
303
|
+
type: "string",
|
|
304
|
+
help: "<row type>:count — rows of that type in --file's active run; with --of, added to it",
|
|
305
|
+
},
|
|
306
|
+
{ ...FILE_FLAG, required: false, help: "status.jsonl, with --of or --rows" },
|
|
307
|
+
{ ...WORKFLOW_FLAG, required: false, help: "workflow, with --of or --rows" },
|
|
308
|
+
{ ...GROUP_FLAG, help: "with --of: only rows for this plan group" },
|
|
309
|
+
{ ...ALL_RUNS_FLAG, help: "with --of: count every run of the workflow in --file" },
|
|
310
|
+
{ name: "max", type: "string", help: "max as a number (or use --point)" },
|
|
311
|
+
{
|
|
312
|
+
name: "point",
|
|
179
313
|
type: "string",
|
|
180
|
-
help:
|
|
314
|
+
help: `ask point whose limit is the max: ${ASK_POINTS.join(" | ")}`,
|
|
181
315
|
},
|
|
182
|
-
{ name: "max", type: "string", help: "max as a number (or use --limit)" },
|
|
183
|
-
{ name: "limit", type: "string", help: "max as a threshold name, e.g. MAX_VERIFY_ATTEMPT" },
|
|
184
316
|
{ name: "continue", type: "string", help: "step to go to when value <= max" },
|
|
185
317
|
{ name: "exceeded", type: "string", help: "step to go to when value > max" },
|
|
186
318
|
],
|
|
@@ -189,47 +321,105 @@ export const countersCommand: CommandSpec = {
|
|
|
189
321
|
exceeded: "true when value > max",
|
|
190
322
|
next: "--continue or --exceeded step, whichever applies (null when not given)",
|
|
191
323
|
max: "the max compared against",
|
|
324
|
+
ask: "with --point: the point's ask setting, false when headless (GITHUB_ACTION); else false",
|
|
192
325
|
},
|
|
193
326
|
exitCodes: {
|
|
194
|
-
[EXIT_NO_STATUS]: "--of: status.jsonl missing, unreadable, or not valid NDJSON",
|
|
327
|
+
[EXIT_NO_STATUS]: "--of / --rows: status.jsonl missing, unreadable, or not valid NDJSON",
|
|
195
328
|
[EXIT_NO_OWN_ROW]: "--of=<step>:current counted 0: the step's own row is missing",
|
|
196
329
|
},
|
|
197
330
|
run: (ctx) => {
|
|
198
331
|
const name = String(ctx.flags.name);
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
332
|
+
const derived = ctx.flags.of !== undefined || ctx.flags.rows !== undefined;
|
|
333
|
+
if (derived === (ctx.flags.value !== undefined))
|
|
334
|
+
throw new CommandError(EXIT.USAGE, "give --value, or --of and/or --rows");
|
|
335
|
+
const value = derived
|
|
336
|
+
? (ctx.flags.of !== undefined ? derivedOf(ctx) : 0) +
|
|
337
|
+
(ctx.flags.rows !== undefined ? derivedRows(ctx) : 0)
|
|
338
|
+
: nonNegativeInt(ctx.flags.value, "value");
|
|
339
|
+
if ((ctx.flags.max === undefined) === (ctx.flags.point === undefined)) {
|
|
340
|
+
throw new CommandError(EXIT.USAGE, "give exactly one of --max or --point");
|
|
205
341
|
}
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
: nonNegativeInt(ctx.flags.max, "max");
|
|
342
|
+
const point = ctx.flags.point === undefined ? undefined : askPoint(String(ctx.flags.point));
|
|
343
|
+
const setting = point === undefined ? undefined : askSetting(ctx.cwd, point);
|
|
344
|
+
const max = setting === undefined ? nonNegativeInt(ctx.flags.max, "max") : setting.max;
|
|
210
345
|
const exceeded = value > max;
|
|
211
346
|
if (exceeded) ctx.log(`counter ${name} exceeded max=${max} (value=${value})`);
|
|
212
347
|
ctx.emit({
|
|
213
348
|
value,
|
|
214
349
|
exceeded,
|
|
215
|
-
next:
|
|
350
|
+
next: (exceeded ? str(ctx.flags.exceeded) : str(ctx.flags.continue)) ?? null,
|
|
216
351
|
max,
|
|
352
|
+
ask: setting !== undefined && setting.ask && !headlessRun(ctx.cwd),
|
|
217
353
|
});
|
|
218
354
|
return exceeded ? EXIT.NO : EXIT.OK;
|
|
219
355
|
},
|
|
220
356
|
},
|
|
221
357
|
max: {
|
|
222
|
-
summary: "The
|
|
358
|
+
summary: "The ask points' limits and ask settings: one by --point, or all.",
|
|
359
|
+
flags: [{ name: "point", type: "string", help: "ask point, e.g. debug.fix" }],
|
|
360
|
+
output: {
|
|
361
|
+
value: "the point's limit (with --point)",
|
|
362
|
+
ask: "the point's ask setting, false when headless (with --point)",
|
|
363
|
+
points: "every point's {ask, max} as set (without --point)",
|
|
364
|
+
},
|
|
365
|
+
run: (ctx) => {
|
|
366
|
+
const name = str(ctx.flags.point);
|
|
367
|
+
if (name === undefined) {
|
|
368
|
+
ctx.emit({ points: readBkitConfig(checkoutRoot(ctx.cwd)).asks });
|
|
369
|
+
return EXIT.OK;
|
|
370
|
+
}
|
|
371
|
+
const setting = askSetting(ctx.cwd, askPoint(name));
|
|
372
|
+
ctx.emit({
|
|
373
|
+
value: setting.max,
|
|
374
|
+
ask: setting.ask && !headlessRun(ctx.cwd),
|
|
375
|
+
});
|
|
376
|
+
return EXIT.OK;
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
progress: {
|
|
380
|
+
summary:
|
|
381
|
+
"Progress report for a fix loop in the active run: counts per round, code change, strategy, trend.",
|
|
223
382
|
flags: [
|
|
224
|
-
|
|
383
|
+
FILE_FLAG,
|
|
384
|
+
WORKFLOW_FLAG,
|
|
385
|
+
{
|
|
386
|
+
name: "check",
|
|
387
|
+
type: "string",
|
|
388
|
+
required: true,
|
|
389
|
+
help: "the step that counts problems, e.g. build-plan-verify",
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
name: "fix",
|
|
393
|
+
type: "string",
|
|
394
|
+
required: true,
|
|
395
|
+
help: "the step that fixes them, e.g. build-plan-gaps-remediate",
|
|
396
|
+
},
|
|
397
|
+
GROUP_FLAG,
|
|
225
398
|
],
|
|
226
399
|
output: {
|
|
227
|
-
|
|
228
|
-
|
|
400
|
+
rounds: "the check rounds counted: attempt, failures, at",
|
|
401
|
+
counts: "problem count after each round, e.g. 5 → 2",
|
|
402
|
+
codeChanged:
|
|
403
|
+
"source changed between the first and last check round (null when git cannot tell)",
|
|
404
|
+
lastStrategy: "strategy of the last fix round (null when none ran)",
|
|
405
|
+
nextStrategy: "strategy the next fix round would use",
|
|
406
|
+
finalSpent: "true when a fix round already ran FINAL",
|
|
407
|
+
minutesPerRound: "average minutes between check rounds (null under two rounds)",
|
|
408
|
+
trend: "first-round | closing | stuck | worse",
|
|
409
|
+
recommend: "try-again when closing, else stop (null on the first round)",
|
|
229
410
|
},
|
|
411
|
+
exitCodes: { [EXIT_NO_STATUS]: "status.jsonl missing, unreadable, or not valid NDJSON" },
|
|
230
412
|
run: (ctx) => {
|
|
231
|
-
|
|
232
|
-
|
|
413
|
+
ctx.emit({
|
|
414
|
+
...loopProgress(
|
|
415
|
+
statusFile(ctx),
|
|
416
|
+
ctx.cwd,
|
|
417
|
+
String(ctx.flags.workflow),
|
|
418
|
+
String(ctx.flags.check),
|
|
419
|
+
String(ctx.flags.fix),
|
|
420
|
+
positiveInt(ctx.flags.group, "group"),
|
|
421
|
+
),
|
|
422
|
+
});
|
|
233
423
|
return EXIT.OK;
|
|
234
424
|
},
|
|
235
425
|
},
|
|
@@ -257,18 +447,11 @@ export const countersCommand: CommandSpec = {
|
|
|
257
447
|
const position = String(ctx.flags.position);
|
|
258
448
|
if (!["next", "count"].includes(position))
|
|
259
449
|
throw new CommandError(EXIT.USAGE, "--position must be next or count");
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
if (r.type === "workflow-started" && r.workflow === workflow) start = i;
|
|
266
|
-
});
|
|
267
|
-
const count = rows
|
|
268
|
-
.slice(start + 1)
|
|
269
|
-
.filter(
|
|
270
|
-
(r) => r.type === type && (r.workflow === undefined || r.workflow === workflow),
|
|
271
|
-
).length;
|
|
450
|
+
const count = typedRowCount(
|
|
451
|
+
statusFile(ctx),
|
|
452
|
+
String(ctx.flags.workflow),
|
|
453
|
+
String(ctx.flags.type),
|
|
454
|
+
);
|
|
272
455
|
ctx.emit({ value: position === "next" ? count + 1 : count, count });
|
|
273
456
|
return EXIT.OK;
|
|
274
457
|
},
|