@cbartens/bkit 5.2.4 → 5.3.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 +26 -11
- package/.bkit/core/.agents/context.md +1 -1
- package/.bkit/core/.agents/docs.md +1 -1
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +1 -1
- package/.bkit/core/.agents/rules.md +11 -0
- package/.bkit/core/.bkit/README.md +25 -10
- package/.bkit/core/.bkit/cloud.md +9 -8
- package/.bkit/core/.bkit/comparison.md +68 -345
- package/.bkit/core/.bkit/install.md +12 -6
- package/.bkit/core/.bkit/lite.md +73 -0
- package/.bkit/core/.bkit/pipeline.md +345 -0
- package/.bkit/core/.bkit/prompts.md +88 -73
- package/.bkit/core/.bkit/providers.md +41 -22
- package/.bkit/core/.bkit/templates.md +106 -17
- package/.bkit/core/.bkit/trackers.md +47 -1
- package/.bkit/core/.bkit/workflows.md +44 -43
- package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +1 -1
- package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +7 -4
- package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +8 -5
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +14 -10
- package/.bkit/core/docs/templates/bkit-audit-llm.md +20 -14
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +10 -8
- package/.bkit/core/docs/templates/bkit-audit-security.md +3 -3
- package/.bkit/core/docs/templates/bkit-audit-testing.md +4 -3
- package/.bkit/core/docs/templates/bkit-plan.md +8 -6
- package/.bkit/core/engine/checks/after/auth.ts +9 -9
- package/.bkit/core/engine/checks/after/ci-yml.ts +14 -12
- package/.bkit/core/engine/checks/after/github.ts +29 -120
- package/.bkit/core/engine/checks/after/index.ts +2 -2
- package/.bkit/core/engine/checks/after/managed.ts +8 -28
- package/.bkit/core/engine/checks/after/tools.ts +3 -15
- package/.bkit/core/engine/checks/before/context-fetch.ts +1 -21
- package/.bkit/core/engine/checks/before/index.ts +7 -43
- package/.bkit/core/engine/checks/before/mcp.ts +17 -8
- package/.bkit/core/engine/checks/before/repo.ts +9 -12
- package/.bkit/core/engine/checks/status-holes.ts +4 -5
- package/.bkit/core/engine/checks/tips/catalogue.ts +60 -24
- package/.bkit/core/engine/checks/tips/detect.ts +45 -2
- package/.bkit/core/engine/checks/tips/index.ts +37 -8
- package/.bkit/core/engine/cli.ts +39 -16
- package/.bkit/core/engine/commands/analysis.ts +36 -26
- package/.bkit/core/engine/commands/comply.ts +17 -16
- package/.bkit/core/engine/commands/harvest.ts +12 -12
- package/.bkit/core/engine/commands/install/doctor.ts +57 -28
- package/.bkit/core/engine/commands/install/install.ts +62 -126
- package/.bkit/core/engine/commands/install/uninstall.ts +191 -33
- package/.bkit/core/engine/commands/install/upgrade.ts +49 -43
- package/.bkit/core/engine/commands/lib.ts +35 -10
- package/.bkit/core/engine/commands/tips.ts +8 -5
- package/.bkit/core/engine/commands/workflow/branches.ts +4 -4
- package/.bkit/core/engine/commands/workflow/counters.ts +21 -12
- package/.bkit/core/engine/commands/workflow/fids.ts +46 -0
- package/.bkit/core/engine/commands/workflow/ledgers.ts +3 -1
- package/.bkit/core/engine/commands/workflow/prs.ts +4 -2
- package/.bkit/core/engine/commands/workflow/repo.ts +2 -2
- package/.bkit/core/engine/commands/workflow/roadmap.ts +4 -3
- package/.bkit/core/engine/commands/workflow/runs.ts +8 -7
- package/.bkit/core/engine/commands/workflow/steps.ts +1 -0
- package/.bkit/core/engine/commands/workflow/tests.ts +17 -5
- package/.bkit/core/engine/commands/workflow/workflows.ts +15 -14
- package/.bkit/core/engine/commands/workflow/workstreams.ts +2 -1
- package/.bkit/core/engine/commands/workflow/worktrees.ts +13 -5
- package/.bkit/core/engine/install/cloud-env.ts +10 -31
- package/.bkit/core/engine/install/manifest.ts +14 -7
- package/.bkit/core/engine/install/modules/antigravity.ts +15 -26
- package/.bkit/core/engine/install/modules/claude.ts +20 -28
- package/.bkit/core/engine/install/modules/cloud.ts +5 -2
- package/.bkit/core/engine/install/modules/codex.ts +15 -29
- package/.bkit/core/engine/install/modules/core.ts +91 -70
- package/.bkit/core/engine/install/modules/cursor.ts +6 -20
- package/.bkit/core/engine/install/modules/index.ts +7 -1
- package/.bkit/core/engine/install/modules/opencode.ts +48 -70
- package/.bkit/core/engine/install/network-allowlist.ts +73 -0
- package/.bkit/core/engine/install/placeholders.ts +3 -18
- package/.bkit/core/engine/install/write.ts +59 -12
- package/.bkit/core/engine/ledgers/telemetry.ts +6 -4
- package/.bkit/core/engine/render/hosts.ts +47 -67
- package/.bkit/core/engine/render/models.ts +29 -11
- package/.bkit/core/engine/shared/branches.ts +13 -0
- package/.bkit/core/engine/shared/egress.ts +3 -3
- package/.bkit/core/engine/shared/json.ts +18 -1
- package/.bkit/core/engine/shared/package-json.ts +63 -0
- package/.bkit/core/engine/shared/package-roots.ts +0 -10
- package/.bkit/core/engine/shared/protected-paths.ts +5 -130
- package/.bkit/core/engine/shared/settings.ts +36 -0
- package/.bkit/core/hooks/antigravity-hook.js +1 -0
- package/.bkit/core/hooks/guardrails-shell.js +186 -40
- package/.bkit/core/hooks/guardrails-tiers.js +5 -78
- package/.bkit/core/prompts/bkit-audit-generate.md +60 -7
- package/.bkit/core/prompts/bkit-build-challenge-1.md +1 -1
- package/.bkit/core/prompts/bkit-build-challenge-2.md +1 -1
- package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +1 -1
- 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-install-skills.md +1 -1
- package/.bkit/core/prompts/bkit-build-plan-current.md +1 -1
- package/.bkit/core/prompts/bkit-build-plan-execute.md +4 -4
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-build-plan-verify.md +2 -2
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +78 -0
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +1 -1
- package/.bkit/core/prompts/bkit-debug-summary.md +3 -3
- package/.bkit/core/prompts/bkit-design-spike.md +1 -1
- package/.bkit/core/prompts/bkit-design-summary.md +2 -2
- package/.bkit/core/prompts/bkit-design-update.md +1 -1
- package/.bkit/core/prompts/bkit-plan-complexity-check.md +1 -1
- package/.bkit/core/prompts/bkit-plan-generate.md +1 -1
- package/.bkit/core/prompts/bkit-plan-scope-check-1.md +1 -1
- package/.bkit/core/prompts/bkit-plan-scope-check-2.md +1 -1
- package/.bkit/core/prompts/bkit-plan-summary.md +1 -1
- package/.bkit/core/prompts/bkit-plan-update.md +1 -1
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +1 -1
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +1 -1
- package/.bkit/core/prompts/bkit-ship-update-docs.md +1 -1
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +9 -2
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +9 -2
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +2 -1
- package/.bkit/core/prompts/bkit-utility-update-failures.md +9 -2
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +9 -2
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +11 -4
- package/.bkit/core/workflows/bkit-build.md +3 -3
- package/.bkit/core/workflows/bkit-debug.md +69 -33
- package/.bkit/core/workflows/bkit-design.md +2 -2
- package/.bkit/core/workflows/bkit-plan.md +11 -4
- package/.bkit/core/workflows/bkit-ship.md +5 -5
- package/.bkit/shared/.claude/bkit-cloud.md +46 -13
- package/.bkit/shared/.claude/settings.json +18 -0
- package/.bkit/shared/.cursor/mcp.json +2 -1
- package/.bkit/shared/.opencode/opencode.json +19 -1
- package/.bkit/shared/docs/deployments.md +20 -4
- package/.bkit/shared/docs/security.md +8 -6
- package/.bkit/shared/docs/testing.md +9 -5
- package/.bkit/templates/.cursor/Dockerfile +30 -16
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-bug.yml +78 -0
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +91 -0
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-idea.yml +56 -0
- package/.bkit/templates/.github/renovate.json5 +91 -12
- package/.bkit/templates/.github/workflows/bkit-ci.yml +66 -53
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +3 -1
- package/.bkit/templates/.github/workflows/bkit-renovate.yml +8 -1
- package/.bkit/templates/.github/workflows/bkit-trivy.yml +67 -0
- package/.bkit/templates/.husky/pre-push +8 -3
- package/.bkit/templates/.oxlintrc.json +21 -0
- package/.bkit/templates/docs/capabilities.md +1 -1
- package/.bkit/templates/scripts/ci/check-capstone.mjs +176 -0
- package/.bkit/templates/scripts/ci/check-capstone.test.mjs +311 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-eager.py +2 -2
- package/.bkit/templates/scripts/graphify/bkit-graph-imports.py +43 -20
- package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +33 -11
- package/.bkit/templates/scripts/graphify/bkit-graph-repair.py +3 -2
- package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +5 -5
- package/.bkit/templates/scripts/graphify/bkit-graphify.sh +79 -19
- package/CHANGELOG.md +50 -3
- package/README.md +258 -129
- package/dist/checks/after/auth.js +10 -11
- package/dist/checks/after/ci-yml.js +11 -14
- package/dist/checks/after/github.js +32 -125
- package/dist/checks/after/index.js +3 -2
- package/dist/checks/after/managed.js +8 -24
- package/dist/checks/after/tools.js +3 -16
- package/dist/checks/before/context-fetch.js +1 -21
- package/dist/checks/before/index.js +6 -42
- package/dist/checks/before/mcp.js +14 -9
- package/dist/checks/before/repo.js +8 -11
- package/dist/checks/status-holes.js +5 -6
- package/dist/checks/tips/catalogue.js +51 -18
- package/dist/checks/tips/detect.js +41 -2
- package/dist/checks/tips/index.js +25 -5
- package/dist/cli.js +34 -14
- package/dist/commands/analysis.js +21 -5
- package/dist/commands/comply.js +20 -18
- package/dist/commands/harvest.js +12 -13
- package/dist/commands/install/doctor.js +55 -23
- package/dist/commands/install/install.js +62 -118
- package/dist/commands/install/uninstall.js +165 -31
- package/dist/commands/install/upgrade.js +46 -39
- package/dist/commands/lib.js +32 -10
- package/dist/commands/tips.js +6 -3
- package/dist/commands/workflow/branches.js +3 -5
- package/dist/commands/workflow/counters.js +17 -7
- package/dist/commands/workflow/fids.js +39 -0
- package/dist/commands/workflow/ledgers.js +3 -1
- package/dist/commands/workflow/prs.js +3 -3
- package/dist/commands/workflow/repo.js +2 -2
- package/dist/commands/workflow/roadmap.js +4 -4
- package/dist/commands/workflow/runs.js +5 -5
- package/dist/commands/workflow/steps.js +1 -0
- package/dist/commands/workflow/tests.js +16 -3
- package/dist/commands/workflow/workflows.js +15 -15
- package/dist/commands/workflow/workstreams.js +2 -1
- package/dist/commands/workflow/worktrees.js +4 -5
- package/dist/install/cloud-env.js +10 -23
- package/dist/install/manifest.js +14 -7
- package/dist/install/modules/antigravity.js +15 -26
- package/dist/install/modules/claude.js +17 -21
- package/dist/install/modules/cloud.js +6 -2
- package/dist/install/modules/codex.js +15 -29
- package/dist/install/modules/core.js +82 -63
- package/dist/install/modules/cursor.js +6 -9
- package/dist/install/modules/index.js +6 -1
- package/dist/install/modules/opencode.js +41 -72
- package/dist/install/network-allowlist.js +62 -0
- package/dist/install/placeholders.js +3 -16
- package/dist/install/write.js +55 -15
- package/dist/ledgers/telemetry.js +5 -4
- package/dist/render/hosts.js +30 -55
- package/dist/render/models.js +20 -9
- package/dist/shared/branches.js +11 -0
- package/dist/shared/egress.js +0 -2
- package/dist/shared/json.js +14 -0
- package/dist/shared/package-json.js +61 -0
- package/dist/shared/package-roots.js +0 -8
- package/dist/shared/protected-paths.js +5 -122
- package/dist/shared/settings.js +18 -1
- package/package.json +21 -17
- package/.bkit/core/.agents/shortcuts.md +0 -73
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
import * as fs from "node:fs";
|
|
5
5
|
import { findLineAnchoredMarkers, selectMarkers } from "../install/managed-block.js";
|
|
6
6
|
import { LOG_PREFIX } from "../shared/log-prefix.js";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
OPENCODE_PROVIDERS,
|
|
9
|
+
OPENCODE_PROVIDER_DEFAULTS,
|
|
10
|
+
type OpencodeProvider,
|
|
11
|
+
} from "../shared/egress.js";
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
14
|
* Parse .bkit/prompts.md § Models table → Map<name, columnValue>.
|
|
@@ -97,8 +101,11 @@ export function parseModelLookup(subagentsMdPath: string): Map<string, string> {
|
|
|
97
101
|
*
|
|
98
102
|
* Cells hold the BARE, gateway-scoped model id. Any prefix a program's config format needs
|
|
99
103
|
* is added at render time by formatModelPin — never stored in the table.
|
|
104
|
+
*
|
|
105
|
+
* Every allowlisted opencode provider MUST have an entry; the `satisfies Record<OpencodeProvider | …>`
|
|
106
|
+
* check fails tsc when one is missing.
|
|
100
107
|
*/
|
|
101
|
-
const GATEWAY_COLUMN
|
|
108
|
+
const GATEWAY_COLUMN = {
|
|
102
109
|
anthropic: "Anthropic",
|
|
103
110
|
cursor: "Cursor",
|
|
104
111
|
openrouter: "OpenRouter",
|
|
@@ -107,7 +114,13 @@ const GATEWAY_COLUMN: Record<string, string> = {
|
|
|
107
114
|
"opencode-go": "OpenCode Go",
|
|
108
115
|
openai: "OpenAI",
|
|
109
116
|
google: "Google",
|
|
110
|
-
}
|
|
117
|
+
} satisfies Record<OpencodeProvider | "anthropic" | "cursor" | "openai" | "google", string>;
|
|
118
|
+
|
|
119
|
+
type GatewayKey = keyof typeof GATEWAY_COLUMN;
|
|
120
|
+
|
|
121
|
+
function isGatewayKey(value: string): value is GatewayKey {
|
|
122
|
+
return Object.hasOwn(GATEWAY_COLUMN, value);
|
|
123
|
+
}
|
|
111
124
|
|
|
112
125
|
/**
|
|
113
126
|
* Spell a model pin the way a program's config file expects it.
|
|
@@ -125,22 +138,21 @@ export function formatModelPin(program: string, gateway: string, bareModel: stri
|
|
|
125
138
|
}
|
|
126
139
|
|
|
127
140
|
/**
|
|
128
|
-
* Build the per-agent
|
|
129
|
-
* Source of truth = prompts.md § Models, which carries one curated column per
|
|
130
|
-
*
|
|
131
|
-
* ships a column;
|
|
141
|
+
* Build the per-agent model lookup for one gateway: an opencode provider, or the Codex
|
|
142
|
+
* "openai" column. Source of truth = prompts.md § Models, which carries one curated column per
|
|
143
|
+
* gateway ("OpenRouter", "Ollama", "OpenAI"). Header-addressed. Every key of GATEWAY_COLUMN
|
|
144
|
+
* ships a column; any other key throws.
|
|
132
145
|
*/
|
|
133
146
|
export function buildOpencodeModelLookup(
|
|
134
147
|
subagentsMdPath: string,
|
|
135
148
|
provider: string,
|
|
136
149
|
): Map<string, string> {
|
|
137
|
-
|
|
138
|
-
if (!header) {
|
|
150
|
+
if (!isGatewayKey(provider)) {
|
|
139
151
|
throw new Error(
|
|
140
152
|
`buildOpencodeModelLookup: no prompts.md § Models column for provider ${JSON.stringify(provider)}`,
|
|
141
153
|
);
|
|
142
154
|
}
|
|
143
|
-
return parseModelLookupForColumn(subagentsMdPath,
|
|
155
|
+
return parseModelLookupForColumn(subagentsMdPath, GATEWAY_COLUMN[provider]);
|
|
144
156
|
}
|
|
145
157
|
|
|
146
158
|
/**
|
|
@@ -329,5 +341,11 @@ export function lookupEffort(effortMap: EffortMap, program: string, sourceEffort
|
|
|
329
341
|
* keys pass through unchanged.
|
|
330
342
|
*/
|
|
331
343
|
export function opencodeProviderId(providerKey: string): string {
|
|
332
|
-
|
|
344
|
+
if (!isOpencodeProvider(providerKey)) return providerKey;
|
|
345
|
+
return OPENCODE_PROVIDER_DEFAULTS[providerKey].providerId ?? providerKey;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/** Narrow a raw string to the opencode provider allowlist. */
|
|
349
|
+
export function isOpencodeProvider(value: string): value is OpencodeProvider {
|
|
350
|
+
return OPENCODE_PROVIDERS.some((provider) => provider === value);
|
|
333
351
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// shared/branches.ts — which branches are shared, so nobody works on them directly.
|
|
2
|
+
//
|
|
3
|
+
// `dev` is the integration branch; `dev` and `main` are the shared branches. The workflow
|
|
4
|
+
// commands (`commands/lib.ts` re-exports these) and the managed-version check both read
|
|
5
|
+
// this one rule.
|
|
6
|
+
|
|
7
|
+
/** The integration branch feature work lands on. */
|
|
8
|
+
export const DEV = "dev";
|
|
9
|
+
|
|
10
|
+
/** True for `dev` and `main`: no feature work happens on them, no force-push touches them. */
|
|
11
|
+
export function isSharedBranch(branch: string): boolean {
|
|
12
|
+
return branch === DEV || branch === "main";
|
|
13
|
+
}
|
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Providers bkit supports for the opencode host. `--opencode=<provider>` accepts
|
|
6
6
|
* ONLY these — anything else is rejected (no generic/arbitrary-endpoint fallback).
|
|
7
|
-
* Keep in sync with OPENCODE_PROVIDER_DEFAULTS (below) and
|
|
8
|
-
* GATEWAY_COLUMN (render/models.ts § Models lookup).
|
|
9
7
|
*/
|
|
10
8
|
export const OPENCODE_PROVIDERS = [
|
|
11
9
|
// OpenAI-compatible npm driver — endpoint + key per provider.
|
|
@@ -18,6 +16,8 @@ export const OPENCODE_PROVIDERS = [
|
|
|
18
16
|
"opencode-go",
|
|
19
17
|
] as const;
|
|
20
18
|
|
|
19
|
+
export type OpencodeProvider = (typeof OPENCODE_PROVIDERS)[number];
|
|
20
|
+
|
|
21
21
|
/**
|
|
22
22
|
* One egress source: a bkit-shipped surface that an agent session reaches over the
|
|
23
23
|
* network. `hosts` are the exact hostnames contacted. `bases` are the registrable
|
|
@@ -47,7 +47,7 @@ export interface EgressSource {
|
|
|
47
47
|
// These are sane defaults; consumers tune after install.
|
|
48
48
|
// npmPackage: set for custom OpenAI-compatible providers that use npm-based AI SDK driver.
|
|
49
49
|
export const OPENCODE_PROVIDER_DEFAULTS: Record<
|
|
50
|
-
|
|
50
|
+
OpencodeProvider,
|
|
51
51
|
{
|
|
52
52
|
envVar: string;
|
|
53
53
|
baseURL: string;
|
|
@@ -4,9 +4,14 @@
|
|
|
4
4
|
// .bkit/version) must fail open into a result the caller reports in its own terms,
|
|
5
5
|
// never abort install, upgrade or `bkit check`. One shape, one catch — so the
|
|
6
6
|
// defensive-slop gate reads a single documented fallback instead of one per caller.
|
|
7
|
+
// `audits/repo/json-parse-owner.test.ts` fails on a `JSON.parse` inside a `try` anywhere else.
|
|
8
|
+
|
|
9
|
+
import * as fs from "node:fs";
|
|
10
|
+
|
|
11
|
+
export type JsonRead = { ok: true; value: unknown } | { ok: false };
|
|
7
12
|
|
|
8
13
|
/** `JSON.parse(raw)` as a result: `{ ok: true, value }`, or `{ ok: false }` when not JSON. */
|
|
9
|
-
export function parseJson(raw: string):
|
|
14
|
+
export function parseJson(raw: string): JsonRead {
|
|
10
15
|
try {
|
|
11
16
|
return { ok: true, value: JSON.parse(raw) as unknown };
|
|
12
17
|
} catch {
|
|
@@ -14,3 +19,15 @@ export function parseJson(raw: string): { ok: true; value: unknown } | { ok: fal
|
|
|
14
19
|
return { ok: false };
|
|
15
20
|
}
|
|
16
21
|
}
|
|
22
|
+
|
|
23
|
+
/** `parseJson` over the file at `file`; `{ ok: false }` also when the file cannot be read. */
|
|
24
|
+
export function readJsonFile(file: string): JsonRead {
|
|
25
|
+
let raw: string;
|
|
26
|
+
try {
|
|
27
|
+
raw = fs.readFileSync(file, "utf-8");
|
|
28
|
+
} catch {
|
|
29
|
+
// Missing, unreadable or a directory: the result says so, like malformed JSON.
|
|
30
|
+
return { ok: false };
|
|
31
|
+
}
|
|
32
|
+
return parseJson(raw);
|
|
33
|
+
}
|
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
// Commands that look up a script or a `bkit` setting need to tell "no file" and
|
|
4
4
|
// "file is not JSON" apart from "key absent", so a broken manifest is named in the
|
|
5
5
|
// message instead of reading as an empty one.
|
|
6
|
+
//
|
|
7
|
+
// `readInstallingVersion` reads the same file for the bkit package doing the install.
|
|
6
8
|
|
|
7
9
|
import * as fs from "node:fs";
|
|
8
10
|
import * as path from "node:path";
|
|
9
11
|
|
|
10
12
|
import { parseJson } from "./json.js";
|
|
13
|
+
import { getPkgRoot } from "./package-roots.js";
|
|
11
14
|
|
|
12
15
|
export type PackageJsonRead =
|
|
13
16
|
{ ok: true; pkg: Record<string, unknown> } | { ok: false; reason: "missing" | "unparseable" };
|
|
@@ -27,3 +30,63 @@ export function readPackageJson(dir: string): PackageJsonRead {
|
|
|
27
30
|
}
|
|
28
31
|
return { ok: true, pkg: parsed.value as Record<string, unknown> };
|
|
29
32
|
}
|
|
33
|
+
|
|
34
|
+
/** Every dependency name across the four `package.json` dependency fields; `[]` when unreadable. */
|
|
35
|
+
export function readDependencyNames(cwd: string): string[] {
|
|
36
|
+
const read = readPackageJson(cwd);
|
|
37
|
+
if (!read.ok) return [];
|
|
38
|
+
const names: string[] = [];
|
|
39
|
+
for (const field of [
|
|
40
|
+
"dependencies",
|
|
41
|
+
"devDependencies",
|
|
42
|
+
"optionalDependencies",
|
|
43
|
+
"peerDependencies",
|
|
44
|
+
]) {
|
|
45
|
+
const deps = read.pkg[field];
|
|
46
|
+
if (deps && typeof deps === "object") {
|
|
47
|
+
names.push(...Object.keys(deps as Record<string, unknown>));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return names;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The spec `package.json` declares for dependency `name` (`"^5.2.0"`, `"file:../x.tgz"`, …),
|
|
55
|
+
* from `dependencies`, `devDependencies` or `optionalDependencies`; `null` when undeclared or
|
|
56
|
+
* the file is unreadable.
|
|
57
|
+
*/
|
|
58
|
+
export function readDependencySpec(cwd: string, name: string): string | null {
|
|
59
|
+
const read = readPackageJson(cwd);
|
|
60
|
+
if (!read.ok) return null;
|
|
61
|
+
for (const field of ["dependencies", "devDependencies", "optionalDependencies"]) {
|
|
62
|
+
const deps = read.pkg[field];
|
|
63
|
+
if (deps && typeof deps === "object") {
|
|
64
|
+
const spec = (deps as Record<string, unknown>)[name];
|
|
65
|
+
if (typeof spec === "string") return spec;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The version of the bkit package doing the install, read from that package's own
|
|
73
|
+
* `package.json` (`root` defaults to the package root; never the consumer's file).
|
|
74
|
+
* Throws when the file is missing, is not a JSON object, or has no non-empty string
|
|
75
|
+
* `version`: the value is stamped into every managed file and the `.bkit/version` pin,
|
|
76
|
+
* so a damaged package stops the command instead of writing a guessed version.
|
|
77
|
+
*/
|
|
78
|
+
export function readInstallingVersion(root: string = getPkgRoot()): string {
|
|
79
|
+
const file = path.join(root, "package.json");
|
|
80
|
+
const read = readPackageJson(root);
|
|
81
|
+
if (!read.ok) {
|
|
82
|
+
const state = read.reason === "missing" ? "is missing" : "is not a JSON object";
|
|
83
|
+
throw new Error(`bkit's own package.json ${state} (${file}); reinstall @cbartens/bkit.`);
|
|
84
|
+
}
|
|
85
|
+
const version = read.pkg["version"];
|
|
86
|
+
if (typeof version !== "string" || version === "") {
|
|
87
|
+
throw new Error(
|
|
88
|
+
`bkit's own package.json has no string "version" (${file}); reinstall @cbartens/bkit.`,
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
return version;
|
|
92
|
+
}
|
|
@@ -149,13 +149,3 @@ export function getHooksRoot(): string {
|
|
|
149
149
|
export function getBkitDocsRoot(): string {
|
|
150
150
|
return path.join(getCoreRoot(), ".bkit");
|
|
151
151
|
}
|
|
152
|
-
|
|
153
|
-
// ---------------------------------------------------------------------------
|
|
154
|
-
// isDogfood — true when bkit is running inside its own repo (in-repo install).
|
|
155
|
-
// In this case the source tree IS the consumer's .agents/ directory, so any
|
|
156
|
-
// payload copy would overwrite the source with itself.
|
|
157
|
-
// ---------------------------------------------------------------------------
|
|
158
|
-
|
|
159
|
-
export function isDogfood(): boolean {
|
|
160
|
-
return getPkgRoot() === process.cwd();
|
|
161
|
-
}
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
// shared/protected-paths.ts —
|
|
2
|
-
// grader (`commands/comply.ts`)
|
|
3
|
-
// (`.claude/hooks/gate-paths.generated.cjs`).
|
|
1
|
+
// shared/protected-paths.ts — the table of bkit-managed IDE mirror directories, used by the
|
|
2
|
+
// compliance grader (`commands/comply.ts`).
|
|
4
3
|
//
|
|
5
4
|
// RULES:
|
|
6
|
-
// - This file is the ONE source of truth for
|
|
7
|
-
// - The
|
|
8
|
-
//
|
|
9
|
-
// - The `.cjs` lives in bkit's own repo only; install never writes it. The
|
|
10
|
-
// generation step is a manual bkit-dev tool (`generateGatePathsCjs()`).
|
|
5
|
+
// - This file is the ONE source of truth for mirror path definitions.
|
|
6
|
+
// - The gate-config list (quality-gate config basenames) lives only in
|
|
7
|
+
// `.bkit/core/hooks/gateguard-engine.js`, which every host's `bkit-gateguard` hook inlines.
|
|
11
8
|
// - Never import install-tier logic from here (keeps grader crash-isolated from
|
|
12
9
|
// the consumer-mutating install path — see DE-34).
|
|
13
10
|
|
|
14
|
-
import * as fs from "node:fs";
|
|
15
|
-
import * as path from "node:path";
|
|
16
|
-
import { fileURLToPath } from "node:url";
|
|
17
|
-
import { isDogfood, TEMPLATE_COPIES_DIR } from "./package-roots.js";
|
|
18
|
-
|
|
19
11
|
// ---------------------------------------------------------------------------
|
|
20
12
|
// Mirror-path patterns (bkit-managed IDE mirrors)
|
|
21
13
|
// ---------------------------------------------------------------------------
|
|
@@ -45,120 +37,3 @@ export const MIRROR_PATH_PREFIXES: readonly string[] = [
|
|
|
45
37
|
export function isMirrorPath(posixPath: string): boolean {
|
|
46
38
|
return MIRROR_PATH_PREFIXES.some((prefix) => posixPath.startsWith(prefix));
|
|
47
39
|
}
|
|
48
|
-
|
|
49
|
-
// ---------------------------------------------------------------------------
|
|
50
|
-
// Gate-config basename patterns (quality-gate configs)
|
|
51
|
-
// ---------------------------------------------------------------------------
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Basename patterns for quality-gate configs (lint / format / types / test / slop).
|
|
55
|
-
* Mirrors `GATE_CONFIG_PATTERNS` in `bkit-gateguard.cjs` — kept in sync via the
|
|
56
|
-
* generated `.cjs` drift test. Editing these configs to silence a gate is the
|
|
57
|
-
* "weaken-the-gate" anti-pattern; prefer targeted per-file opt-outs.
|
|
58
|
-
*/
|
|
59
|
-
export const GATE_CONFIG_PATTERNS: readonly RegExp[] = [
|
|
60
|
-
/^tsconfig(\..+)?\.json$/,
|
|
61
|
-
/^vitest\.config\.[mc]?[jt]s$/,
|
|
62
|
-
/^vite\.config\.[mc]?[jt]s$/,
|
|
63
|
-
/^eslint\.config\.[mc]?[jt]s$/,
|
|
64
|
-
/^\.eslintrc(\.(json|js|cjs|ya?ml))?$/,
|
|
65
|
-
/^\.prettierrc(\.(json|js|cjs|mjs|ya?ml|toml))?$/,
|
|
66
|
-
/^prettier\.config\.[mc]?js$/,
|
|
67
|
-
/^\.prettierignore$/,
|
|
68
|
-
/^biome\.jsonc?$/,
|
|
69
|
-
/^\.vale\.ini$/,
|
|
70
|
-
/^slop-scan\.config\.json$/,
|
|
71
|
-
/^\.lintstagedrc(\.(json|js|cjs|mjs|ya?ml))?$/,
|
|
72
|
-
/^lint-staged\.config\.[mc]?js$/,
|
|
73
|
-
];
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* POSIX prefix of the consumer's template copies (`shared/package-roots.ts` TEMPLATE_COPIES_DIR).
|
|
77
|
-
* Those are bkit's reference copies, refreshed on every upgrade, not the repo's gate config.
|
|
78
|
-
*/
|
|
79
|
-
export const TEMPLATE_COPIES_PREFIX = TEMPLATE_COPIES_DIR.split(path.sep).join("/") + "/";
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Returns true if the file basename matches any gate-config pattern. In a consumer repo a
|
|
83
|
-
* path under `.bkit/templates/` never is one; in bkit's own repo (`dogfood`) that folder is
|
|
84
|
-
* the template source, so it stays guarded.
|
|
85
|
-
*/
|
|
86
|
-
export function isGateConfig(posixPath: string, dogfood: boolean = isDogfood()): boolean {
|
|
87
|
-
const inTemplateCopies =
|
|
88
|
-
posixPath.startsWith(TEMPLATE_COPIES_PREFIX) ||
|
|
89
|
-
posixPath.includes("/" + TEMPLATE_COPIES_PREFIX);
|
|
90
|
-
if (inTemplateCopies && !dogfood) return false;
|
|
91
|
-
const base = posixPath.split("/").pop() ?? posixPath;
|
|
92
|
-
return GATE_CONFIG_PATTERNS.some((re) => re.test(base));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// ---------------------------------------------------------------------------
|
|
96
|
-
// Code generator — emits the committed `.cjs` from this table.
|
|
97
|
-
// Run manually by a bkit developer: `ts-node .bkit/core/engine/shared/protected-paths.ts`
|
|
98
|
-
// The output must be committed to `.claude/hooks/gate-paths.generated.cjs`.
|
|
99
|
-
// ---------------------------------------------------------------------------
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Generate the content of `.claude/hooks/gate-paths.generated.cjs`.
|
|
103
|
-
* This is the single committed snapshot derived from the tables above.
|
|
104
|
-
*/
|
|
105
|
-
export function generateGatePathsCjs(): string {
|
|
106
|
-
const mirrorLines = MIRROR_PATH_PREFIXES.map((p) => ` ${JSON.stringify(p)},`).join("\n");
|
|
107
|
-
const gateLines = GATE_CONFIG_PATTERNS.map((re) => ` ${re.toString()},`).join("\n");
|
|
108
|
-
|
|
109
|
-
return `// gate-paths.generated.cjs — AUTO-GENERATED from .bkit/core/engine/shared/protected-paths.ts
|
|
110
|
-
// DO NOT EDIT BY HAND — regenerate via \`generateGatePathsCjs()\` then commit.
|
|
111
|
-
// Drift is detected by .bkit/core/engine/shared/protected-paths.test.ts (Vitest).
|
|
112
|
-
"use strict";
|
|
113
|
-
|
|
114
|
-
/** Prefixes for bkit-managed IDE mirror directories. */
|
|
115
|
-
const MIRROR_PATH_PREFIXES = [
|
|
116
|
-
${mirrorLines}
|
|
117
|
-
];
|
|
118
|
-
|
|
119
|
-
/** Returns true if the POSIX path is inside a bkit-managed mirror directory. */
|
|
120
|
-
function isMirrorPath(posixPath) {
|
|
121
|
-
return MIRROR_PATH_PREFIXES.some((prefix) => posixPath.startsWith(prefix));
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/** Basename patterns for quality-gate configs. */
|
|
125
|
-
const GATE_CONFIG_PATTERNS = [
|
|
126
|
-
${gateLines}
|
|
127
|
-
];
|
|
128
|
-
|
|
129
|
-
/** The consumer's template copies — reference copies, not the repo's gate config. */
|
|
130
|
-
const TEMPLATE_COPIES_PREFIX = ${JSON.stringify(TEMPLATE_COPIES_PREFIX)};
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Returns true if the file basename matches any gate-config pattern. Pass \`dogfood\` = true
|
|
134
|
-
* in bkit's own repo, where \`.bkit/templates/\` is the template source and stays guarded.
|
|
135
|
-
*/
|
|
136
|
-
function isGateConfig(posixPath, dogfood) {
|
|
137
|
-
const inTemplateCopies =
|
|
138
|
-
posixPath.startsWith(TEMPLATE_COPIES_PREFIX) || posixPath.includes("/" + TEMPLATE_COPIES_PREFIX);
|
|
139
|
-
if (inTemplateCopies && !dogfood) return false;
|
|
140
|
-
const base = posixPath.split("/").pop() || posixPath;
|
|
141
|
-
return GATE_CONFIG_PATTERNS.some((re) => re.test(base));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
module.exports = {
|
|
145
|
-
MIRROR_PATH_PREFIXES,
|
|
146
|
-
isMirrorPath,
|
|
147
|
-
GATE_CONFIG_PATTERNS,
|
|
148
|
-
TEMPLATE_COPIES_PREFIX,
|
|
149
|
-
isGateConfig,
|
|
150
|
-
};
|
|
151
|
-
`;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// CLI: `node dist/shared/protected-paths.js` prints the generated content to stdout.
|
|
155
|
-
// This file compiles to ESM, so use import.meta.url for main-module detection.
|
|
156
|
-
if (process.argv[1]) {
|
|
157
|
-
try {
|
|
158
|
-
if (fs.realpathSync(fileURLToPath(import.meta.url)) === fs.realpathSync(process.argv[1])) {
|
|
159
|
-
process.stdout.write(generateGatePathsCjs());
|
|
160
|
-
}
|
|
161
|
-
} catch (_e) {
|
|
162
|
-
void _e; // realpathSync can fail on non-existent paths — skip silently
|
|
163
|
-
}
|
|
164
|
-
}
|
|
@@ -4,10 +4,15 @@
|
|
|
4
4
|
// a check name, or an app folder.
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
+
DEFAULT_CLOUD_AGENTS,
|
|
7
8
|
DEFAULT_ISSUE_TRACKER,
|
|
9
|
+
parseCloudAgents,
|
|
8
10
|
parseIssueTracker,
|
|
11
|
+
type CloudAgents,
|
|
9
12
|
type IssueTracker,
|
|
10
13
|
} from "../install/manifest.js";
|
|
14
|
+
import { isOpencodeProvider } from "../render/models.js";
|
|
15
|
+
import type { OpencodeProvider } from "./egress.js";
|
|
11
16
|
import { readPackageJson } from "./package-json.js";
|
|
12
17
|
|
|
13
18
|
export interface BkitConfig {
|
|
@@ -25,6 +30,18 @@ export interface BkitConfig {
|
|
|
25
30
|
githubProject: Record<string, unknown> | false | null;
|
|
26
31
|
/** CI lanes whose `skipped` conclusion refuses a ship merge; empty = the capstone's green decides. */
|
|
27
32
|
shipGateRequiredLanes: string[];
|
|
33
|
+
/** The opencode provider recorded on install; null = absent or not a supported provider. */
|
|
34
|
+
opencodeProvider: OpencodeProvider | null;
|
|
35
|
+
/** Every installed opencode provider, supported ones only; empty = none recorded. */
|
|
36
|
+
opencodeProviders: OpencodeProvider[];
|
|
37
|
+
/** The post-CI cloud-agent variant; `none` is both the default and the explicit opt-out. */
|
|
38
|
+
cloudAgents: CloudAgents;
|
|
39
|
+
/** `bkit.depUpdater` is `"none"`: silences the missing-dependency-updater advisory. */
|
|
40
|
+
depUpdaterOptOut: boolean;
|
|
41
|
+
/** `bkit.issueTracker` is present with any value, so `none` is a choice, not an undecided install. */
|
|
42
|
+
issueTrackerExplicit: boolean;
|
|
43
|
+
/** `bkit.cloudAgents` is present with any value, so `none` is a choice, not an undecided install. */
|
|
44
|
+
cloudAgentsExplicit: boolean;
|
|
28
45
|
}
|
|
29
46
|
|
|
30
47
|
export const CONFIG_DEFAULTS: Readonly<BkitConfig> = {
|
|
@@ -35,6 +52,12 @@ export const CONFIG_DEFAULTS: Readonly<BkitConfig> = {
|
|
|
35
52
|
issueTracker: DEFAULT_ISSUE_TRACKER,
|
|
36
53
|
githubProject: null,
|
|
37
54
|
shipGateRequiredLanes: [],
|
|
55
|
+
opencodeProvider: null,
|
|
56
|
+
opencodeProviders: [],
|
|
57
|
+
cloudAgents: DEFAULT_CLOUD_AGENTS,
|
|
58
|
+
depUpdaterOptOut: false,
|
|
59
|
+
issueTrackerExplicit: false,
|
|
60
|
+
cloudAgentsExplicit: false,
|
|
38
61
|
};
|
|
39
62
|
|
|
40
63
|
const nonEmptyString = (v: unknown): v is string => typeof v === "string" && v.trim() !== "";
|
|
@@ -51,6 +74,8 @@ export function readBkitConfig(root: string): BkitConfig {
|
|
|
51
74
|
const copy = worktree.copy;
|
|
52
75
|
const project = bkit.githubProject;
|
|
53
76
|
const lanes = bkit.shipGateRequiredLanes;
|
|
77
|
+
const provider = bkit.opencodeProvider;
|
|
78
|
+
const providers = bkit.opencodeProviders;
|
|
54
79
|
return {
|
|
55
80
|
ciWorkflow: nonEmptyString(bkit.ciWorkflow) ? bkit.ciWorkflow : CONFIG_DEFAULTS.ciWorkflow,
|
|
56
81
|
capstoneJob: nonEmptyString(bkit.capstoneJob) ? bkit.capstoneJob : CONFIG_DEFAULTS.capstoneJob,
|
|
@@ -68,5 +93,16 @@ export function readBkitConfig(root: string): BkitConfig {
|
|
|
68
93
|
? (project as Record<string, unknown>)
|
|
69
94
|
: null,
|
|
70
95
|
shipGateRequiredLanes: Array.isArray(lanes) ? lanes.filter(nonEmptyString) : [],
|
|
96
|
+
opencodeProvider:
|
|
97
|
+
typeof provider === "string" && isOpencodeProvider(provider) ? provider : null,
|
|
98
|
+
opencodeProviders: Array.isArray(providers)
|
|
99
|
+
? providers.filter(
|
|
100
|
+
(v): v is OpencodeProvider => typeof v === "string" && isOpencodeProvider(v),
|
|
101
|
+
)
|
|
102
|
+
: [],
|
|
103
|
+
cloudAgents: parseCloudAgents(bkit.cloudAgents) ?? CONFIG_DEFAULTS.cloudAgents,
|
|
104
|
+
depUpdaterOptOut: bkit.depUpdater === "none",
|
|
105
|
+
issueTrackerExplicit: bkit.issueTracker !== undefined,
|
|
106
|
+
cloudAgentsExplicit: bkit.cloudAgents !== undefined,
|
|
71
107
|
};
|
|
72
108
|
}
|