playwright-intelligence-engine 2.0.1 → 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.
Files changed (48) hide show
  1. package/README.md +229 -229
  2. package/dist/cli/index.d.ts.map +1 -1
  3. package/dist/core/version.d.ts +3 -3
  4. package/dist/index.js +81 -24
  5. package/package.json +76 -76
  6. package/src/authoring/author.ts +81 -81
  7. package/src/authoring/generation-contract.ts +283 -283
  8. package/src/authoring/hybrid-author.ts +115 -115
  9. package/src/authoring/index.ts +7 -7
  10. package/src/authoring/llm-author.ts +282 -282
  11. package/src/authoring/naming/name-plan.ts +28 -28
  12. package/src/authoring/naming/name-planner.ts +339 -339
  13. package/src/authoring/naming/naming-linter.ts +292 -292
  14. package/src/cli/index.ts +1238 -1172
  15. package/src/collectors/git-diff-collector.ts +190 -190
  16. package/src/core/version.ts +25 -25
  17. package/src/diagnostics/diagnostic-report.ts +204 -204
  18. package/src/diagnostics/failure-classifier.ts +701 -701
  19. package/src/evaluation/repository-runner.ts +197 -197
  20. package/src/gate/quality.ts +101 -101
  21. package/src/generator/architecture-generator.ts +582 -582
  22. package/src/generator/assertion-quality-gate.ts +88 -88
  23. package/src/generator/candidate-writer.ts +288 -288
  24. package/src/generator/test-generator.ts +52 -52
  25. package/src/index.ts +107 -107
  26. package/src/intelligence/evidence-bundle.ts +300 -300
  27. package/src/intelligence/generation-agent.ts +561 -561
  28. package/src/intelligence/generation-verifier.ts +1115 -1115
  29. package/src/intelligence/locator-disambiguation-engine.ts +331 -331
  30. package/src/intelligence/project-intelligence.ts +140 -140
  31. package/src/intelligence/repository-profile.ts +796 -796
  32. package/src/intelligence/trace-proposal-workflow.ts +318 -318
  33. package/src/intelligence/workflow-planner.ts +966 -966
  34. package/src/mcp/server.ts +970 -970
  35. package/src/perception/app-model.ts +32 -32
  36. package/src/perception/crawler.ts +263 -263
  37. package/src/perception/index.ts +3 -3
  38. package/src/repair/assertion-hasher.ts +386 -386
  39. package/src/repair/diff-allowlist.ts +612 -612
  40. package/src/repair/intent-validator.ts +761 -761
  41. package/src/repair/repair-planner.ts +467 -467
  42. package/src/repair/statement-patcher.ts +544 -544
  43. package/src/reproduce/interactive-workflow-runner.ts +828 -828
  44. package/src/sandbox/execution-runner.ts +408 -408
  45. package/src/selector/abstention-policy.ts +175 -175
  46. package/src/selector/candidate-extractor.ts +343 -343
  47. package/src/selector/repair-candidate-ranker.ts +92 -92
  48. 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
+ }