@angular-modernizer/adapter-mcp 1.2.0 → 2.0.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 (130) hide show
  1. package/CHANGELOG.md +662 -0
  2. package/README.md +84 -445
  3. package/dist/cli.js +9 -1
  4. package/dist/core/project-analyzer.js +2 -2
  5. package/dist/index.d.ts +9 -0
  6. package/dist/index.js +1 -0
  7. package/dist/scan-host/scan-host.d.ts +7 -0
  8. package/dist/scan-host/scan-host.js +73 -10
  9. package/dist/scan-host/scan-protocol.d.ts +2 -0
  10. package/dist/scan-host/scan-worker.js +14 -8
  11. package/dist/server/limited-stdio-transport.d.ts +6 -3
  12. package/dist/server/limited-stdio-transport.js +26 -9
  13. package/dist/server/mcp-server.js +1 -1
  14. package/dist/server/sdk-server.d.ts +14 -3
  15. package/dist/server/sdk-server.js +54 -6
  16. package/dist/server/tool-registry.d.ts +3 -1
  17. package/dist/server/tool-registry.js +8 -3
  18. package/dist/streaming/progress-store.d.ts +19 -7
  19. package/dist/streaming/progress-store.js +19 -8
  20. package/dist/tools/analyze-build-impact.d.ts +7 -4
  21. package/dist/tools/analyze-build-impact.js +8 -3
  22. package/dist/tools/analyze-core-to-shared.d.ts +10 -6
  23. package/dist/tools/analyze-core-to-shared.js +63 -60
  24. package/dist/tools/analyze-parser-performance.d.ts +57 -13
  25. package/dist/tools/analyze-parser-performance.js +67 -6
  26. package/dist/tools/analyze-project.d.ts +30 -4
  27. package/dist/tools/analyze-project.js +99 -15
  28. package/dist/tools/check-incremental-compatibility.d.ts +30 -41
  29. package/dist/tools/check-incremental-compatibility.js +32 -264
  30. package/dist/tools/collect-feedback.js +15 -2
  31. package/dist/tools/extract-libraries.js +42 -27
  32. package/dist/tools/find-angular-symbol.js +3 -2
  33. package/dist/tools/find-component-hosts.js +3 -2
  34. package/dist/tools/find-usages.js +21 -12
  35. package/dist/tools/get-call-graph.js +15 -2
  36. package/dist/tools/get-operation-progress-tool.d.ts +1 -1
  37. package/dist/tools/get-operation-progress-tool.js +2 -2
  38. package/dist/tools/get-operation-progress.d.ts +4 -1
  39. package/dist/tools/get-operation-progress.js +6 -2
  40. package/dist/tools/helpers/analysis-output.d.ts +32 -1
  41. package/dist/tools/helpers/analysis-output.js +22 -1
  42. package/dist/tools/helpers/build-cache.d.ts +27 -0
  43. package/dist/tools/helpers/build-cache.js +86 -0
  44. package/dist/tools/helpers/class-filter.d.ts +18 -0
  45. package/dist/tools/helpers/class-filter.js +30 -0
  46. package/dist/tools/helpers/cli-arguments.d.ts +23 -0
  47. package/dist/tools/helpers/cli-arguments.js +35 -0
  48. package/dist/tools/helpers/feedback-catalog.d.ts +38 -0
  49. package/dist/tools/helpers/feedback-catalog.js +196 -0
  50. package/dist/tools/helpers/feedback-sidecar.d.ts +201 -0
  51. package/dist/tools/helpers/feedback-sidecar.js +381 -0
  52. package/dist/tools/helpers/file-type-check.d.ts +34 -0
  53. package/dist/tools/helpers/file-type-check.js +56 -0
  54. package/dist/tools/helpers/output-contract.d.ts +42 -0
  55. package/dist/tools/helpers/output-contract.js +54 -0
  56. package/dist/tools/helpers/pattern-anonymizer.d.ts +27 -0
  57. package/dist/tools/helpers/pattern-anonymizer.js +159 -0
  58. package/dist/tools/helpers/project-cache.d.ts +5 -4
  59. package/dist/tools/helpers/project-cache.js +21 -16
  60. package/dist/tools/helpers/project-decorators.d.ts +11 -4
  61. package/dist/tools/helpers/project-decorators.js +13 -6
  62. package/dist/tools/helpers/refresh-apply.d.ts +94 -0
  63. package/dist/tools/helpers/refresh-apply.js +460 -0
  64. package/dist/tools/helpers/refresh-inventory.d.ts +106 -0
  65. package/dist/tools/helpers/refresh-inventory.js +610 -0
  66. package/dist/tools/helpers/rule-runner.js +3 -1
  67. package/dist/tools/helpers/scan-cache.d.ts +74 -5
  68. package/dist/tools/helpers/scan-cache.js +134 -6
  69. package/dist/tools/helpers/scan-engine.d.ts +30 -6
  70. package/dist/tools/helpers/scan-engine.js +131 -22
  71. package/dist/tools/helpers/scan-plan.js +16 -2
  72. package/dist/tools/helpers/source-map-loader.d.ts +55 -0
  73. package/dist/tools/helpers/source-map-loader.js +226 -0
  74. package/dist/tools/helpers/template-check.d.ts +76 -0
  75. package/dist/tools/helpers/template-check.js +158 -0
  76. package/dist/tools/helpers/tool-cache.d.ts +7 -2
  77. package/dist/tools/helpers/tool-cache.js +9 -3
  78. package/dist/tools/helpers/tool-context.d.ts +18 -0
  79. package/dist/tools/helpers/tool-context.js +29 -0
  80. package/dist/tools/helpers/transform-safety.d.ts +151 -1
  81. package/dist/tools/helpers/transform-safety.js +357 -4
  82. package/dist/tools/inspect-form-group.js +5 -0
  83. package/dist/tools/inspect-i18n.d.ts +1 -1
  84. package/dist/tools/inspect-template.js +8 -2
  85. package/dist/tools/learn-patterns.d.ts +43 -28
  86. package/dist/tools/learn-patterns.js +83 -161
  87. package/dist/tools/list-imports.d.ts +1 -1
  88. package/dist/tools/orchestrate-migration.d.ts +19 -1
  89. package/dist/tools/orchestrate-migration.js +52 -10
  90. package/dist/tools/parse-stack-trace.d.ts +48 -1
  91. package/dist/tools/parse-stack-trace.js +108 -9
  92. package/dist/tools/plan-migration.js +22 -10
  93. package/dist/tools/refresh-state.d.ts +378 -0
  94. package/dist/tools/refresh-state.js +370 -0
  95. package/dist/tools/resolve-type.js +10 -3
  96. package/dist/tools/review-feedback.d.ts +42 -7
  97. package/dist/tools/review-feedback.js +24 -17
  98. package/dist/tools/rollback-changes.d.ts +5 -0
  99. package/dist/tools/rollback-changes.js +7 -2
  100. package/dist/tools/run-angular-cli.js +36 -22
  101. package/dist/tools/run-build.d.ts +33 -28
  102. package/dist/tools/run-build.js +136 -438
  103. package/dist/tools/run-schematic.d.ts +8 -2
  104. package/dist/tools/run-schematic.js +80 -50
  105. package/dist/tools/scan-all.d.ts +31 -15
  106. package/dist/tools/scan-all.js +75 -109
  107. package/dist/tools/scan-angular.d.ts +27 -14
  108. package/dist/tools/scan-angular.js +70 -92
  109. package/dist/tools/scan-architecture.d.ts +29 -12
  110. package/dist/tools/scan-architecture.js +205 -135
  111. package/dist/tools/scan-solid.d.ts +27 -14
  112. package/dist/tools/scan-solid.js +73 -89
  113. package/dist/tools/search-codebase.d.ts +6 -1
  114. package/dist/tools/search-codebase.js +13 -7
  115. package/dist/tools/suggest-improvements.d.ts +34 -3
  116. package/dist/tools/suggest-improvements.js +34 -9
  117. package/dist/tools/trace-output-flow.js +3 -2
  118. package/dist/tools/transform-code-batch.d.ts +9 -9
  119. package/dist/tools/transform-code.d.ts +161 -12
  120. package/dist/tools/transform-code.js +715 -206
  121. package/dist/tools/validate-before-transform.js +2 -1
  122. package/dist/tools/validate-project-compatibility.d.ts +28 -55
  123. package/dist/tools/validate-project-compatibility.js +33 -225
  124. package/dist/tools/validate-transformation.d.ts +40 -26
  125. package/dist/tools/validate-transformation.js +115 -294
  126. package/dist/tools/verify-citations.js +8 -2
  127. package/dist/types.d.ts +9 -9
  128. package/dist/utils/format-tool-response.d.ts +3 -1
  129. package/dist/utils/format-tool-response.js +8 -3
  130. package/package.json +14 -13
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Anonymization of learn-patterns examples: file paths and code.
3
+ *
4
+ * `strict` hashes file paths and renames every identifier, string literal
5
+ * and template text in code deterministically (same name, same alias in
6
+ * every example and run) and drops comments; framework names stay.
7
+ * `moderate` makes file paths project-relative and keeps the code.
8
+ * `minimal` keeps both as they are.
9
+ */
10
+ import { createHash } from 'node:crypto';
11
+ import { extname, relative, resolve, sep } from 'node:path';
12
+ import { ts } from 'ts-morph';
13
+ /** Angular, RxJS, TypeScript and JavaScript names that stay readable. */
14
+ const PRESERVED_IDENTIFIERS = new Set([
15
+ // Angular decorators, metadata keys and APIs
16
+ 'Component', 'Injectable', 'Directive', 'Pipe', 'NgModule', 'Input', 'Output', 'HostListener',
17
+ 'HostBinding', 'ViewChild', 'ViewChildren', 'ContentChild', 'ContentChildren', 'Inject', 'Optional',
18
+ 'Self', 'SkipSelf', 'Host', 'selector', 'template', 'templateUrl', 'styles', 'styleUrl', 'styleUrls',
19
+ 'standalone', 'imports', 'exports', 'declarations', 'providers', 'bootstrap', 'providedIn',
20
+ 'changeDetection', 'ChangeDetectionStrategy', 'OnPush', 'Default', 'ChangeDetectorRef', 'EventEmitter',
21
+ 'inject', 'signal', 'computed', 'effect', 'input', 'output', 'model', 'OnInit', 'OnDestroy', 'OnChanges',
22
+ 'AfterViewInit', 'AfterContentInit', 'DoCheck', 'ngOnInit', 'ngOnDestroy', 'ngOnChanges', 'ngAfterViewInit',
23
+ 'ngAfterContentInit', 'ngDoCheck', 'SimpleChanges', 'ElementRef', 'Injector', 'InjectionToken',
24
+ 'HttpClient', 'Router', 'ActivatedRoute', 'FormBuilder', 'FormGroup', 'FormControl', 'Validators',
25
+ 'CommonModule', 'RouterModule', 'BrowserModule', 'Service',
26
+ // RxJS
27
+ 'Observable', 'Subject', 'BehaviorSubject', 'ReplaySubject', 'AsyncSubject', 'Subscription', 'of', 'from',
28
+ 'subscribe', 'unsubscribe', 'pipe', 'next', 'error', 'complete', 'map', 'filter', 'switchMap', 'mergeMap',
29
+ 'concatMap', 'exhaustMap', 'takeUntil', 'take', 'tap', 'catchError', 'debounceTime', 'distinctUntilChanged',
30
+ 'combineLatest', 'forkJoin', 'firstValueFrom', 'lastValueFrom', 'takeUntilDestroyed', 'asObservable',
31
+ // TypeScript and JavaScript
32
+ 'undefined', 'NaN', 'Infinity', 'console', 'log', 'warn', 'Promise', 'Array', 'Object', 'String', 'Number',
33
+ 'Boolean', 'Date', 'Math', 'JSON', 'Error', 'Map', 'Set', 'Record', 'Partial', 'Readonly', 'Pick', 'Omit',
34
+ 'length', 'push', 'reduce', 'forEach', 'find', 'some', 'every', 'includes', 'indexOf', 'slice', 'concat',
35
+ 'join', 'keys', 'values', 'entries', 'then', 'catch', 'finally', 'get', 'has', 'add', 'delete', 'clear',
36
+ 'size', 'toString', 'emit',
37
+ ]);
38
+ /** String values that stay readable (DI scopes). */
39
+ const PRESERVED_STRINGS = new Set(['root', 'any', 'platform']);
40
+ /** Module specifiers of framework packages stay readable. */
41
+ function isFrameworkModule(value) {
42
+ return value.startsWith('@angular/') || value === 'rxjs' || value.startsWith('rxjs/') || value === 'tslib';
43
+ }
44
+ function hash(value, length) {
45
+ return createHash('sha256').update(value).digest('hex').slice(0, length);
46
+ }
47
+ /** Deterministic alias of an identifier, keeping the case of its first letter. */
48
+ function identifierAlias(name) {
49
+ const isPrivate = name.startsWith('#');
50
+ const bare = isPrivate ? name.slice(1) : name;
51
+ const first = bare.charAt(0);
52
+ const prefix = first !== first.toLowerCase() ? 'Name' : 'name';
53
+ return `${isPrivate ? '#' : ''}${prefix}_${hash(bare, 8)}`;
54
+ }
55
+ function stringAlias(value) {
56
+ return `str_${hash(value, 8)}`;
57
+ }
58
+ /**
59
+ * File path of an example: hashed (`strict`), project-relative (`moderate`)
60
+ * or unchanged (`minimal`).
61
+ */
62
+ export function anonymizeFilePath(filePath, projectRoot, level) {
63
+ if (level === 'minimal') {
64
+ return filePath;
65
+ }
66
+ const projectRelative = relative(resolve(projectRoot), resolve(filePath)).split(sep).join('/');
67
+ if (level === 'moderate') {
68
+ return projectRelative;
69
+ }
70
+ return `file-${hash(projectRelative, 12)}${extname(filePath)}`;
71
+ }
72
+ function commentRanges(sourceFile, code) {
73
+ const seen = new Map();
74
+ const collect = (ranges) => {
75
+ for (const range of ranges ?? []) {
76
+ seen.set(range.pos, range);
77
+ }
78
+ };
79
+ const visit = (node) => {
80
+ collect(ts.getLeadingCommentRanges(code, node.pos));
81
+ collect(ts.getTrailingCommentRanges(code, node.end));
82
+ for (const child of node.getChildren(sourceFile)) {
83
+ visit(child);
84
+ }
85
+ };
86
+ visit(sourceFile);
87
+ return [...seen.values()];
88
+ }
89
+ function templateEdit(node, sourceFile) {
90
+ const start = node.getStart(sourceFile);
91
+ const opening = node.kind === ts.SyntaxKind.TemplateHead || node.kind === ts.SyntaxKind.NoSubstitutionTemplateLiteral ? '`' : '}';
92
+ const closing = node.kind === ts.SyntaxKind.TemplateHead || node.kind === ts.SyntaxKind.TemplateMiddle ? '${' : '`';
93
+ return { start, end: node.end, text: `${opening}${stringAlias(node.text)}${closing}` };
94
+ }
95
+ function literalEdit(node, sourceFile) {
96
+ if (ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) {
97
+ const name = node.text;
98
+ if (PRESERVED_IDENTIFIERS.has(name)) {
99
+ return undefined;
100
+ }
101
+ return { start: node.getStart(sourceFile), end: node.end, text: identifierAlias(name) };
102
+ }
103
+ if (ts.isStringLiteral(node)) {
104
+ if (PRESERVED_STRINGS.has(node.text) || isFrameworkModule(node.text)) {
105
+ return undefined;
106
+ }
107
+ const start = node.getStart(sourceFile);
108
+ const quote = sourceFile.text.charAt(start);
109
+ return { start, end: node.end, text: `${quote}${stringAlias(node.text)}${quote}` };
110
+ }
111
+ if (ts.isNoSubstitutionTemplateLiteral(node) ||
112
+ ts.isTemplateHead(node) ||
113
+ ts.isTemplateMiddle(node) ||
114
+ ts.isTemplateTail(node)) {
115
+ return templateEdit(node, sourceFile);
116
+ }
117
+ return undefined;
118
+ }
119
+ /**
120
+ * Code of an example. `strict` renames identifiers, string literals and
121
+ * template text and drops comments; the other levels keep the code.
122
+ */
123
+ export function anonymizeCode(code, level) {
124
+ if (level !== 'strict' || code === '') {
125
+ return code;
126
+ }
127
+ const sourceFile = ts.createSourceFile('example.ts', code, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
128
+ const comments = commentRanges(sourceFile, code);
129
+ const inComment = (pos) => comments.some((c) => pos >= c.pos && pos < c.end);
130
+ const edits = comments.map((c) => ({ start: c.pos, end: c.end, text: '' }));
131
+ const visit = (node) => {
132
+ if (ts.isJSDoc(node)) {
133
+ return;
134
+ }
135
+ const edit = literalEdit(node, sourceFile);
136
+ if (edit !== undefined && !inComment(edit.start)) {
137
+ edits.push(edit);
138
+ return;
139
+ }
140
+ ts.forEachChild(node, visit);
141
+ };
142
+ visit(sourceFile);
143
+ let result = code;
144
+ for (const edit of edits.sort((a, b) => b.start - a.start)) {
145
+ result = result.slice(0, edit.start) + edit.text + result.slice(edit.end);
146
+ }
147
+ return result;
148
+ }
149
+ /**
150
+ * Metadata of an example. `strict` anonymizes string values like code
151
+ * (class and property names get the same alias as in the code).
152
+ */
153
+ export function anonymizeMetadata(metadata, level) {
154
+ if (level !== 'strict') {
155
+ return metadata;
156
+ }
157
+ return Object.fromEntries(Object.entries(metadata).map(([key, value]) => [key, typeof value === 'string' ? anonymizeCode(value, level) : value]));
158
+ }
159
+ //# sourceMappingURL=pattern-anonymizer.js.map
@@ -195,10 +195,11 @@ export declare class ProjectCache {
195
195
  /** Eviction count and the most recent eviction. */
196
196
  get evictions(): EvictionStats;
197
197
  /**
198
- * Warnings about the loaded project for `tsConfigPath`: today the library
199
- * imports that do not resolve (missing or incomplete node_modules). Checked
200
- * once per load, on the first call, and kept until the project is reloaded;
201
- * empty when the project is not cached.
198
+ * Warnings about the loaded project for `tsConfigPath`: program files that
199
+ * could not be read and were left out, and the library imports that do not
200
+ * resolve (missing or incomplete node_modules). Checked once per load, on
201
+ * the first call, and kept until the project is reloaded; empty when the
202
+ * project is not cached.
202
203
  */
203
204
  warnings(tsConfigPath: string): string[];
204
205
  /** Cached projects, least recently used first. */
@@ -1,5 +1,6 @@
1
1
  import { statSync } from 'node:fs';
2
2
  import { Project, ts } from 'ts-morph';
3
+ import { addReadableSourceFiles, unreadableFilesWarning, } from '@angular-modernizer/core';
3
4
  import { findUnresolvedLibraryImports, libraryImportWarning, } from './library-imports.js';
4
5
  /** Thrown by `acquire()` when its signal aborts. */
5
6
  export class ProjectLoadCancelledError extends Error {
@@ -140,7 +141,7 @@ export class ProjectCache {
140
141
  // would stack two large programs before the check below evicts one.
141
142
  this.evictOverHeap(tsConfigPath);
142
143
  const heapBefore = this.memory.usage().heapUsed;
143
- project = this.store(tsConfigPath, mtimeMs, heapBefore, runToEnd(this.loadSteps(tsConfigPath)));
144
+ project = this.store(tsConfigPath, mtimeMs, heapBefore, runToEnd(this.loadSteps(tsConfigPath))).project;
144
145
  }
145
146
  this.evictOverCount();
146
147
  this.evictOverHeap(tsConfigPath);
@@ -195,10 +196,11 @@ export class ProjectCache {
195
196
  : { count: this.evictionCount, last: this.lastEviction };
196
197
  }
197
198
  /**
198
- * Warnings about the loaded project for `tsConfigPath`: today the library
199
- * imports that do not resolve (missing or incomplete node_modules). Checked
200
- * once per load, on the first call, and kept until the project is reloaded;
201
- * empty when the project is not cached.
199
+ * Warnings about the loaded project for `tsConfigPath`: program files that
200
+ * could not be read and were left out, and the library imports that do not
201
+ * resolve (missing or incomplete node_modules). Checked once per load, on
202
+ * the first call, and kept until the project is reloaded; empty when the
203
+ * project is not cached.
202
204
  */
203
205
  warnings(tsConfigPath) {
204
206
  const entry = this.entries.get(tsConfigPath);
@@ -207,7 +209,7 @@ export class ProjectCache {
207
209
  }
208
210
  if (entry.warnings === undefined) {
209
211
  const warning = libraryImportWarning(findUnresolvedLibraryImports(entry.project, tsConfigPath));
210
- entry.warnings = warning === undefined ? [] : [warning];
212
+ entry.warnings = [unreadableFilesWarning(entry.unreadableFiles), warning].filter((w) => w !== undefined);
211
213
  }
212
214
  return [...entry.warnings];
213
215
  }
@@ -284,17 +286,18 @@ export class ProjectCache {
284
286
  */
285
287
  *loadSteps(tsConfigPath) {
286
288
  if (this.createProject !== undefined) {
287
- return this.createProject(tsConfigPath);
289
+ return { project: this.createProject(tsConfigPath), unreadableFiles: [] };
288
290
  }
289
291
  const { project, files } = this.openProject(tsConfigPath);
292
+ // A file that cannot be read (EACCES) is left out and reported, as the
293
+ // scans skip it; it still counts for the load progress
294
+ const unreadableFiles = [];
290
295
  for (let start = 0; start < files.length; start += this.batchSize) {
291
- for (const filePath of files.slice(start, start + this.batchSize)) {
292
- project.addSourceFileAtPath(filePath);
293
- }
296
+ unreadableFiles.push(...addReadableSourceFiles(project, files.slice(start, start + this.batchSize)));
294
297
  yield [Math.min(start + this.batchSize, files.length), files.length];
295
298
  }
296
299
  project.resolveSourceFileDependencies();
297
- return project;
300
+ return { project, unreadableFiles };
298
301
  }
299
302
  startLoad(tsConfigPath, mtimeMs) {
300
303
  const state = { waiters: new Set(), cancelled: false };
@@ -325,14 +328,14 @@ export class ProjectCache {
325
328
  this.stopIfCancelled(tsConfigPath, job);
326
329
  step = steps.next();
327
330
  }
328
- const project = step.value;
331
+ const loaded = step.value;
329
332
  await nextTurn();
330
333
  this.stopIfCancelled(tsConfigPath, job);
331
- project.getProgram().compilerObject.getTypeChecker();
334
+ loaded.project.getProgram().compilerObject.getTypeChecker();
332
335
  const cached = this.entries.get(tsConfigPath);
333
336
  const result = cached?.mtimeMs === mtimeMs
334
337
  ? cached.project
335
- : this.store(tsConfigPath, mtimeMs, heapBefore, project);
338
+ : this.store(tsConfigPath, mtimeMs, heapBefore, loaded).project;
336
339
  this.evictOverCount();
337
340
  this.evictOverHeap(tsConfigPath);
338
341
  return result;
@@ -371,10 +374,12 @@ export class ProjectCache {
371
374
  .finally(() => signal.removeEventListener('abort', onAbort));
372
375
  });
373
376
  }
374
- store(tsConfigPath, mtimeMs, heapBefore, project) {
377
+ store(tsConfigPath, mtimeMs, heapBefore, loaded) {
378
+ const { project, unreadableFiles } = loaded;
375
379
  const now = new Date();
376
380
  this.entries.set(tsConfigPath, {
377
381
  project,
382
+ unreadableFiles,
378
383
  mtimeMs,
379
384
  loadedAt: now,
380
385
  lastUsedAt: now,
@@ -382,7 +387,7 @@ export class ProjectCache {
382
387
  fileMtimes: this.recordMtimes(project),
383
388
  refreshedFiles: 0,
384
389
  });
385
- return project;
390
+ return loaded;
386
391
  }
387
392
  evictOverCount() {
388
393
  for (const key of this.entries.keys()) {
@@ -5,10 +5,17 @@
5
5
  * project root. The list adds to `Component`; the api classes treat a missing
6
6
  * and an empty list the same (Component only).
7
7
  */
8
+ /** Configured component decorators and why the config could not be used. */
9
+ export interface ProjectComponentDecorators {
10
+ /** `parser.componentDecorators`, `undefined` without a config or when it does not load. */
11
+ componentDecorators: readonly string[] | undefined;
12
+ /** One entry when the config does not load (invalid JSON or schema); empty otherwise. */
13
+ warnings: string[];
14
+ }
8
15
  /**
9
- * `parser.componentDecorators` of the project, or `undefined` when the project
10
- * has no config file or the config does not load. A broken config must not
11
- * break investigation; the tools then fall back to `Component` only.
16
+ * `parser.componentDecorators` of the project. A broken config must not break
17
+ * investigation: the tools then fall back to `Component` only, and the warning
18
+ * says so (with the loader's message, which names unknown keys).
12
19
  */
13
- export declare function configuredComponentDecorators(projectRoot: string): readonly string[] | undefined;
20
+ export declare function configuredComponentDecorators(projectRoot: string): ProjectComponentDecorators;
14
21
  //# sourceMappingURL=project-decorators.d.ts.map
@@ -7,16 +7,23 @@
7
7
  */
8
8
  import { loadConfig } from '@angular-modernizer/core';
9
9
  /**
10
- * `parser.componentDecorators` of the project, or `undefined` when the project
11
- * has no config file or the config does not load. A broken config must not
12
- * break investigation; the tools then fall back to `Component` only.
10
+ * `parser.componentDecorators` of the project. A broken config must not break
11
+ * investigation: the tools then fall back to `Component` only, and the warning
12
+ * says so (with the loader's message, which names unknown keys).
13
13
  */
14
14
  export function configuredComponentDecorators(projectRoot) {
15
15
  try {
16
- return loadConfig(projectRoot).parser?.componentDecorators;
16
+ return {
17
+ componentDecorators: loadConfig(projectRoot).parser?.componentDecorators,
18
+ warnings: [],
19
+ };
17
20
  }
18
- catch {
19
- return undefined;
21
+ catch (error) {
22
+ const message = error instanceof Error ? error.message : String(error);
23
+ return {
24
+ componentDecorators: undefined,
25
+ warnings: [`.angular-modernizer.json not used (only @Component counts as a component): ${message}`],
26
+ };
20
27
  }
21
28
  }
22
29
  //# sourceMappingURL=project-decorators.js.map
@@ -0,0 +1,94 @@
1
+ import { type GitRunner, type RefreshItem, type RefreshReason, type RefreshRetention, type RefreshStore } from './refresh-inventory.js';
2
+ import { type CatalogTool } from './feedback-catalog.js';
3
+ /** Time a plan stays valid after its report. */
4
+ export declare const PLAN_TTL_MS: number;
5
+ /** Parts of the platform state an apply can act on. */
6
+ export type RefreshPart = 'caches' | 'backups' | 'refs' | 'feedback';
7
+ /** Every part apply accepts. */
8
+ export declare const REFRESH_PARTS: readonly RefreshPart[];
9
+ /** Why apply left a planned item in place. */
10
+ export type SkipCause = 'no-longer-listed' | 'missing' | 'changed' | 'symbolic-link' | 'outside-cache-folder' | 'outside-backup-folder' | 'outside-feedback-folder' | 'failed';
11
+ /** A planned item apply removed. */
12
+ export interface RemovedItem {
13
+ /** Store of the item. */
14
+ store: RefreshStore;
15
+ /** Reason it was listed. */
16
+ reason: RefreshReason;
17
+ /** Path relative to the project root, backup group id or ref name. */
18
+ path: string;
19
+ /** Bytes freed (0 for a ref). */
20
+ bytes: number;
21
+ }
22
+ /** A planned item apply left in place. */
23
+ export interface SkippedItem {
24
+ /** Store of the item. */
25
+ store: RefreshStore;
26
+ /** Reason it was listed. */
27
+ reason: RefreshReason;
28
+ /** Path relative to the project root, backup group id or ref name. */
29
+ path: string;
30
+ /** Why it stayed. */
31
+ cause: SkipCause;
32
+ /** Error message of a failed removal. */
33
+ detail?: string;
34
+ }
35
+ /** A planned feedback item whose session file apply marked in the sidecar. */
36
+ export interface MarkedItem {
37
+ /** Store of the item (`feedback`). */
38
+ store: RefreshStore;
39
+ /** Reason it was listed. */
40
+ reason: RefreshReason;
41
+ /** Session file relative to the project root. */
42
+ path: string;
43
+ /** Records of the file the sidecar marks now (all reasons). */
44
+ records: number;
45
+ }
46
+ /** Outcome of an apply. */
47
+ export interface ApplyOutcome {
48
+ /** Removed items, plan order. */
49
+ removed: RemovedItem[];
50
+ /** Feedback items marked in the sidecar, plan order. */
51
+ marked: MarkedItem[];
52
+ /** Planned items of the requested parts that stayed. */
53
+ skipped: SkippedItem[];
54
+ }
55
+ /** Lists the items a fresh inventory of the project finds with the given retention. */
56
+ export type InventoryLister = (retention: RefreshRetention) => readonly RefreshItem[];
57
+ /** Registered tools for the feedback marks, read at apply time. */
58
+ export type ApplyTools = readonly CatalogTool[] | undefined;
59
+ /** Plans of one tool instance, kept in memory only. */
60
+ export declare class RefreshPlans {
61
+ private readonly now;
62
+ private readonly git;
63
+ private readonly plans;
64
+ /**
65
+ * @param now clock
66
+ * @param git git runner (snapshot refs are read and deleted through it)
67
+ */
68
+ constructor(now: () => number, git?: GitRunner);
69
+ /**
70
+ * Records the items of a report with their fingerprints and the retention the report used.
71
+ *
72
+ * @param projectRoot real path of the project root
73
+ * @returns the plan id and when it expires (ms)
74
+ */
75
+ create(projectRoot: string, items: readonly RefreshItem[], retention: RefreshRetention): {
76
+ planId: string;
77
+ expiresAt: number;
78
+ };
79
+ /**
80
+ * Removes the planned items of `parts` that a fresh inventory still lists and that are unchanged. The inventory
81
+ * runs with the retention of the report. The plan is used up by the call, whatever the outcome.
82
+ *
83
+ * @param projectRoot real path of the project root
84
+ * @throws when the plan is unknown, expired or belongs to another project
85
+ */
86
+ apply(planId: string, projectRoot: string, parts: readonly RefreshPart[], inventory: InventoryLister, tools?: ApplyTools): ApplyOutcome;
87
+ /** Writes the sidecar marks of the planned session files that are still unchanged. */
88
+ private mark;
89
+ /** Fingerprint of an item at report time, or why it can never be removed. */
90
+ private plan;
91
+ /** Removes one listed item when it is unchanged against its fingerprint. */
92
+ private remove;
93
+ }
94
+ //# sourceMappingURL=refresh-apply.d.ts.map