@cbartens/bkit 5.0.3 → 5.2.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.
Files changed (212) hide show
  1. package/.bkit/README.md +14 -10
  2. package/.bkit/core/.agents/docs.md +1 -0
  3. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-gateguard.cjs +93 -0
  4. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +137 -0
  5. package/.bkit/core/.agents/plugins/bkit/hooks/bkit-readguard.cjs +72 -0
  6. package/.bkit/core/.agents/rules.md +10 -6
  7. package/.bkit/core/.agents/shortcuts.md +73 -0
  8. package/.bkit/core/.agents/skills.md +5 -3
  9. package/.bkit/core/.bkit/LICENSE.md +18 -140
  10. package/.bkit/core/.bkit/README.md +13 -9
  11. package/.bkit/core/.bkit/cloud.md +12 -15
  12. package/.bkit/core/.bkit/comparison.md +68 -16
  13. package/.bkit/core/.bkit/install.md +36 -11
  14. package/.bkit/core/.bkit/jsonl.md +0 -1
  15. package/.bkit/core/.bkit/prompts.md +83 -81
  16. package/.bkit/core/.bkit/providers.md +110 -28
  17. package/.bkit/core/.bkit/templates.md +42 -13
  18. package/.bkit/core/.bkit/workflows.md +64 -42
  19. package/.bkit/core/.claude/hooks/bkit-gateguard.cjs +4 -3
  20. package/.bkit/core/.claude/hooks/bkit-readguard.cjs +60 -0
  21. package/.bkit/core/.codex/hooks/bkit-gateguard.cjs +8 -6
  22. package/.bkit/core/.codex/hooks/bkit-readguard.cjs +58 -0
  23. package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +12 -19
  24. package/.bkit/core/.cursor/hooks/bkit-readguard.cjs +59 -0
  25. package/.bkit/core/.opencode/plugin/bkit-gateguard.js +73 -22
  26. package/.bkit/core/.opencode/plugin/bkit-readguard.js +126 -0
  27. package/.bkit/core/AGENTS.md +11 -0
  28. package/.bkit/core/docs/templates/bkit-audit-adoption.md +2 -2
  29. package/.bkit/core/docs/templates/bkit-plan.md +6 -3
  30. package/.bkit/core/engine/checks/after/auth.ts +32 -0
  31. package/.bkit/core/engine/checks/after/github.ts +4 -4
  32. package/.bkit/core/engine/checks/after/index.ts +36 -50
  33. package/.bkit/core/engine/checks/after/managed.ts +44 -1
  34. package/.bkit/core/engine/checks/before/index.ts +5 -4
  35. package/.bkit/core/engine/checks/before/mcp.ts +60 -54
  36. package/.bkit/core/engine/checks/status-holes.ts +1 -1
  37. package/.bkit/core/engine/checks/tips/catalogue.ts +356 -0
  38. package/.bkit/core/engine/checks/tips/detect.ts +144 -0
  39. package/.bkit/core/engine/checks/tips/index.ts +174 -0
  40. package/.bkit/core/engine/cli.ts +82 -18
  41. package/.bkit/core/engine/commands/install/check.ts +2 -0
  42. package/.bkit/core/engine/commands/install/doctor.ts +14 -1
  43. package/.bkit/core/engine/commands/install/install.ts +59 -9
  44. package/.bkit/core/engine/commands/install/uninstall.ts +59 -34
  45. package/.bkit/core/engine/commands/install/upgrade.ts +30 -28
  46. package/.bkit/core/engine/commands/launch.ts +33 -11
  47. package/.bkit/core/engine/commands/tips.ts +16 -0
  48. package/.bkit/core/engine/commands/workflow/prs.ts +20 -2
  49. package/.bkit/core/engine/commands/workflow/runs.ts +82 -18
  50. package/.bkit/core/engine/commands/workflow/runtime.ts +12 -0
  51. package/.bkit/core/engine/commands/workflow/steps.ts +1 -0
  52. package/.bkit/core/engine/commands/workflow/tests.ts +647 -4
  53. package/.bkit/core/engine/commands/workflow/workstreams.ts +4 -4
  54. package/.bkit/core/engine/install/cloud-env.ts +7 -21
  55. package/.bkit/core/engine/install/hosts.ts +21 -0
  56. package/.bkit/core/engine/install/managed-block.ts +36 -0
  57. package/.bkit/core/engine/install/manifest.ts +83 -5
  58. package/.bkit/core/engine/install/modules/antigravity.ts +266 -0
  59. package/.bkit/core/engine/install/modules/claude.ts +6 -6
  60. package/.bkit/core/engine/install/modules/cloud.ts +2 -2
  61. package/.bkit/core/engine/install/modules/codex.ts +8 -5
  62. package/.bkit/core/engine/install/modules/core.ts +30 -10
  63. package/.bkit/core/engine/install/modules/cursor.ts +6 -6
  64. package/.bkit/core/engine/install/modules/index.ts +33 -6
  65. package/.bkit/core/engine/install/modules/opencode.ts +4 -4
  66. package/.bkit/core/engine/install/payload-links.ts +6 -10
  67. package/.bkit/core/engine/install/placeholders.ts +1 -1
  68. package/.bkit/core/engine/install/version-file.ts +17 -9
  69. package/.bkit/core/engine/install/write.ts +68 -1
  70. package/.bkit/core/engine/ledgers/telemetry.ts +0 -2
  71. package/.bkit/core/engine/render/hosts.ts +174 -1
  72. package/.bkit/core/engine/render/models.ts +10 -0
  73. package/.bkit/core/engine/shared/package-roots.ts +8 -10
  74. package/.bkit/core/hooks/antigravity-hook.js +67 -0
  75. package/.bkit/core/hooks/gateguard-edit-payload.js +4 -4
  76. package/.bkit/core/hooks/gateguard-engine.js +16 -6
  77. package/.bkit/core/hooks/guardrails-read.js +23 -0
  78. package/.bkit/core/hooks/readguard-engine.js +259 -0
  79. package/.bkit/core/hooks/readguard-payload.js +67 -0
  80. package/.bkit/core/prompts/bkit-audit-generate.md +2 -1
  81. package/.bkit/core/prompts/bkit-build-challenge-1.md +2 -1
  82. package/.bkit/core/prompts/bkit-build-challenge-2.md +2 -1
  83. package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +2 -1
  84. package/.bkit/core/prompts/bkit-build-challenge-remediate.md +2 -1
  85. package/.bkit/core/prompts/bkit-build-challenge-tests.md +2 -1
  86. package/.bkit/core/prompts/bkit-build-install-skills.md +7 -5
  87. package/.bkit/core/prompts/bkit-build-plan-current.md +2 -1
  88. package/.bkit/core/prompts/bkit-build-plan-execute.md +6 -2
  89. package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +2 -1
  90. package/.bkit/core/prompts/bkit-build-plan-verify.md +12 -4
  91. package/.bkit/core/prompts/bkit-build-summary.md +2 -1
  92. package/.bkit/core/prompts/bkit-debug-abort-handover.md +2 -1
  93. package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +2 -1
  94. package/.bkit/core/prompts/bkit-debug-failure-remediate.md +2 -1
  95. package/.bkit/core/prompts/bkit-debug-failure-soak.md +2 -1
  96. package/.bkit/core/prompts/bkit-debug-summary.md +2 -1
  97. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +2 -1
  98. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +2 -1
  99. package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +2 -1
  100. package/.bkit/core/prompts/bkit-design-generate.md +10 -5
  101. package/.bkit/core/prompts/bkit-design-organise.md +2 -1
  102. package/.bkit/core/prompts/bkit-design-review-1.md +2 -1
  103. package/.bkit/core/prompts/bkit-design-review-2.md +2 -1
  104. package/.bkit/core/prompts/bkit-design-spike.md +2 -1
  105. package/.bkit/core/prompts/bkit-design-summary.md +2 -1
  106. package/.bkit/core/prompts/bkit-design-update.md +2 -1
  107. package/.bkit/core/prompts/bkit-plan-complexity-check.md +2 -1
  108. package/.bkit/core/prompts/bkit-plan-complexity-split.md +4 -3
  109. package/.bkit/core/prompts/bkit-plan-generate.md +2 -1
  110. package/.bkit/core/prompts/bkit-plan-review-1.md +2 -1
  111. package/.bkit/core/prompts/bkit-plan-review-2.md +2 -1
  112. package/.bkit/core/prompts/bkit-plan-review-3.md +2 -1
  113. package/.bkit/core/prompts/bkit-plan-scope-check-1.md +3 -2
  114. package/.bkit/core/prompts/bkit-plan-scope-check-2.md +3 -2
  115. package/.bkit/core/prompts/bkit-plan-summary.md +2 -1
  116. package/.bkit/core/prompts/bkit-plan-update.md +3 -2
  117. package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +2 -1
  118. package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +2 -1
  119. package/.bkit/core/prompts/bkit-ship-summary.md +2 -1
  120. package/.bkit/core/prompts/bkit-ship-update-docs.md +2 -1
  121. package/.bkit/core/prompts/bkit-utility-compress-markdown.md +2 -1
  122. package/.bkit/core/prompts/bkit-utility-update-decisions.md +2 -1
  123. package/.bkit/core/prompts/bkit-utility-update-deferrals.md +2 -1
  124. package/.bkit/core/prompts/bkit-utility-update-documentation.md +2 -1
  125. package/.bkit/core/prompts/bkit-utility-update-failures.md +2 -1
  126. package/.bkit/core/prompts/bkit-utility-update-knowledge.md +2 -1
  127. package/.bkit/core/prompts/bkit-utility-update-roadmap.md +4 -3
  128. package/.bkit/core/workflows/bkit-auto.md +1 -1
  129. package/.bkit/core/workflows/bkit-build.md +35 -21
  130. package/.bkit/core/workflows/bkit-debug.md +31 -22
  131. package/.bkit/core/workflows/bkit-design.md +83 -38
  132. package/.bkit/core/workflows/bkit-plan.md +10 -2
  133. package/.bkit/core/workflows/bkit-ship.md +10 -2
  134. package/.bkit/shared/.agents/plugins/bkit/hooks.json +36 -0
  135. package/.bkit/shared/.agents/plugins/bkit/plugin.json +5 -0
  136. package/.bkit/shared/.claude/settings.json +19 -0
  137. package/.bkit/shared/.codex/hooks.json +21 -0
  138. package/.bkit/shared/.cursor/hooks.json +6 -1
  139. package/.bkit/shared/.opencode/opencode.json +1 -1
  140. package/.bkit/shared/GEMINI.md +11 -0
  141. package/.bkit/shared/docs/deployments.md +1 -1
  142. package/.bkit/shared/docs/security.md +3 -3
  143. package/.bkit/shared/docs/testing.md +12 -1
  144. package/.bkit/templates/.github/dependabot.yml +6 -0
  145. package/.bkit/templates/.github/renovate.json5 +3 -3
  146. package/.bkit/templates/.github/workflows/bkit-ci.yml +24 -13
  147. package/.bkit/templates/.github/workflows/bkit-cloud.yml +5 -5
  148. package/.bkit/templates/.prettierignore +4 -1
  149. package/.bkit/templates/context/bkit-expo.md +22 -13
  150. package/.bkit/templates/context/bkit-github.md +20 -6
  151. package/.bkit/templates/context/bkit-inngest.md +10 -4
  152. package/.bkit/templates/context/bkit-maestro.md +5 -5
  153. package/.bkit/templates/context/bkit-playwright.md +3 -3
  154. package/.bkit/templates/context/bkit-sentry.md +6 -5
  155. package/.bkit/templates/context/bkit-stripe.md +31 -8
  156. package/.bkit/templates/scripts/ci/check-accepted-divergences.mjs +65 -19
  157. package/.bkit/templates/scripts/ci/check-accepted-divergences.test.mjs +34 -0
  158. package/.bkit/templates/scripts/ci/lanes/resolve-push-base.mjs +33 -12
  159. package/.bkit/templates/scripts/ci/lanes/resolve-push-base.test.mjs +54 -0
  160. package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +2 -2
  161. package/.bkit/templates/scripts/launchd/bkit-launchd-env.sh +76 -6
  162. package/.bkit/templates/slop-scan.config.json +10 -3
  163. package/CHANGELOG.md +62 -0
  164. package/LICENSE.md +21 -161
  165. package/README.md +66 -35
  166. package/dist/checks/after/auth.js +28 -0
  167. package/dist/checks/after/github.js +4 -4
  168. package/dist/checks/after/index.js +29 -45
  169. package/dist/checks/after/managed.js +41 -1
  170. package/dist/checks/before/index.js +5 -4
  171. package/dist/checks/before/mcp.js +53 -53
  172. package/dist/checks/status-holes.js +1 -1
  173. package/dist/checks/tips/catalogue.js +297 -0
  174. package/dist/checks/tips/detect.js +130 -0
  175. package/dist/checks/tips/index.js +146 -0
  176. package/dist/cli.js +68 -17
  177. package/dist/commands/install/check.js +2 -0
  178. package/dist/commands/install/doctor.js +9 -1
  179. package/dist/commands/install/install.js +49 -8
  180. package/dist/commands/install/uninstall.js +61 -34
  181. package/dist/commands/install/upgrade.js +31 -33
  182. package/dist/commands/launch.js +27 -11
  183. package/dist/commands/tips.js +10 -0
  184. package/dist/commands/workflow/prs.js +13 -1
  185. package/dist/commands/workflow/runs.js +74 -18
  186. package/dist/commands/workflow/runtime.js +8 -0
  187. package/dist/commands/workflow/steps.js +1 -0
  188. package/dist/commands/workflow/tests.js +541 -4
  189. package/dist/commands/workflow/workstreams.js +4 -4
  190. package/dist/install/cloud-env.js +3 -14
  191. package/dist/install/hosts.js +22 -0
  192. package/dist/install/managed-block.js +36 -0
  193. package/dist/install/manifest.js +79 -4
  194. package/dist/install/modules/antigravity.js +225 -0
  195. package/dist/install/modules/claude.js +6 -6
  196. package/dist/install/modules/cloud.js +2 -2
  197. package/dist/install/modules/codex.js +8 -5
  198. package/dist/install/modules/core.js +21 -6
  199. package/dist/install/modules/cursor.js +6 -6
  200. package/dist/install/modules/index.js +17 -6
  201. package/dist/install/modules/opencode.js +4 -4
  202. package/dist/install/payload-links.js +5 -5
  203. package/dist/install/placeholders.js +1 -1
  204. package/dist/install/version-file.js +12 -3
  205. package/dist/install/write.js +61 -2
  206. package/dist/render/hosts.js +149 -1
  207. package/dist/render/models.js +9 -0
  208. package/dist/shared/package-roots.js +8 -11
  209. package/package.json +8 -8
  210. package/.bkit/core/LICENSE.md +0 -149
  211. package/.bkit/shared/LICENSE.md +0 -22
  212. package/.bkit/templates/LICENSE.md +0 -22
