@angular-modernizer/adapter-mcp 0.1.1
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/LICENSE +21 -0
- package/README.md +917 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +129 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/project-analyzer.d.ts +59 -0
- package/dist/core/project-analyzer.d.ts.map +1 -0
- package/dist/core/project-analyzer.js +116 -0
- package/dist/core/project-analyzer.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-watcher.d.ts +119 -0
- package/dist/mcp-watcher.d.ts.map +1 -0
- package/dist/mcp-watcher.js +380 -0
- package/dist/mcp-watcher.js.map +1 -0
- package/dist/server/json-rpc-handler.d.ts +57 -0
- package/dist/server/json-rpc-handler.d.ts.map +1 -0
- package/dist/server/json-rpc-handler.js +222 -0
- package/dist/server/json-rpc-handler.js.map +1 -0
- package/dist/server/mcp-server.d.ts +62 -0
- package/dist/server/mcp-server.d.ts.map +1 -0
- package/dist/server/mcp-server.js +184 -0
- package/dist/server/mcp-server.js.map +1 -0
- package/dist/server/tool-registry.d.ts +73 -0
- package/dist/server/tool-registry.d.ts.map +1 -0
- package/dist/server/tool-registry.js +102 -0
- package/dist/server/tool-registry.js.map +1 -0
- package/dist/streaming/progress-store.d.ts +120 -0
- package/dist/streaming/progress-store.d.ts.map +1 -0
- package/dist/streaming/progress-store.js +238 -0
- package/dist/streaming/progress-store.js.map +1 -0
- package/dist/tools/analyze-build-impact.d.ts +127 -0
- package/dist/tools/analyze-build-impact.d.ts.map +1 -0
- package/dist/tools/analyze-build-impact.js +194 -0
- package/dist/tools/analyze-build-impact.js.map +1 -0
- package/dist/tools/analyze-core-to-shared.d.ts +163 -0
- package/dist/tools/analyze-core-to-shared.d.ts.map +1 -0
- package/dist/tools/analyze-core-to-shared.js +436 -0
- package/dist/tools/analyze-core-to-shared.js.map +1 -0
- package/dist/tools/analyze-parser-performance.d.ts +105 -0
- package/dist/tools/analyze-parser-performance.d.ts.map +1 -0
- package/dist/tools/analyze-parser-performance.js +313 -0
- package/dist/tools/analyze-parser-performance.js.map +1 -0
- package/dist/tools/analyze-project.d.ts +277 -0
- package/dist/tools/analyze-project.d.ts.map +1 -0
- package/dist/tools/analyze-project.js +946 -0
- package/dist/tools/analyze-project.js.map +1 -0
- package/dist/tools/check-incremental-compatibility.d.ts +109 -0
- package/dist/tools/check-incremental-compatibility.d.ts.map +1 -0
- package/dist/tools/check-incremental-compatibility.js +302 -0
- package/dist/tools/check-incremental-compatibility.js.map +1 -0
- package/dist/tools/collect-feedback.d.ts +117 -0
- package/dist/tools/collect-feedback.d.ts.map +1 -0
- package/dist/tools/collect-feedback.js +773 -0
- package/dist/tools/collect-feedback.js.map +1 -0
- package/dist/tools/extract-libraries.d.ts +121 -0
- package/dist/tools/extract-libraries.d.ts.map +1 -0
- package/dist/tools/extract-libraries.js +223 -0
- package/dist/tools/extract-libraries.js.map +1 -0
- package/dist/tools/find-angular-symbol.d.ts +55 -0
- package/dist/tools/find-angular-symbol.d.ts.map +1 -0
- package/dist/tools/find-angular-symbol.js +104 -0
- package/dist/tools/find-angular-symbol.js.map +1 -0
- package/dist/tools/find-usages.d.ts +65 -0
- package/dist/tools/find-usages.d.ts.map +1 -0
- package/dist/tools/find-usages.js +108 -0
- package/dist/tools/find-usages.js.map +1 -0
- package/dist/tools/get-call-graph.d.ts +61 -0
- package/dist/tools/get-call-graph.d.ts.map +1 -0
- package/dist/tools/get-call-graph.js +119 -0
- package/dist/tools/get-call-graph.js.map +1 -0
- package/dist/tools/get-operation-progress-tool.d.ts +29 -0
- package/dist/tools/get-operation-progress-tool.d.ts.map +1 -0
- package/dist/tools/get-operation-progress-tool.js +36 -0
- package/dist/tools/get-operation-progress-tool.js.map +1 -0
- package/dist/tools/get-operation-progress.d.ts +51 -0
- package/dist/tools/get-operation-progress.d.ts.map +1 -0
- package/dist/tools/get-operation-progress.js +93 -0
- package/dist/tools/get-operation-progress.js.map +1 -0
- package/dist/tools/helpers/feedback-analyzer.d.ts +43 -0
- package/dist/tools/helpers/feedback-analyzer.d.ts.map +1 -0
- package/dist/tools/helpers/feedback-analyzer.js +196 -0
- package/dist/tools/helpers/feedback-analyzer.js.map +1 -0
- package/dist/tools/helpers/find-ts-config.d.ts +10 -0
- package/dist/tools/helpers/find-ts-config.d.ts.map +1 -0
- package/dist/tools/helpers/find-ts-config.js +32 -0
- package/dist/tools/helpers/find-ts-config.js.map +1 -0
- package/dist/tools/helpers/platform-root-resolver.d.ts +33 -0
- package/dist/tools/helpers/platform-root-resolver.d.ts.map +1 -0
- package/dist/tools/helpers/platform-root-resolver.js +60 -0
- package/dist/tools/helpers/platform-root-resolver.js.map +1 -0
- package/dist/tools/helpers/rule-matcher.d.ts +84 -0
- package/dist/tools/helpers/rule-matcher.d.ts.map +1 -0
- package/dist/tools/helpers/rule-matcher.js +212 -0
- package/dist/tools/helpers/rule-matcher.js.map +1 -0
- package/dist/tools/helpers/suggestion-generator.d.ts +66 -0
- package/dist/tools/helpers/suggestion-generator.d.ts.map +1 -0
- package/dist/tools/helpers/suggestion-generator.js +248 -0
- package/dist/tools/helpers/suggestion-generator.js.map +1 -0
- package/dist/tools/learn-patterns.d.ts +368 -0
- package/dist/tools/learn-patterns.d.ts.map +1 -0
- package/dist/tools/learn-patterns.js +1089 -0
- package/dist/tools/learn-patterns.js.map +1 -0
- package/dist/tools/orchestrate-migration.d.ts +187 -0
- package/dist/tools/orchestrate-migration.d.ts.map +1 -0
- package/dist/tools/orchestrate-migration.js +235 -0
- package/dist/tools/orchestrate-migration.js.map +1 -0
- package/dist/tools/parse-stack-trace.d.ts +63 -0
- package/dist/tools/parse-stack-trace.d.ts.map +1 -0
- package/dist/tools/parse-stack-trace.js +92 -0
- package/dist/tools/parse-stack-trace.js.map +1 -0
- package/dist/tools/plan-migration.d.ts +388 -0
- package/dist/tools/plan-migration.d.ts.map +1 -0
- package/dist/tools/plan-migration.js +826 -0
- package/dist/tools/plan-migration.js.map +1 -0
- package/dist/tools/resolve-type.d.ts +54 -0
- package/dist/tools/resolve-type.d.ts.map +1 -0
- package/dist/tools/resolve-type.js +101 -0
- package/dist/tools/resolve-type.js.map +1 -0
- package/dist/tools/review-feedback.d.ts +124 -0
- package/dist/tools/review-feedback.d.ts.map +1 -0
- package/dist/tools/review-feedback.js +276 -0
- package/dist/tools/review-feedback.js.map +1 -0
- package/dist/tools/rollback-changes.d.ts +42 -0
- package/dist/tools/rollback-changes.d.ts.map +1 -0
- package/dist/tools/rollback-changes.js +95 -0
- package/dist/tools/rollback-changes.js.map +1 -0
- package/dist/tools/run-angular-cli.d.ts +102 -0
- package/dist/tools/run-angular-cli.d.ts.map +1 -0
- package/dist/tools/run-angular-cli.js +152 -0
- package/dist/tools/run-angular-cli.js.map +1 -0
- package/dist/tools/run-build.d.ts +201 -0
- package/dist/tools/run-build.d.ts.map +1 -0
- package/dist/tools/run-build.js +554 -0
- package/dist/tools/run-build.js.map +1 -0
- package/dist/tools/run-schematic.d.ts +173 -0
- package/dist/tools/run-schematic.d.ts.map +1 -0
- package/dist/tools/run-schematic.js +410 -0
- package/dist/tools/run-schematic.js.map +1 -0
- package/dist/tools/scan-all.d.ts +160 -0
- package/dist/tools/scan-all.d.ts.map +1 -0
- package/dist/tools/scan-all.js +486 -0
- package/dist/tools/scan-all.js.map +1 -0
- package/dist/tools/scan-angular.d.ts +132 -0
- package/dist/tools/scan-angular.d.ts.map +1 -0
- package/dist/tools/scan-angular.js +411 -0
- package/dist/tools/scan-angular.js.map +1 -0
- package/dist/tools/scan-architecture.d.ts +351 -0
- package/dist/tools/scan-architecture.d.ts.map +1 -0
- package/dist/tools/scan-architecture.js +1290 -0
- package/dist/tools/scan-architecture.js.map +1 -0
- package/dist/tools/scan-solid.d.ts +132 -0
- package/dist/tools/scan-solid.d.ts.map +1 -0
- package/dist/tools/scan-solid.js +435 -0
- package/dist/tools/scan-solid.js.map +1 -0
- package/dist/tools/search-codebase.d.ts +64 -0
- package/dist/tools/search-codebase.d.ts.map +1 -0
- package/dist/tools/search-codebase.js +109 -0
- package/dist/tools/search-codebase.js.map +1 -0
- package/dist/tools/shared/scan-types.d.ts +200 -0
- package/dist/tools/shared/scan-types.d.ts.map +1 -0
- package/dist/tools/shared/scan-types.js +7 -0
- package/dist/tools/shared/scan-types.js.map +1 -0
- package/dist/tools/suggest-improvements.d.ts +96 -0
- package/dist/tools/suggest-improvements.d.ts.map +1 -0
- package/dist/tools/suggest-improvements.js +182 -0
- package/dist/tools/suggest-improvements.js.map +1 -0
- package/dist/tools/transform-code-batch.d.ts +57 -0
- package/dist/tools/transform-code-batch.d.ts.map +1 -0
- package/dist/tools/transform-code-batch.js +107 -0
- package/dist/tools/transform-code-batch.js.map +1 -0
- package/dist/tools/transform-code.d.ts +352 -0
- package/dist/tools/transform-code.d.ts.map +1 -0
- package/dist/tools/transform-code.js +1171 -0
- package/dist/tools/transform-code.js.map +1 -0
- package/dist/tools/validate-before-transform.d.ts +54 -0
- package/dist/tools/validate-before-transform.d.ts.map +1 -0
- package/dist/tools/validate-before-transform.js +141 -0
- package/dist/tools/validate-before-transform.js.map +1 -0
- package/dist/tools/validate-project-compatibility.d.ts +119 -0
- package/dist/tools/validate-project-compatibility.d.ts.map +1 -0
- package/dist/tools/validate-project-compatibility.js +243 -0
- package/dist/tools/validate-project-compatibility.js.map +1 -0
- package/dist/tools/validate-transformation.d.ts +105 -0
- package/dist/tools/validate-transformation.d.ts.map +1 -0
- package/dist/tools/validate-transformation.js +391 -0
- package/dist/tools/validate-transformation.js.map +1 -0
- package/dist/types.d.ts +153 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +38 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/format-tool-response.d.ts +72 -0
- package/dist/utils/format-tool-response.d.ts.map +1 -0
- package/dist/utils/format-tool-response.js +149 -0
- package/dist/utils/format-tool-response.js.map +1 -0
- package/package.json +70 -0
package/README.md
ADDED
|
@@ -0,0 +1,917 @@
|
|
|
1
|
+
# @angular-modernizer/adapter-mcp
|
|
2
|
+
|
|
3
|
+
MCP server that exposes Angular Modernizer capabilities as 24 structured tools for AI assistants.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
The `@angular-modernizer/adapter-mcp` package provides a Model Context Protocol (MCP) server for Angular codebase modernization. Built on the core Angular Modernization Platform, this adapter enables AI assistants to perform analysis, generate migration strategies, and execute safe transformations.
|
|
10
|
+
|
|
11
|
+
Tools are designed for LLM consumption with structured I/O, pre-validation, automatic backup, build validation, and rollback on failure.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Architecture
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
AI Assistant (Claude/Copilot)
|
|
19
|
+
|
|
|
20
|
+
| JSON-RPC 2.0 (stdio)
|
|
21
|
+
v
|
|
22
|
+
MCP Server (adapter-mcp)
|
|
23
|
+
- 24 Specialized Tools
|
|
24
|
+
- Real-time Progress Monitoring
|
|
25
|
+
- Parameter Validation
|
|
26
|
+
- Result Serialization
|
|
27
|
+
|
|
|
28
|
+
| TypeScript API
|
|
29
|
+
v
|
|
30
|
+
Core Platform (Kernel + Plugins)
|
|
31
|
+
- Analysis Rules (53 rules total)
|
|
32
|
+
- Architecture: 16 rules
|
|
33
|
+
- Angular: 30 rules
|
|
34
|
+
- SOLID: 7 rules
|
|
35
|
+
- Transformations (19 types)
|
|
36
|
+
- Caching
|
|
37
|
+
- Orchestration
|
|
38
|
+
|
|
|
39
|
+
| ts-morph AST
|
|
40
|
+
v
|
|
41
|
+
TypeScript Project
|
|
42
|
+
- Source Files
|
|
43
|
+
- Type Checking
|
|
44
|
+
- Semantic Analysis
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Quick Start
|
|
50
|
+
|
|
51
|
+
### Installation
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
cd packages/adapter-mcp
|
|
55
|
+
pnpm install
|
|
56
|
+
pnpm build
|
|
57
|
+
pnpm start
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Configuration
|
|
61
|
+
|
|
62
|
+
Create `.angular-modernizer.json` in your project root:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"analyze-project": {
|
|
67
|
+
"rootPath": ".",
|
|
68
|
+
"excludePatterns": ["**/node_modules/**", "**/dist/**"],
|
|
69
|
+
"orchestration": {
|
|
70
|
+
"parallel": true,
|
|
71
|
+
"autoSelectMode": true
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"scan-architecture": {
|
|
75
|
+
"rootPath": ".",
|
|
76
|
+
"maxFiles": 500,
|
|
77
|
+
"orchestration": {
|
|
78
|
+
"parallel": true,
|
|
79
|
+
"enableProgress": true
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Claude Desktop Setup
|
|
86
|
+
|
|
87
|
+
Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"mcpServers": {
|
|
92
|
+
"angular-modernizer": {
|
|
93
|
+
"command": "node",
|
|
94
|
+
"args": ["/path/to/tsanalyzer/packages/adapter-mcp/dist/index.js"],
|
|
95
|
+
"cwd": "/path/to/your/angular/project"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Available Tools
|
|
104
|
+
|
|
105
|
+
### Analysis Tools
|
|
106
|
+
|
|
107
|
+
| Tool | Purpose | Rules | Cache | Time |
|
|
108
|
+
|-|-|-|-|-|
|
|
109
|
+
| analyze-project | Framework/architecture detection | - | yes | 2-5s |
|
|
110
|
+
| scan-architecture | Architecture violations | 16 | yes | 5-30s |
|
|
111
|
+
| scan-solid | SOLID principle violations | 7 | yes | 3-15s |
|
|
112
|
+
| scan-angular | Angular best practices | 30 | yes | 5-20s |
|
|
113
|
+
| scan-all | Combined analysis (all plugins) | 53 | yes | 10-45s |
|
|
114
|
+
| analyze-core-to-shared | Dependency violation analysis | - | yes | 3-10s |
|
|
115
|
+
| learn-patterns | ML-based pattern discovery | - | yes | 10-60s |
|
|
116
|
+
|
|
117
|
+
#### analyze-project
|
|
118
|
+
|
|
119
|
+
Detects framework (Angular CLI, Nx), analyzes architecture patterns, identifies layers, and discovers project structure including PWA/offline capabilities.
|
|
120
|
+
|
|
121
|
+
Key features:
|
|
122
|
+
- Auto-detects tsconfig.json location
|
|
123
|
+
- Identifies applications and libraries
|
|
124
|
+
- Detects service worker configuration
|
|
125
|
+
- Maps architectural layers from path aliases
|
|
126
|
+
|
|
127
|
+
#### scan-architecture
|
|
128
|
+
|
|
129
|
+
Runs 16 architecture rules detecting circular dependencies, god objects, layer boundary violations, and architectural anti-patterns.
|
|
130
|
+
|
|
131
|
+
Key features:
|
|
132
|
+
- Batch processing (handles unlimited files)
|
|
133
|
+
- Scope filtering (apps, libs, features, folders)
|
|
134
|
+
- Up to 39x speedup with caching (202.8s to 5.2s measured)
|
|
135
|
+
- Parallel execution with auto-selection
|
|
136
|
+
|
|
137
|
+
#### scan-solid
|
|
138
|
+
|
|
139
|
+
Runs 7 SOLID principle rules detecting dependency inversion, single responsibility, Liskov substitution, open/closed, and interface segregation violations.
|
|
140
|
+
|
|
141
|
+
Key features:
|
|
142
|
+
- Pure SOLID principle analysis (DIP, SRP, LSP, OCP, ISP)
|
|
143
|
+
- Identifies tightly-coupled dependencies
|
|
144
|
+
- Detects god objects and bloated classes
|
|
145
|
+
- Independent cache for optimal performance
|
|
146
|
+
|
|
147
|
+
#### scan-angular
|
|
148
|
+
|
|
149
|
+
Runs 30 Angular-specific rules detecting OnPush violations, RxJS anti-patterns, performance issues, and framework best practice violations.
|
|
150
|
+
|
|
151
|
+
Key features:
|
|
152
|
+
- Angular-specific best practices
|
|
153
|
+
- RxJS optimization opportunities
|
|
154
|
+
- Change detection strategy violations
|
|
155
|
+
- Bundle size optimization recommendations
|
|
156
|
+
- Independent cache for Angular analysis
|
|
157
|
+
|
|
158
|
+
#### scan-all
|
|
159
|
+
|
|
160
|
+
Runs all 53 analysis rules (16 architecture + 7 SOLID + 30 Angular) with cross-cache reading for maximum efficiency.
|
|
161
|
+
|
|
162
|
+
Key features:
|
|
163
|
+
- Combines all plugin rules in single scan
|
|
164
|
+
- Reads from fallback caches (architecture/solid/angular)
|
|
165
|
+
- Up to 57% faster when individual scans run first
|
|
166
|
+
- Comprehensive analysis in one execution
|
|
167
|
+
|
|
168
|
+
#### analyze-core-to-shared
|
|
169
|
+
|
|
170
|
+
Detects when the core layer imports from the shared layer (architectural anti-pattern) with reverse dependency impact assessment.
|
|
171
|
+
|
|
172
|
+
Key features:
|
|
173
|
+
- Identifies dependency inversion violations
|
|
174
|
+
- Calculates breaking change risk (LOW/MEDIUM/HIGH)
|
|
175
|
+
- Traces reverse dependencies
|
|
176
|
+
- Provides refactoring recommendations
|
|
177
|
+
|
|
178
|
+
#### learn-patterns
|
|
179
|
+
|
|
180
|
+
Discovers recurring patterns with self-learning capabilities.
|
|
181
|
+
|
|
182
|
+
Key features:
|
|
183
|
+
- 5 pattern categories (RxJS, Component, Service, Transformation, Architectural)
|
|
184
|
+
- Auto-detects codebase style (RxJS preference, DI style, state management)
|
|
185
|
+
- Generates custom analysis rules from patterns
|
|
186
|
+
- Tracks pattern evolution across scans
|
|
187
|
+
|
|
188
|
+
#### collect-feedback
|
|
189
|
+
|
|
190
|
+
Manually collect transformation feedback for AI learning with privacy-first design.
|
|
191
|
+
|
|
192
|
+
Key features:
|
|
193
|
+
- Privacy-first: hashed file paths, no code snippets, bucketed metrics
|
|
194
|
+
- Dual-location storage (project + platform root)
|
|
195
|
+
- Automated validation (6 checks) and quality scoring
|
|
196
|
+
- Outlier detection (4 types) for anomaly handling
|
|
197
|
+
- Learning extraction from transformation outcomes
|
|
198
|
+
|
|
199
|
+
Usage:
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
{
|
|
203
|
+
"transformation": {
|
|
204
|
+
"ruleId": "standalone-migration-v1",
|
|
205
|
+
"targetFile": "/src/app/user.component.ts",
|
|
206
|
+
"approach": "Migrate to standalone component",
|
|
207
|
+
"reasoning": "Isolated component, no complex dependencies",
|
|
208
|
+
"confidence": 0.95
|
|
209
|
+
},
|
|
210
|
+
"execution": {
|
|
211
|
+
"succeeded": true,
|
|
212
|
+
"duration": 1200
|
|
213
|
+
},
|
|
214
|
+
"validation": {
|
|
215
|
+
"buildSuccess": true,
|
|
216
|
+
"testsPass": true
|
|
217
|
+
},
|
|
218
|
+
"storageLocation": "both" // 'project', 'platform', or 'both' (default)
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Returns:
|
|
223
|
+
- `feedbackId`: unique identifier for this feedback
|
|
224
|
+
- `sessionId`: session this feedback belongs to
|
|
225
|
+
- `stored`: boolean indicating successful storage
|
|
226
|
+
- `storageLocations`: array of paths where feedback was saved
|
|
227
|
+
- `validationResult`: quality validation results
|
|
228
|
+
- `learnings`: extracted patterns and insights
|
|
229
|
+
|
|
230
|
+
#### review-feedback
|
|
231
|
+
|
|
232
|
+
Review collected feedback and extract actionable insights for AI learning.
|
|
233
|
+
|
|
234
|
+
Key features:
|
|
235
|
+
- Reads from both project and platform locations (dual-source)
|
|
236
|
+
- Pattern detection: success patterns (>=3 occurrences, >=80% success rate)
|
|
237
|
+
- Failure patterns (>=2 occurrences) for early warning
|
|
238
|
+
- Quality trend analysis (improved/degraded/unchanged)
|
|
239
|
+
- Outlier filtering (<3% outlier rate target)
|
|
240
|
+
- Confidence scoring (0.0-1.0) for each insight
|
|
241
|
+
|
|
242
|
+
Usage:
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
{
|
|
246
|
+
"source": "both",
|
|
247
|
+
"analysisType": "all",
|
|
248
|
+
"minConfidence": 0.7,
|
|
249
|
+
"minCompleteness": 70,
|
|
250
|
+
"category": "standalone-migration",
|
|
251
|
+
"since": "2025-12-01"
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Returns:
|
|
256
|
+
- `sessions`: number of sessions reviewed
|
|
257
|
+
- `transformations`: number of transformations analyzed
|
|
258
|
+
- `successRate`: overall success rate (0.0-1.0)
|
|
259
|
+
- `insights`: array of detected patterns with confidence scores
|
|
260
|
+
- `qualityWarnings`: warnings about low-quality feedback
|
|
261
|
+
- `sourcesRead`: locations where feedback was read from
|
|
262
|
+
|
|
263
|
+
#### suggest-improvements
|
|
264
|
+
|
|
265
|
+
Generate suggestions for transformation rules based on feedback patterns.
|
|
266
|
+
|
|
267
|
+
Key features:
|
|
268
|
+
- 3 suggestion types: parameter-adjustment, prerequisite-check, approach-change
|
|
269
|
+
- Confidence scoring (0.0-1.0) for each suggestion
|
|
270
|
+
- All suggestions require human approval (`requiresApproval: true`)
|
|
271
|
+
- Expected improvement estimates
|
|
272
|
+
- Sorted by confidence (highest first)
|
|
273
|
+
|
|
274
|
+
Suggestion types:
|
|
275
|
+
1. Parameter adjustment: lower confidence thresholds to reduce false positives (>=3 high-confidence failures)
|
|
276
|
+
2. Prerequisite check: add prerequisite checks for common failure patterns (>=40% failures match pattern)
|
|
277
|
+
3. Approach change: switch to alternative approach with >90% success rate (>=3 successes with new approach)
|
|
278
|
+
|
|
279
|
+
Usage:
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
{
|
|
283
|
+
"ruleId": "standalone-migration-v1",
|
|
284
|
+
"source": "both",
|
|
285
|
+
"minConfidence": 0.7
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Returns:
|
|
290
|
+
- `ruleId`: rule these suggestions apply to
|
|
291
|
+
- `suggestions`: array of suggestions sorted by confidence (descending)
|
|
292
|
+
- `totalFeedback`: number of feedback records analyzed
|
|
293
|
+
- `successRate`: current rule success rate
|
|
294
|
+
|
|
295
|
+
Example suggestion:
|
|
296
|
+
|
|
297
|
+
```json
|
|
298
|
+
{
|
|
299
|
+
"type": "parameter-adjustment",
|
|
300
|
+
"confidence": 0.85,
|
|
301
|
+
"suggestion": "Lower confidence threshold from 0.95 to 0.85",
|
|
302
|
+
"reasoning": "3 high-confidence failures detected, threshold too aggressive",
|
|
303
|
+
"expectedImprovement": "Reduce false positives by 40%",
|
|
304
|
+
"requiresApproval": true
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Planning Tools
|
|
309
|
+
|
|
310
|
+
| Tool | Purpose | Cache | Time |
|
|
311
|
+
|-|-|-|-|
|
|
312
|
+
| plan-migration | Style-aware strategy generation | no | 1-3s |
|
|
313
|
+
|
|
314
|
+
#### plan-migration
|
|
315
|
+
|
|
316
|
+
Generates comprehensive migration strategies based on violations, architecture, and codebase style.
|
|
317
|
+
|
|
318
|
+
Key features:
|
|
319
|
+
- Style-aware risk assessment
|
|
320
|
+
- Team context integration (velocity, experience, availability)
|
|
321
|
+
- Multi-phase roadmap generation
|
|
322
|
+
- Identifies style-conflicting steps
|
|
323
|
+
|
|
324
|
+
### Transformation Tools
|
|
325
|
+
|
|
326
|
+
| Tool | Purpose | Cache | Time |
|
|
327
|
+
|-|-|-|-|
|
|
328
|
+
| transform-code | 19 transformation types | no | varies |
|
|
329
|
+
| run-schematic | Angular schematic execution | no | varies |
|
|
330
|
+
| run-angular-cli | CLI command execution | no | varies |
|
|
331
|
+
| run-build | Multi-build system support | no | varies |
|
|
332
|
+
|
|
333
|
+
#### transform-code
|
|
334
|
+
|
|
335
|
+
Applies surgical code transformations with pre-validation, backup, build validation, and automatic rollback.
|
|
336
|
+
|
|
337
|
+
19 transformation types:
|
|
338
|
+
1. constructor-to-inject
|
|
339
|
+
2. interface-extraction
|
|
340
|
+
3. standalone-migration
|
|
341
|
+
4. dependency-injection-migration
|
|
342
|
+
5. facade-pattern
|
|
343
|
+
6. form-modernization
|
|
344
|
+
7. constructor-injection-transform
|
|
345
|
+
8. component-inputs-interface-extraction
|
|
346
|
+
9. service-injection-cleanup
|
|
347
|
+
10. container-presentational
|
|
348
|
+
11. core-shared-modules
|
|
349
|
+
12. inheritance-to-composition
|
|
350
|
+
13. promise-service-to-observable
|
|
351
|
+
14. promise-component-to-reactive
|
|
352
|
+
15. promise-cleanup
|
|
353
|
+
16. sequential-await-to-forkjoin
|
|
354
|
+
17. subscription-transform
|
|
355
|
+
18. missing-output-transform
|
|
356
|
+
19. library-extraction
|
|
357
|
+
|
|
358
|
+
Safety features:
|
|
359
|
+
- Pre-transformation validation (syntax, types, schema)
|
|
360
|
+
- Automatic file backup before changes
|
|
361
|
+
- Build validation (ensures code compiles)
|
|
362
|
+
- Auto-rollback on build failure (prevents broken code)
|
|
363
|
+
- Post-transformation validation (lint, tests)
|
|
364
|
+
- Batch mode with all-or-nothing strategy
|
|
365
|
+
|
|
366
|
+
Build validation parameters:
|
|
367
|
+
- `validateBuild: boolean` - run build after transformation (default: true)
|
|
368
|
+
- `rollbackOnBuildFailure: boolean` - auto-rollback on build errors (default: true)
|
|
369
|
+
- `buildTimeout: number` - build timeout in ms (default: 300000 = 5 min)
|
|
370
|
+
- `projectRoot: string` - project root for build execution
|
|
371
|
+
|
|
372
|
+
Diff format parameters:
|
|
373
|
+
- `diffFormat: 'unified' | 'structured' | 'both'` - diff output format (default: 'unified')
|
|
374
|
+
- `unified`: traditional git-style diff (human-readable, backward compatible)
|
|
375
|
+
- `structured`: machine-first JSON diff with semantic annotations (AI-optimized)
|
|
376
|
+
- `both`: include both formats (useful for debugging, higher overhead)
|
|
377
|
+
|
|
378
|
+
Structured diff features:
|
|
379
|
+
- 13 Angular-specific file type classifications (component, service, module, etc.)
|
|
380
|
+
- 14 TypeScript syntax type annotations (decorator, import, class, method, etc.)
|
|
381
|
+
- Semantic intent inference with confidence scores (0.0-1.0)
|
|
382
|
+
- Angular context extraction (decorators, lifecycle hooks, DI patterns)
|
|
383
|
+
- Related change tracking (imports linked to usage)
|
|
384
|
+
|
|
385
|
+
Supported build systems: Angular CLI, Nx, Vite, Webpack, npm
|
|
386
|
+
|
|
387
|
+
### Validation and Safety Tools
|
|
388
|
+
|
|
389
|
+
| Tool | Purpose | Cache | Time |
|
|
390
|
+
|-|-|-|-|
|
|
391
|
+
| validate-before-transform | Pre-transformation checks | no | 1-2s |
|
|
392
|
+
| validate-transformation | Post-transformation checks | no | 30-300s |
|
|
393
|
+
| rollback-changes | Revert transformations | no | <1s |
|
|
394
|
+
|
|
395
|
+
---
|
|
396
|
+
|
|
397
|
+
## Advanced Features
|
|
398
|
+
|
|
399
|
+
### Cross-Cache Reading System
|
|
400
|
+
|
|
401
|
+
`scan-all` reads from individual plugin caches written by `scan-architecture`, `scan-solid`, and `scan-angular`. When those tools have run first, `scan-all` avoids re-analyzing files it already has results for.
|
|
402
|
+
|
|
403
|
+
Performance impact:
|
|
404
|
+
|
|
405
|
+
```
|
|
406
|
+
Workflow: scan-architecture -> scan-solid -> scan-angular -> scan-all
|
|
407
|
+
|
|
408
|
+
Without cross-cache: scan-all analyzes all 450 files
|
|
409
|
+
With cross-cache: scan-all reads cached results (up to 57% reduction)
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
Cache statistics example:
|
|
413
|
+
|
|
414
|
+
```json
|
|
415
|
+
{
|
|
416
|
+
"hitRate": 0.0,
|
|
417
|
+
"hitsBySource": {
|
|
418
|
+
"architecture": 150,
|
|
419
|
+
"solid": 150,
|
|
420
|
+
"angular": 150
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
A `hitRate` of 0% with non-zero `hitsBySource` is correct: it means the primary cache (scan-all's own) is empty on the first run, but fallback caches from the other tools are being read successfully. The second `scan-all` run will have `hitRate > 0%`.
|
|
426
|
+
|
|
427
|
+
Best practice: run individual scans first, then `scan-all` for maximum cache benefit.
|
|
428
|
+
|
|
429
|
+
### Intelligent Mode Selection
|
|
430
|
+
|
|
431
|
+
The orchestration system automatically selects between Promise-based and worker thread parallelism based on project complexity score:
|
|
432
|
+
|
|
433
|
+
```
|
|
434
|
+
Score 0-35: Promise mode (small projects)
|
|
435
|
+
Score 35-50: Promise mode with monitoring
|
|
436
|
+
Score 50-75: Worker mode preferred
|
|
437
|
+
Score 75-100: Worker mode required
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
Performance results (1,500 files, 13 rules):
|
|
441
|
+
- Auto-selection: 251.81s
|
|
442
|
+
- Forced worker mode: 279.83s
|
|
443
|
+
- Auto-selection was 1.14x faster
|
|
444
|
+
|
|
445
|
+
Memory management:
|
|
446
|
+
- RAM-aware worker count (2-8 workers, not CPU-based)
|
|
447
|
+
- Worker recycling at 80% heap threshold
|
|
448
|
+
- Real-time monitoring with automatic fallback
|
|
449
|
+
- Isolated worker heaps prevent cascade failures
|
|
450
|
+
|
|
451
|
+
Configuration (enabled by default):
|
|
452
|
+
|
|
453
|
+
```typescript
|
|
454
|
+
orchestration: {
|
|
455
|
+
autoSelectMode: true, // Default, no configuration needed
|
|
456
|
+
}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
### Self-Learning Pattern Knowledge Base
|
|
460
|
+
|
|
461
|
+
The `learn-patterns` tool persists discovered patterns across scans in `.angular-modernizer-cache/pattern-knowledge.json`. This enables pattern evolution tracking, confidence improvement over time, style shift detection, and pattern velocity measurement.
|
|
462
|
+
|
|
463
|
+
Example evolution output:
|
|
464
|
+
|
|
465
|
+
```json
|
|
466
|
+
{
|
|
467
|
+
"scan1": { "patterns": 15, "avgConfidence": 0.65 },
|
|
468
|
+
"scan2": { "patterns": 18, "avgConfidence": 0.72 },
|
|
469
|
+
"scan3": { "patterns": 16, "avgConfidence": 0.78 },
|
|
470
|
+
"evolution": {
|
|
471
|
+
"newPatterns": 3,
|
|
472
|
+
"deprecatedPatterns": 2,
|
|
473
|
+
"confidenceImprovement": 0.13,
|
|
474
|
+
"patternStability": 0.85
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
---
|
|
480
|
+
|
|
481
|
+
## Configuration
|
|
482
|
+
|
|
483
|
+
### Tool-Specific Configuration
|
|
484
|
+
|
|
485
|
+
Create `.angular-modernizer.json`:
|
|
486
|
+
|
|
487
|
+
```json
|
|
488
|
+
{
|
|
489
|
+
"analyze-project": {
|
|
490
|
+
"rootPath": ".",
|
|
491
|
+
"excludePatterns": ["**/node_modules/**", "**/dist/**"],
|
|
492
|
+
"maxResults": 1000,
|
|
493
|
+
"orchestration": {
|
|
494
|
+
"parallel": true,
|
|
495
|
+
"autoSelectMode": true,
|
|
496
|
+
"enableProgress": true
|
|
497
|
+
}
|
|
498
|
+
},
|
|
499
|
+
"scan-architecture": {
|
|
500
|
+
"rootPath": ".",
|
|
501
|
+
"maxFiles": 500,
|
|
502
|
+
"includeAutoFixes": true,
|
|
503
|
+
"orchestration": {
|
|
504
|
+
"parallel": true,
|
|
505
|
+
"incremental": false,
|
|
506
|
+
"autoSelectMode": true,
|
|
507
|
+
"enableProgress": true,
|
|
508
|
+
"timeout": 120000
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
"learn-patterns": {
|
|
512
|
+
"targetPath": ".",
|
|
513
|
+
"categories": ["all"],
|
|
514
|
+
"minOccurrences": 3,
|
|
515
|
+
"enableLearning": true,
|
|
516
|
+
"generateStyleProfile": true,
|
|
517
|
+
"respectCodebaseStyle": true
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### Cache Configuration
|
|
523
|
+
|
|
524
|
+
Caching is enabled by default for analysis tools:
|
|
525
|
+
|
|
526
|
+
```typescript
|
|
527
|
+
cacheConfig: {
|
|
528
|
+
enabled: true,
|
|
529
|
+
cacheDir: '.angular-modernizer-cache',
|
|
530
|
+
maxSize: 100 * 1024 * 1024, // 100MB
|
|
531
|
+
maxAge: 24 * 60 * 60 * 1000, // 24 hours
|
|
532
|
+
compression: true
|
|
533
|
+
}
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
Cache locations:
|
|
537
|
+
- `architecture`: `.angular-modernizer-cache/architecture/`
|
|
538
|
+
- `solid`: `.angular-modernizer-cache/solid/`
|
|
539
|
+
- `angular`: `.angular-modernizer-cache/angular/`
|
|
540
|
+
- `patterns`: `.angular-modernizer-cache/pattern-knowledge.json`
|
|
541
|
+
|
|
542
|
+
When to clear cache:
|
|
543
|
+
- After major codebase changes (framework upgrade, large refactoring)
|
|
544
|
+
- When rules are updated
|
|
545
|
+
- If cache corruption is suspected
|
|
546
|
+
|
|
547
|
+
```bash
|
|
548
|
+
rm -rf .angular-modernizer-cache
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
### Orchestration Tuning
|
|
552
|
+
|
|
553
|
+
For large projects (500+ files):
|
|
554
|
+
|
|
555
|
+
```json
|
|
556
|
+
{
|
|
557
|
+
"orchestration": {
|
|
558
|
+
"parallel": true,
|
|
559
|
+
"autoSelectMode": true,
|
|
560
|
+
"maxWorkers": 6,
|
|
561
|
+
"enableProgress": true,
|
|
562
|
+
"enableMonitoring": true,
|
|
563
|
+
"resourceLimits": {
|
|
564
|
+
"maxMemory": 4294967296,
|
|
565
|
+
"maxWorkers": 8
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
For small projects (<100 files):
|
|
572
|
+
|
|
573
|
+
```json
|
|
574
|
+
{
|
|
575
|
+
"orchestration": {
|
|
576
|
+
"parallel": false,
|
|
577
|
+
"autoSelectMode": true
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
---
|
|
583
|
+
|
|
584
|
+
## Best Practices
|
|
585
|
+
|
|
586
|
+
### Recommended Workflows
|
|
587
|
+
|
|
588
|
+
#### Initial Assessment
|
|
589
|
+
|
|
590
|
+
```
|
|
591
|
+
1. analyze-project
|
|
592
|
+
(framework, architecture, layers)
|
|
593
|
+
2. scan-architecture
|
|
594
|
+
(violations by category)
|
|
595
|
+
3. learn-patterns
|
|
596
|
+
(codebase style profile)
|
|
597
|
+
4. plan-migration
|
|
598
|
+
(style-aware strategy)
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
#### Safe Transformation
|
|
602
|
+
|
|
603
|
+
```
|
|
604
|
+
1. validate-before-transform
|
|
605
|
+
(check syntax, types, dependencies)
|
|
606
|
+
2. transform-code (with safety flags)
|
|
607
|
+
(backup -> transform -> validate)
|
|
608
|
+
3. validate-transformation
|
|
609
|
+
(build, lint, tests)
|
|
610
|
+
4. rollback-changes (if needed)
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
#### Incremental Monitoring
|
|
614
|
+
|
|
615
|
+
```
|
|
616
|
+
Day 1: Full scan + cache write
|
|
617
|
+
Day 2+: Incremental scan (changed files only)
|
|
618
|
+
Weekly: Full scan + pattern evolution check
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
### Cache Optimization
|
|
622
|
+
|
|
623
|
+
Run individual scans before `scan-all`:
|
|
624
|
+
|
|
625
|
+
```bash
|
|
626
|
+
# Step 1: Individual scans (write plugin-specific caches)
|
|
627
|
+
scan-architecture # Writes: .cache/architecture/
|
|
628
|
+
scan-solid # Writes: .cache/solid/
|
|
629
|
+
scan-angular # Writes: .cache/angular/
|
|
630
|
+
|
|
631
|
+
# Step 2: Combined scan (reads from fallback caches)
|
|
632
|
+
scan-all # Reads from all above caches (up to 57% faster)
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
Second run performance:
|
|
636
|
+
- architecture: 202.8s to 5.2s (39x speedup)
|
|
637
|
+
- solid: 85.3s to 5.7s (14.9x speedup)
|
|
638
|
+
- angular: 65.2s to 43.5s (1.5x speedup)
|
|
639
|
+
|
|
640
|
+
### Safety Guidelines
|
|
641
|
+
|
|
642
|
+
Always use safety features:
|
|
643
|
+
|
|
644
|
+
```typescript
|
|
645
|
+
transform-code: {
|
|
646
|
+
validateBeforeTransform: true,
|
|
647
|
+
createBackup: true,
|
|
648
|
+
validateTransformation: true,
|
|
649
|
+
autoRollback: true
|
|
650
|
+
}
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
Batch transformations:
|
|
654
|
+
|
|
655
|
+
```typescript
|
|
656
|
+
{
|
|
657
|
+
files: [...],
|
|
658
|
+
rollbackStrategy: "all-or-nothing"
|
|
659
|
+
}
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
---
|
|
663
|
+
|
|
664
|
+
## Streaming Progress
|
|
665
|
+
|
|
666
|
+
The streaming progress feature provides real-time feedback during long-running transformations through a polling-based architecture. AI assistants can monitor progress, display diffs, and detect errors as they occur.
|
|
667
|
+
|
|
668
|
+
Key capabilities:
|
|
669
|
+
- Real-time progress (percentage, phase, and ETA updates)
|
|
670
|
+
- Unified diffs (git-style diffs for every file transformation)
|
|
671
|
+
- Syntax validation (lightweight error detection without compilation)
|
|
672
|
+
- Memory tracking (continuous heap usage monitoring)
|
|
673
|
+
- Incremental polling (fetch only new events since last poll)
|
|
674
|
+
- Zero overhead (only active when explicitly used)
|
|
675
|
+
|
|
676
|
+
### Architecture
|
|
677
|
+
|
|
678
|
+
```
|
|
679
|
+
AI Assistant -> Start Operation -> Background Execution
|
|
680
|
+
| | |
|
|
681
|
+
Poll Progress -> ProgressStore <- Stream Events
|
|
682
|
+
| |
|
|
683
|
+
Display Updates Transform Files
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
Polling pattern:
|
|
687
|
+
1. Start transformation, receive `operationId`
|
|
688
|
+
2. Poll `get-operation-progress` with `operationId`
|
|
689
|
+
3. Display progress, diffs, errors to user
|
|
690
|
+
4. Continue polling until `status: 'completed'`
|
|
691
|
+
|
|
692
|
+
### Quick Start
|
|
693
|
+
|
|
694
|
+
Start a streaming operation:
|
|
695
|
+
|
|
696
|
+
```typescript
|
|
697
|
+
{
|
|
698
|
+
"tool": "transform-code-batch",
|
|
699
|
+
"arguments": {
|
|
700
|
+
"rules": ["standalone-migration"],
|
|
701
|
+
"patterns": ["src/**/*.component.ts"]
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
// Response
|
|
706
|
+
{
|
|
707
|
+
"operationId": "transform-20251209-123456-abc",
|
|
708
|
+
"status": "running",
|
|
709
|
+
"message": "Transformation started in background"
|
|
710
|
+
}
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
Poll for progress:
|
|
714
|
+
|
|
715
|
+
```typescript
|
|
716
|
+
{
|
|
717
|
+
"tool": "get-operation-progress",
|
|
718
|
+
"arguments": {
|
|
719
|
+
"operationId": "transform-20251209-123456-abc"
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
// Response
|
|
724
|
+
{
|
|
725
|
+
"operationId": "transform-20251209-123456-abc",
|
|
726
|
+
"status": "running",
|
|
727
|
+
"events": [
|
|
728
|
+
{
|
|
729
|
+
"phase": "transforming",
|
|
730
|
+
"percentage": 50,
|
|
731
|
+
"message": "Transforming home.component.ts",
|
|
732
|
+
"timestamp": 1733750401000,
|
|
733
|
+
"diff": {
|
|
734
|
+
"filePath": "src/app/home/home.component.ts",
|
|
735
|
+
"diff": "--- src/app/home/home.component.ts\n+++ ...",
|
|
736
|
+
"linesAdded": 4,
|
|
737
|
+
"linesRemoved": 1
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
],
|
|
741
|
+
"totalEvents": 5,
|
|
742
|
+
"elapsedTime": 2500,
|
|
743
|
+
"eta": 2500
|
|
744
|
+
}
|
|
745
|
+
```
|
|
746
|
+
|
|
747
|
+
Incremental polling (recommended):
|
|
748
|
+
|
|
749
|
+
```typescript
|
|
750
|
+
// First poll: get all events
|
|
751
|
+
const poll1 = await getProgress({ operationId });
|
|
752
|
+
|
|
753
|
+
// Subsequent polls: get only new events
|
|
754
|
+
const poll2 = await getProgress({
|
|
755
|
+
operationId,
|
|
756
|
+
sinceTimestamp: poll1.events[poll1.events.length - 1].timestamp,
|
|
757
|
+
});
|
|
758
|
+
```
|
|
759
|
+
|
|
760
|
+
### Event Structure
|
|
761
|
+
|
|
762
|
+
```typescript
|
|
763
|
+
interface StreamingProgressEvent {
|
|
764
|
+
phase: 'analyzing' | 'transforming' | 'validating' | 'building' | 'complete';
|
|
765
|
+
percentage: number; // 0-100
|
|
766
|
+
message: string;
|
|
767
|
+
timestamp: number; // Unix timestamp (ms)
|
|
768
|
+
|
|
769
|
+
currentFile?: string;
|
|
770
|
+
|
|
771
|
+
diff?: {
|
|
772
|
+
filePath: string;
|
|
773
|
+
diff: string; // Unified diff
|
|
774
|
+
linesAdded: number;
|
|
775
|
+
linesRemoved: number;
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
syntaxErrors?: Array<{
|
|
779
|
+
filePath: string;
|
|
780
|
+
line: number;
|
|
781
|
+
message: string;
|
|
782
|
+
}>;
|
|
783
|
+
|
|
784
|
+
memoryUsage?: {
|
|
785
|
+
heapUsed: number;
|
|
786
|
+
heapTotal: number;
|
|
787
|
+
percentage: number; // 0-100
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
```
|
|
791
|
+
|
|
792
|
+
### Progress Phases
|
|
793
|
+
|
|
794
|
+
```
|
|
795
|
+
analyzing (0-10%) : Project setup, file discovery
|
|
796
|
+
transforming (10-90%) : Per-file AST transformation
|
|
797
|
+
validating (90-95%) : Syntax validation
|
|
798
|
+
building (95-98%) : Optional compilation check
|
|
799
|
+
complete (100%) : Final summary
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
### Performance Impact
|
|
803
|
+
|
|
804
|
+
| Configuration | Overhead | Use Case |
|
|
805
|
+
|-|-|-|
|
|
806
|
+
| No streaming | 0% | Automation, CI/CD |
|
|
807
|
+
| Minimal streaming | ~2-3% | Progress tracking only |
|
|
808
|
+
| Full streaming | ~8-16% | AI assistants (diffs + validation) |
|
|
809
|
+
|
|
810
|
+
Overhead breakdown:
|
|
811
|
+
- Event generation: ~2-3%
|
|
812
|
+
- Diff generation: ~5-10% (only modified files)
|
|
813
|
+
- Syntax detection: ~1-2%
|
|
814
|
+
- Memory tracking: <1%
|
|
815
|
+
|
|
816
|
+
When to use streaming:
|
|
817
|
+
- Long-running operations (>10 seconds)
|
|
818
|
+
- Large projects (>100 files)
|
|
819
|
+
- AI assistants requiring feedback
|
|
820
|
+
- User needs diff visibility
|
|
821
|
+
|
|
822
|
+
When to use batch (non-streaming):
|
|
823
|
+
- Short operations (<10 seconds)
|
|
824
|
+
- Automation/CI/CD
|
|
825
|
+
- Performance-critical scenarios
|
|
826
|
+
|
|
827
|
+
---
|
|
828
|
+
|
|
829
|
+
## Troubleshooting
|
|
830
|
+
|
|
831
|
+
### "Insufficient resources to proceed"
|
|
832
|
+
|
|
833
|
+
Cause: memory or worker limit exceeded.
|
|
834
|
+
|
|
835
|
+
Solutions:
|
|
836
|
+
1. Reduce batch size: `maxFiles: 50`
|
|
837
|
+
2. Enable auto-selection: `autoSelectMode: true`
|
|
838
|
+
3. Set memory limit: `resourceLimits.maxMemory: 4GB`
|
|
839
|
+
4. Reduce workers: `maxWorkers: 2`
|
|
840
|
+
|
|
841
|
+
### "Cache hit rate 0% - is cache working?"
|
|
842
|
+
|
|
843
|
+
Yes, this is normal for the first run or for `scan-all` using the cross-cache system.
|
|
844
|
+
|
|
845
|
+
- `hitRate: 0%` means the primary cache (scan-all's own plugin cache) is empty
|
|
846
|
+
- `hitsBySource: {...}` with non-zero values means fallback caches are working correctly
|
|
847
|
+
- The second run will have `hitRate > 0%`
|
|
848
|
+
|
|
849
|
+
### "Worker threads not available (offline mode)"
|
|
850
|
+
|
|
851
|
+
Cause: worker script not compiled or unavailable.
|
|
852
|
+
|
|
853
|
+
Solutions:
|
|
854
|
+
1. Build project: `pnpm build`
|
|
855
|
+
2. Set manual mode: `useWorkerThreads: false`
|
|
856
|
+
3. Trust auto-selection: `autoSelectMode: true` (auto-detects and uses Promises)
|
|
857
|
+
|
|
858
|
+
### "Transformation failed - syntax errors"
|
|
859
|
+
|
|
860
|
+
Cause: code has existing syntax/type errors.
|
|
861
|
+
|
|
862
|
+
Solutions:
|
|
863
|
+
1. Check `preValidation.issues` array
|
|
864
|
+
2. Fix reported errors before transforming
|
|
865
|
+
3. Use `validateBeforeTransform: true` (default)
|
|
866
|
+
|
|
867
|
+
### "Memory exceeded during analysis"
|
|
868
|
+
|
|
869
|
+
Cause: large project analyzed without batching.
|
|
870
|
+
|
|
871
|
+
Solutions:
|
|
872
|
+
1. Use default `maxFiles: 100` (batching enabled)
|
|
873
|
+
2. Enable monitoring: `enableMonitoring: true`
|
|
874
|
+
3. Set memory limit: `resourceLimits.maxMemory`
|
|
875
|
+
4. Clear cache: `rm -rf .angular-modernizer-cache`
|
|
876
|
+
|
|
877
|
+
---
|
|
878
|
+
|
|
879
|
+
## Performance Guide
|
|
880
|
+
|
|
881
|
+
### Expected Timings by Project Size
|
|
882
|
+
|
|
883
|
+
| Project Size | Files | analyze-project | scan-architecture | learn-patterns |
|
|
884
|
+
|-|-|-|-|-|
|
|
885
|
+
| Small | <100 | 2-3s | 5-10s (cache: 1s) | 10-20s |
|
|
886
|
+
| Medium | 100-500 | 5-10s | 15-30s (cache: 3s) | 20-40s |
|
|
887
|
+
| Large | 500-1500 | 10-20s | 60-120s (cache: 5s) | 40-90s |
|
|
888
|
+
| Enterprise | 1500+ | 20-40s | 180-300s (cache: 10s) | 90-180s |
|
|
889
|
+
|
|
890
|
+
Cache timings apply to the second run with full cache hit.
|
|
891
|
+
|
|
892
|
+
### Memory Requirements
|
|
893
|
+
|
|
894
|
+
| Configuration | Peak Memory | Recommended RAM |
|
|
895
|
+
|-|-|-|
|
|
896
|
+
| Sequential | ~800MB | 2GB |
|
|
897
|
+
| Promise (4 workers) | ~1.2GB | 4GB |
|
|
898
|
+
| Worker (4 workers) | ~3.2GB | 8GB |
|
|
899
|
+
| Auto-selection | ~1.5GB | 4GB |
|
|
900
|
+
|
|
901
|
+
Memory calculation:
|
|
902
|
+
- Base: ~400MB (Node.js + ts-morph)
|
|
903
|
+
- Per file: ~1-2MB (AST + analysis)
|
|
904
|
+
- Per worker: ~300-500MB (isolated heap)
|
|
905
|
+
|
|
906
|
+
---
|
|
907
|
+
|
|
908
|
+
## Links
|
|
909
|
+
|
|
910
|
+
- Tools Reference: `src/tools/README.md`
|
|
911
|
+
- MCP Protocol: https://modelcontextprotocol.io/
|
|
912
|
+
|
|
913
|
+
---
|
|
914
|
+
|
|
915
|
+
## License
|
|
916
|
+
|
|
917
|
+
MIT License - See LICENSE file for details
|