@ng-annotate/angular 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,24 +16,31 @@ ng add @ng-annotate/angular
16
16
  ```
17
17
 
18
18
  The schematic configures everything automatically:
19
- - Adds the Vite plugin to `vite.config.ts`
19
+ - Switches the Angular dev server to `@ng-annotate/angular:dev-server` (handles WebSocket + manifest injection — no separate config file or proxy needed)
20
20
  - Adds `provideNgAnnotate()` to `app.config.ts`
21
- - Creates the MCP config file for your AI editor
21
+ - Creates the MCP config file for your AI editor (`.mcp.json` for Claude Code, `.vscode/mcp.json` for VS Code, or both)
22
+
23
+ Works with both `@angular/build:dev-server` and the legacy `@angular-devkit/build-angular:dev-server` builder.
22
24
 
23
25
  ## Manual install
24
26
 
25
27
  ```bash
26
- npm install @ng-annotate/angular @ng-annotate/vite-plugin --save-dev
28
+ npm install @ng-annotate/angular --save-dev
27
29
  ```
28
30
 
29
- **`vite.config.ts`**
30
- ```ts
31
- import { defineConfig } from 'vite';
32
- import { ngAnnotateMcp } from '@ng-annotate/vite-plugin';
33
-
34
- export default defineConfig({
35
- plugins: [...ngAnnotateMcp()],
36
- });
31
+ **`angular.json`** — change the serve builder:
32
+ ```json
33
+ {
34
+ "projects": {
35
+ "your-app": {
36
+ "architect": {
37
+ "serve": {
38
+ "builder": "@ng-annotate/angular:dev-server"
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
37
44
  ```
38
45
 
39
46
  **`src/app/app.config.ts`**
@@ -56,7 +63,7 @@ Once installed:
56
63
 
57
64
  **1. Start the dev server**
58
65
  ```bash
59
- npm run dev
66
+ ng serve
60
67
  ```
61
68
 
62
69
  **2. Start the agent polling loop**
@@ -113,8 +120,8 @@ export class AppModule {}
113
120
 
114
121
  | Package | Purpose |
115
122
  |---|---|