@@ -282,23 +282,34 @@ jobs:
282
282
  done
283
283
  "$RUNNER_TEMP/actionlint" -color
284
284
 
285
- # bkit >= 5.0.1 gitignores `.bkit/core` + `.bkit/shared` (browse-only symlinks into
286
- # node_modules/@cbartens/bkit) yet `bkit check` counts a missing link as drift, so a
287
- # fresh checkout that never runs `bkit install` can never pass the gate below.
288
- # Recreate them exactly as install/upgrade does: relative targets, never clobber.
289
- - name: Materialize bkit Payload View Links
290
- if: steps.cache.outputs.skip != 'true'
291
- run: |
292
- for rel in core shared; do
293
- if [ ! -L ".bkit/$rel" ] && [ ! -e ".bkit/$rel" ]; then
294
- ln -s "../node_modules/@cbartens/bkit/.bkit/$rel" ".bkit/$rel"
295
- fi
296
- done
297
-
298
285
  - name: Run bkit Check
299
286
  if: steps.cache.outputs.skip != 'true'
300
287
  run: pnpm bkit check
301
288
 
289
+ # Capability-register freshness gate: rebuild the graph with graphify and fail when
290
+ # docs/capabilities.md is not what this tree produces, so the register cannot drift
291
+ # silently. Self-skips when the graphify wrapper is absent — a repo that did not adopt
292
+ # scripts/graphify/ is a no-op. graphify is pinned because its output must match the
293
+ # committed register to the byte: bump GRAPHIFY_SPEC and refresh the register together.
294
+ # Push events only — a pull_request checkout is the MERGE ref, whose tree (base + head)
295
+ # can differ from the head the register was built against: a false red no author can clear.
296
+ - name: Setup uv
297
+ if: steps.cache.outputs.skip != 'true' && github.event_name == 'push' && hashFiles('scripts/graphify/bkit-graphify.sh') != ''
298
+ uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
299
+ with:
300
+ version: "0.12.6"
301
+
302
+ - name: Check Capability Register
303
+ if: steps.cache.outputs.skip != 'true' && github.event_name == 'push' && hashFiles('scripts/graphify/bkit-graphify.sh') != ''
304
+ env:
305
+ # PyPI distribution is `graphifyy`; the CLI it exposes is `graphify`.
306
+ GRAPHIFY_SPEC: "graphifyy[sql]==0.9.50"
307
+ run: |
308
+ uv tool install "$GRAPHIFY_SPEC"
309
+ # `uv tool install` drops the shim in ~/.local/bin, not on this step's PATH.
310
+ export PATH="$HOME/.local/bin:$PATH"
311
+ pnpm graph:check
312
+
302
313
  # ── bkit-tests-unit ───────────────────────────────────────────────────────
