sela-core 0.1.0-alpha.1
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 -0
- package/bin/sela.js +3 -0
- package/dist/cli/ErrorHandler.d.ts +10 -0
- package/dist/cli/ErrorHandler.d.ts.map +1 -0
- package/dist/cli/ErrorHandler.js +70 -0
- package/dist/cli/commands/bulk.d.ts +3 -0
- package/dist/cli/commands/bulk.d.ts.map +1 -0
- package/dist/cli/commands/bulk.js +158 -0
- package/dist/cli/commands/find.d.ts +3 -0
- package/dist/cli/commands/find.d.ts.map +1 -0
- package/dist/cli/commands/find.js +51 -0
- package/dist/cli/commands/init.d.ts +3 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +166 -0
- package/dist/cli/commands/list.d.ts +3 -0
- package/dist/cli/commands/list.d.ts.map +1 -0
- package/dist/cli/commands/list.js +56 -0
- package/dist/cli/commands/merge.d.ts +13 -0
- package/dist/cli/commands/merge.d.ts.map +1 -0
- package/dist/cli/commands/merge.js +119 -0
- package/dist/cli/commands/refactor.d.ts +3 -0
- package/dist/cli/commands/refactor.d.ts.map +1 -0
- package/dist/cli/commands/refactor.js +30 -0
- package/dist/cli/commands/showReport.d.ts +3 -0
- package/dist/cli/commands/showReport.d.ts.map +1 -0
- package/dist/cli/commands/showReport.js +82 -0
- package/dist/cli/commands/status.d.ts +3 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +51 -0
- package/dist/cli/commands/sync.d.ts +3 -0
- package/dist/cli/commands/sync.d.ts.map +1 -0
- package/dist/cli/commands/sync.js +131 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +94 -0
- package/dist/cli/ui/DnaTable.d.ts +3 -0
- package/dist/cli/ui/DnaTable.d.ts.map +1 -0
- package/dist/cli/ui/DnaTable.js +77 -0
- package/dist/cli/ui/LocatorPicker.d.ts +8 -0
- package/dist/cli/ui/LocatorPicker.d.ts.map +1 -0
- package/dist/cli/ui/LocatorPicker.js +33 -0
- package/dist/cli/ui/ProgressReporter.d.ts +11 -0
- package/dist/cli/ui/ProgressReporter.d.ts.map +1 -0
- package/dist/cli/ui/ProgressReporter.js +33 -0
- package/dist/cli/ui/RefactorWizard.d.ts +26 -0
- package/dist/cli/ui/RefactorWizard.d.ts.map +1 -0
- package/dist/cli/ui/RefactorWizard.js +295 -0
- package/dist/config/ConfigLoader.d.ts +16 -0
- package/dist/config/ConfigLoader.d.ts.map +1 -0
- package/dist/config/ConfigLoader.js +185 -0
- package/dist/config/DryRunGuard.d.ts +14 -0
- package/dist/config/DryRunGuard.d.ts.map +1 -0
- package/dist/config/DryRunGuard.js +80 -0
- package/dist/config/PathScopeGuard.d.ts +42 -0
- package/dist/config/PathScopeGuard.d.ts.map +1 -0
- package/dist/config/PathScopeGuard.js +192 -0
- package/dist/config/SelaConfig.d.ts +178 -0
- package/dist/config/SelaConfig.d.ts.map +1 -0
- package/dist/config/SelaConfig.js +141 -0
- package/dist/config/defineConfig.d.ts +3 -0
- package/dist/config/defineConfig.d.ts.map +1 -0
- package/dist/config/defineConfig.js +9 -0
- package/dist/engine/FixwrightEngine.d.ts +24 -0
- package/dist/engine/FixwrightEngine.d.ts.map +1 -0
- package/dist/engine/FixwrightEngine.js +403 -0
- package/dist/engine/HealingRegistry.d.ts +40 -0
- package/dist/engine/HealingRegistry.d.ts.map +1 -0
- package/dist/engine/HealingRegistry.js +99 -0
- package/dist/engine/SelaEngine.d.ts +57 -0
- package/dist/engine/SelaEngine.d.ts.map +1 -0
- package/dist/engine/SelaEngine.js +1146 -0
- package/dist/engine/singleton.d.ts +3 -0
- package/dist/engine/singleton.d.ts.map +1 -0
- package/dist/engine/singleton.js +5 -0
- package/dist/errors/SelaError.d.ts +146 -0
- package/dist/errors/SelaError.d.ts.map +1 -0
- package/dist/errors/SelaError.js +168 -0
- package/dist/fixtures/expectProxy.d.ts +12 -0
- package/dist/fixtures/expectProxy.d.ts.map +1 -0
- package/dist/fixtures/expectProxy.js +246 -0
- package/dist/fixtures/index.d.ts +30 -0
- package/dist/fixtures/index.d.ts.map +1 -0
- package/dist/fixtures/index.js +765 -0
- package/dist/fixtures/moduleExpect.d.ts +2 -0
- package/dist/fixtures/moduleExpect.d.ts.map +1 -0
- package/dist/fixtures/moduleExpect.js +54 -0
- package/dist/fixtures/proxyTag.d.ts +12 -0
- package/dist/fixtures/proxyTag.d.ts.map +1 -0
- package/dist/fixtures/proxyTag.js +45 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/reporter/SelaReporter.d.ts +165 -0
- package/dist/reporter/SelaReporter.d.ts.map +1 -0
- package/dist/reporter/SelaReporter.js +517 -0
- package/dist/services/ASTSourceUpdater.d.ts +143 -0
- package/dist/services/ASTSourceUpdater.d.ts.map +1 -0
- package/dist/services/ASTSourceUpdater.js +3514 -0
- package/dist/services/AnchorResolver.d.ts +157 -0
- package/dist/services/AnchorResolver.d.ts.map +1 -0
- package/dist/services/AnchorResolver.js +289 -0
- package/dist/services/ArgumentTypeAnalyzer.d.ts +26 -0
- package/dist/services/ArgumentTypeAnalyzer.d.ts.map +1 -0
- package/dist/services/ArgumentTypeAnalyzer.js +92 -0
- package/dist/services/BlastRadiusAnalyzer.d.ts +15 -0
- package/dist/services/BlastRadiusAnalyzer.d.ts.map +1 -0
- package/dist/services/BlastRadiusAnalyzer.js +107 -0
- package/dist/services/ChainValidator.d.ts +76 -0
- package/dist/services/ChainValidator.d.ts.map +1 -0
- package/dist/services/ChainValidator.js +570 -0
- package/dist/services/CrossFileHealer.d.ts +6 -0
- package/dist/services/CrossFileHealer.d.ts.map +1 -0
- package/dist/services/CrossFileHealer.js +135 -0
- package/dist/services/DecisionEngine.d.ts +51 -0
- package/dist/services/DecisionEngine.d.ts.map +1 -0
- package/dist/services/DecisionEngine.js +260 -0
- package/dist/services/DefinitionTracer.d.ts +41 -0
- package/dist/services/DefinitionTracer.d.ts.map +1 -0
- package/dist/services/DefinitionTracer.js +366 -0
- package/dist/services/DnaEditorService.d.ts +31 -0
- package/dist/services/DnaEditorService.d.ts.map +1 -0
- package/dist/services/DnaEditorService.js +217 -0
- package/dist/services/DnaIndexService.d.ts +24 -0
- package/dist/services/DnaIndexService.d.ts.map +1 -0
- package/dist/services/DnaIndexService.js +131 -0
- package/dist/services/HealBudget.d.ts +32 -0
- package/dist/services/HealBudget.d.ts.map +1 -0
- package/dist/services/HealBudget.js +85 -0
- package/dist/services/HealReportService.d.ts +161 -0
- package/dist/services/HealReportService.d.ts.map +1 -0
- package/dist/services/HealReportService.js +1039 -0
- package/dist/services/HealingAdvisory.d.ts +30 -0
- package/dist/services/HealingAdvisory.d.ts.map +1 -0
- package/dist/services/HealingAdvisory.js +51 -0
- package/dist/services/HealingCacheService.d.ts +135 -0
- package/dist/services/HealingCacheService.d.ts.map +1 -0
- package/dist/services/HealingCacheService.js +404 -0
- package/dist/services/HealthReportService.d.ts +10 -0
- package/dist/services/HealthReportService.d.ts.map +1 -0
- package/dist/services/HealthReportService.js +84 -0
- package/dist/services/InitializerUpdater.d.ts +16 -0
- package/dist/services/InitializerUpdater.d.ts.map +1 -0
- package/dist/services/InitializerUpdater.js +73 -0
- package/dist/services/IntentAuditor.d.ts +56 -0
- package/dist/services/IntentAuditor.d.ts.map +1 -0
- package/dist/services/IntentAuditor.js +326 -0
- package/dist/services/InteractiveReview.d.ts +15 -0
- package/dist/services/InteractiveReview.d.ts.map +1 -0
- package/dist/services/InteractiveReview.js +128 -0
- package/dist/services/LLMService.d.ts +121 -0
- package/dist/services/LLMService.d.ts.map +1 -0
- package/dist/services/LLMService.js +475 -0
- package/dist/services/MutationApplier.d.ts +69 -0
- package/dist/services/MutationApplier.d.ts.map +1 -0
- package/dist/services/MutationApplier.js +360 -0
- package/dist/services/PRAutomationService.d.ts +50 -0
- package/dist/services/PRAutomationService.d.ts.map +1 -0
- package/dist/services/PRAutomationService.js +760 -0
- package/dist/services/PendingPromptLedger.d.ts +51 -0
- package/dist/services/PendingPromptLedger.d.ts.map +1 -0
- package/dist/services/PendingPromptLedger.js +205 -0
- package/dist/services/ReportGenerator.d.ts +156 -0
- package/dist/services/ReportGenerator.d.ts.map +1 -0
- package/dist/services/ReportGenerator.js +278 -0
- package/dist/services/ReportMergeService.d.ts +95 -0
- package/dist/services/ReportMergeService.d.ts.map +1 -0
- package/dist/services/ReportMergeService.js +0 -0
- package/dist/services/SafetyGuard.d.ts +112 -0
- package/dist/services/SafetyGuard.d.ts.map +1 -0
- package/dist/services/SafetyGuard.js +87 -0
- package/dist/services/Sanitizer.d.ts +28 -0
- package/dist/services/Sanitizer.d.ts.map +1 -0
- package/dist/services/Sanitizer.js +142 -0
- package/dist/services/SanitizingAnthropic.d.ts +19 -0
- package/dist/services/SanitizingAnthropic.d.ts.map +1 -0
- package/dist/services/SanitizingAnthropic.js +84 -0
- package/dist/services/SelectorSanitizer.d.ts +52 -0
- package/dist/services/SelectorSanitizer.d.ts.map +1 -0
- package/dist/services/SelectorSanitizer.js +318 -0
- package/dist/services/SnapshotService.d.ts +11 -0
- package/dist/services/SnapshotService.d.ts.map +1 -0
- package/dist/services/SnapshotService.js +352 -0
- package/dist/services/SourceLinkService.d.ts +26 -0
- package/dist/services/SourceLinkService.d.ts.map +1 -0
- package/dist/services/SourceLinkService.js +165 -0
- package/dist/services/SourceUpdater.d.ts +45 -0
- package/dist/services/SourceUpdater.d.ts.map +1 -0
- package/dist/services/SourceUpdater.js +1091 -0
- package/dist/services/TemplateDiffService.d.ts +25 -0
- package/dist/services/TemplateDiffService.d.ts.map +1 -0
- package/dist/services/TemplateDiffService.js +334 -0
- package/dist/services/TraceBackEngine.d.ts +67 -0
- package/dist/services/TraceBackEngine.d.ts.map +1 -0
- package/dist/services/TraceBackEngine.js +672 -0
- package/dist/services/WorkspaceSnapshotService.d.ts +71 -0
- package/dist/services/WorkspaceSnapshotService.d.ts.map +1 -0
- package/dist/services/WorkspaceSnapshotService.js +200 -0
- package/dist/services/safety/PipelineContext.d.ts +63 -0
- package/dist/services/safety/PipelineContext.d.ts.map +1 -0
- package/dist/services/safety/PipelineContext.js +34 -0
- package/dist/services/safety/roleClassifier.d.ts +4 -0
- package/dist/services/safety/roleClassifier.d.ts.map +1 -0
- package/dist/services/safety/roleClassifier.js +233 -0
- package/dist/services/safety/rules/ConfidenceTierRule.d.ts +3 -0
- package/dist/services/safety/rules/ConfidenceTierRule.d.ts.map +1 -0
- package/dist/services/safety/rules/ConfidenceTierRule.js +32 -0
- package/dist/services/safety/rules/DangerousSinkRule.d.ts +10 -0
- package/dist/services/safety/rules/DangerousSinkRule.d.ts.map +1 -0
- package/dist/services/safety/rules/DangerousSinkRule.js +53 -0
- package/dist/services/safety/rules/FunctionalRoleRule.d.ts +3 -0
- package/dist/services/safety/rules/FunctionalRoleRule.d.ts.map +1 -0
- package/dist/services/safety/rules/FunctionalRoleRule.js +64 -0
- package/dist/services/safety/rules/HardConfidenceRule.d.ts +3 -0
- package/dist/services/safety/rules/HardConfidenceRule.d.ts.map +1 -0
- package/dist/services/safety/rules/HardConfidenceRule.js +22 -0
- package/dist/services/safety/rules/IntentAuditorRule.d.ts +3 -0
- package/dist/services/safety/rules/IntentAuditorRule.d.ts.map +1 -0
- package/dist/services/safety/rules/IntentAuditorRule.js +97 -0
- package/dist/services/safety/rules/SemanticOppositeRule.d.ts +3 -0
- package/dist/services/safety/rules/SemanticOppositeRule.d.ts.map +1 -0
- package/dist/services/safety/rules/SemanticOppositeRule.js +30 -0
- package/dist/services/safety/rules/StructuralOnlyRule.d.ts +3 -0
- package/dist/services/safety/rules/StructuralOnlyRule.d.ts.map +1 -0
- package/dist/services/safety/rules/StructuralOnlyRule.js +38 -0
- package/dist/services/safety/rules/VisibilityRule.d.ts +3 -0
- package/dist/services/safety/rules/VisibilityRule.d.ts.map +1 -0
- package/dist/services/safety/rules/VisibilityRule.js +53 -0
- package/dist/services/safety/rules/ZeroTrustRule.d.ts +3 -0
- package/dist/services/safety/rules/ZeroTrustRule.d.ts.map +1 -0
- package/dist/services/safety/rules/ZeroTrustRule.js +37 -0
- package/dist/services/safety/rules/index.d.ts +3 -0
- package/dist/services/safety/rules/index.d.ts.map +1 -0
- package/dist/services/safety/rules/index.js +34 -0
- package/dist/services/types.d.ts +59 -0
- package/dist/services/types.d.ts.map +1 -0
- package/dist/services/types.js +2 -0
- package/dist/storage/SnapshotManager.d.ts +5 -0
- package/dist/storage/SnapshotManager.d.ts.map +1 -0
- package/dist/storage/SnapshotManager.js +32 -0
- package/dist/types/index.d.ts +95 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/utils/DOMUtils.d.ts +49 -0
- package/dist/utils/DOMUtils.d.ts.map +1 -0
- package/dist/utils/DOMUtils.js +466 -0
- package/dist/utils/FileLock.d.ts +44 -0
- package/dist/utils/FileLock.d.ts.map +1 -0
- package/dist/utils/FileLock.js +189 -0
- package/dist/utils/IsolatedDiff.d.ts +45 -0
- package/dist/utils/IsolatedDiff.d.ts.map +1 -0
- package/dist/utils/IsolatedDiff.js +382 -0
- package/dist/utils/StackUtils.d.ts +11 -0
- package/dist/utils/StackUtils.d.ts.map +1 -0
- package/dist/utils/StackUtils.js +120 -0
- package/dist/utils/SummaryTable.d.ts +17 -0
- package/dist/utils/SummaryTable.d.ts.map +1 -0
- package/dist/utils/SummaryTable.js +37 -0
- package/dist/utils/atomicWrite.d.ts +9 -0
- package/dist/utils/atomicWrite.d.ts.map +1 -0
- package/dist/utils/atomicWrite.js +83 -0
- package/dist/utils/logger.d.ts +59 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +123 -0
- package/dist/vendor/enquirer.d.ts +33 -0
- package/dist/vendor/enquirer.d.ts.map +1 -0
- package/dist/vendor/enquirer.js +11 -0
- package/package.json +71 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/services/InteractiveReview.ts
|
|
3
|
+
//
|
|
4
|
+
// Local DX - Post-run summary printer (MVP write-and-notify).
|
|
5
|
+
//
|
|
6
|
+
// The MVP flow is write-on-disk-then-notify: workers (and the engine)
|
|
7
|
+
// already mutated the source files in-place during execution. The
|
|
8
|
+
// reporter calls printHealReview() at the end purely to display:
|
|
9
|
+
// • a banner with the number of mutated files,
|
|
10
|
+
// • per-file isolated unified diff (clean room - never the working tree),
|
|
11
|
+
// • a vscode://file deeplink to the mutated line,
|
|
12
|
+
// • an optional deeplink to the generated HTML insights report.
|
|
13
|
+
//
|
|
14
|
+
// No prompts. No rollback. No blocking on stdin. SIGINT handling lives
|
|
15
|
+
// in SelaReporter - this module is pure stdout/stderr.
|
|
16
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
19
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
20
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
21
|
+
}
|
|
22
|
+
Object.defineProperty(o, k2, desc);
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
28
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
29
|
+
}) : function(o, v) {
|
|
30
|
+
o["default"] = v;
|
|
31
|
+
});
|
|
32
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
33
|
+
var ownKeys = function(o) {
|
|
34
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
35
|
+
var ar = [];
|
|
36
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
37
|
+
return ar;
|
|
38
|
+
};
|
|
39
|
+
return ownKeys(o);
|
|
40
|
+
};
|
|
41
|
+
return function (mod) {
|
|
42
|
+
if (mod && mod.__esModule) return mod;
|
|
43
|
+
var result = {};
|
|
44
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
45
|
+
__setModuleDefault(result, mod);
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
})();
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.printHealReview = printHealReview;
|
|
54
|
+
const path = __importStar(require("path"));
|
|
55
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
56
|
+
const IsolatedDiff_1 = require("../utils/IsolatedDiff");
|
|
57
|
+
/**
|
|
58
|
+
* Print the post-run review summary. Returns immediately - never blocks
|
|
59
|
+
* on stdin. Safe to call from the reporter's onEnd() in any environment
|
|
60
|
+
* (TTY, piped CI, IDE-integrated runner).
|
|
61
|
+
*/
|
|
62
|
+
function printHealReview(deps) {
|
|
63
|
+
const log = deps.log ?? ((m) => process.stdout.write(m + "\n"));
|
|
64
|
+
const entries = deps.entries ?? [];
|
|
65
|
+
const reportHtmlPath = deps.reportHtmlPath ?? null;
|
|
66
|
+
if (entries.length === 0 && !reportHtmlPath)
|
|
67
|
+
return;
|
|
68
|
+
log("");
|
|
69
|
+
if (entries.length > 0) {
|
|
70
|
+
// Count actual healed selectors (a file can hold several), not files.
|
|
71
|
+
const fileCount = entries.length;
|
|
72
|
+
const fixCount = entries.reduce((n, e) => n + (e.healCount ?? 1), 0);
|
|
73
|
+
log(chalk_1.default.bold.bgCyan.black(` [Sela] Local DX Review - ${fixCount} fix${fixCount === 1 ? "" : "es"} applied across ${fileCount} file${fileCount === 1 ? "" : "s"} `));
|
|
74
|
+
for (const entry of entries) {
|
|
75
|
+
renderEntry(entry, log);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (reportHtmlPath) {
|
|
79
|
+
log("");
|
|
80
|
+
log(chalk_1.default.bold(`[Sela] 📄 Insights report:`));
|
|
81
|
+
log(` ${chalk_1.default.cyan(buildFileLink(reportHtmlPath))}`);
|
|
82
|
+
}
|
|
83
|
+
log("");
|
|
84
|
+
}
|
|
85
|
+
function renderEntry(entry, log) {
|
|
86
|
+
const fileName = path.basename(entry.absolutePath);
|
|
87
|
+
const diff = (0, IsolatedDiff_1.generateUnifiedDiff)(entry.contentBefore, entry.contentAfter, {
|
|
88
|
+
filePath: entry.relativePath,
|
|
89
|
+
});
|
|
90
|
+
log("");
|
|
91
|
+
log(chalk_1.default.bold(`[Sela] 🔧 Healed selector in ${fileName}`));
|
|
92
|
+
log("");
|
|
93
|
+
log(colorizeDiff(diff));
|
|
94
|
+
log("");
|
|
95
|
+
log(`👉 Open in VS Code:`);
|
|
96
|
+
log(` ${chalk_1.default.cyan(buildVsCodeLink(entry.absolutePath, entry.lineNumber))}`);
|
|
97
|
+
}
|
|
98
|
+
function colorizeDiff(diff) {
|
|
99
|
+
if (!diff)
|
|
100
|
+
return chalk_1.default.dim("(no diff)");
|
|
101
|
+
return diff
|
|
102
|
+
.split("\n")
|
|
103
|
+
.map((row) => {
|
|
104
|
+
if (row.startsWith("+++") ||
|
|
105
|
+
row.startsWith("---") ||
|
|
106
|
+
row.startsWith("diff --git")) {
|
|
107
|
+
return chalk_1.default.bold(row);
|
|
108
|
+
}
|
|
109
|
+
if (row.startsWith("@@"))
|
|
110
|
+
return chalk_1.default.cyan(row);
|
|
111
|
+
if (row.startsWith("+"))
|
|
112
|
+
return chalk_1.default.green(row);
|
|
113
|
+
if (row.startsWith("-"))
|
|
114
|
+
return chalk_1.default.red(row);
|
|
115
|
+
return row;
|
|
116
|
+
})
|
|
117
|
+
.join("\n");
|
|
118
|
+
}
|
|
119
|
+
function buildVsCodeLink(absPath, line) {
|
|
120
|
+
const normalised = absPath.split(path.sep).join("/");
|
|
121
|
+
return line && line > 0
|
|
122
|
+
? `vscode://file/${normalised}:${line}`
|
|
123
|
+
: `vscode://file/${normalised}`;
|
|
124
|
+
}
|
|
125
|
+
function buildFileLink(absPath) {
|
|
126
|
+
const normalised = absPath.split(path.sep).join("/");
|
|
127
|
+
return `file://${normalised}`;
|
|
128
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
2
|
+
import { FixRequest } from "../types";
|
|
3
|
+
export interface SelectorSegment {
|
|
4
|
+
type: "frame" | "element";
|
|
5
|
+
selector: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ContentChange {
|
|
8
|
+
oldText: string;
|
|
9
|
+
newText: string;
|
|
10
|
+
}
|
|
11
|
+
export type SmartChainSegment = {
|
|
12
|
+
type: "locator";
|
|
13
|
+
selector: string;
|
|
14
|
+
hasText?: string;
|
|
15
|
+
has?: string;
|
|
16
|
+
hasNot?: string;
|
|
17
|
+
} | {
|
|
18
|
+
type: "frameLocator";
|
|
19
|
+
selector: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: "getByRole";
|
|
22
|
+
role: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
exact?: boolean;
|
|
25
|
+
level?: number;
|
|
26
|
+
checked?: boolean;
|
|
27
|
+
pressed?: boolean;
|
|
28
|
+
expanded?: boolean;
|
|
29
|
+
selected?: boolean;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
} | {
|
|
32
|
+
type: "getByLabel";
|
|
33
|
+
text: string;
|
|
34
|
+
exact?: boolean;
|
|
35
|
+
} | {
|
|
36
|
+
type: "getByText";
|
|
37
|
+
text: string;
|
|
38
|
+
exact?: boolean;
|
|
39
|
+
} | {
|
|
40
|
+
type: "getByPlaceholder";
|
|
41
|
+
text: string;
|
|
42
|
+
exact?: boolean;
|
|
43
|
+
} | {
|
|
44
|
+
type: "getByTestId";
|
|
45
|
+
testId: string;
|
|
46
|
+
} | {
|
|
47
|
+
type: "getByAltText";
|
|
48
|
+
text: string;
|
|
49
|
+
exact?: boolean;
|
|
50
|
+
} | {
|
|
51
|
+
type: "getByTitle";
|
|
52
|
+
text: string;
|
|
53
|
+
exact?: boolean;
|
|
54
|
+
} | {
|
|
55
|
+
type: "filter";
|
|
56
|
+
hasText?: string;
|
|
57
|
+
hasNotText?: string;
|
|
58
|
+
has?: string;
|
|
59
|
+
hasNot?: string;
|
|
60
|
+
} | {
|
|
61
|
+
type: "first";
|
|
62
|
+
} | {
|
|
63
|
+
type: "last";
|
|
64
|
+
} | {
|
|
65
|
+
type: "nth";
|
|
66
|
+
index: number;
|
|
67
|
+
};
|
|
68
|
+
export interface FixResponse {
|
|
69
|
+
status: "FIXED" | "NOT_FOUND";
|
|
70
|
+
/**
|
|
71
|
+
* LEGACY/PROXY: This selector is used for IMMEDIATE RETRY in the proxy.
|
|
72
|
+
* CRITICAL: Must be as specific as the chainSegments to avoid Strict Mode errors.
|
|
73
|
+
*/
|
|
74
|
+
segments: SelectorSegment[];
|
|
75
|
+
/**
|
|
76
|
+
* NEW: Rich semantic chain segments for AST source update.
|
|
77
|
+
*/
|
|
78
|
+
chainSegments?: SmartChainSegment[];
|
|
79
|
+
originalChainHint?: SmartChainSegment[];
|
|
80
|
+
/**
|
|
81
|
+
* Confidence score 0-100. Undefined when the model omitted it or returned a
|
|
82
|
+
* non-finite value - downstream code must treat undefined as "unknown" and
|
|
83
|
+
* render "n/a" rather than synthesising a 0.
|
|
84
|
+
*/
|
|
85
|
+
confidence?: number;
|
|
86
|
+
explanation: string;
|
|
87
|
+
new_selector?: string | null;
|
|
88
|
+
contentChange?: ContentChange;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Constructor options for LLMService.
|
|
92
|
+
*
|
|
93
|
+
* - `anthropic`: pre-built Anthropic client. Tests use this to inject a
|
|
94
|
+
* mock client without touching env vars or network.
|
|
95
|
+
* - `apiKey`: override the env-based ANTHROPIC_API_KEY when constructing
|
|
96
|
+
* the default client.
|
|
97
|
+
* - `model`: override the Sonnet model id (lets tests pin the SDK call).
|
|
98
|
+
*/
|
|
99
|
+
export interface LLMServiceOptions {
|
|
100
|
+
anthropic?: Anthropic;
|
|
101
|
+
apiKey?: string;
|
|
102
|
+
model?: string;
|
|
103
|
+
}
|
|
104
|
+
export declare class LLMService {
|
|
105
|
+
private anthropic;
|
|
106
|
+
private readonly model;
|
|
107
|
+
constructor(opts?: LLMServiceOptions);
|
|
108
|
+
private cleanJson;
|
|
109
|
+
/**
|
|
110
|
+
* Attempts to infer contentChange when the AI did not return the field.
|
|
111
|
+
*
|
|
112
|
+
* Strategies (in order of confidence):
|
|
113
|
+
*
|
|
114
|
+
* 1. previousState.text vs has-text() in new selector
|
|
115
|
+
* 2. has-text() in old selector vs new selector
|
|
116
|
+
* 3. intentDescription text vs new selector
|
|
117
|
+
*/
|
|
118
|
+
private inferContentChange;
|
|
119
|
+
getFix(request: FixRequest): Promise<FixResponse>;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=LLMService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LLMService.d.ts","sourceRoot":"","sources":["../../src/services/LLMService.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAWtC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,iBAAiB,GACzB;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IAEjB,OAAO,CAAC,EAAE,MAAM,CAAC;IAC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