@cbartens/bkit 5.3.0 → 5.5.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 +20 -7
- package/.bkit/core/.agents/docs.md +1 -1
- package/.bkit/core/.agents/rules.md +14 -9
- package/.bkit/core/.bkit/README.md +19 -6
- package/.bkit/core/.bkit/cloud.md +77 -46
- package/.bkit/core/.bkit/comparison.md +3 -3
- package/.bkit/core/.bkit/install.md +21 -18
- package/.bkit/core/.bkit/lite.md +6 -6
- package/.bkit/core/.bkit/pipeline.md +6 -3
- package/.bkit/core/.bkit/prompts.md +14 -10
- package/.bkit/core/.bkit/providers.md +7 -7
- package/.bkit/core/.bkit/templates.md +46 -10
- package/.bkit/core/.bkit/trackers.md +92 -38
- package/.bkit/core/.bkit/workflows.md +140 -116
- package/.bkit/core/AGENTS.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +1 -1
- 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 +2 -2
- 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 +4 -2
- package/.bkit/core/docs/templates/bkit-audit-config.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-cost.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-database.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +5 -5
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +14 -13
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-failures.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-gates.md +5 -2
- package/.bkit/core/docs/templates/bkit-audit-issues.md +25 -8
- package/.bkit/core/docs/templates/bkit-audit-llm.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-logs.md +10 -6
- package/.bkit/core/docs/templates/bkit-audit-models.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +5 -5
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +3 -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 +11 -9
- package/.bkit/core/docs/templates/bkit-audit-slop.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-testing.md +6 -5
- package/.bkit/core/docs/templates/bkit-audit-usability.md +1 -1
- package/.bkit/core/engine/checks/after/auth.ts +88 -45
- package/.bkit/core/engine/checks/after/github.ts +18 -5
- package/.bkit/core/engine/checks/after/index.ts +1 -1
- package/.bkit/core/engine/checks/after/tools.ts +1 -1
- package/.bkit/core/engine/checks/before/env.ts +28 -18
- package/.bkit/core/engine/checks/before/mcp.ts +4 -2
- package/.bkit/core/engine/checks/status-holes.ts +0 -1
- package/.bkit/core/engine/checks/tips/catalogue.ts +31 -2
- package/.bkit/core/engine/checks/tips/index.ts +49 -27
- package/.bkit/core/engine/cli.ts +27 -18
- package/.bkit/core/engine/commands/ci/ci.ts +107 -0
- package/.bkit/core/engine/commands/comply.ts +25 -16
- package/.bkit/core/engine/commands/install/install.ts +11 -4
- package/.bkit/core/engine/commands/install/uninstall.ts +46 -0
- package/.bkit/core/engine/commands/land.ts +156 -0
- package/.bkit/core/engine/commands/lib.ts +10 -8
- package/.bkit/core/engine/commands/registry.ts +2 -0
- package/.bkit/core/engine/commands/tips.ts +7 -3
- package/.bkit/core/engine/commands/workflow/branches.ts +382 -282
- package/.bkit/core/engine/commands/workflow/disk.ts +556 -0
- package/.bkit/core/engine/commands/workflow/fids.ts +23 -15
- package/.bkit/core/engine/commands/workflow/issues.ts +106 -42
- package/.bkit/core/engine/commands/workflow/ledgers.ts +28 -11
- package/.bkit/core/engine/commands/workflow/locks.ts +38 -152
- package/.bkit/core/engine/commands/workflow/prs.ts +14 -3
- package/.bkit/core/engine/commands/workflow/repo.ts +6 -0
- package/.bkit/core/engine/commands/workflow/roadmap.ts +53 -54
- package/.bkit/core/engine/commands/workflow/runtime.ts +3 -2
- package/.bkit/core/engine/commands/workflow/status.ts +33 -11
- package/.bkit/core/engine/commands/workflow/steps.ts +26 -17
- package/.bkit/core/engine/commands/workflow/workflows.ts +442 -269
- package/.bkit/core/engine/commands/workflow/workstreams.ts +3 -2
- package/.bkit/core/engine/commands/workflow/worktrees.ts +11 -1
- package/.bkit/core/engine/install/manifest.ts +31 -10
- package/.bkit/core/engine/install/modules/cloud.ts +3 -1
- package/.bkit/core/engine/install/modules/core.ts +97 -4
- package/.bkit/core/engine/install/modules/opencode.ts +5 -0
- package/.bkit/core/engine/install/placeholders.ts +13 -17
- package/.bkit/core/engine/install/write.ts +37 -1
- package/.bkit/core/engine/render/trackers.ts +35 -23
- package/.bkit/core/engine/shared/egress.ts +6 -0
- package/.bkit/core/engine/shared/settings.ts +96 -1
- package/.bkit/core/engine/shared/timeouts.ts +8 -7
- package/.bkit/core/hooks/guardrails-tiers.js +1 -1
- package/.bkit/core/prompts/bkit-audit-generate.md +80 -7
- package/.bkit/core/prompts/bkit-build-challenge-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-build-challenge-tests.md +1 -1
- package/.bkit/core/prompts/bkit-build-plan-execute.md +1 -1
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +1 -1
- package/.bkit/core/prompts/bkit-design-generate.md +2 -1
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +1 -1
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +4 -2
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +4 -2
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +12 -2
- package/.bkit/core/prompts/bkit-utility-update-failures.md +4 -2
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +4 -2
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +12 -5
- package/.bkit/core/prompts/bkit-utility-update-tracker.md +159 -0
- package/.bkit/core/workflows/bkit-auto.md +19 -6
- package/.bkit/core/workflows/bkit-build.md +64 -22
- package/.bkit/core/workflows/bkit-debug.md +72 -28
- package/.bkit/core/workflows/bkit-design.md +101 -37
- package/.bkit/core/workflows/bkit-plan.md +82 -31
- package/.bkit/core/workflows/bkit-ship.md +127 -108
- package/.bkit/shared/.bkit/.env.example +8 -0
- package/.bkit/shared/.claude/bkit-cloud.md +12 -12
- package/.bkit/shared/.claude/settings.json +4 -1
- package/.bkit/shared/.cursor/bkit-cloud.md +2 -2
- package/.bkit/shared/.cursor/mcp.json +11 -4
- package/.bkit/shared/.mcp.json +11 -4
- package/.bkit/shared/.opencode/opencode.json +2 -0
- package/.bkit/shared/docs/deployments.md +44 -29
- package/.bkit/shared/docs/security.md +1 -1
- package/.bkit/shared/docs/testing.md +3 -3
- package/.bkit/shared/gitignore +1 -2
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +2 -2
- package/.bkit/templates/.github/renovate.json5 +1 -1
- package/.bkit/templates/.github/workflows/bkit-ci.yml +29 -56
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +40 -12
- package/.bkit/templates/.husky/pre-commit +10 -4
- package/.bkit/templates/.husky/pre-push +69 -12
- package/.bkit/templates/.lintstagedrc.json +5 -1
- package/.bkit/templates/scripts/ci/lanes/check-tree-cache.mjs +138 -0
- package/.bkit/templates/scripts/ci/lanes/check-tree-cache.test.mjs +181 -0
- package/.bkit/templates/scripts/cleanup/bkit-disk-prune.machine.mjs +197 -0
- package/.bkit/templates/scripts/cleanup/bkit-disk-prune.mjs +164 -0
- package/.bkit/templates/scripts/graphify/bkit-graphify.sh +1 -1
- package/CHANGELOG.md +85 -1
- package/README.md +102 -100
- package/dist/checks/after/auth.js +81 -45
- package/dist/checks/after/github.js +17 -5
- package/dist/checks/after/index.js +1 -1
- package/dist/checks/after/tools.js +1 -1
- package/dist/checks/before/env.js +24 -17
- package/dist/checks/before/mcp.js +4 -2
- package/dist/checks/status-holes.js +0 -1
- package/dist/checks/tips/catalogue.js +28 -2
- package/dist/checks/tips/index.js +44 -28
- package/dist/cli.js +27 -19
- package/dist/commands/ci/ci.js +100 -0
- package/dist/commands/comply.js +20 -13
- package/dist/commands/install/install.js +10 -4
- package/dist/commands/install/uninstall.js +42 -0
- package/dist/commands/land.js +129 -0
- package/dist/commands/lib.js +9 -6
- package/dist/commands/registry.js +2 -0
- package/dist/commands/tips.js +7 -3
- package/dist/commands/workflow/branches.js +300 -243
- package/dist/commands/workflow/disk.js +452 -0
- package/dist/commands/workflow/fids.js +22 -15
- package/dist/commands/workflow/issues.js +90 -41
- package/dist/commands/workflow/ledgers.js +26 -11
- package/dist/commands/workflow/locks.js +35 -130
- package/dist/commands/workflow/prs.js +8 -3
- package/dist/commands/workflow/repo.js +5 -0
- package/dist/commands/workflow/roadmap.js +52 -57
- package/dist/commands/workflow/runtime.js +3 -2
- package/dist/commands/workflow/status.js +32 -12
- package/dist/commands/workflow/steps.js +20 -13
- package/dist/commands/workflow/workflows.js +397 -251
- package/dist/commands/workflow/workstreams.js +3 -2
- package/dist/commands/workflow/worktrees.js +11 -1
- package/dist/install/manifest.js +30 -10
- package/dist/install/modules/cloud.js +3 -1
- package/dist/install/modules/core.js +95 -5
- package/dist/install/modules/opencode.js +6 -0
- package/dist/install/placeholders.js +13 -19
- package/dist/install/write.js +26 -2
- package/dist/render/trackers.js +34 -20
- package/dist/shared/egress.js +6 -0
- package/dist/shared/settings.js +44 -0
- package/dist/shared/timeouts.js +8 -7
- package/package.json +11 -2
|
@@ -6,14 +6,29 @@ import { spawnSync } from "node:child_process";
|
|
|
6
6
|
// ---------------------------------------------------------------------------
|
|
7
7
|
// [mcp-env] advisories — direnv + .bkit/.env setup (BAR-260)
|
|
8
8
|
// ---------------------------------------------------------------------------
|
|
9
|
+
/** The token a tracker's MCP server reads from `.bkit/.env`, beside `BKIT_GH_TOKEN`. */
|
|
10
|
+
const TRACKER_TOKENS = {
|
|
11
|
+
linear: {
|
|
12
|
+
key: "BKIT_LINEAR_API_KEY",
|
|
13
|
+
description: "Linear personal API key for the Linear MCP server and the Linear preflight hook (generate at https://linear.app/settings/api)",
|
|
14
|
+
},
|
|
15
|
+
jira: {
|
|
16
|
+
key: "BKIT_JIRA_API_TOKEN",
|
|
17
|
+
description: 'Atlassian API token with scopes for the app "Atlassian MCP V2", sent as Bearer to the Jira MCP server (create at https://id.atlassian.com/manage-profile/security/api-tokens; see .bkit/trackers.md § jira)',
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
/** The token names `tracker` needs, `BKIT_GH_TOKEN` first. */
|
|
21
|
+
function tokenKeys(tracker) {
|
|
22
|
+
const own = TRACKER_TOKENS[tracker];
|
|
23
|
+
return own ? ["BKIT_GH_TOKEN", own.key] : ["BKIT_GH_TOKEN"];
|
|
24
|
+
}
|
|
9
25
|
/**
|
|
10
26
|
* Advisory: .bkit/.env.example exists but .bkit/.env does not.
|
|
11
27
|
* Consumer ran `bkit install` (which seeds .env.example) but has not yet
|
|
12
28
|
* copied it to .bkit/.env and filled in their tokens.
|
|
13
29
|
*/
|
|
14
|
-
// `tracker`
|
|
15
|
-
//
|
|
16
|
-
// caller passes the consumer's resolved `bkit.issueTracker`.
|
|
30
|
+
// `tracker` adds its own token to the token prose (`TRACKER_TOKENS`). Defaults to
|
|
31
|
+
// `linear`; the real Phase-3 caller passes the consumer's resolved `bkit.issueTracker`.
|
|
17
32
|
export function detectMissingDotenv(cwd, tracker = "linear") {
|
|
18
33
|
const examplePath = path.join(cwd, ".bkit", ".env.example");
|
|
19
34
|
const envPath = path.join(cwd, ".bkit", ".env");
|
|
@@ -21,7 +36,7 @@ export function detectMissingDotenv(cwd, tracker = "linear") {
|
|
|
21
36
|
return null;
|
|
22
37
|
if (fs.existsSync(envPath))
|
|
23
38
|
return null;
|
|
24
|
-
const tokens = tracker
|
|
39
|
+
const tokens = tokenKeys(tracker).join(", ");
|
|
25
40
|
return {
|
|
26
41
|
id: "mcp-env-missing-dotenv",
|
|
27
42
|
severity: "advisory",
|
|
@@ -57,15 +72,8 @@ export function detectBlankDotenvKeys(cwd, tracker = "linear") {
|
|
|
57
72
|
key: "BKIT_GH_TOKEN",
|
|
58
73
|
description: "fine-grained PAT for the GitHub MCP server (Contents, Pull requests, Issues, Actions, Workflows, Metadata — read/write), or a classic PAT when one token must span owners",
|
|
59
74
|
},
|
|
60
|
-
//
|
|
61
|
-
...(tracker
|
|
62
|
-
? [
|
|
63
|
-
{
|
|
64
|
-
key: "BKIT_LINEAR_API_KEY",
|
|
65
|
-
description: "Linear personal API key for the Linear MCP server and the Linear preflight hook (generate at https://linear.app/settings/api)",
|
|
66
|
-
},
|
|
67
|
-
]
|
|
68
|
-
: []),
|
|
75
|
+
// A tracker token is required only under its tracker.
|
|
76
|
+
...(TRACKER_TOKENS[tracker] ? [TRACKER_TOKENS[tracker]] : []),
|
|
69
77
|
];
|
|
70
78
|
const findings = [];
|
|
71
79
|
for (const { key, description } of REQUIRED_KEYS) {
|
|
@@ -105,9 +113,8 @@ export function detectDirenvMissing(cwd, tracker = "linear") {
|
|
|
105
113
|
const result = spawnSync("which", ["direnv"], { encoding: "utf-8" });
|
|
106
114
|
if (result.status === 0 && result.stdout.trim())
|
|
107
115
|
return null;
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
const exportKeys = tracker === "linear" ? "BKIT_GH_TOKEN / BKIT_LINEAR_API_KEY" : "BKIT_GH_TOKEN";
|
|
116
|
+
const editKeys = tokenKeys(tracker).join(", ");
|
|
117
|
+
const exportKeys = tokenKeys(tracker).join(" / ");
|
|
111
118
|
return {
|
|
112
119
|
id: "mcp-env-direnv-missing",
|
|
113
120
|
severity: "advisory",
|
|
@@ -156,7 +163,7 @@ export function detectDirenvNotAllowed(cwd, tracker = "linear") {
|
|
|
156
163
|
id: "mcp-env-direnv-not-allowed",
|
|
157
164
|
severity: "advisory",
|
|
158
165
|
detect: "direnv is installed but the .envrc in this repo is blocked. .bkit/.env is not being auto-loaded.",
|
|
159
|
-
action: `[mcp-env] Run \`direnv allow\` in this repo to trust the .envrc and enable auto-load of .bkit/.env. direnv will then export ${tracker
|
|
166
|
+
action: `[mcp-env] Run \`direnv allow\` in this repo to trust the .envrc and enable auto-load of .bkit/.env. direnv will then export ${tokenKeys(tracker).join(" and ")} into your shell whenever you cd into the repo.`,
|
|
160
167
|
};
|
|
161
168
|
}
|
|
162
169
|
return null;
|
|
@@ -3,7 +3,7 @@ import * as fs from "node:fs";
|
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { parseJson } from "../../shared/json.js";
|
|
5
5
|
/** Every MCP server key bkit writes; `requiredMcpServersForTracker` picks the required subset. */
|
|
6
|
-
const BKIT_MCP_SERVERS = ["linear", "github"];
|
|
6
|
+
const BKIT_MCP_SERVERS = ["linear", "github", "jira"];
|
|
7
7
|
/**
|
|
8
8
|
* bkit-written servers a workflow step calls under every tracker, so never flagged as extra:
|
|
9
9
|
* the workflows' gh MCP fallback (PR / CI / merge when `gh` is unavailable) calls `github`.
|
|
@@ -60,7 +60,9 @@ export function detectMissingMcpServers(cwd, relPath, issueTracker) {
|
|
|
60
60
|
? `"url": "https://mcp.linear.app/mcp"`
|
|
61
61
|
: key === "github"
|
|
62
62
|
? `"url": "https://api.githubcopilot.com/mcp/"`
|
|
63
|
-
:
|
|
63
|
+
: key === "jira"
|
|
64
|
+
? `"url": "https://mcp.atlassian.com/v2/mcp"`
|
|
65
|
+
: `"url": "<server-url>"`;
|
|
64
66
|
findings.push({
|
|
65
67
|
id: `mcp-missing-server-${key}-${advisoryPathSlug(relPath)}`,
|
|
66
68
|
severity: "advisory",
|
|
@@ -47,7 +47,6 @@ export const SHIP_STEP_ORDER = [
|
|
|
47
47
|
"ship-failure-diagnose",
|
|
48
48
|
"ship-failure-remediate",
|
|
49
49
|
"ship-switch-to-dev",
|
|
50
|
-
"ship-worktree-cleanup",
|
|
51
50
|
"ship-close-workflow",
|
|
52
51
|
];
|
|
53
52
|
/** Steps that appear only in the merge-retry loop — never mandatory, never holes. */
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
// Where an advisory already detects the gap, `fires` calls that detector and `advisories`
|
|
21
21
|
// names its ids, so the tip and the advisory can never disagree and one
|
|
22
22
|
// `bkit.ignoreAdvisories` entry silences both.
|
|
23
|
+
import * as fs from "node:fs";
|
|
24
|
+
import * as path from "node:path";
|
|
25
|
+
import { machineStepsPath, REPO_STEPS } from "../../commands/workflow/disk.js";
|
|
23
26
|
import { detectContextFetchMissing } from "../before/context-fetch.js";
|
|
24
27
|
import { detectBlankDotenvKeys, detectDirenvMissing, detectDirenvNotAllowed, detectMissingDotenv, isCloudOrCi, } from "../before/env.js";
|
|
25
28
|
import { detectGhMcpToken, hasGithubMcpServer } from "../after/auth.js";
|
|
@@ -39,7 +42,7 @@ export const SETUP_TIPS = [
|
|
|
39
42
|
id: "tracker",
|
|
40
43
|
workflows: EVERY_CONTEXT,
|
|
41
44
|
title: "Connect an issue tracker",
|
|
42
|
-
line: "bkit isn't connected to an issue tracker, so it can't read the task it's working on or record what it did. Connect GitHub or
|
|
45
|
+
line: "bkit isn't connected to an issue tracker, so it can't read the task it's working on or record what it did. Connect GitHub, Linear or Jira, or switch this tip off if you don't want one.",
|
|
43
46
|
why: "Every workflow starts by reading the issue it's working on and reports progress back to it as it goes. Without a tracker, you have to paste in what the agent should look at each time, and nothing records what changed or why.",
|
|
44
47
|
ask: 'Connect bkit to GitHub Issues: re-run `bkit install` with the tool flags I use plus `--tracker=github` (it records `bkit.issueTracker` in package.json and adds the tracker server to .mcp.json). If I don\'t want a tracker, set `"issueTracker": "none"` under `bkit` in package.json instead.',
|
|
45
48
|
steps: '`.bkit/install.md` § Optional post-install decisions. Opt out: `"bkit": { "issueTracker": "none" }` in `package.json`.',
|
|
@@ -180,7 +183,7 @@ export const SETUP_TIPS = [
|
|
|
180
183
|
title: "Finish cloud setup",
|
|
181
184
|
line: "You've turned on cloud agents, but setup isn't finished, so cloud runs will stop partway. Finish the remaining steps.",
|
|
182
185
|
why: "With cloud agents, bkit runs on its own: a change that passes its checks gets shipped and one that fails gets investigated, with nobody at the keyboard. That only works once every piece is in place.",
|
|
183
|
-
ask: "Check my cloud-agent setup against .bkit/cloud.md: copy .bkit/templates/.github/workflows/bkit-cloud.yml to .github/workflows/bkit-cloud.yml and .bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh to .claude/hooks/ (for Cursor: .bkit/templates/.cursor/environment.json and .bkit/templates/.cursor/Dockerfile to .cursor/), run `gh secret set ANTHROPIC_API_KEY
|
|
186
|
+
ask: "Check my cloud-agent setup against .bkit/cloud.md: copy .bkit/templates/.github/workflows/bkit-cloud.yml to .github/workflows/bkit-cloud.yml and .bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh to .claude/hooks/ (for Cursor: .bkit/templates/.cursor/environment.json and .bkit/templates/.cursor/Dockerfile to .cursor/), run `gh secret set ANTHROPIC_API_KEY` (or, keyless, `gh variable set` ANTHROPIC_FEDERATION_RULE_ID and ANTHROPIC_ORGANIZATION_ID from a Claude Console federation rule), then tell me which dashboard settings are left.",
|
|
184
187
|
steps: "`.bkit/cloud.md`; `.bkit/templates.md` § Cloud-agent workflow and § Cursor.",
|
|
185
188
|
fires: (cwd) => {
|
|
186
189
|
const cloud = readBkitConfig(cwd).cloudAgents;
|
|
@@ -312,6 +315,29 @@ export const SETUP_TIPS = [
|
|
|
312
315
|
steps: "`.bkit/templates.md` § tmp/ prune.",
|
|
313
316
|
fires: (cwd) => exists(cwd, ".husky/pre-push") && !exists(cwd, "scripts/cleanup/bkit-tmp-prune.mjs"),
|
|
314
317
|
},
|
|
318
|
+
{
|
|
319
|
+
id: "min-push",
|
|
320
|
+
workflows: ["plan", "ship"],
|
|
321
|
+
title: "Quick pushes for logs and records",
|
|
322
|
+
line: "Pushing only plan logs and records still runs every test. Add the quick path for those pushes.",
|
|
323
|
+
why: "A workflow's last push is often just its logs and records. The quick path checks only formatting and wording on such a push, so it takes seconds and never waits on anything another session is using. Any other file still runs everything.",
|
|
324
|
+
ask: 'Copy the min-push parts of .bkit/templates/.husky/pre-push into .husky/pre-push: PUSH_SHAS / PUSH_SHARED_SHAS in the stdin loop, the `Min push` and `CI-suppressor guard on dev / main` blocks, and the `bkit:gate:min` branch. Wrap slow checks below the gates in `if [ "$MIN_PUSH" != "1" ]`.',
|
|
325
|
+
steps: "`.bkit/templates.md` § Git hooks.",
|
|
326
|
+
fires: (cwd) => exists(cwd, ".husky/pre-push") &&
|
|
327
|
+
!fs.readFileSync(path.join(cwd, ".husky/pre-push"), "utf-8").includes("bkit ci min-push"),
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
id: "disk-prune",
|
|
331
|
+
workflows: ALL_WORKFLOWS,
|
|
332
|
+
title: "Keep enough disk free for new worktrees",
|
|
333
|
+
line: "Build caches, Docker images and simulators fill the disk until a workflow cannot make its worktree. Add your own clean-up steps, run after commits and pushes.",
|
|
334
|
+
why: "bkit deletes nothing on its own: you choose the steps, starting from examples that only delete what comes back by itself. Commits run the cheap steps, pushes run the rest, and a workflow runs them before making a worktree on a nearly full disk.",
|
|
335
|
+
ask: "Copy .bkit/templates/scripts/cleanup/bkit-disk-prune.mjs to scripts/cleanup/ and/or .bkit/templates/scripts/cleanup/bkit-disk-prune.machine.mjs to ~/.config/bkit/disk-prune.mjs, edit the steps, then paste the `disk prune` block from the end of each .bkit/templates/.husky hook at the end of yours.",
|
|
336
|
+
steps: "`.bkit/templates.md` § Disk prune.",
|
|
337
|
+
fires: (cwd) => exists(cwd, ".husky/pre-push") &&
|
|
338
|
+
!exists(cwd, REPO_STEPS) &&
|
|
339
|
+
!fs.existsSync(machineStepsPath()),
|
|
340
|
+
},
|
|
315
341
|
// --- setup: only some setups -----------------------------------------------------------
|
|
316
342
|
{
|
|
317
343
|
id: "cursor-files",
|
|
@@ -12,8 +12,17 @@ export const SETUP_TIPS_HEADING = "Setup tips";
|
|
|
12
12
|
export const tipsIntro = (n) => n === 1 ? "Setup tip for a smoother next run:" : "Setup tips for a smoother next run:";
|
|
13
13
|
/** Where the full tip list lives. */
|
|
14
14
|
export const TIPS_DETAILS_POINTER = "Details for every tip: .bkit/advisories.md § Setup tips (refreshed by `bkit check`).";
|
|
15
|
+
/** Last line of a workflow's `## bkit Tips`: how to silence what it shows, by id. */
|
|
16
|
+
export function silenceLine(ids) {
|
|
17
|
+
const names = ids.map((id) => `\`${id}\``);
|
|
18
|
+
const list = names.length > 1 ? `${names.slice(0, -1).join(", ")} and ${names.at(-1)}` : names[0];
|
|
19
|
+
const what = ids.length > 1 ? "these tips" : "this tip";
|
|
20
|
+
return `Want to silence ${what}? Ask your agent to "add ${list} to \`bkit.ignoreAdvisories\` in package.json".`;
|
|
21
|
+
}
|
|
15
22
|
/** `bkit.ignoreAdvisories` key that silences `STAR_TIP`. */
|
|
16
|
-
export const STAR_TIP_ID = "star";
|
|
23
|
+
export const STAR_TIP_ID = "bkit-star";
|
|
24
|
+
/** Older key that also silences `STAR_TIP`, so repos that set it keep the line off. */
|
|
25
|
+
export const STAR_TIP_OLD_ID = "star";
|
|
17
26
|
/**
|
|
18
27
|
* Last line of `bkit tips` output while not silenced, in bare `bkit tips` and the phase
|
|
19
28
|
* workflows only — audits and the ledger / roadmap updaters often run back to back. Not a
|
|
@@ -46,7 +55,8 @@ export function collectTips(cwd, catalogue = SETUP_TIPS) {
|
|
|
46
55
|
else
|
|
47
56
|
tips.push(tip);
|
|
48
57
|
}
|
|
49
|
-
|
|
58
|
+
const star = !ignored.has(STAR_TIP_ID) && !ignored.has(STAR_TIP_OLD_ID);
|
|
59
|
+
return { tips, suppressed, star };
|
|
50
60
|
}
|
|
51
61
|
/**
|
|
52
62
|
* Drop advisory findings whose tip the root package.json silenced, so one
|
|
@@ -74,12 +84,10 @@ function tipTextLines(tip, n) {
|
|
|
74
84
|
lines.push(` Caution: ${tip.caution}`);
|
|
75
85
|
return lines;
|
|
76
86
|
}
|
|
77
|
-
/** One tip as markdown
|
|
78
|
-
function
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
lines.push("", `Caution: ${tip.caution}`);
|
|
82
|
-
return lines;
|
|
87
|
+
/** One tip as one markdown paragraph for a workflow's `## bkit Tips` section. */
|
|
88
|
+
function tipParagraph(tip) {
|
|
89
|
+
const caution = tip.caution ? ` Caution: ${tip.caution}` : "";
|
|
90
|
+
return `**${tip.title}.** ${tip.line} Ask your agent: "${tip.ask}"${caution}`;
|
|
83
91
|
}
|
|
84
92
|
/**
|
|
85
93
|
* `tips` with the ones that matter in `workflow` first, each group in catalogue order.
|
|
@@ -94,40 +102,48 @@ export function starShownIn(workflow) {
|
|
|
94
102
|
return !workflow || ALL_WORKFLOWS.includes(workflow);
|
|
95
103
|
}
|
|
96
104
|
/**
|
|
97
|
-
* `bkit tips` output
|
|
98
|
-
* `
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
105
|
+
* `bkit tips` output. `""` when no tip fires and no star line shows.
|
|
106
|
+
* - `workflow`: the `WORKFLOW_TIPS_CAP` tips that matter most in that workflow as
|
|
107
|
+
* one markdown paragraph each, then `STAR_TIP` when shown, then `silenceLine` naming both — the
|
|
108
|
+
* workflow appends them under its own `## bkit Tips` heading.
|
|
109
|
+
* - neither: the top `TIPS_CAP` tips as a numbered terminal list, where the rest live,
|
|
110
|
+
* then `STAR_TIP` when shown.
|
|
103
111
|
* - `all`: every tip as a numbered list (in the workflow's order when `workflow` is set).
|
|
112
|
+
* `STAR_TIP` shows when `opts.star` is set and `starShownIn(workflow)`.
|
|
104
113
|
*/
|
|
105
114
|
export function formatTips(tips, opts = {}) {
|
|
115
|
+
const star = !!opts.star && starShownIn(opts.workflow);
|
|
116
|
+
if (opts.workflow && !opts.all)
|
|
117
|
+
return formatWorkflowTips(tips, opts.workflow, star);
|
|
106
118
|
const body = formatSetupTips(tips, opts);
|
|
107
|
-
if (!
|
|
119
|
+
if (!star)
|
|
108
120
|
return body;
|
|
109
121
|
return body ? `${body}\n\n${STAR_TIP}` : STAR_TIP;
|
|
110
122
|
}
|
|
111
|
-
/** `formatTips`
|
|
123
|
+
/** `formatTips` for a workflow's `## bkit Tips`: tips, star line, how to silence both. */
|
|
124
|
+
function formatWorkflowTips(tips, workflow, star) {
|
|
125
|
+
const shown = orderForWorkflow(tips, workflow).slice(0, WORKFLOW_TIPS_CAP);
|
|
126
|
+
const ids = shown.map((t) => t.id);
|
|
127
|
+
const parts = shown.map(tipParagraph);
|
|
128
|
+
if (star) {
|
|
129
|
+
parts.push(STAR_TIP);
|
|
130
|
+
ids.push(STAR_TIP_ID);
|
|
131
|
+
}
|
|
132
|
+
if (ids.length === 0)
|
|
133
|
+
return "";
|
|
134
|
+
return [...parts, silenceLine(ids)].join("\n\n");
|
|
135
|
+
}
|
|
136
|
+
/** `formatTips` as a terminal list, without `STAR_TIP`. */
|
|
112
137
|
function formatSetupTips(tips, opts) {
|
|
113
138
|
if (tips.length === 0)
|
|
114
139
|
return "";
|
|
115
140
|
const ordered = opts.workflow ? orderForWorkflow(tips, opts.workflow) : [...tips];
|
|
116
|
-
const
|
|
117
|
-
const shown = opts.all ? ordered : ordered.slice(0, cap);
|
|
141
|
+
const shown = opts.all ? ordered : ordered.slice(0, TIPS_CAP);
|
|
118
142
|
const rest = tips.length - shown.length;
|
|
119
|
-
const more = rest > 0 ? `${rest} more: \`bkit tips --all\`. ` : "";
|
|
120
|
-
if (opts.workflow && !opts.all) {
|
|
121
|
-
const lines = [];
|
|
122
|
-
for (const tip of shown)
|
|
123
|
-
lines.push(...tipMarkdownLines(tip), "");
|
|
124
|
-
lines.push(`${more}${TIPS_DETAILS_POINTER}`);
|
|
125
|
-
return lines.join("\n");
|
|
126
|
-
}
|
|
127
143
|
const lines = [tipsIntro(shown.length), ""];
|
|
128
144
|
shown.forEach((tip, i) => lines.push(...tipTextLines(tip, i + 1), ""));
|
|
129
|
-
if (
|
|
130
|
-
lines.push(more
|
|
145
|
+
if (rest > 0)
|
|
146
|
+
lines.push(`${rest} more: \`bkit tips --all\`.`);
|
|
131
147
|
lines.push(TIPS_DETAILS_POINTER);
|
|
132
148
|
return lines.join("\n");
|
|
133
149
|
}
|
package/dist/cli.js
CHANGED
|
@@ -230,7 +230,7 @@ export function parseArgs(argv) {
|
|
|
230
230
|
}
|
|
231
231
|
if (arg.startsWith("--")) {
|
|
232
232
|
const flag = arg.slice(2);
|
|
233
|
-
// Value-bearing flag: --tracker=<github|linear|none>
|
|
233
|
+
// Value-bearing flag: --tracker=<github|linear|jira|none>
|
|
234
234
|
if (flag.startsWith("tracker=")) {
|
|
235
235
|
const value = flag.slice("tracker=".length);
|
|
236
236
|
const parsed = parseIssueTracker(value);
|
|
@@ -443,7 +443,10 @@ Usage:
|
|
|
443
443
|
Upgrade everything installed (no module flags). Diffs old
|
|
444
444
|
vs new templates; conflict list emitted to stderr. Use
|
|
445
445
|
--auto-apply for CI (apply non-conflicting; exit non-zero
|
|
446
|
-
on any conflict).
|
|
446
|
+
on any conflict). Only a whole file you edited since bkit
|
|
447
|
+
wrote it conflicts; rendered files (agents, commands,
|
|
448
|
+
skills, .bkit/*.md) are always re-rendered — bkit check
|
|
449
|
+
flags an edit to one.
|
|
447
450
|
--to=<version> / --latest atomically BUMP @cbartens/bkit
|
|
448
451
|
(pnpm add), then re-render + re-pin in one step — so a
|
|
449
452
|
version bump can never drift from its rendered mirrors.
|
|
@@ -468,8 +471,8 @@ Usage:
|
|
|
468
471
|
the tips that matter there first and prints one (each
|
|
469
472
|
workflow runs this at its close; audit and utility do the
|
|
470
473
|
same for audits and the ledger / roadmap updaters);
|
|
471
|
-
--all lists every one. Ends with a star line ("star"
|
|
472
|
-
bkit.ignoreAdvisories silences it), except under
|
|
474
|
+
--all lists every one. Ends with a star line ("bkit-star"
|
|
475
|
+
in bkit.ignoreAdvisories silences it), except under
|
|
473
476
|
--workflow=audit|utility. Local checks only. Exits 0.
|
|
474
477
|
bkit status Read-only host/provider status. Reports current host+provider
|
|
475
478
|
(sampled from .claude/, .cursor/, package.json, and the
|
|
@@ -512,7 +515,7 @@ Usage:
|
|
|
512
515
|
(design|plan|build|debug|ship). Without it, prints the
|
|
513
516
|
ledger-health line only. Read-only: exits 0.
|
|
514
517
|
bkit analysis Cross-repo analysis — reports counts/rates/elapsed-time,
|
|
515
|
-
|
|
518
|
+
change-size vs outcome regression, dispatch-size threshold,
|
|
516
519
|
counterSource trust labelling, per-rule compliance
|
|
517
520
|
rate over kind:"compliance" rows, and the
|
|
518
521
|
unjustified-deferral rate per (subagent, model)
|
|
@@ -567,17 +570,20 @@ Dependency updaters (copy an example and own it):
|
|
|
567
570
|
|
|
568
571
|
--auto=<claude|cursor|opencode>
|
|
569
572
|
Cloud-agent (auto-dispatch) integration (opt-in). --auto=claude needs
|
|
570
|
-
tracker=github + the ANTHROPIC_API_KEY repo secret
|
|
573
|
+
tracker=github + the ANTHROPIC_API_KEY repo secret (or the
|
|
574
|
+
ANTHROPIC_FEDERATION_RULE_ID + ANTHROPIC_ORGANIZATION_ID repo variables
|
|
575
|
+
for keyless federation) + the Claude GitHub App; --auto=cursor
|
|
571
576
|
needs tracker=linear; --auto=opencode needs tracker=github + a remote
|
|
572
577
|
opencode provider (OPENCODE_PROVIDER_KEY). Bare --auto is accepted on
|
|
573
578
|
uninstall only.
|
|
574
579
|
|
|
575
580
|
Cross-cutting / modifiers:
|
|
576
|
-
--tracker=<name> Wire issue tracker integration. Values: github, linear, none
|
|
581
|
+
--tracker=<name> Wire issue tracker integration. Values: github, linear, jira, none
|
|
577
582
|
(default). Records bkit.issueTracker in package.json and substitutes
|
|
578
|
-
tracker snippets into command mirrors.
|
|
579
|
-
|
|
580
|
-
|
|
583
|
+
tracker snippets into command mirrors. Re-renders every installed
|
|
584
|
+
host, and works alone (bkit install --tracker=github). Switching is
|
|
585
|
+
free; a switch removes the old linear or jira MCP entry unless you
|
|
586
|
+
edited it (github always stays). Does NOT own AGENTS.md (tracker-agnostic).
|
|
581
587
|
|
|
582
588
|
Install flags:
|
|
583
589
|
--auto-revert On a Phase 3 blocker, automatically run uninstall and exit 1.
|
|
@@ -644,17 +650,18 @@ function commandsUsage() {
|
|
|
644
650
|
}
|
|
645
651
|
/**
|
|
646
652
|
* Validate the verb/module-flag combination before any dispatch
|
|
647
|
-
* work runs. `install` requires >=1 module flag (
|
|
648
|
-
* `check` / `upgrade` take NO module
|
|
649
|
-
* operate on everything already installed, so a stray flag is a hard
|
|
650
|
-
* pointing at the no-flag form. Returns the error message to print, or `null`
|
|
653
|
+
* work runs. `install` requires >=1 module flag or `--tracker=` (which re-renders
|
|
654
|
+
* every installed host); a bare install errors. `check` / `upgrade` take NO module
|
|
655
|
+
* flags — they operate on everything already installed, so a stray flag is a hard
|
|
656
|
+
* error pointing at the no-flag form. Returns the error message to print, or `null`
|
|
651
657
|
* when the combination is valid.
|
|
652
658
|
*/
|
|
653
|
-
export function validateModuleFlagsForVerb(verb, moduleFlags) {
|
|
654
|
-
if (verb === "install" && moduleFlags.size === 0) {
|
|
659
|
+
export function validateModuleFlagsForVerb(verb, moduleFlags, tracker = null) {
|
|
660
|
+
if (verb === "install" && moduleFlags.size === 0 && tracker === null) {
|
|
655
661
|
return ("[bkit] `bkit install` requires at least one module flag. Name what to install: " +
|
|
656
662
|
"--claude, --cursor, --codex, --antigravity, --opencode=<provider> (plus opt-in " +
|
|
657
|
-
`--auto=<${CLOUD_VARIANTS.join("|")}>)
|
|
663
|
+
`--auto=<${CLOUD_VARIANTS.join("|")}>), or --tracker=<name> alone to switch the ` +
|
|
664
|
+
"tracker on what is installed. Run `bkit help` for usage.");
|
|
658
665
|
}
|
|
659
666
|
if ((verb === "check" || verb === "upgrade") && moduleFlags.size > 0) {
|
|
660
667
|
return (`[bkit] \`bkit ${verb}\` takes no module flags — it operates on everything already ` +
|
|
@@ -714,8 +721,9 @@ export async function main() {
|
|
|
714
721
|
await launchApp(verb, process.cwd());
|
|
715
722
|
return;
|
|
716
723
|
}
|
|
717
|
-
// install requires >=1 module flag
|
|
718
|
-
|
|
724
|
+
// install requires >=1 module flag or --tracker=; check/upgrade take NONE
|
|
725
|
+
// (validateModuleFlagsForVerb).
|
|
726
|
+
const moduleFlagsError = validateModuleFlagsForVerb(verb, moduleFlags, tracker);
|
|
719
727
|
if (moduleFlagsError) {
|
|
720
728
|
console.error(moduleFlagsError);
|
|
721
729
|
process.exit(1);
|
package/dist/commands/ci/ci.js
CHANGED
|
@@ -14,11 +14,17 @@
|
|
|
14
14
|
//
|
|
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
|
+
//
|
|
18
|
+
// `min-push` — whether every file a push changes matches `bkit.minPushPaths`, so
|
|
19
|
+
// `.husky/pre-push` runs `bkit:gate:min`. Files decide, never `[skip ci]` (a typed label
|
|
20
|
+
// GitHub reads off the last commit only).
|
|
17
21
|
import { spawnSync } from "node:child_process";
|
|
18
22
|
import * as fs from "node:fs";
|
|
19
23
|
import * as os from "node:os";
|
|
20
24
|
import * as path from "node:path";
|
|
25
|
+
import { readBkitConfig } from "../../shared/settings.js";
|
|
21
26
|
import { CommandError, commitMessage, EXIT, git, parseJson, runGit, SKIP_CI_TOKEN, } from "../lib.js";
|
|
27
|
+
import { changedOutside } from "../workflow/ledgers.js";
|
|
22
28
|
/** Exit code: slop-scan could not be started (not installed, not executable). */
|
|
23
29
|
export const EXIT_SLOP_UNAVAILABLE = 3;
|
|
24
30
|
/** Exit code: slop-scan ran but failed, or its JSON lacks the fields the gate reads. */
|
|
@@ -27,6 +33,8 @@ export const EXIT_SLOP_FAILED = 4;
|
|
|
27
33
|
export const EXIT_NO_WORKTREE = 5;
|
|
28
34
|
/** Exit code: vale could not run, or ended with a runtime error (its exit 2). */
|
|
29
35
|
export const EXIT_VALE_FAILED = 6;
|
|
36
|
+
/** Exit code: a pushed commit, its base, or its `git diff` could not be read. */
|
|
37
|
+
export const EXIT_RANGE_UNKNOWN = 7;
|
|
30
38
|
/** Branches whose merge-base with HEAD is the default base, in order. */
|
|
31
39
|
const BASE_CANDIDATES = ["origin/dev", "origin/main"];
|
|
32
40
|
/** A net score at or below this is float noise, not worsening. */
|
|
@@ -372,6 +380,75 @@ function skipToken(ctx) {
|
|
|
372
380
|
ctx.emit({ ref, sha, token });
|
|
373
381
|
return token === null ? EXIT.NO : EXIT.OK;
|
|
374
382
|
}
|
|
383
|
+
// ---------------------------------------------------------------------------
|
|
384
|
+
// min-push
|
|
385
|
+
// ---------------------------------------------------------------------------
|
|
386
|
+
/** `bkit.minPushPaths` as git pathspecs: `:(glob)` unless an entry carries its own magic. */
|
|
387
|
+
export const minPushPathspecs = (paths) => paths.map((p) => (p.startsWith(":") ? p : `:(glob)${p}`));
|
|
388
|
+
/** Where a pushed commit's range starts: its merge-base with origin/dev, else origin/main. */
|
|
389
|
+
export function pushBase(cwd, sha) {
|
|
390
|
+
for (const cand of BASE_CANDIDATES) {
|
|
391
|
+
if (!runGit(cwd, ["rev-parse", "--verify", "--quiet", cand]).ok)
|
|
392
|
+
continue;
|
|
393
|
+
const mb = runGit(cwd, ["merge-base", sha, cand]);
|
|
394
|
+
if (mb.ok && mb.stdout)
|
|
395
|
+
return mb.stdout;
|
|
396
|
+
}
|
|
397
|
+
return null;
|
|
398
|
+
}
|
|
399
|
+
function minPush(ctx) {
|
|
400
|
+
const top = runGit(ctx.cwd, ["rev-parse", "--show-toplevel"]);
|
|
401
|
+
if (!top.ok)
|
|
402
|
+
throw new CommandError(EXIT.USAGE, `not inside a git repository: ${ctx.cwd}`);
|
|
403
|
+
const given = ctx.flags.ref;
|
|
404
|
+
const refs = Array.isArray(given) && given.length > 0 ? given.map(String) : ["HEAD"];
|
|
405
|
+
const baseFlag = typeof ctx.flags.base === "string" && ctx.flags.base ? ctx.flags.base : null;
|
|
406
|
+
const paths = readBkitConfig(top.stdout).minPushPaths;
|
|
407
|
+
const specs = minPushPathspecs(paths);
|
|
408
|
+
const changed = new Set();
|
|
409
|
+
const outside = new Set();
|
|
410
|
+
for (const ref of refs) {
|
|
411
|
+
const sha = git(ctx.cwd, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`]);
|
|
412
|
+
const base = sha ? (baseFlag ?? pushBase(ctx.cwd, sha)) : null;
|
|
413
|
+
const diff = sha && base ? changedOutside(top.stdout, base, sha, specs) : null;
|
|
414
|
+
if (!diff?.ok) {
|
|
415
|
+
const why = !sha
|
|
416
|
+
? `cannot read commit '${ref}'`
|
|
417
|
+
: !base
|
|
418
|
+
? `no base for ${ref} (neither origin/dev nor origin/main resolves)`
|
|
419
|
+
: `'git diff' failed for ${base}..${ref}: ${diff && !diff.ok ? diff.stderr : ""}`;
|
|
420
|
+
ctx.log(`${why} — not proven a min push`);
|
|
421
|
+
ctx.emit({ minPush: false, reason: "unknown", changed: 0, outside: [], paths });
|
|
422
|
+
return EXIT_RANGE_UNKNOWN;
|
|
423
|
+
}
|
|
424
|
+
for (const p of diff.changed)
|
|
425
|
+
changed.add(p);
|
|
426
|
+
for (const p of diff.outside)
|
|
427
|
+
outside.add(p);
|
|
428
|
+
}
|
|
429
|
+
const result = (reason, code, message) => {
|
|
430
|
+
ctx.log(message);
|
|
431
|
+
ctx.emit({
|
|
432
|
+
minPush: reason === null,
|
|
433
|
+
reason,
|
|
434
|
+
changed: changed.size,
|
|
435
|
+
outside: [...outside].sort(),
|
|
436
|
+
paths,
|
|
437
|
+
});
|
|
438
|
+
return code;
|
|
439
|
+
};
|
|
440
|
+
if (paths.length === 0) {
|
|
441
|
+
return result("no-paths", EXIT.NO, "bkit.minPushPaths is empty — not a min push");
|
|
442
|
+
}
|
|
443
|
+
if (changed.size === 0) {
|
|
444
|
+
return result("no-changes", EXIT.NO, "the push changes no files — not proven a min push");
|
|
445
|
+
}
|
|
446
|
+
if (outside.size > 0) {
|
|
447
|
+
const first = [...outside].sort()[0];
|
|
448
|
+
return result("outside", EXIT.NO, `${outside.size} of ${changed.size} changed files match no min-push path (first: ${first})`);
|
|
449
|
+
}
|
|
450
|
+
return result(null, EXIT.OK, `all ${changed.size} changed files match min-push paths`);
|
|
451
|
+
}
|
|
375
452
|
export const ciCommand = {
|
|
376
453
|
noun: "ci",
|
|
377
454
|
summary: "Gates CI and the git hooks run.",
|
|
@@ -434,5 +511,28 @@ export const ciCommand = {
|
|
|
434
511
|
},
|
|
435
512
|
run: skipToken,
|
|
436
513
|
},
|
|
514
|
+
"min-push": {
|
|
515
|
+
summary: "Exit 0 when every file a push changes matches bkit.minPushPaths (the pre-push light gate).",
|
|
516
|
+
flags: [
|
|
517
|
+
{
|
|
518
|
+
name: "ref",
|
|
519
|
+
type: "string",
|
|
520
|
+
repeatable: true,
|
|
521
|
+
help: "a pushed commit (default HEAD); its range starts at its merge-base with origin/dev, else origin/main",
|
|
522
|
+
},
|
|
523
|
+
{ name: "base", type: "string", help: "start every range here instead" },
|
|
524
|
+
],
|
|
525
|
+
output: {
|
|
526
|
+
minPush: "true when every changed file matches bkit.minPushPaths",
|
|
527
|
+
reason: "null when a min push; else no-paths | no-changes | outside | unknown",
|
|
528
|
+
changed: "files the push changes, across every ref",
|
|
529
|
+
outside: "the changed files no min-push path matches",
|
|
530
|
+
paths: "bkit.minPushPaths as read",
|
|
531
|
+
},
|
|
532
|
+
exitCodes: {
|
|
533
|
+
[EXIT_RANGE_UNKNOWN]: "a pushed commit, its base, or its git diff could not be read",
|
|
534
|
+
},
|
|
535
|
+
run: minPush,
|
|
536
|
+
},
|
|
437
537
|
},
|
|
438
538
|
};
|
package/dist/commands/comply.js
CHANGED
|
@@ -23,13 +23,13 @@ import { gitEnv, resolveGitSha, resolveRepoSlug, } from "../ledgers/telemetry.js
|
|
|
23
23
|
/** SHA charset guard — only raw hex SHAs from the ledger are accepted. */
|
|
24
24
|
const SHA_RE = /^[0-9a-f]{7,40}$/;
|
|
25
25
|
export const realGitAdapter = {
|
|
26
|
-
diffPaths(parentSha, cwd) {
|
|
27
|
-
if (!SHA_RE.test(parentSha)) {
|
|
28
|
-
console.error(`[bkit-comply] diffPaths:
|
|
26
|
+
diffPaths(parentSha, cwd, head = "HEAD") {
|
|
27
|
+
if (!SHA_RE.test(parentSha) || (head !== "HEAD" && !SHA_RE.test(head))) {
|
|
28
|
+
console.error(`[bkit-comply] diffPaths: "${parentSha}..${head}" is not a sha range — skipping diff`);
|
|
29
29
|
return [];
|
|
30
30
|
}
|
|
31
31
|
try {
|
|
32
|
-
const output = execFileSync("git", ["diff", "--name-only", `${parentSha}
|
|
32
|
+
const output = execFileSync("git", ["diff", "--name-only", `${parentSha}..${head}`], {
|
|
33
33
|
cwd,
|
|
34
34
|
env: gitEnv(),
|
|
35
35
|
encoding: "utf8",
|
|
@@ -45,9 +45,11 @@ export const realGitAdapter = {
|
|
|
45
45
|
return [];
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
-
headSubject(cwd) {
|
|
48
|
+
headSubject(cwd, head = "HEAD") {
|
|
49
|
+
if (head !== "HEAD" && !SHA_RE.test(head))
|
|
50
|
+
return "";
|
|
49
51
|
try {
|
|
50
|
-
return execFileSync("git", ["log", "-1", "--format=%s"], {
|
|
52
|
+
return execFileSync("git", ["log", "-1", "--format=%s", head], {
|
|
51
53
|
cwd,
|
|
52
54
|
env: gitEnv(),
|
|
53
55
|
encoding: "utf8",
|
|
@@ -113,8 +115,8 @@ export function runGrader(input) {
|
|
|
113
115
|
try {
|
|
114
116
|
const cwd = input.cwd ?? process.cwd();
|
|
115
117
|
const adapter = input.gitAdapter ?? realGitAdapter;
|
|
116
|
-
const diffPaths = adapter.diffPaths(input.parentSha, cwd);
|
|
117
|
-
const headSubject = adapter.headSubject(cwd);
|
|
118
|
+
const diffPaths = adapter.diffPaths(input.parentSha, cwd, input.headSha);
|
|
119
|
+
const headSubject = adapter.headSubject(cwd, input.headSha);
|
|
118
120
|
const violations = [];
|
|
119
121
|
const noMirrorViolation = ruleNoMirrorEdit(diffPaths);
|
|
120
122
|
if (noMirrorViolation)
|
|
@@ -191,17 +193,22 @@ export function appendComplianceRows(rows, statsPath) {
|
|
|
191
193
|
// ---------------------------------------------------------------------------
|
|
192
194
|
/**
|
|
193
195
|
* Grade `phase` over HEAD~1..HEAD (HEAD alone in a one-commit repo) and append
|
|
194
|
-
* its compliance rows to `<cwd>/.bkit/stats.jsonl`.
|
|
195
|
-
*
|
|
196
|
+
* its compliance rows to `<cwd>/.bkit/stats.jsonl`. With `squashSha` (ship's
|
|
197
|
+
* close, run in the feature worktree) the squash commit is graded instead —
|
|
198
|
+
* its subject and `squash~1..squash` — so the grade covers the whole feature
|
|
199
|
+
* as it reaches main, not the worktree's last commit. Fail-open: any
|
|
200
|
+
* error is logged and returns null, so a close never stops on the grader.
|
|
196
201
|
*/
|
|
197
|
-
export function gradeCompliance(cwd, phase, log) {
|
|
202
|
+
export function gradeCompliance(cwd, phase, log, squashSha) {
|
|
198
203
|
try {
|
|
199
|
-
const
|
|
204
|
+
const squashParent = squashSha === undefined ? "" : resolveGitSha(`${squashSha}~1`, cwd);
|
|
205
|
+
const parentSha = squashParent || resolveGitSha("HEAD~1", cwd) || resolveGitSha("HEAD", cwd);
|
|
200
206
|
if (!parentSha) {
|
|
201
207
|
log("[bkit-comply] cannot resolve a parent SHA (no commits?) — skipping grade");
|
|
202
208
|
return null;
|
|
203
209
|
}
|
|
204
|
-
const
|
|
210
|
+
const headSha = squashParent ? squashSha : undefined;
|
|
211
|
+
const violations = runGrader({ parentSha, phase, cwd, ...(headSha ? { headSha } : {}) });
|
|
205
212
|
const rows = buildComplianceRows({
|
|
206
213
|
violations,
|
|
207
214
|
phase,
|
|
@@ -184,13 +184,19 @@ export async function runInstall(args, upgradeReport = false) {
|
|
|
184
184
|
else if (dryRun)
|
|
185
185
|
console.log(`${LOG_PREFIX} Running in check (dry-run) mode`);
|
|
186
186
|
// `bkit check` scopes drift detection to what is INSTALLED (detected by sentinel files),
|
|
187
|
-
// not to a fixed full set. `install` keeps its explicit resolved set
|
|
188
|
-
|
|
187
|
+
// not to a fixed full set. `install` keeps its explicit resolved set, plus every installed
|
|
188
|
+
// host when `--tracker=` is given: each host renders tracker-specific commands, agents and
|
|
189
|
+
// MCP entries, so a host left out would keep the old tracker's.
|
|
190
|
+
const effectiveModules = verb === "check"
|
|
191
|
+
? detectInstalledModules(process.cwd())
|
|
192
|
+
: tracker !== null
|
|
193
|
+
? new Set([...modules, ...detectInstalledModules(process.cwd())])
|
|
194
|
+
: modules;
|
|
189
195
|
// RENDER-input provider resolution. `bkit check` takes no `--opencode=` flag, so the parsed
|
|
190
196
|
// `opencodeProvider` is null on the check path; it falls back to the INSTALLED provider
|
|
191
197
|
// (package.json `bkit.opencodeProvider`, else the opencode.json provider block). On install
|
|
192
|
-
// `?? detect`
|
|
193
|
-
//
|
|
198
|
+
// `?? detect` fires only when opencode joins as an installed host under `--tracker=`; with
|
|
199
|
+
// `--opencode=<provider>` the flag wins. The PARSED `opencodeProvider` alone drives the persist-to-package.json logic
|
|
194
200
|
// below (gated on `!dryRun` + a real flag). The tracker is resolved from package.json below,
|
|
195
201
|
// so the tracker-dependent opencode mcp block renders the same way on check.
|
|
196
202
|
const renderOpencodeProvider = opencodeProvider ?? detectOpencodeProvider(process.cwd());
|