@bbcsoftwarefactory/cli 1.1.2 → 1.1.4

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 (73) hide show
  1. package/dist/bbc-install.d.ts +2 -1
  2. package/dist/bbc-install.js +93 -28
  3. package/dist/bbc.js +4 -1
  4. package/dist/bundle/commands/daily/SKILL.md +112 -0
  5. package/dist/bundle/commands/daily/adapters/command.md +17 -0
  6. package/dist/bundle/commands/daily/adapters/gemini.toml +17 -0
  7. package/dist/bundle/commands/issue-clean-and-close/SKILL.md +85 -0
  8. package/dist/bundle/commands/issue-clean-and-close/adapters/command.md +17 -0
  9. package/dist/bundle/commands/issue-clean-and-close/adapters/gemini.toml +17 -0
  10. package/dist/bundle/commands/issue-clean-and-close/references/policy.md +87 -0
  11. package/dist/bundle/commands/recap/SKILL.md +84 -0
  12. package/dist/bundle/commands/recap/adapters/command.md +17 -0
  13. package/dist/bundle/commands/recap/adapters/gemini.toml +17 -0
  14. package/dist/bundle/installer/clients.json +103 -0
  15. package/dist/bundle/skills/code-quality-gate/SKILL.md +58 -0
  16. package/dist/bundle/skills/code-quality-gate/references/gate-bigo.md +31 -0
  17. package/dist/bundle/skills/code-quality-gate/references/gate-earlyreturn.md +73 -0
  18. package/dist/bundle/skills/code-quality-gate/references/gate-typesafe.md +32 -0
  19. package/dist/bundle/skills/code-quality-gate/references/output-schema.yml +40 -0
  20. package/dist/bundle/skills/delivery-coordinator/SKILL.md +80 -0
  21. package/dist/bundle/skills/delivery-coordinator/references/hud-output.md +55 -0
  22. package/dist/bundle/skills/delivery-coordinator/references/intake.md +86 -0
  23. package/dist/bundle/skills/delivery-coordinator/references/issue-claim.md +143 -0
  24. package/dist/bundle/skills/delivery-coordinator/references/issue-dedup.md +38 -0
  25. package/dist/bundle/skills/delivery-coordinator/references/sleuth-regression-exercise.md +60 -0
  26. package/dist/bundle/skills/delivery-coordinator/references/visual-reference.md +45 -0
  27. package/dist/bundle/skills/delivery-coordinator/references/worktree-isolation.md +19 -0
  28. package/dist/bundle/skills/documentation-steward/SKILL.md +43 -0
  29. package/dist/bundle/skills/documentation-steward/references/discovery.md +17 -0
  30. package/dist/bundle/skills/documentation-steward/references/handoff.md +15 -0
  31. package/dist/bundle/skills/greptile-review-loop/SKILL.md +56 -0
  32. package/dist/bundle/skills/greptile-review-loop/references/review-protocol.md +37 -0
  33. package/dist/bundle/skills/issue-reviewer/SKILL.md +84 -0
  34. package/dist/bundle/skills/issue-reviewer/references/review-format.md +100 -0
  35. package/dist/bundle/skills/issue-reviewer/references/triage.md +105 -0
  36. package/dist/bundle/skills/question-gate/SKILL.md +64 -0
  37. package/dist/bundle/skills/question-gate/references/client-hooks.md +111 -0
  38. package/dist/bundle/skills/question-gate/references/diagram-routing.md +58 -0
  39. package/dist/bundle/skills/question-gate/tests/fixtures/question-corpus.json +481 -0
  40. package/dist/bundle/skills/regression-testing/SKILL.md +49 -0
  41. package/dist/bundle/skills/regression-testing/references/evidence-record.md +35 -0
  42. package/dist/bundle/skills/requirements-spec/SKILL.md +59 -0
  43. package/dist/bundle/skills/risk-scout/SKILL.md +53 -0
  44. package/dist/bundle/skills/risk-scout/references/risk-matrix.md +49 -0
  45. package/dist/bundle/skills/skill-clean-architecture/SKILL.md +53 -0
  46. package/dist/bundle/skills/skill-clean-architecture/references/layer-rules.md +22 -0
  47. package/dist/bundle/skills/skill-clean-architecture/references/source-headers.md +30 -0
  48. package/dist/bundle/skills/skill-clean-architecture/tests/fixtures/bigo/bad-utf8.js +1 -0
  49. package/dist/bundle/skills/skill-clean-architecture/tests/fixtures/bigo/edge-crlf.ts +6 -0
  50. package/dist/bundle/skills/skill-clean-architecture/tests/fixtures/bigo/edge-mixed.ts +15 -0
  51. package/dist/bundle/skills/skill-clean-architecture/tests/fixtures/bigo/empty.js +0 -0
  52. package/dist/bundle/skills/skill-clean-architecture/tests/fixtures/bigo/no-newline.js +1 -0
  53. package/dist/bundle/skills/skill-clean-architecture/tests/fixtures/bigo.expected.yml +95 -0
  54. package/dist/bundle/skills/tool-depot/SKILL.md +47 -0
  55. package/dist/bundle/skills/tool-depot/references/checkout.md +29 -0
  56. package/dist/bundle/skills/tool-depot/references/loki-read.md +41 -0
  57. package/dist/bundle/skills/tool-depot/references/readonly-access.md +84 -0
  58. package/dist/bundle/skills/tool-depot/references/tool-catalog.json +47 -0
  59. package/dist/bundle/skills/tool-depot/scripts/loki-runtime-logs.py +305 -0
  60. package/dist/bundle/skills/tool-depot/tests/loki-runtime-logs.test.sh +101 -0
  61. package/dist/bundle/skills/watcher-observability/SKILL.md +72 -0
  62. package/dist/bundle/skills/watcher-observability/references/batch-protocol.md +44 -0
  63. package/dist/bundle/skills/watcher-observability/references/configuration.md +31 -0
  64. package/dist/bundle/skills/watcher-observability/references/error-scan.md +102 -0
  65. package/dist/bundle/skills/watcher-observability/references/live-protocol.md +49 -0
  66. package/dist/bundle/skills/watcher-observability/references/server-account.md +72 -0
  67. package/dist/bundle/skills/watcher-observability/server/watcher-gate.sh +51 -0
  68. package/dist/bundle/skills/watcher-observability/tests/watcher-gate.test.sh +113 -0
  69. package/dist/bundle/skills/watcher-observability/watcher.json +1 -0
  70. package/dist/bundle/skills/workflow-auditor/SKILL.md +53 -0
  71. package/dist/bundle/skills/workflow-auditor/references/audit-protocol.md +49 -0
  72. package/dist/bundle/skills/workflow-auditor/references/ledger.md +122 -0
  73. package/package.json +3 -3
