@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
|
@@ -167,3 +167,35 @@ export function hasTestLinter(cwd) {
|
|
|
167
167
|
}
|
|
168
168
|
return eslintConfigs.some((text) => TEST_LINT_PLUGIN.test(text));
|
|
169
169
|
}
|
|
170
|
+
/** Consumer-owned folders whose files may run bkit and read what it prints. */
|
|
171
|
+
const OUTPUT_READER_DIRS = [".claude/hooks", ".husky", ".github/workflows", "scripts"];
|
|
172
|
+
/**
|
|
173
|
+
* A line that reads bkit's stdout as JSON without asking for it: a bkit call piped to `jq`,
|
|
174
|
+
* or a bkit argument list (`"bkit", "<noun>", "<verb>", …]`) passed to a spawn.
|
|
175
|
+
*/
|
|
176
|
+
const READS_BKIT_TEXT = [
|
|
177
|
+
/\bbkit\b(?:(?!--json)[^\n|])*\|\s*jq\b/i,
|
|
178
|
+
/"bkit",\s*"[a-z-]+",\s*"[a-z-]+"(?:(?!"--json")[^\n\]])*\]/,
|
|
179
|
+
];
|
|
180
|
+
/** Files under `dir` (relative to `cwd`), `node_modules` left out, at most 4 levels down. */
|
|
181
|
+
function filesUnder(cwd, dir, depth = 4) {
|
|
182
|
+
const abs = path.join(cwd, dir);
|
|
183
|
+
if (depth === 0 || !fs.existsSync(abs) || !fs.statSync(abs).isDirectory())
|
|
184
|
+
return [];
|
|
185
|
+
return fs.readdirSync(abs, { withFileTypes: true }).flatMap((e) => {
|
|
186
|
+
const rel = path.posix.join(dir, e.name);
|
|
187
|
+
if (e.isDirectory())
|
|
188
|
+
return e.name === "node_modules" ? [] : filesUnder(cwd, rel, depth - 1);
|
|
189
|
+
return e.isFile() ? [rel] : [];
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Hooks, CI workflows and scripts that parse bkit's output as JSON without `--json`;
|
|
194
|
+
* bkit prints text by default, so each one reads nothing.
|
|
195
|
+
*/
|
|
196
|
+
export function readsBkitText(cwd) {
|
|
197
|
+
return OUTPUT_READER_DIRS.flatMap((dir) => filesUnder(cwd, dir)).filter((rel) => {
|
|
198
|
+
const text = readText(cwd, rel);
|
|
199
|
+
return text.split("\n").some((line) => READS_BKIT_TEXT.some((re) => re.test(line)));
|
|
200
|
+
});
|
|
201
|
+
}
|
|
@@ -17,9 +17,9 @@ export function silenceLine(ids) {
|
|
|
17
17
|
const names = ids.map((id) => `\`${id}\``);
|
|
18
18
|
const list = names.length > 1 ? `${names.slice(0, -1).join(", ")} and ${names.at(-1)}` : names[0];
|
|
19
19
|
const what = ids.length > 1 ? "these tips" : "this tip";
|
|
20
|
-
return `**Want to silence ${what}?** Ask your agent to "add ${list} to \`bkit.
|
|
20
|
+
return `**Want to silence ${what}?** Ask your agent to "add ${list} to \`bkit.advisories.ignore\` in package.json".`;
|
|
21
21
|
}
|
|
22
|
-
/** `bkit.
|
|
22
|
+
/** `bkit.advisories.ignore` key that silences `STAR_TIP`. */
|
|
23
23
|
export const STAR_TIP_ID = "bkit-star";
|
|
24
24
|
/** Older key that also silences `STAR_TIP`, so repos that set it keep the line off. */
|
|
25
25
|
export const STAR_TIP_OLD_ID = "star";
|
|
@@ -32,7 +32,7 @@ export const STAR_TIP = "Do you like bkit? Then give it a star at [https://githu
|
|
|
32
32
|
/** `STAR_TIP` for a workflow's `## bkit Tips`, its question bold like each tip's title. */
|
|
33
33
|
export const STAR_TIP_PARAGRAPH = STAR_TIP.replace("Do you like bkit?", "**Do you like bkit?**");
|
|
34
34
|
/** Intro of the Setup tips section: who reads which field, and how to silence a tip. */
|
|
35
|
-
export const TIPS_SECTION_INTRO = "Things not set up yet, most useful first. For the person: each tip says what goes wrong today and a sentence to ask your agent. For an AI agent: follow each tip's Agent steps unless the person declines it. Silence a tip by adding its id to `bkit.
|
|
35
|
+
export const TIPS_SECTION_INTRO = "Things not set up yet, most useful first. For the person: each tip says what goes wrong today and a sentence to ask your agent. For an AI agent: follow each tip's Agent steps unless the person declines it. Silence a tip by adding its id to `bkit.advisories.ignore` in package.json. Full template catalogue: .bkit/templates.md.";
|
|
36
36
|
/** True when advisory `id` matches catalogue pattern `pattern` (trailing `*` = prefix). */
|
|
37
37
|
export function matchesAdvisory(pattern, id) {
|
|
38
38
|
return pattern.endsWith("*") ? id.startsWith(pattern.slice(0, -1)) : id === pattern;
|
|
@@ -62,7 +62,7 @@ export function collectTips(cwd, catalogue = SETUP_TIPS) {
|
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Drop advisory findings whose tip the root package.json silenced, so one
|
|
65
|
-
* `bkit.
|
|
65
|
+
* `bkit.advisories.ignore` entry silences a tip and the advisories it reuses. Blockers are
|
|
66
66
|
* never dropped.
|
|
67
67
|
*/
|
|
68
68
|
export function dropTipSilencedAdvisories(findings, cwd, onSuppressed, catalogue = SETUP_TIPS) {
|
package/dist/cli.js
CHANGED
|
@@ -10,8 +10,7 @@ import { runCommand } from "./commands/lib.js";
|
|
|
10
10
|
import { launchApp } from "./commands/launch.js";
|
|
11
11
|
import { runStatus, runDoctor } from "./commands/install/doctor.js";
|
|
12
12
|
import { runComplyCommand } from "./commands/comply.js";
|
|
13
|
-
import {
|
|
14
|
-
import { runAnalysisCommand } from "./commands/analysis.js";
|
|
13
|
+
import { runStatsCommand } from "./commands/stats.js";
|
|
15
14
|
import { runTelemetryCommand } from "./commands/telemetry.js";
|
|
16
15
|
import { runTipsCommand } from "./commands/tips.js";
|
|
17
16
|
import { runUpgradeCommand } from "./commands/install/upgrade.js";
|
|
@@ -39,8 +38,7 @@ export const CLASSIC_VERBS = new Set([
|
|
|
39
38
|
"uninstall",
|
|
40
39
|
"upgrade",
|
|
41
40
|
"comply",
|
|
42
|
-
"
|
|
43
|
-
"analysis",
|
|
41
|
+
"stats",
|
|
44
42
|
"telemetry",
|
|
45
43
|
"tips",
|
|
46
44
|
"cursor",
|
|
@@ -149,21 +147,12 @@ export function parseArgs(argv) {
|
|
|
149
147
|
verb = "comply";
|
|
150
148
|
args.shift();
|
|
151
149
|
}
|
|
152
|
-
else if (firstArg === "
|
|
153
|
-
verb = "
|
|
150
|
+
else if (firstArg === "stats") {
|
|
151
|
+
verb = "stats";
|
|
154
152
|
args.shift();
|
|
155
|
-
//
|
|
153
|
+
// stats takes no flags — reject any remaining positional args
|
|
156
154
|
if (args.length > 0 && !args[0]?.startsWith("-")) {
|
|
157
|
-
console.error(`[bkit] \`bkit
|
|
158
|
-
process.exit(1);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
else if (firstArg === "analysis") {
|
|
162
|
-
verb = "analysis";
|
|
163
|
-
args.shift();
|
|
164
|
-
// analysis takes no flags — reject any remaining positional args
|
|
165
|
-
if (args.length > 0 && !args[0]?.startsWith("-")) {
|
|
166
|
-
console.error(`[bkit] \`bkit analysis\` takes no positional args. Run \`bkit help\` for usage.`);
|
|
155
|
+
console.error(`[bkit] \`bkit stats\` takes no positional args. Run \`bkit help\` for usage.`);
|
|
167
156
|
process.exit(1);
|
|
168
157
|
}
|
|
169
158
|
}
|
|
@@ -472,7 +461,7 @@ Usage:
|
|
|
472
461
|
workflow runs this at its close; audit and utility do the
|
|
473
462
|
same for audits and the ledger / roadmap updaters);
|
|
474
463
|
--all lists every one. Ends with a star line ("bkit-star"
|
|
475
|
-
in bkit.
|
|
464
|
+
in bkit.advisories.ignore silences it), except under
|
|
476
465
|
--workflow=audit|utility. Local checks only. Exits 0.
|
|
477
466
|
bkit status Read-only host/provider status. Reports current host+provider
|
|
478
467
|
(sampled from .claude/, .cursor/, package.json, and the
|
|
@@ -493,18 +482,6 @@ Usage:
|
|
|
493
482
|
never gates a workflow. Appends kind:"compliance"
|
|
494
483
|
rows to .bkit/stats.jsonl. Fail-open: always exits 0.
|
|
495
484
|
Valid phases: design, plan, build, debug, ship.
|
|
496
|
-
bkit harvest Cross-repo harvest — COPIES consumer .bkit/stats.jsonl
|
|
497
|
-
and MOVES .bkit/friction.jsonl into harvest/ (COUNT-ONLY
|
|
498
|
-
for docs/deferrals.jsonl and docs/failures.jsonl).
|
|
499
|
-
Reads consumer paths from harvest/consumers.md.
|
|
500
|
-
DESTRUCTIVE: harvested friction rows are REMOVED from
|
|
501
|
-
the consumer, but only after they are fsync'd and read
|
|
502
|
-
back from harvest/. stats.jsonl is never modified.
|
|
503
|
-
harvest/ accumulates and is never cleared; it is
|
|
504
|
-
gitignored, so it is the only record of pruned rows —
|
|
505
|
-
back it up. Never commits
|
|
506
|
-
in any repo. Deduplicates by per-kind composite
|
|
507
|
-
identity. Advisory + fail-open: exits 0.
|
|
508
485
|
bkit telemetry summary [--phase=<workflow>]
|
|
509
486
|
Per-workflow telemetry report: THIS run's metrics
|
|
510
487
|
(duration, size, friction/deferrals/failures added,
|
|
@@ -514,13 +491,12 @@ Usage:
|
|
|
514
491
|
--phase=<workflow>: the workflow to report
|
|
515
492
|
(design|plan|build|debug|ship). Without it, prints the
|
|
516
493
|
ledger-health line only. Read-only: exits 0.
|
|
517
|
-
bkit
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
.bkit/stats.jsonl and docs/deferrals.jsonl.
|
|
494
|
+
bkit stats This repo's stats report: counts, durations, change-size vs
|
|
495
|
+
outcome, counterSource trust, per-rule and per-version
|
|
496
|
+
compliance, and the unjustified-deferral rate per
|
|
497
|
+
(subagent, model). Reads .bkit/stats.jsonl,
|
|
498
|
+
.bkit/friction.jsonl and docs/deferrals.jsonl of THIS repo
|
|
499
|
+
only; writes .bkit/stats.md and prints it.
|
|
524
500
|
Advisory + inform-only: exits 0.
|
|
525
501
|
bkit help Print this message.
|
|
526
502
|
|
|
@@ -548,7 +524,7 @@ Module flags (composable; symmetric install ↔ uninstall):
|
|
|
548
524
|
Ships .opencode/** (agents, commands, opencode.json, bkit-gateguard.js,
|
|
549
525
|
bkit-readguard.js).
|
|
550
526
|
Configure your provider key; verify with \`bkit doctor\`. All installed
|
|
551
|
-
providers tracked in bkit.
|
|
527
|
+
providers tracked in bkit.providers.opencode.installed.
|
|
552
528
|
--codex Codex CLI host. BARE flag — takes no value: Codex runs on one gateway
|
|
553
529
|
(openai), so only --opencode is provider-pluggable. Ships .codex/agents/*.toml
|
|
554
530
|
+ .codex/hooks.json + .codex/hooks/bkit-{gateguard,guardrails,readguard}.cjs,
|
|
@@ -579,7 +555,7 @@ Dependency updaters (copy an example and own it):
|
|
|
579
555
|
|
|
580
556
|
Cross-cutting / modifiers:
|
|
581
557
|
--tracker=<name> Wire issue tracker integration. Values: github, linear, jira, none
|
|
582
|
-
(default). Records bkit.
|
|
558
|
+
(default). Records bkit.tracker.default in package.json and substitutes
|
|
583
559
|
tracker snippets into command mirrors. Re-renders every installed
|
|
584
560
|
host, and works alone (bkit install --tracker=github). Switching is
|
|
585
561
|
free; a switch removes the old linear or jira MCP entry unless you
|
|
@@ -597,7 +573,7 @@ Uninstall flags:
|
|
|
597
573
|
--dry-run Print decision table (FILE / DECISION / REASON) without writing.
|
|
598
574
|
--opencode=<provider>
|
|
599
575
|
Surgical provider removal: removes that provider's block from
|
|
600
|
-
opencode.json + drops it from bkit.
|
|
576
|
+
opencode.json + drops it from bkit.providers.opencode.installed. Does NOT remove
|
|
601
577
|
agents/commands/gateguard. If the removed provider was active, the first
|
|
602
578
|
remaining provider becomes active and the agents are re-rendered to its
|
|
603
579
|
model pins.
|
|
@@ -644,7 +620,7 @@ function commandsUsage() {
|
|
|
644
620
|
return [
|
|
645
621
|
"",
|
|
646
622
|
"",
|
|
647
|
-
"Workflow commands (bkit <noun> <verb> --flags;
|
|
623
|
+
"Workflow commands (bkit <noun> <verb> --flags; text on stdout, --json for JSON; bkit <noun> --help):",
|
|
648
624
|
...COMMANDS.map((c) => ` bkit ${c.noun.padEnd(width)} ${c.summary}`),
|
|
649
625
|
].join("\n");
|
|
650
626
|
}
|
|
@@ -698,12 +674,8 @@ export async function main() {
|
|
|
698
674
|
runComplyCommand(complyPhase);
|
|
699
675
|
return;
|
|
700
676
|
}
|
|
701
|
-
if (verb === "
|
|
702
|
-
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
|
-
if (verb === "analysis") {
|
|
706
|
-
runAnalysisCommand();
|
|
677
|
+
if (verb === "stats") {
|
|
678
|
+
runStatsCommand();
|
|
707
679
|
return;
|
|
708
680
|
}
|
|
709
681
|
if (verb === "telemetry") {
|
|
@@ -1,57 +1,96 @@
|
|
|
1
|
-
// commands/analysis.ts —
|
|
1
|
+
// commands/analysis.ts — the computations behind `bkit stats` (commands/stats.ts) and the
|
|
2
|
+
// cross-repo section of the harvest report (scripts/harvest/, bkit's checkout only).
|
|
2
3
|
//
|
|
3
4
|
// Provides:
|
|
4
5
|
// 1. Counts/rates/elapsed-time over telemetry rows.
|
|
5
|
-
// 2. Size↔outcome regression (
|
|
6
|
-
//
|
|
7
|
-
// 3. Dispatch-size threshold computation
|
|
8
|
-
// 4. `
|
|
9
|
-
// (model-self-report
|
|
6
|
+
// 2. Size↔outcome regression (error rate per `lines.total.added` bucket) over
|
|
7
|
+
// `kind:"outcome"` rows.
|
|
8
|
+
// 3. Dispatch-size threshold computation, printed by `bkit stats` and the harvest report.
|
|
9
|
+
// 4. `counter.source` trust labelling: each outcome row is joined to its `counter` row
|
|
10
|
+
// (model-self-report or shell-bus).
|
|
10
11
|
// 5. Per-rule compliance rate over `kind:"compliance"` rows.
|
|
11
|
-
// 6. Per-`
|
|
12
|
+
// 6. Per-`bkit.version` release-attributed regression.
|
|
12
13
|
//
|
|
13
|
-
//
|
|
14
|
-
// installed; PRs closed >= `--since` date; fields: additions, deletions, changedFiles,
|
|
15
|
-
// commits count (for correctiveCommits proxy). Model-self-report counterSource.
|
|
14
|
+
// Rows are read folded, so rows written without `schema` arrive in the current shape.
|
|
16
15
|
//
|
|
17
16
|
// All computation is advisory + inform-only; never gates any workflow.
|
|
18
17
|
// See DE-34 for the shared-entrypoint + crash-isolation contract.
|
|
19
|
-
import
|
|
20
|
-
import * as path from "node:path";
|
|
21
|
-
import { UNJUSTIFIED_REASON, foldFrom, } from "../ledgers/telemetry.js";
|
|
22
|
-
import { HARVEST_DEST_DIR } from "./harvest.js";
|
|
18
|
+
import { AGENT_CONTEXT_CAP, UNJUSTIFIED_REASON, foldFrom, } from "../ledgers/telemetry.js";
|
|
23
19
|
export function computeCounts(events) {
|
|
24
20
|
const byKind = {};
|
|
25
21
|
const byWorkflow = {};
|
|
26
22
|
const byRepo = {};
|
|
27
23
|
for (const ev of events) {
|
|
28
24
|
byKind[ev.kind] = (byKind[ev.kind] ?? 0) + 1;
|
|
29
|
-
|
|
25
|
+
const workflow = ev.by?.workflow ?? "unknown";
|
|
26
|
+
byWorkflow[workflow] = (byWorkflow[workflow] ?? 0) + 1;
|
|
30
27
|
byRepo[ev.repo] = (byRepo[ev.repo] ?? 0) + 1;
|
|
31
28
|
}
|
|
32
29
|
return { total: events.length, byKind, byWorkflow, byRepo };
|
|
33
30
|
}
|
|
31
|
+
/** Over the rows that carry `time.totalMinutes`. */
|
|
34
32
|
export function computeElapsedStats(rows) {
|
|
35
|
-
|
|
33
|
+
const durations = rows
|
|
34
|
+
.map((r) => r.time?.totalMinutes)
|
|
35
|
+
.filter((m) => typeof m === "number")
|
|
36
|
+
.sort((a, b) => a - b);
|
|
37
|
+
if (durations.length === 0) {
|
|
36
38
|
return {
|
|
37
39
|
count: 0,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
totalMinutes: 0,
|
|
41
|
+
meanMinutes: 0,
|
|
42
|
+
minMinutes: 0,
|
|
43
|
+
maxMinutes: 0,
|
|
44
|
+
p50Minutes: 0,
|
|
43
45
|
};
|
|
44
46
|
}
|
|
45
|
-
const durations = rows.map((r) => r.durationSeconds).sort((a, b) => a - b);
|
|
46
47
|
const total = durations.reduce((s, v) => s + v, 0);
|
|
47
|
-
const p50 = durations[Math.floor(durations.length / 2)] ?? 0;
|
|
48
48
|
return {
|
|
49
|
-
count:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
count: durations.length,
|
|
50
|
+
totalMinutes: total,
|
|
51
|
+
meanMinutes: total / durations.length,
|
|
52
|
+
minMinutes: durations[0] ?? 0,
|
|
53
|
+
maxMinutes: durations[durations.length - 1] ?? 0,
|
|
54
|
+
p50Minutes: durations[Math.floor(durations.length / 2)] ?? 0,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** Over the outcome rows whose `build.challenge.gate` is set. */
|
|
58
|
+
export function computeChallengeGate(rows) {
|
|
59
|
+
const out = { runs: 0, small: 0, large: 0 };
|
|
60
|
+
for (const r of rows) {
|
|
61
|
+
const gate = r.build?.challenge?.gate;
|
|
62
|
+
if (gate === undefined)
|
|
63
|
+
continue;
|
|
64
|
+
out.runs++;
|
|
65
|
+
if (gate.skipped)
|
|
66
|
+
out.small++;
|
|
67
|
+
else
|
|
68
|
+
out.large++;
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
/** Each agent type's context peak over the outcome rows' `context` blocks, against `cap`. */
|
|
73
|
+
export function computeAgentContext(rows, cap = AGENT_CONTEXT_CAP) {
|
|
74
|
+
const by = {};
|
|
75
|
+
let recorded = 0;
|
|
76
|
+
for (const r of rows) {
|
|
77
|
+
if (r.context === undefined)
|
|
78
|
+
continue;
|
|
79
|
+
recorded++;
|
|
80
|
+
for (const [agent, a] of Object.entries(r.context.byAgent)) {
|
|
81
|
+
const e = (by[agent] ??= { agent, subagents: 0, runs: 0, peak: 0, overCap: 0 });
|
|
82
|
+
e.subagents += a.runs;
|
|
83
|
+
e.runs++;
|
|
84
|
+
e.peak = Math.max(e.peak, a.peak);
|
|
85
|
+
if (a.peak > cap)
|
|
86
|
+
e.overCap++;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
cap,
|
|
91
|
+
outcomes: rows.length,
|
|
92
|
+
recorded,
|
|
93
|
+
byAgent: Object.values(by).sort((a, b) => b.peak - a.peak || a.agent.localeCompare(b.agent)),
|
|
55
94
|
};
|
|
56
95
|
}
|
|
57
96
|
const SIZE_BUCKETS = [
|
|
@@ -64,7 +103,7 @@ const SIZE_BUCKETS = [
|
|
|
64
103
|
/**
|
|
65
104
|
* Per-run NEW failures = this row's cumulative total minus the previous row's.
|
|
66
105
|
*
|
|
67
|
-
* `
|
|
106
|
+
* `ledgers.failures.repo` is the repo's CUMULATIVE distinct-failure count at close.
|
|
68
107
|
*
|
|
69
108
|
* Previous = the newest outcome row for the SAME repo strictly before this one; the
|
|
70
109
|
* first row for a repo has no predecessor, so its total IS its delta.
|
|
@@ -75,25 +114,22 @@ export function newFailuresThisRun(row, allRows) {
|
|
|
75
114
|
const previous = allRows
|
|
76
115
|
.filter((r) => r.repo === row.repo && r.ts < row.ts)
|
|
77
116
|
.sort((a, b) => b.ts - a.ts)[0];
|
|
117
|
+
const failures = (r) => r.ledgers?.failures?.repo ?? 0;
|
|
78
118
|
if (!previous)
|
|
79
|
-
return row
|
|
80
|
-
return Math.max(0, row
|
|
81
|
-
}
|
|
82
|
-
function isErrorRun(row, allRows) {
|
|
83
|
-
return ((row.ciTrySuccess !== undefined && row.ciTrySuccess > 1) ||
|
|
84
|
-
(row.correctiveCommits !== undefined && row.correctiveCommits > 0) ||
|
|
85
|
-
(row.reviewIterations !== undefined && row.reviewIterations > 1) ||
|
|
86
|
-
newFailuresThisRun(row, allRows) > 0);
|
|
119
|
+
return failures(row);
|
|
120
|
+
return Math.max(0, failures(row) - failures(previous));
|
|
87
121
|
}
|
|
122
|
+
const isErrorRun = (row, allRows) => newFailuresThisRun(row, allRows) > 0;
|
|
88
123
|
/** Identity of one workflow run: the key the close writes on both its counter and outcome rows. */
|
|
89
124
|
function runKey(row) {
|
|
90
|
-
|
|
125
|
+
const sha = row.run?.parentSha;
|
|
126
|
+
return sha ? JSON.stringify([row.repo, row.by?.workflow, sha]) : undefined;
|
|
91
127
|
}
|
|
92
128
|
export function computeRegression(rows, counterRows) {
|
|
93
129
|
const shellBusRuns = new Set();
|
|
94
130
|
for (const c of counterRows) {
|
|
95
131
|
const key = runKey(c);
|
|
96
|
-
if (c.
|
|
132
|
+
if (c.counter?.source === "shell-bus" && key !== undefined)
|
|
97
133
|
shellBusRuns.add(key);
|
|
98
134
|
}
|
|
99
135
|
const buckets = SIZE_BUCKETS.map((b) => ({
|
|
@@ -115,8 +151,8 @@ export function computeRegression(rows, counterRows) {
|
|
|
115
151
|
else {
|
|
116
152
|
modelSelfReportCount++;
|
|
117
153
|
}
|
|
118
|
-
// Bucket by
|
|
119
|
-
const lines = row.
|
|
154
|
+
// Bucket by lines added
|
|
155
|
+
const lines = row.lines?.total?.added ?? 0;
|
|
120
156
|
for (const bucket of buckets) {
|
|
121
157
|
if (lines >= bucket.minLines && lines <= bucket.maxLines) {
|
|
122
158
|
bucket.count++;
|
|
@@ -150,14 +186,15 @@ export function computeRegression(rows, counterRows) {
|
|
|
150
186
|
export function computeComplianceRates(rows) {
|
|
151
187
|
const byRule = {};
|
|
152
188
|
for (const row of rows) {
|
|
153
|
-
|
|
154
|
-
|
|
189
|
+
const id = row.rule?.id ?? "unknown";
|
|
190
|
+
if (!byRule[id]) {
|
|
191
|
+
byRule[id] = { passCount: 0, failCount: 0, naCount: 0, totalCount: 0 };
|
|
155
192
|
}
|
|
156
|
-
const r = byRule[
|
|
193
|
+
const r = byRule[id];
|
|
157
194
|
r.totalCount++;
|
|
158
|
-
if (row.
|
|
195
|
+
if (row.rule?.verdict === "pass")
|
|
159
196
|
r.passCount++;
|
|
160
|
-
else if (row.
|
|
197
|
+
else if (row.rule?.verdict === "fail")
|
|
161
198
|
r.failCount++;
|
|
162
199
|
else
|
|
163
200
|
r.naCount++;
|
|
@@ -171,20 +208,21 @@ export function computeComplianceRates(rows) {
|
|
|
171
208
|
export function computeVersionCompliance(rows) {
|
|
172
209
|
const byVersion = {};
|
|
173
210
|
for (const row of rows) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
211
|
+
const version = row.bkit?.version ?? "unknown";
|
|
212
|
+
if (!byVersion[version])
|
|
213
|
+
byVersion[version] = { pass: 0, total: 0 };
|
|
214
|
+
const v = byVersion[version];
|
|
177
215
|
v.total++;
|
|
178
|
-
if (row.
|
|
216
|
+
if (row.rule?.verdict === "pass")
|
|
179
217
|
v.pass++;
|
|
180
218
|
}
|
|
181
219
|
return Object.entries(byVersion)
|
|
182
|
-
.map(([
|
|
183
|
-
|
|
220
|
+
.map(([version, { pass, total }]) => ({
|
|
221
|
+
version,
|
|
184
222
|
passRate: total > 0 ? pass / total : 0,
|
|
185
223
|
totalRuns: total,
|
|
186
224
|
}))
|
|
187
|
-
.sort((a, b) => a.
|
|
225
|
+
.sort((a, b) => a.version.localeCompare(b.version, undefined, { numeric: true }));
|
|
188
226
|
}
|
|
189
227
|
/**
|
|
190
228
|
* Unjustified-rate per `(subagent, model)`.
|
|
@@ -196,8 +234,8 @@ export function computeVersionCompliance(rows) {
|
|
|
196
234
|
export function computeDeferralDiscipline(rows) {
|
|
197
235
|
const byWriter = {};
|
|
198
236
|
for (const row of rows) {
|
|
199
|
-
const writer = row.subagent ?? (row.workflow ? `${row.workflow} (orchestrator)` : "unattributed");
|
|
200
|
-
const model = row.model ?? "unknown";
|
|
237
|
+
const writer = row.by?.subagent ?? (row.by?.workflow ? `${row.by.workflow} (orchestrator)` : "unattributed");
|
|
238
|
+
const model = row.by?.model ?? "unknown";
|
|
201
239
|
const id = `${writer}\u0000${model}`;
|
|
202
240
|
if (!byWriter[id])
|
|
203
241
|
byWriter[id] = { writer, model, total: 0, unjustifiedCount: 0, byReason: {} };
|
|
@@ -222,9 +260,10 @@ export function computeDeferralDiscipline(rows) {
|
|
|
222
260
|
b.total - a.total ||
|
|
223
261
|
a.writer.localeCompare(b.writer));
|
|
224
262
|
}
|
|
225
|
-
|
|
263
|
+
/** Analyse the folded rows of `paths`, leaving out rows of `skipKinds`. */
|
|
264
|
+
export function runAnalysis(paths, skipKinds = new Set()) {
|
|
226
265
|
const { state, rowCount, malformedLineCount } = foldFrom(paths);
|
|
227
|
-
const events = [...state.values()];
|
|
266
|
+
const events = [...state.values()].filter((ev) => !skipKinds.has(ev.kind));
|
|
228
267
|
const outcomeRows = [];
|
|
229
268
|
const counterRows = [];
|
|
230
269
|
const complianceRows = [];
|
|
@@ -249,6 +288,8 @@ export function runAnalysis(paths) {
|
|
|
249
288
|
const complianceRates = computeComplianceRates(complianceRows);
|
|
250
289
|
const versionCompliance = computeVersionCompliance(complianceRows);
|
|
251
290
|
const deferralDiscipline = computeDeferralDiscipline(deferralRows);
|
|
291
|
+
const challengeGate = computeChallengeGate(outcomeRows);
|
|
292
|
+
const agentContext = computeAgentContext(outcomeRows);
|
|
252
293
|
const reportLines = [
|
|
253
294
|
`[bkit-analysis] Telemetry rows: ${rowCount} | malformed: ${malformedLineCount}`,
|
|
254
295
|
`[bkit-analysis] Kinds: ${JSON.stringify(counts.byKind)}`,
|
|
@@ -256,16 +297,19 @@ export function runAnalysis(paths) {
|
|
|
256
297
|
`[bkit-analysis] Run outcomes: ${outcomeRows.length} | Compliance rows: ${complianceRows.length}`,
|
|
257
298
|
];
|
|
258
299
|
if (elapsed.count > 0) {
|
|
259
|
-
reportLines.push(`[bkit-analysis] Duration (
|
|
300
|
+
reportLines.push(`[bkit-analysis] Duration (min): mean=${elapsed.meanMinutes.toFixed(1)} | p50=${elapsed.p50Minutes.toFixed(1)} | min=${elapsed.minMinutes} | max=${elapsed.maxMinutes}`);
|
|
260
301
|
}
|
|
261
302
|
// Regression report
|
|
262
|
-
reportLines.push(`[bkit-analysis] #183 Size↔outcome regression (dispatch-size threshold: ${regression.dispatchSizeThreshold}
|
|
303
|
+
reportLines.push(`[bkit-analysis] #183 Size↔outcome regression (dispatch-size threshold: ${regression.dispatchSizeThreshold} lines added):`);
|
|
263
304
|
for (const b of regression.buckets) {
|
|
264
305
|
if (b.count > 0) {
|
|
265
306
|
reportLines.push(` ${b.label}: ${b.count} runs, ${b.errorCount} errors (${(b.errorRate * 100).toFixed(1)}%)`);
|
|
266
307
|
}
|
|
267
308
|
}
|
|
268
|
-
reportLines.push(`[bkit-analysis]
|
|
309
|
+
reportLines.push(`[bkit-analysis] counter.source trust: shell-bus=${regression.shellBusCount} (trusted) | model-self-report=${regression.modelSelfReportCount} (untrusted)`);
|
|
310
|
+
if (challengeGate.runs > 0) {
|
|
311
|
+
reportLines.push(`[bkit-analysis] Build challenge size: ${challengeGate.small} small (challenge-1 skipped) | ${challengeGate.large} large, of ${challengeGate.runs} runs`);
|
|
312
|
+
}
|
|
269
313
|
// Compliance rates
|
|
270
314
|
if (complianceRates.length > 0) {
|
|
271
315
|
reportLines.push(`[bkit-analysis] Per-rule compliance rates:`);
|
|
@@ -275,9 +319,9 @@ export function runAnalysis(paths) {
|
|
|
275
319
|
}
|
|
276
320
|
// Version compliance
|
|
277
321
|
if (versionCompliance.length > 0) {
|
|
278
|
-
reportLines.push(`[bkit-analysis] Per-
|
|
322
|
+
reportLines.push(`[bkit-analysis] Per-bkit.version compliance:`);
|
|
279
323
|
for (const v of versionCompliance) {
|
|
280
|
-
reportLines.push(` v${v.
|
|
324
|
+
reportLines.push(` v${v.version}: ${(v.passRate * 100).toFixed(1)}% pass (${v.totalRuns} runs)`);
|
|
281
325
|
}
|
|
282
326
|
}
|
|
283
327
|
// Deferral discipline — who defers work they should have finished.
|
|
@@ -299,43 +343,8 @@ export function runAnalysis(paths) {
|
|
|
299
343
|
complianceRates,
|
|
300
344
|
versionCompliance,
|
|
301
345
|
deferralDiscipline,
|
|
346
|
+
challengeGate,
|
|
347
|
+
agentContext,
|
|
302
348
|
reportLines,
|
|
303
349
|
};
|
|
304
350
|
}
|
|
305
|
-
// analysis — cross-repo analysis CLI.
|
|
306
|
-
// Reports counts/rates/elapsed-time, size↔outcome regression, per-rule compliance
|
|
307
|
-
// rate, dispatch-size threshold, counterSource trust labelling. Advisory + inform-only.
|
|
308
|
-
// See DE-34 for the shared-entrypoint + crash-isolation contract.
|
|
309
|
-
export function runAnalysisCommand() {
|
|
310
|
-
try {
|
|
311
|
-
const cwd = process.cwd();
|
|
312
|
-
// Analyse: bkit's own stats.jsonl + harvested consumer rows.
|
|
313
|
-
// Harvest dest is sourced from the constant, NOT re-spelled here.
|
|
314
|
-
const statsPath = path.join(cwd, ".bkit", "stats.jsonl");
|
|
315
|
-
const harvestStatsPath = path.join(cwd, HARVEST_DEST_DIR, "stats.jsonl");
|
|
316
|
-
const harvestFrictionPath = path.join(cwd, HARVEST_DEST_DIR, "friction.jsonl");
|
|
317
|
-
const frictionPath = path.join(cwd, ".bkit", "friction.jsonl");
|
|
318
|
-
// deferrals is LOCAL-only: harvest takes it count-only (prose never leaves the
|
|
319
|
-
// consumer), so the discipline rate is this repo's own writers, not a fleet view.
|
|
320
|
-
const deferralsPath = path.join(cwd, "docs", "deferrals.jsonl");
|
|
321
|
-
const paths = [
|
|
322
|
-
statsPath,
|
|
323
|
-
harvestStatsPath,
|
|
324
|
-
harvestFrictionPath,
|
|
325
|
-
frictionPath,
|
|
326
|
-
deferralsPath,
|
|
327
|
-
].filter((p) => fs.existsSync(p));
|
|
328
|
-
if (paths.length === 0) {
|
|
329
|
-
console.log("[bkit-analysis] No telemetry files found. Run `bkit harvest` first, or accumulate telemetry via bkit workflows.");
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
const report = runAnalysis(paths);
|
|
333
|
-
for (const line of report.reportLines) {
|
|
334
|
-
console.log(line);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
catch (err) {
|
|
338
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
339
|
-
console.error(`[bkit-analysis] analysis error (fail-open): ${msg}`);
|
|
340
|
-
}
|
|
341
|
-
}
|
package/dist/commands/ci/ci.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// `skip-token` — whether a commit message carries a GitHub skip-CI token
|
|
16
16
|
// (`SKIP_CI_TOKEN`), for the `.husky/pre-push` CI-suppressor guard.
|
|
17
17
|
//
|
|
18
|
-
// `min-push` — whether every file a push changes matches `bkit.minPushPaths`, so
|
|
18
|
+
// `min-push` — whether every file a push changes matches `bkit.testing.minPushPaths`, so
|
|
19
19
|
// `.husky/pre-push` runs `bkit:gate:min`. Files decide, never `[skip ci]` (a typed label
|
|
20
20
|
// GitHub reads off the last commit only).
|
|
21
21
|
import { spawnSync } from "node:child_process";
|
|
@@ -383,7 +383,7 @@ function skipToken(ctx) {
|
|
|
383
383
|
// ---------------------------------------------------------------------------
|
|
384
384
|
// min-push
|
|
385
385
|
// ---------------------------------------------------------------------------
|
|
386
|
-
/** `bkit.minPushPaths` as git pathspecs: `:(glob)` unless an entry carries its own magic. */
|
|
386
|
+
/** `bkit.testing.minPushPaths` as git pathspecs: `:(glob)` unless an entry carries its own magic. */
|
|
387
387
|
export const minPushPathspecs = (paths) => paths.map((p) => (p.startsWith(":") ? p : `:(glob)${p}`));
|
|
388
388
|
/** Where a pushed commit's range starts: its merge-base with origin/dev, else origin/main. */
|
|
389
389
|
export function pushBase(cwd, sha) {
|
|
@@ -438,7 +438,7 @@ function minPush(ctx) {
|
|
|
438
438
|
return code;
|
|
439
439
|
};
|
|
440
440
|
if (paths.length === 0) {
|
|
441
|
-
return result("no-paths", EXIT.NO, "bkit.minPushPaths is empty — not a min push");
|
|
441
|
+
return result("no-paths", EXIT.NO, "bkit.testing.minPushPaths is empty — not a min push");
|
|
442
442
|
}
|
|
443
443
|
if (changed.size === 0) {
|
|
444
444
|
return result("no-changes", EXIT.NO, "the push changes no files — not proven a min push");
|
|
@@ -512,7 +512,7 @@ export const ciCommand = {
|
|
|
512
512
|
run: skipToken,
|
|
513
513
|
},
|
|
514
514
|
"min-push": {
|
|
515
|
-
summary: "Exit 0 when every file a push changes matches bkit.minPushPaths (the pre-push light gate).",
|
|
515
|
+
summary: "Exit 0 when every file a push changes matches bkit.testing.minPushPaths (the pre-push light gate).",
|
|
516
516
|
flags: [
|
|
517
517
|
{
|
|
518
518
|
name: "ref",
|
|
@@ -523,11 +523,11 @@ export const ciCommand = {
|
|
|
523
523
|
{ name: "base", type: "string", help: "start every range here instead" },
|
|
524
524
|
],
|
|
525
525
|
output: {
|
|
526
|
-
minPush: "true when every changed file matches bkit.minPushPaths",
|
|
526
|
+
minPush: "true when every changed file matches bkit.testing.minPushPaths",
|
|
527
527
|
reason: "null when a min push; else no-paths | no-changes | outside | unknown",
|
|
528
528
|
changed: "files the push changes, across every ref",
|
|
529
529
|
outside: "the changed files no min-push path matches",
|
|
530
|
-
paths: "bkit.minPushPaths as read",
|
|
530
|
+
paths: "bkit.testing.minPushPaths as read",
|
|
531
531
|
},
|
|
532
532
|
exitCodes: {
|
|
533
533
|
[EXIT_RANGE_UNKNOWN]: "a pushed commit, its base, or its git diff could not be read",
|