patchwright 0.0.0-stage → 1.64.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.
Files changed (58) hide show
  1. package/README.md +194 -2
  2. package/ThirdPartyNotices.txt +14 -0
  3. package/cli.js +19 -0
  4. package/index.d.ts +17 -0
  5. package/index.js +17 -0
  6. package/index.mjs +18 -0
  7. package/lib/agents/agentParser.js +89 -0
  8. package/lib/agents/copilot-setup-steps.yml +34 -0
  9. package/lib/agents/generateAgents.js +395 -0
  10. package/lib/agents/playwright-test-coverage.prompt.md +31 -0
  11. package/lib/agents/playwright-test-generate.prompt.md +8 -0
  12. package/lib/agents/playwright-test-generator.agent.md +88 -0
  13. package/lib/agents/playwright-test-heal.prompt.md +6 -0
  14. package/lib/agents/playwright-test-healer.agent.md +56 -0
  15. package/lib/agents/playwright-test-plan.prompt.md +9 -0
  16. package/lib/agents/playwright-test-planner.agent.md +74 -0
  17. package/lib/cli/reportActions.js +78 -0
  18. package/lib/cli/testActions.js +217 -0
  19. package/lib/common/index.js +2937 -0
  20. package/lib/common/index.js.txt +33 -0
  21. package/lib/errorContext.js +129 -0
  22. package/lib/globals.js +58 -0
  23. package/lib/index.js +827 -0
  24. package/lib/isomorphic.js +260 -0
  25. package/lib/isomorphic.js.txt +9 -0
  26. package/lib/loader/loaderProcessEntry.js +34 -0
  27. package/lib/loader/loaderProcessEntry.js.txt +9 -0
  28. package/lib/matchers/expect.js +13496 -0
  29. package/lib/matchers/expect.js.LICENSE +640 -0
  30. package/lib/matchers/expect.js.txt +67 -0
  31. package/lib/mcp/test/browserBackend.js +135 -0
  32. package/lib/mcp/test/generatorTools.js +122 -0
  33. package/lib/mcp/test/plannerTools.js +150 -0
  34. package/lib/mcp/test/seed.js +82 -0
  35. package/lib/mcp/test/streams.js +44 -0
  36. package/lib/mcp/test/testBackend.js +99 -0
  37. package/lib/mcp/test/testContext.js +306 -0
  38. package/lib/mcp/test/testTool.js +30 -0
  39. package/lib/mcp/test/testTools.js +98 -0
  40. package/lib/package.js +47 -0
  41. package/lib/program.js +242 -0
  42. package/lib/runner/index.js +8721 -0
  43. package/lib/runner/index.js.txt +62 -0
  44. package/lib/transform/babelBundle.js +72490 -0
  45. package/lib/transform/babelBundle.js.LICENSE +2384 -0
  46. package/lib/transform/babelBundle.js.txt +328 -0
  47. package/lib/transform/esmLoader.js +8066 -0
  48. package/lib/transform/esmLoader.js.LICENSE +355 -0
  49. package/lib/transform/esmLoader.js.txt +60 -0
  50. package/lib/util.js +373 -0
  51. package/lib/worker/workerProcessEntry.js +1860 -0
  52. package/lib/worker/workerProcessEntry.js.txt +19 -0
  53. package/package.json +48 -4
  54. package/test.d.ts +18 -0
  55. package/test.js +24 -0
  56. package/test.mjs +35 -0
  57. package/types/test.d.ts +11191 -0
  58. package/types/testReporter.d.ts +950 -0
