@cbartens/bkit 5.2.4 → 5.4.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 +27 -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 +18 -1
- package/.bkit/core/.bkit/README.md +26 -10
- package/.bkit/core/.bkit/cloud.md +40 -39
- package/.bkit/core/.bkit/comparison.md +68 -345
- package/.bkit/core/.bkit/install.md +16 -9
- package/.bkit/core/.bkit/lite.md +73 -0
- package/.bkit/core/.bkit/pipeline.md +346 -0
- package/.bkit/core/.bkit/prompts.md +90 -74
- package/.bkit/core/.bkit/providers.md +42 -23
- package/.bkit/core/.bkit/templates.md +138 -19
- package/.bkit/core/.bkit/trackers.md +49 -4
- package/.bkit/core/.bkit/workflows.md +144 -123
- 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-accessibility.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-agents.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +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 +26 -21
- 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 +3 -2
- package/.bkit/core/docs/templates/bkit-audit-llm.md +22 -15
- 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 +7 -7
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +12 -9
- 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 +14 -12
- package/.bkit/core/docs/templates/bkit-audit-slop.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-testing.md +10 -8
- package/.bkit/core/docs/templates/bkit-audit-usability.md +1 -1
- 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 -6
- package/.bkit/core/engine/checks/tips/catalogue.ts +76 -24
- package/.bkit/core/engine/checks/tips/detect.ts +45 -2
- package/.bkit/core/engine/checks/tips/index.ts +77 -26
- package/.bkit/core/engine/cli.ts +57 -27
- package/.bkit/core/engine/commands/analysis.ts +36 -26
- package/.bkit/core/engine/commands/comply.ts +42 -32
- 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 +73 -130
- 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/land.ts +156 -0
- package/.bkit/core/engine/commands/lib.ts +45 -18
- package/.bkit/core/engine/commands/registry.ts +2 -0
- package/.bkit/core/engine/commands/tips.ts +12 -5
- package/.bkit/core/engine/commands/workflow/branches.ts +386 -286
- package/.bkit/core/engine/commands/workflow/counters.ts +21 -12
- package/.bkit/core/engine/commands/workflow/disk.ts +556 -0
- package/.bkit/core/engine/commands/workflow/fids.ts +46 -0
- package/.bkit/core/engine/commands/workflow/issues.ts +73 -28
- package/.bkit/core/engine/commands/workflow/ledgers.ts +3 -1
- package/.bkit/core/engine/commands/workflow/locks.ts +38 -152
- package/.bkit/core/engine/commands/workflow/prs.ts +15 -4
- package/.bkit/core/engine/commands/workflow/repo.ts +2 -2
- package/.bkit/core/engine/commands/workflow/roadmap.ts +49 -53
- package/.bkit/core/engine/commands/workflow/runs.ts +8 -7
- 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 +25 -15
- package/.bkit/core/engine/commands/workflow/tests.ts +17 -5
- package/.bkit/core/engine/commands/workflow/workflows.ts +436 -267
- package/.bkit/core/engine/commands/workflow/workstreams.ts +4 -2
- package/.bkit/core/engine/commands/workflow/worktrees.ts +24 -6
- 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 +106 -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 +16 -35
- 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 +44 -0
- package/.bkit/core/engine/shared/timeouts.ts +8 -7
- 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 +103 -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-auto.md +2 -2
- package/.bkit/core/workflows/bkit-build.md +10 -10
- package/.bkit/core/workflows/bkit-debug.md +80 -44
- package/.bkit/core/workflows/bkit-design.md +22 -13
- package/.bkit/core/workflows/bkit-plan.md +33 -16
- package/.bkit/core/workflows/bkit-ship.md +87 -98
- package/.bkit/shared/.claude/bkit-cloud.md +58 -25
- package/.bkit/shared/.claude/settings.json +19 -0
- package/.bkit/shared/.cursor/mcp.json +2 -1
- package/.bkit/shared/.opencode/opencode.json +19 -1
- package/.bkit/shared/docs/deployments.md +49 -29
- package/.bkit/shared/docs/security.md +8 -6
- package/.bkit/shared/docs/testing.md +9 -5
- package/.bkit/shared/gitignore +1 -2
- 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 +73 -55
- 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-commit +6 -0
- package/.bkit/templates/.husky/pre-push +15 -3
- package/.bkit/templates/.lintstagedrc.json +5 -1
- 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/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-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 +98 -3
- package/README.md +252 -122
- 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 -7
- package/dist/checks/tips/catalogue.js +65 -18
- package/dist/checks/tips/detect.js +41 -2
- package/dist/checks/tips/index.js +61 -25
- package/dist/cli.js +52 -26
- package/dist/commands/analysis.js +21 -5
- package/dist/commands/comply.js +40 -31
- package/dist/commands/harvest.js +12 -13
- package/dist/commands/install/doctor.js +55 -23
- package/dist/commands/install/install.js +72 -122
- package/dist/commands/install/uninstall.js +165 -31
- package/dist/commands/install/upgrade.js +46 -39
- package/dist/commands/land.js +129 -0
- package/dist/commands/lib.js +41 -16
- package/dist/commands/registry.js +2 -0
- package/dist/commands/tips.js +10 -3
- package/dist/commands/workflow/branches.js +303 -248
- package/dist/commands/workflow/counters.js +17 -7
- package/dist/commands/workflow/disk.js +452 -0
- package/dist/commands/workflow/fids.js +39 -0
- package/dist/commands/workflow/issues.js +63 -27
- package/dist/commands/workflow/ledgers.js +3 -1
- package/dist/commands/workflow/locks.js +35 -130
- package/dist/commands/workflow/prs.js +8 -5
- package/dist/commands/workflow/repo.js +2 -2
- package/dist/commands/workflow/roadmap.js +50 -57
- package/dist/commands/workflow/runs.js +5 -5
- package/dist/commands/workflow/runtime.js +3 -2
- package/dist/commands/workflow/status.js +32 -12
- package/dist/commands/workflow/steps.js +19 -11
- package/dist/commands/workflow/tests.js +16 -3
- package/dist/commands/workflow/workflows.js +390 -249
- package/dist/commands/workflow/workstreams.js +4 -2
- package/dist/commands/workflow/worktrees.js +15 -6
- 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 +95 -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 +16 -35
- 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 +23 -1
- package/dist/shared/timeouts.js +8 -7
- package/package.json +21 -17
- package/.bkit/core/.agents/shortcuts.md +0 -73
|
@@ -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 {
|
|
@@ -19,12 +24,26 @@ export interface BkitConfig {
|
|
|
19
24
|
worktreeCopy: string[];
|
|
20
25
|
/** Whether worktree setup installs dependencies in a created or resumed worktree. */
|
|
21
26
|
worktreeInstall: boolean;
|
|
27
|
+
/** Free GB under which worktree setup and `bkit disk prune --auto` run the max cleanup steps. */
|
|
28
|
+
diskMinFreeGb: number;
|
|
22
29
|
/** Which tracker issues live in: github, linear or none. */
|
|
23
30
|
issueTracker: IssueTracker;
|
|
24
31
|
/** The GitHub Projects v2 board settings; false = opted out, null = not configured. */
|
|
25
32
|
githubProject: Record<string, unknown> | false | null;
|
|
26
33
|
/** CI lanes whose `skipped` conclusion refuses a ship merge; empty = the capstone's green decides. */
|
|
27
34
|
shipGateRequiredLanes: string[];
|
|
35
|
+
/** The opencode provider recorded on install; null = absent or not a supported provider. */
|
|
36
|
+
opencodeProvider: OpencodeProvider | null;
|
|
37
|
+
/** Every installed opencode provider, supported ones only; empty = none recorded. */
|
|
38
|
+
opencodeProviders: OpencodeProvider[];
|
|
39
|
+
/** The post-CI cloud-agent variant; `none` is both the default and the explicit opt-out. */
|
|
40
|
+
cloudAgents: CloudAgents;
|
|
41
|
+
/** `bkit.depUpdater` is `"none"`: silences the missing-dependency-updater advisory. */
|
|
42
|
+
depUpdaterOptOut: boolean;
|
|
43
|
+
/** `bkit.issueTracker` is present with any value, so `none` is a choice, not an undecided install. */
|
|
44
|
+
issueTrackerExplicit: boolean;
|
|
45
|
+
/** `bkit.cloudAgents` is present with any value, so `none` is a choice, not an undecided install. */
|
|
46
|
+
cloudAgentsExplicit: boolean;
|
|
28
47
|
}
|
|
29
48
|
|
|
30
49
|
export const CONFIG_DEFAULTS: Readonly<BkitConfig> = {
|
|
@@ -32,9 +51,16 @@ export const CONFIG_DEFAULTS: Readonly<BkitConfig> = {
|
|
|
32
51
|
capstoneJob: "bkit-tests-check",
|
|
33
52
|
worktreeCopy: [".env", ".env.local"],
|
|
34
53
|
worktreeInstall: true,
|
|
54
|
+
diskMinFreeGb: 40,
|
|
35
55
|
issueTracker: DEFAULT_ISSUE_TRACKER,
|
|
36
56
|
githubProject: null,
|
|
37
57
|
shipGateRequiredLanes: [],
|
|
58
|
+
opencodeProvider: null,
|
|
59
|
+
opencodeProviders: [],
|
|
60
|
+
cloudAgents: DEFAULT_CLOUD_AGENTS,
|
|
61
|
+
depUpdaterOptOut: false,
|
|
62
|
+
issueTrackerExplicit: false,
|
|
63
|
+
cloudAgentsExplicit: false,
|
|
38
64
|
};
|
|
39
65
|
|
|
40
66
|
const nonEmptyString = (v: unknown): v is string => typeof v === "string" && v.trim() !== "";
|
|
@@ -49,8 +75,11 @@ export function readBkitConfig(root: string): BkitConfig {
|
|
|
49
75
|
const bkit = ((read.ok ? read.pkg.bkit : undefined) ?? {}) as Record<string, unknown>;
|
|
50
76
|
const worktree = (bkit.worktree ?? {}) as Record<string, unknown>;
|
|
51
77
|
const copy = worktree.copy;
|
|
78
|
+
const minFreeGb = ((bkit.disk ?? {}) as Record<string, unknown>).minFreeGb;
|
|
52
79
|
const project = bkit.githubProject;
|
|
53
80
|
const lanes = bkit.shipGateRequiredLanes;
|
|
81
|
+
const provider = bkit.opencodeProvider;
|
|
82
|
+
const providers = bkit.opencodeProviders;
|
|
54
83
|
return {
|
|
55
84
|
ciWorkflow: nonEmptyString(bkit.ciWorkflow) ? bkit.ciWorkflow : CONFIG_DEFAULTS.ciWorkflow,
|
|
56
85
|
capstoneJob: nonEmptyString(bkit.capstoneJob) ? bkit.capstoneJob : CONFIG_DEFAULTS.capstoneJob,
|
|
@@ -60,6 +89,10 @@ export function readBkitConfig(root: string): BkitConfig {
|
|
|
60
89
|
: [...CONFIG_DEFAULTS.worktreeCopy],
|
|
61
90
|
worktreeInstall:
|
|
62
91
|
typeof worktree.install === "boolean" ? worktree.install : CONFIG_DEFAULTS.worktreeInstall,
|
|
92
|
+
diskMinFreeGb:
|
|
93
|
+
typeof minFreeGb === "number" && Number.isFinite(minFreeGb) && minFreeGb >= 0
|
|
94
|
+
? minFreeGb
|
|
95
|
+
: CONFIG_DEFAULTS.diskMinFreeGb,
|
|
63
96
|
issueTracker: parseIssueTracker(bkit.issueTracker) ?? CONFIG_DEFAULTS.issueTracker,
|
|
64
97
|
githubProject:
|
|
65
98
|
project === false
|
|
@@ -68,5 +101,16 @@ export function readBkitConfig(root: string): BkitConfig {
|
|
|
68
101
|
? (project as Record<string, unknown>)
|
|
69
102
|
: null,
|
|
70
103
|
shipGateRequiredLanes: Array.isArray(lanes) ? lanes.filter(nonEmptyString) : [],
|
|
104
|
+
opencodeProvider:
|
|
105
|
+
typeof provider === "string" && isOpencodeProvider(provider) ? provider : null,
|
|
106
|
+
opencodeProviders: Array.isArray(providers)
|
|
107
|
+
? providers.filter(
|
|
108
|
+
(v): v is OpencodeProvider => typeof v === "string" && isOpencodeProvider(v),
|
|
109
|
+
)
|
|
110
|
+
: [],
|
|
111
|
+
cloudAgents: parseCloudAgents(bkit.cloudAgents) ?? CONFIG_DEFAULTS.cloudAgents,
|
|
112
|
+
depUpdaterOptOut: bkit.depUpdater === "none",
|
|
113
|
+
issueTrackerExplicit: bkit.issueTracker !== undefined,
|
|
114
|
+
cloudAgentsExplicit: bkit.cloudAgents !== undefined,
|
|
71
115
|
};
|
|
72
116
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// shared/timeouts.ts — bkit-owned waits, poll intervals and stale ages.
|
|
2
2
|
//
|
|
3
|
-
// One table so no command hard-codes a wait of its own
|
|
4
|
-
//
|
|
5
|
-
// equal. Units are in the name (`_S` seconds).
|
|
3
|
+
// One table so no command hard-codes a wait of its own. Units are in the name
|
|
4
|
+
// (`_S` seconds).
|
|
6
5
|
|
|
7
6
|
export const TIMEOUTS = {
|
|
8
7
|
/** Wall-clock seconds to wait for a CI run to appear and complete after a head move. */
|
|
@@ -13,10 +12,12 @@ export const TIMEOUTS = {
|
|
|
13
12
|
SHIP_PROBE_INTERVAL_S: 10,
|
|
14
13
|
/** Re-validate presence probe: how many checks (6 x 10s = the 60s a push-triggered run needs). */
|
|
15
14
|
SHIP_PROBE_ATTEMPTS: 6,
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
/** Seconds
|
|
19
|
-
|
|
15
|
+
/** Every dev landing: tries at the dev push (dev moved underneath); design / plan close: at the PR merge too. */
|
|
16
|
+
LAND_ATTEMPTS: 10,
|
|
17
|
+
/** Seconds before the first retry of a landing; doubles each retry up to LAND_BACKOFF_CAP_S. */
|
|
18
|
+
LAND_BACKOFF_START_S: 2,
|
|
19
|
+
/** Longest single wait between landing retries, in seconds. */
|
|
20
|
+
LAND_BACKOFF_CAP_S: 30,
|
|
20
21
|
/** Seconds a registry answer for the newest published bkit is reused before asking again. */
|
|
21
22
|
BKIT_LATEST_CACHE_S: 86400,
|
|
22
23
|
/** Seconds a failed registry lookup is remembered, so an offline run does not wait on every call. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// --- Shell detection: identical in every host's guardrails hook (bkit renders it from
|
|
2
2
|
// one source). Needs `fs` and `path` in scope; the host's own code above declares them.
|
|
3
3
|
|
|
4
|
-
/** Wrappers that precede the real command; skipped when finding a
|
|
4
|
+
/** Wrappers that precede the real command; skipped when finding a command's program. */
|
|
5
5
|
const CMD_WRAPPERS = new Set(["sudo", "env", "time", "nohup", "nice", "command", "exec", "xargs"]);
|
|
6
6
|
|
|
7
7
|
/** Split a command line into pipeline / list segments. */
|
|
@@ -13,28 +13,95 @@ function shellSegments(cmd) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* A token that only appears as an argument (`grep -n 'curl' file`,
|
|
20
|
-
* `sed -n '/sed -i/p' notes.md`) is not the segment's program.
|
|
16
|
+
* A segment's words: single / double quotes group and are dropped, a backslash escapes
|
|
17
|
+
* the next character, an unquoted `#` at a word start ends the segment (comment). An
|
|
18
|
+
* unterminated quote runs to the end of the segment.
|
|
21
19
|
*/
|
|
22
|
-
function
|
|
23
|
-
const words =
|
|
20
|
+
function shellWords(seg) {
|
|
21
|
+
const words = [];
|
|
22
|
+
let cur = "";
|
|
23
|
+
let started = false;
|
|
24
|
+
let quote = "";
|
|
25
|
+
for (let i = 0; i < seg.length; i++) {
|
|
26
|
+
const ch = seg[i];
|
|
27
|
+
if (quote) {
|
|
28
|
+
if (ch === quote) quote = "";
|
|
29
|
+
else if (ch === "\\" && quote === '"' && i + 1 < seg.length) cur += seg[++i];
|
|
30
|
+
else cur += ch;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (ch === "#" && !started) break;
|
|
34
|
+
if (ch === "'" || ch === '"') {
|
|
35
|
+
quote = ch;
|
|
36
|
+
started = true;
|
|
37
|
+
} else if (ch === "\\" && i + 1 < seg.length) {
|
|
38
|
+
cur += seg[++i];
|
|
39
|
+
started = true;
|
|
40
|
+
} else if (/\s/.test(ch)) {
|
|
41
|
+
if (started) words.push(cur);
|
|
42
|
+
cur = "";
|
|
43
|
+
started = false;
|
|
44
|
+
} else {
|
|
45
|
+
cur += ch;
|
|
46
|
+
started = true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (started) words.push(cur);
|
|
50
|
+
return words;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The words a segment runs: subshell punctuation, `VAR=val` and wrappers skipped. */
|
|
54
|
+
function commandWords(seg) {
|
|
55
|
+
const words = shellWords(seg.replace(/^(?:\$\(|[({`!\s])+/, "").replace(/[)}`\s]+$/, ""));
|
|
24
56
|
let i = 0;
|
|
25
57
|
while (
|
|
26
58
|
i < words.length &&
|
|
27
59
|
(/^[A-Za-z_][A-Za-z0-9_]*=/.test(words[i]) || CMD_WRAPPERS.has(words[i]))
|
|
28
60
|
)
|
|
29
61
|
i++;
|
|
30
|
-
return
|
|
62
|
+
return words.slice(i);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const SHELLS = new Set(["sh", "bash", "zsh", "dash", "ksh"]);
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Every command line the input runs: each list / pipeline segment, the script of a
|
|
69
|
+
* `sh -c '…'`, and the body of each `$(…)` / backtick substitution, recursively.
|
|
70
|
+
*/
|
|
71
|
+
function commandLines(cmd, depth = 0) {
|
|
72
|
+
const lines = [];
|
|
73
|
+
if (depth < 3) {
|
|
74
|
+
for (const m of String(cmd).matchAll(/\$\(([^()]*)\)|`([^`]*)`/g)) {
|
|
75
|
+
lines.push(...commandLines(m[1] ?? m[2] ?? "", depth + 1));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for (const seg of shellSegments(cmd)) {
|
|
79
|
+
lines.push(seg);
|
|
80
|
+
if (depth >= 3) continue;
|
|
81
|
+
const words = commandWords(seg);
|
|
82
|
+
const head = (words[0] || "").replace(/^.*\//, "");
|
|
83
|
+
if (!SHELLS.has(head)) continue;
|
|
84
|
+
const c = words.findIndex((w, i) => i > 0 && /^-[a-z]*c$/.test(w));
|
|
85
|
+
if (c > 0 && words[c + 1]) lines.push(...commandLines(words[c + 1], depth + 1));
|
|
86
|
+
}
|
|
87
|
+
return lines;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** The program a command line runs, path stripped (`/usr/bin/curl` -> `curl`). */
|
|
91
|
+
function commandProgram(words) {
|
|
92
|
+
return (words[0] || "").replace(/^.*\//, "");
|
|
31
93
|
}
|
|
32
94
|
|
|
33
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* True when some command line actually INVOKES curl or wget, including inside
|
|
97
|
+
* `sh -c '…'`, `$(…)`, backticks and `( … )`.
|
|
98
|
+
*
|
|
99
|
+
* A token that only appears as an argument (`grep -n 'curl' file`) is not a program.
|
|
100
|
+
*/
|
|
34
101
|
function usesFetch(cmd) {
|
|
35
|
-
return
|
|
36
|
-
const
|
|
37
|
-
return
|
|
102
|
+
return commandLines(cmd).some((line) => {
|
|
103
|
+
const p = commandProgram(commandWords(line));
|
|
104
|
+
return p === "curl" || p === "wget";
|
|
38
105
|
});
|
|
39
106
|
}
|
|
40
107
|
|
|
@@ -42,6 +109,48 @@ function usesFetch(cmd) {
|
|
|
42
109
|
const SOURCE_EXT_RE =
|
|
43
110
|
/\.(ts|tsx|js|jsx|cjs|mjs|json|md|sh|bash|py|rb|go|rs|java|css|scss|html|ya?ml|toml|sql)$/i;
|
|
44
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Targets of every unquoted `>` / `>>` redirect in a command line. A `>` inside single
|
|
114
|
+
* or double quotes is text (`rg 'a > b.ts'`), a backslash-escaped `>` is a literal, and
|
|
115
|
+
* `2>`, `&>` and `>&` forms (fd redirects) are not file targets.
|
|
116
|
+
*/
|
|
117
|
+
function redirectTargets(text) {
|
|
118
|
+
const targets = [];
|
|
119
|
+
let quote = "";
|
|
120
|
+
for (let i = 0; i < text.length; i++) {
|
|
121
|
+
const ch = text[i];
|
|
122
|
+
if (quote) {
|
|
123
|
+
if (ch === quote) quote = "";
|
|
124
|
+
else if (ch === "\\" && quote === '"') i++;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (ch === "'" || ch === '"') quote = ch;
|
|
128
|
+
else if (ch === "\\") i++;
|
|
129
|
+
else if (ch === ">") {
|
|
130
|
+
const prev = text[i - 1] ?? "";
|
|
131
|
+
let j = i + 1;
|
|
132
|
+
if (text[j] === ">") j++;
|
|
133
|
+
const fdOrAmp = /[>&\d]/.test(prev);
|
|
134
|
+
i = j - 1;
|
|
135
|
+
if (fdOrAmp) continue;
|
|
136
|
+
while (/\s/.test(text[j] ?? "")) j++;
|
|
137
|
+
const open = text[j];
|
|
138
|
+
let target = "";
|
|
139
|
+
if (open === '"' || open === "'") {
|
|
140
|
+
const end = text.indexOf(open, j + 1);
|
|
141
|
+
target = end < 0 ? "" : text.slice(j + 1, end);
|
|
142
|
+
i = end < 0 ? text.length : end;
|
|
143
|
+
} else {
|
|
144
|
+
const m = /^[^\s;|&<>]+/.exec(text.slice(j));
|
|
145
|
+
target = m ? m[0] : "";
|
|
146
|
+
i = j + target.length - 1;
|
|
147
|
+
}
|
|
148
|
+
if (target.trim()) targets.push(target.trim());
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return targets;
|
|
152
|
+
}
|
|
153
|
+
|
|
45
154
|
/**
|
|
46
155
|
* Detect a shell command being used as an edit channel. Returns a list of human
|
|
47
156
|
* descriptions, empty when the command edits nothing.
|
|
@@ -52,25 +161,27 @@ const SOURCE_EXT_RE =
|
|
|
52
161
|
*/
|
|
53
162
|
function shellEditTargets(cmd) {
|
|
54
163
|
const hits = [];
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
164
|
+
const lines = commandLines(cmd);
|
|
165
|
+
for (const line of lines) {
|
|
166
|
+
const words = commandWords(line);
|
|
167
|
+
const program = commandProgram(words);
|
|
168
|
+
const args = words.slice(1);
|
|
169
|
+
if ((program === "sed" || program === "perl") && args.some((w) => /^-i(?:\..*)?$/.test(w))) {
|
|
58
170
|
hits.push("in-place sed/perl (-i)");
|
|
59
171
|
}
|
|
60
|
-
if (
|
|
172
|
+
if (program === "awk" && args.some((w, i) => w === "-i" && args[i + 1] === "inplace")) {
|
|
173
|
+
hits.push("awk -i inplace");
|
|
174
|
+
}
|
|
61
175
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (/\.(log|bak|tmp|out|err|orig)$/i.test(target)) continue;
|
|
72
|
-
if (!SOURCE_EXT_RE.test(target)) continue;
|
|
73
|
-
hits.push(`redirect into ${target}`);
|
|
176
|
+
for (const text of [String(cmd), ...lines]) {
|
|
177
|
+
for (const target of redirectTargets(text)) {
|
|
178
|
+
// Scratch and env sinks — never a source edit.
|
|
179
|
+
if (target.startsWith("$") || target.startsWith("&")) continue;
|
|
180
|
+
if (/^\/(dev|tmp|var\/folders|var\/tmp)\//.test(target)) continue;
|
|
181
|
+
if (/\.(log|bak|tmp|out|err|orig)$/i.test(target)) continue;
|
|
182
|
+
if (!SOURCE_EXT_RE.test(target)) continue;
|
|
183
|
+
hits.push(`redirect into ${target}`);
|
|
184
|
+
}
|
|
74
185
|
}
|
|
75
186
|
return [...new Set(hits)];
|
|
76
187
|
}
|
|
@@ -86,18 +197,52 @@ function shellEditAdvisory(hits) {
|
|
|
86
197
|
);
|
|
87
198
|
}
|
|
88
199
|
|
|
200
|
+
/** Repo-relative path of the install-written network allowlist every host's hook reads. */
|
|
201
|
+
const NETWORK_ALLOWLIST_FILE = path.join(".bkit", "allowlist.json");
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Directories a hook call names, most authoritative first: the workspace roots (Cursor
|
|
205
|
+
* `workspace_roots`; Antigravity `workspacePaths`, carried over by its payload adapter),
|
|
206
|
+
* the payload `cwd` (Claude, Codex, Cursor), then the hook process's own cwd — which on
|
|
207
|
+
* Antigravity is the plugin dir, not the repo.
|
|
208
|
+
*/
|
|
209
|
+
function hookDirs(payload) {
|
|
210
|
+
const p = payload && typeof payload === "object" ? payload : {};
|
|
211
|
+
const roots = Array.isArray(p.workspace_roots) ? p.workspace_roots : [];
|
|
212
|
+
return [...roots, p.cwd, process.cwd()].filter((d) => typeof d === "string" && d !== "");
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* The network allowlist file for a hook call: walking up from each of `dirs` in turn,
|
|
217
|
+
* the first `.bkit/allowlist.json` found. A directory holding `.git` (the repo root)
|
|
218
|
+
* ends that walk. null when none is found.
|
|
219
|
+
*/
|
|
220
|
+
function findNetworkAllowlist(dirs) {
|
|
221
|
+
for (const start of dirs) {
|
|
222
|
+
let dir = path.resolve(start);
|
|
223
|
+
for (;;) {
|
|
224
|
+
const file = path.join(dir, NETWORK_ALLOWLIST_FILE);
|
|
225
|
+
if (fs.existsSync(file)) return file;
|
|
226
|
+
const parent = path.dirname(dir);
|
|
227
|
+
if (parent === dir || fs.existsSync(path.join(dir, ".git"))) break;
|
|
228
|
+
dir = parent;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
|
|
89
234
|
/**
|
|
90
|
-
* Hosts come from `.
|
|
91
|
-
*
|
|
92
|
-
* `allowed-domains`); every host's hook reads it
|
|
93
|
-
*
|
|
94
|
-
* host is treated as unknown.
|
|
235
|
+
* Hosts come from `.bkit/allowlist.json`, the one install-written artifact carrying the
|
|
236
|
+
* resolved network allowlist (the shipped egress registry union the consumer's
|
|
237
|
+
* `allowed-domains`); every host's hook reads it, found from the hook call's
|
|
238
|
+
* directories (`hookDirs`). There is NO hardcoded fallback list: absent or unreadable,
|
|
239
|
+
* this returns empty and every host is treated as unknown.
|
|
95
240
|
*/
|
|
96
|
-
function loadNetworkAllowlistBases() {
|
|
241
|
+
function loadNetworkAllowlistBases(dirs) {
|
|
97
242
|
const bases = new Set();
|
|
98
243
|
try {
|
|
99
|
-
const p =
|
|
100
|
-
if (
|
|
244
|
+
const p = findNetworkAllowlist(dirs);
|
|
245
|
+
if (p) {
|
|
101
246
|
const doc = JSON.parse(fs.readFileSync(p, "utf8"));
|
|
102
247
|
const domains = Array.isArray(doc.domains) ? doc.domains : [];
|
|
103
248
|
for (const d of domains) {
|
|
@@ -144,11 +289,12 @@ function hostMatchesBase(host, base) {
|
|
|
144
289
|
* True when EVERY URL in the command targets an allowlisted host.
|
|
145
290
|
*
|
|
146
291
|
* Only each URL's host is consulted, never the rest of the command string (query
|
|
147
|
-
* params, headers). No parseable URL, or any host off the list → false.
|
|
292
|
+
* params, headers). No parseable URL, or any host off the list → false. `dirs` locate
|
|
293
|
+
* the allowlist (`hookDirs`).
|
|
148
294
|
*/
|
|
149
|
-
function curlWgetHostAllowed(cmd) {
|
|
295
|
+
function curlWgetHostAllowed(cmd, dirs) {
|
|
150
296
|
const hosts = extractUrlHosts(cmd);
|
|
151
297
|
if (hosts.length === 0) return false;
|
|
152
|
-
const bases = loadNetworkAllowlistBases();
|
|
298
|
+
const bases = loadNetworkAllowlistBases(dirs);
|
|
153
299
|
return hosts.every((h) => [...bases].some((b) => hostMatchesBase(h, b)));
|
|
154
300
|
}
|