Skip to content

Commit fb40407

Browse files
committed
ci: add contributor guidelines, agent skills and commit message checks
Contributors and AI agents had no shared rules for commits, code or UI, so every change drifted a little from the last one. Add guides for the commit format, coding standards, UI and fixup commits, skills and roles that carry the same rules for agents, git hooks that format staged files and check commit messages, a CI workflow that validates the pull request title and every commit, a skills check, and pull request and issue templates.
1 parent 1c6eea1 commit fb40407

28 files changed

Lines changed: 1025 additions & 53 deletions

‎.claude/agents/a11y-reviewer.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: a11y-reviewer
3+
description: Audits the devtools panel and the demo app for accessibility and visual consistency with axe, contrast checks and keyboard walkthroughs. Use before a pull request that changes UI, or when asked to review a page.
4+
tools: Read, Grep, Glob, Bash
5+
---
6+
7+
You review accessibility and visual consistency. You don't edit files; you report.
8+
9+
Follow the browser checks in the `devtools-verify` skill: run axe on each page in dark and light color schemes, check horizontal overflow at 1280px and 360px, and walk every interactive element with the keyboard (focus visible, arrow keys in trees and lists, `Escape` closes popups and clears search). Check text contrast by hand where axe can't (gradients, text over images) and compare each page against `docs/contributing/ui-guidelines.md`.
10+
11+
Report findings ranked by user impact, each with the page, the element, what fails (rule or measured contrast), and a concrete fix. Say which pages you checked and how.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: devtools-reviewer
3+
description: Reviews a change or pull request against this repository's coding standards, commit guidelines and data-collection rules. Use before opening a pull request or when asked to review a diff.
4+
tools: Read, Grep, Glob, Bash
5+
---
6+
7+
You review changes to the Angular devtools. You don't edit files; you report.
8+
9+
Check the diff against:
10+
11+
- `docs/contributing/coding-standards.md`: TypeScript and Angular rules, and the page-side rules (debug APIs, stable ids, no DOM writes, `pageId`, expiry, cheap pushes, safe serialization).
12+
- `docs/contributing/ui-guidelines.md` for anything under `app/`.
13+
- `docs/contributing/commit-message-guidelines.md` for commit messages and the pull request title.
14+
- Tests: every behavior change has one, and agent tools changed together with their tests and descriptions.
15+
- Generated output: `extension/ui` rebuilt and committed when `app/` changed.
16+
17+
Verify claims by reading the code, and run `pnpm test:devtools` and the `ngc` template check when in doubt. Report only real problems, ranked by impact, each with file:line, what is wrong, why it matters and a concrete fix.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: inspector-engineer
3+
description: Owns how inspectors collect data from the running app and serve it to the panel and to agents. Use for new inspectors, wrong or noisy data, unstable ids, tabs overwriting each other, heavy polling, and new MCP tools.
4+
---
5+
6+
You are the inspector engineer for the Angular devtools.
7+
8+
Follow the `devtools-inspector` skill and the "Reading data from the page" section of `docs/contributing/coding-standards.md`. Read Angular through its debug APIs and check every field you rely on against `node_modules/@angular/core/fesm2022`. Keep ids stable with `WeakMap`s, never write to the app's DOM, send `pageId` with every report, expire and forget pages on the server, and skip unchanged pushes.
9+
10+
Put new logic in its own module and keep edits to `overlay.ts` and `devframe.ts` small. Add jsdom tests with a fake `ng` for every collector change and keep `pnpm test:devtools` green.
11+
12+
Return a short summary: what was wrong, what you changed (file:line), the tests you added, and anything left undone.

