playwright-intelligence-engine 2.0.0 → 2.0.2
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 +229 -229
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/core/version.d.ts +3 -3
- package/dist/index.js +81 -24
- package/package.json +76 -76
- package/src/authoring/author.ts +81 -81
- package/src/authoring/generation-contract.ts +283 -283
- package/src/authoring/hybrid-author.ts +115 -115
- package/src/authoring/index.ts +7 -7
- package/src/authoring/llm-author.ts +282 -282
- package/src/authoring/naming/name-plan.ts +28 -28
- package/src/authoring/naming/name-planner.ts +339 -339
- package/src/authoring/naming/naming-linter.ts +292 -292
- package/src/cli/index.ts +1238 -1172
- package/src/collectors/git-diff-collector.ts +190 -190
- package/src/core/version.ts +25 -25
- package/src/diagnostics/diagnostic-report.ts +204 -204
- package/src/diagnostics/failure-classifier.ts +701 -701
- package/src/evaluation/repository-runner.ts +197 -197
- package/src/gate/quality.ts +101 -101
- package/src/generator/architecture-generator.ts +582 -582
- package/src/generator/assertion-quality-gate.ts +88 -88
- package/src/generator/candidate-writer.ts +288 -288
- package/src/generator/test-generator.ts +52 -52
- package/src/index.ts +107 -107
- package/src/intelligence/evidence-bundle.ts +300 -300
- package/src/intelligence/generation-agent.ts +561 -561
- package/src/intelligence/generation-verifier.ts +1115 -1115
- package/src/intelligence/locator-disambiguation-engine.ts +331 -331
- package/src/intelligence/project-intelligence.ts +140 -140
- package/src/intelligence/repository-profile.ts +796 -796
- package/src/intelligence/trace-proposal-workflow.ts +318 -318
- package/src/intelligence/workflow-planner.ts +966 -966
- package/src/mcp/server.ts +970 -970
- package/src/perception/app-model.ts +32 -32
- package/src/perception/crawler.ts +263 -263
- package/src/perception/index.ts +3 -3
- package/src/repair/assertion-hasher.ts +386 -386
- package/src/repair/diff-allowlist.ts +612 -612
- package/src/repair/intent-validator.ts +761 -761
- package/src/repair/repair-planner.ts +467 -467
- package/src/repair/statement-patcher.ts +544 -544
- package/src/reproduce/interactive-workflow-runner.ts +828 -828
- package/src/sandbox/execution-runner.ts +408 -408
- package/src/selector/abstention-policy.ts +175 -175
- package/src/selector/candidate-extractor.ts +343 -343
- package/src/selector/repair-candidate-ranker.ts +92 -92
- package/src/selector/selector-scorer.ts +344 -344
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
import { ProjectIntelligenceSnapshot, getDecayedHistoricalSelectorScore } from '../intelligence/project-intelligence.js';
|
|
2
|
-
import { CandidateExtractor } from './candidate-extractor.js';
|
|
3
|
-
import { ResolvedElement } from '../trace/snapshot-resolver.js';
|
|
4
|
-
import { ScoredCandidate } from './abstention-policy.js';
|
|
5
|
-
import { SelectorScorer, SelectorProjectContext } from './selector-scorer.js';
|
|
6
|
-
import { LocatorDisambiguationEngine } from '../intelligence/locator-disambiguation-engine.js';
|
|
7
|
-
|
|
8
|
-
export interface RankedRepairCandidate extends ScoredCandidate {
|
|
9
|
-
locatorExpression: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class RepairCandidateRanker {
|
|
13
|
-
public static rank(
|
|
14
|
-
candidates: ResolvedElement[],
|
|
15
|
-
originalSelector?: string,
|
|
16
|
-
intendedAction?: string,
|
|
17
|
-
intelligence?: ProjectIntelligenceSnapshot,
|
|
18
|
-
rootDom?: ResolvedElement,
|
|
19
|
-
testIntentText?: string,
|
|
20
|
-
): RankedRepairCandidate[] {
|
|
21
|
-
const projectContext: SelectorProjectContext | undefined = intelligence?.profile
|
|
22
|
-
? {
|
|
23
|
-
preferredLocator: intelligence.profile.locatorConventions.preferred,
|
|
24
|
-
locatorUsage: {
|
|
25
|
-
getByRole: intelligence.profile.locatorConventions.getByRole,
|
|
26
|
-
getByTestId: intelligence.profile.locatorConventions.getByTestId,
|
|
27
|
-
getByLabel: intelligence.profile.locatorConventions.getByLabel,
|
|
28
|
-
getByText: intelligence.profile.locatorConventions.getByText,
|
|
29
|
-
locator: intelligence.profile.locatorConventions.locator,
|
|
30
|
-
},
|
|
31
|
-
}
|
|
32
|
-
: undefined;
|
|
33
|
-
|
|
34
|
-
const disambiguation =
|
|
35
|
-
candidates.length > 1
|
|
36
|
-
? LocatorDisambiguationEngine.disambiguate(
|
|
37
|
-
candidates,
|
|
38
|
-
{ originalSelector, intendedAction, rootDom, testIntentText },
|
|
39
|
-
'page'
|
|
40
|
-
)
|
|
41
|
-
: undefined;
|
|
42
|
-
|
|
43
|
-
return candidates
|
|
44
|
-
.flatMap((candidate) => {
|
|
45
|
-
try {
|
|
46
|
-
let locatorExpression = CandidateExtractor.generateLocator(candidate, 'page');
|
|
47
|
-
const isDisambiguatedTarget =
|
|
48
|
-
disambiguation &&
|
|
49
|
-
disambiguation.isUnique &&
|
|
50
|
-
disambiguation.resolvedCandidate === candidate;
|
|
51
|
-
|
|
52
|
-
if (isDisambiguatedTarget && disambiguation.resolvedExpression) {
|
|
53
|
-
locatorExpression = disambiguation.resolvedExpression;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const breakdown = SelectorScorer.score(
|
|
57
|
-
candidate,
|
|
58
|
-
candidates,
|
|
59
|
-
originalSelector,
|
|
60
|
-
getDecayedHistoricalSelectorScore(intelligence, locatorExpression),
|
|
61
|
-
undefined,
|
|
62
|
-
projectContext,
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
if (isDisambiguatedTarget) {
|
|
66
|
-
breakdown.uniqueness = 1.0;
|
|
67
|
-
breakdown.matchCount = 1;
|
|
68
|
-
breakdown.explanation.push(
|
|
69
|
-
`Disambiguation Applied: ${disambiguation.strategy} -> ${disambiguation.explanation}`
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return [
|
|
74
|
-
{
|
|
75
|
-
candidate,
|
|
76
|
-
element: candidate,
|
|
77
|
-
breakdown,
|
|
78
|
-
locatorExpression,
|
|
79
|
-
originalSelector,
|
|
80
|
-
intendedAction,
|
|
81
|
-
parentScopeVerified: isDisambiguatedTarget ? true : undefined,
|
|
82
|
-
disambiguationStrategy: isDisambiguatedTarget ? disambiguation.strategy : undefined,
|
|
83
|
-
disambiguationExplanation: isDisambiguatedTarget ? disambiguation.explanation : undefined,
|
|
84
|
-
},
|
|
85
|
-
];
|
|
86
|
-
} catch {
|
|
87
|
-
return [];
|
|
88
|
-
}
|
|
89
|
-
})
|
|
90
|
-
.sort((left, right) => right.breakdown.score - left.breakdown.score);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
1
|
+
import { ProjectIntelligenceSnapshot, getDecayedHistoricalSelectorScore } from '../intelligence/project-intelligence.js';
|
|
2
|
+
import { CandidateExtractor } from './candidate-extractor.js';
|
|
3
|
+
import { ResolvedElement } from '../trace/snapshot-resolver.js';
|
|
4
|
+
import { ScoredCandidate } from './abstention-policy.js';
|
|
5
|
+
import { SelectorScorer, SelectorProjectContext } from './selector-scorer.js';
|
|
6
|
+
import { LocatorDisambiguationEngine } from '../intelligence/locator-disambiguation-engine.js';
|
|
7
|
+
|
|
8
|
+
export interface RankedRepairCandidate extends ScoredCandidate {
|
|
9
|
+
locatorExpression: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class RepairCandidateRanker {
|
|
13
|
+
public static rank(
|
|
14
|
+
candidates: ResolvedElement[],
|
|
15
|
+
originalSelector?: string,
|
|
16
|
+
intendedAction?: string,
|
|
17
|
+
intelligence?: ProjectIntelligenceSnapshot,
|
|
18
|
+
rootDom?: ResolvedElement,
|
|
19
|
+
testIntentText?: string,
|
|
20
|
+
): RankedRepairCandidate[] {
|
|
21
|
+
const projectContext: SelectorProjectContext | undefined = intelligence?.profile
|
|
22
|
+
? {
|
|
23
|
+
preferredLocator: intelligence.profile.locatorConventions.preferred,
|
|
24
|
+
locatorUsage: {
|
|
25
|
+
getByRole: intelligence.profile.locatorConventions.getByRole,
|
|
26
|
+
getByTestId: intelligence.profile.locatorConventions.getByTestId,
|
|
27
|
+
getByLabel: intelligence.profile.locatorConventions.getByLabel,
|
|
28
|
+
getByText: intelligence.profile.locatorConventions.getByText,
|
|
29
|
+
locator: intelligence.profile.locatorConventions.locator,
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
: undefined;
|
|
33
|
+
|
|
34
|
+
const disambiguation =
|
|
35
|
+
candidates.length > 1
|
|
36
|
+
? LocatorDisambiguationEngine.disambiguate(
|
|
37
|
+
candidates,
|
|
38
|
+
{ originalSelector, intendedAction, rootDom, testIntentText },
|
|
39
|
+
'page'
|
|
40
|
+
)
|
|
41
|
+
: undefined;
|
|
42
|
+
|
|
43
|
+
return candidates
|
|
44
|
+
.flatMap((candidate) => {
|
|
45
|
+
try {
|
|
46
|
+
let locatorExpression = CandidateExtractor.generateLocator(candidate, 'page');
|
|
47
|
+
const isDisambiguatedTarget =
|
|
48
|
+
disambiguation &&
|
|
49
|
+
disambiguation.isUnique &&
|
|
50
|
+
disambiguation.resolvedCandidate === candidate;
|
|
51
|
+
|
|
52
|
+
if (isDisambiguatedTarget && disambiguation.resolvedExpression) {
|
|
53
|
+
locatorExpression = disambiguation.resolvedExpression;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const breakdown = SelectorScorer.score(
|
|
57
|
+
candidate,
|
|
58
|
+
candidates,
|
|
59
|
+
originalSelector,
|
|
60
|
+
getDecayedHistoricalSelectorScore(intelligence, locatorExpression),
|
|
61
|
+
undefined,
|
|
62
|
+
projectContext,
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
if (isDisambiguatedTarget) {
|
|
66
|
+
breakdown.uniqueness = 1.0;
|
|
67
|
+
breakdown.matchCount = 1;
|
|
68
|
+
breakdown.explanation.push(
|
|
69
|
+
`Disambiguation Applied: ${disambiguation.strategy} -> ${disambiguation.explanation}`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return [
|
|
74
|
+
{
|
|
75
|
+
candidate,
|
|
76
|
+
element: candidate,
|
|
77
|
+
breakdown,
|
|
78
|
+
locatorExpression,
|
|
79
|
+
originalSelector,
|
|
80
|
+
intendedAction,
|
|
81
|
+
parentScopeVerified: isDisambiguatedTarget ? true : undefined,
|
|
82
|
+
disambiguationStrategy: isDisambiguatedTarget ? disambiguation.strategy : undefined,
|
|
83
|
+
disambiguationExplanation: isDisambiguatedTarget ? disambiguation.explanation : undefined,
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
} catch {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
.sort((left, right) => right.breakdown.score - left.breakdown.score);
|
|
91
|
+
}
|
|
92
|
+
}
|