Skip to content

Commit 3f6a900

Browse files
authored
feat(mcp): performance and build inspectors, native fetch, server errors, oxlint ratchet (#489)
Refs #372, #373, #369
1 parent 261d638 commit 3f6a900

111 files changed

Lines changed: 10069 additions & 2623 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.claude/skills/devtools-inspector/SKILL.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Read `docs/contributing/coding-standards.md` ("Reading data from the page") befo
2121

2222
- 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.
2323
- 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+
- `debug-api.ts`: `NgDebugApi`, the typed `window.ng` with `@since` notes, and `pageDebugApi()`. Add a function there (and to `NG_DEBUG_FUNCTIONS`) before a collector reads it.
2425
- `element-id.ts`: stable `WeakMap` ids for elements (`elementId`, `elementById`).
2526
- `injector-tree.ts`: `className()` strips bundler `_` prefixes, `tokenName()`, `dependenciesOf()`, environment injector walk.
2627
- `serialize.ts`: safe, size-limited serialization.
@@ -31,6 +32,8 @@ Read `docs/contributing/coding-standards.md` ("Reading data from the page") befo
3132

3233
## Server side (`devframe.ts`, `rpc/`)
3334

35+
- `devframe.ts` wires the setup. A new inspector goes in its own `rpc/<area>-register.ts` (see `rpc/errors-register.ts`), and agent tools of an existing area live in `devframe-<area>-tools.ts`, which take the setup values they read as an `env` object typed through `devframe-env.ts`. Keep `devframe.ts` under the line ratchet of `pnpm lint`.
36+
3437
- Keep a `Map<pageId, report>` with `reportedAt`, drop pages older than `ttl(pageId)` (from `visibility.ttl()`, so a page with a current heartbeat never expires) in the shared expiry interval, and write the combined value into the shared state.
3538
- 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.
3639
- Source scans in `rpc/` enrich or stand in for live data. They must return a `kind` for anything the Dashboard counts.
@@ -45,7 +48,7 @@ Read `docs/contributing/coding-standards.md` ("Reading data from the page") befo
4548

4649
- Describe what the tool returns, where the data comes from and what an empty answer means. Answer in markdown.
4750
- Give each new tool or resource one entry in `AGENT_ENTRIES` (`packages/devtools/src/config.ts`): its inspector, safety tier, the `actions` it writes for and whether it needs a page. `AGENT_INSPECTOR`, `AGENT_SAFETY`, `ACTION_TOOLS`, `PAGE_AGENT_ENTRIES` and the tags derive from it. `packages/devtools/src/__tests__/agent-metadata.test.ts` fails on a registered tool without an entry; update `packages/devtools/src/__tests__/fixtures/agent-metadata-derived.json` with it.
48-
- Update descriptions in `devframe.ts` when data shapes change, and the tool list on the docs site (apps/docs/src/content/agents/tools.md). Use the `devtools-docs` skill for that edit.
51+
- Update tool descriptions (in `devframe.ts`, `devframe-<area>-tools.ts` or the inspector's register module) when data shapes change, and the tool list on the docs site (apps/docs/src/content/agents/tools.md). Use the `devtools-docs` skill for that edit.
4952

5053
## Tests
5154

‎.claude/skills/devtools-verify/SKILL.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Run them in this order; all must pass:
1111

1212
```sh
1313
pnpm format:check
14+
pnpm lint
1415
pnpm commit:check
1516
pnpm skills:check
1617
pnpm typecheck

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ jobs:
3434
- name: Check formatting
3535
run: pnpm format:check
3636

37+
- name: Lint (no new oxlint warnings)
38+
run: pnpm lint
39+
3740
- name: Validate agent skills and roles
3841
run: pnpm skills:check
3942

‎.oxlintrc.json‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["typescript", "unicorn", "oxc"],
4+
"categories": {
5+
"correctness": "warn"
6+
},
7+
"rules": {
8+
"typescript/no-explicit-any": "warn"
9+
},
10+
"ignorePatterns": [
11+
"**/dist/**",
12+
"**/.angular/**",
13+
"**/node_modules/**",
14+
"extension/ui/**",
15+
"examples/nativescript/platforms/**",
16+
"examples/nativescript/hooks/**"
17+
]
18+
}

‎AGENTS.md‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@ Pangular Inspector inspects a running Angular app and serves what it finds to a
1414

1515
### Commands
1616

17-
| Command | What it runs |
18-
| ---------------------- | ------------------------------------------------------------------------- |
19-
| `pnpm test:devtools` | Package tests |
20-
| `pnpm test:panel` | Panel tests |
21-
| `pnpm test:axe` | Builds a static report and runs axe on every panel view |
22-
| `pnpm typecheck` | TypeScript and template checks for every project |
23-
| `pnpm format:check` | Prettier, including the docs markdown |
24-
| `pnpm skills:check` | Checks the skills and roles in `.claude` and the skills the package ships |
25-
| `pnpm docs:build` | Builds the docs site with its link guards |
26-
| `pnpm extension:build` | Rebuilds `extension/ui` from `app` |
27-
| `pnpm commit:check` | Checks the commit messages on the branch |
17+
| Command | What it runs |
18+
| ---------------------- | --------------------------------------------------------------------------------------------------------------- |
19+
| `pnpm test:devtools` | Package tests |
20+
| `pnpm test:panel` | Panel tests |
21+
| `pnpm test:axe` | Builds a static report and runs axe on every panel view |
22+
| `pnpm typecheck` | TypeScript and template checks for every project |
23+
| `pnpm format:check` | Prettier, including the docs markdown |
24+
| `pnpm lint` | oxlint with a ratchet: no file gets more warnings than `lint-baseline.json`, and no file over 1,500 lines grows |
25+
| `pnpm skills:check` | Checks the skills and roles in `.claude` and the skills the package ships |
26+
| `pnpm docs:build` | Builds the docs site with its link guards |
27+
| `pnpm extension:build` | Rebuilds `extension/ui` from `app` |
28+
| `pnpm commit:check` | Checks the commit messages on the branch |
2829

2930
The words this project uses for its own concepts (overlay, collector, hub, devframe, agent tool and so on) are defined in `docs/CONTEXT.md`. Use them the same way in code, docs and issues.
3031

‎app/src/__tests__/app-shell.test.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,9 @@ describe('App scroll memory', () => {
334334
Object.defineProperty(main, 'scrollTop', {
335335
configurable: true,
336336
get: () => top,
337-
set: (value: number) => (top = value),
337+
set: (value: number) => {
338+
top = value;
339+
},
338340
});
339341
const buttons = () => [...host(fixture).querySelectorAll<HTMLButtonElement>('nav button')];
340342
// An earlier test can leave another tab in the URL.
@@ -373,7 +375,9 @@ describe('App scroll memory while content loads', () => {
373375
Object.defineProperty(main, 'scrollTop', {
374376
configurable: true,
375377
get: () => top,
376-
set: (value: number) => (top = Math.max(0, Math.min(value, max))),
378+
set: (value: number) => {
379+
top = Math.max(0, Math.min(value, max));
380+
},
377381
});
378382
const buttons = () => [...host(fixture).querySelectorAll<HTMLButtonElement>('nav button')];
379383
buttons()[0].click();

‎app/src/__tests__/network-live-sort.test.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ describe('the network live controls', () => {
157157
Object.defineProperty(wrap, 'scrollTop', {
158158
configurable: true,
159159
get: () => top,
160-
set: (value: number) => (top = value),
160+
set: (value: number) => {
161+
top = value;
162+
},
161163
});
162164
const follow = host().querySelector<HTMLInputElement>('app-live-controls input')!;
163165
expect(follow.checked).toBe(false);
@@ -204,7 +206,9 @@ describe('Follow newest with SSR requests on the page', () => {
204206
Object.defineProperty(wrap, 'scrollTop', {
205207
configurable: true,
206208
get: () => tops[i],
207-
set: (value: number) => (tops[i] = value),
209+
set: (value: number) => {
210+
tops[i] = value;
211+
},
208212
}),
209213
);
210214
host().querySelector<HTMLInputElement>('app-live-controls input')!.click();
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import { TestBed, type ComponentFixture } from '@angular/core/testing';
2+
import { afterEach, describe, expect, it } from 'vitest';
3+
import { NetworkInspector } from '../pages/network-inspector';
4+
5+
let fixture: ComponentFixture<NetworkInspector>;
6+
7+
const call = (id: string, overrides: Record<string, unknown> = {}) => ({
8+
id,
9+
url: `/api/${id}`,
10+
method: 'GET',
11+
status: 200,
12+
durationMs: 12,
13+
side: 'client' as const,
14+
cacheHit: false,
15+
faulted: false,
16+
at: 1000,
17+
...overrides,
18+
});
19+
20+
describe('NetworkInspector native fetch calls', () => {
21+
afterEach(() => {
22+
fixture?.destroy();
23+
TestBed.resetTestingModule();
24+
});
25+
26+
it('tags a native fetch() call and leaves HttpClient calls untagged', async () => {
27+
fixture = TestBed.createComponent(NetworkInspector);
28+
document.body.append(fixture.nativeElement);
29+
fixture.componentInstance.pages.set([
30+
{
31+
pageId: 'p1',
32+
url: '/trips',
33+
title: 'Trips',
34+
hydration: null,
35+
reportedAt: 1000,
36+
calls: [call('client'), call('native', { nativeFetch: true })],
37+
},
38+
]);
39+
await fixture.whenStable();
40+
const host = fixture.nativeElement as HTMLElement;
41+
const rowOf = (id: string) =>
42+
host.querySelector(`button[data-call-id="${id}"]`)!.closest('tr')!;
43+
const tags = (id: string) =>
44+
[...rowOf(id).querySelectorAll('.tag')].map((tag) => tag.textContent!.trim());
45+
expect(tags('native')).toContain('fetch()');
46+
expect(tags('client')).not.toContain('fetch()');
47+
});
48+
49+
it('offers no mock for a native fetch() call and says why', async () => {
50+
fixture = TestBed.createComponent(NetworkInspector);
51+
document.body.append(fixture.nativeElement);
52+
const inspector = fixture.componentInstance;
53+
inspector.pages.set([
54+
{
55+
pageId: 'p1',
56+
url: '/trips',
57+
title: 'Trips',
58+
hydration: null,
59+
reportedAt: 1000,
60+
calls: [call('client'), call('native', { nativeFetch: true })],
61+
},
62+
]);
63+
await fixture.whenStable();
64+
const host = fixture.nativeElement as HTMLElement;
65+
const open = async (id: string) => {
66+
host.querySelector<HTMLButtonElement>(`button[data-call-id="${id}"]`)!.click();
67+
await fixture.whenStable();
68+
return host.querySelector('#call-preview')!;
69+
};
70+
const mockButton = (preview: Element) =>
71+
[...preview.querySelectorAll('button')].find((b) =>
72+
b.textContent!.includes('Mock this request'),
73+
);
74+
let preview = await open('native');
75+
expect(mockButton(preview)).toBeUndefined();
76+
expect(preview.textContent).toContain('skips the HttpClient interceptor');
77+
preview = await open('client');
78+
expect(mockButton(preview)).toBeDefined();
79+
expect(preview.textContent).not.toContain('skips the HttpClient interceptor');
80+
});
81+
});

‎app/src/__tests__/network-ssr-requests.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ describe('NetworkInspector SSR requests', () => {
8181
calls: [
8282
call({ id: 'b1', side: 'client', url: '/api/products', cacheHit: true, at: 1200 }),
8383
call({ id: 'b2', side: 'client', url: '/api/quote', method: 'POST', at: 1200 }),
84+
// A native fetch() to the same URL never reads the transfer cache: no cache miss.
85+
call({ id: 'b3', side: 'client', url: '/api/products', at: 1300, nativeFetch: true }),
8486
],
8587
},
8688
]);

0 commit comments

Comments
 (0)