@angular-modernizer/adapter-mcp 0.3.0 → 1.1.0

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.
Files changed (298) hide show
  1. package/README.md +181 -282
  2. package/dist/cli.js +21 -13
  3. package/dist/core/project-analyzer.d.ts +3 -12
  4. package/dist/core/project-analyzer.js +3 -12
  5. package/dist/index.d.ts +122 -6
  6. package/dist/index.js +49 -5
  7. package/dist/mcp-watcher.d.ts +32 -7
  8. package/dist/mcp-watcher.js +16 -15
  9. package/dist/scan-host/scan-host.d.ts +119 -0
  10. package/dist/scan-host/scan-host.js +376 -0
  11. package/dist/scan-host/scan-protocol.d.ts +35 -0
  12. package/dist/scan-host/scan-protocol.js +6 -0
  13. package/dist/scan-host/scan-worker.d.ts +14 -0
  14. package/dist/scan-host/scan-worker.js +48 -0
  15. package/dist/server/limited-stdio-transport.d.ts +75 -0
  16. package/dist/server/limited-stdio-transport.js +115 -0
  17. package/dist/server/mcp-server.d.ts +20 -18
  18. package/dist/server/mcp-server.js +42 -79
  19. package/dist/server/package-version.d.ts +16 -0
  20. package/dist/server/package-version.js +37 -0
  21. package/dist/server/sdk-server.d.ts +71 -0
  22. package/dist/server/sdk-server.js +113 -0
  23. package/dist/server/tool-registry.d.ts +6 -9
  24. package/dist/server/tool-registry.js +6 -12
  25. package/dist/streaming/progress-store.d.ts +22 -5
  26. package/dist/streaming/progress-store.js +9 -5
  27. package/dist/tools/analyze-build-impact.d.ts +276 -35
  28. package/dist/tools/analyze-build-impact.js +175 -28
  29. package/dist/tools/analyze-core-to-shared.d.ts +176 -16
  30. package/dist/tools/analyze-core-to-shared.js +124 -19
  31. package/dist/tools/analyze-parser-performance.d.ts +209 -15
  32. package/dist/tools/analyze-parser-performance.js +119 -56
  33. package/dist/tools/analyze-project.d.ts +349 -17
  34. package/dist/tools/analyze-project.js +282 -97
  35. package/dist/tools/check-incremental-compatibility.d.ts +74 -12
  36. package/dist/tools/check-incremental-compatibility.js +69 -10
  37. package/dist/tools/collect-feedback.d.ts +225 -21
  38. package/dist/tools/collect-feedback.js +199 -118
  39. package/dist/tools/compare-health.d.ts +413 -0
  40. package/dist/tools/compare-health.js +479 -0
  41. package/dist/tools/extract-libraries.d.ts +200 -24
  42. package/dist/tools/extract-libraries.js +131 -27
  43. package/dist/tools/find-angular-symbol.d.ts +92 -24
  44. package/dist/tools/find-angular-symbol.js +70 -20
  45. package/dist/tools/find-component-hosts.d.ts +603 -27
  46. package/dist/tools/find-component-hosts.js +223 -19
  47. package/dist/tools/find-usages.d.ts +102 -22
  48. package/dist/tools/find-usages.js +81 -21
  49. package/dist/tools/get-bootstrap-execution.d.ts +183 -25
  50. package/dist/tools/get-bootstrap-execution.js +109 -25
  51. package/dist/tools/get-call-graph.d.ts +127 -12
  52. package/dist/tools/get-call-graph.js +84 -19
  53. package/dist/tools/get-operation-progress-tool.d.ts +126 -8
  54. package/dist/tools/get-operation-progress-tool.js +124 -12
  55. package/dist/tools/get-operation-progress.d.ts +27 -1
  56. package/dist/tools/get-operation-progress.js +5 -5
  57. package/dist/tools/helpers/analysis-output.d.ts +182 -0
  58. package/dist/tools/helpers/analysis-output.js +165 -0
  59. package/dist/tools/helpers/batch-kernel.d.ts +14 -0
  60. package/dist/tools/helpers/batch-kernel.js +12 -0
  61. package/dist/tools/helpers/build-schemas.d.ts +36 -0
  62. package/dist/tools/helpers/build-schemas.js +23 -0
  63. package/dist/tools/helpers/citation-file-source.d.ts +10 -0
  64. package/dist/tools/helpers/citation-file-source.js +82 -0
  65. package/dist/tools/helpers/compact-output.d.ts +2 -1
  66. package/dist/tools/helpers/compact-output.js +2 -1
  67. package/dist/tools/helpers/finding-window.d.ts +43 -0
  68. package/dist/tools/helpers/finding-window.js +64 -0
  69. package/dist/tools/helpers/health-delta.d.ts +99 -0
  70. package/dist/tools/helpers/health-delta.js +236 -0
  71. package/dist/tools/helpers/investigation-schemas.d.ts +93 -0
  72. package/dist/tools/helpers/investigation-schemas.js +48 -0
  73. package/dist/tools/helpers/library-imports.d.ts +57 -0
  74. package/dist/tools/helpers/library-imports.js +151 -0
  75. package/dist/tools/helpers/load-source-files.d.ts +30 -0
  76. package/dist/tools/helpers/load-source-files.js +34 -0
  77. package/dist/tools/helpers/output-contract.d.ts +32 -0
  78. package/dist/tools/helpers/output-contract.js +32 -0
  79. package/dist/tools/helpers/platform-root-resolver.d.ts +55 -25
  80. package/dist/tools/helpers/platform-root-resolver.js +75 -48
  81. package/dist/tools/helpers/process-output.d.ts +19 -0
  82. package/dist/tools/helpers/process-output.js +31 -0
  83. package/dist/tools/helpers/project-cache.d.ts +60 -37
  84. package/dist/tools/helpers/project-cache.js +54 -37
  85. package/dist/tools/helpers/project-decorators.d.ts +14 -0
  86. package/dist/tools/helpers/project-decorators.js +22 -0
  87. package/dist/tools/helpers/rule-matcher.js +5 -0
  88. package/dist/tools/helpers/rule-runner.d.ts +25 -13
  89. package/dist/tools/helpers/rule-runner.js +45 -24
  90. package/dist/tools/helpers/scan-cache.d.ts +22 -0
  91. package/dist/tools/helpers/scan-cache.js +34 -0
  92. package/dist/tools/helpers/scan-engine.d.ts +107 -0
  93. package/dist/tools/helpers/scan-engine.js +197 -0
  94. package/dist/tools/helpers/scan-plan.d.ts +5 -2
  95. package/dist/tools/helpers/scan-plan.js +18 -3
  96. package/dist/tools/helpers/scope-paths.d.ts +17 -0
  97. package/dist/tools/helpers/scope-paths.js +32 -0
  98. package/dist/tools/helpers/suggestion-generator.d.ts +9 -13
  99. package/dist/tools/helpers/suggestion-generator.js +0 -12
  100. package/dist/tools/helpers/tool-cache.d.ts +11 -0
  101. package/dist/tools/helpers/tool-cache.js +15 -0
  102. package/dist/tools/helpers/tool-context.d.ts +63 -0
  103. package/dist/tools/helpers/tool-context.js +79 -0
  104. package/dist/tools/helpers/transform-safety.d.ts +40 -0
  105. package/dist/tools/helpers/transform-safety.js +87 -0
  106. package/dist/tools/helpers/validation-output.d.ts +53 -0
  107. package/dist/tools/helpers/validation-output.js +48 -0
  108. package/dist/tools/inspect-form-group.d.ts +262 -24
  109. package/dist/tools/inspect-form-group.js +134 -13
  110. package/dist/tools/inspect-i18n.d.ts +410 -23
  111. package/dist/tools/inspect-i18n.js +213 -13
  112. package/dist/tools/inspect-template.d.ts +260 -22
  113. package/dist/tools/inspect-template.js +174 -13
  114. package/dist/tools/learn-patterns.d.ts +210 -13
  115. package/dist/tools/learn-patterns.js +113 -12
  116. package/dist/tools/list-imports.d.ts +152 -34
  117. package/dist/tools/list-imports.js +124 -18
  118. package/dist/tools/orchestrate-migration.d.ts +159 -14
  119. package/dist/tools/orchestrate-migration.js +147 -20
  120. package/dist/tools/parse-stack-trace.d.ts +78 -21
  121. package/dist/tools/parse-stack-trace.js +44 -7
  122. package/dist/tools/plan-migration.d.ts +395 -26
  123. package/dist/tools/plan-migration.js +173 -22
  124. package/dist/tools/resolve-type.d.ts +57 -9
  125. package/dist/tools/resolve-type.js +49 -12
  126. package/dist/tools/review-feedback.d.ts +214 -16
  127. package/dist/tools/review-feedback.js +142 -57
  128. package/dist/tools/rollback-changes.d.ts +88 -7
  129. package/dist/tools/rollback-changes.js +74 -19
  130. package/dist/tools/run-angular-cli.d.ts +57 -12
  131. package/dist/tools/run-angular-cli.js +76 -13
  132. package/dist/tools/run-build.d.ts +127 -13
  133. package/dist/tools/run-build.js +128 -16
  134. package/dist/tools/run-schematic.d.ts +82 -12
  135. package/dist/tools/run-schematic.js +115 -18
  136. package/dist/tools/scan-all.d.ts +88 -23
  137. package/dist/tools/scan-all.js +161 -220
  138. package/dist/tools/scan-angular.d.ts +60 -19
  139. package/dist/tools/scan-angular.js +100 -141
  140. package/dist/tools/scan-architecture.d.ts +92 -24
  141. package/dist/tools/scan-architecture.js +268 -211
  142. package/dist/tools/scan-solid.d.ts +59 -19
  143. package/dist/tools/scan-solid.js +98 -139
  144. package/dist/tools/search-codebase.d.ts +110 -23
  145. package/dist/tools/search-codebase.js +67 -11
  146. package/dist/tools/server-status.d.ts +392 -26
  147. package/dist/tools/server-status.js +260 -27
  148. package/dist/tools/suggest-improvements.d.ts +105 -10
  149. package/dist/tools/suggest-improvements.js +91 -51
  150. package/dist/tools/trace-output-flow.d.ts +713 -26
  151. package/dist/tools/trace-output-flow.js +396 -33
  152. package/dist/tools/transform-code-batch.d.ts +3 -0
  153. package/dist/tools/transform-code-batch.js +10 -5
  154. package/dist/tools/transform-code.d.ts +402 -18
  155. package/dist/tools/transform-code.js +708 -649
  156. package/dist/tools/validate-before-transform.d.ts +136 -7
  157. package/dist/tools/validate-before-transform.js +65 -9
  158. package/dist/tools/validate-project-compatibility.d.ts +82 -15
  159. package/dist/tools/validate-project-compatibility.js +84 -15
  160. package/dist/tools/validate-transformation.d.ts +243 -8
  161. package/dist/tools/validate-transformation.js +127 -23
  162. package/dist/tools/verify-citations.d.ts +202 -0
  163. package/dist/tools/verify-citations.js +221 -0
  164. package/dist/types.d.ts +78 -11
  165. package/dist/types.js +0 -5
  166. package/dist/utils/format-tool-response.d.ts +22 -59
  167. package/dist/utils/format-tool-response.js +25 -134
  168. package/package.json +31 -20
  169. package/dist/cli.d.ts.map +0 -1
  170. package/dist/cli.js.map +0 -1
  171. package/dist/core/project-analyzer.d.ts.map +0 -1
  172. package/dist/core/project-analyzer.js.map +0 -1
  173. package/dist/index.d.ts.map +0 -1
  174. package/dist/index.js.map +0 -1
  175. package/dist/mcp-watcher.d.ts.map +0 -1
  176. package/dist/mcp-watcher.js.map +0 -1
  177. package/dist/server/json-rpc-handler.d.ts +0 -98
  178. package/dist/server/json-rpc-handler.d.ts.map +0 -1
  179. package/dist/server/json-rpc-handler.js +0 -301
  180. package/dist/server/json-rpc-handler.js.map +0 -1
  181. package/dist/server/mcp-server.d.ts.map +0 -1
  182. package/dist/server/mcp-server.js.map +0 -1
  183. package/dist/server/stdio-guard.d.ts.map +0 -1
  184. package/dist/server/stdio-guard.js.map +0 -1
  185. package/dist/server/tool-registry.d.ts.map +0 -1
  186. package/dist/server/tool-registry.js.map +0 -1
  187. package/dist/streaming/progress-store.d.ts.map +0 -1
  188. package/dist/streaming/progress-store.js.map +0 -1
  189. package/dist/tools/analyze-build-impact.d.ts.map +0 -1
  190. package/dist/tools/analyze-build-impact.js.map +0 -1
  191. package/dist/tools/analyze-core-to-shared.d.ts.map +0 -1
  192. package/dist/tools/analyze-core-to-shared.js.map +0 -1
  193. package/dist/tools/analyze-parser-performance.d.ts.map +0 -1
  194. package/dist/tools/analyze-parser-performance.js.map +0 -1
  195. package/dist/tools/analyze-project.d.ts.map +0 -1
  196. package/dist/tools/analyze-project.js.map +0 -1
  197. package/dist/tools/check-incremental-compatibility.d.ts.map +0 -1
  198. package/dist/tools/check-incremental-compatibility.js.map +0 -1
  199. package/dist/tools/collect-feedback.d.ts.map +0 -1
  200. package/dist/tools/collect-feedback.js.map +0 -1
  201. package/dist/tools/extract-libraries.d.ts.map +0 -1
  202. package/dist/tools/extract-libraries.js.map +0 -1
  203. package/dist/tools/find-angular-symbol.d.ts.map +0 -1
  204. package/dist/tools/find-angular-symbol.js.map +0 -1
  205. package/dist/tools/find-component-hosts.d.ts.map +0 -1
  206. package/dist/tools/find-component-hosts.js.map +0 -1
  207. package/dist/tools/find-usages.d.ts.map +0 -1
  208. package/dist/tools/find-usages.js.map +0 -1
  209. package/dist/tools/get-bootstrap-execution.d.ts.map +0 -1
  210. package/dist/tools/get-bootstrap-execution.js.map +0 -1
  211. package/dist/tools/get-call-graph.d.ts.map +0 -1
  212. package/dist/tools/get-call-graph.js.map +0 -1
  213. package/dist/tools/get-operation-progress-tool.d.ts.map +0 -1
  214. package/dist/tools/get-operation-progress-tool.js.map +0 -1
  215. package/dist/tools/get-operation-progress.d.ts.map +0 -1
  216. package/dist/tools/get-operation-progress.js.map +0 -1
  217. package/dist/tools/helpers/compact-output.d.ts.map +0 -1
  218. package/dist/tools/helpers/compact-output.js.map +0 -1
  219. package/dist/tools/helpers/feedback-analyzer.d.ts.map +0 -1
  220. package/dist/tools/helpers/feedback-analyzer.js.map +0 -1
  221. package/dist/tools/helpers/find-ts-config.d.ts.map +0 -1
  222. package/dist/tools/helpers/find-ts-config.js.map +0 -1
  223. package/dist/tools/helpers/platform-root-resolver.d.ts.map +0 -1
  224. package/dist/tools/helpers/platform-root-resolver.js.map +0 -1
  225. package/dist/tools/helpers/project-cache.d.ts.map +0 -1
  226. package/dist/tools/helpers/project-cache.js.map +0 -1
  227. package/dist/tools/helpers/rule-matcher.d.ts.map +0 -1
  228. package/dist/tools/helpers/rule-matcher.js.map +0 -1
  229. package/dist/tools/helpers/rule-runner.d.ts.map +0 -1
  230. package/dist/tools/helpers/rule-runner.js.map +0 -1
  231. package/dist/tools/helpers/scan-plan.d.ts.map +0 -1
  232. package/dist/tools/helpers/scan-plan.js.map +0 -1
  233. package/dist/tools/helpers/stack-frame-file-index.d.ts.map +0 -1
  234. package/dist/tools/helpers/stack-frame-file-index.js.map +0 -1
  235. package/dist/tools/helpers/suggestion-generator.d.ts.map +0 -1
  236. package/dist/tools/helpers/suggestion-generator.js.map +0 -1
  237. package/dist/tools/inspect-form-group.d.ts.map +0 -1
  238. package/dist/tools/inspect-form-group.js.map +0 -1
  239. package/dist/tools/inspect-i18n.d.ts.map +0 -1
  240. package/dist/tools/inspect-i18n.js.map +0 -1
  241. package/dist/tools/inspect-template.d.ts.map +0 -1
  242. package/dist/tools/inspect-template.js.map +0 -1
  243. package/dist/tools/learn-patterns.d.ts.map +0 -1
  244. package/dist/tools/learn-patterns.js.map +0 -1
  245. package/dist/tools/list-imports.d.ts.map +0 -1
  246. package/dist/tools/list-imports.js.map +0 -1
  247. package/dist/tools/orchestrate-migration.d.ts.map +0 -1
  248. package/dist/tools/orchestrate-migration.js.map +0 -1
  249. package/dist/tools/parse-stack-trace.d.ts.map +0 -1
  250. package/dist/tools/parse-stack-trace.js.map +0 -1
  251. package/dist/tools/plan-migration.d.ts.map +0 -1
  252. package/dist/tools/plan-migration.js.map +0 -1
  253. package/dist/tools/resolve-type.d.ts.map +0 -1
  254. package/dist/tools/resolve-type.js.map +0 -1
  255. package/dist/tools/review-feedback.d.ts.map +0 -1
  256. package/dist/tools/review-feedback.js.map +0 -1
  257. package/dist/tools/rollback-changes.d.ts.map +0 -1
  258. package/dist/tools/rollback-changes.js.map +0 -1
  259. package/dist/tools/run-angular-cli.d.ts.map +0 -1
  260. package/dist/tools/run-angular-cli.js.map +0 -1
  261. package/dist/tools/run-build.d.ts.map +0 -1
  262. package/dist/tools/run-build.js.map +0 -1
  263. package/dist/tools/run-schematic.d.ts.map +0 -1
  264. package/dist/tools/run-schematic.js.map +0 -1
  265. package/dist/tools/scan-all.d.ts.map +0 -1
  266. package/dist/tools/scan-all.js.map +0 -1
  267. package/dist/tools/scan-angular.d.ts.map +0 -1
  268. package/dist/tools/scan-angular.js.map +0 -1
  269. package/dist/tools/scan-architecture.d.ts.map +0 -1
  270. package/dist/tools/scan-architecture.js.map +0 -1
  271. package/dist/tools/scan-solid.d.ts.map +0 -1
  272. package/dist/tools/scan-solid.js.map +0 -1
  273. package/dist/tools/search-codebase.d.ts.map +0 -1
  274. package/dist/tools/search-codebase.js.map +0 -1
  275. package/dist/tools/server-status.d.ts.map +0 -1
  276. package/dist/tools/server-status.js.map +0 -1
  277. package/dist/tools/shared/scan-types.d.ts +0 -200
  278. package/dist/tools/shared/scan-types.d.ts.map +0 -1
  279. package/dist/tools/shared/scan-types.js +0 -7
  280. package/dist/tools/shared/scan-types.js.map +0 -1
  281. package/dist/tools/suggest-improvements.d.ts.map +0 -1
  282. package/dist/tools/suggest-improvements.js.map +0 -1
  283. package/dist/tools/trace-output-flow.d.ts.map +0 -1
  284. package/dist/tools/trace-output-flow.js.map +0 -1
  285. package/dist/tools/transform-code-batch.d.ts.map +0 -1
  286. package/dist/tools/transform-code-batch.js.map +0 -1
  287. package/dist/tools/transform-code.d.ts.map +0 -1
  288. package/dist/tools/transform-code.js.map +0 -1
  289. package/dist/tools/validate-before-transform.d.ts.map +0 -1
  290. package/dist/tools/validate-before-transform.js.map +0 -1
  291. package/dist/tools/validate-project-compatibility.d.ts.map +0 -1
  292. package/dist/tools/validate-project-compatibility.js.map +0 -1
  293. package/dist/tools/validate-transformation.d.ts.map +0 -1
  294. package/dist/tools/validate-transformation.js.map +0 -1
  295. package/dist/types.d.ts.map +0 -1
  296. package/dist/types.js.map +0 -1
  297. package/dist/utils/format-tool-response.d.ts.map +0 -1
  298. package/dist/utils/format-tool-response.js.map +0 -1
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @angular-modernizer/adapter-mcp - Cancellable file loading for scans
3
+ *
4
+ * Adding a file to a ts-morph project reads and parses it synchronously. A
5
+ * scan adds hundreds of files before its analysis loop starts, so without a
6
+ * yield per file a `notifications/cancelled` is read only after the whole
7
+ * batch is loaded (measured: answer 2.6 s after a cancel at 2 s, 375 files).
8
+ */
9
+ import type { Project, SourceFile } from 'ts-morph';
10
+ export interface LoadSourceFilesOptions {
11
+ /** Aborts the load between files (MCP `notifications/cancelled`). */
12
+ signal?: AbortSignal;
13
+ isCancelled?: () => boolean;
14
+ /** Use a file the project already has instead of adding it again. */
15
+ reuseExisting?: boolean;
16
+ /** Rethrow a file that cannot be added; default: warn and skip it. */
17
+ failOnError?: boolean;
18
+ }
19
+ export interface LoadedSourceFiles {
20
+ /** Files added (or reused), in the order of the input list. */
21
+ sourceFiles: SourceFile[];
22
+ /** `true` when the load stopped at a cancellation. */
23
+ cancelled: boolean;
24
+ }
25
+ /**
26
+ * Add `files` to `project` one by one. With a signal the event loop gets one
27
+ * turn per file and the signal is checked before each file.
28
+ */
29
+ export declare function loadSourceFiles(project: Project, files: readonly string[], options?: LoadSourceFilesOptions): Promise<LoadedSourceFiles>;
30
+ //# sourceMappingURL=load-source-files.d.ts.map
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @angular-modernizer/adapter-mcp - Cancellable file loading for scans
3
+ *
4
+ * Adding a file to a ts-morph project reads and parses it synchronously. A
5
+ * scan adds hundreds of files before its analysis loop starts, so without a
6
+ * yield per file a `notifications/cancelled` is read only after the whole
7
+ * batch is loaded (measured: answer 2.6 s after a cancel at 2 s, 375 files).
8
+ */
9
+ import { yieldIfCancellable } from './tool-context.js';
10
+ /**
11
+ * Add `files` to `project` one by one. With a signal the event loop gets one
12
+ * turn per file and the signal is checked before each file.
13
+ */
14
+ export async function loadSourceFiles(project, files, options = {}) {
15
+ const sourceFiles = [];
16
+ for (const filePath of files) {
17
+ await yieldIfCancellable(options.signal);
18
+ if (options.signal?.aborted === true || options.isCancelled?.() === true) {
19
+ return { sourceFiles, cancelled: true };
20
+ }
21
+ try {
22
+ const existing = options.reuseExisting === true ? project.getSourceFile(filePath) : undefined;
23
+ sourceFiles.push(existing ?? project.addSourceFileAtPath(filePath));
24
+ }
25
+ catch (error) {
26
+ if (options.failOnError === true) {
27
+ throw error;
28
+ }
29
+ console.warn(`Error loading ${filePath}:`, error);
30
+ }
31
+ }
32
+ return { sourceFiles, cancelled: false };
33
+ }
34
+ //# sourceMappingURL=load-source-files.js.map
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @angular-modernizer/adapter-mcp - Output contract helpers
3
+ *
4
+ * Pieces shared by the `outputSchema` of the tools on the structured output
5
+ * contract (`structuredContent` plus a `summary` string).
6
+ *
7
+ * @remarks
8
+ * Output schemas describe what a tool returns without closing objects
9
+ * (`additionalProperties` stays open), so a new field never turns a valid
10
+ * result into an output validation error. `required` lists only fields every
11
+ * variant of the result carries (`summaryOnly` drops the lists).
12
+ */
13
+ /** `warnings` entry of an output schema. */
14
+ export declare const WARNINGS_OUTPUT_SCHEMA: {
15
+ readonly warnings: {
16
+ readonly type: "array";
17
+ readonly items: {
18
+ readonly type: "string";
19
+ };
20
+ readonly description: "Conditions that can make the result incomplete, e.g. library imports that do not resolve because node_modules is missing.";
21
+ };
22
+ };
23
+ /**
24
+ * Adds `warnings` to a result and one `Warning:` line per entry to its
25
+ * summary; returns the result unchanged when there are none.
26
+ */
27
+ export declare function withWarnings<T extends {
28
+ summary: string;
29
+ }>(result: T, warnings: readonly string[]): T & {
30
+ warnings?: string[];
31
+ };
32
+ //# sourceMappingURL=output-contract.d.ts.map
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @angular-modernizer/adapter-mcp - Output contract helpers
3
+ *
4
+ * Pieces shared by the `outputSchema` of the tools on the structured output
5
+ * contract (`structuredContent` plus a `summary` string).
6
+ *
7
+ * @remarks
8
+ * Output schemas describe what a tool returns without closing objects
9
+ * (`additionalProperties` stays open), so a new field never turns a valid
10
+ * result into an output validation error. `required` lists only fields every
11
+ * variant of the result carries (`summaryOnly` drops the lists).
12
+ */
13
+ /** `warnings` entry of an output schema. */
14
+ export const WARNINGS_OUTPUT_SCHEMA = {
15
+ warnings: {
16
+ type: 'array',
17
+ items: { type: 'string' },
18
+ description: 'Conditions that can make the result incomplete, e.g. library imports that do not resolve because node_modules is missing.',
19
+ },
20
+ };
21
+ /**
22
+ * Adds `warnings` to a result and one `Warning:` line per entry to its
23
+ * summary; returns the result unchanged when there are none.
24
+ */
25
+ export function withWarnings(result, warnings) {
26
+ if (warnings.length === 0) {
27
+ return result;
28
+ }
29
+ const lines = warnings.map((w) => `Warning: ${w}`).join('\n');
30
+ return { ...result, summary: `${result.summary}\n${lines}`, warnings: [...warnings] };
31
+ }
32
+ //# sourceMappingURL=output-contract.js.map
@@ -1,33 +1,63 @@
1
1
  /**
2
- * @angular-modernizer/adapter-mcp - Platform Root Resolver
2
+ * @angular-modernizer/adapter-mcp - Feedback storage roots
3
3
  *
4
- * Utility for intelligently resolving the platform root directory.
5
- * Searches upward for monorepo root (package.json with workspaces).
4
+ * Feedback always lives in `<projectRoot>/.claude-feedback`. A second,
5
+ * platform-wide store exists only when `ANGULAR_MODERNIZER_PLATFORM_ROOT` is
6
+ * set. The server never derives a platform root from its own install path:
7
+ * installed from npm that path is the user's workspace root or a
8
+ * `node_modules` / npx cache directory.
6
9
  */
