@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.
- package/README.md +181 -282
- package/dist/cli.js +21 -13
- package/dist/core/project-analyzer.d.ts +3 -12
- package/dist/core/project-analyzer.js +3 -12
- package/dist/index.d.ts +122 -6
- package/dist/index.js +49 -5
- package/dist/mcp-watcher.d.ts +32 -7
- package/dist/mcp-watcher.js +16 -15
- package/dist/scan-host/scan-host.d.ts +119 -0
- package/dist/scan-host/scan-host.js +376 -0
- package/dist/scan-host/scan-protocol.d.ts +35 -0
- package/dist/scan-host/scan-protocol.js +6 -0
- package/dist/scan-host/scan-worker.d.ts +14 -0
- package/dist/scan-host/scan-worker.js +48 -0
- package/dist/server/limited-stdio-transport.d.ts +75 -0
- package/dist/server/limited-stdio-transport.js +115 -0
- package/dist/server/mcp-server.d.ts +20 -18
- package/dist/server/mcp-server.js +42 -79
- package/dist/server/package-version.d.ts +16 -0
- package/dist/server/package-version.js +37 -0
- package/dist/server/sdk-server.d.ts +71 -0
- package/dist/server/sdk-server.js +113 -0
- package/dist/server/tool-registry.d.ts +6 -9
- package/dist/server/tool-registry.js +6 -12
- package/dist/streaming/progress-store.d.ts +22 -5
- package/dist/streaming/progress-store.js +9 -5
- package/dist/tools/analyze-build-impact.d.ts +276 -35
- package/dist/tools/analyze-build-impact.js +175 -28
- package/dist/tools/analyze-core-to-shared.d.ts +176 -16
- package/dist/tools/analyze-core-to-shared.js +124 -19
- package/dist/tools/analyze-parser-performance.d.ts +209 -15
- package/dist/tools/analyze-parser-performance.js +119 -56
- package/dist/tools/analyze-project.d.ts +349 -17
- package/dist/tools/analyze-project.js +282 -97
- package/dist/tools/check-incremental-compatibility.d.ts +74 -12
- package/dist/tools/check-incremental-compatibility.js +69 -10
- package/dist/tools/collect-feedback.d.ts +225 -21
- package/dist/tools/collect-feedback.js +199 -118
- package/dist/tools/compare-health.d.ts +413 -0
- package/dist/tools/compare-health.js +479 -0
- package/dist/tools/extract-libraries.d.ts +200 -24
- package/dist/tools/extract-libraries.js +131 -27
- package/dist/tools/find-angular-symbol.d.ts +92 -24
- package/dist/tools/find-angular-symbol.js +70 -20
- package/dist/tools/find-component-hosts.d.ts +603 -27
- package/dist/tools/find-component-hosts.js +223 -19
- package/dist/tools/find-usages.d.ts +102 -22
- package/dist/tools/find-usages.js +81 -21
- package/dist/tools/get-bootstrap-execution.d.ts +183 -25
- package/dist/tools/get-bootstrap-execution.js +109 -25
- package/dist/tools/get-call-graph.d.ts +127 -12
- package/dist/tools/get-call-graph.js +84 -19
- package/dist/tools/get-operation-progress-tool.d.ts +126 -8
- package/dist/tools/get-operation-progress-tool.js +124 -12
- package/dist/tools/get-operation-progress.d.ts +27 -1
- package/dist/tools/get-operation-progress.js +5 -5
- package/dist/tools/helpers/analysis-output.d.ts +182 -0
- package/dist/tools/helpers/analysis-output.js +165 -0
- package/dist/tools/helpers/batch-kernel.d.ts +14 -0
- package/dist/tools/helpers/batch-kernel.js +12 -0
- package/dist/tools/helpers/build-schemas.d.ts +36 -0
- package/dist/tools/helpers/build-schemas.js +23 -0
- package/dist/tools/helpers/citation-file-source.d.ts +10 -0
- package/dist/tools/helpers/citation-file-source.js +82 -0
- package/dist/tools/helpers/compact-output.d.ts +2 -1
- package/dist/tools/helpers/compact-output.js +2 -1
- package/dist/tools/helpers/finding-window.d.ts +43 -0
- package/dist/tools/helpers/finding-window.js +64 -0
- package/dist/tools/helpers/health-delta.d.ts +99 -0
- package/dist/tools/helpers/health-delta.js +236 -0
- package/dist/tools/helpers/investigation-schemas.d.ts +93 -0
- package/dist/tools/helpers/investigation-schemas.js +48 -0
- package/dist/tools/helpers/library-imports.d.ts +57 -0
- package/dist/tools/helpers/library-imports.js +151 -0
- package/dist/tools/helpers/load-source-files.d.ts +30 -0
- package/dist/tools/helpers/load-source-files.js +34 -0
- package/dist/tools/helpers/output-contract.d.ts +32 -0
- package/dist/tools/helpers/output-contract.js +32 -0
- package/dist/tools/helpers/platform-root-resolver.d.ts +55 -25
- package/dist/tools/helpers/platform-root-resolver.js +75 -48
- package/dist/tools/helpers/process-output.d.ts +19 -0
- package/dist/tools/helpers/process-output.js +31 -0
- package/dist/tools/helpers/project-cache.d.ts +60 -37
- package/dist/tools/helpers/project-cache.js +54 -37
- package/dist/tools/helpers/project-decorators.d.ts +14 -0
- package/dist/tools/helpers/project-decorators.js +22 -0
- package/dist/tools/helpers/rule-matcher.js +5 -0
- package/dist/tools/helpers/rule-runner.d.ts +25 -13
- package/dist/tools/helpers/rule-runner.js +45 -24
- package/dist/tools/helpers/scan-cache.d.ts +22 -0
- package/dist/tools/helpers/scan-cache.js +34 -0
- package/dist/tools/helpers/scan-engine.d.ts +107 -0
- package/dist/tools/helpers/scan-engine.js +197 -0
- package/dist/tools/helpers/scan-plan.d.ts +5 -2
- package/dist/tools/helpers/scan-plan.js +18 -3
- package/dist/tools/helpers/scope-paths.d.ts +17 -0
- package/dist/tools/helpers/scope-paths.js +32 -0
- package/dist/tools/helpers/suggestion-generator.d.ts +9 -13
- package/dist/tools/helpers/suggestion-generator.js +0 -12
- package/dist/tools/helpers/tool-cache.d.ts +11 -0
- package/dist/tools/helpers/tool-cache.js +15 -0
- package/dist/tools/helpers/tool-context.d.ts +63 -0
- package/dist/tools/helpers/tool-context.js +79 -0
- package/dist/tools/helpers/transform-safety.d.ts +40 -0
- package/dist/tools/helpers/transform-safety.js +87 -0
- package/dist/tools/helpers/validation-output.d.ts +53 -0
- package/dist/tools/helpers/validation-output.js +48 -0
- package/dist/tools/inspect-form-group.d.ts +262 -24
- package/dist/tools/inspect-form-group.js +134 -13
- package/dist/tools/inspect-i18n.d.ts +410 -23
- package/dist/tools/inspect-i18n.js +213 -13
- package/dist/tools/inspect-template.d.ts +260 -22
- package/dist/tools/inspect-template.js +174 -13
- package/dist/tools/learn-patterns.d.ts +210 -13
- package/dist/tools/learn-patterns.js +113 -12
- package/dist/tools/list-imports.d.ts +152 -34
- package/dist/tools/list-imports.js +124 -18
- package/dist/tools/orchestrate-migration.d.ts +159 -14
- package/dist/tools/orchestrate-migration.js +147 -20
- package/dist/tools/parse-stack-trace.d.ts +78 -21
- package/dist/tools/parse-stack-trace.js +44 -7
- package/dist/tools/plan-migration.d.ts +395 -26
- package/dist/tools/plan-migration.js +173 -22
- package/dist/tools/resolve-type.d.ts +57 -9
- package/dist/tools/resolve-type.js +49 -12
- package/dist/tools/review-feedback.d.ts +214 -16
- package/dist/tools/review-feedback.js +142 -57
- package/dist/tools/rollback-changes.d.ts +88 -7
- package/dist/tools/rollback-changes.js +74 -19
- package/dist/tools/run-angular-cli.d.ts +57 -12
- package/dist/tools/run-angular-cli.js +76 -13
- package/dist/tools/run-build.d.ts +127 -13
- package/dist/tools/run-build.js +128 -16
- package/dist/tools/run-schematic.d.ts +82 -12
- package/dist/tools/run-schematic.js +115 -18
- package/dist/tools/scan-all.d.ts +88 -23
- package/dist/tools/scan-all.js +161 -220
- package/dist/tools/scan-angular.d.ts +60 -19
- package/dist/tools/scan-angular.js +100 -141
- package/dist/tools/scan-architecture.d.ts +92 -24
- package/dist/tools/scan-architecture.js +268 -211
- package/dist/tools/scan-solid.d.ts +59 -19
- package/dist/tools/scan-solid.js +98 -139
- package/dist/tools/search-codebase.d.ts +110 -23
- package/dist/tools/search-codebase.js +67 -11
- package/dist/tools/server-status.d.ts +392 -26
- package/dist/tools/server-status.js +260 -27
- package/dist/tools/suggest-improvements.d.ts +105 -10
- package/dist/tools/suggest-improvements.js +91 -51
- package/dist/tools/trace-output-flow.d.ts +713 -26
- package/dist/tools/trace-output-flow.js +396 -33
- package/dist/tools/transform-code-batch.d.ts +3 -0
- package/dist/tools/transform-code-batch.js +10 -5
- package/dist/tools/transform-code.d.ts +402 -18
- package/dist/tools/transform-code.js +708 -649
- package/dist/tools/validate-before-transform.d.ts +136 -7
- package/dist/tools/validate-before-transform.js +65 -9
- package/dist/tools/validate-project-compatibility.d.ts +82 -15
- package/dist/tools/validate-project-compatibility.js +84 -15
- package/dist/tools/validate-transformation.d.ts +243 -8
- package/dist/tools/validate-transformation.js +127 -23
- package/dist/tools/verify-citations.d.ts +202 -0
- package/dist/tools/verify-citations.js +221 -0
- package/dist/types.d.ts +78 -11
- package/dist/types.js +0 -5
- package/dist/utils/format-tool-response.d.ts +22 -59
- package/dist/utils/format-tool-response.js +25 -134
- package/package.json +31 -20
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/core/project-analyzer.d.ts.map +0 -1
- package/dist/core/project-analyzer.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/mcp-watcher.d.ts.map +0 -1
- package/dist/mcp-watcher.js.map +0 -1
- package/dist/server/json-rpc-handler.d.ts +0 -98
- package/dist/server/json-rpc-handler.d.ts.map +0 -1
- package/dist/server/json-rpc-handler.js +0 -301
- package/dist/server/json-rpc-handler.js.map +0 -1
- package/dist/server/mcp-server.d.ts.map +0 -1
- package/dist/server/mcp-server.js.map +0 -1
- package/dist/server/stdio-guard.d.ts.map +0 -1
- package/dist/server/stdio-guard.js.map +0 -1
- package/dist/server/tool-registry.d.ts.map +0 -1
- package/dist/server/tool-registry.js.map +0 -1
- package/dist/streaming/progress-store.d.ts.map +0 -1
- package/dist/streaming/progress-store.js.map +0 -1
- package/dist/tools/analyze-build-impact.d.ts.map +0 -1
- package/dist/tools/analyze-build-impact.js.map +0 -1
- package/dist/tools/analyze-core-to-shared.d.ts.map +0 -1
- package/dist/tools/analyze-core-to-shared.js.map +0 -1
- package/dist/tools/analyze-parser-performance.d.ts.map +0 -1
- package/dist/tools/analyze-parser-performance.js.map +0 -1
- package/dist/tools/analyze-project.d.ts.map +0 -1
- package/dist/tools/analyze-project.js.map +0 -1
- package/dist/tools/check-incremental-compatibility.d.ts.map +0 -1
- package/dist/tools/check-incremental-compatibility.js.map +0 -1
- package/dist/tools/collect-feedback.d.ts.map +0 -1
- package/dist/tools/collect-feedback.js.map +0 -1
- package/dist/tools/extract-libraries.d.ts.map +0 -1
- package/dist/tools/extract-libraries.js.map +0 -1
- package/dist/tools/find-angular-symbol.d.ts.map +0 -1
- package/dist/tools/find-angular-symbol.js.map +0 -1
- package/dist/tools/find-component-hosts.d.ts.map +0 -1
- package/dist/tools/find-component-hosts.js.map +0 -1
- package/dist/tools/find-usages.d.ts.map +0 -1
- package/dist/tools/find-usages.js.map +0 -1
- package/dist/tools/get-bootstrap-execution.d.ts.map +0 -1
- package/dist/tools/get-bootstrap-execution.js.map +0 -1
- package/dist/tools/get-call-graph.d.ts.map +0 -1
- package/dist/tools/get-call-graph.js.map +0 -1
- package/dist/tools/get-operation-progress-tool.d.ts.map +0 -1
- package/dist/tools/get-operation-progress-tool.js.map +0 -1
- package/dist/tools/get-operation-progress.d.ts.map +0 -1
- package/dist/tools/get-operation-progress.js.map +0 -1
- package/dist/tools/helpers/compact-output.d.ts.map +0 -1
- package/dist/tools/helpers/compact-output.js.map +0 -1
- package/dist/tools/helpers/feedback-analyzer.d.ts.map +0 -1
- package/dist/tools/helpers/feedback-analyzer.js.map +0 -1
- package/dist/tools/helpers/find-ts-config.d.ts.map +0 -1
- package/dist/tools/helpers/find-ts-config.js.map +0 -1
- package/dist/tools/helpers/platform-root-resolver.d.ts.map +0 -1
- package/dist/tools/helpers/platform-root-resolver.js.map +0 -1
- package/dist/tools/helpers/project-cache.d.ts.map +0 -1
- package/dist/tools/helpers/project-cache.js.map +0 -1
- package/dist/tools/helpers/rule-matcher.d.ts.map +0 -1
- package/dist/tools/helpers/rule-matcher.js.map +0 -1
- package/dist/tools/helpers/rule-runner.d.ts.map +0 -1
- package/dist/tools/helpers/rule-runner.js.map +0 -1
- package/dist/tools/helpers/scan-plan.d.ts.map +0 -1
- package/dist/tools/helpers/scan-plan.js.map +0 -1
- package/dist/tools/helpers/stack-frame-file-index.d.ts.map +0 -1
- package/dist/tools/helpers/stack-frame-file-index.js.map +0 -1
- package/dist/tools/helpers/suggestion-generator.d.ts.map +0 -1
- package/dist/tools/helpers/suggestion-generator.js.map +0 -1
- package/dist/tools/inspect-form-group.d.ts.map +0 -1
- package/dist/tools/inspect-form-group.js.map +0 -1
- package/dist/tools/inspect-i18n.d.ts.map +0 -1
- package/dist/tools/inspect-i18n.js.map +0 -1
- package/dist/tools/inspect-template.d.ts.map +0 -1
- package/dist/tools/inspect-template.js.map +0 -1
- package/dist/tools/learn-patterns.d.ts.map +0 -1
- package/dist/tools/learn-patterns.js.map +0 -1
- package/dist/tools/list-imports.d.ts.map +0 -1
- package/dist/tools/list-imports.js.map +0 -1
- package/dist/tools/orchestrate-migration.d.ts.map +0 -1
- package/dist/tools/orchestrate-migration.js.map +0 -1
- package/dist/tools/parse-stack-trace.d.ts.map +0 -1
- package/dist/tools/parse-stack-trace.js.map +0 -1
- package/dist/tools/plan-migration.d.ts.map +0 -1
- package/dist/tools/plan-migration.js.map +0 -1
- package/dist/tools/resolve-type.d.ts.map +0 -1
- package/dist/tools/resolve-type.js.map +0 -1
- package/dist/tools/review-feedback.d.ts.map +0 -1
- package/dist/tools/review-feedback.js.map +0 -1
- package/dist/tools/rollback-changes.d.ts.map +0 -1
- package/dist/tools/rollback-changes.js.map +0 -1
- package/dist/tools/run-angular-cli.d.ts.map +0 -1
- package/dist/tools/run-angular-cli.js.map +0 -1
- package/dist/tools/run-build.d.ts.map +0 -1
- package/dist/tools/run-build.js.map +0 -1
- package/dist/tools/run-schematic.d.ts.map +0 -1
- package/dist/tools/run-schematic.js.map +0 -1
- package/dist/tools/scan-all.d.ts.map +0 -1
- package/dist/tools/scan-all.js.map +0 -1
- package/dist/tools/scan-angular.d.ts.map +0 -1
- package/dist/tools/scan-angular.js.map +0 -1
- package/dist/tools/scan-architecture.d.ts.map +0 -1
- package/dist/tools/scan-architecture.js.map +0 -1
- package/dist/tools/scan-solid.d.ts.map +0 -1
- package/dist/tools/scan-solid.js.map +0 -1
- package/dist/tools/search-codebase.d.ts.map +0 -1
- package/dist/tools/search-codebase.js.map +0 -1
- package/dist/tools/server-status.d.ts.map +0 -1
- package/dist/tools/server-status.js.map +0 -1
- package/dist/tools/shared/scan-types.d.ts +0 -200
- package/dist/tools/shared/scan-types.d.ts.map +0 -1
- package/dist/tools/shared/scan-types.js +0 -7
- package/dist/tools/shared/scan-types.js.map +0 -1
- package/dist/tools/suggest-improvements.d.ts.map +0 -1
- package/dist/tools/suggest-improvements.js.map +0 -1
- package/dist/tools/trace-output-flow.d.ts.map +0 -1
- package/dist/tools/trace-output-flow.js.map +0 -1
- package/dist/tools/transform-code-batch.d.ts.map +0 -1
- package/dist/tools/transform-code-batch.js.map +0 -1
- package/dist/tools/transform-code.d.ts.map +0 -1
- package/dist/tools/transform-code.js.map +0 -1
- package/dist/tools/validate-before-transform.d.ts.map +0 -1
- package/dist/tools/validate-before-transform.js.map +0 -1
- package/dist/tools/validate-project-compatibility.d.ts.map +0 -1
- package/dist/tools/validate-project-compatibility.js.map +0 -1
- package/dist/tools/validate-transformation.d.ts.map +0 -1
- package/dist/tools/validate-transformation.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/format-tool-response.d.ts.map +0 -1
- 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 -
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Feedback storage roots
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
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
|
-
*
|
|
27
|
-
*
|
|
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
|
-
*
|
|
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
|
|
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 -
|
|
2
|
+
* @angular-modernizer/adapter-mcp - Feedback storage roots
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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
|
-
|
|
11
|
+
/** Environment variable that enables the platform feedback store. */
|
|
12
|
+
export const PLATFORM_ROOT_ENV = 'ANGULAR_MODERNIZER_PLATFORM_ROOT';
|
|
9
13
|
/**
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*
|
|
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
|
-
*
|
|
29
|
-
*
|
|
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
|
-
*
|
|
32
|
-
* ```
|
|
27
|
+
* @throws {Error} for `platform` without {@link PLATFORM_ROOT_ENV}
|
|
33
28
|
*/
|
|
34
|
-
export function
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
|
|
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
|
-
|
|
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
|
-
|
|
58
|
-
|
|
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.
|
|
94
|
-
* loaded and queried; V8's heap limit on the dev machines is about 4.1 GB.
|
|
95
|
-
* 2048 MB keeps
|
|
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
|
-
/**
|
|
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
|
/**
|