‎.claude/agents/ui-engineer.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: ui-engineer
3+
description: Builds and restyles pages in the devtools panel (app/) so they match the design system, work with the keyboard and pass axe. Use for new inspector pages, UI polish, dropdowns, toolbars, empty states and theme changes.
4+
---
5+
6+
You are the UI engineer for the Angular devtools panel.
7+
8+
Follow the `devtools-ui` skill and `docs/contributing/ui-guidelines.md`. Use the theme variables and SCSS mixins, the shared `app-select` dropdown and the page anatomy (intro, sticky toolbar, list or tree with a detail panel, loading, error, empty and no-match states). Headings start at `h2`.
9+
10+
Don't change RPC names, data shapes or behavior. If the data a page shows is wrong, stop and report it for the inspector engineer instead of working around it in the template.
11+
12+
Before you finish, run the checks in the `devtools-verify` skill that apply to UI (format, `ngc` template check, the axe and 360px audit on the pages you touched) and list what you ran. Return a short summary of what changed, per file.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: devtools-commit
3+
description: Write commit messages and pull request titles and descriptions for this repository, following this project's commit format and scopes. Use whenever you commit, split work into commits, or open or update a pull request.
4+
---
5+
6+
# Commits and pull requests
7+
8+
The rules are in `docs/contributing/commit-message-guidelines.md`. Summary:
9+
10+
```
11+
<type>(<scope>): <short summary>
12+
13+
<body: why the change is needed, old vs new behavior, imperative tense, 20+ characters>
14+
15+
<footer: Fixes #123 | BREAKING CHANGE: ... | DEPRECATED: ...>
16+
```
17+
18+
- Types: `feat`, `fix`, `perf`, `refactor`, `test`, `docs`, `build`, `ci`, `revert`.
19+
- Scopes: `hub`, `ui`, `popup`, `overlay`, `components`, `signals`, `injectors`, `router`, `forms`, `store`, `pipes`, `http`, `analog`, `mcp`, `extension`, `vite`, `demo`, `deps`. Leave the scope out for cross-cutting changes.
20+
- Summary: imperative, lowercase first letter, no period, header under 100 characters.
21+
22+
## Pull requests
23+
24+
- Pull requests are squash merged; the title becomes the commit on `main`, so it must follow the header format.
25+
- A `commit-msg` hook (`scripts/commit-message.mjs`, enabled by `pnpm install`) warns about a bad message as you commit; CI rejects it, checking the title and every commit in the pull request. Run `pnpm commit:check` before pushing, and fix flagged messages with `git commit --amend` or a reword rebase.
26+
- Address review feedback with fixup commits (`docs/contributing/using-fixup-commits.md`).
27+
- One feature per pull request, with its tests (including agent tool tests when tools change).
28+
- Rebuild and commit `extension/ui` when `app/` changed.
29+
- Fill in `.github/PULL_REQUEST_TEMPLATE.md`: what changed and why, how it was verified (see the `devtools-verify` skill), screenshots for UI changes.
30+
- Don't add AI attribution lines to commits or pull requests unless the maintainers ask for them.
31+
32+
## Splitting work
33+
34+
Group commits by area (the scope), keep each one building and passing tests where practical, and put generated output (`extension/ui`, lockfile) in the commit that needs it.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
name: devtools-inspector
3+
description: Add or fix how an inspector collects data, from the page-side overlay through the devframe server to the panel and the MCP tools. Use for new inspectors, wrong or noisy data, unstable selection, tabs overwriting each other, heavy polling, and new agent tools.
4+
---
5+
6+
# Inspector data pipeline
7+
8+
Every inspector follows the same path:
9+
10+
```
11+
app page (overlay.ts + <area>-collector.ts)
12+
-> rpc.call('push-<area>', { pageId, ... })
13+
-> devframe.ts: per-page Map, shared state '<area>', expiry, forget-<area>-page
14+
-> panel page (app/src/pages/<area>.ts) via rpc.sharedState('<area>')
15+
-> agent tools (ctx.agent.registerTool) and MCP resources
16+
```
17+
18+
Read `docs/contributing/coding-standards.md` ("Reading data from the page") before you start.
19+
20+
## Page side (`packages/ng-devtools/src`)
21+
22+
- Put collection logic in its own module (`<area>-collector.ts`) and keep `overlay.ts` changes to wiring: import, attach, push, `leave()` and the returned cleanup.
23+
- Read Angular through the debug APIs on `window.ng` and verify each field against `node_modules/@angular/core/fesm2022` (or the library's fesm build). Known helpers:
24+
- `element-id.ts`: stable `WeakMap` ids for elements (`elementId`, `elementById`).
25+
- `injector-tree.ts`: `className()` strips bundler `_` prefixes, `tokenName()`, `dependenciesOf()`, environment injector walk.
26+
- `serialize.ts`: safe, size-limited serialization.
27+
- `router.ts` `providerOf()`: find a service through the injector resolution path.
28+
- Never write attributes into the app's DOM. Never run app code (validators, guards) on a timer unless the user turned recording on.
29+
- Pushes: send on change, skip unchanged payloads (compare with the last JSON), re-send every few cycles so the server doesn't expire the page, and avoid full DOM scans on a timer (cache, rescan after a `MutationObserver` signal).
30+
- Every report carries `pageId` from `claimPageId()`. Call `forget-<area>-page` from `leave()`.
31+
32+
## Server side (`devframe.ts`, `rpc/`)
33+
34+
- Keep a `Map<pageId, report>` with `reportedAt`, drop pages older than 15 seconds in the shared expiry interval, and write the combined value into the shared state.
35+
- Page actions that the panel triggers (restore, highlight, run) go panel -> `request-<area>-action` -> broadcast `<area>-action` to the page -> `<area>-action-result`, keyed by `requestId`, with a timeout.
36+
- Source scans in `rpc/` enrich or stand in for live data. They must return a `kind` for anything the Dashboard counts.
37+
38+
## Panel side
39+
40+
- Subscribe with `const state = await rpc.sharedState('<area>'); apply(state.value()); state.on('updated', apply)` and remove the listener through `DestroyRef`. There is no `subscribe()` on shared state.
41+
- Filter to the current page with the `?pageId` host parameter when the page can show several tabs; offer an "All pages" option.
42+
- Then follow the `devtools-ui` skill for the page itself.
43+
44+
## Agent tools
45+
46+
- Describe what the tool returns, where the data comes from and what an empty answer means. Answer in markdown.
47+
- Update descriptions in `devframe.ts` when data shapes change, and the README tool list.
48+
49+
## Tests
50+
51+
- Collector tests run in jsdom with a fake `ng` (see `__tests__/injector-tree.test.ts`, `component-tree.test.ts`, `ngrx-collector.test.ts`). Cover stable ids, dedupe, expiry and the Angular shapes you rely on.
52+
- Server tests call the RPC handlers directly (see `http-server.test.ts`, `agent-tools.test.ts`).
53+
- `pnpm test:devtools` must stay green.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
name: devtools-ui
3+
description: Build or change any page, component or style in the devtools panel (app/). Use for new inspector pages, restyles, dropdowns, toolbars, empty states, theme or palette changes, and any UI/UX or accessibility work in the panel.
4+
---
5+
6+
# Devtools panel UI
7+
8+
Read `docs/contributing/ui-guidelines.md` first; it is the source of truth for the theme, tokens and page anatomy. This skill is the working checklist.
9+
10+
## Before you write code
11+
12+
1. Open two recently built pages as references: `app/src/pages/di-inspector.ts` (tree + detail, keyboard, highlight) and `app/src/pages/network-inspector.ts` (toolbar, tables, forms, `app-select`).
13+
2. Check which data the page gets and from where (`client.scope('ng-devtools').rpc.call(...)` or `rpc.sharedState(...)`). UI work must not change RPC names or data shapes; if the data is wrong, use the `devtools-inspector` skill.
14+
15+
## Rules
16+
17+
- Styles are SCSS in the component `styles` field, starting with `@use 'mixins' as m;`.
18+
- Colors only through CSS variables (`--surface`, `--text-2`, `--accent`, ...). No hex values except brand colors on their own view (NgRx purple, Angular gradient, Analog, NativeScript, Capacitor).
19+
- Controls are `var(--control-h)` tall. Use `app/src/ui/select.ts` for every dropdown; never a native `<select>`.
20+
- Page structure: intro line, sticky toolbar (search with icon and `Escape` to clear, filters, count, actions), content (list or tree plus sticky detail on wide screens), and loading, error with Retry, empty and no-match states.
21+
- Headings start at `h2` and never skip a level. Section labels use `m.label`.
22+
- Rows are keyboard reachable (buttons or ARIA tree items with arrow keys). Selection is keyed by stable ids from the page.
23+
- Rows that map to an element in the app call `request-page-highlight` on hover and focus, and clear it on leave and blur.
24+
- Focus: `m.focus-ring` (use `-2px` inside scroll containers). Inputs use `m.field-focus`.
25+
- Motion 150 to 350ms, disabled under `prefers-reduced-motion`.
26+
- Angular: signals, `computed`, `linkedSignal`, `input`/`output`/`model`, `inject`, native control flow, `class`/`style` bindings, `host` object. No `any` in new code.
27+
- Copy: short and plain, no em dashes, never compare with other tools.
28+
- A new tab also needs: the `Tab` union in `app/src/types/tab.types.ts`, `allTabs` and the template switch in `app/src/app.ts`, an icon case in `tab-icon.ts`, and usually a Dashboard card.
29+
30+
## Changing the brand
31+
32+
Edit `app/src/styles/main.scss` (`$accent`) or the maps in `_palette.scss`. Never override tokens inside a page.
33+
34+
## Verify
35+
36+
Use the `devtools-verify` skill: template check with `ngc`, rebuild `extension/ui`, then the axe and 360px overflow audit on every page you touched, in the popup and at `/__devframes/`.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
name: devtools-verify
3+
description: Verify a devtools change the way CI and a reviewer would, then check it in a real browser with axe. Use before saying a change is done, before committing, and before opening a pull request.
4+
---
5+
6+
# Verify a change
7+
8+
## 1. The CI checks
9+
10+
Run them in this order; all must pass:
11+
12+
```sh
13+
pnpm format:check
14+
pnpm commit:check
15+
pnpm skills:check
16+
pnpm typecheck
17+
pnpm test
18+
pnpm test:devtools
19+
pnpm build
20+
pnpm extension:build
21+
pnpm devtools:build-pkg
22+
git status --porcelain -- extension/ui # must be committed when app/ changed
23+
```
24+
25+
`pnpm typecheck` does not type-check panel templates. Also run:
26+
27+
```sh
28+
NO_COLOR=1 pnpm exec ngc -p app/tsconfig.json --noEmit
29+
```
30+
31+
and treat any `error TS` or `error NG` line as a failure. Strip color codes before grepping the output, or errors slip through.
32+
33+
## 2. Run the demos
34+
35+
`pnpm build` is a production build and turns the in-page launcher off. For manual checks rebuild in development mode:
36+
37+
```sh
38+
pnpm build --configuration development
39+
node dist/angular-devtools/server/server.mjs # Angular Travel on :4000
40+
pnpm analog:dev # Analog demo on :5173
41+
```
42+
43+
Open the panel through the amber launcher on the page, at `/__devframes/`, and directly at `/__devframes/ng-devtools/?view=angular#tab=<tab>`.
44+
45+
## 3. Browser checks
46+
47+
With Playwright and `@axe-core/playwright` (install them in a scratch folder, not in the repo):
48+
49+
- Every page you touched, in dark and light color schemes: axe reports no violations, there are no page errors, and `document.documentElement.scrollWidth <= innerWidth` at 1280px and 360px wide.
50+
- Hub docks: clicking each rail button shows the matching view and only one frame (the rail selection and the content must match after fast switching and after a reload).
51+
- The feature itself, with real data from the demo app (for example `/examples/<area>`).
52+
53+
Exclude the launcher (`#ng-devtools-popup-root`) from axe runs on demo pages; it is checked through the panel.
54+
55+
## 4. Report honestly
56+
57+
Say which checks ran and their results. If something was skipped (no browser, no build), say so.

‎.gitattributes‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
extension/ui/** linguist-generated=true
2+
pnpm-lock.yaml linguist-generated=true
3+
*.mjs text eol=lf
4+
.githooks/* text eol=lf

‎.githooks/commit-msg‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
node "$(git rev-parse --show-toplevel)/scripts/commit-message.mjs" --file "$1" || echo "WARNING: this commit message does not follow the guidelines."
3+
exit 0

0 commit comments

Comments
 (0)