10
+ import type { StorageLocation } from '@angular-modernizer/core';
11
+ /** Environment variable that enables the platform feedback store. */
12
+ export declare const PLATFORM_ROOT_ENV = "ANGULAR_MODERNIZER_PLATFORM_ROOT";
13
+ /** Roots the feedback tools read from or write to. */
14
+ export interface FeedbackRoots {
15
+ projectRoot: string;
16
+ /** Set only when {@link PLATFORM_ROOT_ENV} is set. */
17
+ platformRoot?: string;
18
+ /** Locations actually used: never `platform` without a platform root. */
19
+ locations: ('project' | 'platform')[];
20
+ }
7
21
  /**
8
- * Resolve platform root directory by searching upward for package.json with workspaces
9
- * Falls back to environment variable or calculated path
10
- *
11
- * @param currentDir - Starting directory for upward search (typically __dirname)
12
- * @param fallbackPath - Fallback relative path if monorepo root not found (e.g., '../../../..')
13
- * @returns Absolute path to platform root directory
14
- *
15
- * @remarks
16
- * - First checks ANGULAR_MODERNIZER_PLATFORM_ROOT environment variable
17
- * - Then searches upward from currentDir for package.json with workspaces field
18
- * - Falls back to calculated path relative to currentDir if not found
19
- * - Stops searching at filesystem root to prevent infinite loops
20
- *
21
- * @example
22
- * ```typescript
23
- * import { fileURLToPath } from 'node:url';
24
- * import * as path from 'node:path';
22
+ * The platform root from {@link PLATFORM_ROOT_ENV}, or `undefined`.
23
+ */
24
+ export declare function configuredPlatformRoot(): string | undefined;
25
+ /**
26
+ * Resolve the locations for a requested storage strategy.
25
27
  *
26
- * const __filename = fileURLToPath(import.meta.url);
27
- * const __dirname = path.dirname(__filename);
28
+ * - `project`: the project only
29
+ * - `both`: the project, plus the platform root when it is configured
30
+ * - `platform`: the platform root; without one this is an error
28
31
  *
29
- * const platformRoot = resolvePlatformRoot(__dirname, '../../../..');
30
- * ```
32
+ * @throws {Error} for `platform` without {@link PLATFORM_ROOT_ENV}
33
+ */
34
+ export declare function resolveFeedbackRoots(projectRoot: string, requested: StorageLocation): FeedbackRoots;
35
+ /**
36
+ * The `StorageLocation` for core `FeedbackStorage` / `FeedbackCollector`
37
+ * matching the resolved locations.
38
+ */
39
+ export declare function effectiveStorageLocation(roots: FeedbackRoots): StorageLocation;
40
+ /**
41
+ * Absolute root directory of a location.
42
+ */
43
+ export declare function locationRoot(roots: FeedbackRoots, location: 'project' | 'platform'): string;
44
+ /**
45
+ * The platform root to hand to core `FeedbackStorage` (which needs a string):
46
+ * the project root when no platform store is configured, never read then
47
+ * because the effective location is `project`.
48
+ */
49
+ export declare function storagePlatformRoot(roots: FeedbackRoots): string;
50
+ /**
51
+ * Config for core `FeedbackStorage` for the resolved roots.
52
+ */
53
+ export declare function feedbackStorageConfig(roots: FeedbackRoots): {
54
+ projectRoot: string;
55
+ platformRoot: string;
56
+ storageLocation: StorageLocation;
57
+ };
58
+ /**
59
+ * The session directories of the used locations (`sourcesRead` of the
60
+ * reading tools).
31
61
  */