116
- | [`@ng-annotate/vite-plugin`](https://www.npmjs.com/package/@ng-annotate/vite-plugin) | Vite plugin (WebSocket server, component manifest) |
117
123
  | [`@ng-annotate/mcp-server`](https://www.npmjs.com/package/@ng-annotate/mcp-server) | MCP server exposing tools to the AI agent |
124
+ | [`@ng-annotate/vite-plugin`](https://www.npmjs.com/package/@ng-annotate/vite-plugin) | For non-Angular-CLI Vite projects (Vue, Svelte, etc.) |
118
125
 
119
126
  ## License
120
127
 
package/dist/README.md CHANGED
@@ -16,24 +16,31 @@ ng add @ng-annotate/angular
16
16
  ```
17
17
 
18
18
  The schematic configures everything automatically:
19
- - Adds the Vite plugin to `vite.config.ts`
19
+ - Switches the Angular dev server to `@ng-annotate/angular:dev-server` (handles WebSocket + manifest injection — no separate config file or proxy needed)
20
20
  - Adds `provideNgAnnotate()` to `app.config.ts`
21
- - Creates the MCP config file for your AI editor
21
+ - Creates the MCP config file for your AI editor (`.mcp.json` for Claude Code, `.vscode/mcp.json` for VS Code, or both)
22
+
23
+ Works with both `@angular/build:dev-server` and the legacy `@angular-devkit/build-angular:dev-server` builder.
22
24
 
23
25
  ## Manual install
24
26
 
25
27
  ```bash
26
- npm install @ng-annotate/angular @ng-annotate/vite-plugin --save-dev
28
+ npm install @ng-annotate/angular --save-dev
27
29
  ```
28
30
 
29
- **`vite.config.ts`**
30
- ```ts
31
- import { defineConfig } from 'vite';
32
- import { ngAnnotateMcp } from '@ng-annotate/vite-plugin';
33
-
34
- export default defineConfig({
35
- plugins: [...ngAnnotateMcp()],
36
- });
31
+ **`angular.json`** — change the serve builder:
32
+ ```json
33
+ {
34
+ "projects": {
35
+ "your-app": {
36
+ "architect": {
37
+ "serve": {
38
+ "builder": "@ng-annotate/angular:dev-server"
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
37
44
  ```
38
45
 
39
46
  **`src/app/app.config.ts`**
@@ -56,7 +63,7 @@ Once installed:
56
63
 
57
64
  **1. Start the dev server**
58
65
  ```bash
59
- npm run dev
66
+ ng serve
60
67
  ```
61
68
 
62
69
  **2. Start the agent polling loop**
@@ -113,8 +120,8 @@ export class AppModule {}
113
120
 
114
121
  | Package | Purpose |
115
122
  |---|---|
116
- | [`@ng-annotate/vite-plugin`](https://www.npmjs.com/package/@ng-annotate/vite-plugin) | Vite plugin (WebSocket server, component manifest) |
117
123
  | [`@ng-annotate/mcp-server`](https://www.npmjs.com/package/@ng-annotate/mcp-server) | MCP server exposing tools to the AI agent |
124
+ | [`@ng-annotate/vite-plugin`](https://www.npmjs.com/package/@ng-annotate/vite-plugin) | For non-Angular-CLI Vite projects (Vue, Svelte, etc.) |
118
125
 
119
126
  ## License
120
127
 
@@ -3,5 +3,125 @@
3
3
  "title": "ng-annotate Dev Server",
4
4
  "description": "Wraps @angular/build:dev-server with integrated ng-annotate WebSocket and manifest support.",
5
5
  "type": "object",
6
- "properties": {}
6
+ "properties": {
7
+ "buildTarget": {
8
+ "type": "string",
9
+ "description": "A build builder target to serve in the format of `project:target[:configuration]`. You can also pass in more than one configuration name as a comma-separated list. Example: `project:target:production,staging`.",
10
+ "pattern": "^[^:\\s]*:[^:\\s]*(:[^\\s]+)?$"
11
+ },
12
+ "port": {
13
+ "type": "number",
14
+ "description": "Port to listen on.",
15
+ "default": 4200
16
+ },
17
+ "host": {
18
+ "type": "string",
19
+ "description": "Host to listen on.",
20
+ "default": "localhost"
21
+ },
22
+ "proxyConfig": {
23
+ "type": "string",
24
+ "description": "Proxy configuration file. For more information, see https://angular.dev/tools/cli/serve#proxying-to-a-backend-server."
25
+ },
26
+ "ssl": {
27
+ "type": "boolean",
28
+ "description": "Serve using HTTPS.",
29
+ "default": false
30
+ },
31
+ "sslKey": {
32
+ "type": "string",
33
+ "description": "SSL key to use for serving HTTPS."
34
+ },
35
+ "sslCert": {
36
+ "type": "string",
37
+ "description": "SSL certificate to use for serving HTTPS."
38
+ },
39
+ "allowedHosts": {
40
+ "description": "The hosts that the development server will respond to.",
41
+ "default": [],
42
+ "oneOf": [
43
+ {
44
+ "type": "array",
45
+ "description": "A list of hosts that the development server will respond to.",
46
+ "items": { "type": "string" }
47
+ },
48
+ {
49
+ "type": "boolean",
50
+ "description": "Indicates that all hosts are allowed."
51
+ }
52
+ ]
53
+ },
54
+ "define": {
55
+ "description": "Defines global identifiers that will be replaced with a specified constant value when found in any JavaScript or TypeScript code including libraries.",
56
+ "type": "object",
57
+ "additionalProperties": { "type": "string" }
58
+ },
59
+ "headers": {
60
+ "type": "object",
61
+ "description": "Custom HTTP headers to be added to all responses.",
62
+ "propertyNames": { "pattern": "^[-_A-Za-z0-9]+$" },
63
+ "additionalProperties": { "type": "string" }
64
+ },
65
+ "open": {
66
+ "type": "boolean",
67
+ "description": "Opens the url in default browser.",
68
+ "default": false,
69
+ "alias": "o"
70
+ },
71
+ "verbose": {
72
+ "type": "boolean",
73
+ "description": "Adds more details to output logging."
74
+ },
75
+ "liveReload": {
76
+ "type": "boolean",
77
+ "description": "Whether to reload the page on change, using live-reload.",
78
+ "default": true
79
+ },
80
+ "servePath": {
81
+ "type": "string",
82
+ "description": "The pathname where the application will be served."
83
+ },
84
+ "hmr": {
85
+ "type": "boolean",
86
+ "description": "Enable hot module replacement. Defaults to the value of 'liveReload'."
87
+ },
88
+ "watch": {
89
+ "type": "boolean",
90
+ "description": "Rebuild on change.",
91
+ "default": true
92
+ },
93
+ "poll": {
94
+ "type": "number",
95
+ "description": "Enable and define the file watching poll time period in milliseconds."
96
+ },
97
+ "inspect": {
98
+ "default": false,
99
+ "description": "Activate debugging inspector.",
100
+ "oneOf": [
101
+ { "type": "string" },
102
+ { "type": "boolean" }
103
+ ]
104
+ },
105
+ "prebundle": {
106
+ "description": "Enable and control the Vite-based development server's prebundling capabilities.",
107
+ "default": true,
108
+ "oneOf": [
109
+ { "type": "boolean" },
110
+ {
111
+ "type": "object",
112
+ "properties": {
113
+ "exclude": {
114
+ "description": "List of package imports that should not be prebundled by the development server.",
115
+ "type": "array",
116
+ "items": { "type": "string" }
117
+ }
118
+ },
119
+ "additionalProperties": false,
120
+ "required": ["exclude"]
121
+ }
122
+ ]
123
+ }
124
+ },
125
+ "additionalProperties": false,
126
+ "required": ["buildTarget"]
7
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-annotate/angular",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "schematics": "./schematics/collection.json",
5
5
  "builders": "./builders.json",
6
6
  "description": "Angular library for ng-annotate-mcp — browser overlay for annotating components and routing instructions to an AI agent",
@@ -41,7 +41,13 @@ const path = __importStar(require("path"));
41
41
  const helpers_1 = require("./helpers");
42
42
  const MIN_ANGULAR_MAJOR = 21;
43
43
  const NG_ANNOTATE_BUILDER = '@ng-annotate/angular:dev-server';
44
- const ANGULAR_DEV_SERVER_BUILDER = '@angular/build:dev-server';
44
+ // Both builders use the same underlying implementation in Angular 17+.
45
+ // @angular-devkit/build-angular:dev-server is the legacy alias that many
46
+ // projects still have in their angular.json even on Angular 21.
47
+ const COMPATIBLE_DEV_SERVER_BUILDERS = [
48
+ '@angular/build:dev-server',
49
+ '@angular-devkit/build-angular:dev-server',
50
+ ];
45
51
  function checkAngularVersion() {
46
52
  return (tree) => {
47
53
  const pkgPath = 'package.json';
@@ -83,9 +89,9 @@ function updateAngularJsonBuilder() {
83
89
  context.logger.info(`ng-annotate builder already configured in ${projectName}, skipping.`);
84
90
  continue;
85
91
  }
86
- if (currentBuilder !== ANGULAR_DEV_SERVER_BUILDER) {
92
+ if (!COMPATIBLE_DEV_SERVER_BUILDERS.includes(currentBuilder ?? '')) {
87
93
  context.logger.warn(`⚠️ Project "${projectName}" uses builder "${String(currentBuilder)}" which is not ` +
88
- `"${ANGULAR_DEV_SERVER_BUILDER}". Skipping automatic builder update — ` +
94
+ `a compatible dev-server builder. Skipping automatic builder update — ` +
89
95
  `set it to "${NG_ANNOTATE_BUILDER}" manually if compatible.`);
90
96
  continue;
91
97
  }
@@ -164,6 +164,27 @@ describe('ng-add schematic — updateAngularJsonBuilder', () => {
164
164
  expect((serve['builder'] as string)).toBe('@ng-annotate/angular:dev-server');
165
165
  });
166
166
 
167
+ it('updates legacy @angular-devkit/build-angular:dev-server builder too', async () => {
168
+ const withLegacyBuilder = JSON.stringify({
169
+ projects: {
170
+ 'my-app': {
171
+ architect: {
172
+ serve: {
173
+ builder: '@angular-devkit/build-angular:dev-server',
174
+ options: {},
175
+ },
176
+ },
177
+ },
178
+ },
179
+ });
180
+ const tree = makeTree({ 'package.json': BASE_PKG, 'angular.json': withLegacyBuilder });
181
+ const result = await runSchematic(tree);
182
+ const angular = JSON.parse(result.readText('angular.json')) as Record<string, unknown>;
183
+ const projects = angular['projects'] as Record<string, Record<string, unknown>>;
184
+ const serve = (projects['my-app']['architect'] as Record<string, Record<string, unknown>>)['serve'];
185
+ expect((serve['builder'] as string)).toBe('@ng-annotate/angular:dev-server');
186
+ });
187
+
167
188
  it('warns but does not change unknown builders', async () => {
168
189
  const withCustomBuilder = JSON.stringify({
169
190
  projects: {
@@ -10,7 +10,14 @@ interface Options {
10
10
 
11
11
  const MIN_ANGULAR_MAJOR = 21;
12
12
  const NG_ANNOTATE_BUILDER = '@ng-annotate/angular:dev-server';
13
- const ANGULAR_DEV_SERVER_BUILDER = '@angular/build:dev-server';
13
+
14
+ // Both builders use the same underlying implementation in Angular 17+.
15
+ // @angular-devkit/build-angular:dev-server is the legacy alias that many
16
+ // projects still have in their angular.json even on Angular 21.
17
+ const COMPATIBLE_DEV_SERVER_BUILDERS = [
18
+ '@angular/build:dev-server',
19
+ '@angular-devkit/build-angular:dev-server',
20
+ ];
14
21
 
15
22
  function checkAngularVersion(): Rule {
16
23
  return (tree: Tree) => {
@@ -69,10 +76,10 @@ function updateAngularJsonBuilder(): Rule {
69
76
  continue;
70
77
  }
71
78
 
72
- if (currentBuilder !== ANGULAR_DEV_SERVER_BUILDER) {
79
+ if (!COMPATIBLE_DEV_SERVER_BUILDERS.includes(currentBuilder ?? '')) {
73
80
  context.logger.warn(
74
81
  `⚠️ Project "${projectName}" uses builder "${String(currentBuilder)}" which is not ` +
75
- `"${ANGULAR_DEV_SERVER_BUILDER}". Skipping automatic builder update — ` +
82
+ `a compatible dev-server builder. Skipping automatic builder update — ` +
76
83
  `set it to "${NG_ANNOTATE_BUILDER}" manually if compatible.`,
77
84
  );
78
85
  continue;