@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.
- package/CHANGELOG.md +662 -0
- package/README.md +84 -445
- package/dist/cli.js +9 -1
- package/dist/core/project-analyzer.js +2 -2
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1 -0
- package/dist/scan-host/scan-host.d.ts +7 -0
- package/dist/scan-host/scan-host.js +73 -10
- package/dist/scan-host/scan-protocol.d.ts +2 -0
- package/dist/scan-host/scan-worker.js +14 -8
- package/dist/server/limited-stdio-transport.d.ts +6 -3
- package/dist/server/limited-stdio-transport.js +26 -9
- package/dist/server/mcp-server.js +1 -1
- package/dist/server/sdk-server.d.ts +14 -3
- package/dist/server/sdk-server.js +54 -6
- package/dist/server/tool-registry.d.ts +3 -1
- package/dist/server/tool-registry.js +8 -3
- package/dist/streaming/progress-store.d.ts +19 -7
- package/dist/streaming/progress-store.js +19 -8
- package/dist/tools/analyze-build-impact.d.ts +7 -4
- package/dist/tools/analyze-build-impact.js +8 -3
- package/dist/tools/analyze-core-to-shared.d.ts +10 -6
- package/dist/tools/analyze-core-to-shared.js +63 -60
- package/dist/tools/analyze-parser-performance.d.ts +57 -13
- package/dist/tools/analyze-parser-performance.js +67 -6
- package/dist/tools/analyze-project.d.ts +30 -4
- package/dist/tools/analyze-project.js +99 -15
- package/dist/tools/check-incremental-compatibility.d.ts +30 -41
- package/dist/tools/check-incremental-compatibility.js +32 -264
- package/dist/tools/collect-feedback.js +15 -2
- package/dist/tools/extract-libraries.js +42 -27
- package/dist/tools/find-angular-symbol.js +3 -2
- package/dist/tools/find-component-hosts.js +3 -2
- package/dist/tools/find-usages.js +21 -12
- package/dist/tools/get-call-graph.js +15 -2
- package/dist/tools/get-operation-progress-tool.d.ts +1 -1
- package/dist/tools/get-operation-progress-tool.js +2 -2
- package/dist/tools/get-operation-progress.d.ts +4 -1
- package/dist/tools/get-operation-progress.js +6 -2
- package/dist/tools/helpers/analysis-output.d.ts +32 -1
- package/dist/tools/helpers/analysis-output.js +22 -1
- package/dist/tools/helpers/build-cache.d.ts +27 -0
- package/dist/tools/helpers/build-cache.js +86 -0
- package/dist/tools/helpers/class-filter.d.ts +18 -0
- package/dist/tools/helpers/class-filter.js +30 -0
- package/dist/tools/helpers/cli-arguments.d.ts +23 -0
- package/dist/tools/helpers/cli-arguments.js +35 -0
- package/dist/tools/helpers/feedback-catalog.d.ts +38 -0
- package/dist/tools/helpers/feedback-catalog.js +196 -0
- package/dist/tools/helpers/feedback-sidecar.d.ts +201 -0
- package/dist/tools/helpers/feedback-sidecar.js +381 -0
- package/dist/tools/helpers/file-type-check.d.ts +34 -0
- package/dist/tools/helpers/file-type-check.js +56 -0
- package/dist/tools/helpers/output-contract.d.ts +42 -0
- package/dist/tools/helpers/output-contract.js +54 -0
- package/dist/tools/helpers/pattern-anonymizer.d.ts +27 -0
- package/dist/tools/helpers/pattern-anonymizer.js +159 -0
- package/dist/tools/helpers/project-cache.d.ts +5 -4
- package/dist/tools/helpers/project-cache.js +21 -16
- package/dist/tools/helpers/project-decorators.d.ts +11 -4
- package/dist/tools/helpers/project-decorators.js +13 -6
- package/dist/tools/helpers/refresh-apply.d.ts +94 -0
- package/dist/tools/helpers/refresh-apply.js +460 -0
- package/dist/tools/helpers/refresh-inventory.d.ts +106 -0
- package/dist/tools/helpers/refresh-inventory.js +610 -0
- package/dist/tools/helpers/rule-runner.js +3 -1
- package/dist/tools/helpers/scan-cache.d.ts +74 -5
- package/dist/tools/helpers/scan-cache.js +134 -6
- package/dist/tools/helpers/scan-engine.d.ts +30 -6
- package/dist/tools/helpers/scan-engine.js +131 -22
- package/dist/tools/helpers/scan-plan.js +16 -2
- package/dist/tools/helpers/source-map-loader.d.ts +55 -0
- package/dist/tools/helpers/source-map-loader.js +226 -0
- package/dist/tools/helpers/template-check.d.ts +76 -0
- package/dist/tools/helpers/template-check.js +158 -0
- package/dist/tools/helpers/tool-cache.d.ts +7 -2
- package/dist/tools/helpers/tool-cache.js +9 -3
- package/dist/tools/helpers/tool-context.d.ts +18 -0
- package/dist/tools/helpers/tool-context.js +29 -0
- package/dist/tools/helpers/transform-safety.d.ts +151 -1
- package/dist/tools/helpers/transform-safety.js +357 -4
- package/dist/tools/inspect-form-group.js +5 -0
- package/dist/tools/inspect-i18n.d.ts +1 -1
- package/dist/tools/inspect-template.js +8 -2
- package/dist/tools/learn-patterns.d.ts +43 -28
- package/dist/tools/learn-patterns.js +83 -161
- package/dist/tools/list-imports.d.ts +1 -1
- package/dist/tools/orchestrate-migration.d.ts +19 -1
- package/dist/tools/orchestrate-migration.js +52 -10
- package/dist/tools/parse-stack-trace.d.ts +48 -1
- package/dist/tools/parse-stack-trace.js +108 -9
- package/dist/tools/plan-migration.js +22 -10
- package/dist/tools/refresh-state.d.ts +378 -0
- package/dist/tools/refresh-state.js +370 -0
- package/dist/tools/resolve-type.js +10 -3
- package/dist/tools/review-feedback.d.ts +42 -7
- package/dist/tools/review-feedback.js +24 -17
- package/dist/tools/rollback-changes.d.ts +5 -0
- package/dist/tools/rollback-changes.js +7 -2
- package/dist/tools/run-angular-cli.js +36 -22
- package/dist/tools/run-build.d.ts +33 -28
- package/dist/tools/run-build.js +136 -438
- package/dist/tools/run-schematic.d.ts +8 -2
- package/dist/tools/run-schematic.js +80 -50
- package/dist/tools/scan-all.d.ts +31 -15
- package/dist/tools/scan-all.js +75 -109
- package/dist/tools/scan-angular.d.ts +27 -14
- package/dist/tools/scan-angular.js +70 -92
- package/dist/tools/scan-architecture.d.ts +29 -12
- package/dist/tools/scan-architecture.js +205 -135
- package/dist/tools/scan-solid.d.ts +27 -14
- package/dist/tools/scan-solid.js +73 -89
- package/dist/tools/search-codebase.d.ts +6 -1
- package/dist/tools/search-codebase.js +13 -7
- package/dist/tools/suggest-improvements.d.ts +34 -3
- package/dist/tools/suggest-improvements.js +34 -9
- package/dist/tools/trace-output-flow.js +3 -2
- package/dist/tools/transform-code-batch.d.ts +9 -9
- package/dist/tools/transform-code.d.ts +161 -12
- package/dist/tools/transform-code.js +715 -206
- package/dist/tools/validate-before-transform.js +2 -1
- package/dist/tools/validate-project-compatibility.d.ts +28 -55
- package/dist/tools/validate-project-compatibility.js +33 -225
- package/dist/tools/validate-transformation.d.ts +40 -26
- package/dist/tools/validate-transformation.js +115 -294
- package/dist/tools/verify-citations.js +8 -2
- package/dist/types.d.ts +9 -9
- package/dist/utils/format-tool-response.d.ts +3 -1
- package/dist/utils/format-tool-response.js +8 -3
- package/package.json +14 -13
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What feedback records are checked against (refresh-state, feedback part): the rule ids of the plugins, the
|
|
3
|
+
* transformation types of transform-code and the tools the server registers. Rule ids and transformation types are
|
|
4
|
+
* constants, so no plugin is loaded for the check (plugin-angular brings `@angular/compiler`); a test compares the
|
|
5
|
+
* rule ids with the plugins. The tools come from the server at run time.
|
|
6
|
+
*/
|
|
7
|
+
import { fromLegacyAnalysisRecord } from '@angular-modernizer/core';
|
|
8
|
+
/** Values of transform-code's `transformation` argument. */
|
|
9
|
+
export const TRANSFORMATION_TYPES = [
|
|
10
|
+
'constructor-to-inject',
|
|
11
|
+
'interface-extraction',
|
|
12
|
+
'standalone-migration',
|
|
13
|
+
'dependency-injection-migration',
|
|
14
|
+
'facade-pattern',
|
|
15
|
+
'form-modernization',
|
|
16
|
+
'constructor-injection-transform',
|
|
17
|
+
'component-inputs-interface-extraction',
|
|
18
|
+
'service-injection-cleanup',
|
|
19
|
+
'container-presentational',
|
|
20
|
+
'core-shared-modules',
|
|
21
|
+
'inheritance-to-composition',
|
|
22
|
+
'promise-service-to-observable',
|
|
23
|
+
'promise-component-to-reactive',
|
|
24
|
+
'promise-cleanup',
|
|
25
|
+
'sequential-await-to-forkjoin',
|
|
26
|
+
'missing-output-transform',
|
|
27
|
+
'subscription-transform',
|
|
28
|
+
'library-extraction',
|
|
29
|
+
'service-bag-transform',
|
|
30
|
+
'any-to-interface',
|
|
31
|
+
'dto-object-literal',
|
|
32
|
+
'interface-duplication',
|
|
33
|
+
'static-class-to-functions',
|
|
34
|
+
'extract-static-from-stateful',
|
|
35
|
+
'type-safety',
|
|
36
|
+
];
|
|
37
|
+
/** Ids of the analysis and transform rules of plugin-angular, plugin-architecture, plugin-solid, plugin-standalone and plugin-analyzer. */
|
|
38
|
+
export const REGISTERED_RULE_IDS = [
|
|
39
|
+
'analyzer:framework-detector',
|
|
40
|
+
'angular:any-to-interface',
|
|
41
|
+
'angular:any-to-interface-transform',
|
|
42
|
+
'angular:async-pipe-misuse',
|
|
43
|
+
'angular:component-inputs-interface-extraction',
|
|
44
|
+
'angular:component-without-selector',
|
|
45
|
+
'angular:component-wrapper-instantiation',
|
|
46
|
+
'angular:constructor-injection-transform',
|
|
47
|
+
'angular:constructor-to-inject',
|
|
48
|
+
'angular:container-presentational',
|
|
49
|
+
'angular:core-shared-modules',
|
|
50
|
+
'angular:dependency-injection-migration',
|
|
51
|
+
'angular:directive-without-selector',
|
|
52
|
+
'angular:dto-direct-instantiation',
|
|
53
|
+
'angular:dto-object-literal-transform',
|
|
54
|
+
'angular:extract-static-from-stateful',
|
|
55
|
+
'angular:facade-pattern',
|
|
56
|
+
'angular:form-modernization',
|
|
57
|
+
'angular:immutable-input-violation',
|
|
58
|
+
'angular:interface-duplication',
|
|
59
|
+
'angular:interface-duplication-transform',
|
|
60
|
+
'angular:interface-extraction',
|
|
61
|
+
'angular:lifecycle-hook-violation',
|
|
62
|
+
'angular:magic-string-selector',
|
|
63
|
+
'angular:missing-onpush-change-detection',
|
|
64
|
+
'angular:missing-output-transform',
|
|
65
|
+
'angular:missing-return-type',
|
|
66
|
+
'angular:missing-trackby',
|
|
67
|
+
'angular:performance-violation',
|
|
68
|
+
'angular:pipe-without-name',
|
|
69
|
+
'angular:presentational-component-violation',
|
|
70
|
+
'angular:promise-cleanup',
|
|
71
|
+
'angular:promise-component-to-reactive',
|
|
72
|
+
'angular:promise-service-to-observable',
|
|
73
|
+
'angular:promise-vs-observable-anti-pattern',
|
|
74
|
+
'angular:sequential-await-to-forkjoin',
|
|
75
|
+
'angular:service-mutable-state',
|
|
76
|
+
'angular:service-without-injectable',
|
|
77
|
+
'angular:static-class-detection',
|
|
78
|
+
'angular:static-class-to-functions',
|
|
79
|
+
'angular:subscription-transform',
|
|
80
|
+
'angular:template-complexity',
|
|
81
|
+
'angular:too-many-inputs',
|
|
82
|
+
'angular:transform:inheritance-to-composition',
|
|
83
|
+
'angular:transform:service-injection-cleanup',
|
|
84
|
+
'angular:type-safety',
|
|
85
|
+
'angular:type-safety-transform',
|
|
86
|
+
'angular:unnecessary-change-detection',
|
|
87
|
+
'angular:untyped-dynamic-component',
|
|
88
|
+
'architecture:advanced-content-placement',
|
|
89
|
+
'architecture:component-complexity',
|
|
90
|
+
'architecture:content-placement',
|
|
91
|
+
'architecture:cross-file-architecture',
|
|
92
|
+
'architecture:error-handling-pattern',
|
|
93
|
+
'architecture:inheritance-analysis',
|
|
94
|
+
'architecture:layer-boundary-violation',
|
|
95
|
+
'architecture:library-extraction-opportunity',
|
|
96
|
+
'architecture:model-separation',
|
|
97
|
+
'architecture:performance-pattern',
|
|
98
|
+
'architecture:rxjs-memory-leak',
|
|
99
|
+
'architecture:service-architecture',
|
|
100
|
+
'architecture:service-bag',
|
|
101
|
+
'architecture:static-in-stateful-class',
|
|
102
|
+
'plugin-angular:bundle-size-optimization',
|
|
103
|
+
'plugin-angular:data-handling-strategy',
|
|
104
|
+
'plugin-angular:rxjs-optimization',
|
|
105
|
+
'refactor:library-extraction',
|
|
106
|
+
'refactor:service-bag-split',
|
|
107
|
+
'solid:circular-dependency',
|
|
108
|
+
'solid:dip-violation-direct-instantiation',
|
|
109
|
+
'solid:god-object-violation',
|
|
110
|
+
'solid:god-switch',
|
|
111
|
+
'solid:god-switch-transform',
|
|
112
|
+
'solid:import-direction-violation',
|
|
113
|
+
'solid:isp-violation',
|
|
114
|
+
'solid:lsp-violation',
|
|
115
|
+
'solid:ocp-violation',
|
|
116
|
+
'solid:service-dip-violation',
|
|
117
|
+
'solid:service-dip-violation-transform',
|
|
118
|
+
'solid:srp-single-responsibility-violation',
|
|
119
|
+
'standalone:migrate-to-standalone',
|
|
120
|
+
];
|
|
121
|
+
/** Tool entry of a registered tool, from its name and description. */
|
|
122
|
+
export function catalogTool(tool) {
|
|
123
|
+
return { name: tool.name, deprecated: /^deprecated\b/i.test(tool.description) };
|
|
124
|
+
}
|
|
125
|
+
const RULE_IDS = new Set(REGISTERED_RULE_IDS);
|
|
126
|
+
/** Rule ids without the plugin prefix (`angular:constructor-to-inject` -> `constructor-to-inject`). */
|
|
127
|
+
const RULE_NAMES = new Set(REGISTERED_RULE_IDS.map((id) => id.slice(id.lastIndexOf(':') + 1)));
|
|
128
|
+
const TYPES = new Set(TRANSFORMATION_TYPES);
|
|
129
|
+
/** Plugin prefixes of the registered rule ids (`solid`, `architecture`, ...). */
|
|
130
|
+
const RULE_PREFIXES = new Set(REGISTERED_RULE_IDS.map((id) => id.slice(0, id.indexOf(':'))));
|
|
131
|
+
/** A single tool name; anything else in `tool` is free text. */
|
|
132
|
+
const TOOL_NAME = /^[a-z][a-z0-9-]*$/;
|
|
133
|
+
/**
|
|
134
|
+
* Why a raw session record is outdated, or `undefined` when it is current or not checked. A transformation record
|
|
135
|
+
* names its rule in `rule.ruleId`: with a `:` it must be a registered rule id, without one a transformation type or
|
|
136
|
+
* a rule name (collect-feedback documents `'constructor-to-inject'`). Analysis records name a tool; only a single
|
|
137
|
+
* tool name is checked (free text like `find-usages/get-call-graph (manual synthesis)` never named a removed tool).
|
|
138
|
+
* Old analysis records stored as transformation records are checked by tool only when their rule id names one; a
|
|
139
|
+
* plugin rule id (`solid:circular-dependency`) is checked as a rule, a free slug (`platform:mcp-registration`) not
|
|
140
|
+
* at all. Tools are checked only with a catalog.
|
|
141
|
+
*/
|
|
142
|
+
export function outdatedReason(record, tools) {
|
|
143
|
+
if (record.kind === 'analysis') {
|
|
144
|
+
return typeof record.tool === 'string' && TOOL_NAME.test(record.tool)
|
|
145
|
+
? toolReason(record.tool, tools)
|
|
146
|
+
: undefined;
|
|
147
|
+
}
|
|
148
|
+
const rule = record.rule;
|
|
149
|
+
if (rule?.ruleType === 'analysis') {
|
|
150
|
+
const legacy = fromLegacyAnalysisRecord(record);
|
|
151
|
+
return legacy === null ? undefined : legacyReason(legacy.tool, rule.ruleId, tools);
|
|
152
|
+
}
|
|
153
|
+
const ruleId = rule?.ruleId;
|
|
154
|
+
if (typeof ruleId !== 'string' || ruleId === '') {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
if (ruleId.includes(':')) {
|
|
158
|
+
return RULE_IDS.has(ruleId)
|
|
159
|
+
? undefined
|
|
160
|
+
: { reason: 'unknown-rule', detail: `rule ${ruleId} is not registered` };
|
|
161
|
+
}
|
|
162
|
+
return TYPES.has(ruleId) || RULE_NAMES.has(ruleId)
|
|
163
|
+
? undefined
|
|
164
|
+
: {
|
|
165
|
+
reason: 'unknown-transformation',
|
|
166
|
+
detail: `${ruleId} is neither a transformation type of transform-code nor a rule name`,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Old analysis records derive their tool from the rule id: a known tool name at its start, or else the whole rule
|
|
171
|
+
* id. Only the first names a tool. A derived name that is the rule id itself and no registered tool is the fallback:
|
|
172
|
+
* then a plugin rule id is checked as a rule, anything else is a free slug and not checked.
|
|
173
|
+
*/
|
|
174
|
+
function legacyReason(tool, ruleId, tools) {
|
|
175
|
+
const id = typeof ruleId === 'string' ? ruleId : '';
|
|
176
|
+
const fallback = tool === id.replace(/^analysis:/, '') && !tools?.some((t) => t.name === tool);
|
|
177
|
+
if (!fallback) {
|
|
178
|
+
return toolReason(tool, tools);
|
|
179
|
+
}
|
|
180
|
+
const prefix = id.includes(':') ? id.slice(0, id.indexOf(':')) : '';
|
|
181
|
+
if (!RULE_PREFIXES.has(prefix) || RULE_IDS.has(id)) {
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
return { reason: 'unknown-rule', detail: `rule ${id} is not registered` };
|
|
185
|
+
}
|
|
186
|
+
function toolReason(name, tools) {
|
|
187
|
+
if (tools === undefined) {
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
const tool = tools.find((t) => t.name === name);
|
|
191
|
+
if (tool === undefined) {
|
|
192
|
+
return { reason: 'unknown-tool', detail: `tool ${name} is not registered` };
|
|
193
|
+
}
|
|
194
|
+
return tool.deprecated ? { reason: 'deprecated-tool', detail: `tool ${name} is deprecated` } : undefined;
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=feedback-catalog.js.map
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { type CatalogTool, type OutdatedReason } from './feedback-catalog.js';
|
|
2
|
+
/** Format of the sidecar file. */
|
|
3
|
+
export declare const SIDECAR_FORMAT = "ngm-feedback-consolidated-v1";
|
|
4
|
+
/** Feedback folder in the project root. */
|
|
5
|
+
export declare const FEEDBACK_ROOT_DIR = ".claude-feedback";
|
|
6
|
+
/** Sidecar folder below the feedback folder. */
|
|
7
|
+
export declare const FEEDBACK_INDEX_DIR = "index";
|
|
8
|
+
/** Sidecar file name. */
|
|
9
|
+
export declare const SIDECAR_FILE = "consolidated.json";
|
|
10
|
+
/** The sidecar before the last apply. */
|
|
11
|
+
export declare const PREVIOUS_SIDECAR_FILE = "consolidated.prev.json";
|
|
12
|
+
/** Why a record is marked. */
|
|
13
|
+
export type FeedbackMarkReason = 'duplicate' | OutdatedReason;
|
|
14
|
+
/** Mark of one record. */
|
|
15
|
+
export interface FeedbackMark {
|
|
16
|
+
/** Why it is marked. */
|
|
17
|
+
reason: FeedbackMarkReason;
|
|
18
|
+
/** What was found. */
|
|
19
|
+
detail?: string;
|
|
20
|
+
}
|
|
21
|
+
/** Marks of one session file. */
|
|
22
|
+
export interface SidecarSession {
|
|
23
|
+
/** SHA-256 of the session file when it was marked. */
|
|
24
|
+
sha256: string;
|
|
25
|
+
/** Marks by record key (`t:<transformationId>`, `f:<feedbackId>`). */
|
|
26
|
+
marks: Record<string, FeedbackMark>;
|
|
27
|
+
}
|
|
28
|
+
/** Content of `consolidated.json`. */
|
|
29
|
+
export interface FeedbackSidecar {
|
|
30
|
+
/** Always {@link SIDECAR_FORMAT}. */
|
|
31
|
+
format: typeof SIDECAR_FORMAT;
|
|
32
|
+
/** When it was written (ISO). */
|
|
33
|
+
writtenAt: string;
|
|
34
|
+
/** Plan of the refresh-state report the marks were confirmed with. */
|
|
35
|
+
planId: string;
|
|
36
|
+
/** adapter-mcp version that wrote it. */
|
|
37
|
+
version: string;
|
|
38
|
+
/** Marks per session file name. */
|
|
39
|
+
sessions: Record<string, SidecarSession>;
|
|
40
|
+
}
|
|
41
|
+
/** One session file and what it holds. */
|
|
42
|
+
export interface SessionScan {
|
|
43
|
+
/** File name in the sessions folder. */
|
|
44
|
+
file: string;
|
|
45
|
+
/** SHA-256 of the file. */
|
|
46
|
+
sha256: string;
|
|
47
|
+
/** Bytes. */
|
|
48
|
+
size: number;
|
|
49
|
+
/** mtime. */
|
|
50
|
+
mtimeMs: number;
|
|
51
|
+
/** Records with a key. */
|
|
52
|
+
records: number;
|
|
53
|
+
/** Marks this file's records get now. */
|
|
54
|
+
marks: Record<string, FeedbackMark>;
|
|
55
|
+
/** Records that repeat an earlier one. */
|
|
56
|
+
duplicates: number;
|
|
57
|
+
/** Outdated records. */
|
|
58
|
+
outdated: number;
|
|
59
|
+
}
|
|
60
|
+
/** Key of a raw session record: `t:<transformationId>`, `f:<feedbackId>`, or `undefined` (header). */
|
|
61
|
+
export declare function recordKey(record: {
|
|
62
|
+
transformationId?: unknown;
|
|
63
|
+
feedbackId?: unknown;
|
|
64
|
+
}): string | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Reads every `.jsonl` file of a sessions folder in name order and marks each record that repeats a key of an
|
|
67
|
+
* earlier one (file order, then line order: the first stays) and each outdated record. Symbolic links are skipped.
|
|
68
|
+
* `tools` undefined leaves the tools unchecked.
|
|
69
|
+
*/
|
|
70
|
+
export declare function scanFeedbackSessions(sessionsDir: string, tools: readonly CatalogTool[] | undefined): SessionScan[];
|
|
71
|
+
/** Result of reading the sidecar. */
|
|
72
|
+
export interface SidecarRead {
|
|
73
|
+
/** The sidecar, `undefined` when there is none or it is unusable. */
|
|
74
|
+
sidecar?: FeedbackSidecar;
|
|
75
|
+
/** Why it is unusable. */
|
|
76
|
+
problem?: string;
|
|
77
|
+
}
|
|
78
|
+
/** Reads `consolidated.json` of a project; never throws. */
|
|
79
|
+
export declare function readSidecar(projectRoot: string): SidecarRead;
|
|
80
|
+
/** Whether the marks of a sidecar entry equal `marks` (key order ignored). */
|
|
81
|
+
export declare function sameMarks(a: Record<string, FeedbackMark>, b: Record<string, FeedbackMark>): boolean;
|
|
82
|
+
/** Outcome of {@link writeFeedbackMarks}. */
|
|
83
|
+
export type MarkWriteResult = {
|
|
84
|
+
/** Records marked per session file that was written. */
|
|
85
|
+
marked: {
|
|
86
|
+
file: string;
|
|
87
|
+
records: number;
|
|
88
|
+
}[];
|
|
89
|
+
/** Planned files whose content changed since the report. */
|
|
90
|
+
changed: string[];
|
|
91
|
+
/** Planned files that are gone. */
|
|
92
|
+
missing: string[];
|
|
93
|
+
} | {
|
|
94
|
+
error: string;
|
|
95
|
+
outsideFolder: boolean;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Writes the marks of the session files in `planned` (file name -> SHA-256 at report time) into the sidecar. A file
|
|
99
|
+
* is marked only while it still has that hash; entries of other files stay while their file is unchanged and are
|
|
100
|
+
* dropped otherwise. The previous sidecar is kept as {@link PREVIOUS_SIDECAR_FILE}; the new one replaces it through
|
|
101
|
+
* a rename. Session files are only read.
|
|
102
|
+
*/
|
|
103
|
+
export declare function writeFeedbackMarks(projectRoot: string, sessionsDir: string, planned: ReadonlyMap<string, string>, tools: readonly CatalogTool[] | undefined, planId: string, now: number): MarkWriteResult;
|
|
104
|
+
/** Marks the readers apply, from the sidecar of the project. */
|
|
105
|
+
export interface MarkView {
|
|
106
|
+
/** Outdated record keys with their reason. */
|
|
107
|
+
outdated: ReadonlyMap<string, FeedbackMarkReason>;
|
|
108
|
+
/** Keys with a duplicate mark: the first record of such a key stays, every later one is skipped. */
|
|
109
|
+
duplicateKeys: ReadonlySet<string>;
|
|
110
|
+
/** Unusable sidecar, or session files changed since they were marked. */
|
|
111
|
+
warnings: string[];
|
|
112
|
+
}
|
|
113
|
+
/** Reads the marks of the project's sidecar for the readers; an unusable sidecar marks nothing. */
|
|
114
|
+
export declare function loadMarkView(projectRoot: string): MarkView;
|
|
115
|
+
/** Records the readers skipped. */
|
|
116
|
+
export interface SkippedRecords {
|
|
117
|
+
/** Skipped records. */
|
|
118
|
+
total: number;
|
|
119
|
+
/** Skipped records per reason. */
|
|
120
|
+
byReason: Record<string, number>;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Decides per record whether a reader skips it. Feed the records session by session in the order of
|
|
124
|
+
* {@link sessionFileOrder} and in file order within a session, so the first record of a duplicate key is the one the
|
|
125
|
+
* sidecar keeps.
|
|
126
|
+
*/
|
|
127
|
+
export declare class MarkFilter {
|
|
128
|
+
private readonly view;
|
|
129
|
+
private readonly includeOutdated;
|
|
130
|
+
private readonly seen;
|
|
131
|
+
/** What was skipped so far. */
|
|
132
|
+
readonly skipped: SkippedRecords;
|
|
133
|
+
/**
|
|
134
|
+
* @param view marks of the sidecar
|
|
135
|
+
* @param includeOutdated true skips nothing (the view before the sidecar)
|
|
136
|
+
*/
|
|
137
|
+
constructor(view: MarkView, includeOutdated: boolean);
|
|
138
|
+
/** Whether to keep the record with this key; counts it when not. */
|
|
139
|
+
keep(key: string | undefined): boolean;
|
|
140
|
+
}
|
|
141
|
+
/** Session ids in the order the sidecar reads their files (by file name). */
|
|
142
|
+
export declare function sessionFileOrder(sessionIds: readonly string[]): string[];
|
|
143
|
+
/** Sessions after the sidecar marks, for the readers. */
|
|
144
|
+
export interface MarkedSessions<S> {
|
|
145
|
+
/** Sessions in file name order, without the skipped records. */
|
|
146
|
+
sessions: S[];
|
|
147
|
+
/** The same sessions by session id. */
|
|
148
|
+
byId: Map<string, S>;
|
|
149
|
+
/** What was skipped. */
|
|
150
|
+
skipped: SkippedRecords;
|
|
151
|
+
/** Unusable sidecar, or session files changed since they were marked. */
|
|
152
|
+
warnings: string[];
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Drops the records the project's sidecar marks from loaded sessions (nothing with `includeOutdated`). Keys come
|
|
156
|
+
* from the stored ids (`transformationId`, `feedbackId`), so old analysis records stored as transformation records
|
|
157
|
+
* keep their `t:` key.
|
|
158
|
+
*/
|
|
159
|
+
export declare function skipMarkedRecords<S extends {
|
|
160
|
+
transformations: {
|
|
161
|
+
transformationId: string;
|
|
162
|
+
}[];
|
|
163
|
+
analyses?: {
|
|
164
|
+
feedbackId: string;
|
|
165
|
+
}[];
|
|
166
|
+
}>(projectRoot: string, sessions: ReadonlyMap<string, S>, includeOutdated: boolean): MarkedSessions<S>;
|
|
167
|
+
/** Input property `includeOutdated` of the readers. */
|
|
168
|
+
export declare const INCLUDE_OUTDATED_SCHEMA: {
|
|
169
|
+
readonly includeOutdated: {
|
|
170
|
+
readonly type: "boolean";
|
|
171
|
+
readonly default: false;
|
|
172
|
+
readonly description: "Also read the records that .claude-feedback/index/consolidated.json marks as duplicate or outdated (written by refresh-state apply, part 'feedback'); default false skips them and counts them in skippedRecords";
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
/** Output properties `skippedRecords` and `sidecarWarnings` of the readers. */
|
|
176
|
+
export declare const SKIPPED_RECORDS_OUTPUT_SCHEMA: {
|
|
177
|
+
readonly skippedRecords: {
|
|
178
|
+
readonly type: "object";
|
|
179
|
+
readonly properties: {
|
|
180
|
+
readonly total: {
|
|
181
|
+
readonly type: "integer";
|
|
182
|
+
};
|
|
183
|
+
readonly byReason: {
|
|
184
|
+
readonly type: "object";
|
|
185
|
+
readonly additionalProperties: {
|
|
186
|
+
readonly type: "integer";
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
readonly required: readonly ["total", "byReason"];
|
|
191
|
+
};
|
|
192
|
+
readonly sidecarWarnings: {
|
|
193
|
+
readonly type: "array";
|
|
194
|
+
readonly items: {
|
|
195
|
+
readonly type: "string";
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
/** Summary lines about skipped records and sidecar warnings (none when nothing to say). */
|
|
200
|
+
export declare function describeSkipped(skipped: SkippedRecords, warnings: readonly string[]): string[];
|
|
201
|
+
//# sourceMappingURL=feedback-sidecar.d.ts.map
|