32
- export declare function resolvePlatformRoot(currentDir: string, fallbackPath: string): string;
62
+ export declare function feedbackSessionDirs(roots: FeedbackRoots): string[];
33
63
  //# sourceMappingURL=platform-root-resolver.d.ts.map
@@ -1,60 +1,87 @@
1
1
  /**
2
- * @angular-modernizer/adapter-mcp - Platform Root Resolver
2
+ * @angular-modernizer/adapter-mcp - Feedback storage roots
3
3
  *
4
- * Utility for intelligently resolving the platform root directory.
5
- * Searches upward for monorepo root (package.json with workspaces).
4
+ * Feedback always lives in `<projectRoot>/.claude-feedback`. A second,
5
+ * platform-wide store exists only when `ANGULAR_MODERNIZER_PLATFORM_ROOT` is
6
+ * set. The server never derives a platform root from its own install path:
7
+ * installed from npm that path is the user's workspace root or a
8
+ * `node_modules` / npx cache directory.
6
9
  */
7
10
  import * as path from 'node:path';
8
- import { readFileSync } from 'node:fs';
11
+ /** Environment variable that enables the platform feedback store. */
12
+ export const PLATFORM_ROOT_ENV = 'ANGULAR_MODERNIZER_PLATFORM_ROOT';
9
13
  /**
10
- * Resolve platform root directory by searching upward for package.json with workspaces
11
- * Falls back to environment variable or calculated path
12
- *
13
- * @param currentDir - Starting directory for upward search (typically __dirname)
14
- * @param fallbackPath - Fallback relative path if monorepo root not found (e.g., '../../../..')
15
- * @returns Absolute path to platform root directory
16
- *
17
- * @remarks
18
- * - First checks ANGULAR_MODERNIZER_PLATFORM_ROOT environment variable
19
- * - Then searches upward from currentDir for package.json with workspaces field
20
- * - Falls back to calculated path relative to currentDir if not found
21
- * - Stops searching at filesystem root to prevent infinite loops
22
- *
23
- * @example
24
- * ```typescript
25
- * import { fileURLToPath } from 'node:url';
26
- * import * as path from 'node:path';
14
+ * The platform root from {@link PLATFORM_ROOT_ENV}, or `undefined`.
15
+ */
16
+ export function configuredPlatformRoot() {
17
+ const value = process.env[PLATFORM_ROOT_ENV]?.trim();
18
+ return value === undefined || value === '' ? undefined : value;
19
+ }
20
+ /**
21
+ * Resolve the locations for a requested storage strategy.
27
22
  *
28
- * const __filename = fileURLToPath(import.meta.url);
29
- * const __dirname = path.dirname(__filename);
23
+ * - `project`: the project only
24
+ * - `both`: the project, plus the platform root when it is configured
25
+ * - `platform`: the platform root; without one this is an error
30
26
  *
31
- * const platformRoot = resolvePlatformRoot(__dirname, '../../../..');
32
- * ```
27
+ * @throws {Error} for `platform` without {@link PLATFORM_ROOT_ENV}
33
28
  */
