Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/ng-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"mcp"
],
"dependencies": {
"cac": "^7.0.0",
"devframe": "^1.0.0",
"valibot": "^1.5.0"
},
Expand Down
33 changes: 27 additions & 6 deletions packages/ng-devtools/src/devframe.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { RemoteAssets } from 'devframe'
import { defineDevframe } from 'devframe'
import { getRoutes } from './rpc/get-routes.js'
import { getComponents } from './rpc/get-components.js'
import { getBuildMeta } from './rpc/build-meta.js'
import { getSignals } from './rpc/get-signals.js'
import { getProviders } from './rpc/get-providers.js'
import type {} from './types.js'
import { getRoutes } from './rpc/get-routes.ts'
import { getComponents } from './rpc/get-components.ts'
import { getBuildMeta } from './rpc/build-meta.ts'
import { getSignals } from './rpc/get-signals.ts'
import { getProviders } from './rpc/get-providers.ts'
import type {} from './types.ts'

import pkg from '../package.json' with { type: 'json' }

Expand Down Expand Up @@ -137,6 +137,13 @@ const ngDevtools = defineDevframe({
id: 'ng-devtools:highlight',
description: 'Highlight a component in the running Angular app by its selector.',
safety: 'action',
inputSchema: {
type: 'object',
properties: {
selector: { type: 'string', description: 'CSS selector of the component to highlight, e.g. app-root.' },
},
required: ['selector'],
},
handler: async (args: { selector: string }) => {
await ctx.rpc.invokeLocal('ng-devtools:select-component' as any, args.selector)
void my.rpc.broadcast({ method: 'highlight-in-page', args: [args.selector], optional: true })
Expand All @@ -148,6 +155,13 @@ const ngDevtools = defineDevframe({
id: 'ng-devtools:inspect-signals',
description: 'Get the signal graph for a specific component by CSS selector. Returns signal nodes (signal, computed, linkedSignal, effect) and their dependency edges. Call this to understand reactive data flow before suggesting state changes.',
safety: 'read',
inputSchema: {
type: 'object',
properties: {
selector: { type: 'string', description: 'CSS selector of the component to inspect, e.g. app-root.' },
},
required: ['selector'],
},
handler: async (args: { selector: string }) => {
try {
const result = await my.rpc.broadcast({ method: 'get-signal-graph-for', args: [args.selector] })
Expand All @@ -163,6 +177,13 @@ const ngDevtools = defineDevframe({
id: 'ng-devtools:inspect-providers',
description: 'Get DI providers and the injector resolution path for a component by CSS selector. Call this to understand dependency injection before suggesting provider changes.',
safety: 'read',
inputSchema: {
type: 'object',
properties: {
selector: { type: 'string', description: 'CSS selector of the component to inspect, e.g. app-root.' },
},
required: ['selector'],
},
handler: async (args: { selector: string }) => {
try {
const result = await my.rpc.broadcast({ method: 'get-providers-for', args: [args.selector] })
Expand Down
20 changes: 15 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions src/app/app.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { provideRouter } from '@angular/router';
import { App } from './app';

describe('App', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [App],
providers: [provideRouter([])],
Comment thread
coderabbitai[bot] marked this conversation as resolved.
})
.compileComponents();
});
Expand All @@ -15,10 +17,11 @@ describe('App', () => {
expect(app).toBeTruthy();
});

it('should render title', async () => {
it('should render the nav links', async () => {
const fixture = TestBed.createComponent(App);
await fixture.whenStable();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, angular-devtools');
const hrefs = Array.from(compiled.querySelectorAll('nav a')).map((a) => a.getAttribute('href'));
expect(hrefs).toEqual(['/', '/about']);
});
});
4 changes: 3 additions & 1 deletion tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"compilerOptions": {
"types": [
"node"
]
],
"allowImportingTsExtensions": true,
"rewriteRelativeImportExtensions": true
},
"include": [
"src/**/*.ts"
Expand Down