Skip to content

Commit f8ea8f6

Browse files
authored
Merge pull request #96 from AmadeusITGroup/ai-feat-integration
Ai feat integration
2 parents 7fe52db + 816b068 commit f8ea8f6

17 files changed

Lines changed: 1214 additions & 30 deletions

File tree

CONTRIBUTING.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ npm run lint:fix # Auto-fix lint errors
8888
### Branch Naming
8989

9090
Use descriptive branch names:
91-
- `feat/description` for new features
92-
- `fix/description` for bug fixes
93-
- `docs/description` for documentation changes
94-
- `refactor/description` for code refactoring
95-
- `test/description` for adding or updating tests
91+
- `feat/description` - for new features
92+
- `fix/description` - for bug fixes
93+
- `docs/description` - for documentation changes
94+
- `refactor/description` - for code refactoring
95+
- `test/description` - for adding or updating tests
9696

9797
### Commit Messages
9898

@@ -117,14 +117,14 @@ test(store): add unit tests for meta reducer
117117
3. Ensure all tests pass: `npm test`
118118
4. Ensure linting passes: `npm run lint`
119119
5. Push your branch and open a pull request against `master`
120-
6. CI will automatically run lint and tests — both must pass before merging
120+
6. CI will automatically run lint and tests. Both must pass before merging
121121

122122
### Code Quality Requirements
123123

124124
- All new code must include unit tests
125125
- Existing tests must continue to pass
126126
- Code must pass linting without errors
127-
- Keep pull requests focused one feature or fix per PR
127+
- Keep pull requests focused: one feature or fix per PR
128128

129129
---
130130

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<p align="center">
1515
A development tool for visualizing and debugging NgRx state management in Angular applications.<br>
16-
Real-time action monitoring, effect tracking, state visualization, diff viewer, and performance metrics no browser extensions needed.
16+
Real-time action monitoring, effect tracking, state visualization, diff viewer, and performance metrics. No browser extensions needed.
1717
</p>
1818

1919
<p align="center">
@@ -67,8 +67,6 @@ npx ngrx-devtool
6767

6868
Open **http://localhost:3000** and start your Angular app.
6969

70-
---
71-
7270
For full documentation, configuration options, troubleshooting, and more, visit the **[documentation site](https://amadeusitgroup.github.io/ngrx-devtool/)**.
7371

7472
## Contributing
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
sidebar_position: 6
3+
title: Debug with AI
4+
---
5+
6+
# Debug with AI
7+
8+
Turn your live NgRx DevTool session into AI-ready debugging context with no API key, subscription, or extra install required.
9+
10+
## Copy a debugging prompt
11+
12+
Click **Debug with AI** in the toolbar. The DevTool assembles a focused prompt from the current session:
13+
14+
- Recent actions
15+
- Effect errors with stack traces
16+
- Slowest renders
17+
- Latest state diff
18+
19+
Paste the prompt into GitHub Copilot Chat, Claude, ChatGPT, or another assistant. Pick a focus such as health check, debug errors, why slow, or explain flow, and the prompt adapts.
20+
21+
## Run locally with Ollama
22+
23+
If you have [Ollama](https://ollama.com) running, the dialog detects it automatically and lets you ask a local model right inside the DevTool. Answers stream in, and nothing leaves your machine.
24+
25+
```bash
26+
ollama pull llama3
27+
```
28+
29+
## Connect via MCP
30+
31+
The server exposes a [Model Context Protocol](https://modelcontextprotocol.io) endpoint at `http://localhost:3000/mcp`, so AI assistants can query your running NgRx session directly.
32+
33+
Add this to `.vscode/mcp.json` in your project:
34+
35+
```json
36+
{
37+
"servers": {
38+
"ngrx-devtool": {
39+
"type": "http",
40+
"url": "http://localhost:3000/mcp"
41+
}
42+
}
43+
}
44+
```
45+
46+
Then ask Copilot Chat things like:
47+
48+
```text
49+
Why is my loadBooks$ effect failing?
50+
```
51+
52+
## MCP tools
53+
54+
| Tool | What it returns |
55+
|---|---|
56+
| `get_debug_summary` | Recent actions, effect errors and performance at a glance |
57+
| `get_action_timeline` | Recent actions with source, render time and warnings |
58+
| `get_effects` / `get_effect_errors` | Effect executions, plus errors with stack traces |
59+
| `get_state_diff` | What changed in the store for a given action |
60+
| `get_current_state` | The latest store snapshot |
61+
| `get_performance_stats` | Average/max render time and the slowest actions |
62+
63+
:::info
64+
The MCP server captures traffic in memory on the DevTool server and adds no new dependencies to the published package.
65+
:::

docs/sidebars.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const sidebars: SidebarsConfig = {
2424
'features/performance',
2525
'features/state-visualization',
2626
'features/diff-viewer',
27+
'features/debug-with-ai',
2728
],
2829
},
2930
{

index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { WebSocket, WebSocketServer } from 'ws';
33
import * as path from 'path';
44
import * as express from 'express';
55
import { createServer } from 'http';
6+
import { createStore, captureMessage, registerMcpEndpoint } from './mcp-server';
67
const chalk = require('chalk');
78

89
const PORT_WS = 4000;
@@ -11,6 +12,8 @@ const wss = new WebSocketServer({ port: PORT_WS });
1112

1213
let clients = [];
1314

15+
const store = createStore();
16+
1417
const logo = `
1518
***@ +**
1619
** ******%
@@ -63,6 +66,7 @@ console.log(chalk.dim('─'.repeat(60)));
6366
wss.on('connection', (socket) => {
6467
clients.push(socket);
6568
socket.on('message', (message) => {
69+
captureMessage(store, message.toString());
6670
clients.forEach((client) => {
6771
if (client !== socket && client.readyState === WebSocket.OPEN) {
6872
client.send(message);
@@ -71,6 +75,7 @@ wss.on('connection', (socket) => {
7175
});
7276
});
7377
const app = express();
78+
registerMcpEndpoint(app, express, store);
7479
app.use(express.static(path.resolve(__dirname, 'ngrx-devtool-ui/browser')));
7580
app.get('*', (_req, res) => {
7681
res.sendFile(path.resolve(__dirname, 'ngrx-devtool-ui/browser/index.html'));
@@ -94,6 +99,11 @@ process.on('SIGINT', () => {
9499
console.log('');
95100
console.log(chalk.green(` ✓ WebSocket`), chalk.dim(`ws://localhost:${PORT_WS}`));
96101
console.log(chalk.green(` ✓ UI Server`), chalk.dim(`http://localhost:${PORT_UI}`));
102+
console.log(chalk.green(` ✓ AI / MCP `), chalk.dim(`http://localhost:${PORT_UI}/mcp`));
103+
console.log('');
104+
console.log(chalk.dim(' Connect Copilot / Claude / Cursor by adding to .vscode/mcp.json:'));
105+
console.log(chalk.dim(' { "servers": { "ngrx-devtool": { "type": "http",'));
106+
console.log(chalk.dim(` "url": "http://localhost:${PORT_UI}/mcp" } } }`));
97107
console.log('');
98108
console.log(chalk.dim('─'.repeat(60)));
99109
console.log(chalk.dim(' Press'), chalk.white('Ctrl+C'), chalk.dim('to stop all servers'));

0 commit comments

Comments
 (0)