@angular-modernizer/adapter-mcp 0.3.0 → 1.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/README.md +103 -218
- package/dist/cli.js +13 -13
- package/dist/index.d.ts +4 -3
- package/dist/index.js +3 -2
- package/dist/mcp-watcher.d.ts +6 -1
- package/dist/mcp-watcher.js +11 -10
- package/dist/server/limited-stdio-transport.d.ts +68 -0
- package/dist/server/limited-stdio-transport.js +115 -0
- package/dist/server/mcp-server.d.ts +12 -14
- package/dist/server/mcp-server.js +41 -75
- package/dist/server/package-version.d.ts +16 -0
- package/dist/server/package-version.js +37 -0
- package/dist/server/sdk-server.d.ts +70 -0
- package/dist/server/sdk-server.js +113 -0
- package/dist/server/tool-registry.d.ts +3 -2
- package/dist/server/tool-registry.js +5 -5
- package/dist/tools/analyze-build-impact.d.ts +220 -1
- package/dist/tools/analyze-build-impact.js +145 -3
- package/dist/tools/analyze-core-to-shared.d.ts +134 -4
- package/dist/tools/analyze-core-to-shared.js +113 -9
- package/dist/tools/analyze-parser-performance.d.ts +200 -7
- package/dist/tools/analyze-parser-performance.js +108 -47
- package/dist/tools/analyze-project.d.ts +267 -5
- package/dist/tools/analyze-project.js +196 -8
- package/dist/tools/check-incremental-compatibility.d.ts +61 -1
- package/dist/tools/check-incremental-compatibility.js +58 -2
- package/dist/tools/collect-feedback.d.ts +199 -10
- package/dist/tools/collect-feedback.js +171 -99
- package/dist/tools/compare-health.d.ts +356 -0
- package/dist/tools/compare-health.js +472 -0
- package/dist/tools/extract-libraries.d.ts +156 -4
- package/dist/tools/extract-libraries.js +115 -10
- package/dist/tools/find-angular-symbol.d.ts +69 -3
- package/dist/tools/find-angular-symbol.js +55 -8
- package/dist/tools/find-component-hosts.d.ts +572 -2
- package/dist/tools/find-component-hosts.js +207 -6
- package/dist/tools/find-usages.d.ts +79 -1
- package/dist/tools/find-usages.js +64 -7
- package/dist/tools/get-bootstrap-execution.d.ts +151 -1
- package/dist/tools/get-bootstrap-execution.js +84 -3
- package/dist/tools/get-call-graph.d.ts +111 -1
- package/dist/tools/get-call-graph.js +72 -10
- package/dist/tools/get-operation-progress-tool.d.ts +114 -2
- package/dist/tools/get-operation-progress-tool.js +114 -7
- package/dist/tools/get-operation-progress.d.ts +1 -1
- package/dist/tools/get-operation-progress.js +5 -5
- package/dist/tools/helpers/analysis-output.d.ts +177 -0
- package/dist/tools/helpers/analysis-output.js +165 -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/finding-window.d.ts +43 -0
- package/dist/tools/helpers/finding-window.js +64 -0
- package/dist/tools/helpers/health-delta.d.ts +86 -0
- package/dist/tools/helpers/health-delta.js +239 -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 +11 -4
- package/dist/tools/helpers/project-cache.js +22 -4
- 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 +9 -4
- package/dist/tools/helpers/rule-runner.js +28 -14
- package/dist/tools/helpers/scan-cache.d.ts +22 -0
- package/dist/tools/helpers/scan-cache.js +34 -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/tool-context.d.ts +60 -0
- package/dist/tools/helpers/tool-context.js +82 -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 +232 -1
- package/dist/tools/inspect-form-group.js +120 -2
- package/dist/tools/inspect-i18n.d.ts +382 -1
- package/dist/tools/inspect-i18n.js +199 -2
- package/dist/tools/inspect-template.d.ts +232 -1
- package/dist/tools/inspect-template.js +160 -2
- package/dist/tools/learn-patterns.d.ts +122 -1
- package/dist/tools/learn-patterns.js +97 -2
- package/dist/tools/list-imports.d.ts +111 -10
- package/dist/tools/list-imports.js +110 -7
- package/dist/tools/orchestrate-migration.d.ts +128 -5
- package/dist/tools/orchestrate-migration.js +135 -13
- package/dist/tools/parse-stack-trace.d.ts +56 -1
- package/dist/tools/parse-stack-trace.js +34 -0
- package/dist/tools/plan-migration.d.ts +330 -1
- package/dist/tools/plan-migration.js +154 -3
- package/dist/tools/resolve-type.d.ts +39 -1
- package/dist/tools/resolve-type.js +31 -2
- package/dist/tools/review-feedback.d.ts +206 -11
- package/dist/tools/review-feedback.js +132 -51
- package/dist/tools/rollback-changes.d.ts +79 -2
- package/dist/tools/rollback-changes.js +66 -14
- package/dist/tools/run-angular-cli.d.ts +45 -2
- package/dist/tools/run-angular-cli.js +67 -7
- package/dist/tools/run-build.d.ts +114 -2
- package/dist/tools/run-build.js +117 -8
- package/dist/tools/run-schematic.d.ts +70 -2
- package/dist/tools/run-schematic.js +104 -10
- package/dist/tools/scan-all.d.ts +19 -11
- package/dist/tools/scan-all.js +139 -131
- package/dist/tools/scan-angular.d.ts +19 -10
- package/dist/tools/scan-angular.js +51 -23
- package/dist/tools/scan-architecture.d.ts +17 -10
- package/dist/tools/scan-architecture.js +93 -31
- package/dist/tools/scan-solid.d.ts +19 -10
- package/dist/tools/scan-solid.js +51 -23
- package/dist/tools/search-codebase.d.ts +82 -1
- package/dist/tools/search-codebase.js +55 -2
- package/dist/tools/server-status.d.ts +279 -5
- package/dist/tools/server-status.js +179 -5
- package/dist/tools/suggest-improvements.d.ts +97 -5
- package/dist/tools/suggest-improvements.js +80 -44
- package/dist/tools/trace-output-flow.d.ts +682 -2
- package/dist/tools/trace-output-flow.js +375 -15
- 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 +335 -12
- package/dist/tools/transform-code.js +649 -608
- package/dist/tools/validate-before-transform.d.ts +116 -2
- package/dist/tools/validate-before-transform.js +55 -2
- package/dist/tools/validate-project-compatibility.d.ts +64 -2
- package/dist/tools/validate-project-compatibility.js +67 -4
- package/dist/tools/validate-transformation.d.ts +220 -2
- package/dist/tools/validate-transformation.js +113 -15
- package/dist/tools/verify-citations.d.ts +181 -0
- package/dist/tools/verify-citations.js +218 -0
- package/dist/types.d.ts +38 -1
- package/dist/utils/format-tool-response.d.ts +22 -59
- package/dist/utils/format-tool-response.js +25 -134
- package/package.json +30 -13
- 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.map +0 -1
- 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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @angular-modernizer/adapter-mcp - Collect Feedback Tool
|
|
3
3
|
*
|
|
4
4
|
* MCP tool for manually collecting transformation feedback for AI learning.
|
|
5
|
-
* Stores feedback in
|
|
5
|
+
* Stores feedback in the user's project (`<projectRoot>/.claude-feedback`).
|
|
6
6
|
*
|
|
7
7
|
* Record kinds:
|
|
8
8
|
* - 'transformation' (default): outcome of a transform-code run
|
|
@@ -15,21 +15,68 @@
|
|
|
15
15
|
* - Privacy audit enforced before storage
|
|
16
16
|
*
|
|
17
17
|
* Storage Strategy:
|
|
18
|
-
* -
|
|
19
|
-
* -
|
|
18
|
+
* - Always the project; a platform store only with ANGULAR_MODERNIZER_PLATFORM_ROOT
|
|
19
|
+
* - 'both' (default): project, plus the platform store when configured
|
|
20
|
+
* - 'project' / 'platform' ('platform' needs the variable)
|
|
20
21
|
* - Graceful partial failure handling
|
|
21
22
|
*/
|
|
22
|
-
import { type MCPTool } from '../types.js';
|
|
23
|
-
import type { AnalysisFeedbackCategory, ErrorType } from '@angular-modernizer/core';
|
|
23
|
+
import { type MCPTool, type ToolAnnotations } from '../types.js';
|
|
24
|
+
import type { AnalysisFeedbackCategory, ErrorType, TransformFeedbackValidationIssue, Learning, ValidationIssue } from '@angular-modernizer/core';
|
|
25
|
+
/**
|
|
26
|
+
* Output from collect-feedback tool
|
|
27
|
+
*/
|
|
28
|
+
interface CollectFeedbackOutput {
|
|
29
|
+
/** Unique feedback identifier (UUID) */
|
|
30
|
+
feedbackId: string;
|
|
31
|
+
/** Session identifier (UUID) */
|
|
32
|
+
sessionId: string;
|
|
33
|
+
/** Whether feedback was stored successfully */
|
|
34
|
+
stored: boolean;
|
|
35
|
+
/** Paths where feedback was stored */
|
|
36
|
+
storageLocations: string[];
|
|
37
|
+
/** Learnings extracted from feedback */
|
|
38
|
+
learnings: Learning[];
|
|
39
|
+
/** Validation result with issues */
|
|
40
|
+
validationResult: {
|
|
41
|
+
/** Whether validation passed */
|
|
42
|
+
valid: boolean;
|
|
43
|
+
/** Completeness score (0-100) */
|
|
44
|
+
score: number;
|
|
45
|
+
/** Validation issues found */
|
|
46
|
+
issues: ValidationIssue[];
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Output from collect-feedback tool for kind 'analysis'
|
|
51
|
+
*/
|
|
52
|
+
interface CollectAnalysisFeedbackOutput {
|
|
53
|
+
kind: 'analysis';
|
|
54
|
+
/** Session identifier (UUID) */
|
|
55
|
+
sessionId: string;
|
|
56
|
+
/** Whether at least one record was stored */
|
|
57
|
+
stored: boolean;
|
|
58
|
+
/** Paths where feedback was stored */
|
|
59
|
+
storageLocations: string[];
|
|
60
|
+
/** Per-record result, in input order */
|
|
61
|
+
records: {
|
|
62
|
+
feedbackId: string;
|
|
63
|
+
tool: string;
|
|
64
|
+
stored: boolean;
|
|
65
|
+
completenessScore: number;
|
|
66
|
+
issues: TransformFeedbackValidationIssue[];
|
|
67
|
+
}[];
|
|
68
|
+
}
|
|
24
69
|
/**
|
|
25
70
|
* Collect transformation feedback for AI learning
|
|
26
71
|
*/
|
|
27
72
|
export declare class CollectFeedbackTool implements MCPTool {
|
|
28
73
|
name: string;
|
|
74
|
+
title: string;
|
|
75
|
+
annotations: ToolAnnotations;
|
|
29
76
|
description: string;
|
|
30
|
-
private platformRoot;
|
|
31
77
|
inputSchema: {
|
|
32
78
|
readonly type: "object";
|
|
79
|
+
readonly additionalProperties: false;
|
|
33
80
|
readonly properties: {
|
|
34
81
|
readonly projectRoot: {
|
|
35
82
|
readonly type: "string";
|
|
@@ -55,7 +102,11 @@ export declare class CollectFeedbackTool implements MCPTool {
|
|
|
55
102
|
readonly description: "Tool that produced the result (e.g. 'find-usages')";
|
|
56
103
|
};
|
|
57
104
|
readonly query: {
|
|
58
|
-
readonly
|
|
105
|
+
readonly anyOf: readonly [{
|
|
106
|
+
readonly type: "object";
|
|
107
|
+
}, {
|
|
108
|
+
readonly type: "string";
|
|
109
|
+
}];
|
|
59
110
|
readonly description: "Query passed to the tool (args object or text)";
|
|
60
111
|
};
|
|
61
112
|
readonly claimed: {
|
|
@@ -98,7 +149,11 @@ export declare class CollectFeedbackTool implements MCPTool {
|
|
|
98
149
|
readonly description: "Tool that produced the result (e.g. 'find-usages')";
|
|
99
150
|
};
|
|
100
151
|
readonly query: {
|
|
101
|
-
readonly
|
|
152
|
+
readonly anyOf: readonly [{
|
|
153
|
+
readonly type: "object";
|
|
154
|
+
}, {
|
|
155
|
+
readonly type: "string";
|
|
156
|
+
}];
|
|
102
157
|
readonly description: "Query passed to the tool (args object or text)";
|
|
103
158
|
};
|
|
104
159
|
readonly claimed: {
|
|
@@ -218,11 +273,145 @@ export declare class CollectFeedbackTool implements MCPTool {
|
|
|
218
273
|
readonly storageLocation: {
|
|
219
274
|
readonly type: "string";
|
|
220
275
|
readonly enum: readonly ["project", "platform", "both"];
|
|
221
|
-
readonly description:
|
|
276
|
+
readonly description: string;
|
|
222
277
|
};
|
|
223
278
|
};
|
|
224
279
|
readonly required: readonly [];
|
|
225
280
|
};
|
|
226
|
-
|
|
281
|
+
outputSchema: {
|
|
282
|
+
type: string;
|
|
283
|
+
properties: {
|
|
284
|
+
kind: {
|
|
285
|
+
type: string;
|
|
286
|
+
enum: string[];
|
|
287
|
+
};
|
|
288
|
+
feedbackId: {
|
|
289
|
+
type: string;
|
|
290
|
+
};
|
|
291
|
+
sessionId: {
|
|
292
|
+
type: string;
|
|
293
|
+
};
|
|
294
|
+
stored: {
|
|
295
|
+
type: string;
|
|
296
|
+
};
|
|
297
|
+
storageLocations: {
|
|
298
|
+
readonly type: "array";
|
|
299
|
+
readonly items: {
|
|
300
|
+
readonly type: "string";
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
learnings: {
|
|
304
|
+
type: string;
|
|
305
|
+
items: {
|
|
306
|
+
type: string;
|
|
307
|
+
properties: {
|
|
308
|
+
pattern: {
|
|
309
|
+
type: string;
|
|
310
|
+
};
|
|
311
|
+
category: {
|
|
312
|
+
type: string;
|
|
313
|
+
};
|
|
314
|
+
confidence: {
|
|
315
|
+
type: string;
|
|
316
|
+
};
|
|
317
|
+
description: {
|
|
318
|
+
type: string;
|
|
319
|
+
};
|
|
320
|
+
applicability: {
|
|
321
|
+
type: string;
|
|
322
|
+
};
|
|
323
|
+
evidence: {
|
|
324
|
+
readonly type: "array";
|
|
325
|
+
readonly items: {
|
|
326
|
+
readonly type: "string";
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
required: string[];
|
|
331
|
+
};
|
|
332
|
+
};
|
|
333
|
+
validationResult: {
|
|
334
|
+
type: string;
|
|
335
|
+
properties: {
|
|
336
|
+
valid: {
|
|
337
|
+
type: string;
|
|
338
|
+
};
|
|
339
|
+
score: {
|
|
340
|
+
type: string;
|
|
341
|
+
};
|
|
342
|
+
issues: {
|
|
343
|
+
type: string;
|
|
344
|
+
items: {
|
|
345
|
+
type: string;
|
|
346
|
+
properties: {
|
|
347
|
+
type: {
|
|
348
|
+
type: string;
|
|
349
|
+
};
|
|
350
|
+
severity: {
|
|
351
|
+
type: string;
|
|
352
|
+
};
|
|
353
|
+
message: {
|
|
354
|
+
type: string;
|
|
355
|
+
};
|
|
356
|
+
field: {
|
|
357
|
+
type: string;
|
|
358
|
+
};
|
|
359
|
+
};
|
|
360
|
+
required: string[];
|
|
361
|
+
};
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
required: string[];
|
|
365
|
+
};
|
|
366
|
+
records: {
|
|
367
|
+
type: string;
|
|
368
|
+
items: {
|
|
369
|
+
type: string;
|
|
370
|
+
properties: {
|
|
371
|
+
feedbackId: {
|
|
372
|
+
type: string;
|
|
373
|
+
};
|
|
374
|
+
tool: {
|
|
375
|
+
type: string;
|
|
376
|
+
};
|
|
377
|
+
stored: {
|
|
378
|
+
type: string;
|
|
379
|
+
};
|
|
380
|
+
completenessScore: {
|
|
381
|
+
type: string;
|
|
382
|
+
};
|
|
383
|
+
issues: {
|
|
384
|
+
type: string;
|
|
385
|
+
items: {
|
|
386
|
+
type: string;
|
|
387
|
+
properties: {
|
|
388
|
+
severity: {
|
|
389
|
+
type: string;
|
|
390
|
+
};
|
|
391
|
+
message: {
|
|
392
|
+
type: string;
|
|
393
|
+
};
|
|
394
|
+
field: {
|
|
395
|
+
type: string;
|
|
396
|
+
};
|
|
397
|
+
};
|
|
398
|
+
required: string[];
|
|
399
|
+
};
|
|
400
|
+
};
|
|
401
|
+
};
|
|
402
|
+
required: string[];
|
|
403
|
+
};
|
|
404
|
+
};
|
|
405
|
+
summary: {
|
|
406
|
+
type: string;
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
required: string[];
|
|
410
|
+
};
|
|
411
|
+
execute(args: Record<string, unknown>): Promise<(CollectFeedbackOutput | CollectAnalysisFeedbackOutput) & {
|
|
412
|
+
summary: string;
|
|
413
|
+
}>;
|
|
414
|
+
private collect;
|
|
227
415
|
}
|
|
416
|
+
export {};
|
|
228
417
|
//# sourceMappingURL=collect-feedback.d.ts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @angular-modernizer/adapter-mcp - Collect Feedback Tool
|
|
3
3
|
*
|
|
4
4
|
* MCP tool for manually collecting transformation feedback for AI learning.
|
|
5
|
-
* Stores feedback in
|
|
5
|
+
* Stores feedback in the user's project (`<projectRoot>/.claude-feedback`).
|
|
6
6
|
*
|
|
7
7
|
* Record kinds:
|
|
8
8
|
* - 'transformation' (default): outcome of a transform-code run
|
|
@@ -15,21 +15,17 @@
|
|
|
15
15
|
* - Privacy audit enforced before storage
|
|
16
16
|
*
|
|
17
17
|
* Storage Strategy:
|
|
18
|
-
* -
|
|
19
|
-
* -
|
|
18
|
+
* - Always the project; a platform store only with ANGULAR_MODERNIZER_PLATFORM_ROOT
|
|
19
|
+
* - 'both' (default): project, plus the platform store when configured
|
|
20
|
+
* - 'project' / 'platform' ('platform' needs the variable)
|
|
20
21
|
* - Graceful partial failure handling
|
|
21
22
|
*/
|
|
22
23
|
import { FeedbackCollector, PrivacyFilter, FeedbackValidator, FeedbackStorage, loadConfig, FEEDBACK_VERSION, FEEDBACK_FORMAT, ValidationType, ValidationSeverity, ANALYSIS_FEEDBACK_CATEGORIES, ERROR_TYPES, inferErrorType, isErrorType, scoreAnalysisCompleteness, validateAnalysisFeedback, } from '@angular-modernizer/core';
|
|
23
24
|
import { randomUUID } from 'node:crypto';
|
|
24
25
|
import * as path from 'node:path';
|
|
25
26
|
import { promises as fs } from 'node:fs';
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
// ESM-compatible __dirname alternative. Named _module* (not __filename/
|
|
29
|
-
// __dirname) so the CJS jest runtime, which already injects those wrapper
|
|
30
|
-
// identifiers, does not collide with these module-scope declarations.
|
|
31
|
-
const _moduleFilename = fileURLToPath(import.meta.url);
|
|
32
|
-
const _moduleDirname = path.dirname(_moduleFilename);
|
|
27
|
+
import { effectiveStorageLocation, locationRoot, resolveFeedbackRoots, storagePlatformRoot, } from './helpers/platform-root-resolver.js';
|
|
28
|
+
import { STRING_ARRAY } from './helpers/investigation-schemas.js';
|
|
33
29
|
// Custom error types for better error handling
|
|
34
30
|
class SessionPersistenceError extends Error {
|
|
35
31
|
sessionId;
|
|
@@ -47,8 +43,6 @@ class ValidationError extends Error {
|
|
|
47
43
|
}
|
|
48
44
|
// Mutex to prevent race conditions during session initialization
|
|
49
45
|
const sessionInitLocks = new Map();
|
|
50
|
-
// Cache for platform root resolution (avoid repeated upward directory search)
|
|
51
|
-
let cachedPlatformRoot = null;
|
|
52
46
|
/**
|
|
53
47
|
* Ensures a feedback session exists, creating it if necessary.
|
|
54
48
|
* Thread-safe via Promise-based locking mechanism.
|
|
@@ -57,9 +51,7 @@ let cachedPlatformRoot = null;
|
|
|
57
51
|
*
|
|
58
52
|
* @param feedbackStorage - Storage instance for session persistence
|
|
59
53
|
*
|
|
60
|
-
* @param
|
|
61
|
-
*
|
|
62
|
-
* @param platformRoot - Absolute path to platform root (tsanalyzer)
|
|
54
|
+
* @param roots - Project root and, when configured, the platform root
|
|
63
55
|
*
|
|
64
56
|
* @param privacyFilter - Privacy filter for anonymization
|
|
65
57
|
*
|
|
@@ -67,20 +59,19 @@ let cachedPlatformRoot = null;
|
|
|
67
59
|
* @throws {ValidationError} If sessionId format is invalid or roots don't exist
|
|
68
60
|
* @throws {SessionPersistenceError} If session creation fails
|
|
69
61
|
*/
|
|
70
|
-
async function ensureSessionExists(sessionId, feedbackStorage,
|
|
62
|
+
async function ensureSessionExists(sessionId, feedbackStorage, roots, privacyFilter, salt) {
|
|
71
63
|
const startTime = Date.now();
|
|
72
64
|
// 1. Validate session ID format (alphanumeric + underscore + hyphen)
|
|
73
65
|
if (!/^[a-zA-Z0-9_-]+$/.test(sessionId)) {
|
|
74
66
|
throw new ValidationError(`Invalid session ID: ${sessionId}. Must contain only alphanumeric characters, underscores, and hyphens.`);
|
|
75
67
|
}
|
|
76
|
-
// 2. Validate platform root exists
|
|
77
|
-
if (
|
|
68
|
+
// 2. Validate a configured platform root exists
|
|
69
|
+
if (roots.platformRoot !== undefined && roots.locations.includes('platform')) {
|
|
78
70
|
try {
|
|
79
|
-
await fs.access(platformRoot);
|
|
80
|
-
cachedPlatformRoot = platformRoot; // Cache successful validation
|
|
71
|
+
await fs.access(roots.platformRoot);
|
|
81
72
|
}
|
|
82
73
|
catch {
|
|
83
|
-
throw new ValidationError(`Invalid platformRoot: ${platformRoot} does not exist or is not accessible.`);
|
|
74
|
+
throw new ValidationError(`Invalid platformRoot: ${roots.platformRoot} (ANGULAR_MODERNIZER_PLATFORM_ROOT) does not exist or is not accessible.`);
|
|
84
75
|
}
|
|
85
76
|
}
|
|
86
77
|
// 3. Check if session already exists
|
|
@@ -105,11 +96,11 @@ async function ensureSessionExists(sessionId, feedbackStorage, projectRoot, plat
|
|
|
105
96
|
if (!stillNotExists) {
|
|
106
97
|
return; // Another concurrent call created it
|
|
107
98
|
}
|
|
108
|
-
// Ensure directories exist (with retries for transient failures)
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
99
|
+
// Ensure directories exist (with retries for transient failures),
|
|
100
|
+
// only where feedback is written
|
|
101
|
+
for (const location of roots.locations) {
|
|
102
|
+
await fs.mkdir(path.join(locationRoot(roots, location), '.claude-feedback', 'sessions'), { recursive: true });
|
|
103
|
+
}
|
|
113
104
|
// Create minimal session for manual feedback
|
|
114
105
|
const minimalSession = {
|
|
115
106
|
format: FEEDBACK_FORMAT,
|
|
@@ -117,7 +108,7 @@ async function ensureSessionExists(sessionId, feedbackStorage, projectRoot, plat
|
|
|
117
108
|
timestamp: new Date().toISOString(),
|
|
118
109
|
projectContext: {
|
|
119
110
|
// Use proper privacy filter with salt
|
|
120
|
-
projectId: privacyFilter.anonymizeProjectId(projectRoot, salt),
|
|
111
|
+
projectId: privacyFilter.anonymizeProjectId(roots.projectRoot, salt),
|
|
121
112
|
angularVersion: 'unknown',
|
|
122
113
|
projectSize: 'medium',
|
|
123
114
|
moduleStructure: 'ngmodule',
|
|
@@ -186,6 +177,37 @@ async function ensureSessionExists(sessionId, feedbackStorage, projectRoot, plat
|
|
|
186
177
|
function getStringValue(value) {
|
|
187
178
|
return typeof value === 'string' && value ? value : undefined;
|
|
188
179
|
}
|
|
180
|
+
/** Issues spelled out in a summary; the rest is in the result. */
|
|
181
|
+
const SUMMARY_ISSUES = 5;
|
|
182
|
+
/** Text summary of a transformation or analysis feedback result. */
|
|
183
|
+
function describeFeedback(output) {
|
|
184
|
+
const where = `session ${output.sessionId}, ${output.storageLocations.length} location(s)`;
|
|
185
|
+
if ('kind' in output) {
|
|
186
|
+
const stored = output.records.filter((r) => r.stored).length;
|
|
187
|
+
const lines = [
|
|
188
|
+
`Analysis feedback: ${stored} of ${output.records.length} record(s) stored (${where}).`,
|
|
189
|
+
];
|
|
190
|
+
for (const record of output.records
|
|
191
|
+
.filter((r) => !r.stored)
|
|
192
|
+
.slice(0, SUMMARY_ISSUES)) {
|
|
193
|
+
const errors = record.issues
|
|
194
|
+
.filter((i) => i.severity === 'error')
|
|
195
|
+
.map((i) => i.message);
|
|
196
|
+
lines.push(`- ${record.tool} not stored${errors.length > 0 ? `: ${errors.join('; ')}` : ''}`);
|
|
197
|
+
}
|
|
198
|
+
return lines.join('\n');
|
|
199
|
+
}
|
|
200
|
+
const v = output.validationResult;
|
|
201
|
+
const lines = [
|
|
202
|
+
`Feedback ${output.feedbackId} ${output.stored ? 'stored' : 'not stored'} (${where}); ` +
|
|
203
|
+
`completeness score ${v.score}, ${v.valid ? 'valid' : 'not valid'}; ` +
|
|
204
|
+
`${output.learnings.length} learning(s), ${v.issues.length} validation issue(s).`,
|
|
205
|
+
];
|
|
206
|
+
lines.push(...v.issues
|
|
207
|
+
.slice(0, SUMMARY_ISSUES)
|
|
208
|
+
.map((i) => `- ${i.severity}: ${i.message}`));
|
|
209
|
+
return lines.join('\n');
|
|
210
|
+
}
|
|
189
211
|
/**
|
|
190
212
|
* JSON schema for a single analysis record
|
|
191
213
|
*/
|
|
@@ -198,7 +220,7 @@ const ANALYSIS_RECORD_SCHEMA = {
|
|
|
198
220
|
description: "Tool that produced the result (e.g. 'find-usages')",
|
|
199
221
|
},
|
|
200
222
|
query: {
|
|
201
|
-
type:
|
|
223
|
+
anyOf: [{ type: 'object' }, { type: 'string' }],
|
|
202
224
|
description: 'Query passed to the tool (args object or text)',
|
|
203
225
|
},
|
|
204
226
|
claimed: {
|
|
@@ -233,16 +255,23 @@ const ANALYSIS_RECORD_SCHEMA = {
|
|
|
233
255
|
*/
|
|
234
256
|
export class CollectFeedbackTool {
|
|
235
257
|
name = 'collect-feedback';
|
|
258
|
+
title = 'Collect Transformation Feedback';
|
|
259
|
+
annotations = {
|
|
260
|
+
readOnlyHint: false,
|
|
261
|
+
destructiveHint: false,
|
|
262
|
+
idempotentHint: false,
|
|
263
|
+
openWorldHint: false,
|
|
264
|
+
};
|
|
236
265
|
description = 'Manually collect transformation feedback for AI learning. ' +
|
|
237
|
-
'Stores feedback in
|
|
266
|
+
'Stores feedback in <projectRoot>/.claude-feedback, plus the platform store when ANGULAR_MODERNIZER_PLATFORM_ROOT is set. ' +
|
|
238
267
|
'Validates feedback, anonymizes file paths, and extracts learnings automatically. ' +
|
|
239
268
|
"Use kind 'analysis' to report a read-only tool result (find-usages, search-codebase, scans) " +
|
|
240
269
|
'that had to be corrected by grep, build output, a script or manual reading; ' +
|
|
241
|
-
"'analysis' accepts one record or an array and needs no execution/duration/build data."
|
|
242
|
-
|
|
243
|
-
platformRoot = null;
|
|
270
|
+
"'analysis' accepts one record or an array and needs no execution/duration/build data. " +
|
|
271
|
+
'summary is a short text with what was stored and the validation issues.';
|
|
244
272
|
inputSchema = {
|
|
245
273
|
type: 'object',
|
|
274
|
+
additionalProperties: false,
|
|
246
275
|
properties: {
|
|
247
276
|
projectRoot: {
|
|
248
277
|
type: 'string',
|
|
@@ -358,14 +387,99 @@ export class CollectFeedbackTool {
|
|
|
358
387
|
storageLocation: {
|
|
359
388
|
type: 'string',
|
|
360
389
|
enum: ['project', 'platform', 'both'],
|
|
361
|
-
description: "
|
|
390
|
+
description: "Where to store feedback (default 'both'). Feedback always goes to <projectRoot>/.claude-feedback; " +
|
|
391
|
+
"'both' adds the platform store only when ANGULAR_MODERNIZER_PLATFORM_ROOT is set, " +
|
|
392
|
+
"'platform' requires that variable.",
|
|
362
393
|
},
|
|
363
394
|
},
|
|
364
395
|
// transformation + execution are required for kind 'transformation'
|
|
365
396
|
// (checked at runtime); kind 'analysis' needs only `analysis`.
|
|
366
397
|
required: [],
|
|
367
398
|
};
|
|
399
|
+
outputSchema = {
|
|
400
|
+
type: 'object',
|
|
401
|
+
properties: {
|
|
402
|
+
kind: { type: 'string', enum: ['analysis'] },
|
|
403
|
+
feedbackId: { type: 'string' },
|
|
404
|
+
sessionId: { type: 'string' },
|
|
405
|
+
stored: { type: 'boolean' },
|
|
406
|
+
storageLocations: STRING_ARRAY,
|
|
407
|
+
learnings: {
|
|
408
|
+
type: 'array',
|
|
409
|
+
items: {
|
|
410
|
+
type: 'object',
|
|
411
|
+
properties: {
|
|
412
|
+
pattern: { type: 'string' },
|
|
413
|
+
category: { type: 'string' },
|
|
414
|
+
confidence: { type: 'number' },
|
|
415
|
+
description: { type: 'string' },
|
|
416
|
+
applicability: { type: 'string' },
|
|
417
|
+
evidence: STRING_ARRAY,
|
|
418
|
+
},
|
|
419
|
+
required: ['pattern', 'category', 'confidence', 'description'],
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
validationResult: {
|
|
423
|
+
type: 'object',
|
|
424
|
+
properties: {
|
|
425
|
+
valid: { type: 'boolean' },
|
|
426
|
+
score: { type: 'number' },
|
|
427
|
+
issues: {
|
|
428
|
+
type: 'array',
|
|
429
|
+
items: {
|
|
430
|
+
type: 'object',
|
|
431
|
+
properties: {
|
|
432
|
+
type: { type: 'string' },
|
|
433
|
+
severity: { type: 'string' },
|
|
434
|
+
message: { type: 'string' },
|
|
435
|
+
field: { type: 'string' },
|
|
436
|
+
},
|
|
437
|
+
required: ['severity', 'message'],
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
required: ['valid', 'score', 'issues'],
|
|
442
|
+
},
|
|
443
|
+
records: {
|
|
444
|
+
type: 'array',
|
|
445
|
+
items: {
|
|
446
|
+
type: 'object',
|
|
447
|
+
properties: {
|
|
448
|
+
feedbackId: { type: 'string' },
|
|
449
|
+
tool: { type: 'string' },
|
|
450
|
+
stored: { type: 'boolean' },
|
|
451
|
+
completenessScore: { type: 'number' },
|
|
452
|
+
issues: {
|
|
453
|
+
type: 'array',
|
|
454
|
+
items: {
|
|
455
|
+
type: 'object',
|
|
456
|
+
properties: {
|
|
457
|
+
severity: { type: 'string' },
|
|
458
|
+
message: { type: 'string' },
|
|
459
|
+
field: { type: 'string' },
|
|
460
|
+
},
|
|
461
|
+
required: ['severity', 'message'],
|
|
462
|
+
},
|
|
463
|
+
},
|
|
464
|
+
},
|
|
465
|
+
required: [
|
|
466
|
+
'feedbackId',
|
|
467
|
+
'tool',
|
|
468
|
+
'stored',
|
|
469
|
+
'completenessScore',
|
|
470
|
+
'issues',
|
|
471
|
+
],
|
|
472
|
+
},
|
|
473
|
+
},
|
|
474
|
+
summary: { type: 'string' },
|
|
475
|
+
},
|
|
476
|
+
required: ['sessionId', 'stored', 'storageLocations', 'summary'],
|
|
477
|
+
};
|
|
368
478
|
async execute(args) {
|
|
479
|
+
const output = await this.collect(args);
|
|
480
|
+
return { ...output, summary: describeFeedback(output) };
|
|
481
|
+
}
|
|
482
|
+
async collect(args) {
|
|
369
483
|
// Determine initial project root for config loading (args > process.cwd)
|
|
370
484
|
const initialProjectRoot = args['projectRoot'] ?? process.cwd();
|
|
371
485
|
// Load config from .angular-modernizer.json and merge with args
|
|
@@ -377,15 +491,13 @@ export class CollectFeedbackTool {
|
|
|
377
491
|
const projectRoot = getStringValue(args['projectRoot']) ??
|
|
378
492
|
getStringValue(fullConfig.projectRoot) ??
|
|
379
493
|
initialProjectRoot;
|
|
380
|
-
//
|
|
381
|
-
|
|
382
|
-
const platformRoot = this.platformRoot;
|
|
383
|
-
const storageLocation = input.storageLocation ?? 'both';
|
|
494
|
+
// The project always; the platform store only when configured
|
|
495
|
+
const roots = resolveFeedbackRoots(projectRoot, input.storageLocation ?? 'both');
|
|
384
496
|
// Initialize FeedbackCollector
|
|
385
497
|
const collectorConfig = {
|
|
386
498
|
projectRoot,
|
|
387
|
-
platformRoot,
|
|
388
|
-
storageLocation,
|
|
499
|
+
platformRoot: storagePlatformRoot(roots),
|
|
500
|
+
storageLocation: effectiveStorageLocation(roots),
|
|
389
501
|
};
|
|
390
502
|
const salt = PrivacyFilter.generateSalt();
|
|
391
503
|
const privacyFilter = new PrivacyFilter({ salt, strictMode: true });
|
|
@@ -394,9 +506,7 @@ export class CollectFeedbackTool {
|
|
|
394
506
|
if (input.kind === 'analysis') {
|
|
395
507
|
return collectAnalysisFeedback(input, {
|
|
396
508
|
sessionId,
|
|
397
|
-
|
|
398
|
-
platformRoot,
|
|
399
|
-
storageLocation,
|
|
509
|
+
roots,
|
|
400
510
|
privacyFilter,
|
|
401
511
|
salt,
|
|
402
512
|
});
|
|
@@ -493,22 +603,12 @@ export class CollectFeedbackTool {
|
|
|
493
603
|
// Store feedback if valid (validation errors don't block storage in manual mode)
|
|
494
604
|
try {
|
|
495
605
|
// Initialize FeedbackStorage
|
|
496
|
-
const feedbackStorage =
|
|
497
|
-
projectRoot,
|
|
498
|
-
platformRoot,
|
|
499
|
-
storageLocation,
|
|
500
|
-
});
|
|
606
|
+
const feedbackStorage = createFeedbackStorage(roots);
|
|
501
607
|
// Ensure session exists (creates minimal session if needed, race-protected)
|
|
502
|
-
await ensureSessionExists(sessionId, feedbackStorage,
|
|
608
|
+
await ensureSessionExists(sessionId, feedbackStorage, roots, privacyFilter, salt);
|
|
503
609
|
// Append transformation feedback to session
|
|
504
610
|
await feedbackStorage.appendTransformation(sessionId, feedback);
|
|
505
|
-
|
|
506
|
-
const locations = getStorageLocations(storageLocation);
|
|
507
|
-
for (const location of locations) {
|
|
508
|
-
const root = location === 'project' ? projectRoot : platformRoot;
|
|
509
|
-
const sessionPath = path.join(root, '.claude-feedback/sessions', `${sessionId}.jsonl`);
|
|
510
|
-
storageLocations.push(sessionPath);
|
|
511
|
-
}
|
|
611
|
+
storageLocations.push(...sessionPaths(roots, sessionId));
|
|
512
612
|
stored = true;
|
|
513
613
|
}
|
|
514
614
|
catch (error) {
|
|
@@ -832,41 +932,20 @@ function determineStatus(succeeded, validation) {
|
|
|
832
932
|
return 'success';
|
|
833
933
|
}
|
|
834
934
|
/**
|
|
835
|
-
*
|
|
836
|
-
*
|
|
837
|
-
* Converts the storage location strategy enum into an array of concrete
|
|
838
|
-
* location identifiers for iteration and file operations.
|
|
839
|
-
*
|
|
840
|
-
* @param storageLocation - The storage strategy ('project', 'platform', or 'both')
|
|
841
|
-
*
|
|
842
|
-
* @returns An array of location identifiers:
|
|
843
|
-
* - ['project']: Store only in user's project
|
|
844
|
-
* - ['platform']: Store only in platform root
|
|
845
|
-
* - ['project', 'platform']: Store in both locations (default for 'both')
|
|
846
|
-
*
|
|
847
|
-
* @remarks
|
|
848
|
-
* - Default case returns both locations for safety
|
|
849
|
-
* - Returned array determines which directories receive feedback storage
|
|
850
|
-
* - Used internally by ensureSessionExists() and execute() for dual-storage
|
|
851
|
-
*
|
|
852
|
-
* @example
|
|
853
|
-
* getStorageLocations('both')
|
|
854
|
-
* // Returns: ['project', 'platform']
|
|
855
|
-
*
|
|
856
|
-
* getStorageLocations('project')
|
|
857
|
-
* // Returns: ['project']
|
|
935
|
+
* Core `FeedbackStorage` for the resolved roots.
|
|
858
936
|
*/
|
|
859
|
-
function
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
937
|
+
function createFeedbackStorage(roots) {
|
|
938
|
+
return new FeedbackStorage({
|
|
939
|
+
projectRoot: roots.projectRoot,
|
|
940
|
+
platformRoot: storagePlatformRoot(roots),
|
|
941
|
+
storageLocation: effectiveStorageLocation(roots),
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Session file paths that were written, one per used location.
|
|
946
|
+
*/
|
|
947
|
+
function sessionPaths(roots, sessionId) {
|
|
948
|
+
return roots.locations.map((location) => path.join(locationRoot(roots, location), '.claude-feedback/sessions', `${sessionId}.jsonl`));
|
|
870
949
|
}
|
|
871
950
|
/**
|
|
872
951
|
* Ensure the transformation payload is present for kind 'transformation'.
|
|
@@ -967,17 +1046,10 @@ async function collectAnalysisFeedback(input, context) {
|
|
|
967
1046
|
let stored = false;
|
|
968
1047
|
if (toStore.length > 0) {
|
|
969
1048
|
try {
|
|
970
|
-
const feedbackStorage =
|
|
971
|
-
|
|
972
|
-
platformRoot: context.platformRoot,
|
|
973
|
-
storageLocation: context.storageLocation,
|
|
974
|
-
});
|
|
975
|
-
await ensureSessionExists(context.sessionId, feedbackStorage, context.projectRoot, context.platformRoot, context.privacyFilter, context.salt);
|
|
1049
|
+
const feedbackStorage = createFeedbackStorage(context.roots);
|
|
1050
|
+
await ensureSessionExists(context.sessionId, feedbackStorage, context.roots, context.privacyFilter, context.salt);
|
|
976
1051
|
await feedbackStorage.appendAnalysis(context.sessionId, toStore);
|
|
977
|
-
|
|
978
|
-
const root = location === 'project' ? context.projectRoot : context.platformRoot;
|
|
979
|
-
storageLocations.push(path.join(root, '.claude-feedback/sessions', `${context.sessionId}.jsonl`));
|
|
980
|
-
}
|
|
1052
|
+
storageLocations.push(...sessionPaths(context.roots, context.sessionId));
|
|
981
1053
|
stored = true;
|
|
982
1054
|
}
|
|
983
1055
|
catch (error) {
|