303
314
  # Unit lane. Parallel sibling of bkit-tests-static. Integration, E2E, deploy-await,
304
315
  # and remote db push move out of this job when you adopt the scaffold below.
@@ -18,8 +18,9 @@ name: bkit-cloud
18
18
  # - workflow_run (CI completion on dev): success -> no-op (regression check passed),
19
19
  # failure -> /bkit-debug {FID} (FID recovered from squash-merge commit scope;
20
20
  # loop-bounded by MAX_DEV_DISPATCH_ATTEMPTS). [skip ci] close commits never trigger CI.
21
- # - workflow_dispatch: pick ANY phase (ship|debug|design|plan|build) for an issue.
22
- # design/plan/build have no tracker-event trigger; they run only via dispatch.
21
+ # - workflow_dispatch: pick ANY phase (ship|debug|plan|build) for an issue.
22
+ # plan/build have no tracker-event trigger; they run only via dispatch.
23
+ # design is not offered: its Grill step interviews a human, so it runs locally only.
23
24
  #
24
25
  # Required secrets (claude job): ANTHROPIC_API_KEY + Claude GitHub App (one-time
25
26
  # `/install-github-app` — grants `id-token: write` OIDC for claude-code-action@v1).
@@ -42,7 +43,6 @@ on:
42
43
  options:
43
44
  - ship
44
45
  - debug
45
- - design
46
46
  - plan
47
47
  - build
48
48
  issue:
@@ -465,7 +465,7 @@ jobs:
465
465
  # `cloud` run to dev's `status.jsonl`, and the dispatched phase skill creates its
466
466
  # own `feat/{FID}` worktree under `.worktrees/`. ship/debug then read+write
467
467
  # their branch-local `status.jsonl` on `feat/{FID}` (worktree-prefer at Step 1);
468
- # design/plan/build start from dev. NDJSON + `*.jsonl merge=union` keeps it merge-safe.
468
+ # plan/build start from dev. NDJSON + `*.jsonl merge=union` keeps it merge-safe.
469
469
  ref: dev
470
470
  fetch-depth: 0
471
471
  # The auto-provided GITHUB_TOKEN inherits the `permissions:` block above.
@@ -493,7 +493,7 @@ jobs:
493
493
  uses: anthropics/claude-code-action@58985842b834ed26087302ba27d07bc24ca8697a # v1.0.244
494
494
  with:
495
495
  # Orchestrator contract: `/bkit-auto <phase> <arg>` where <arg> is the open
496
- # PR number (ship/debug) or the tracker issue number/id (design/plan/build).
496
+ # PR number (ship/debug) or the tracker issue number/id (plan/build).
497
497
  # The context job validated arg against its allowlist.
498
498
  prompt: "/bkit-auto ${{ needs.context.outputs.phase }} ${{ needs.context.outputs.arg }}"
499
499
  # Lock the runner-side session to the same tool surface bkit grants the local
@@ -4,7 +4,10 @@
4
4
  node_modules/
5
5
  dist/
6
6
  .agents/skills/
7
- # Canonical-overwrite content (CANONICAL_OVERWRITE_RELPATHS in bkit's install engine):
7
+ # Antigravity host installs as a workspace plugin; its skills/agents/hooks are
8
+ # force-overwritten renders like the other host mirrors below.
9
+ .agents/plugins/bkit/
10
+ # Canonical-overwrite content (byte-equal-text and markered-text entries of `getInstallManifest` in .bkit/core/engine/install/manifest.ts):
8
11
  # bkit force-overwrites these on every install, so consumer prettier must not
9
12
  # lint them. Width-sensitive rewrites would be reverted next install. The
10
13
  # .opencode agent + command mirrors are force-overwritten just like .claude /
@@ -6,7 +6,7 @@
6
6
  Fits: React Native / Expo apps on EAS. `context=runtime` (`expo` block): recent EAS Build status (id, platform, status, profile, commit, error), then the error-level lines of the latest errored builds' logs. `context=e2e` (`expo-workflows` block): for the latest failed EAS Workflow runs (`eas workflow:run`, Maestro) — job status and errors, step-log tails, the per-flow exception for every flow and retry (EAS GraphQL), JUnit, failure screenshot URLs, and from `artifacts.tar.gz` the failing Maestro commands, the view-hierarchy dump list, per-attempt JUnit, the XCUITest runner's own errors and the app's JS console. EAS drains build failures and Workflow runs nowhere else — no host log, no error tracker — so this is the only place they surface.
7
7
 
8
8
  - Secret: `EXPO_TOKEN` (an EAS access token), in the app's env (e.g. `apps/mobile/.env.local`), not `.bkit/.env`.
9
- - Non-secret: `EXPO_APP_DIR` (the EAS-linked app folder, default `apps/mobile`), both blocks; `expo`: `EAS_PLATFORM`, `EAS_N`, `EAS_ERR_N`; `expo-workflows`: `EAS_WF_N`, `EAS_WF_ERR_N`.
9
+ - Non-secret: `EXPO_APP_DIR` (the EAS-linked app folder, default `apps/mobile`), both blocks; `expo`: `EAS_PLATFORM`, `EAS_PROFILE`, `EAS_N`, `EAS_ERR_N`, `EAS_LOG_N`; `expo-workflows`: `EAS_WF_FILE`, `EAS_WF_N`, `EAS_WF_ERR_N`, `EAS_JUNIT_N`.
10
10
  - CLI: `eas` (`eas-cli`); each block's same-named provision block installs it in cloud, self-guarded, so copying both installs once. `expo` also uses `node` to decompress logs.
11
11
  - Domains: `expo.dev` (both), `googleapis.com` (`expo`), `eascdn.net` (`expo-workflows`); each section carries its own `allowed-domains` block.
12
12
  - `expo`: build logs are pre-signed, brotli-encoded storage URLs valid ~15 min; macOS curl has no brotli, so the block decompresses with Node zlib and filters the JSON lines with `jq`.
@@ -24,7 +24,7 @@ Copy the blocks below into `.agents/context.md`, below `<!-- bkit:end -->`. The
24
24
  # Expo EAS native build status + errored-build logs (read-only).
25
25
  # EXPO_TOKEN is an app/stack cred (it builds and ships the native apps) — app env, not .bkit/.env.
26
26
  # Run `eas` from the EAS-linked app folder: from anywhere else it writes a stub app.json there.
27
- # Customise: EXPO_APP_DIR; EAS_PLATFORM (android|ios|all); EAS_N (<= 50); EAS_ERR_N; the log-line filter.
27
+ # Customise: EXPO_APP_DIR; EAS_PLATFORM (android|ios|all); EAS_PROFILE (build profile, e.g. preview / production); EAS_N (<= 50); EAS_ERR_N; EAS_LOG_N (log lines per build); the log-line filter.
28
28
  EXPO_APP_DIR="${EXPO_APP_DIR:-apps/mobile}"
29
29
  command -v eas >/dev/null && [ -n "${EXPO_TOKEN:-}" ] \
30
30
  || { echo "[context-fetch:expo] skipped — eas CLI / EXPO_TOKEN missing" >&2; exit 0; }
@@ -34,18 +34,21 @@ cd "$EXPO_APP_DIR" || exit 0
34
34
  # 1) Recent build status. --status new|in-queue|in-progress|pending-cancel|errored|finished|canceled.
