@skyramp/mcp 0.4.3-rc.1 → 0.4.3

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 (37) hide show
  1. package/build/recommendation/answers.d.ts +5 -3
  2. package/build/recommendation/answers.js +5 -2
  3. package/build/recommendation/verifierContracts.d.ts +8 -0
  4. package/build/recommendation/verifierContracts.js +13 -0
  5. package/build/recommendation/verifiers/coverage.js +143 -4
  6. package/build/tools/code-refactor/removed-modules.d.ts +33 -0
  7. package/build/tools/code-refactor/removed-modules.js +61 -0
  8. package/build/tools/code-refactor/reuse-outcome.d.ts +27 -1
  9. package/build/tools/code-refactor/reuse-record-store.d.ts +5 -0
  10. package/build/tools/code-refactor/reuse-record-store.js +15 -1
  11. package/build/tools/code-refactor/reuse-state.d.ts +17 -4
  12. package/build/tools/code-refactor/reuse-state.js +67 -9
  13. package/build/tools/code-refactor/utils-verify-gates.js +39 -15
  14. package/build/tools/submitReportTool.js +47 -18
  15. package/build/tools/test-management/registerTestPlanTool.js +1 -1
  16. package/build/types/ReuseOutcome.d.ts +27 -0
  17. package/build/utils/utils-verify/allow.d.ts +1 -1
  18. package/build/utils/utils-verify/allow.js +15 -0
  19. package/build/utils/utils-verify/changed-lines.d.ts +48 -0
  20. package/build/utils/utils-verify/changed-lines.js +106 -0
  21. package/build/utils/utils-verify/head.d.ts +32 -7
  22. package/build/utils/utils-verify/head.js +55 -14
  23. package/build/utils/utils-verify/typecheck.d.ts +25 -4
  24. package/build/utils/utils-verify/typecheck.js +95 -13
  25. package/build/utils/utils-verify/verify.d.ts +24 -5
  26. package/build/utils/utils-verify/verify.js +156 -8
  27. package/build/utils/versions.d.ts +3 -3
  28. package/build/utils/versions.js +1 -1
  29. package/node_modules/playwright/lib/mcp/skyramp/exportTool.js +4 -2
  30. package/node_modules/playwright/lib/mcp/skyramp/snapshotLocators.js +246 -0
  31. package/node_modules/playwright/lib/mcp/skyramp/traceRecordingBackend.js +221 -233
  32. package/node_modules/playwright/lib/mcp/test/skyRampExport.js +21 -0
  33. package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/index.html +1 -1
  34. package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/{index.ZYuEFHsi.js → index.uiPTFncY.js} +1 -1
  35. package/node_modules/playwright/node_modules/playwright-core/package.json +1 -1
  36. package/node_modules/playwright/package.json +1 -1
  37. package/package.json +3 -3
