From 653d66e70075ca60ecdbd2b12e6470b3640af303 Mon Sep 17 00:00:00 2001 From: Kam Date: Mon, 28 Sep 2026 15:29:02 +0300 Subject: [PATCH 01/16] 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. --- .claude/agents/a11y-reviewer.md | 11 ++ .claude/agents/devtools-reviewer.md | 17 ++ .claude/agents/inspector-engineer.md | 12 ++ .claude/agents/ui-engineer.md | 12 ++ .claude/skills/devtools-commit/SKILL.md | 34 ++++ .claude/skills/devtools-inspector/SKILL.md | 53 +++++++ .claude/skills/devtools-ui/SKILL.md | 36 +++++ .claude/skills/devtools-verify/SKILL.md | 57 +++++++ .gitattributes | 4 + .githooks/commit-msg | 3 + .githooks/pre-commit | 8 + .github/ISSUE_TEMPLATE/bug_report.yml | 48 ++++++ .github/ISSUE_TEMPLATE/feature_request.yml | 29 ++++ .github/PULL_REQUEST_TEMPLATE.md | 26 ++++ .github/workflows/ci.yml | 3 + .github/workflows/commit-message.yml | 32 ++++ .gitmessage | 16 ++ AGENTS.md | 17 ++ CLAUDE.md | 17 ++ CONTRIBUTING.md | 131 +++++++++------- README.md | 21 +++ docs/contributing/coding-standards.md | 50 ++++++ .../contributing/commit-message-guidelines.md | 104 +++++++++++++ docs/contributing/ui-guidelines.md | 69 +++++++++ docs/contributing/using-fixup-commits.md | 35 +++++ package.json | 3 + scripts/commit-message.mjs | 145 ++++++++++++++++++ scripts/validate-skills.mjs | 85 ++++++++++ 28 files changed, 1025 insertions(+), 53 deletions(-) create mode 100644 .claude/agents/a11y-reviewer.md create mode 100644 .claude/agents/devtools-reviewer.md create mode 100644 .claude/agents/inspector-engineer.md create mode 100644 .claude/agents/ui-engineer.md create mode 100644 .claude/skills/devtools-commit/SKILL.md create mode 100644 .claude/skills/devtools-inspector/SKILL.md create mode 100644 .claude/skills/devtools-ui/SKILL.md create mode 100644 .claude/skills/devtools-verify/SKILL.md create mode 100644 .gitattributes create mode 100755 .githooks/commit-msg create mode 100755 .githooks/pre-commit create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/commit-message.yml create mode 100644 .gitmessage create mode 100644 docs/contributing/coding-standards.md create mode 100644 docs/contributing/commit-message-guidelines.md create mode 100644 docs/contributing/ui-guidelines.md create mode 100644 docs/contributing/using-fixup-commits.md create mode 100755 scripts/commit-message.mjs create mode 100644 scripts/validate-skills.mjs diff --git a/.claude/agents/a11y-reviewer.md b/.claude/agents/a11y-reviewer.md new file mode 100644 index 0000000..7c3d02a --- /dev/null +++ b/.claude/agents/a11y-reviewer.md @@ -0,0 +1,11 @@ +--- +name: a11y-reviewer +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. +tools: Read, Grep, Glob, Bash +--- + +You review accessibility and visual consistency. You don't edit files; you report. + +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`. + +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. diff --git a/.claude/agents/devtools-reviewer.md b/.claude/agents/devtools-reviewer.md new file mode 100644 index 0000000..3f5bec5 --- /dev/null +++ b/.claude/agents/devtools-reviewer.md @@ -0,0 +1,17 @@ +--- +name: devtools-reviewer +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. +tools: Read, Grep, Glob, Bash +--- + +You review changes to the Angular devtools. You don't edit files; you report. + +Check the diff against: + +- `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). +- `docs/contributing/ui-guidelines.md` for anything under `app/`. +- `docs/contributing/commit-message-guidelines.md` for commit messages and the pull request title. +- Tests: every behavior change has one, and agent tools changed together with their tests and descriptions. +- Generated output: `extension/ui` rebuilt and committed when `app/` changed. + +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. diff --git a/.claude/agents/inspector-engineer.md b/.claude/agents/inspector-engineer.md new file mode 100644 index 0000000..1ba46c5 --- /dev/null +++ b/.claude/agents/inspector-engineer.md @@ -0,0 +1,12 @@ +--- +name: inspector-engineer +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. +--- + +You are the inspector engineer for the Angular devtools. + +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. + +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. + +Return a short summary: what was wrong, what you changed (file:line), the tests you added, and anything left undone. diff --git a/.claude/agents/ui-engineer.md b/.claude/agents/ui-engineer.md new file mode 100644 index 0000000..9e9d631 --- /dev/null +++ b/.claude/agents/ui-engineer.md @@ -0,0 +1,12 @@ +--- +name: ui-engineer +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. +--- + +You are the UI engineer for the Angular devtools panel. + +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`. + +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. + +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. diff --git a/.claude/skills/devtools-commit/SKILL.md b/.claude/skills/devtools-commit/SKILL.md new file mode 100644 index 0000000..8a7ec5a --- /dev/null +++ b/.claude/skills/devtools-commit/SKILL.md @@ -0,0 +1,34 @@ +--- +name: devtools-commit +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. +--- + +# Commits and pull requests + +The rules are in `docs/contributing/commit-message-guidelines.md`. Summary: + +``` +(): + + + + +``` + +- Types: `feat`, `fix`, `perf`, `refactor`, `test`, `docs`, `build`, `ci`, `revert`. +- 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. +- Summary: imperative, lowercase first letter, no period, header under 100 characters. + +## Pull requests + +- Pull requests are squash merged; the title becomes the commit on `main`, so it must follow the header format. +- 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. +- Address review feedback with fixup commits (`docs/contributing/using-fixup-commits.md`). +- One feature per pull request, with its tests (including agent tool tests when tools change). +- Rebuild and commit `extension/ui` when `app/` changed. +- Fill in `.github/PULL_REQUEST_TEMPLATE.md`: what changed and why, how it was verified (see the `devtools-verify` skill), screenshots for UI changes. +- Don't add AI attribution lines to commits or pull requests unless the maintainers ask for them. + +## Splitting work + +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. diff --git a/.claude/skills/devtools-inspector/SKILL.md b/.claude/skills/devtools-inspector/SKILL.md new file mode 100644 index 0000000..8016d8b --- /dev/null +++ b/.claude/skills/devtools-inspector/SKILL.md @@ -0,0 +1,53 @@ +--- +name: devtools-inspector +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. +--- + +# Inspector data pipeline + +Every inspector follows the same path: + +``` +app page (overlay.ts + -collector.ts) + -> rpc.call('push-', { pageId, ... }) + -> devframe.ts: per-page Map, shared state '', expiry, forget--page + -> panel page (app/src/pages/.ts) via rpc.sharedState('') + -> agent tools (ctx.agent.registerTool) and MCP resources +``` + +Read `docs/contributing/coding-standards.md` ("Reading data from the page") before you start. + +## Page side (`packages/ng-devtools/src`) + +- Put collection logic in its own module (`-collector.ts`) and keep `overlay.ts` changes to wiring: import, attach, push, `leave()` and the returned cleanup. +- 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: + - `element-id.ts`: stable `WeakMap` ids for elements (`elementId`, `elementById`). + - `injector-tree.ts`: `className()` strips bundler `_` prefixes, `tokenName()`, `dependenciesOf()`, environment injector walk. + - `serialize.ts`: safe, size-limited serialization. + - `router.ts` `providerOf()`: find a service through the injector resolution path. +- Never write attributes into the app's DOM. Never run app code (validators, guards) on a timer unless the user turned recording on. +- 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). +- Every report carries `pageId` from `claimPageId()`. Call `forget--page` from `leave()`. + +## Server side (`devframe.ts`, `rpc/`) + +- Keep a `Map` with `reportedAt`, drop pages older than 15 seconds in the shared expiry interval, and write the combined value into the shared state. +- Page actions that the panel triggers (restore, highlight, run) go panel -> `request--action` -> broadcast `-action` to the page -> `-action-result`, keyed by `requestId`, with a timeout. +- Source scans in `rpc/` enrich or stand in for live data. They must return a `kind` for anything the Dashboard counts. + +## Panel side + +- Subscribe with `const state = await rpc.sharedState(''); apply(state.value()); state.on('updated', apply)` and remove the listener through `DestroyRef`. There is no `subscribe()` on shared state. +- Filter to the current page with the `?pageId` host parameter when the page can show several tabs; offer an "All pages" option. +- Then follow the `devtools-ui` skill for the page itself. + +## Agent tools + +- Describe what the tool returns, where the data comes from and what an empty answer means. Answer in markdown. +- Update descriptions in `devframe.ts` when data shapes change, and the README tool list. + +## Tests + +- 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. +- Server tests call the RPC handlers directly (see `http-server.test.ts`, `agent-tools.test.ts`). +- `pnpm test:devtools` must stay green. diff --git a/.claude/skills/devtools-ui/SKILL.md b/.claude/skills/devtools-ui/SKILL.md new file mode 100644 index 0000000..de0c4b8 --- /dev/null +++ b/.claude/skills/devtools-ui/SKILL.md @@ -0,0 +1,36 @@ +--- +name: devtools-ui +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. +--- + +# Devtools panel UI + +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. + +## Before you write code + +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`). +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. + +## Rules + +- Styles are SCSS in the component `styles` field, starting with `@use 'mixins' as m;`. +- 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). +- Controls are `var(--control-h)` tall. Use `app/src/ui/select.ts` for every dropdown; never a native ``; the system popup ignores the theme. +- **Tab icons**: `app/src/pages/tab-icon.ts`, Lucide-style 24px strokes. Add a case when you add a tab. +- **Global baselines** in `_base.scss`: tabular numbers, textarea sizing, focus fallback, reduced motion. + +## Anatomy of an inspector page + +1. **Intro**: one or two sentences saying what the page shows and where the data comes from (live page or source scan). +2. **Toolbar**: sticky, with a search field (icon, `Escape` clears), filters as chips or `app-select`, a count ("12 of 40"), and actions. Controls are `var(--control-h)` tall. +3. **Content**: a list or tree on the left, a detail panel on the right on wide screens (sticky), stacked below 880px. +4. **States**: every page has loading, error (with Retry), empty (explains how to get data) and no-match (with Clear filters) states. Never leave a blank area. + +Headings start at `h2` inside a page (the shell owns the `h1`) and never skip a level. Use `m.label` for small uppercase section labels. + +## Interaction + +- Rows are buttons or ARIA tree items; arrow keys move, `Home` and `End` jump, `Enter` selects, left and right collapse and expand. +- Hovering or focusing a row that maps to an element in the app highlights it there through the `request-page-highlight` RPC. +- Selection is keyed by a stable id from the page, so it survives refreshes. +- Motion is short (150 to 350ms) and respects `prefers-reduced-motion`. + +## Accessibility checklist + +- Text contrast at least 4.5:1 (3:1 for large text and UI outlines). Check gradients at their darkest stop. +- Every control has a label (`