@@ -0,0 +1,87 @@
1
+ # Issue cleanup policy
2
+
3
+ `/issue-clean-and-close` reviews every open issue of the repository it runs in, closes only what the evidence settles, and labels and pings the rest, so nothing is left open without a reason and nothing is closed because it is old. It runs when a person invokes it; nothing is scheduled or installed. The person approves the exact plan at the Boss Gate, and that approval is the authorization for Tool Depot `github-write` / `clean-approved-issues`.
4
+
5
+ ## Pipeline
6
+
7
+ ```text
8
+ bbc sweep plan -> login, optional .github/issue-sweeper.json from the default branch
9
+ bbc sweep-github fetch -> snapshot.json (one GraphQL query per 30 open issues)
10
+ bbc sweep-issues -> plans/<UTC>.json (offline: rules SW1-SW8, metrics, report)
11
+ 🟡 Boss Gate -> the person approves all, some issue numbers, or nothing
12
+ bbc sweep apply --plan -> bbc sweep-github apply: only what the approved plan lists, plus the report issue
13
+ ```
14
+
15
+ `sweep-issues` decides everything and never calls GitHub; `sweep-github` only reads and writes what the plan says; `sweep` chains them, finds the repository from the checkout's `origin`, and keeps the evidence. An LLM reading this file applies the same rules and must reach the same plan; when they differ, the CLI stands and the difference is reported.
16
+
17
+ ## Configuration (optional `.github/issue-sweeper.json`)
18
+
19
+ Without the file, the defaults apply. With it, its keys override them; it is read from the default branch, so changing it takes a reviewed pull request.
20
+
21
+ | Key | Default | Meaning |
22
+ |---|---|---|
23
+ | `language` | `es` | Language of comments and report (`es`, `en`). |
24
+ | `max_writes_per_run` | `20` | Issues acted on per plan; the rest are listed as `deferred` for the next run. |
25
+ | `needs_info_days` | `14` | Days after `needs-info` without an answer from the author before closing. |
26
+ | `claim_stale_days` | `7` | Days a claimed issue may go without activity or an open PR. |
27
+ | `inactive_days` | `30` | Days without activity before an unclaimed issue with no PR is marked `stale`. |
28
+ | `labels` | `stale`, `needs-info`, `needs-close-review`, `status:in-progress` | Label names. The command never creates labels; a missing one is a gap and the action proceeds without it. |
29
+ | `exempt_labels` | `security`, `frozen`, `lifecycle/frozen`, `pinned` | Issues the command never touches. |
30
+ | `exempt_priorities` | `P0`, `P1` | Priority levels it never touches (`priority:*`, `prioridad:*`, `P0`–`P3`). |
31
+ | `report_title` | `Estado de issues` | Title of the report issue. |
32
+
33
+ The account that applies the plan is the `gh` login of whoever runs the command (`run_by` in the plan). Its sweep comments (by marker) and the `stale` and `needs-close-review` labels it sets are the command's own writes; anything else that person does is activity.
34
+
35
+ ## Rules decided by `sweep-issues`
36
+
37
+ Rules are checked in this order; an issue gets at most one action per plan.
38
+
39
+ | Rule | Condition | Action |
40
+ |---|---|---|
41
+ | `SW8` | The issue has an exempt label or priority. | Report only. |
42
+ | `SW1` | A merged pull request **declares** closing the issue (manual link, GitHub's `willCloseTarget`, or a closing keyword `close/fix/resolve` + `#n` in its title or body), the issue was not reopened after that merge, and no open pull request also declares closing it. | Comment with the PR and merge commit, then close as `completed`. |
43
+ | `SW2` | A merged pull request references the issue without declaring it closed, or `SW1` was blocked by a reopen or another open PR. | Add `needs-close-review` and comment to the assignees (or the author). |
44
+ | `SW3` | `needs-info` is set, was added at least `needs_info_days` ago, and the author has not commented since. | Comment, then close as `not_planned`. |
45
+ | `SW4` | More than one open pull request references the issue. | Report only (`duplicate-work`). |
46
+ | `SW5` | The claim label is set, someone is assigned, no open pull request references it, and no activity for `claim_stale_days`. | Comment to the assignees. Never unassign. |
47
+ | `SW7` | `stale` is set and there was activity after it was added, within the last `inactive_days`. | Remove `stale`. |
48
+ | `SW6` | `stale` is not set, no open or merged pull request references it, it is not claimed, and no activity for `inactive_days`. | Add `stale` and comment. Never close. |
49
+
50
+ An issue with an incomplete pull request timeline gets no action at all, only a gap in the report.
51
+
52
+ **Activity** is the latest of: the issue's creation, a comment without a sweep marker, a label change other than the runner setting `stale` or `needs-close-review`, and a pull request referencing the issue. The command's own writes never reset or extend a timer.
53
+
54
+ **Idempotency:** every comment ends with `<!-- issue-sweeper:<rule> -->`. A rule that comments (`SW2`, `SW5`, `SW6`) does not comment again while its marker is newer than the last activity, whoever ran it.
55
+
56
+ **Safety:**
57
+
58
+ - The person sees every write before it happens, and `apply` performs only the plan file shown (all of it, or `--only` the approved issue numbers; a number outside the plan is refused). A plan older than 60 minutes or for another repository is refused.
59
+ - An issue with more pull request references than one page holds (25) gets no action (`incomplete`). Only the latest 25 comments and label events are read; an older `needs-info` label without its event in that window is never closed by `SW3`.
60
+ - `willCloseTarget` is not reliable once an issue is closed or reopened, so the closing keywords in the pull request's title and body are checked too. The fetcher keeps only the body lines that reference an issue, so a keyword at the end of a long body is not lost.
61
+ - Comments contain only numbers, links, dates, logins, and fixed text, never text copied from issues or pull requests. Each comment carries a `🟡 GAP visual` line: the evidence is the linked pull request or the timeline.
62
+ - Only an issue opened by the runner's login and carrying the report marker is its report issue, so copying the marker into another issue cannot get that issue's body overwritten.
63
+ - A failed write skips the remaining steps for that issue (a comment that fails is never followed by a close).
64
+
65
+ ## Report
66
+
67
+ The plan carries a report, shown at the gate and kept as `report.md`. When a plan is applied, the runner's report issue (titled `report_title`, marked `<!-- issue-sweeper:report -->`) is created or rewritten with it:
68
+
69
+ - Open issues, with a pull request, assigned, age (median and 90th percentile, in days).
70
+ - Merged but still open (`SW1` + `SW2`), stale claims (`SW5`), duplicate work (`SW4`), waiting for information, inactive (`SW6`), exempt (`SW8`).
71
+ - The actions, the issues deferred by the cap, and the report-only issues, each with its rule.
72
+ - Gaps: missing labels, incomplete issues.
73
+
74
+ ## Operation
75
+
76
+ ```bash
77
+ npx -y @bbcsoftwarefactory/cli sweep plan [--repo <owner>/<repo>]
78
+ npx -y @bbcsoftwarefactory/cli sweep apply --plan <plan> [--only 12,15] [--dry-run]
79
+ ```
80
+
81
+ Every step keeps its evidence in `~/.issue-clean-and-close/<owner>__<repo>/` (`SWEEP_HOME` overrides it): the policy file used (`config.json`), `snapshot.json`, the last 30 plans in `plans/` (`--keep`), `report.md`, and one JSON line per step in `runs.log` (plan: actions, deferred, gaps; apply: the plan, `only`, writes, errors).
82
+
83
+ | Exit | `sweep` | `sweep-issues` | `sweep-github` |
84
+ |---|---|---|---|
85
+ | 0 | Done | Plan ready | Done |
86
+ | 1 | Some writes failed (listed) | — | Some writes failed (listed) |
87
+ | 2 | Unusable input, stale or foreign plan, broken policy file | `unusable` input or config | Unusable input |
@@ -0,0 +1,84 @@
1
+ ---
2
+ name: recap
3
+ description: "Trigger: /recap, recap, resumen del dia, progreso del dia, cuanto avance, que efectivo fui, daily progress summary. Daily progress summary across Git, GitHub REST, and Project v2 boards: issues created/closed, PRs opened/merged, contribution, work in progress, effectiveness ratios, and optional board sync."
4
+ disable-model-invocation: true
5
+ license: Apache-2.0
6
+ compatibility: Requires Node.js 22.18+ (`@bbcsoftwarefactory/cli`), Git, and an authenticated gh CLI for GitHub metrics in `bbc recap`.
7
+ metadata:
8
+ author: bbc-skill-internals
9
+ version: "1.1"
10
+ pre_hook: "tool-depot (github-read: read-approved-issue-or-pr, read-pr-review-and-checks)"
11
+ post_hook: "Quest-Tree HUD"
12
+ post_install: "npx --full-depth; copy adapters/gemini.toml + /commands reload (Gemini); server restart (Zed ACP)"
13
+ adapters: "adapters/command.md, adapters/gemini.toml"
14
+ ---
15
+
16
+ ## Activation Contract
17
+
18
+ Run only when a person explicitly invokes `/recap` (or asks for a daily progress recap). By default it produces a **read-only** summary across local Git, GitHub REST, and an optional GitHub Project v2 board; it never mutates branches, files, issues, PRs, or boards unless the user explicitly asks to organize/sync the board (`--sync-board`).
19
+
20
+ Optional arguments:
21
+ - `--since <YYYY-MM-DD | <N>h | <N>d>`: Start of the summary window (default: local midnight today).
22
+ - `--all-repos`: Aggregate GitHub activity across all repositories for the user instead of only the current `origin` repository.
23
+ - `--repo <owner/repo>`: Override the target GitHub repository.
24
+ - `--user <login>`: Override the GitHub login (default: authenticated `gh` user).
25
+ - `--team`: Collect summary across all members of the target organization.
26
+ - `--users <u1,u2,...>`: Comma-separated GitHub logins for team summary.
27
+ - `--project <url | owner/number>`: Inspect a GitHub Project v2 board (column counts, assignee breakdown, and sync diff).
28
+ - `--sync-board`: With `--project`, add missing items and move closed/merged cards to `Done`.
29
+ - `--fix-colors`: With `--sync-board`, normalize `Status`/single-select colors (preserving option IDs) and show Labels/Priority/PRs on board view cards.
30
+ - `--apply-labels`: With `--sync-board`, apply matching existing repo labels (`bug`, `enhancement`, `documentation`) to unlabeled added items.
31
+ - `--dry-run`: With `--sync-board`, preview planned board changes without writing.
32
+ - `--no-github`: Collect local Git metrics only without calling `gh`.
33
+ - `--json`: Return structured JSON instead of the Quest-Tree HUD.
34
+
35
+ Granted authority upon explicit `/recap` invocation:
36
+ - `A1` (Read-only repo, GitHub & Project v2): local read-only `git log` / `git status` / `git rev-list`, GitHub REST reads (`gh api`) under [Tool Depot](../../skills/tool-depot/SKILL.md) `github-read` (`read-approved-issue-or-pr`, `read-pr-review-and-checks`), and read-only Project v2 GraphQL queries when `--project` is passed. Keep issue/PR/CI reads on REST (`bbc recap`).
37
+ - `A2` (Board sync, only when explicitly requested): `--sync-board` mutates only the named `--project` board (and existing repo labels when `--apply-labels` is passed), never closing issues, merging PRs, or modifying local Git files. Preview with `--dry-run` first when the user has not explicitly approved the write target.
38
+
39
+ ## Hard Rules
40
+
41
+ - **Read-only by default.** Never write files, switch branches, push commits, or mutate issues, PRs, or boards unless `--sync-board` is explicitly authorized for that target project.
42
+ - **Preserve option IDs on color updates.** When `--fix-colors` updates a single-select field, always keep every option `id` so existing card assignments are never cleared.
43
+ - **No invented numbers.** Every count and ratio comes from `bbc recap` against real Git/GitHub output. When GitHub or local Git is unavailable, report `🟡 GAP` and `N/A` rather than guessing `0` or `100%`.
44
+ - **Objective effectiveness.** Report ratios (`merged/opened`, `CI passing`, `closed/created`) with traffic lights (`🟢` / `🟡` / `🔴` / `⚪ N/A`), never a fabricated score.
45
+ - Match the final HUD language to the user (`--lang es` or `--lang en`).
46
+
47
+ ## Decision Gates
48
+
49
+ | Situation | Action |
50
+ |---|---|
51
+ | Default invocation (`/recap`) | Run `npx -y @bbcsoftwarefactory/cli recap` for the current repo (`origin`) from local midnight today |
52
+ | `--all-repos` passed | Include all GitHub repositories for the user while keeping local Git metrics from the current working tree if present |
53
+ | `--project <url\|owner/n>` passed | Query Project v2 board columns, assignee breakdown, and sync diff (`missing_from_board`, `status_mismatches`) read-only |
54
+ | `--team` or `--users` passed | Collect per-member metrics across org members (or listed logins) and include them in the board cross-check |
55
+ | User asks to organize/sync the board | Run `--sync-board --dry-run` to preview, then apply `--sync-board` (with `--fix-colors` / `--apply-labels` as requested) once the target project is confirmed |
56
+ | `gh` missing or unauthenticated | Still run with local Git fallback and surface the explicit `🟡 GAP` in the HUD |
57
+ | Zero denominator in a ratio (e.g. `0` PRs opened) | Show `N/A` (or `<N> merged (0 opened)` when merges occurred from earlier days) |
58
+
59
+ ## Execution Steps
60
+
61
+ 1. Run `bbc recap` (via `npx -y @bbcsoftwarefactory/cli recap` or the linked `bbc` binary) with `--lang` matching the user's language (`es` or `en`) and any user-supplied flags (`--since`, `--all-repos`, `--repo`, `--user`, `--team`, `--users`, `--project`, `--sync-board`, `--fix-colors`, `--apply-labels`, `--dry-run`, `--no-github`, `--json`):
62
+ ```bash
63
+ npx -y @bbcsoftwarefactory/cli recap --lang es
64
+ ```
65
+ 2. Render the command's Quest-Tree HUD directly in chat. If the user asks for item links (`"detalle"`), rerun with `--json` (or include the `items` list from the JSON output) without inventing details.
66
+
67
+ ## Output Contract
68
+
69
+ Render the compact **Quest-Tree HUD** (`📊 RECAP ─ <repo> (@<user> · desde <since>)`) covering all 7 core items (plus `👥 Equipo`, `📋 Tablero`, and `🔄 Tablero organizado` when `--team`, `--project`, or `--sync-board` are used):
70
+ 1. `Issues creados`
71
+ 2. `Issues cerrados`
72
+ 3. `PRs enviados`
73
+ 4. `Aporte` (commits, files changed, `+ins/-del`, peer PRs reviewed/commented)
74
+ 5. `Solucionado` (PRs merged + issues closed)
75
+ 6. `Avance en curso` (active open PRs ready/draft, unpushed commits, local working changes)
76
+ 7. `Efectividad` (PR merge ratio, CI pass rate, issue close ratio)
77
+
78
+ Close with `🏁 STAGE CLEAR` when all sources succeeded, or list explicit `🟡 Gaps` when a source was unavailable or capped.
79
+
80
+ ## References
81
+
82
+ - [Install guide for Cursor, Zed, Claude Code, Claude, and Gemini](../../INSTALLATION.md)
83
+ - [Tool Depot catalog](../../skills/tool-depot/references/tool-catalog.json)
84
+ - [Commands reference](../../docs/commands.md)
@@ -0,0 +1,17 @@
1
+ ---
2
+ description: Read-only daily progress summary: issues created/closed, PRs opened/merged, commit/review contribution, work in progress, and effectiveness ratios (/recap)
3
+ ---
4
+
5
+ # /recap
6
+
7
+ Read and execute `SKILL.md` from the first existing path (single source of truth; do not duplicate or summarize its steps here):
8
+
9
+ 1. `.cursor/skills/recap/SKILL.md`
10
+ 2. `.claude/skills/recap/SKILL.md`
11
+ 3. `.agents/skills/recap/SKILL.md`
12
+ 4. `~/.cursor/skills/recap/SKILL.md`
13
+ 5. `~/.claude/skills/recap/SKILL.md`
14
+ 6. `~/.agents/skills/recap/SKILL.md`
15
+ 7. `commands/recap/SKILL.md`
16
+
17
+ Optional arguments: `--since <YYYY-MM-DD|Nh|Nd>`, `--all-repos`, `--repo <owner/repo>`, `--user <login>`, `--team`, `--users <u1,u2>`, `--project <url|owner/number>`, `--sync-board`, `--fix-colors`, `--apply-labels`, `--dry-run`, `--no-github`, `--json`.
@@ -0,0 +1,17 @@
1
+ description = "Read-only daily progress summary: issues created/closed, PRs opened/merged, commits/reviews contribution, work in progress, and effectiveness ratios (/recap)."
2
+
3
+ prompt = """
4
+ Execute the `/recap` command workflow from its single source of truth `SKILL.md`.
5
+
6
+ First, locate and read `SKILL.md` from the first existing path:
7
+ 1. `.gemini/skills/recap/SKILL.md`
8
+ 2. `.agents/skills/recap/SKILL.md`
9
+ 3. `~/.gemini/skills/recap/SKILL.md`
10
+ 4. `~/.agents/skills/recap/SKILL.md`
11
+ 5. `commands/recap/SKILL.md`
12
+
13
+ If none of those files exists, stop and ask the user to install `commands/recap` into `.gemini/skills/recap/` (or `~/.gemini/skills/recap/`) following `INSTALLATION.md`.
14
+
15
+ Otherwise, follow `SKILL.md` exactly without skipping steps.
16
+ Optional arguments passed by the user: {{args}}
17
+ """
@@ -0,0 +1,103 @@
1
+ {
2
+ "version": 1,
3
+ "clients": [
4
+ {
5
+ "id": "claude-code",
6
+ "name": "Claude Code",
7
+ "skills": {"project": ".claude/skills", "global": ".claude/skills"},
8
+ "detect": {"commands": ["claude"], "home": [".claude"], "project": [".claude"]},
9
+ "hook": {
10
+ "file": {"project": ".claude/settings.json", "global": ".claude/settings.json"},
11
+ "event": "Stop",
12
+ "format": "claude-hook",
13
+ "root": {},
14
+ "entry": {"hooks": [{"type": "command", "command": "{command}"}]}
15
+ },
16
+ "agents_md": false,
17
+ "manual": ["Start Claude Code in the project and enter /requirements-spec to confirm discovery."]
18
+ },
19
+ {
20
+ "id": "codex",
21
+ "name": "OpenAI Codex CLI",
22
+ "skills": {"project": ".codex/skills", "global": ".codex/skills"},
23
+ "detect": {"commands": ["codex"], "home": [".codex"], "project": [".codex"]},
24
+ "hook": {
25
+ "file": {"project": ".codex/hooks.json", "global": ".codex/hooks.json"},
26
+ "event": "Stop",
27
+ "format": "codex-hook",
28
+ "project_script": "git-toplevel",
29
+ "root": {},
30
+ "entry": {"hooks": [{"type": "command", "command": "{command}", "timeout": 10}]}
31
+ },
32
+ "agents_md": true,
33
+ "manual": ["Review and trust the new hook with /hooks in Codex CLI.", "Check the installed skills in Codex CLI's skills list."]
34
+ },
35
+ {
36
+ "id": "cursor",
37
+ "name": "Cursor",
38
+ "skills": {"project": ".cursor/skills", "global": ".cursor/skills"},
39
+ "detect": {"commands": ["cursor", "cursor-agent"], "home": [".cursor"], "project": [".cursor"]},
40
+ "hook": {
41
+ "file": {"project": ".cursor/hooks.json", "global": ".cursor/hooks.json"},
42
+ "event": "stop",
43
+ "format": "cursor-hook",
44
+ "root": {"version": 1},
45
+ "entry": {"command": "{command}", "loop_limit": 2}
46
+ },
47
+ "agents_md": false,
48
+ "manual": ["Open the project in Cursor and look for the skills in Agent's / menu (open a new chat)."]
49
+ },
50
+ {
51
+ "id": "zed",
52
+ "name": "Zed (native agent and Cursor over ACP)",
53
+ "skills": {"project": ".agents/skills", "global": ".agents/skills"},
54
+ "detect": {"commands": ["zed", "zeditor"], "home": [".config/zed", "AppData/Roaming/Zed", "Library/Application Support/Zed"], "project": [".zed"]},
55
+ "hook": null,
56
+ "agents_md": true,
57
+ "manual": ["Native agent: Settings > AI > Skills; keep the frontmatter catalog under 50 KB.", "Cursor over ACP: ... > Restart in the Agent Panel, open a new thread and type /."]
58
+ },
59
+ {
60
+ "id": "gemini-cli",
61
+ "name": "Gemini CLI",
62
+ "skills": {"project": ".gemini/skills", "global": ".gemini/skills"},
63
+ "commands_dir": {"project": ".gemini/commands", "global": ".gemini/commands"},
64
+ "detect": {"commands": ["gemini"], "home": [".gemini"], "project": [".gemini"]},
65
+ "hook": {
66
+ "file": {"project": ".gemini/settings.json", "global": ".gemini/settings.json"},
67
+ "event": "AfterAgent",
68
+ "format": "gemini-hook",
69
+ "root": {},
70
+ "entry": {"matcher": "*", "hooks": [{"name": "question-gate", "type": "command", "command": "{command}"}]}
71
+ },
72
+ "agents_md": false,
73
+ "manual": ["If Gemini CLI is open, run /commands reload and /skills reload, then /skills list."]
74
+ },
75
+ {
76
+ "id": "opencode",
77
+ "name": "OpenCode",
78
+ "skills": {"project": ".opencode/skills", "global": ".config/opencode/skills"},
79
+ "detect": {"commands": ["opencode"], "home": [".config/opencode"], "project": [".opencode"]},
80
+ "hook": null,
81
+ "agents_md": true,
82
+ "manual": ["Start OpenCode in the project and ask it to load requirements-spec with its skill tool."]
83
+ },
84
+ {
85
+ "id": "antigravity",
86
+ "name": "Google Antigravity",
87
+ "skills": {"project": ".agents/skills", "global": ".agents/skills"},
88
+ "detect": {"commands": ["antigravity"], "home": [".antigravity"], "project": []},
89
+ "hook": null,
90
+ "agents_md": true,
91
+ "manual": ["Reopen the workspace and ask the agent to use requirements-spec."]
92
+ },
93
+ {
94
+ "id": "pi",
95
+ "name": "Pi coding agent",
96
+ "skills": {"project": ".agents/skills", "global": ".agents/skills"},
97
+ "detect": {"commands": ["pi"], "home": [".pi"], "project": [".pi"]},
98
+ "hook": null,
99
+ "agents_md": true,
100
+ "manual": ["Run /reload in Pi, then enter /skill:requirements-spec."]
101
+ }
102
+ ]
103
+ }
@@ -0,0 +1,58 @@
1
+ ---
2
+ name: code-quality-gate
3
+ description: "Trigger: quality gate, post-wave gate, TypeSafe, EarlyReturn, BigO, code review gate. Enforce TypeSafe, Early Return, and Big O gates on changed code after each wave or before commit."
4
+ license: Apache-2.0
5
+ compatibility: Requires Node.js 22.18+ and Git; the diff scope extractor ships in the @bbcsoftwarefactory/cli package.
6
+ metadata:
7
+ author: bbc-skill-internals
8
+ version: "1.3"
9
+ pre_hook: "npx -y @bbcsoftwarefactory/cli extract-diff-scope --working|--staged|--range <base>..HEAD"
10
+ ---
11
+
12
+ ## Activation Contract
13
+
14
+ Run after every implementation wave, fix slice, or before committing to verify all added or modified TypeScript/JavaScript code passes three blocking quality gates: **TypeSafe**, **EarlyReturn**, and **BigO**.
15
+
16
+ **Company role:** Software Engineer self-check, run by the agent that implemented the slice. It does not replace peer review by a human code owner.
17
+
18
+ ## Hard Rules
19
+
20
+ - Scope to **added and modified lines** in the active wave or commit diff (including untracked new source files in `--working` mode). Do not rewrite untouched legacy code outside the slice.
21
+ - **No warn-only or silent bypass:** any confirmed violation in `typesafe`, `earlyreturn`, or `bigo` sets `gate.status: block` and must be fixed before advancing to the next wave or committing.
22
+ - Never approve or block from regex matches alone. Extract the diff with the bundled scope script, read surrounding function context, and verify semantically.
23
+ - Only documented exceptions (`external-boundary` for TypeSafe, bounded `fixture` `<= 10` items for BigO) may pass, and every exception must be recorded explicitly in `exceptions`.
24
+
25
+ ## Decision Gates
26
+
27
+ | Condition | Action |
28
+ |---|---|
29
+ | Diff contains zero `.ts`/`.tsx`/`.js`/`.jsx`/`.mts`/`.cts`/`.mjs`/`.cjs` files | Emit `gate.status: pass` with `files_changed: 0`. |
30
+ | Confirmed violation in TypeSafe, EarlyReturn, or BigO | Emit `gate.status: block`, remediate the exact file and line, rerun affected tests, and rerun this gate. |
31
+ | Valid `external-boundary` cast or bounded `<= 10` test fixture | Allow and record under `exceptions` with justification. |
32
+
33
+ ## Execution Steps
34
+
35
+ 1. Extract the wave or commit scope with `npx -y @bbcsoftwarefactory/cli extract-diff-scope` (`--working` after a wave, `--staged` before commit, or `--range <base>..HEAD` for a branch/PR slice).
36
+ 2. Inspect every added or modified record in its enclosing function and module against [TypeSafe](references/gate-typesafe.md), [EarlyReturn](references/gate-earlyreturn.md), and [BigO](references/gate-bigo.md).
37
+ 3. Run the repository typechecker (`tsc --noEmit`, `build.types`, or equivalent) and, if `skill-clean-architecture` is installed, verify Big O headers on touched source files.
38
+ 4. If `gate.status` is `block`, apply the minimal fix, rerun affected tests to keep GREEN, and repeat steps 1–3 until `gate.status: pass`.
39
+ 5. Return the final structured YAML verdict matching [Output schema](references/output-schema.yml).
40
+
41
+ ## Companion Handoffs
42
+
43
+ When a finding needs tests or architecture work, look for `regression-testing` or `skill-clean-architecture`. Pass the exact diff and relevant findings.
44
+
45
+ Check the active skill catalog for the named companion before relying on it. If availability is unknown and its help is needed, ask whether it is available; do not ask when equivalent evidence already satisfies the handoff. Never assume installation, install automatically, or transfer permissions.
46
+
47
+ ## Output Contract
48
+
49
+ - **In chat (agile HUD):** emit a single traffic-light line (`🛡️ **Quality:** 🟢 TypeSafe · EarlyReturn · BigO · Types` on `pass`, or `🔴 BLOCK` with exact `file:line -> fix` lines when `gate.status: block`).
50
+ - **Full YAML / ledger / `"detalle"`:** produce the strict YAML report matching [Output schema](references/output-schema.yml) (`scan`, `gates_checked: [typesafe, earlyreturn, bigo]`, `violations`, `exceptions`, `gate`, `actions_required`) plus the exact typecheck command and exit status.
51
+
52
+ ## References
53
+
54
+ - [Gate TypeSafe rules](references/gate-typesafe.md)
55
+ - [Gate EarlyReturn rules](references/gate-earlyreturn.md)
56
+ - [Gate BigO rules](references/gate-bigo.md)
57
+ - [Strict output YAML schema](references/output-schema.yml)
58
+ - [Wave diff scope extractor](../../packages/cli/src/extract-diff-scope.ts)
@@ -0,0 +1,31 @@
1
+ # Gate BigO
2
+
3
+ Added or modified code must not introduce avoidable superlinear time complexity. Aim for single-pass processing and `O(1)` lookups via `Map`/`Set` instead of repeated scans over unbounded collections.
4
+
5
+ ## Blocking Rule
6
+
7
+ Every confirmed violation is `severity: BLOCK`.
8
+
9
+ ## Violation Rules
10
+
11
+ | Rule ID | Pattern to Detect | Avoid | Prefer |
12
+ |---|---|---|---|
13
+ | `NESTED_LOOP` | Nested `for` / `forEach` / `map` over unbounded arrays (`O(n^2)` or `O(n*m)`) | `items.forEach(a => others.forEach(b => ...))` | Single pass or pre-indexed lookup |
14
+ | `LOOKUP_IN_LOOP` | `includes`, `indexOf`, `find`, `some`, or `filter` inside a loop over another collection | `list.filter(x => ids.includes(x.id))` | `const idSet = new Set(ids)` then `idSet.has(x.id)` |
15
+ | `FILTER_FIND_COMBO` | `filter(...).find(...)` or `filter(...).map(...)` inside an outer iteration | `rows.map(r => cols.filter(c => c.k === r.k))` | Pre-group once into a `Map<K, V[]>` |
16
+ | `LOOKUP_BY_INDEX` | Linear index scan inside another loop to match records by key | `for (i...) for (j...) if (a[j].id === b[i].id)` | `const byId = new Map(a.map(x => [x.id, x]))` |
17
+ | `REBUILD_PER_ITER` | Recomputing or filtering an invariant collection on every loop iteration | Inside `map`: `getAll().filter(...)` | Hoist invariant computation outside the loop |
18
+ | `SPREAD_IN_REDUCE` | Object/array spread inside `reduce` or loop (`{ ...acc, [k]: v }` or `[...acc, x]`), `O(n^2)` copies | `arr.reduce((acc, x) => ({ ...acc, [x.id]: x }), {})` | Mutate a local `Map` or pre-allocated object/array in one pass |
19
+
20
+ ## Documented Exception
21
+
22
+ | Case | Condition |
23
+ |---|---|
24
+ | `fixture` | Unit test or bounded static constant with explicit `<= 10` items. Record under `exceptions[]` with collection size. Never exempt unbounded runtime or user-supplied data. |
25
+
26
+ ## Semantic Checks
27
+
28
+ 1. Evaluate complexity only on added or modified lines in the diff scope.
29
+ 2. Treat collection sizes as unbounded unless a constant or explicit bound (`<= 10`) is visible in code.
30
+ 3. Do not micro-optimize tiny fixed tuples (`<= 3` static constants); target avoidable superlinear work over growing collections.
31
+ 4. When `skill-clean-architecture` is installed, run `bbc measure-bigo` on modified source files to keep file headers accurate.
@@ -0,0 +1,73 @@
1
+ # Gate EarlyReturn
2
+
3
+ New or modified functions must validate inputs first (guard clauses), exit early, and keep the happy path flat and readable.
4
+
5
+ ## Blocking Rule
6
+
7
+ Every confirmed violation is `severity: BLOCK`.
8
+
9
+ ## Violation Rules
10
+
11
+ | Rule ID | Pattern to Detect | Avoid | Prefer |
12
+ |---|---|---|---|
13
+ | `ELSE_AFTER_RETURN` | `else` immediately after a branch ending in `return`, `throw`, `continue`, or `break` | `if (x) { return a } else { return b }` | `if (x) return a` followed by `return b` |
14
+ | `GUARD_MISSING` | Late input/state validation forcing the main body inside a wrapper `if` | `if (input) { /* 20 lines */ }` | `if (!input) return` / `throw` at the top |
15
+ | `NESTING_DEPTH` | Conditional or loop+conditional nesting `> 2` levels inside added code | `if (a) { if (b) { if (c) { ... } } }` | Invert conditions, return early, or extract a focused helper |
16
+ | `ELSE_IF_CHAIN` | Long `else if` branch chain where guards or a `switch`/`Map` lookup is clearer | `if (k === 'a') ... else if (k === 'b') ... else if ...` | `switch`, `Map` dispatch, or independent guard returns |
17
+ | `TRY_NO_EARLY_EXIT` | Oversized `try` wrapping preconditions and happy path together | `try { validate(); work(); } catch ...` | Validate preconditions before `try`; wrap only the fallible I/O call |
18
+ | `CALLBACK_NESTED` | Nested `.then()` or nested callbacks inside async/event flows | `fetch(a).then(() => fetch(b).then(...))` | Sequential `await` with guard clauses between steps |
19
+ | `DUPLICATE_BRANCH_CALL` | Duplicating the same call across `if/else` or ternary branches solely to omit an optional `undefined` argument | `options ? await fn(a, b, options) : await fn(a, b)` | Single call `await fn(a, b, options)` (or build `resolvedOptions` once before calling) |
20
+
21
+ ## Bad Examples and Recommendations
22
+
23
+ ### 1. Duplicate branch call for an optional argument (`DUPLICATE_BRANCH_CALL`)
24
+
25
+ ```typescript
26
+ // AVOID: duplicates the entire call just to omit an optional parameter
27
+ const event = options
28
+ ? await this.fbpixel.buildPurchaseEvent(userId, amount, resolvedCurrency, browserData, userData, options)
29
+ : await this.fbpixel.buildPurchaseEvent(userId, amount, resolvedCurrency, browserData, userData)
30
+
31
+ // ALSO AVOID: early-return branch duplicating the exact same call
32
+ if (options) {
33
+ await this.trackEvents.trackEventPaySuccess(email, amount, data, userData, currency, resolvedOptions)
34
+ return
35
+ }
36
+ await this.trackEvents.trackEventPaySuccess(email, amount, data, userData, currency)
37
+ ```
38
+
39
+ ```typescript
40
+ // PREFER: compute options once, invoke once
41
+ const resolvedOptions = options ? { ...options, eventId } : undefined
42
+ const event = await this.fbpixel.buildPurchaseEvent(
43
+ userId,
44
+ amount,
45
+ resolvedCurrency,
46
+ browserData,
47
+ userData,
48
+ resolvedOptions,
49
+ )
50
+ ```
51
+
52
+ **Recommendations:**
53
+ - Never duplicate a multi-argument function call in production code just to satisfy a brittle exact-arity spy (`expect(fn).toHaveBeenCalledWith(a, b)`). Pass the optional `options` argument in one call and update the test expectation to include `undefined` or `expect.objectContaining(...)`.
54
+ - When conditional properties belong inside an options object, construct `resolvedOptions` before the call and keep a single invocation.
55
+ - Flatten post-call `if (result.success) { ... } else { ... }` blocks by handling the failure path with an early `return` first.
56
+
57
+ ## Reference Pattern
58
+
59
+ ```typescript
60
+ // Prefer: guard clauses first, flat happy path
61
+ function sendMessage(message: Message): SendResult {
62
+ if (!message.recipient) throw new Error('Missing recipient')
63
+ if (!message.body) throw new Error('Missing body')
64
+
65
+ return channel.send(message)
66
+ }
67
+ ```
68
+
69
+ ## Semantic Checks
70
+
71
+ 1. Do validation guards appear before business logic so the happy path sits at minimum indentation?
72
+ 2. Can any `3+` level nested block be flattened by inverting a condition and returning early?
73
+ 3. Do not flag legitimate structures dogmatically: flat `if (a && b)` checks and clean `switch` statements with early `return` per case are compliant.
@@ -0,0 +1,32 @@
1
+ # Gate TypeSafe
2
+
3
+ Added or modified code must preserve compiler-verified type invariants without unsafe escapes.
4
+
5
+ ## Blocking Rule
6
+
7
+ Every confirmed violation is `severity: BLOCK`. There is no warn-only mode.
8
+
9
+ ## Violation Rules
10
+
11
+ | Rule ID | Pattern to Detect | Avoid | Prefer |
12
+ |---|---|---|---|
13
+ | `ANY_UNJUSTIFIED` | `: any` or `as any` in added lines | `const x: any = getThing()` | Real type or `unknown` + type guard narrowing |
14
+ | `CAST_UNSAFE` | `as T` on `unknown` or a union without prior narrowing | `const id = raw as string` | `typeof raw === 'string' ? raw : fallback` or type guard |
15
+ | `NON_NULL_UNSAFE` | `!` on a nullable value without an earlier guard in the same function | `user!.email` | `user?.email` or `if (!user) return` / `throw` |
16
+ | `TS_IGNORE_UNJUSTIFIED` | `@ts-ignore` or `@ts-expect-error` without an inline root-cause comment | `// @ts-ignore` | Fix the underlying type; if unavoidable, `@ts-expect-error` with explanation |
17
+ | `UNKNOWN_DUMP` | Casting `unknown` directly to a concrete interface without runtime validation | `(payload as Payload).id` | Runtime schema/type-guard check before reading fields |
18
+ | `ANY_FROM_GENERIC` | Generics defaulting or instantiated with `any` | `function f<T = any>()` | Constrain `<T extends ...>` or pass explicit concrete type argument |
19
+ | `COMPILER_SILENCER` | Disabling type checks (`@ts-nocheck`, bare `as unknown as T`) | `// @ts-nocheck` | Define DTO/declaration at the boundary and narrow properly |
20
+
21
+ ## Documented Exception
22
+
23
+ | Case | Condition |
24
+ |---|---|
25
+ | `external-boundary` | Untyped third-party SDK/wire boundary only: single entry-point `as unknown as T` accompanied by a cause comment and immediate runtime narrowing/DTO mapping. Record under `exceptions[]`. |
26
+
27
+ ## Semantic Checks
28
+
29
+ 1. Did the added line introduce a type escape that did not exist before?
30
+ 2. Is a concrete domain/DTO type available instead of `any` or an unchecked cast?
31
+ 3. For `!`, is there an explicit guard (`if (!x) return/throw`) in the same function scope?
32
+ 4. For `@ts-expect-error`, does it fail cleanly if the upstream type improves?
@@ -0,0 +1,40 @@
1
+ # Strict output schema — code-quality-gate
2
+
3
+ scan:
4
+ mode: working | staged | range | head # required
5
+ range: string # required when mode = range
6
+ files_changed: int # required
7
+ lines_added: int # required
8
+ gates_checked: # required: always all 3
9
+ - typesafe
10
+ - earlyreturn
11
+ - bigo
12
+
13
+ violations: # empty list [] when gate.status = pass
14
+ - gate: typesafe | earlyreturn | bigo # required
15
+ rule: string # required: rule ID from references/gate-*.md
16
+ file: string # required
17
+ line: int # required
18
+ match: string # required: offending line content
19
+ severity: BLOCK # required
20
+
21
+ exceptions: # empty list [] when none used
22
+ - gate: typesafe | bigo # required
23
+ type: external-boundary | fixture # required
24
+ file: string # required
25
+ line: int # required
26
+ justification: string # required
27
+
28
+ gate:
29
+ status: pass | block # required
30
+ reason: string # required
31
+ gates_failed: # required when status = block
32
+ - typesafe
33
+ - earlyreturn
34
+ - bigo
35
+ pass_conditions: string # required when status = block
36
+
37
+ actions_required: # required (>= 1 P0) when block; [] when pass
38
+ - priority: P0 | P1 # required
39
+ action: string # required: file:line + concrete verb
40
+ suggestion: string # required: exact fix or command