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 @@
|
|
|
1
|
+
{"version":3,"file":"moduleExpect.d.ts","sourceRoot":"","sources":["../../src/fixtures/moduleExpect.ts"],"names":[],"mappings":"AA8CA,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,CAa1C"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Standalone module-level expect for `import { expect } from 'sela'` usage.
|
|
3
|
+
// Creates a per-call healing expect using the shared engine singleton.
|
|
4
|
+
// Falls back to raw Playwright expect for non-Locator values.
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.expect = expect;
|
|
7
|
+
const test_1 = require("@playwright/test");
|
|
8
|
+
const singleton_js_1 = require("../engine/singleton.js");
|
|
9
|
+
const expectProxy_js_1 = require("./expectProxy.js");
|
|
10
|
+
const index_js_1 = require("./index.js");
|
|
11
|
+
function extractPage(value) {
|
|
12
|
+
if (!value || typeof value !== "object")
|
|
13
|
+
return null;
|
|
14
|
+
// Sela locator proxy exposes _selaPage directly
|
|
15
|
+
const proxied = value._selaPage;
|
|
16
|
+
if (proxied)
|
|
17
|
+
return proxied;
|
|
18
|
+
// Playwright public API: Locator.page()
|
|
19
|
+
if (typeof value.page === "function") {
|
|
20
|
+
try {
|
|
21
|
+
return value.page();
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
function getCallerFile() {
|
|
30
|
+
const lines = new Error().stack?.split("\n") ?? [];
|
|
31
|
+
// Match BOTH frame shapes V8 emits:
|
|
32
|
+
// " at fnName (D:\\path\\file.spec.ts:17:20)"
|
|
33
|
+
// " at D:\\path\\file.spec.ts:17:20"
|
|
34
|
+
// The path may include Windows drive letters (colon after C/D/...).
|
|
35
|
+
const FRAME_WITH_PARENS = /\(([^()]+?):\d+:\d+\)\s*$/;
|
|
36
|
+
const FRAME_BARE = /\s+at\s+(.+?):\d+:\d+\s*$/;
|
|
37
|
+
for (let i = 1; i < lines.length; i++) {
|
|
38
|
+
const line = lines[i];
|
|
39
|
+
if (!/\.(spec|test)\.[jt]sx?/.test(line))
|
|
40
|
+
continue;
|
|
41
|
+
const m = line.match(FRAME_WITH_PARENS) ?? line.match(FRAME_BARE);
|
|
42
|
+
if (m && m[1])
|
|
43
|
+
return m[1].trim();
|
|
44
|
+
}
|
|
45
|
+
return "";
|
|
46
|
+
}
|
|
47
|
+
function expect(value) {
|
|
48
|
+
const page = extractPage(value);
|
|
49
|
+
if (page) {
|
|
50
|
+
const filePath = getCallerFile();
|
|
51
|
+
return (0, expectProxy_js_1.createHealingExpect)(singleton_js_1.sharedEngine, page, filePath, 0, index_js_1.resolveSelaProxy)(value);
|
|
52
|
+
}
|
|
53
|
+
return (0, test_1.expect)(value);
|
|
54
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const SELA_PROXY: unique symbol;
|
|
2
|
+
export type SelaProxyKind = "locator" | "framelocator" | "page" | "expect";
|
|
3
|
+
/**
|
|
4
|
+
* Returns the proxy kind if `v` is a Sela proxy, otherwise `null`.
|
|
5
|
+
*
|
|
6
|
+
* Performs no instanceof checks against Playwright internals - relies
|
|
7
|
+
* solely on the `SELA_PROXY` symbol contract. Always safe to call on
|
|
8
|
+
* arbitrary values (null/undefined/primitive → null).
|
|
9
|
+
*/
|
|
10
|
+
export declare function selaProxyKind(v: unknown): SelaProxyKind | null;
|
|
11
|
+
export declare function isSelaProxy(v: unknown, kind?: SelaProxyKind): boolean;
|
|
12
|
+
//# sourceMappingURL=proxyTag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxyTag.d.ts","sourceRoot":"","sources":["../../src/fixtures/proxyTag.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,UAAU,eAA2B,CAAC;AAEnD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,cAAc,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE3E;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI,CAa9D;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,CAIrE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/fixtures/proxyTag.ts
|
|
3
|
+
//
|
|
4
|
+
// Single source of truth for the Sela proxy tag.
|
|
5
|
+
//
|
|
6
|
+
// Every Sela-created Proxy (locator, frame-locator, page, expect) honors a
|
|
7
|
+
// `get` trap on this symbol and returns the kind string. Consumers - the
|
|
8
|
+
// surface-diff test, internal helpers, debuggers - can identify Sela
|
|
9
|
+
// proxies without touching the brittle "_selaSelector" heuristic.
|
|
10
|
+
//
|
|
11
|
+
// We use Symbol.for() (a registered symbol) so the identity survives
|
|
12
|
+
// across module boundaries when multiple bundles end up in the same
|
|
13
|
+
// process (vitest worker pools, side-loaded fixtures, etc.).
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SELA_PROXY = void 0;
|
|
16
|
+
exports.selaProxyKind = selaProxyKind;
|
|
17
|
+
exports.isSelaProxy = isSelaProxy;
|
|
18
|
+
exports.SELA_PROXY = Symbol.for("sela.proxy");
|
|
19
|
+
/**
|
|
20
|
+
* Returns the proxy kind if `v` is a Sela proxy, otherwise `null`.
|
|
21
|
+
*
|
|
22
|
+
* Performs no instanceof checks against Playwright internals - relies
|
|
23
|
+
* solely on the `SELA_PROXY` symbol contract. Always safe to call on
|
|
24
|
+
* arbitrary values (null/undefined/primitive → null).
|
|
25
|
+
*/
|
|
26
|
+
function selaProxyKind(v) {
|
|
27
|
+
if (v === null || v === undefined)
|
|
28
|
+
return null;
|
|
29
|
+
if (typeof v !== "object" && typeof v !== "function")
|
|
30
|
+
return null;
|
|
31
|
+
const tag = v[exports.SELA_PROXY];
|
|
32
|
+
if (tag === "locator" ||
|
|
33
|
+
tag === "framelocator" ||
|
|
34
|
+
tag === "page" ||
|
|
35
|
+
tag === "expect") {
|
|
36
|
+
return tag;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
function isSelaProxy(v, kind) {
|
|
41
|
+
const k = selaProxyKind(v);
|
|
42
|
+
if (k === null)
|
|
43
|
+
return false;
|
|
44
|
+
return kind === undefined ? true : k === kind;
|
|
45
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { defineConfig } from "./config/defineConfig.js";
|
|
2
|
+
export type { SelaConfig, ResolvedConfig } from "./config/SelaConfig.js";
|
|
3
|
+
export type * from "@playwright/test";
|
|
4
|
+
export { chromium, firefox, webkit, devices, selectors, } from "@playwright/test";
|
|
5
|
+
export { test } from "./fixtures/index.js";
|
|
6
|
+
export { expect } from "./fixtures/moduleExpect.js";
|
|
7
|
+
export { SelaReporter } from "./reporter/SelaReporter.js";
|
|
8
|
+
export type { SelaReporterOpts, ReporterEngine, ReporterLogger, } from "./reporter/SelaReporter.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGzE,mBAAmB,kBAAkB,CAAC;AAGtC,OAAO,EACL,QAAQ,EACR,OAAO,EACP,MAAM,EACN,OAAO,EACP,SAAS,GACV,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAI3C,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAKpD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,cAAc,GACf,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// sela-core - AI self-healing Playwright wrapper
|
|
3
|
+
//
|
|
4
|
+
// Drop-in replacement for @playwright/test:
|
|
5
|
+
// import { test, expect } from 'sela-core'
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.SelaReporter = exports.expect = exports.test = exports.selectors = exports.devices = exports.webkit = exports.firefox = exports.chromium = exports.defineConfig = void 0;
|
|
8
|
+
// Config DSL exported FIRST so `sela.config.ts` can `import { defineConfig }`
|
|
9
|
+
// without triggering the heavier fixtures/engine graph during config load.
|
|
10
|
+
var defineConfig_js_1 = require("./config/defineConfig.js");
|
|
11
|
+
Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return defineConfig_js_1.defineConfig; } });
|
|
12
|
+
// Playwright value exports (launchers, devices, etc.)
|
|
13
|
+
var test_1 = require("@playwright/test");
|
|
14
|
+
Object.defineProperty(exports, "chromium", { enumerable: true, get: function () { return test_1.chromium; } });
|
|
15
|
+
Object.defineProperty(exports, "firefox", { enumerable: true, get: function () { return test_1.firefox; } });
|
|
16
|
+
Object.defineProperty(exports, "webkit", { enumerable: true, get: function () { return test_1.webkit; } });
|
|
17
|
+
Object.defineProperty(exports, "devices", { enumerable: true, get: function () { return test_1.devices; } });
|
|
18
|
+
Object.defineProperty(exports, "selectors", { enumerable: true, get: function () { return test_1.selectors; } });
|
|
19
|
+
// Sela's extended test - includes DNA capture, trace collection,
|
|
20
|
+
// locator proxy, and fixture-scoped healing expect
|
|
21
|
+
var index_js_1 = require("./fixtures/index.js");
|
|
22
|
+
Object.defineProperty(exports, "test", { enumerable: true, get: function () { return index_js_1.test; } });
|
|
23
|
+
// Sela's healing expect - works standalone (import { expect } from 'sela-core')
|
|
24
|
+
// Detects page from locator, falls back to raw PW expect for non-locators
|
|
25
|
+
var moduleExpect_js_1 = require("./fixtures/moduleExpect.js");
|
|
26
|
+
Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return moduleExpect_js_1.expect; } });
|
|
27
|
+
// Playwright Reporter - drop into `reporter: [['sela-core/reporter']]`
|
|
28
|
+
// in playwright.config.ts to drive heal-and-report at the reporter layer
|
|
29
|
+
// (safety net for worker crashes + Playwright failure screenshot capture).
|
|
30
|
+
var SelaReporter_js_1 = require("./reporter/SelaReporter.js");
|
|
31
|
+
Object.defineProperty(exports, "SelaReporter", { enumerable: true, get: function () { return SelaReporter_js_1.SelaReporter; } });
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { Reporter, TestCase, TestResult, FullConfig, Suite, FullResult } from "@playwright/test/reporter";
|
|
2
|
+
import { HealReportService } from "../services/HealReportService.js";
|
|
3
|
+
import type { SelaEngine } from "../engine/SelaEngine.js";
|
|
4
|
+
import { type PendingPromptEntry } from "../services/PendingPromptLedger.js";
|
|
5
|
+
import { type PrintReviewDeps } from "../services/InteractiveReview.js";
|
|
6
|
+
export interface ReporterEngine {
|
|
7
|
+
commitUpdates(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export interface ReporterLogger {
|
|
10
|
+
info: (msg: string) => void;
|
|
11
|
+
warn: (msg: string) => void;
|
|
12
|
+
error: (msg: string) => void;
|
|
13
|
+
}
|
|
14
|
+
export interface SelaReporterOpts {
|
|
15
|
+
/**
|
|
16
|
+
* Skip the `ANTHROPIC_API_KEY` presence check. Tests inject this so
|
|
17
|
+
* the reporter does not surface a noisy warning when no real key is
|
|
18
|
+
* required to drive the lifecycle.
|
|
19
|
+
*/
|
|
20
|
+
skipApiKeyCheck?: boolean;
|
|
21
|
+
/** Override the engine. Defaults to `sharedEngine`. */
|
|
22
|
+
engine?: ReporterEngine | SelaEngine;
|
|
23
|
+
/** Override the report buffer. Defaults to `sharedHealReport`. */
|
|
24
|
+
report?: HealReportService;
|
|
25
|
+
/** Override the logger (defaults to `console`). */
|
|
26
|
+
logger?: ReporterLogger;
|
|
27
|
+
/** Override cwd used to locate the pending-prompts ledger. Defaults to process.cwd(). */
|
|
28
|
+
cwd?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Inject the ledger reader - tests stub this so they don't have to
|
|
31
|
+
* touch the real filesystem.
|
|
32
|
+
*/
|
|
33
|
+
readLedger?: (cwd: string) => PendingPromptEntry[];
|
|
34
|
+
/** Inject the ledger cleaner. */
|
|
35
|
+
clearLedger?: (cwd: string) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Inject the review printer. Tests stub this to assert that the
|
|
38
|
+
* reporter wires the ledger entries + HTML report path through unchanged.
|
|
39
|
+
*/
|
|
40
|
+
printReview?: (deps: PrintReviewDeps) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Override the resolution of the HTML report path. Returns `null` when
|
|
43
|
+
* no report exists. Defaults to `<cwd>/sela-report.html` when the file
|
|
44
|
+
* is on disk.
|
|
45
|
+
*/
|
|
46
|
+
resolveReportPath?: (cwd: string) => string | null;
|
|
47
|
+
/**
|
|
48
|
+
* Override the CI detection - true means "behave as CI" (skip the
|
|
49
|
+
* post-run notify). Defaults to checking `process.env.CI`.
|
|
50
|
+
*/
|
|
51
|
+
isCi?: () => boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Fan in per-worker report shards into the final report (SELA-5). Tests
|
|
54
|
+
* stub this; the default discovers `<cwd>/.sela/report-shards/sela-shard-*`
|
|
55
|
+
* and merges them via ReportMergeService, then clears the shard dir.
|
|
56
|
+
*/
|
|
57
|
+
mergeShards?: (cwd: string) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Install process-level SIGINT/SIGTERM handlers in onBegin. Defaults
|
|
60
|
+
* to true. Tests pass `false` so vitest's own signal lifecycle isn't
|
|
61
|
+
* polluted by leftover handlers between cases.
|
|
62
|
+
*/
|
|
63
|
+
installSignalHandlers?: boolean;
|
|
64
|
+
}
|
|
65
|
+
export declare class SelaReporter implements Reporter {
|
|
66
|
+
private readonly engine;
|
|
67
|
+
private readonly report;
|
|
68
|
+
private readonly logger;
|
|
69
|
+
private readonly skipApiKeyCheck;
|
|
70
|
+
private readonly cwd;
|
|
71
|
+
private readonly readLedger;
|
|
72
|
+
private readonly clearLedger;
|
|
73
|
+
private readonly printReview;
|
|
74
|
+
private readonly resolveReportPath;
|
|
75
|
+
private readonly isCi;
|
|
76
|
+
private readonly mergeShards;
|
|
77
|
+
private readonly shouldInstallSignalHandlers;
|
|
78
|
+
private shutdownHandler;
|
|
79
|
+
private shuttingDown;
|
|
80
|
+
/** Total tests in the suite, captured at onBegin for the end-of-run summary. */
|
|
81
|
+
private totalTests;
|
|
82
|
+
/**
|
|
83
|
+
* Screenshots that arrived before a matching FailedEvent existed in
|
|
84
|
+
* the shared report. Re-flushed once at onEnd time so worker-crash
|
|
85
|
+
* scenarios (no fixture teardown ⇒ no engine-side FailedEvent yet)
|
|
86
|
+
* still get their visual context attached.
|
|
87
|
+
*
|
|
88
|
+
* Key shape: `${normalisedSourceFile}::${testTitle}`.
|
|
89
|
+
*/
|
|
90
|
+
private readonly pendingScreenshots;
|
|
91
|
+
/**
|
|
92
|
+
* Mirror of the failures the reporter observed, kept so external
|
|
93
|
+
* consumers (and tests) can audit what the reporter saw without
|
|
94
|
+
* having to subscribe to the entire Playwright Reporter API.
|
|
95
|
+
*/
|
|
96
|
+
private readonly failures;
|
|
97
|
+
constructor(opts?: SelaReporterOpts);
|
|
98
|
+
onBegin(_config?: FullConfig, suite?: Suite): void;
|
|
99
|
+
onTestEnd(test: TestCase, result: TestResult): void;
|
|
100
|
+
onEnd(_result?: FullResult): Promise<void>;
|
|
101
|
+
/** Reporter prints nothing of its own - Playwright stdio stays clean. */
|
|
102
|
+
printsToStdio(): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Tally the run's outcome from the report buffer. MUST be called before
|
|
105
|
+
* commitUpdates() clears the in-memory events. "Errors detected" counts
|
|
106
|
+
* every broken selector Sela engaged (healed + held + failed); "skipped"
|
|
107
|
+
* counts heals declined by a developer fail-fast directive.
|
|
108
|
+
*/
|
|
109
|
+
private collectRunSummary;
|
|
110
|
+
/**
|
|
111
|
+
* Render the summary table — but only when Sela actually did something.
|
|
112
|
+
* A run with zero detected errors prints nothing, keeping the terminal
|
|
113
|
+
* clean for the common all-green case.
|
|
114
|
+
*/
|
|
115
|
+
private renderRunSummary;
|
|
116
|
+
/**
|
|
117
|
+
* Install the SIGINT/SIGTERM listener once per reporter. First signal
|
|
118
|
+
* triggers an orderly drain; second signal hard-exits with code 130
|
|
119
|
+
* (SIGINT) / 143 (SIGTERM) so the user can always escape if the drain
|
|
120
|
+
* itself wedges (e.g. a stuck LLM call).
|
|
121
|
+
*/
|
|
122
|
+
private installShutdownHandler;
|
|
123
|
+
private uninstallShutdownHandler;
|
|
124
|
+
/**
|
|
125
|
+
* Best-effort drain on signal. Mirrors the orderly onEnd path but
|
|
126
|
+
* swallows every error - we never want to throw inside a signal
|
|
127
|
+
* handler because Node prints raw stack traces otherwise.
|
|
128
|
+
*
|
|
129
|
+
* Exposed for tests so they can drive the shutdown without raising
|
|
130
|
+
* a real signal in the vitest process.
|
|
131
|
+
*/
|
|
132
|
+
gracefulShutdown(): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Walk every buffered pending screenshot and try to attach it to a
|
|
135
|
+
* now-existing FailedEvent. Successfully-attached entries are
|
|
136
|
+
* removed; unmatched entries are dropped (the matching FailedEvent
|
|
137
|
+
* never arrived - most likely worker crashed before the engine
|
|
138
|
+
* could record one).
|
|
139
|
+
*
|
|
140
|
+
* Returns the number of FailedEvents touched.
|
|
141
|
+
*/
|
|
142
|
+
flushPendingScreenshots(): number;
|
|
143
|
+
/** Test hook - read-only snapshot of recorded failures. */
|
|
144
|
+
getRecordedFailures(): ReadonlyArray<{
|
|
145
|
+
sourceFile: string;
|
|
146
|
+
sourceLine?: number;
|
|
147
|
+
testTitle: string;
|
|
148
|
+
status: string;
|
|
149
|
+
hasScreenshot: boolean;
|
|
150
|
+
}>;
|
|
151
|
+
/** Test hook - number of screenshots still waiting for a FailedEvent. */
|
|
152
|
+
getPendingScreenshotCount(): number;
|
|
153
|
+
private pendingKey;
|
|
154
|
+
private normalisePath;
|
|
155
|
+
/**
|
|
156
|
+
* Convert the first PNG attachment on a TestResult into a Base64
|
|
157
|
+
* string immediately. Prefers an in-memory `body` when Playwright
|
|
158
|
+
* already inlined the bytes (faster, no IO); falls back to reading
|
|
159
|
+
* the attachment `path` synchronously BEFORE Playwright has a chance
|
|
160
|
+
* to clean up its temp folder.
|
|
161
|
+
*/
|
|
162
|
+
private extractScreenshotBase64;
|
|
163
|
+
}
|
|
164
|
+
export default SelaReporter;
|
|
165
|
+
//# sourceMappingURL=SelaReporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelaReporter.d.ts","sourceRoot":"","sources":["../../src/reporter/SelaReporter.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,UAAU,EACV,KAAK,EACL,UAAU,EACX,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAEL,iBAAiB,EAIlB,MAAM,kCAAkC,CAAC;AAG1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,kCAAkC,CAAC;AAS1C,MAAM,WAAW,cAAc;IAC7B,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,gBAAgB;I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