34
- export function resolvePlatformRoot(currentDir, fallbackPath) {
35
- // Allow override via environment variable
36
- if (process.env['ANGULAR_MODERNIZER_PLATFORM_ROOT']) {
37
- return process.env['ANGULAR_MODERNIZER_PLATFORM_ROOT'];
38
- }
39
- // Search upward from current directory for monorepo root (package.json with workspaces)
40
- let searchDir = currentDir;
41
- const root = path.parse(searchDir).root;
42
- while (searchDir !== root) {
43
- try {
44
- const packageJsonPath = path.join(searchDir, 'package.json');
45
- const packageJsonContent = readFileSync(packageJsonPath, 'utf-8');
46
- const packageJson = JSON.parse(packageJsonContent);
47
- // Check if this is the monorepo root (has workspaces)
48
- if (packageJson.workspaces) {
49
- return searchDir;
50
- }
51
- }
52
- catch {
53
- // package.json not found or invalid, continue searching
29
+ export function resolveFeedbackRoots(projectRoot, requested) {
30
+ const platformRoot = configuredPlatformRoot();
31
+ if (platformRoot === undefined) {
32
+ if (requested === 'platform') {
33
+ throw new Error(`Feedback location 'platform' needs ${PLATFORM_ROOT_ENV}; without it feedback is stored in <projectRoot>/.claude-feedback ('project' or 'both').`);
54
34
  }
55
- searchDir = path.dirname(searchDir);
35
+ return { projectRoot, locations: ['project'] };
36
+ }
37
+ return { projectRoot, platformRoot, locations: LOCATIONS[requested] };
38
+ }
39
+ const LOCATIONS = {
40
+ project: ['project'],
41
+ platform: ['platform'],
42
+ both: ['project', 'platform'],
43
+ };
44
+ /**
45
+ * The `StorageLocation` for core `FeedbackStorage` / `FeedbackCollector`
46
+ * matching the resolved locations.
47
+ */
48
+ export function effectiveStorageLocation(roots) {
49
+ if (roots.locations.length === 2) {
50
+ return 'both';
56
51
  }
57
- // Fallback to calculated path relative to currentDir
58
- return path.join(currentDir, fallbackPath);
52
+ return roots.locations[0] ?? 'project';
53
+ }
54
+ /**
55
+ * Absolute root directory of a location.
56
+ */
57
+ export function locationRoot(roots, location) {
58
+ return location === 'platform' && roots.platformRoot !== undefined
59
+ ? roots.platformRoot
60
+ : roots.projectRoot;
61
+ }
62
+ /**
63
+ * The platform root to hand to core `FeedbackStorage` (which needs a string):
64
+ * the project root when no platform store is configured, never read then
65
+ * because the effective location is `project`.
66
+ */
67
+ export function storagePlatformRoot(roots) {
68
+ return roots.platformRoot ?? roots.projectRoot;
69
+ }
70
+ /**
71
+ * Config for core `FeedbackStorage` for the resolved roots.
72
+ */
73
+ export function feedbackStorageConfig(roots) {
74
+ return {
75
+ projectRoot: roots.projectRoot,
76
+ platformRoot: storagePlatformRoot(roots),
77
+ storageLocation: effectiveStorageLocation(roots),
78
+ };
79
+ }
80
+ /**
81
+ * The session directories of the used locations (`sourcesRead` of the
82
+ * reading tools).
83
+ */
84
+ export function feedbackSessionDirs(roots) {
85
+ return roots.locations.map((location) => path.join(locationRoot(roots, location), '.claude-feedback/sessions'));
59
86
  }
60
87
  //# sourceMappingURL=platform-root-resolver.js.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @angular-modernizer/adapter-mcp - Child process output in summaries
3
+ *
4
+ * Tools that run a child process (Angular CLI, build, schematic) keep the
5
+ * full stdout and stderr in their result; the text summary carries only the
6
+ * last lines, which is where a failing CLI prints its error.
7
+ */
8
+ /** Lines of a process output repeated in a summary. */
9
+ export declare const SUMMARY_OUTPUT_LINES = 15;
10
+ /** Characters of a process output repeated in a summary. */
11
+ export declare const SUMMARY_OUTPUT_CHARS = 2000;
12
+ /**
13
+ * The last non-empty lines of a process output, at most `maxLines` lines and
14
+ * `maxChars` characters; `undefined` when the output is blank.
15
+ */
16
+ export declare function outputTail(text: string, maxLines?: number, maxChars?: number): string | undefined;
17
+ /** Milliseconds as seconds with one decimal, e.g. `12.3 s`. */
18
+ export declare function seconds(ms: number): string;
19
+ //# sourceMappingURL=process-output.d.ts.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @angular-modernizer/adapter-mcp - Child process output in summaries
3
+ *
4
+ * Tools that run a child process (Angular CLI, build, schematic) keep the
5
+ * full stdout and stderr in their result; the text summary carries only the
6
+ * last lines, which is where a failing CLI prints its error.
7
+ */
8
+ /** Lines of a process output repeated in a summary. */
9
+ export const SUMMARY_OUTPUT_LINES = 15;
10
+ /** Characters of a process output repeated in a summary. */
11
+ export const SUMMARY_OUTPUT_CHARS = 2000;
12
+ /**
13
+ * The last non-empty lines of a process output, at most `maxLines` lines and
14
+ * `maxChars` characters; `undefined` when the output is blank.
15
+ */
16
+ export function outputTail(text, maxLines = SUMMARY_OUTPUT_LINES, maxChars = SUMMARY_OUTPUT_CHARS) {
17
+ const lines = text
18
+ .split(/\r?\n/)
19
+ .map((line) => line.trimEnd())
20
+ .filter((line) => line !== '');
21
+ if (lines.length === 0) {
22
+ return undefined;
23
+ }
24
+ const tail = lines.slice(-maxLines).join('\n');
25
+ return tail.length > maxChars ? tail.slice(tail.length - maxChars) : tail;
26
+ }
27
+ /** Milliseconds as seconds with one decimal, e.g. `12.3 s`. */
28
+ export function seconds(ms) {
29
+ return `${(ms / 1000).toFixed(1)} s`;
30
+ }
31
+ //# sourceMappingURL=process-output.js.map
@@ -1,69 +1,53 @@
1
- /**
2
- * @angular-modernizer/adapter-mcp - Project Cache
3
- *
4
- * Keeps ts-morph `Project` instances alive across tool calls, keyed by the
5
- * tsconfig path, so repeated investigation calls on the same workspace do not
6
- * re-parse the whole program each time (seconds on a large Angular app).
7
- *
8
- * @remarks
9
- * Same idea as `SharedProjectManager` in core (one long-lived Project instead
10
- * of one per call), but keyed per tsconfig because the MCP server can serve
11
- * several workspaces in one session. An entry is rebuilt when the tsconfig
12
- * mtime changes. Source files are kept current file by file: the mtime of
13
- * every program file is recorded at load and compared on each `get()` (about
14
- * 6 ms for ngUWI's 3939 files); changed files are re-read, deleted ones
15
- * removed. The type checker then rebuilds lazily on the next query. Files
16
- * that were not in the program at load (new files) need a tsconfig touch or a
17
- * server restart.
18
- *
19
- * Two limits bound the cache: `maxEntries` projects, and `maxHeapMb` of V8
20
- * heap, checked on every `get()` because a project keeps growing after the
21
- * load as the type checker resolves more of it, and on a miss also before
22
- * the load. Over either limit the least recently used project is evicted;
23
- * the project being requested never is.
24
- * The heap is the signal, not the RSS: dropping a Project frees its heap
25
- * (the TypeScript program, checker and ts-morph wrappers hang off it and
26
- * nothing else keeps them), but V8 does not reliably unmap the pages, so the
27
- * RSS can stay at its peak after an eviction and an RSS limit would then
28
- * evict everything on every call. Freed pages are reused by the next load.
29
- * When node runs with `--expose-gc` the cache collects once the raw heap
30
- * reading passes the limit and after each eviction, so garbage does not count
31
- * against the cache; otherwise it subtracts the heap growth recorded when the
32
- * evicted project was loaded, and garbage makes it evict earlier.
33
- */
34
1
  import { Project } from 'ts-morph';
35
2
  /** A cached project as reported by `server-status`. */
36
3
  export interface CachedProjectInfo {
4
+ /** tsconfig the project was loaded from. */
37
5
  tsConfigPath: string;
6
+ /** Number of source files in the project. */
38
7
  sourceFiles: number;
8
+ /** Load time (ISO 8601). */
39
9
  loadedAt: string;
10
+ /** Time of the last `get()` (ISO 8601). */
40
11
  lastUsedAt: string;
41
12
  /** Heap growth while the project was loaded, an estimate of its size. */
42
13
  loadHeapMB: number;
43
14
  /** Source files re-read or removed because they changed on disk. */
44
15
  refreshedFiles: number;
16
+ /** Time of the last refresh of changed files (ISO 8601). */
45
17
  lastRefreshAt?: string;
46
18
  }
47
19
  /** Why a project left the cache. */
48
20
  export type EvictionReason = 'max-entries' | 'max-heap';
49
21
  /** One eviction with the memory around it. */
50
22
  export interface ProjectEviction {
23
+ /** tsconfig of the evicted project. */
51
24
  tsConfigPath: string;
25
+ /** Limit that caused the eviction. */
52
26
  reason: EvictionReason;
27
+ /** Time of the eviction (ISO 8601). */
53
28
  at: string;
29
+ /** Number of source files of the evicted project. */
54
30
  sourceFiles: number;
31
+ /** V8 heap in use, MB. */
55
32
  heapMB: {
33
+ /** Before the eviction. */
56
34
  before: number;
35
+ /** After the eviction. */
57
36
  after: number;
58
37
  };
38
+ /** Resident set size, MB. */
59
39
  rssMB: {
40
+ /** Before the eviction. */
60
41
  before: number;
42
+ /** After the eviction. */
61
43
  after: number;
62
44
  };
63
45
  }
64
46
  /** Evictions since the server started. */
65
47
  export interface EvictionStats {
48
+ /** Number of evictions. */
66
49
  count: number;
50
+ /** The most recent eviction. */
67
51
  last?: ProjectEviction;
68
52
  }
69
53
  /** Heap and RSS reader, plus a full collection when node exposes one. */
@@ -90,15 +74,47 @@ export interface ProjectCacheOptions extends Partial<ProjectCacheLimits> {
90
74
  /** Default number of workspaces kept in memory at once. */
91
75
  export declare const DEFAULT_MAX_ENTRIES = 3;
92
76
  /**
93
- * Default heap limit. ngUWI (3939 files) takes 1.0 to 1.3 GB of heap once
94
- * loaded and queried; V8's heap limit on the dev machines is about 4.1 GB.
95
- * 2048 MB keeps ngUWI together with small workspaces, and evicts it before a
77
+ * Default heap limit. A workspace of 3939 files takes 1.0 to 1.3 GB of heap
78
+ * once loaded and queried; V8's heap limit on the dev machines is about 4.1 GB.
79
+ * 2048 MB keeps such a workspace together with small ones, and evicts it before a
96
80
  * second workspace of its size drives the process towards the V8 limit.
97
81
  */
98
82
  export declare const DEFAULT_MAX_HEAP_MB = 2048;
99
83
  /** Bytes to MB, one decimal. */
100
84
  export declare function toMB(bytes: number): number;
101
- /** LRU cache of ts-morph Projects keyed by tsconfig path. */
85
+ /**
86
+ * LRU cache of ts-morph Projects keyed by tsconfig path. Keeps `Project`
87
+ * instances alive across tool calls, so repeated investigation calls on the
88
+ * same workspace do not re-parse the whole program each time (seconds on a
89
+ * large Angular app).
90
+ *
91
+ * @remarks
92
+ * Same idea as `SharedProjectManager` in core (one long-lived Project instead
93
+ * of one per call), but keyed per tsconfig because the MCP server can serve
94
+ * several workspaces in one session. An entry is rebuilt when the tsconfig
95
+ * mtime changes. Source files are kept current file by file: the mtime of
96
+ * every program file is recorded at load and compared on each `get()` (about
97
+ * 6 ms for 3939 files); changed files are re-read, deleted ones
98
+ * removed. The type checker then rebuilds lazily on the next query. Files
99
+ * that were not in the program at load (new files) need a tsconfig touch or a
100
+ * server restart.
101
+ *
102
+ * Two limits bound the cache: `maxEntries` projects, and `maxHeapMb` of V8
103
+ * heap, checked on every `get()` because a project keeps growing after the
104
+ * load as the type checker resolves more of it, and on a miss also before
105
+ * the load. Over either limit the least recently used project is evicted;
106
+ * the project being requested never is.
107
+ *
108
+ * The heap is the signal, not the RSS: dropping a Project frees its heap
109
+ * (the TypeScript program, checker and ts-morph wrappers hang off it and
110
+ * nothing else keeps them), but V8 does not reliably unmap the pages, so the
111
+ * RSS can stay at its peak after an eviction and an RSS limit would then
112
+ * evict everything on every call. Freed pages are reused by the next load.
113
+ * When node runs with `--expose-gc` the cache collects once the raw heap
114
+ * reading passes the limit and after each eviction, so garbage does not count
115
+ * against the cache; otherwise it subtracts the heap growth recorded when the
116
+ * evicted project was loaded, and garbage makes it evict earlier.
117
+ */
102
118
  export declare class ProjectCache {
103
119
  private readonly entries;
104
120
  private readonly maxEntries;
@@ -123,6 +139,13 @@ export declare class ProjectCache {
123
139
  get limits(): ProjectCacheLimits;
124
140
  /** Eviction count and the most recent eviction. */
125
141
  get evictions(): EvictionStats;
142
+ /**
143
+ * Warnings about the loaded project for `tsConfigPath`: today the library
144
+ * imports that do not resolve (missing or incomplete node_modules). Checked
145
+ * once per load, on the first call, and kept until the project is reloaded;
146
+ * empty when the project is not cached.
147
+ */
148
+ warnings(tsConfigPath: string): string[];
126
149
  /** Cached projects, least recently used first. */
127
150
  describe(): CachedProjectInfo[];
128
151
  /**