@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
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
// Example. Copy to ~/.config/bkit/disk-prune.mjs (`$XDG_CONFIG_HOME/bkit/` when set) and own
|
|
2
|
+
// it. bkit install does not write this file and does not overwrite a copy.
|
|
3
|
+
/**
|
|
4
|
+
* disk-prune.mjs — this machine's cleanup steps for `bkit disk prune`: tools every repo on
|
|
5
|
+
* the machine shares (Docker, the pnpm store, Xcode, Gradle, simulators). bkit deletes
|
|
6
|
+
* nothing itself: it runs only the steps listed here and in each checkout's
|
|
7
|
+
* `scripts/cleanup/bkit-disk-prune.mjs`.
|
|
8
|
+
*
|
|
9
|
+
* Steps run from the home folder, one at a time, with the same shape as the checkout file:
|
|
10
|
+
* `name`, `mode` ("min" | "max"; `max` runs the `min` steps too), `run` (shell command or
|
|
11
|
+
* function), optional `skip` and `paths` (what `--dry-run` sizes: the most the step can free;
|
|
12
|
+
* leave it out when that misleads). A step whose tool is not installed skips itself.
|
|
13
|
+
*
|
|
14
|
+
* Keep a step only when what it deletes comes back by itself. Deliberately left out — add
|
|
15
|
+
* them yourself only if you accept the cost:
|
|
16
|
+
* - Docker named volumes (`docker volume prune -a`): local databases live there
|
|
17
|
+
* - whole runtimes or SDKs (Xcode, Android system images, iOS simulator runtimes, Node
|
|
18
|
+
* versions): gigabytes to download and a manual step to reinstall
|
|
19
|
+
* - deleting the whole pnpm store: `node_modules` hard-link into it, so it frees nothing
|
|
20
|
+
* while any checkout is installed; `pnpm store prune` frees what can be freed
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { spawnSync } from "node:child_process";
|
|
24
|
+
import os from "node:os";
|
|
25
|
+
|
|
26
|
+
/** True when `tool` is on PATH. */
|
|
27
|
+
const has = (tool) => spawnSync("sh", ["-c", `command -v ${tool}`]).status === 0;
|
|
28
|
+
/** True when a process whose full command line matches `pattern` is running. */
|
|
29
|
+
const running = (pattern) => spawnSync("pgrep", ["-f", pattern]).status === 0;
|
|
30
|
+
const missing = (tool) => !has(tool) && `${tool} is not installed`;
|
|
31
|
+
const dockerDown = () =>
|
|
32
|
+
missing("docker") ||
|
|
33
|
+
(spawnSync("docker", ["info"], { stdio: "ignore" }).status !== 0 && "Docker is not running");
|
|
34
|
+
const notMac = () => os.platform() !== "darwin" && "not macOS";
|
|
35
|
+
|
|
36
|
+
/** Docker's major version; 0 when unreadable. */
|
|
37
|
+
function dockerMajor() {
|
|
38
|
+
const r = spawnSync("docker", ["version", "--format", "{{.Server.Version}}"], {
|
|
39
|
+
encoding: "utf8",
|
|
40
|
+
});
|
|
41
|
+
return r.status === 0 ? Number(r.stdout.split(".")[0]) || 0 : 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Name the simulators and emulators you can do without; empty = none deleted. Booted or
|
|
45
|
+
// running ones are skipped. Find names with `xcrun simctl list devices` and
|
|
46
|
+
// `emulator -list-avds`.
|
|
47
|
+
const SIMULATORS = [];
|
|
48
|
+
const EMULATORS = [];
|
|
49
|
+
|
|
50
|
+
export default [
|
|
51
|
+
// --- min: stale, cheap ---------------------------------------------------
|
|
52
|
+
{
|
|
53
|
+
// Comes back: the next `docker build` or `docker pull`.
|
|
54
|
+
name: "Docker dangling images",
|
|
55
|
+
mode: "min",
|
|
56
|
+
skip: dockerDown,
|
|
57
|
+
run: "docker image prune -f",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
// Comes back: the next `docker build`, slower once.
|
|
61
|
+
name: "Docker build cache older than 7 days",
|
|
62
|
+
mode: "min",
|
|
63
|
+
skip: dockerDown,
|
|
64
|
+
run: "docker builder prune -f --filter until=168h",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
// Comes back: never needed — no container uses them. Docker 23+ prunes only anonymous
|
|
68
|
+
// volumes; older Docker would also take named volumes, so the step skips there.
|
|
69
|
+
name: "Docker anonymous volumes",
|
|
70
|
+
mode: "min",
|
|
71
|
+
skip: () => dockerDown() || (dockerMajor() < 23 && "Docker older than 23 prunes named volumes"),
|
|
72
|
+
run: "docker volume prune -f",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
// Comes back: the next `pnpm install` that needs a removed package. No `paths`: the
|
|
76
|
+
// store's size is far more than a prune frees.
|
|
77
|
+
name: "pnpm store packages no project uses",
|
|
78
|
+
mode: "min",
|
|
79
|
+
skip: () =>
|
|
80
|
+
missing("pnpm") || (running("pnpm (install|i|add|update)( |$)") && "pnpm is installing"),
|
|
81
|
+
run: "pnpm store prune",
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
// Comes back: never needed — these simulators belong to runtimes no longer installed.
|
|
85
|
+
name: "iOS simulators whose runtime is gone",
|
|
86
|
+
mode: "min",
|
|
87
|
+
skip: () => notMac() || missing("xcrun"),
|
|
88
|
+
run: "xcrun simctl delete unavailable",
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
// Comes back: the next `npm install` that needs a removed entry.
|
|
92
|
+
name: "npm cache: drop corrupt and unused entries",
|
|
93
|
+
mode: "min",
|
|
94
|
+
paths: ["~/.npm/_cacache"],
|
|
95
|
+
skip: () => missing("npm"),
|
|
96
|
+
run: "npm cache verify",
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
// --- max: everything that comes back by itself -------------------------
|
|
100
|
+
{
|
|
101
|
+
// Comes back: the next `docker pull` or `docker build`. Containers you have stopped
|
|
102
|
+
// keep their images; `supabase stop` removes its containers, so its images go too and
|
|
103
|
+
// `supabase start` pulls them again.
|
|
104
|
+
name: "Docker images no container uses",
|
|
105
|
+
mode: "max",
|
|
106
|
+
skip: dockerDown,
|
|
107
|
+
run: "docker image prune -a -f",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
// Comes back: the next `docker build`, slower once.
|
|
111
|
+
name: "All of the Docker build cache",
|
|
112
|
+
mode: "max",
|
|
113
|
+
skip: dockerDown,
|
|
114
|
+
run: "docker builder prune -a -f",
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
// Comes back: the next Xcode build, slower once.
|
|
118
|
+
name: "Xcode DerivedData",
|
|
119
|
+
mode: "max",
|
|
120
|
+
paths: ["~/Library/Developer/Xcode/DerivedData"],
|
|
121
|
+
skip: () => notMac() || (running("xcodebuild") && "xcodebuild is running"),
|
|
122
|
+
run: 'rm -rf "$HOME/Library/Developer/Xcode/DerivedData"',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
// Comes back: the next Gradle build downloads and rebuilds what it needs.
|
|
126
|
+
name: "Gradle caches",
|
|
127
|
+
mode: "max",
|
|
128
|
+
paths: ["~/.gradle/caches"],
|
|
129
|
+
skip: () => running("GradleDaemon") && "a Gradle daemon is running (`gradle --stop`)",
|
|
130
|
+
run: 'rm -rf "$HOME/.gradle/caches"',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
// Comes back: an emulator cold-boots once, then saves a fresh snapshot.
|
|
134
|
+
name: "Android emulator snapshots",
|
|
135
|
+
mode: "max",
|
|
136
|
+
paths: ["~/.android/avd/*.avd/snapshots"],
|
|
137
|
+
skip: () => running("qemu-system") && "an Android emulator is running",
|
|
138
|
+
run: 'rm -rf "$HOME"/.android/avd/*.avd/snapshots',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
// Comes back: recreate with `xcrun simctl create` (or Xcode → Devices) when needed.
|
|
142
|
+
name: "iOS simulators named in SIMULATORS",
|
|
143
|
+
mode: "max",
|
|
144
|
+
skip: () => notMac() || missing("xcrun") || (SIMULATORS.length === 0 && "SIMULATORS is empty"),
|
|
145
|
+
run: ({ log }) => {
|
|
146
|
+
const booted = spawnSync("xcrun", ["simctl", "list", "devices", "booted"], {
|
|
147
|
+
encoding: "utf8",
|
|
148
|
+
}).stdout;
|
|
149
|
+
for (const name of SIMULATORS) {
|
|
150
|
+
if (booted.includes(`${name} (`)) {
|
|
151
|
+
log(`kept ${name}: booted`);
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
const r = spawnSync("xcrun", ["simctl", "delete", name], { encoding: "utf8" });
|
|
155
|
+
log(`${name}: ${r.status === 0 ? "deleted" : "not deleted"}`);
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
// Comes back: recreate with `avdmanager create avd` (or Android Studio) when needed.
|
|
161
|
+
name: "Android emulators named in EMULATORS",
|
|
162
|
+
mode: "max",
|
|
163
|
+
skip: () => missing("avdmanager") || (EMULATORS.length === 0 && "EMULATORS is empty"),
|
|
164
|
+
run: ({ log }) => {
|
|
165
|
+
for (const name of EMULATORS) {
|
|
166
|
+
if (running(`-avd ${name}( |$)`)) {
|
|
167
|
+
log(`kept ${name}: running`);
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
const r = spawnSync("avdmanager", ["delete", "avd", "-n", name], { encoding: "utf8" });
|
|
171
|
+
log(`${name}: ${r.status === 0 ? "deleted" : "not deleted"}`);
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
// Comes back: the next `npm install` / `npx` downloads what it needs.
|
|
177
|
+
name: "All of the npm cache",
|
|
178
|
+
mode: "max",
|
|
179
|
+
paths: ["~/.npm/_cacache"],
|
|
180
|
+
skip: () => missing("npm"),
|
|
181
|
+
run: "npm cache clean --force",
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
// Comes back: the next `uv` / `uvx` run downloads what it needs.
|
|
185
|
+
name: "uv cache",
|
|
186
|
+
mode: "max",
|
|
187
|
+
skip: () => missing("uv"),
|
|
188
|
+
run: "uv cache clean",
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
// Comes back: Homebrew downloads again only to reinstall or upgrade.
|
|
192
|
+
name: "Homebrew downloads and old versions",
|
|
193
|
+
mode: "max",
|
|
194
|
+
skip: () => missing("brew"),
|
|
195
|
+
run: "brew cleanup --prune=all",
|
|
196
|
+
},
|
|
197
|
+
];
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// Example. Copy into scripts/cleanup/ and own it. bkit install does not write this file
|
|
2
|
+
// and does not overwrite a copy.
|
|
3
|
+
/**
|
|
4
|
+
* bkit-disk-prune.mjs — this checkout's cleanup steps for `bkit disk prune`. bkit deletes
|
|
5
|
+
* nothing itself: it runs only the steps listed here and in your machine file
|
|
6
|
+
* (`~/.config/bkit/disk-prune.mjs`, from `bkit-disk-prune.machine.mjs`).
|
|
7
|
+
*
|
|
8
|
+
* Steps run from the top of the checkout, one at a time. Each step:
|
|
9
|
+
* name what it frees, shown in the log
|
|
10
|
+
* mode "min" (stale, cheap; runs from pre-commit) or "max" (everything that comes back by
|
|
11
|
+
* itself; runs after the pre-push gates pass and before a worktree is made on a low
|
|
12
|
+
* disk). `max` runs the `min` steps too.
|
|
13
|
+
* run a shell command (`sh -c`) or a function `({ cwd, log, note }) => …`; non-zero exit
|
|
14
|
+
* or a throw = failed, logged, the next step still runs. `note(text)` = something
|
|
15
|
+
* only a person can decide; `bkit tips` lists it until the next sweep
|
|
16
|
+
* skip optional; a shell command (exit 0 = skip) or a function returning a reason to skip
|
|
17
|
+
* paths optional; what `bkit disk prune --dry-run` sizes, the most the step can free
|
|
18
|
+
* (relative, `~/…`, or globs)
|
|
19
|
+
*
|
|
20
|
+
* Keep a step only when what it deletes comes back by itself. Edit, add or drop freely:
|
|
21
|
+
* paths below assume a monorepo with apps under `apps/`.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { spawnSync } from "node:child_process";
|
|
25
|
+
import fs from "node:fs";
|
|
26
|
+
import path from "node:path";
|
|
27
|
+
|
|
28
|
+
/** True when a process whose full command line matches `pattern` is running. */
|
|
29
|
+
const running = (pattern) => spawnSync("pgrep", ["-f", pattern]).status === 0;
|
|
30
|
+
|
|
31
|
+
const turboRunning = () => running("(^|/)turbo( |$)") && "turbo is running";
|
|
32
|
+
const nextRunning = () =>
|
|
33
|
+
running("(^|/)next( (dev|build|start)|-server)") && "a Next.js server or build is running";
|
|
34
|
+
|
|
35
|
+
/** `text` as JSON: `{ ok: true, value }`, or `{ ok: false, error }` saying why not. */
|
|
36
|
+
function parseJson(text) {
|
|
37
|
+
try {
|
|
38
|
+
return { ok: true, value: JSON.parse(text) };
|
|
39
|
+
} catch (err) {
|
|
40
|
+
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Days since `wt`'s last commit; Infinity when unreadable. */
|
|
45
|
+
function idleDays(wt) {
|
|
46
|
+
const r = spawnSync("git", ["-C", wt, "log", "-1", "--format=%ct"], { encoding: "utf8" });
|
|
47
|
+
const at = Number(r.stdout.trim());
|
|
48
|
+
return r.status === 0 && at > 0 ? (Date.now() / 1000 - at) / 86400 : Infinity;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* True when a merged pull request's head is exactly `sha`: a squash merge leaves the
|
|
53
|
+
* branch's own commits on no remote. Needs `gh`; false when it cannot answer.
|
|
54
|
+
*/
|
|
55
|
+
function mergedPrAt(cwd, branch, sha) {
|
|
56
|
+
if (branch === "") return false;
|
|
57
|
+
const r = spawnSync(
|
|
58
|
+
"gh",
|
|
59
|
+
["pr", "list", "--head", branch, "--state", "merged", "--json", "headRefOid"],
|
|
60
|
+
{ cwd, encoding: "utf8" },
|
|
61
|
+
);
|
|
62
|
+
const prs = r.status === 0 ? parseJson(r.stdout) : { ok: false };
|
|
63
|
+
return prs.ok && Array.isArray(prs.value) && prs.value.some((pr) => pr.headRefOid === sha);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Leftover worktree `wt` (named `fid`): `{ keep }` while in use, `{ note }` when only a
|
|
68
|
+
* person can tell, else `{}` — removing it loses nothing.
|
|
69
|
+
*/
|
|
70
|
+
function judge(cwd, wt, fid) {
|
|
71
|
+
const git = (...args) => spawnSync("git", ["-C", wt, ...args], { encoding: "utf8" });
|
|
72
|
+
if (fs.globSync(path.join(cwd, "docs/plans/*/logs", fid, ".lock")).length > 0)
|
|
73
|
+
return { keep: "a bkit workflow holds its lock" };
|
|
74
|
+
if (idleDays(wt) < 2) return { keep: "committed to in the last 2 days" };
|
|
75
|
+
const status = git("status", "--porcelain");
|
|
76
|
+
if (status.status !== 0) return { note: "not a git worktree; delete the folder if unneeded" };
|
|
77
|
+
if (status.stdout.trim() !== "")
|
|
78
|
+
return { note: `uncommitted or untracked files (\`git -C .worktrees/${fid} status\`)` };
|
|
79
|
+
if (git("rev-list", "HEAD", "--not", "--remotes").stdout.trim() !== "") {
|
|
80
|
+
const branch = git("branch", "--show-current").stdout.trim();
|
|
81
|
+
const sha = git("rev-parse", "HEAD").stdout.trim();
|
|
82
|
+
if (!mergedPrAt(cwd, branch, sha))
|
|
83
|
+
return { note: "commits on no remote branch, and no merged pull request ends at HEAD" };
|
|
84
|
+
}
|
|
85
|
+
return {};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Remove worktree `wt`; null when gone, else why not. */
|
|
89
|
+
function removeWorktree(cwd, wt, fid) {
|
|
90
|
+
const r = spawnSync("pnpm", ["-s", "bkit", "worktrees", "remove", `--fid=${fid}`], {
|
|
91
|
+
cwd,
|
|
92
|
+
encoding: "utf8",
|
|
93
|
+
});
|
|
94
|
+
const parsed = parseJson(r.stdout);
|
|
95
|
+
if (!parsed.ok) return `bkit worktrees remove failed (exit ${r.status}; output: ${parsed.error})`;
|
|
96
|
+
const out = parsed.value;
|
|
97
|
+
if (out?.removed === true) return null;
|
|
98
|
+
if (out?.reason !== "not-owned")
|
|
99
|
+
return `bkit worktrees remove failed (${out?.reason ?? `exit ${r.status}`})`;
|
|
100
|
+
// No workflow made it, so bkit leaves it; nothing in it is lost, so plain git removes it.
|
|
101
|
+
const g = spawnSync("git", ["-C", cwd, "worktree", "remove", wt], { encoding: "utf8" });
|
|
102
|
+
return g.status === 0 ? null : `git worktree remove failed: ${g.stderr.trim()}`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export default [
|
|
106
|
+
{
|
|
107
|
+
// Comes back: the next build re-runs the tasks it needs.
|
|
108
|
+
name: "Turborepo cache entries untouched for 7 days",
|
|
109
|
+
mode: "min",
|
|
110
|
+
paths: [".turbo/cache"],
|
|
111
|
+
skip: turboRunning,
|
|
112
|
+
run: "[ ! -d .turbo/cache ] || find .turbo/cache -type f -mtime +7 -delete",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
// Comes back: the next `next build` / `next dev`.
|
|
116
|
+
name: "Next.js cache entries untouched for 7 days",
|
|
117
|
+
mode: "min",
|
|
118
|
+
paths: ["apps/*/.next/cache"],
|
|
119
|
+
skip: nextRunning,
|
|
120
|
+
run: 'for d in apps/*/.next/cache; do [ ! -d "$d" ] || find "$d" -type f -mtime +7 -delete; done',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
// Comes back: the next build, slower once.
|
|
124
|
+
name: "All of the Turborepo cache",
|
|
125
|
+
mode: "max",
|
|
126
|
+
paths: [".turbo/cache"],
|
|
127
|
+
skip: turboRunning,
|
|
128
|
+
run: "rm -rf .turbo/cache",
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
// Comes back: the next web, Android or iOS build.
|
|
132
|
+
name: "Next.js caches and native build output",
|
|
133
|
+
mode: "max",
|
|
134
|
+
paths: ["apps/*/.next/cache", "apps/*/android/app/build", "apps/*/ios/build"],
|
|
135
|
+
skip: () =>
|
|
136
|
+
nextRunning() || (running("GradleDaemon|xcodebuild") && "a Gradle or Xcode build is running"),
|
|
137
|
+
run: "rm -rf apps/*/.next/cache apps/*/android/app/build apps/*/ios/build",
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
// Comes back: `bkit worktrees setup` re-creates a worktree from its branch, and
|
|
141
|
+
// reinstalls its node_modules. Removed only when nothing is lost: clean, and every commit
|
|
142
|
+
// on a remote or at the head of a merged pull request (`gh`). Ignored files (a copied
|
|
143
|
+
// `.env`) go with it; branches stay. Kept silently: a workflow's lock, a commit in the
|
|
144
|
+
// last 2 days. Anything else → a note `bkit tips` lists, for a person to decide.
|
|
145
|
+
name: "Leftover agent worktrees nothing would be lost from",
|
|
146
|
+
mode: "max",
|
|
147
|
+
paths: [".worktrees/*"],
|
|
148
|
+
run: ({ cwd, log, note }) => {
|
|
149
|
+
const root = path.join(cwd, ".worktrees");
|
|
150
|
+
if (!fs.existsSync(root)) return;
|
|
151
|
+
for (const fid of fs.readdirSync(root)) {
|
|
152
|
+
const wt = path.join(root, fid);
|
|
153
|
+
const v = judge(cwd, wt, fid);
|
|
154
|
+
if (v.keep) log(`kept .worktrees/${fid}: ${v.keep}`);
|
|
155
|
+
else if (v.note) note(`.worktrees/${fid}: ${v.note}`);
|
|
156
|
+
else {
|
|
157
|
+
const failed = removeWorktree(cwd, wt, fid);
|
|
158
|
+
if (failed === null) log(`.worktrees/${fid}: removed`);
|
|
159
|
+
else note(`.worktrees/${fid}: ${failed}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
];
|
|
@@ -133,10 +133,10 @@ def inside_callable(path, line):
|
|
|
133
133
|
|
|
134
134
|
|
|
135
135
|
# --- who imports this, transitively -------------------------------------------
|
|
136
|
-
# graph.json already carries the
|
|
136
|
+
# graph.json already carries the imports graphify cannot resolve — a `.js`
|
|
137
137
|
# specifier never reaching a `.tsx` file, and workspace subpaths through an
|
|
138
138
|
# `exports` map. bkit-graph-repair.py injects them during `pnpm graph`, so they are
|
|
139
|
-
# read here like any other edge; warns if
|
|
139
|
+
# read here like any other edge; warns if graph.json lacks any of them.
|
|
140
140
|
INBOUND = collections.defaultdict(set)
|
|
141
141
|
for link in raw["links"]:
|
|
142
142
|
if link.get("relation") not in DEP_RELATIONS:
|
|
@@ -8,13 +8,13 @@ Importable module, not a CLI — underscored so `import graph_imports` works fro
|
|
|
8
8
|
the sibling `graph-*.py` scripts, which are standalone and cannot be imported
|
|
9
9
|
themselves.
|
|
10
10
|
|
|
11
|
-
ONE WRITER. `bkit-graph-repair.py` is the only
|
|
12
|
-
|
|
11
|
+
ONE WRITER. `bkit-graph-repair.py` is the only script that writes
|
|
12
|
+
`resolved_import_edges()` into graph.json, during `pnpm graph`, so `graphify affected` /
|
|
13
13
|
`explain` / `path` / `query` see the same edges these scripts do. bkit-graph-eager.py
|
|
14
|
-
and bkit-graphify-rollup.py call `warn_if_unrepaired()
|
|
15
|
-
graph.
|
|
14
|
+
and bkit-graphify-rollup.py call `warn_if_unrepaired()`, which compares the same set
|
|
15
|
+
against graph.json, and otherwise just read the graph.
|
|
16
16
|
|
|
17
|
-
Two independent gaps
|
|
17
|
+
Two independent gaps.
|
|
18
18
|
|
|
19
19
|
── GAP 1: a `.js` specifier never resolves to a `.tsx` file ──────────────────
|
|
20
20
|
|
|
@@ -99,34 +99,57 @@ ALL_CONDITIONS = ("react-native", "default", "node", "import", "require")
|
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
REPAIR_ORIGIN = "graph-repair"
|
|
102
|
+
DEP_RELATIONS = {"imports", "imports_from", "re_exports", "dynamic_import"}
|
|
102
103
|
|
|
103
104
|
|
|
104
105
|
def repair_state(graph):
|
|
105
|
-
"""
|
|
106
|
+
"""Edges injected by bkit-graph-repair.py still in graph.json.
|
|
107
|
+
|
|
108
|
+
Counts the per-link `_origin`, the one repair mark that survives
|
|
109
|
+
`cluster-only` (it drops top-level keys it does not own). Zero does NOT mean
|
|
110
|
+
the repair never ran: when graphify already resolves every import there is
|
|
111
|
+
nothing to inject, and clustering merges an injected edge into graphify's own
|
|
112
|
+
when two files import each other. `missing_import_edges` answers that.
|
|
113
|
+
"""
|
|
114
|
+
return sum(1 for l in graph.get("links", ()) if l.get("_origin") == REPAIR_ORIGIN)
|
|
106
115
|
|
|
107
|
-
Consumers call this instead of re-deriving the edges themselves.
|
|
108
116
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
117
|
+
def missing_import_edges(graph):
|
|
118
|
+
"""Import pairs bkit-graph-repair.py adds that graph.json does not carry.
|
|
119
|
+
|
|
120
|
+
Reads source and compares; writes nothing. A pair counts as present in either
|
|
121
|
+
direction, because clustering keeps one link per file pair. Pairs with an
|
|
122
|
+
endpoint absent from the graph are left out, as the repair leaves them out.
|
|
112
123
|
"""
|
|
113
|
-
|
|
114
|
-
|
|
124
|
+
nodes = {n["id"]: n for n in graph.get("nodes", ())}
|
|
125
|
+
files = {str(n.get("source_file") or "") for n in nodes.values()
|
|
126
|
+
if n.get("source_location") == "L1"}
|
|
127
|
+
files.discard("")
|
|
128
|
+
present = set()
|
|
129
|
+
for l in graph.get("links", ()):
|
|
130
|
+
if l.get("relation") not in DEP_RELATIONS:
|
|
131
|
+
continue
|
|
132
|
+
a = str(nodes.get(l["source"], {}).get("source_file") or "")
|
|
133
|
+
b = str(nodes.get(l["target"], {}).get("source_file") or "")
|
|
134
|
+
present.add((a, b))
|
|
135
|
+
present.add((b, a))
|
|
136
|
+
return {(src, dst) for src, dst in resolved_import_edges()
|
|
137
|
+
if src in files and dst in files and (src, dst) not in present}
|
|
115
138
|
|
|
116
139
|
|
|
117
140
|
def warn_if_unrepaired(graph, who, stream=None):
|
|
118
|
-
"""Print a loud warning when graph.json
|
|
141
|
+
"""Print a loud warning when graph.json lacks imports bkit-graph-repair.py adds.
|
|
119
142
|
|
|
120
|
-
Warns only; never repairs on read.
|
|
143
|
+
Warns only; never repairs on read. Returns the count of injected edges.
|
|
121
144
|
"""
|
|
122
145
|
import sys as _sys
|
|
123
|
-
|
|
124
|
-
if
|
|
125
|
-
print(f"[{who}] WARNING: graph.json
|
|
126
|
-
f"
|
|
127
|
-
f"
|
|
146
|
+
missing = missing_import_edges(graph)
|
|
147
|
+
if missing:
|
|
148
|
+
print(f"[{who}] WARNING: graph.json lacks {len(missing)} imports that "
|
|
149
|
+
f"bkit-graph-repair.py adds, so reachability and blast-radius numbers "
|
|
150
|
+
f"below are UNDERSTATED. Run 'pnpm graph:update'.",
|
|
128
151
|
file=stream or _sys.stderr)
|
|
129
|
-
return
|
|
152
|
+
return repair_state(graph)
|
|
130
153
|
|
|
131
154
|
|
|
132
155
|
def _strip_output_ext(path):
|
|
@@ -2,18 +2,40 @@
|
|
|
2
2
|
# Example. Paste at the end of your .husky/pre-push, below the bkit lines, and own it.
|
|
3
3
|
# bkit install does not write this file and does not overwrite a copy.
|
|
4
4
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
5
|
+
# Capability register current on dev. BLOCKS a push to dev when docs/capabilities.md is not
|
|
6
|
+
# what the pushed commit builds. Reads PUSH_DEV_SHA (commit pushed to dev), set by the bkit
|
|
7
|
+
# pre-push template while reading git's ref list on stdin; stdin is consumed by now.
|
|
8
|
+
#
|
|
9
|
+
# graphify reads the working tree → check runs in a throwaway checkout of the pushed commit
|
|
10
|
+
# (`check-at`): uncommitted edits, a concurrent session's included, cannot change the answer.
|
|
11
|
+
# Other graphify release → blocked, with the install command. graphify NOT INSTALLED → warn
|
|
12
|
+
# only, saying the check did not run: a cloud session without it must still push; CI's Check
|
|
13
|
+
# Capability Register runs the same check on every push to dev. Revert pushes (IS_REVERT=1)
|
|
14
|
+
# skip it, as they skip the test tiers. Other branches → warn-only staleness note.
|
|
8
15
|
CAP_DOC="docs/capabilities.md"
|
|
9
|
-
if [ -f "$CAP_DOC" ]; then
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
echo "[pre-push]
|
|
15
|
-
echo "[pre-push]
|
|
16
|
-
|
|
16
|
+
if [ -f scripts/graphify/bkit-graphify.sh ] && [ -f "$CAP_DOC" ]; then
|
|
17
|
+
if [ -n "${PUSH_DEV_SHA:-}" ] && [ "${IS_REVERT:-0}" != "1" ]; then
|
|
18
|
+
if ! command -v graphify >/dev/null 2>&1; then
|
|
19
|
+
echo "[pre-push] WARNING: $CAP_DOC was NOT checked — graphify is not installed." >&2
|
|
20
|
+
echo "[pre-push] CI's Check Capability Register checks it on this push; if it reds there, run" >&2
|
|
21
|
+
echo "[pre-push] pnpm graph:refresh, commit, and push again. Install graphify to check before pushing:" >&2
|
|
22
|
+
echo "[pre-push] brew install uv && uv tool install '$(bash scripts/graphify/bkit-graphify.sh spec)'" >&2
|
|
23
|
+
elif ! bash scripts/graphify/bkit-graphify.sh check-at "$PUSH_DEV_SHA" < /dev/null; then
|
|
24
|
+
echo "[pre-push] BLOCKED: $CAP_DOC is not what the pushed commit builds (diff above)." >&2
|
|
25
|
+
echo "[pre-push] Fix: pnpm graph:refresh && git add $CAP_DOC && git commit, then push again." >&2
|
|
26
|
+
exit 1
|
|
27
|
+
fi
|
|
28
|
+
else
|
|
29
|
+
# Warn-only. A fresh register is stamped at the parent of its commit → staleness =
|
|
30
|
+
# source files changed since that stamp.
|
|
31
|
+
CAP_SHA=$(sed -n 's/.*Diagrams from `graph\.json` @ `\([0-9a-f]\{7,\}\)`.*/\1/p' "$CAP_DOC" | head -1)
|
|
32
|
+
if [ -n "$CAP_SHA" ] && git cat-file -e "$CAP_SHA^{commit}" 2>/dev/null; then
|
|
33
|
+
CAP_CHANGED=$(git diff --name-only "$CAP_SHA..HEAD" -- '*.ts' '*.tsx' 2>/dev/null | wc -l | tr -d ' ')
|
|
34
|
+
if [ "${CAP_CHANGED:-0}" -gt 0 ]; then
|
|
35
|
+
echo "[pre-push] NOTE: $CAP_DOC diagrams were built at $CAP_SHA; $CAP_CHANGED source files changed since." >&2
|
|
36
|
+
echo "[pre-push] Refresh when convenient: pnpm graph:refresh" >&2
|
|
37
|
+
echo "[pre-push] Not a gate on this branch. A push to dev is blocked until it is current." >&2
|
|
38
|
+
fi
|
|
17
39
|
fi
|
|
18
40
|
fi
|
|
19
41
|
fi
|
|
@@ -102,8 +102,9 @@ graph["links"].extend(added)
|
|
|
102
102
|
# NO top-level marker: a `graph["import_repair"] = {...}` key does not survive
|
|
103
103
|
# `cluster-only`, which rewrites graph.json and keeps only the keys it writes
|
|
104
104
|
# itself (`built_at_commit` survives because graphify sets it). The per-link
|
|
105
|
-
# `_origin` DOES survive,
|
|
106
|
-
# — see warn_if_unrepaired /
|
|
105
|
+
# `_origin` DOES survive, but a zero count is no proof the step was skipped, so
|
|
106
|
+
# readers compare against source instead — see warn_if_unrepaired /
|
|
107
|
+
# missing_import_edges in bkit-graph-imports.py.
|
|
107
108
|
|
|
108
109
|
tmp = args.graph_json + ".repair.tmp"
|
|
109
110
|
with open(tmp, "w", encoding="utf-8") as fh:
|
|
@@ -58,10 +58,10 @@ SRC = (".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".sql")
|
|
|
58
58
|
|
|
59
59
|
# graphify misses two whole classes of import: a `.js` specifier is never
|
|
60
60
|
# resolved to a `.tsx` file, and workspace subpaths through an `exports` map are
|
|
61
|
-
# not resolved at all.
|
|
62
|
-
#
|
|
63
|
-
#
|
|
64
|
-
#
|
|
61
|
+
# not resolved at all. bkit-graph-repair.py writes them into graph.json during
|
|
62
|
+
# `pnpm graph`, so this reads them like any other edge and does NOT add them on
|
|
63
|
+
# read. A graph lacking any of them gets a warning, and the numbers below are
|
|
64
|
+
# understated.
|
|
65
65
|
# bkit-graph-imports.py is hyphenated, which `import` cannot spell, so it is loaded
|
|
66
66
|
# by path.
|
|
67
67
|
import importlib.util as _ilu
|
|
@@ -760,7 +760,7 @@ def as_capabilities_doc(out, min_weight, overlay, rows, rules_path, surface, ov_
|
|
|
760
760
|
">",
|
|
761
761
|
"> **Rules:**",
|
|
762
762
|
">",
|
|
763
|
-
"> - Generated — do not edit. `pnpm graph:
|
|
763
|
+
"> - Generated — do not edit. `pnpm graph:refresh` rewrites this file.",
|
|
764
764
|
f"> - Source of truth: `{rules_path}`. Every status derived from live source, never typed.",
|
|
765
765
|
"> - Add a capability = add a rule there: capability · lane · owner module · one literal marker.",
|
|
766
766
|
"> - Markers literal, never regex, because `new Ratelimit(` as a regex is an unclosed group matching nothing.",
|