@@ -0,0 +1,246 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var snapshotLocators_exports = {};
20
+ __export(snapshotLocators_exports, {
21
+ exactLeaf: () => exactLeaf,
22
+ isInputLine: () => isInputLine,
23
+ isTestHookCss: () => isTestHookCss,
24
+ isVolatileCss: () => isVolatileCss,
25
+ leaf: () => leaf,
26
+ locatorFromSelector: () => locatorFromSelector,
27
+ renderSelector: () => renderSelector,
28
+ snapshotInputValue: () => snapshotInputValue,
29
+ snapshotLineText: () => snapshotLineText,
30
+ snapshotMatches: () => snapshotMatches,
31
+ unquoteYaml: () => unquoteYaml,
32
+ withNth: () => withNth
33
+ });
34
+ module.exports = __toCommonJS(snapshotLocators_exports);
35
+ var import_dynamicId = require("../../dom-analyzer/dynamicId");
36
+ const INPUT_ROLES = /* @__PURE__ */ new Set(["textbox", "searchbox", "combobox", "spinbutton"]);
37
+ function isInputLine(refLine) {
38
+ const role = refLine.match(/^\s*-\s*(\w+)/)?.[1];
39
+ return !!role && INPUT_ROLES.has(role);
40
+ }
41
+ function snapshotInputValue(snapLines, refIdx) {
42
+ if (refIdx < 0)
43
+ return "";
44
+ const refLine = snapLines[refIdx];
45
+ const inline = refLine.match(/\]:\s*(.+)$/)?.[1]?.trim();
46
+ if (inline)
47
+ return unquoteYaml(inline);
48
+ if (!isInputLine(refLine))
49
+ return "";
50
+ const indentOf = (line) => line.match(/^(\s*)/)?.[1]?.length ?? 0;
51
+ const indent = indentOf(refLine);
52
+ let childIndent;
53
+ for (let i = refIdx + 1; i < snapLines.length; i++) {
54
+ const lineIndent = indentOf(snapLines[i]);
55
+ if (lineIndent <= indent)
56
+ break;
57
+ childIndent ??= lineIndent;
58
+ if (lineIndent !== childIndent)
59
+ continue;
60
+ const child = snapLines[i].match(/^\s*-\s*text:\s*(.+?)\s*$/)?.[1];
61
+ if (child !== void 0)
62
+ return unquoteYaml(child);
63
+ }
64
+ return "";
65
+ }
66
+ function snapshotLineText(line) {
67
+ const quoted = line.match(/^\s*-\s*\w+\s+"([^"]*)"/);
68
+ if (quoted)
69
+ return quoted[1];
70
+ const colon = line.match(/\[ref=\w+\](?:\s*\[[^\]]*\])*\s*:\s*(.+?)\s*$/);
71
+ const value = colon?.[1]?.trim();
72
+ return value ? unquoteYaml(value) : null;
73
+ }
74
+ function unquoteYaml(value) {
75
+ if (/^"(?:[^"\\]|\\.)*"$/.test(value)) {
76
+ try {
77
+ return JSON.parse(value);
78
+ } catch {
79
+ return value;
80
+ }
81
+ }
82
+ return value;
83
+ }
84
+ function snapshotMatches(snapLines, locator) {
85
+ if (locator.next)
86
+ return void 0;
87
+ const text = locator.kind === "text" ? locator.body : locator.kind === "role" ? locator.options?.name : void 0;
88
+ if (typeof text !== "string")
89
+ return void 0;
90
+ const exact = !!locator.options?.exact;
91
+ const same = (v) => v !== null && (exact ? v === text : v.toLowerCase().includes(text.toLowerCase()));
92
+ return snapLines.filter((l) => {
93
+ if (locator.kind === "role") {
94
+ const m = l.match(/^\s*-\s*(\w+)\s+"([^"]*)"/);
95
+ return !!m && m[1] === locator.body && same(m[2]);
96
+ }
97
+ return same(snapshotLineText(l));
98
+ }).length;
99
+ }
100
+ function isVolatileCss(selector) {
101
+ return selector.startsWith("#") && (0, import_dynamicId.isDynamicId)(selector.slice(1));
102
+ }
103
+ function isTestHookCss(selector) {
104
+ return /^(?:[a-z][\w-]*)?\[data-[\w-]+=(?:"[^"]+"|'[^']+')\]$/i.test(selector);
105
+ }
106
+ function renderSelector(locator) {
107
+ const q = (v, exact) => `${JSON.stringify(v)}${exact ? "s" : "i"}`;
108
+ let head;
109
+ switch (locator.kind) {
110
+ case "test-id":
111
+ head = `internal:testid=[${locator.options?.attribute ?? "data-testid"}=${JSON.stringify(locator.body)}s]`;
112
+ break;
113
+ case "role":
114
+ head = `internal:role=${locator.body}${typeof locator.options?.name === "string" ? `[name=${q(locator.options.name, locator.options.exact)}]` : ""}`;
115
+ break;
116
+ case "text":
117
+ head = `internal:text=${q(locator.body, locator.options?.exact)}`;
118
+ break;
119
+ case "label":
120
+ head = `internal:label=${q(locator.body, locator.options?.exact)}`;
121
+ break;
122
+ case "has-text":
123
+ head = `internal:has-text=${q(locator.body, locator.options?.exact)}`;
124
+ break;
125
+ case "placeholder":
126
+ case "alt":
127
+ case "title":
128
+ head = `internal:attr=[${locator.kind}=${q(locator.body, locator.options?.exact)}]`;
129
+ break;
130
+ case "nth":
131
+ head = `nth=${locator.body}`;
132
+ break;
133
+ default:
134
+ head = String(locator.body);
135
+ break;
136
+ }
137
+ return locator.next ? `${head} >> ${renderSelector(locator.next)}` : head;
138
+ }
139
+ function leaf(locator) {
140
+ let tail = locator;
141
+ while (tail.next)
142
+ tail = tail.next;
143
+ return tail;
144
+ }
145
+ const copyChain = (l) => ({ ...l, options: { ...l.options }, ...l.next ? { next: copyChain(l.next) } : {} });
146
+ function exactLeaf(parsed, fullText) {
147
+ const locator = copyChain(parsed.locator);
148
+ const tail = leaf(locator);
149
+ const leafText = tail.kind === "text" ? tail.body : tail.kind === "role" ? tail.options?.name : void 0;
150
+ if (typeof leafText !== "string" || leafText !== fullText)
151
+ return parsed;
152
+ tail.options = { ...tail.options, exact: true };
153
+ return { selector: renderSelector(locator), locator };
154
+ }
155
+ function withNth(parsed, index) {
156
+ const locator = copyChain(parsed.locator);
157
+ leaf(locator).next = { kind: "nth", body: String(index), options: { attrs: [], exact: false } };
158
+ return { selector: renderSelector(locator), locator };
159
+ }
160
+ function selectorParts(selector) {
161
+ const parts = [];
162
+ let quote;
163
+ let depth = 0;
164
+ let start = 0;
165
+ for (let i = 0; i < selector.length; i++) {
166
+ const c = selector[i];
167
+ if (quote) {
168
+ if (c === "\\")
169
+ i++;
170
+ else if (c === quote)
171
+ quote = void 0;
172
+ } else if (c === '"' || c === "'") {
173
+ quote = c;
174
+ } else if (c === "[" || c === "(") {
175
+ depth++;
176
+ } else if (c === "]" || c === ")") {
177
+ depth--;
178
+ } else if (!depth && selector.startsWith(" >> ", i)) {
179
+ parts.push(selector.slice(start, i));
180
+ start = i + 4;
181
+ i += 3;
182
+ }
183
+ }
184
+ parts.push(selector.slice(start));
185
+ return parts;
186
+ }
187
+ const QUOTED = '("(?:[^"\\\\]|\\\\.)*")([is])';
188
+ function decodeQuoted(quoted) {
189
+ try {
190
+ return JSON.parse(quoted.replace(/[\u0000-\u001f]/g, (c) => "\\u" + c.charCodeAt(0).toString(16).padStart(4, "0")));
191
+ } catch {
192
+ return void 0;
193
+ }
194
+ }
195
+ function locatorFromSelector(selector, opts = {}) {
196
+ const links = [];
197
+ for (const part of selectorParts(selector)) {
198
+ let m;
199
+ let value;
200
+ if (m = part.match(/^nth=(-?\d+)$/)) {
201
+ links.push({ kind: "nth", body: m[1], options: { attrs: [], exact: false } });
202
+ } else if (m = part.match(new RegExp(`^internal:role=([a-z]+)(?:\\[name=${QUOTED}\\])?$`))) {
203
+ if (m[2] && (value = decodeQuoted(m[2])) === void 0)
204
+ return null;
205
+ links.push({ kind: "role", body: m[1], options: { attrs: [], exact: m[3] === "s", ...m[2] ? { name: value } : {} } });
206
+ } else if (m = part.match(new RegExp(`^internal:testid=\\[([\\w-]+)=${QUOTED}\\]$`))) {
207
+ if ((value = decodeQuoted(m[2])) === void 0)
208
+ return null;
209
+ links.push({ kind: "test-id", body: value, options: m[1] === "data-testid" ? {} : { attribute: m[1] } });
210
+ } else if (m = part.match(new RegExp(`^internal:(label|text|has-text)=${QUOTED}$`))) {
211
+ if ((value = decodeQuoted(m[2])) === void 0)
212
+ return null;
213
+ links.push({ kind: m[1], body: value, options: { exact: m[3] === "s" } });
214
+ } else if (m = part.match(new RegExp(`^internal:attr=\\[(placeholder|alt|title)=${QUOTED}\\]$`))) {
215
+ if ((value = decodeQuoted(m[2])) === void 0)
216
+ return null;
217
+ links.push({ kind: m[1], body: value, options: { exact: m[3] === "s" } });
218
+ } else if (/^(?:[a-z-]+=|internal:|\/\/|\.\.)/i.test(part) || !part.trim()) {
219
+ return null;
220
+ } else {
221
+ links.push({ kind: "default", body: part, options: {} });
222
+ }
223
+ }
224
+ while (!opts.keepTrailingNth && links.length && links[links.length - 1].kind === "nth")
225
+ links.pop();
226
+ if (!links.length || links[0].kind === "nth")
227
+ return null;
228
+ for (let i = links.length - 1; i > 0; i--)
229
+ links[i - 1].next = links[i];
230
+ return links[0];
231
+ }
232
+ // Annotate the CommonJS export names for ESM import in node:
233
+ 0 && (module.exports = {
234
+ exactLeaf,
235
+ isInputLine,
236
+ isTestHookCss,
237
+ isVolatileCss,
238
+ leaf,
239
+ locatorFromSelector,
240
+ renderSelector,
241
+ snapshotInputValue,
242
+ snapshotLineText,
243
+ snapshotMatches,
244
+ unquoteYaml,
245
+ withNth
246
+ });