35
35
  eas build:list \
36
36
  --platform "${EAS_PLATFORM:-all}" \
37
+ ${EAS_PROFILE:+--build-profile "$EAS_PROFILE"} \
37
38
  --limit "${EAS_N:-10}" \
38
39
  --json --non-interactive \
39
40
  | jq -c '.[] | {id, platform, status, createdAt, buildProfile, gitCommitHash, error}' # gitCommitHash stitches to the CI run
40
41
  # 2) LOGS for recent failures. No `eas build:logs`; build:view exposes `logFiles`: pre-signed
41
42
  # URLs (signature in the query string, no auth header), valid ~900s, BROTLI-encoded JSON lines.
42
43
  # An install-dependencies failure (e.g. a private-registry 401) shows here.
43
- for id in $(eas build:list --status errored --limit "${EAS_ERR_N:-2}" --json --non-interactive | jq -r '.[].id'); do
44
+ for id in $(eas build:list --status errored --platform "${EAS_PLATFORM:-all}" ${EAS_PROFILE:+--build-profile "$EAS_PROFILE"} \
45
+ --limit "${EAS_ERR_N:-2}" --json --non-interactive | jq -r '.[].id'); do
44
46
  echo "===== errored build $id ====="
45
47
  eas build:view "$id" --json | jq -r '.logFiles[]?' | while read -r u; do
46
48
  curl -sS "$u" \
47
49
  | node -e "const z=require('zlib'),c=[];process.stdin.on('data',d=>c.push(d)).on('end',()=>{try{process.stdout.write(z.brotliDecompressSync(Buffer.concat(c)))}catch(e){process.stderr.write('[context-fetch:expo] log not brotli — encoding may have changed\n')}})" \
48
- | jq -rc 'select(.level>=40 or ((.msg//"") | test("ERR_|✗|error"))) | {phase, msg: (.msg // .err.message)}'
50
+ | jq -rc 'select(.level>=40 or ((.msg//"") | test("ERR_|✗|error"))) | {phase, msg: (.msg // .err.message)}' \
51
+ | tail -n "${EAS_LOG_N:-80}"
49
52
  done
50
53
  done
51
54
  ```
@@ -75,7 +78,7 @@ googleapis.com
75
78
  ```bash
76
79
  # EAS WORKFLOW runs — the native e2e (Maestro) lane (read-only). SEPARATE from the expo block:
77
80
  # that one covers `eas build`, this one covers `eas workflow:run`.
78
- # Customise: EXPO_APP_DIR; EAS_WF_N; EAS_WF_ERR_N; which artifacts to inline; the log greps.
81
+ # Customise: EXPO_APP_DIR; EAS_WF_FILE (e2e workflow file; unset = all); EAS_WF_N; EAS_WF_ERR_N; EAS_JUNIT_N (lines per JUnit file); which artifacts to inline; the log greps.
79
82
  EXPO_APP_DIR="${EXPO_APP_DIR:-apps/mobile}"
80
83
  command -v eas >/dev/null && [ -n "${EXPO_TOKEN:-}" ] \
81
84
  || { echo "[context-fetch:expo-workflows] skipped — eas CLI / EXPO_TOKEN missing" >&2; exit 0; }
@@ -87,18 +90,21 @@ trap 'rm -rf "$WORK"' EXIT
87
90
  # 1) Recent workflow runs, newest first. `workflow:runs` does NOT accept --non-interactive
88
91
  # (unlike its sibling commands): passing it errors out with no output, which reads exactly
89
92
  # like "no runs found". Its flags are only --json --limit --status --workflow.
90
- eas workflow:runs --json --limit "${EAS_WF_N:-10}" 2>/dev/null \
93
+ eas workflow:runs --json ${EAS_WF_FILE:+--workflow "$EAS_WF_FILE"} --limit "${EAS_WF_N:-10}" 2>/dev/null \
91
94
  | jq -c '.[]? | {id, status, gitCommitHash, createdAt}'
92
95
  # 2) Per-run detail. `workflow:status` is the only command that yields BOTH job ids and artifact URLs.
93
- for run in $(eas workflow:runs --json --status FAILURE --limit "${EAS_WF_ERR_N:-2}" 2>/dev/null \
94
- | jq -r '.[]?.id'); do
96
+ for run in $(eas workflow:runs --json ${EAS_WF_FILE:+--workflow "$EAS_WF_FILE"} --status FAILURE \
97
+ --limit "${EAS_WF_ERR_N:-2}" 2>/dev/null | jq -r '.[]?.id'); do
95
98
  echo "===== failed workflow run $run ====="
96
99
  STATUS="$WORK/status-$run.json"
97
- eas workflow:status "$run" --json --non-interactive > "$STATUS" 2>/dev/null || continue
100
+ # `workflow:status` exits 11 on a FAILED run after printing its JSON: test the output, not the exit code.
101
+ eas workflow:status "$run" --json --non-interactive > "$STATUS" 2>/dev/null
102
+ [ -s "$STATUS" ] || { echo "[context-fetch:expo-workflows] run $run: workflow:status returned no JSON" >&2; continue; }
98
103
  jq -r '.jobs[]? | "job \(.id) key=\(.key // "?") \(.status)", (.turtleJobRun.errors[]? | " \(.errorCode): \(.message)")' "$STATUS"
99
104
  # 2a) Step logs. `workflow:logs` takes the JOB id, not the run id (the run id returns "No
100
105
  # workflow job found"). --all-steps is required or it prompts for a step and hangs headless.
101
- for job in $(jq -r '.jobs[]?.id' "$STATUS"); do
106
+ # Failed jobs only: a passing job's log tail is noise.
107
+ for job in $(jq -r '.jobs[]? | select(.status=="FAILURE") | .id' "$STATUS"); do
102
108
  eas workflow:logs "$job" --all-steps --non-interactive 2>/dev/null | tail -60
103
109
  done
104
110
  # 2b) THE PER-FLOW EXCEPTION. Neither the GitHub job log nor the EAS job log carries it — both
@@ -114,7 +120,7 @@ for run in $(eas workflow:runs --json --status FAILURE --limit "${EAS_WF_ERR_N:-
114
120
  grep -oE 'https://wf-artifacts[^"]*(junit\.xml|failure-attempt[^"]*\.png)[^"]*' "$STATUS" \
115
121
  | while read -r u; do
116
122
  case "$u" in
117
- *junit.xml*) echo "===== JUnit ====="; curl -sS "$u" | tr -d '\r' ;;
123
+ *junit.xml*) echo "===== JUnit (first ${EAS_JUNIT_N:-300} lines) ====="; curl -sS "$u" | tr -d '\r' | head -n "${EAS_JUNIT_N:-300}" ;;
118
124
  *) echo "===== failure screenshot: $u" ;;
119
125
  esac
120
126
  done