package/README.md CHANGED
@@ -1,3 +1,195 @@
1
- # Temporary Holding Version
1
+ <h1 align="center">
2
+ 🎭 Patchwright
3
+ </h1>
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+
6
+ <p align="center">
7
+ <a href="https://github.com/Kaliiiiiiiiii-Vinyzu/patchright/blob/main/LICENSE">
8
+ <img src="https://img.shields.io/badge/License-Apache%202.0-green">
9
+ </a>
10
+ <a>
11
+ <img src="https://img.shields.io/badge/Based%20on-Playwright-goldenrod">
12
+ </a>
13
+ <a>
14
+ <img src="https://img.shields.io/badge/Driver-Patched-blue">
15
+ </a>
16
+ <a href="https://github.com/Kaliiiiiiiiii-Vinyzu/patchright/releases/latest">
17
+ <img alt="Patchright Version" src="https://img.shields.io/github/v/release/Kaliiiiiiiiii-Vinyzu/patchright?display_name=release&label=Version">
18
+ </a>
19
+ <br/>
20
+ <a href="https://github.com/Kaliiiiiiiiii-Vinyzu/patchright-python">
21
+ <img src="https://img.shields.io/badge/Package-Python-seagreen">
22
+ </a>
23
+ <a href="https://github.com/Kaliiiiiiiiii-Vinyzu/patchright-python/releases">
24
+ <img alt="Python Downloads" src="https://img.shields.io/pepy/dt/patchright?color=red&label=Python%20Downloads">
25
+ </a>
26
+ <a href="https://github.com/Kaliiiiiiiiii-Vinyzu/patchright-nodejs">
27
+ <img src="https://img.shields.io/badge/Package-NodeJS-seagreen">
28
+ </a>
29
+ <a href="https://github.com/Kaliiiiiiiiii-Vinyzu/patchright-nodejs/releases">
30
+ <img alt="NodeJS Downloads" src="https://img.shields.io/npm/d18m/patchright?color=red&label=NodeJS%20Downloads">
31
+ </a>
32
+ <a href="https://github.com/DevEnterpriseSoftware/patchright-dotnet">
33
+ <img src="https://img.shields.io/badge/Package-.Net-seagreen">
34
+ </a>
35
+ <a href="https://github.com/Kaliiiiiiiiii-Vinyzu/patchright-nodejs/releases">
36
+ <img alt=".Net Downloads" src="https://img.shields.io/nuget/dt/Patchright?label=.Net%20Downloads">
37
+ </a>
38
+ <br/>
39
+ <img src="https://img.shields.io/github/actions/workflow/status/Kaliiiiiiiiii-Vinyzu/patchright/patchright_tests.yml?label=Patchright%20Driver%20Tests">
40
+ <img src="https://img.shields.io/github/actions/workflow/status/Kaliiiiiiiiii-Vinyzu/patchright-python/patchright_tests.yml?label=Patchright%20Python%20Tests">
41
+ <img src="https://img.shields.io/github/actions/workflow/status/DevEnterpriseSoftware/patchright-dotnet/patchright_test.yml?label=Patchright%20.Net%20Tests">
42
+ </p>
43
+
44
+ #### Patchright is a patched and undetected version of the Playwright Testing and Automation Framework. </br> It can be used as a drop-in replacement for Playwright.
45
+
46
+ > [!NOTE]
47
+ > This repository serves the Patchright Driver. To use Patchright, check out the [Python Package](https://github.com/Kaliiiiiiiiii-Vinyzu/patchright-python), the [NodeJS Package](https://github.com/Kaliiiiiiiiii-Vinyzu/patchright-nodejs) or the _community-driven_ [.Net Package](https://github.com/DevEnterpriseSoftware/patchright-dotnet/)
48
+
49
+ > [!IMPORTANT]
50
+ > Patchright only patches CHROMIUM based browsers. Firefox and Webkit are not supported.
51
+
52
+ ---
53
+
54
+ ## Patches
55
+
56
+ ### [Runtime.enable](https://vanilla.aslushnikov.com/?Runtime.enable) Leak
57
+ This is the biggest Patch Patchright uses. To avoid detection by this leak, patchright avoids using [Runtime.enable](https://vanilla.aslushnikov.com/?Runtime.enable) by executing Javascript in (isolated) ExecutionContexts.
58
+
59
+ ### [Console.enable](https://vanilla.aslushnikov.com/?Console.enable) Leak
60
+ Patchright patches this leak by disabling the Console API all together. This means, console functionality will not work in Patchright. If you really need the console, you might be better off using Javascript loggers, although they also can be easily detected.
61
+
62
+ ### Command Flags Leaks
63
+ Patchright tweaks the Playwright Default Args to avoid detection by Command Flag Leaks. This (most importantly) affects:
64
+ - `--disable-blink-features=AutomationControlled` (added) to avoid navigator.webdriver detection.
65
+ - `--enable-automation` (removed) to avoid navigator.webdriver detection.
66
+ - `--disable-popup-blocking` (removed) to avoid popup crashing.
67
+ - `--disable-component-update` (removed) to avoid detection as a Stealth Driver.
68
+ - `--disable-default-apps` (removed) to enable default apps.
69
+ - `--disable-extensions` (removed) to enable extensions
70
+
71
+ ### General Leaks
72
+ Patchright patches some general leaks in the Playwright codebase. This mainly includes poor setups and obvious detection points.
73
+
74
+ ### Closed Shadow Roots
75
+ Patchright is able to interact with elements in Closed Shadow Roots. Just use normal locators and Patchright will do the rest.
76
+ <br/>
77
+ Patchright is now also able to use XPaths in Closed Shadow Roots.
78
+
79
+ ### Turnstile / Challenge Auto-Solve
80
+ Patchright automatically interacts with embedded challenge widgets (Cloudflare Turnstile and the full-page "Just a moment..." challenge) when they appear. Just navigate normally and Patchright will do the rest — the widget is located by position and clicked with a real trusted mouse event, the same way a user would click the checkbox. Disable it per context with `turnstile: false`.
81
+
82
+ ### Native Storage Partitioning Preservation
83
+ Playwright by default forcibly disables `ThirdPartyStoragePartitioning`, which modern bot-detectors detect immediately via cross-site iframe storage checks. Patchright preserves Chrome's native storage partitioning in the browser switches, ensuring 100% compliance with regular consumer Chrome browsers.
84
+
85
+ ### Human Mouse Trajectory Dynamics
86
+ Robotic single-step cursor jumps are heavily flagged by advanced behavioral bot detectors. Patchright natively calculates smooth quadratic Bézier curved interpolation trajectories with natural acceleration and deceleration easing curves on all mouse movements, hovers, and clicks. Disable per context with `humanize: false`.
87
+
88
+ ---
89
+
90
+ ## Stealth & Anti-Bot Detection
91
+
92
+ With the right setup, Patchright currently is considered undetectable.
93
+ Patchright passes:
94
+ - [Brotector](https://kaliiiiiiiiii.github.io/brotector/) ✅ (with [CDP-Patches](https://github.com/Kaliiiiiiiiii-Vinyzu/CDP-Patches/))
95
+ - [Cloudflare](https://cloudflare.com/) (WAF, Turnstile, Managed Challenge) ✅
96
+ - [Kasada](https://www.kasada.io/) ✅
97
+ - [Akamai](https://www.akamai.com/products/bot-manager/) ✅
98
+ - [Shape/F5](https://www.f5.com/) ✅
99
+ - [Bet365](https://bet365.com/) ✅
100
+ - [Datadome](https://datadome.co/products/bot-protection/) ✅
101
+ - [Fingerprint.com](https://fingerprint.com/products/bot-detection/) ✅
102
+ - [reCAPTCHA v3 Score](https://antcpt.com/score_detector/) (0.9 Human Trust Score) ✅
103
+ - [Rebrowser Bot Detector](https://bot-detector.rebrowser.net/) (Native Storage Partitioning & 0 Leaks) ✅
104
+ - [Pixelscan](https://pixelscan.net/) (Bot Check & Fingerprint Clean) ✅
105
+ - [CreepJS](https://abrahamjuliot.github.io/creepjs/) ✅
106
+ - [Sannysoft](https://bot.sannysoft.com/) (WebDriver Undetected) ✅
107
+ - [Incolumitas](https://bot.incolumitas.com/) ✅
108
+ - [IPHey](https://iphey.com/) ✅
109
+ - [Browserscan](https://browserscan.net/) ✅
110
+
111
+ ### 🚀 Core Built-in Engine Features
112
+ | Built-in Feature | Implementation | Benefit |
113
+ |:---|:---|:---|
114
+ | **Turnstile & Challenge Auto-Solve** | Built into driver `Page._checkTurnstile` & 1s background loop | Automatically detects and clicks Cloudflare Turnstile & "Just a moment..." challenges using trusted CDP coordinate clicks |
115
+ | **Native Storage Partitioning** | Built into `chromiumSwitches.ts` (`feature !== 'ThirdPartyStoragePartitioning'`) | Preserves 3rd-party iframe storage partitioning, passing Rebrowser Bot Detector with 0 detections |
116
+ | **Human Mouse Trajectory Dynamics** | Built into `Mouse.move` in `input.ts` | Quadratic Bézier curved trajectory generation with cubic easing on hovers & clicks, defeating behavioral anti-bot models |
117
+ | **ReCAPTCHA v3 Trust Score** | Clean execution context isolation without leaked flags | Achieves 0.9 maximum human trust score |
118
+ | **Isolated World Execution** | Built into `Frame._isolatedWorld` & execution dispatchers | Arbitrary code execution completely isolated from webpage JS inspection |
119
+ | **Automation Flag Sanitization** | `AutomationControlled` disabled, `--enable-automation` removed | Native `navigator.webdriver === false` across all frames and popups |
120
+
121
+ ### 🧪 Verified Detection Test Suite
122
+ | Target Test Platform | Detection Type | Status |
123
+ |:---|:---|:---|
124
+ | **Cloudflare WAF** | Web Application Firewall challenge | ✅ Passed (~19.4s) |
125
+ | **Cloudflare Turnstile** | Embedded JS Challenge Widget auto-solve | ✅ Passed (~13.6s) |
126
+ | **reCAPTCHA v3 Score** | Google Trust Score test (>= 0.9) | ✅ Passed (~13.2s) |
127
+ | **Rebrowser Bot Detector** | Advanced CDP leak & storage partitioning check | ✅ Passed (0 Detections, Score: -1) |
128
+ | **Sannysoft WebDriver** | WebDriver/navigator properties check | ✅ Passed |
129
+ | **Pixelscan Fingerprint** | Canvas/WebGL fingerprint check | ✅ Passed (No Masking Detected) |
130
+ | **Pixelscan Bot Check** | Bot automation framework detection | ✅ Passed |
131
+
132
+ ---
133
+
134
+ ## Bugs
135
+ #### Even though we have spent a lot of time to make Patchright as stable as possible, bugs may still occur. If you encounter any bugs, please report them in the [Issues](https://github.com/Kaliiiiiiiiii-Vinyzu/patchright/issues).
136
+ #### Patchright is now tested against the Playwright Tests after every release. See [here](https://github.com/Kaliiiiiiiiii-Vinyzu/patchright-python/actions/workflows/patchright_tests.yml)
137
+
138
+ > [!WARNING]
139
+ > Patchright passes most, but not all the Playwright tests. Some bugs are considered impossible to solve, some are just not relevant. See the list of bugs and their explanation [here](https://github.com/Kaliiiiiiiiii-Vinyzu/patchright/issues/30).
140
+
141
+ #### Based on the Playwright Tests, we concluded that its highly unlikely that you will be affected by these bugs in regular usecases.
142
+
143
+ <details>
144
+ <summary><b>Init Script Shenanigans</b></summary>
145
+
146
+ ### Explanation
147
+ To be able to use InitScripts without [Runtime.enable](https://vanilla.aslushnikov.com/?Runtime.enable), Patchright uses Playwright Routes to inject JavaScript into HTML requests.
148
+
149
+ ### Bugs
150
+ Playwright Routes may cause some bugs in other parts of your code. Patchright InitScripts won't cause any bugs that wouldn't be caused by normal Playwright Routes. </br> If you want any of these bugs fixed, you'll have to contact the Playwright team.
151
+
152
+ ### Leaks
153
+ Patchright InitScripts can be detected by Timing Attacks. However, no antibot currently checks for this kind of Timing Attack and they probably won't for a good amount of time. </br> We consider them not to be a big risk of detection.
154
+
155
+ </details>
156
+
157
+ ---
158
+
159
+ ### TODO
160
+ - [x] Implement Option to choose Execution Context (Main/Isolated).
161
+ - [x] Fix Fixable Bugs.
162
+ - [x] Implement .patch Updater to easily show Patchright's patches.
163
+ - [x] Setup Automated Testing on new Release.
164
+ - [x] Implement Patchright on .NET.
165
+ - [ ] Implement Patchright on Java.
166
+
167
+ ---
168
+
169
+ ## Development
170
+
171
+ Deployment of new Patchright versions are automatic, but bugs due to Playwright codebase changes may occur. Fixes for these bugs might take a few days to be released.
172
+
173
+ ---
174
+
175
+ ## Copyright and License
176
+ © [Vinyzu](https://github.com/Vinyzu/)
177
+
178
+ Patchright is licensed [Apache 2.0](https://choosealicense.com/licenses/apache-2.0/)
179
+
180
+ [Some Parts](https://github.com/Kaliiiiiiiiii-Vinyzu/patchright/blob/10c5a090e9a1dcd2107c253d65b3d8b27d0670a9/driver_patches/framesPatch.ts#L156-L171) of the Codebase are inspired by [Driverless](https://github.com/kaliiiiiiiiii/Selenium-Driverless).
181
+ Thanks to [Nick Webson](https://github.com/rebrowser/rebrowser-patches) for the idea of .patch-File Documentation.
182
+
183
+ ---
184
+
185
+ ## Disclaimer
186
+
187
+ This repository is provided for **educational purposes only**. \
188
+ No warranties are provided regarding accuracy, completeness, or suitability for any purpose. **Use at your own risk**—the authors and maintainers assume **no liability** for **any damages**, **legal issues**, or **warranty breaches** resulting from use, modification, or distribution of this code.\
189
+ **Any misuse or legal violations are the sole responsibility of the user**.
190
+
191
+ ---
192
+
193
+ ## Authors
194
+
195
+ #### Active Maintainer: [Vinyzu](https://github.com/Vinyzu/) </br> Co-Maintainer: [Kaliiiiiiiiii](https://github.com/kaliiiiiiiiii/)
@@ -0,0 +1,14 @@
1
+ microsoft/playwright
2
+
3
+ THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
4
+
5
+ This package bundles third-party software inside individual files under
6
+ `lib/`. Each bundled output has a sidecar `<bundle>.js.LICENSE` file next
7
+ to it listing every npm package whose source was inlined into that
8
+ bundle, together with the full license text for each.
9
+
10
+ For example:
11
+ - lib/common/index.js.LICENSE
12
+ - lib/matchers/expect.js.LICENSE
13
+
14
+ This project incorporates components from the projects listed below. The original copyright notices and the licenses under which Microsoft received such components are set forth below. Microsoft reserves all rights not expressly granted herein, whether by implication, estoppel or otherwise.
package/cli.js ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ const { program } = require('./lib/program');
19
+ program.parse(process.argv);
package/index.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ export * from 'patchwright-core';
package/index.js ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ module.exports = require('patchwright-core');
package/index.mjs ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export * from 'patchwright-core';
17
+ import playwright from 'patchwright-core';
18
+ export default playwright;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var agentParser_exports = {};
30
+ __export(agentParser_exports, {
31
+ parseAgentSpec: () => parseAgentSpec
32
+ });
33
+ module.exports = __toCommonJS(agentParser_exports);
34
+ var import_fs = __toESM(require("fs"));
35
+ const yaml = require("patchwright-core/lib/utilsBundle").yaml;
36
+ async function parseAgentSpec(filePath) {
37
+ const source = await import_fs.default.promises.readFile(filePath, "utf-8");
38
+ const { header, content } = extractYamlAndContent(source);
39
+ const { instructions, examples } = extractInstructionsAndExamples(content);
40
+ return {
41
+ ...header,
42
+ instructions,
43
+ examples
44
+ };
45
+ }
46
+ function extractYamlAndContent(markdown) {
47
+ const lines = markdown.split("\n");
48
+ if (lines[0] !== "---")
49
+ throw new Error("Markdown file must start with YAML front matter (---)");
50
+ let yamlEndIndex = -1;
51
+ for (let i = 1; i < lines.length; i++) {
52
+ if (lines[i] === "---") {
53
+ yamlEndIndex = i;
54
+ break;
55
+ }
56
+ }
57
+ if (yamlEndIndex === -1)
58
+ throw new Error("YAML front matter must be closed with ---");
59
+ const yamlLines = lines.slice(1, yamlEndIndex);
60
+ const yamlRaw = yamlLines.join("\n");
61
+ const contentLines = lines.slice(yamlEndIndex + 1);
62
+ const content = contentLines.join("\n");
63
+ let header;
64
+ try {
65
+ header = yaml.parse(yamlRaw);
66
+ } catch (error) {
67
+ throw new Error(`Failed to parse YAML header: ${error.message}`);
68
+ }
69
+ if (!header.name)
70
+ throw new Error('YAML header must contain a "name" field');
71
+ if (!header.description)
72
+ throw new Error('YAML header must contain a "description" field');
73
+ return { header, content };
74
+ }
75
+ function extractInstructionsAndExamples(content) {
76
+ const examples = [];
77
+ const instructions = content.split("<example>")[0].trim();
78
+ const exampleRegex = /<example>([\s\S]*?)<\/example>/g;
79
+ let match;
80
+ while ((match = exampleRegex.exec(content)) !== null) {
81
+ const example = match[1].trim();
82
+ examples.push(example.replace(/[\n]/g, " ").replace(/ +/g, " "));
83
+ }
84
+ return { instructions, examples };
85
+ }
86
+ // Annotate the CommonJS export names for ESM import in node:
87
+ 0 && (module.exports = {
88
+ parseAgentSpec
89
+ });
@@ -0,0 +1,34 @@
1
+ name: "Copilot Setup Steps"
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ paths:
7
+ - .github/workflows/copilot-setup-steps.yml
8
+ pull_request:
9
+ paths:
10
+ - .github/workflows/copilot-setup-steps.yml
11
+
12
+ jobs:
13
+ copilot-setup-steps:
14
+ runs-on: ubuntu-latest
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ steps:
20
+ - uses: actions/checkout@v6
21
+
22
+ - uses: actions/setup-node@v6
23
+ with:
24
+ node-version: lts/*
25
+
26
+ - name: Install dependencies
27
+ run: npm ci
28
+
29
+ - name: Install Playwright Browsers
30
+ run: npx playwright install --with-deps
31
+
32
+ # Customize this step as needed
33
+ - name: Build application
34
+ run: npx run build