@@ -140,8 +146,11 @@ for run in $(eas workflow:runs --json --status FAILURE --limit "${EAS_WF_ERR_N:-
140
146
  find "$DEST" -path '*screen-hierarchy*' -name '*.json' -exec ls -lh {} \; 2>/dev/null \
141
147
  | awk '{print " " $5 " " $NF}'
142
148
  # Per-ATTEMPT JUnit: the merged JUnit above hides a flow that failed and then passed on retry.
143
- find "$DEST" -path '*junit-reports*' -name '*.xml' 2>/dev/null \
144
- | while read -r j; do echo "===== $(basename "$j") ====="; tr -d '\r' < "$j"; done
149
+ find "$DEST" -path '*junit-reports*' -name '*.xml' 2>/dev/null | sort | head -n 20 \
150
+ | while read -r j; do
151
+ echo "===== $(basename "$j") (first ${EAS_JUNIT_N:-300} lines) ====="
152
+ tr -d '\r' < "$j" | head -n "${EAS_JUNIT_N:-300}"
153
+ done
145
154
  # 2e) WHY THE DRIVER DIED — read first for any DeviceUnreachableException. An `error:` line in
146
155
  # xctest_runner_*.log names the cause; neither job log does. A device-unreachable sweep is a
147
156
  # symptom shared by several faults, not a diagnosis.
@@ -3,7 +3,7 @@
3
3
 
4
4
  # GitHub Actions — failing CI run and diff since the last green run
5
5
 
6
- Fits: any repo whose CI runs on GitHub Actions. `context=ci`: the failing run on the current branch — failed jobs and steps, `::error` annotations, failed-step logs (bounded whole-run tail when `--log-failed` returns nothing). `context=diff`: `git diff --stat` from the last commit where your CI workflow passed on trunk to `HEAD`.
6
+ Fits: any repo whose CI runs on GitHub Actions. `context=ci`: the failing run on the current branch — failed jobs and steps, `::error` annotations, failed-step logs per failed job, each tail-bounded (bounded whole-run tail when `--log-failed` returns nothing). `context=diff`: `git diff --stat` (capped at `DIFF_STAT_N` files) from the last commit where your CI workflow passed on trunk to `HEAD`.
7
7
 
8
8
  - Secret: `GH_TOKEN` in cloud (local `gh auth login` works too).
9
9
  - Non-secret: `context=ci` none, the block discovers its own run. `context=diff`: `BASELINE_BRANCH` (your trunk, default `dev`) and `BASELINE_WORKFLOW` (your CI workflow file, default `bkit-ci.yml`); edit the defaults in the block so cloud agents inherit them.
@@ -20,7 +20,7 @@ Copy the blocks below into `.agents/context.md`, below `<!-- bkit:end -->`. The
20
20
  ```bash
21
21
  # GitHub Actions: failing-run job/step failures + error annotations + failed-step logs.
22
22
  # Discovers its own run. `gh` is base tooling — no context-fetch:provision sibling.
23
- # Customise: run (`--branch`, `--limit`, pin RUN_ID); log slice (`--log-failed` vs `--log`); job/step name filter; annotation grep.
23
+ # Customise: run (`--branch`, `--limit`, pin RUN_ID); log slice (`--log-failed` vs `--log`); CI_LOG_TAIL (lines kept per failed job, and of the whole-run fallback); job/step name filter; annotation grep.
24
24
  command -v gh >/dev/null 2>&1 \
25
25
  || { echo "[context-fetch:github] skipped — gh CLI not installed" >&2; exit 0; }
26
26
  gh auth status >/dev/null 2>&1 \
@@ -36,9 +36,23 @@ RUN_CONCLUSION=$(printf '%s' "$RUN_JSON" | jq -r '.[0].conclusion // ""')
36
36
  || { echo "[context-fetch:github] skipped — run $RUN_ID concluded success (nothing failing to fetch)" >&2; exit 0; }
37
37
  FAILED_STEPS=$(gh run view "$RUN_ID" --json conclusion,jobs \
38
38
  --jq '[.jobs[] | select(.conclusion=="failure") | {job: .name, steps: [.steps[] | select(.conclusion=="failure") | .name]}]' 2>/dev/null)
39
- CI_LOGS=$(gh run view "$RUN_ID" --log-failed 2>/dev/null)
40
- # Whole-run fallback is tens of MB — bound it. Raise CI_LOG_TAIL if the cause sits higher.
39
+ # Failed-step logs, one tail-bounded section per failed job, so a second failing job keeps its
40
+ # lines. Raise CI_LOG_TAIL if the cause sits higher in a job's log.
41
41
  CI_LOG_TAIL=2000
42
+ FAILED_JOBS=$(gh run view "$RUN_ID" --json jobs \
43
+ --jq '.jobs[] | select(.conclusion=="failure") | "\(.databaseId)\t\(.name)"' 2>/dev/null)
44
+ CI_LOGS=""
45
+ TAB=$(printf '\t')
46
+ while IFS="$TAB" read -r JOB JOB_NAME; do
47
+ [ -n "$JOB" ] || continue
48
+ JOB_LOG=$(gh run view "$RUN_ID" --job "$JOB" --log-failed 2>/dev/null | tail -n "$CI_LOG_TAIL")
49
+ [ -n "$JOB_LOG" ] && CI_LOGS="${CI_LOGS}===== job ${JOB_NAME} =====
50
+ ${JOB_LOG}
51
+ "
52
+ done <<EOF_JOBS
53
+ $FAILED_JOBS
54
+ EOF_JOBS
55
+ # Whole-run fallback is tens of MB — bound it the same way.
42
56
  [ -z "$CI_LOGS" ] && CI_LOGS=$(gh run view "$RUN_ID" --log 2>/dev/null | tail -n "$CI_LOG_TAIL")
43
57
  [ -n "$CI_LOGS" ] \
44
58
  || { echo "[context-fetch:github] skipped — no logs returned for run $RUN_ID" >&2; exit 0; }
@@ -58,7 +72,7 @@ printf '===== failed-step logs =====\n%s\n' "$CI_LOGS"
58
72
  ```bash
59
73
  # GitHub Actions: diff HEAD vs last-passing CI on trunk.
60
74
  # Set BASELINE_BRANCH / BASELINE_WORKFLOW to YOUR trunk and workflow file; commit them here.
61
- # Customise: BASELINE_BRANCH / BASELINE_WORKFLOW; last-passing `--limit`; `git diff` pathspec / `--stat` vs full patch.
75
+ # Customise: BASELINE_BRANCH / BASELINE_WORKFLOW; last-passing `--limit`; `git diff` pathspec / `--stat` vs full patch; DIFF_STAT_N (files listed).
62
76
  BASELINE_BRANCH="${BASELINE_BRANCH:-dev}"
63
77
  BASELINE_WORKFLOW="${BASELINE_WORKFLOW:-bkit-ci.yml}"
64
78
  command -v gh >/dev/null 2>&1 \
@@ -69,7 +83,7 @@ LAST_PASS_SHA=$(gh run list --branch "$BASELINE_BRANCH" --workflow "$BASELINE_WO
69
83
  || { echo "[context-fetch:github] skipped — no successful $BASELINE_WORKFLOW run on $BASELINE_BRANCH (check both names)" >&2; exit 0; }
70
84
  git cat-file -e "${LAST_PASS_SHA}^{commit}" 2>/dev/null \
71
85
  || { echo "[context-fetch:github] skipped — last-passing SHA $LAST_PASS_SHA not present locally (shallow clone?)" >&2; exit 0; }
72
- DIFF_STAT=$(git diff "$LAST_PASS_SHA..HEAD" --stat 2>/dev/null)
86
+ DIFF_STAT=$(git diff "$LAST_PASS_SHA..HEAD" --stat --stat-count="${DIFF_STAT_N:-200}" 2>/dev/null)
73
87
  [ -n "$DIFF_STAT" ] \
74
88
  || { echo "[context-fetch:github] skipped — no diff between HEAD and last-passing $LAST_PASS_SHA" >&2; exit 0; }
75
89
  printf '===== diff vs last-passing CI on %s (last-passing-sha: %s) =====\n\n%s\n' \
@@ -3,10 +3,10 @@
3
3
 
4
4
  # Inngest — failed function runs
5
5
 
6
- Fits: apps running durable functions on Inngest Cloud. `context=runtime`: recent `inngest/function.failed` system events — function id, run id, error message, and the opaque `*Id` keys of the triggering event.
6
+ Fits: apps running durable functions on Inngest Cloud. `context=runtime`: `inngest/function.failed` system events in a time window (default last 4 h) — function id, run id, error message, and the opaque `*Id` keys of the triggering event.
7
7
 
8
8
  - Secret: `INNGEST_SIGNING_KEY` — reuse the app's existing key. It is environment-scoped (branch environments and production have separate keys): use the key whose runs you want.
9
- - Non-secret: `INNGEST_N` (events, default 25).
9
+ - Non-secret: `INNGEST_N` (events, default 25, max 100), `SINCE_ISO` (window start, default 4 h ago; the API alone looks back only 1 h), `INNGEST_ENV` (branch environment name when the key is a branch key).
10
10
  - CLI: none (`curl` + `jq`), no provision block.
11
11
  - PII: the projection keeps only keys ending in `Id` from the triggering event's data. Keep free text and personal data out of `*Id` keys in your event payloads, or narrow the projection.
12
12
 
@@ -19,10 +19,16 @@ Copy the blocks below into `.agents/context.md`, below `<!-- bkit:end -->`.
19
19
  # INNGEST_SIGNING_KEY is ENV-SCOPED (branch env vs production) — use the key for the env whose
20
20
  # runs you want. Lists recent `inngest/function.failed` system events → function_id + run_id + error.
21
21
  # PII-safe: surfaces ONLY /Id$/ keys from the triggering event; every other key is dropped.
22
- # Customise: INNGEST_N; the ids projection (narrow it if any *Id key in your events carries PII).
22
+ # The API's own default window is the last 1 h; the block sets an explicit one.
23
+ # Customise: INNGEST_N (<= 100); SINCE_ISO window start (default 4 h ago); INNGEST_ENV (branch environment name, with a branch signing key); the ids projection (narrow it if any *Id key in your events carries PII).
23
24
  [ -n "${INNGEST_SIGNING_KEY:-}" ] \
24
25
  || { echo "[context-fetch:inngest] skipped — INNGEST_SIGNING_KEY unset" >&2; exit 0; }
25
- curl -s "https://api.inngest.com/v1/events?name=inngest/function.failed&limit=${INNGEST_N:-25}" \
26
+ START="${SINCE_ISO:-$(date -u -v-4H +%FT%TZ 2>/dev/null || date -u -d '4 hours ago' +%FT%TZ)}"
27
+ curl -sG "https://api.inngest.com/v1/events" \
28
+ --data-urlencode "name=inngest/function.failed" \
29
+ --data-urlencode "limit=${INNGEST_N:-25}" \
30
+ --data-urlencode "received_after=${START}" \
31
+ ${INNGEST_ENV:+-H "x-inngest-env: ${INNGEST_ENV}"} \
26
32
  -H "Authorization: Bearer ${INNGEST_SIGNING_KEY}" \
27
33
  | jq '[.data[]
28
34
  | {id, ts, function_id: .data.function_id, run_id: .data.run_id,
@@ -3,7 +3,7 @@
3
3
 
4
4
  # Maestro e2e lanes on GitHub Actions — job logs
5
5
 
6
- Fits: native e2e lanes (iOS, Android, or both) whose GitHub Actions jobs run Maestro, on the runner or by handing the run to Expo EAS, and upload no GitHub artifact. `context=e2e`: the full log of every failed Maestro job in the run, sliced to the steps that carry the per-flow result, else each log's tail.
6
+ Fits: native e2e lanes (iOS, Android, or both) whose GitHub Actions jobs run Maestro, on the runner or by handing the run to Expo EAS, and upload no GitHub artifact. `context=e2e`: the tail-bounded log of every failed Maestro job in the run, sliced to the steps that carry the per-flow result, else each log's tail.
7
7
 
8
8
  - Reads the per-flow result from steps that succeed inside the failed job, which `gh run view --log-failed` (the `context=ci` block) skips; the Playwright block's artifact download finds nothing on these lanes.
9
9
  - Secret: `GH_TOKEN` in cloud (local `gh auth login` works too).
@@ -23,7 +23,7 @@ Copy the block below into `.agents/context.md`, below `<!-- bkit:end -->`.
23
23
  # iOS: Maestro's driver is an XCUITest case hosting the HTTP server Maestro talks to, so one
24
24
  # failure inside it ends the suite and turns every later flow into DeviceUnreachableException;
25
25
  # read the per-flow table before the traces.
26
- # Customise: MAESTRO_JOB_RE; MAESTRO_STEPS (the steps that print per-flow results); MAESTRO_LOG_TAIL.
26
+ # Customise: MAESTRO_JOB_RE; MAESTRO_STEPS (the steps that print per-flow results); MAESTRO_LOG_TAIL (lines kept per step slice, and of the fallback tail).
27
27
  MAESTRO_JOB_RE="${MAESTRO_JOB_RE:-^your-maestro-e2e-job-name$}"
28
28
  MAESTRO_STEPS="${MAESTRO_STEPS:-Your per-flow results step|Your failure classification step}"
29
29
  MAESTRO_LOG_TAIL="${MAESTRO_LOG_TAIL:-800}"
@@ -50,12 +50,12 @@ while IFS="$TAB" read -r JOB_ID JOB_NAME; do
50
50
  fi
51
51
  PRINTED=1
52
52
  printf '===== Maestro job %s (run %s, job %s) =====\n' "$JOB_NAME" "$RUN_ID" "$JOB_ID"
53
- # Step names match as fixed strings against the step-name column gh prints; no match falls
54
- # through to the whole-log tail.
53
+ # Step names match as fixed strings against the step-name column gh prints; each slice keeps its
54
+ # last MAESTRO_LOG_TAIL lines. No match falls through to the whole-log tail.
55
55
  FOUND=0
56
56
  OLD_IFS=$IFS; IFS='|'
57
57
  for STEP in $MAESTRO_STEPS; do
58
- SLICE=$(grep -F "$STEP" "$JOB_LOG" 2>/dev/null)
58
+ SLICE=$(grep -F "$STEP" "$JOB_LOG" 2>/dev/null | tail -n "$MAESTRO_LOG_TAIL")
59
59
  [ -n "$SLICE" ] || continue
60
60
  FOUND=1
61
61
  printf '\n===== step: %s =====\n%s\n' "$STEP" "$SLICE"
@@ -23,7 +23,7 @@ Copy the block below into `.agents/context.md`, below `<!-- bkit:end -->`.
23
23
  # downloads THIS lane's artifact and files it as that lane's evidence; wrong evidence sends
24
24
  # diagnosis after the wrong failure, which is worse than the `NOT CONFIGURED` you get from
25
25
  # leaving the placeholder in. Until it is edited every run self-skips, naming the placeholder.
26
- # Customise: E2E_ARTIFACT; E2E_JOB_RE (anchored, this lane only); run selection; which report files to inline vs list as binary.
26
+ # Customise: E2E_ARTIFACT; E2E_JOB_RE (anchored, this lane only); run selection; which report files to inline vs list as binary; E2E_MAX_FILES / E2E_MAX_LINES / E2E_MAX_BIN (files inlined, lines per file, binary paths listed).
27
27
  E2E_ARTIFACT="${E2E_ARTIFACT:-playwright-report}"
28
28
  E2E_JOB_RE="${E2E_JOB_RE:-^your-e2e-job-name$}"
29
29
  command -v gh >/dev/null 2>&1 \
@@ -44,7 +44,7 @@ trap 'rm -rf "$DEST"' EXIT
44
44
  gh run download "$RUN_ID" -n "$E2E_ARTIFACT" -D "$DEST" 2>/dev/null \
45
45
  || { echo "[context-fetch:playwright] skipped — run $RUN_ID published no '$E2E_ARTIFACT' artifact; its e2e evidence is NOT in GitHub" >&2; exit 0; }
46
46
  # Failing specs first (`test-results/` holds only failures), then the rest. Bound both counts.
47
- E2E_MAX_FILES=20; E2E_MAX_LINES=300
47
+ E2E_MAX_FILES=20; E2E_MAX_LINES=300; E2E_MAX_BIN=50
48
48
  e2e_list() { find "$1" -type f \( -name '*.md' -o -name '*.json' -o -name '*.txt' -o -name '*.log' -o -name '*.xml' \) 2>/dev/null | sort; }
49
49
  E2E_FILES=$({ e2e_list "$DEST/test-results"; e2e_list "$DEST"; } | awk '!seen[$0]++')
50
50
  E2E_TOTAL=$(printf '%s' "$E2E_FILES" | grep -c . || true)
@@ -56,7 +56,7 @@ printf '%s\n' "$E2E_FILES" | head -n "$E2E_MAX_FILES" | while read -r f; do
56
56
  done
57
57
  [ "$E2E_TOTAL" -gt "$E2E_MAX_FILES" ] && printf '\n===== inlined %s of %s files; the rest were NOT read =====\n' "$E2E_MAX_FILES" "$E2E_TOTAL"
58
58
  printf '\n===== binary artifacts (not inlined) =====\n'
59
- find "$DEST" -type f \( -name '*.html' -o -name '*.png' -o -name '*.webm' -o -name '*.zip' \) | sed "s|^$DEST/||" | sort
59
+ find "$DEST" -type f \( -name '*.html' -o -name '*.png' -o -name '*.webm' -o -name '*.zip' \) | sed "s|^$DEST/||" | sort | head -n "$E2E_MAX_BIN"
60
60
  ```
61
61
 
62
62
  <!-- context-fetch:end -->
@@ -3,10 +3,10 @@
3
3
 
4
4
  # Sentry — unresolved issues
5
5
 
6
- Fits: apps reporting errors to Sentry (web, server or native). `context=runtime`: unresolved issues seen in the last 24 h, newest first (id, title, culprit, count, first / last seen, permalink). Commented recipes in the block pull one issue's `trace_id` (to stitch to the `vercel` block's `traceId`) and every event of one issue with timestamps (to count events inside a run's time window).
6
+ Fits: apps reporting errors to Sentry (web, server or native). `context=runtime`: one project's unresolved issues seen in a window (default last 24 h; optional environment), newest first (id, title, culprit, count, first / last seen, permalink). Commented recipes in the block pull one issue's `trace_id` (to stitch to the `vercel` block's `traceId`) and every event of one issue with timestamps (to count events inside a run's time window).
7
7
 
8
8
  - Secret: `SENTRY_AUTH_TOKEN` (an internal-integration or user token with `project:read`, `event:read`).
9
- - Non-secret: `SENTRY_ORG`, `SENTRY_PROJECT` (slugs) and `SENTRY_HOST` — uncomment the lines in the block so cloud agents inherit them. An EU-region org uses `de.sentry.io`: the global host 404s on its issue ids.
9
+ - Non-secret: `SENTRY_ORG`, `SENTRY_PROJECT` (slugs) and `SENTRY_HOST` — uncomment the lines in the block so cloud agents inherit them. An EU-region org uses `de.sentry.io`: the global host 404s on its issue ids. Optional: `SENTRY_SINCE` (window, default `24h`), `SENTRY_ENV`, `SENTRY_N`.
10
10
  - CLI: none (`curl` + `jq`), no provision block.
11
11
  - An empty list is not "no errors": a spent quota drops events silently. Check the org's quota usage before reading silence as clean.
12
12
 
@@ -15,7 +15,8 @@ Copy the blocks below into `.agents/context.md`, below `<!-- bkit:end -->`.
15
15
  <!-- context-fetch:start sentry context=runtime -->
16
16
 
17
17
  ```bash
18
- # Sentry issues API — unresolved issues, last 24h, sorted by last seen (read-only).
18
+ # Sentry organization issues API — unresolved issues of one project seen in the window (default
19
+ # 24h), sorted by last seen (read-only). statsPeriod is the query window on this endpoint.
19
20
  # Headless: SENTRY_AUTH_TOKEN (secret, from env). SENTRY_ORG / SENTRY_PROJECT / SENTRY_HOST are
20
21
  # non-secret — uncomment + set the lines below so local AND cloud agents inherit them:
21
22
  # SENTRY_ORG="your-org-slug"
@@ -23,13 +24,13 @@ Copy the blocks below into `.agents/context.md`, below `<!-- bkit:end -->`.
23
24
  # SENTRY_HOST="de.sentry.io" # EU-region org; the global host 404s on its issue ids
24
25
  # An empty array is NOT "no errors": a spent quota drops events silently — check the org's
25
26
  # quota usage (or /api/0/organizations/{org}/stats_v2/) before concluding silence = clean.
26
- # Customise: statsPeriod (1h / 7d); SENTRY_N; add `environment:production` to the query; jq keys.
27
+ # Customise: SENTRY_SINCE window (1h / 24h / 7d); SENTRY_ENV (environment name, e.g. production; unset = all); SENTRY_N (<= 100); jq keys.
27
28
  SENTRY_HOST="${SENTRY_HOST:-sentry.io}"
28
29
  [ -n "${SENTRY_AUTH_TOKEN:-}" ] && [ -n "${SENTRY_ORG:-}" ] && [ -n "${SENTRY_PROJECT:-}" ] \
29
30
  || { echo "[context-fetch:sentry] skipped — SENTRY_AUTH_TOKEN / SENTRY_ORG / SENTRY_PROJECT unset" >&2; exit 0; }
30
31
  curl -s \
31
32
  -H "Authorization: Bearer ${SENTRY_AUTH_TOKEN}" \
32
- "https://${SENTRY_HOST}/api/0/projects/${SENTRY_ORG}/${SENTRY_PROJECT}/issues/?query=is%3Aunresolved&statsPeriod=24h&limit=${SENTRY_N:-25}&sort=date" \
33
+ "https://${SENTRY_HOST}/api/0/organizations/${SENTRY_ORG}/issues/?project=${SENTRY_PROJECT}&query=is%3Aunresolved&statsPeriod=${SENTRY_SINCE:-24h}&sort=date&limit=${SENTRY_N:-25}&collapse=stats${SENTRY_ENV:+&environment=${SENTRY_ENV}}" \
33
34
  | jq '[.[] | {id, title, culprit, count: .count, firstSeen, lastSeen, permalink}]'
34
35
 
35
36
  # Trace correlation — one issue's latest event → its trace_id. The same id appears in the
@@ -3,10 +3,10 @@
3
3
 
4
4
  # Stripe — failed payment events
5
5
 
6
- Fits: apps taking payments with Stripe. `context=runtime`: recent Events API entries whose type names a failure, dispute, error or refund (id, type, created, livemode only — never customer, card or metadata). The Events API keeps about 30 days.
6
+ Fits: apps taking payments with Stripe. `context=runtime`: Events API entries in a window (default last day) whose type names a failure, dispute or refund, filtered by the API (id, type, created, livemode only — never customer, card or metadata). The Events API keeps about 30 days.
7
7
 
8
8
  - Secret: `STRIPE_SECRET_KEY` — reuse the app's existing key, or a restricted key with read access to Events. The `sk_live_` / `sk_test_` prefix selects live vs test mode.
9
- - Non-secret: `STRIPE_N` (events scanned, default 50).
9
+ - Non-secret: `STRIPE_N` (events returned, default 50, max 100), `STRIPE_SINCE_S` (window in seconds, default 86400).
10
10
  - CLI: none (`curl` + `jq`), no provision block.
11
11
 
12
12
  Copy the blocks below into `.agents/context.md`, below `<!-- bkit:end -->`.
@@ -17,14 +17,37 @@ Copy the blocks below into `.agents/context.md`, below `<!-- bkit:end -->`.
17
17
  # Stripe event stream — payment / subscription / dispute / refund failures (read-only GET).
18
18
  # Headless: STRIPE_SECRET_KEY (secret, from env); the key prefix (sk_live_ / sk_test_) selects
19
19
  # live vs test mode. PII-safe: only id / type / created / livemode surfaced.
20
- # Customise: STRIPE_N; the type filter; add `&type=` to the URL to narrow server-side.
20
+ # Filters at the source: every event type naming a failure, dispute or refund, in two calls
21
+ # (the API takes at most 20 `types[]` per call), merged newest first.
22
+ # Customise: STRIPE_N (<= 100); STRIPE_SINCE_S window in seconds (default 1 day; the API keeps ~30 days); the two type lists.
21
23
  [ -n "${STRIPE_SECRET_KEY:-}" ] \
22
24
  || { echo "[context-fetch:stripe] skipped — STRIPE_SECRET_KEY unset" >&2; exit 0; }
23
- curl -s "https://api.stripe.com/v1/events?limit=${STRIPE_N:-50}" \
24
- -u "${STRIPE_SECRET_KEY}:" \
25
- | jq '[.data[]
26
- | select(.type | test("fail|dispute|error|refund"; "i"))
27
- | {id, type, created, livemode}]'
25
+ SINCE_TS=$(( $(date +%s) - ${STRIPE_SINCE_S:-86400} ))
26
+ stripe_events() {
27
+ TYPES=""
28
+ for t in "$@"; do TYPES="$TYPES -d types[]=$t"; done
29
+ # $TYPES unquoted on purpose: one `-d types[]=<name>` per word; type names hold no spaces.
30
+ curl -sgG "https://api.stripe.com/v1/events" -u "${STRIPE_SECRET_KEY}:" \
31
+ --data-urlencode "limit=${STRIPE_N:-50}" \
32
+ --data-urlencode "created[gte]=${SINCE_TS}" \
33
+ $TYPES
34
+ }
35
+ {
36
+ stripe_events charge.failed charge.refunded charge.refund.updated \
37
+ charge.dispute.created charge.dispute.updated charge.dispute.closed \
38
+ charge.dispute.funds_withdrawn charge.dispute.funds_reinstated \
39
+ payment_intent.payment_failed invoice.payment_failed invoice.finalization_failed \
40
+ checkout.session.async_payment_failed setup_intent.setup_failed \
41
+ refund.created refund.updated refund.failed
42
+ stripe_events application_fee.refunded application_fee.refund.updated \
43
+ payout.failed topup.failed source.failed source.refund_attributes_required \
44
+ issuing_dispute.created issuing_dispute.updated issuing_dispute.closed \
45
+ issuing_dispute.submitted issuing_dispute.funds_reinstated issuing_dispute.funds_rescinded \
46
+ reporting.report_run.failed terminal.reader.action_failed test_helpers.test_clock.internal_failure
47
+ } | jq -s --argjson n "${STRIPE_N:-50}" '
48
+ [.[] | if .error then error("[context-fetch:stripe] Stripe API error: \(.error.message)") else .data[] end]
49
+ | sort_by(-.created) | .[:$n]
50
+ | map({id, type, created, livemode})'
28
51
  ```
29
52
 
30
53
  <!-- context-fetch:end -->
@@ -13,7 +13,9 @@
13
13
  * - a row names a decision absent from the table, or carries no reason.
14
14
  *
15
15
  * A new comparison inside an already-registered step is a new site: the site key is
16
- * `file#job#step#field`.
16
+ * `file#job#step#field`. The workflow-level `concurrency:` block keys as
17
+ * `file#(workflow)#concurrency#field`. Only `.github/workflows/*.yml` is scanned; scripts,
18
+ * hooks and tests are not.
17
19
  *
18
20
  * Usage: node scripts/ci/check-accepted-divergences.mjs [--workflows=<dir>] [--registry=<file>]
19
21
  * Exit: 0 = every site registered and every row live, 1 = drift.
@@ -32,9 +34,44 @@ function normalizedField(match) {
32
34
  return match.replace(/\s+/g, " ").trim();
33
35
  }
34
36
 
37
+ /** The `job` of a site read outside `jobs:` (workflow-level keys such as `concurrency:`); its `step` is the top-level key. */
38
+ export const WORKFLOW_LEVEL = "(workflow)";
39
+
40
+ /** Leading-space count of a line. */
41
+ function indentOf(line) {
42
+ return line.length - line.trimStart().length;
43
+ }
44
+
45
+ /**
46
+ * Name of the step whose `- key: value` item starts at `start`: its `name:`, else `uses:`,
47
+ * else `id:`, else `step-<n>` (n = 1-based position in the job). Only keys at the item's own
48
+ * key column count, so a `name:` nested in a `with:` or `run:` block is never mistaken for it.
49
+ */
50
+ function stepName(lines, start, dashIndent, ordinal) {
51
+ const keyIndent = dashIndent + 2;
52
+ const found = {};
53
+ for (let j = start; j < lines.length; j++) {
54
+ const text = lines[j];
55
+ if (j > start && text.trim() !== "" && indentOf(text) <= dashIndent) break;
56
+ const m =
57
+ j === start
58
+ ? /^\s*- ([A-Za-z_-]+):\s*(.*?)\s*$/.exec(text)
59
+ : indentOf(text) === keyIndent
60
+ ? /^\s*([A-Za-z_-]+):\s*(.*?)\s*$/.exec(text)
61
+ : null;
62
+ if (m && ["name", "uses", "id"].includes(m[1]) && !(m[1] in found)) {
63
+ found[m[1]] = m[2].replace(/\s+#.*$/, "").replace(/^["']|["']$/g, "");
64
+ }
65
+ }
66
+ return found.name || found.uses || found.id || `step-${ordinal}`;
67
+ }
68
+
35
69
  /**
36
70
  * Collect every event-keyed site in the workflow files under `workflowsDir`.
37
71
  * A line-based scan — deliberately no YAML dependency, so the guard is portable.
72
+ * Sites outside `jobs:` (the workflow-level `concurrency:` block) key as job `(workflow)`,
73
+ * step = the top-level key. A step is any `- key:` item under a job's `steps:`, whatever its
74
+ * first key (`name`, `uses`, `id`, `run`, `if`, ...).
38
75
  * @returns {Array<{file: string, job: string, step: string, field: string, line: number}>}
39
76
  */
40
77
  export function collectSites(workflowsDir, fileFilter = /\.(ya?ml)$/) {
@@ -44,30 +81,39 @@ export function collectSites(workflowsDir, fileFilter = /\.(ya?ml)$/) {
44
81
  if (!fileFilter.test(name)) continue;
45
82
  const file = path.join(".github", "workflows", name).split(path.sep).join("/");
46
83
  const lines = fs.readFileSync(path.join(workflowsDir, name), "utf-8").split("\n");
47
- let job = "";
84
+ let job = WORKFLOW_LEVEL;
48
85
  let step = "";
49
86
  let inJobs = false;
87
+ let stepsIndent = -1;
88
+ let stepOrdinal = 0;
50
89
  const seen = new Set();
51
90
  lines.forEach((line, i) => {
52
91
  const code = line.replace(/\s+#.*$/, "");
53
- if (/^jobs:\s*$/.test(code)) {
54
- inJobs = true;
55
- return;
56
- }
57
- if (inJobs && /^\S/.test(code)) {
58
- // A new top-level key closes the `jobs:` block.
59
- inJobs = false;
60
- }
61
- if (!inJobs) return;
62
- const jobMatch = /^ {2}([A-Za-z0-9_.-]+):\s*$/.exec(code);
63
- if (jobMatch) {
64
- job = jobMatch[1];
65
- step = "";
66
- return;
92
+ const topKey = /^([A-Za-z_-]+):/.exec(code);
93
+ if (topKey) {
94
+ inJobs = topKey[1] === "jobs";
95
+ job = WORKFLOW_LEVEL;
96
+ step = inJobs ? "" : topKey[1];
97
+ stepsIndent = -1;
67
98
  }
68
- const stepMatch = /^\s{4,}- (?:name|uses):\s*(.+?)\s*$/.exec(line);
69
- if (stepMatch) {
70
- step = stepMatch[1].replace(/^["']|["']$/g, "");
99
+ if (inJobs && !topKey) {
100
+ const jobMatch = /^ {2}([A-Za-z0-9_.-]+):\s*$/.exec(code);
101
+ if (jobMatch) {
102
+ job = jobMatch[1];
103
+ step = "";
104
+ stepsIndent = -1;
105
+ stepOrdinal = 0;
106
+ return;
107
+ }
108
+ const stepsMatch = /^(\s+)steps:\s*$/.exec(code);
109
+ if (stepsMatch) {
110
+ stepsIndent = stepsMatch[1].length + 2;
111
+ return;
112
+ }
113
+ if (stepsIndent >= 0 && indentOf(line) === stepsIndent && /^\s*- [A-Za-z_-]+:/.test(code)) {
114
+ stepOrdinal++;
115
+ step = stepName(lines, i, stepsIndent, stepOrdinal);
116
+ }
71
117
  }
72
118
  for (const m of code.matchAll(FIELD_RE)) {
73
119
  const field = normalizedField(m[0]);
@@ -75,6 +75,40 @@ test("collects every event-keyed site with its job and step", () => {
75
75
  });
76
76
  });
77
77
 
78
+ test("collects the workflow-level concurrency block and steps whose first key is not name/uses", () => {
79
+ const yml = [
80
+ "name: CI",
81
+ "concurrency:",
82
+ " group: ci-${{ github.event_name }}",
83
+ " cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}",
84
+ "jobs:",
85
+ " j:",
86
+ " steps:",
87
+ " - id: first",
88
+ " name: Named After Id",
89
+ " if: github.ref_name == 'dev'",
90
+ " - run: echo ${{ github.base_ref }}",
91
+ " - if: github.head_ref",
92
+ " uses: actions/checkout@v4",
93
+ " with:",
94
+ " name: not-a-step-name",
95
+ "",
96
+ ].join("\n");
97
+ withWorkflows(yml, (dir) => {
98
+ const keys = collectSites(dir).map((s) => `${s.job}#${s.step}#${s.field}`);
99
+ for (const want of [
100
+ "(workflow)#concurrency#github.event_name",
101
+ "(workflow)#concurrency#github.ref",
102
+ "j#Named After Id#github.ref_name",
103
+ "j#step-2#github.base_ref",
104
+ "j#actions/checkout@v4#github.head_ref",
105
+ ]) {
106
+ assert(keys.includes(want), `missing ${want} in ${keys.join(", ")}`);
107
+ }
108
+ assert(keys.length === 5, `expected 5 sites, got ${keys.length}`);
109
+ });
110
+ });
111
+
78
112
  test("an unregistered site is reported missing", () => {
79
113
  const sites = [
80
114
  { file: ".github/workflows/bkit-ci.yml", job: "j", step: "s", field: "github.event_name" },