@guanlin4924/devflow-pi 0.1.94 → 0.1.96

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 (245) hide show
  1. package/README.md +34 -4
  2. package/node_modules/@playwright/test/LICENSE +202 -0
  3. package/node_modules/@playwright/test/NOTICE +5 -0
  4. package/node_modules/@playwright/test/README.md +318 -0
  5. package/node_modules/@playwright/test/cli.js +19 -0
  6. package/node_modules/@playwright/test/index.d.ts +18 -0
  7. package/node_modules/@playwright/test/index.js +17 -0
  8. package/node_modules/@playwright/test/index.mjs +18 -0
  9. package/node_modules/@playwright/test/package.json +35 -0
  10. package/node_modules/@playwright/test/reporter.d.ts +17 -0
  11. package/node_modules/@playwright/test/reporter.js +17 -0
  12. package/node_modules/@playwright/test/reporter.mjs +17 -0
  13. package/node_modules/playwright/LICENSE +202 -0
  14. package/node_modules/playwright/NOTICE +5 -0
  15. package/node_modules/playwright/README.md +318 -0
  16. package/node_modules/playwright/ThirdPartyNotices.txt +14 -0
  17. package/node_modules/playwright/cli.js +19 -0
  18. package/node_modules/playwright/index.d.ts +17 -0
  19. package/node_modules/playwright/index.js +17 -0
  20. package/node_modules/playwright/index.mjs +18 -0
  21. package/node_modules/playwright/jsx-runtime.js +42 -0
  22. package/node_modules/playwright/jsx-runtime.mjs +21 -0
  23. package/node_modules/playwright/lib/agents/agentParser.js +89 -0
  24. package/node_modules/playwright/lib/agents/copilot-setup-steps.yml +34 -0
  25. package/node_modules/playwright/lib/agents/generateAgents.js +395 -0
  26. package/node_modules/playwright/lib/agents/playwright-test-coverage.prompt.md +31 -0
  27. package/node_modules/playwright/lib/agents/playwright-test-generate.prompt.md +8 -0
  28. package/node_modules/playwright/lib/agents/playwright-test-generator.agent.md +88 -0
  29. package/node_modules/playwright/lib/agents/playwright-test-heal.prompt.md +6 -0
  30. package/node_modules/playwright/lib/agents/playwright-test-healer.agent.md +56 -0
  31. package/node_modules/playwright/lib/agents/playwright-test-plan.prompt.md +9 -0
  32. package/node_modules/playwright/lib/agents/playwright-test-planner.agent.md +74 -0
  33. package/node_modules/playwright/lib/cli/reportActions.js +78 -0
  34. package/node_modules/playwright/lib/cli/testActions.js +214 -0
  35. package/node_modules/playwright/lib/common/index.js +2923 -0
  36. package/node_modules/playwright/lib/common/index.js.txt +34 -0
  37. package/node_modules/playwright/lib/errorContext.js +129 -0
  38. package/node_modules/playwright/lib/globals.js +58 -0
  39. package/node_modules/playwright/lib/index.js +815 -0
  40. package/node_modules/playwright/lib/isomorphic.js +260 -0
  41. package/node_modules/playwright/lib/isomorphic.js.txt +9 -0
  42. package/node_modules/playwright/lib/loader/loaderProcessEntry.js +34 -0
  43. package/node_modules/playwright/lib/loader/loaderProcessEntry.js.txt +9 -0
  44. package/node_modules/playwright/lib/matchers/expect.js +13490 -0
  45. package/node_modules/playwright/lib/matchers/expect.js.LICENSE +640 -0
  46. package/node_modules/playwright/lib/matchers/expect.js.txt +67 -0
  47. package/node_modules/playwright/lib/mcp/test/browserBackend.js +135 -0
  48. package/node_modules/playwright/lib/mcp/test/generatorTools.js +122 -0
  49. package/node_modules/playwright/lib/mcp/test/plannerTools.js +150 -0
  50. package/node_modules/playwright/lib/mcp/test/seed.js +82 -0
  51. package/node_modules/playwright/lib/mcp/test/streams.js +44 -0
  52. package/node_modules/playwright/lib/mcp/test/testBackend.js +99 -0
  53. package/node_modules/playwright/lib/mcp/test/testContext.js +306 -0
  54. package/node_modules/playwright/lib/mcp/test/testTool.js +30 -0
  55. package/node_modules/playwright/lib/mcp/test/testTools.js +98 -0
  56. package/node_modules/playwright/lib/package.js +47 -0
  57. package/node_modules/playwright/lib/program.js +241 -0
  58. package/node_modules/playwright/lib/runner/index.js +8527 -0
  59. package/node_modules/playwright/lib/runner/index.js.txt +61 -0
  60. package/node_modules/playwright/lib/transform/babelBundle.js +72274 -0
  61. package/node_modules/playwright/lib/transform/babelBundle.js.LICENSE +2384 -0
  62. package/node_modules/playwright/lib/transform/babelBundle.js.txt +325 -0
  63. package/node_modules/playwright/lib/transform/esmLoader.js +8054 -0
  64. package/node_modules/playwright/lib/transform/esmLoader.js.LICENSE +355 -0
  65. package/node_modules/playwright/lib/transform/esmLoader.js.txt +60 -0
  66. package/node_modules/playwright/lib/util.js +373 -0
  67. package/node_modules/playwright/lib/worker/workerProcessEntry.js +1861 -0
  68. package/node_modules/playwright/lib/worker/workerProcessEntry.js.txt +19 -0
  69. package/node_modules/playwright/package.json +55 -0
  70. package/node_modules/playwright/test.d.ts +18 -0
  71. package/node_modules/playwright/test.js +24 -0
  72. package/node_modules/playwright/test.mjs +35 -0
  73. package/node_modules/playwright/types/test.d.ts +11074 -0
  74. package/node_modules/playwright/types/testReporter.d.ts +950 -0
  75. package/node_modules/playwright-core/LICENSE +202 -0
  76. package/node_modules/playwright-core/NOTICE +5 -0
  77. package/node_modules/playwright-core/README.md +3 -0
  78. package/node_modules/playwright-core/ThirdPartyNotices.txt +13 -0
  79. package/node_modules/playwright-core/bin/install_media_pack.ps1 +5 -0
  80. package/node_modules/playwright-core/bin/install_webkit_wsl.ps1 +33 -0
  81. package/node_modules/playwright-core/bin/reinstall_chrome_beta_linux.sh +42 -0
  82. package/node_modules/playwright-core/bin/reinstall_chrome_beta_mac.sh +13 -0
  83. package/node_modules/playwright-core/bin/reinstall_chrome_beta_win.ps1 +24 -0
  84. package/node_modules/playwright-core/bin/reinstall_chrome_stable_linux.sh +42 -0
  85. package/node_modules/playwright-core/bin/reinstall_chrome_stable_mac.sh +12 -0
  86. package/node_modules/playwright-core/bin/reinstall_chrome_stable_win.ps1 +24 -0
  87. package/node_modules/playwright-core/bin/reinstall_msedge_beta_linux.sh +48 -0
  88. package/node_modules/playwright-core/bin/reinstall_msedge_beta_mac.sh +11 -0
  89. package/node_modules/playwright-core/bin/reinstall_msedge_beta_win.ps1 +23 -0
  90. package/node_modules/playwright-core/bin/reinstall_msedge_dev_linux.sh +48 -0
  91. package/node_modules/playwright-core/bin/reinstall_msedge_dev_mac.sh +11 -0
  92. package/node_modules/playwright-core/bin/reinstall_msedge_dev_win.ps1 +23 -0
  93. package/node_modules/playwright-core/bin/reinstall_msedge_stable_linux.sh +48 -0
  94. package/node_modules/playwright-core/bin/reinstall_msedge_stable_mac.sh +11 -0
  95. package/node_modules/playwright-core/bin/reinstall_msedge_stable_win.ps1 +24 -0
  96. package/node_modules/playwright-core/browsers.json +52 -0
  97. package/node_modules/playwright-core/cli.js +21 -0
  98. package/node_modules/playwright-core/index.d.ts +17 -0
  99. package/node_modules/playwright-core/index.js +17 -0
  100. package/node_modules/playwright-core/index.mjs +28 -0
  101. package/node_modules/playwright-core/lib/bootstrap.js +88 -0
  102. package/node_modules/playwright-core/lib/coreBundle.js +75813 -0
  103. package/node_modules/playwright-core/lib/entry/cliDaemon.js +5 -0
  104. package/node_modules/playwright-core/lib/entry/dashboardApp.js +3 -0
  105. package/node_modules/playwright-core/lib/entry/mcp.js +10 -0
  106. package/node_modules/playwright-core/lib/entry/oopBrowserDownload.js +3 -0
  107. package/node_modules/playwright-core/lib/package.js +50 -0
  108. package/node_modules/playwright-core/lib/server/chromium/appIcon.png +0 -0
  109. package/node_modules/playwright-core/lib/server/electron/loader.js +116 -0
  110. package/node_modules/playwright-core/lib/serverRegistry.js +1939 -0
  111. package/node_modules/playwright-core/lib/serverRegistry.js.LICENSE +65 -0
  112. package/node_modules/playwright-core/lib/tools/cli-client/channelSessions.js +141 -0
  113. package/node_modules/playwright-core/lib/tools/cli-client/cli.js +6 -0
  114. package/node_modules/playwright-core/lib/tools/cli-client/help.json +721 -0
  115. package/node_modules/playwright-core/lib/tools/cli-client/minimist.js +128 -0
  116. package/node_modules/playwright-core/lib/tools/cli-client/output.js +351 -0
  117. package/node_modules/playwright-core/lib/tools/cli-client/program.js +418 -0
  118. package/node_modules/playwright-core/lib/tools/cli-client/registry.js +180 -0
  119. package/node_modules/playwright-core/lib/tools/cli-client/session.js +259 -0
  120. package/node_modules/playwright-core/lib/tools/dashboard/appIcon.png +0 -0
  121. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/SKILL.md +425 -0
  122. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/element-attributes.md +23 -0
  123. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/playwright-tests.md +39 -0
  124. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/request-mocking.md +87 -0
  125. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/running-code.md +241 -0
  126. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/session-management.md +225 -0
  127. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/storage-state.md +275 -0
  128. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/test-generation.md +433 -0
  129. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/tracing.md +139 -0
  130. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/video-recording.md +143 -0
  131. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/SKILL.md +136 -0
  132. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +144 -0
  133. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/migration.md +89 -0
  134. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/react.md +69 -0
  135. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/typing.md +173 -0
  136. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/vue.md +77 -0
  137. package/node_modules/playwright-core/lib/tools/skills/playwright-trace/SKILL.md +174 -0
  138. package/node_modules/playwright-core/lib/tools/utils/extension.js +112 -0
  139. package/node_modules/playwright-core/lib/tools/utils/socketConnection.js +108 -0
  140. package/node_modules/playwright-core/lib/utilsBundle.js +85357 -0
  141. package/node_modules/playwright-core/lib/utilsBundle.js.LICENSE +1890 -0
  142. package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule--QdMvsKi.css +1 -0
  143. package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule-CQ8RZGBm.js +32 -0
  144. package/node_modules/playwright-core/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
  145. package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
  146. package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
  147. package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
  148. package/node_modules/playwright-core/lib/vite/dashboard/assets/index-AwgwcYie.css +1 -0
  149. package/node_modules/playwright-core/lib/vite/dashboard/assets/index-hRvO4yU2.js +12 -0
  150. package/node_modules/playwright-core/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
  151. package/node_modules/playwright-core/lib/vite/dashboard/index.html +29 -0
  152. package/node_modules/playwright-core/lib/vite/dashboard/playwright-logo.svg +24 -0
  153. package/node_modules/playwright-core/lib/vite/htmlReport/index.html +16 -0
  154. package/node_modules/playwright-core/lib/vite/htmlReport/report.css +2 -0
  155. package/node_modules/playwright-core/lib/vite/htmlReport/report.js +32 -0
  156. package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +1 -0
  157. package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule-CVQWJZAA.js +32 -0
  158. package/node_modules/playwright-core/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
  159. package/node_modules/playwright-core/lib/vite/recorder/assets/index-BZpYJZ-P.css +1 -0
  160. package/node_modules/playwright-core/lib/vite/recorder/assets/index-hrlLqLtq.js +129 -0
  161. package/node_modules/playwright-core/lib/vite/recorder/index.html +29 -0
  162. package/node_modules/playwright-core/lib/vite/recorder/playwright-logo.svg +9 -0
  163. package/node_modules/playwright-core/lib/vite/traceViewer/assets/codeMirrorModule-BbkfBe3n.js +32 -0
  164. package/node_modules/playwright-core/lib/vite/traceViewer/assets/defaultSettingsView-Ds6CBOo0.js +182 -0
  165. package/node_modules/playwright-core/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +1 -0
  166. package/node_modules/playwright-core/lib/vite/traceViewer/assets/xtermModule-DywYcAf8.js +7 -0
  167. package/node_modules/playwright-core/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +1 -0
  168. package/node_modules/playwright-core/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
  169. package/node_modules/playwright-core/lib/vite/traceViewer/defaultSettingsView.Bqk9acqE.css +1 -0
  170. package/node_modules/playwright-core/lib/vite/traceViewer/index.B4cLoZK3.js +1 -0
  171. package/node_modules/playwright-core/lib/vite/traceViewer/index.B_TqY17P.css +1 -0
  172. package/node_modules/playwright-core/lib/vite/traceViewer/index.html +44 -0
  173. package/node_modules/playwright-core/lib/vite/traceViewer/manifest.webmanifest +16 -0
  174. package/node_modules/playwright-core/lib/vite/traceViewer/playwright-logo.svg +9 -0
  175. package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +1 -0
  176. package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.html +10 -0
  177. package/node_modules/playwright-core/lib/vite/traceViewer/sw.bundle.js +4 -0
  178. package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CU5KtEkS.js +5 -0
  179. package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CyMfwkXJ.css +1 -0
  180. package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.html +18 -0
  181. package/node_modules/playwright-core/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +1 -0
  182. package/node_modules/playwright-core/lib/webp_codec.LICENSE +173 -0
  183. package/node_modules/playwright-core/lib/webp_codec.wasm +0 -0
  184. package/node_modules/playwright-core/lib/xdg-open +1267 -0
  185. package/node_modules/playwright-core/package.json +34 -0
  186. package/node_modules/playwright-core/types/protocol.d.ts +24645 -0
  187. package/node_modules/playwright-core/types/structs.d.ts +52 -0
  188. package/node_modules/playwright-core/types/types.d.ts +26632 -0
  189. package/package.json +13 -2
  190. package/plugins/devflow-core/extensions/devflow-core.ts +432 -7
  191. package/plugins/devflow-core/runtime/hooks/hook_common.py +514 -0
  192. package/plugins/devflow-core/runtime/hooks/index_gate.py +47 -16
  193. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/acceptance_test_runner.py +488 -71
  194. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/advance_state.rb +51 -0
  195. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/approval_pins.py +433 -0
  196. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/approval_store.py +137 -0
  197. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/dsl_coverage.py +87 -0
  198. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/dsl_draft.py +53 -0
  199. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/dsl_v1.py +318 -0
  200. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/environment_profile.py +134 -0
  201. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/execution_contract.rb +1 -0
  202. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/execution_surface.py +138 -0
  203. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/playwright_adapter.py +515 -0
  204. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/tc_hash.py +132 -0
  205. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/test_command_policy.py +102 -8
  206. package/plugins/devflow-core/skills/workflow-orchestrator/scripts/validate_state.rb +13 -0
  207. package/plugins/devflow-core/skills/workflow-orchestrator/templates/feature-development.yaml +13 -34
  208. package/plugins/devflow-core/skills/workflow-pipeline/SKILL.md +3 -1
  209. package/plugins/devflow-core/skills/workflow-pipeline/references/pipeline-flow.md +68 -140
  210. package/plugins/devflow-core/skills/workflow-project-context/scripts/validate_initialization_database.py +1 -1
  211. package/plugins/devflow-implementation/skills/workflow-execute-phase/references/execute-phase.md +3 -1
  212. package/plugins/devflow-intel/extensions/devflow-intel.ts +1 -1
  213. package/plugins/devflow-intel/skills/workflow-code-index/scripts/code_index.py +23 -4
  214. package/plugins/devflow-quality/runtime/playwright/devflow-test-dsl-v1.schema.json +872 -0
  215. package/plugins/devflow-quality/runtime/playwright/playwright.config.mjs +46 -0
  216. package/plugins/devflow-quality/runtime/playwright/reporter.mjs +311 -0
  217. package/plugins/devflow-quality/runtime/playwright/runner.spec.mjs +1308 -0
  218. package/plugins/devflow-quality/runtime/playwright/runtime-manifest.json +11 -0
  219. package/plugins/devflow-quality/skills/workflow-acceptance-test-design/SKILL.md +3 -0
  220. package/plugins/devflow-quality/skills/workflow-generate-mainflow-cases/SKILL.md +71 -58
  221. package/plugins/devflow-quality/skills/workflow-generate-mainflow-cases/references/api-mainflow-rules.md +20 -15
  222. package/plugins/devflow-quality/skills/workflow-generate-mainflow-cases/references/codebase-discovery.md +3 -1
  223. package/plugins/devflow-quality/skills/workflow-generate-mainflow-cases/references/intermediate-format.md +115 -192
  224. package/plugins/devflow-quality/skills/workflow-generate-mainflow-cases/references/mainflow-selection.md +27 -23
  225. package/plugins/devflow-quality/skills/workflow-generate-mainflow-cases/references/project-dsl-contract.md +78 -153
  226. package/plugins/devflow-quality/skills/workflow-generate-mainflow-cases/references/ui-mainflow-rules.md +36 -83
  227. package/plugins/devflow-quality/skills/workflow-generate-mainflow-cases/scripts/compile_dsl.py +497 -556
  228. package/plugins/devflow-quality/skills/workflow-generate-mainflow-cases/scripts/export_legacy_testagent.py +647 -0
  229. package/plugins/devflow-quality/skills/workflow-generate-mainflow-cases/scripts/normalize_case_payloads.py +10 -3
  230. package/plugins/devflow-quality/skills/workflow-generate-mainflow-cases/scripts/validate_case_payloads.py +165 -275
  231. package/plugins/devflow-quality/skills/workflow-human-acceptance/SKILL.md +63 -0
  232. package/plugins/devflow-quality/skills/workflow-release-closeout/SKILL.md +4 -4
  233. package/plugins/devflow-quality/skills/workflow-run-acceptance-tests/SKILL.md +17 -9
  234. package/src/approval-store.ts +340 -0
  235. package/src/cli.ts +10 -0
  236. package/src/constants.ts +1 -1
  237. package/src/doctor.ts +268 -2
  238. package/src/initialization-store.ts +48 -1
  239. package/src/mcp/auth.ts +103 -0
  240. package/src/mcp/core.ts +102 -0
  241. package/src/mcp/server.ts +193 -0
  242. package/src/mcp/types.ts +5 -0
  243. package/src/paths.ts +12 -1
  244. package/src/project-context.ts +24 -1
  245. package/templates/omp/hook-config.json +6 -0
@@ -0,0 +1,46 @@
1
+ // plugins/devflow-quality/runtime/playwright/src/playwright.config.ts
2
+ import fs from "node:fs";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ var here = path.dirname(fileURLToPath(import.meta.url));
7
+ var resultFile = process.env.DEVFLOW_RESULT_FILE;
8
+ var runDir = resultFile && path.isAbsolute(resultFile) ? path.dirname(resultFile) : path.join(os.tmpdir(), "devflow-runtime-unbound");
9
+ function traceMode() {
10
+ try {
11
+ const profile = JSON.parse(fs.readFileSync(process.env.DEVFLOW_ENVIRONMENT_FILE ?? "", "utf8"));
12
+ if (profile?.trace === "off")
13
+ return "off";
14
+ return "retain-on-failure";
15
+ } catch {
16
+ return "off";
17
+ }
18
+ }
19
+ var playwright_config_default = {
20
+ testDir: here,
21
+ testMatch: /[\\/]runner\.spec\.mjs$/,
22
+ outputDir: path.join(runDir, ".pw-output"),
23
+ fullyParallel: false,
24
+ workers: 1,
25
+ retries: 0,
26
+ maxFailures: 1,
27
+ forbidOnly: true,
28
+ timeout: 30 * 60 * 1000,
29
+ updateSnapshots: "none",
30
+ reporter: [[path.join(here, "reporter.mjs")]],
31
+ use: {
32
+ browserName: "chromium",
33
+ headless: true,
34
+ trace: traceMode(),
35
+ screenshot: "only-on-failure",
36
+ video: "off",
37
+ serviceWorkers: "block",
38
+ acceptDownloads: false,
39
+ ignoreHTTPSErrors: false,
40
+ actionTimeout: 1e4,
41
+ navigationTimeout: 30000
42
+ }
43
+ };
44
+ export {
45
+ playwright_config_default as default
46
+ };
@@ -0,0 +1,311 @@
1
+ // plugins/devflow-quality/runtime/playwright/src/reporter.ts
2
+ import crypto from "node:crypto";
3
+ import fs from "node:fs";
4
+ import path2 from "node:path";
5
+
6
+ // plugins/devflow-quality/runtime/playwright/src/env.ts
7
+ import path from "node:path";
8
+ var NAMES = {
9
+ dslFile: "DEVFLOW_DSL_FILE",
10
+ dslSha256: "DEVFLOW_DSL_SHA256",
11
+ tcId: "DEVFLOW_TC_ID",
12
+ tcSha256: "DEVFLOW_TC_SHA256",
13
+ executionId: "DEVFLOW_EXECUTION_ID",
14
+ nonce: "DEVFLOW_EXECUTION_NONCE",
15
+ resultFile: "DEVFLOW_RESULT_FILE",
16
+ artifactDir: "DEVFLOW_ARTIFACT_DIR",
17
+ environmentFile: "DEVFLOW_ENVIRONMENT_FILE"
18
+ };
19
+
20
+ class EnvError extends Error {
21
+ code;
22
+ constructor(message, code) {
23
+ super(message);
24
+ this.code = code;
25
+ }
26
+ }
27
+ function rawEnv(env = process.env) {
28
+ const out = {};
29
+ for (const [key, name] of Object.entries(NAMES)) {
30
+ const value = env[name];
31
+ if (typeof value === "string" && value.length > 0)
32
+ out[key] = value;
33
+ }
34
+ return out;
35
+ }
36
+ function readRuntimeEnv(env = process.env) {
37
+ const raw = rawEnv(env);
38
+ const missing = Object.entries(NAMES).filter(([key]) => !raw[key]).map(([, name]) => name);
39
+ if (missing.length)
40
+ throw new EnvError(`missing reserved environment variables: ${missing.join(", ")}`, "runtime_env_missing");
41
+ const r = raw;
42
+ for (const key of ["dslFile", "resultFile", "artifactDir", "environmentFile"]) {
43
+ if (!path.isAbsolute(r[key]))
44
+ throw new EnvError(`${NAMES[key]} must be an absolute path`, "runtime_env_invalid");
45
+ }
46
+ if (!/^[0-9a-f]{64}$/.test(r.dslSha256))
47
+ throw new EnvError("DEVFLOW_DSL_SHA256 must be 64 lowercase hex", "runtime_env_invalid");
48
+ if (!/^[0-9a-f]{64}$/.test(r.tcSha256))
49
+ throw new EnvError("DEVFLOW_TC_SHA256 must be 64 lowercase hex", "runtime_env_invalid");
50
+ if (path.basename(r.resultFile) !== "result.json")
51
+ throw new EnvError("DEVFLOW_RESULT_FILE must be <run_dir>/result.json", "runtime_env_invalid");
52
+ const runDir = path.dirname(path.resolve(r.resultFile));
53
+ if (path.resolve(r.artifactDir) !== path.join(runDir, "artifacts")) {
54
+ throw new EnvError("DEVFLOW_ARTIFACT_DIR must be <run_dir>/artifacts next to DEVFLOW_RESULT_FILE", "runtime_env_invalid");
55
+ }
56
+ return { ...r, runDir };
57
+ }
58
+
59
+ // plugins/devflow-quality/runtime/playwright/src/redact.ts
60
+ var REDACTED = "***";
61
+ var SENSITIVE_KEY = /(pass(word|wd)?|secret|token|auth|session|cookie|api[-_]?key|signature|sig|credential|private)/i;
62
+ var MAX_ERROR_LENGTH = 2000;
63
+ var ANSI = /\u001b\[[0-9;]*[A-Za-z]/g;
64
+
65
+ class Redactor {
66
+ values = [];
67
+ add(value) {
68
+ if (value === undefined || value === null)
69
+ return;
70
+ const text = typeof value === "string" ? value : JSON.stringify(value);
71
+ if (!text)
72
+ return;
73
+ if (!this.values.includes(text)) {
74
+ this.values.push(text);
75
+ this.values.sort((a, b) => b.length - a.length);
76
+ }
77
+ for (const encoded of [encodeURIComponent(text), new URLSearchParams({ v: text }).toString().slice(2)]) {
78
+ if (encoded !== text && !this.values.includes(encoded))
79
+ this.values.push(encoded);
80
+ }
81
+ this.values.sort((a, b) => b.length - a.length);
82
+ }
83
+ list() {
84
+ return [...this.values];
85
+ }
86
+ text(input) {
87
+ let out = input;
88
+ for (const v of this.values)
89
+ out = out.split(v).join(REDACTED);
90
+ return out;
91
+ }
92
+ url(input) {
93
+ let masked = input;
94
+ try {
95
+ const u = new URL(input);
96
+ if (u.username || u.password) {
97
+ u.username = u.username ? REDACTED : "";
98
+ u.password = u.password ? REDACTED : "";
99
+ }
100
+ for (const key of [...u.searchParams.keys()]) {
101
+ if (SENSITIVE_KEY.test(key))
102
+ u.searchParams.set(key, REDACTED);
103
+ }
104
+ masked = u.toString();
105
+ } catch {}
106
+ return this.text(masked);
107
+ }
108
+ value(input) {
109
+ if (typeof input === "string")
110
+ return this.text(input);
111
+ if (Array.isArray(input))
112
+ return input.map((v) => this.value(v));
113
+ if (input && typeof input === "object") {
114
+ return Object.fromEntries(Object.entries(input).map(([k, v]) => [k, SENSITIVE_KEY.test(k) ? REDACTED : this.value(v)]));
115
+ }
116
+ if (input !== undefined && input !== null && this.values.includes(String(input)))
117
+ return REDACTED;
118
+ return input;
119
+ }
120
+ error(err) {
121
+ const raw = err instanceof Error ? err.message : String(err);
122
+ const text = this.text(raw.replace(ANSI, ""));
123
+ return text.length > MAX_ERROR_LENGTH ? `${text.slice(0, MAX_ERROR_LENGTH)}…` : text;
124
+ }
125
+ }
126
+
127
+ // plugins/devflow-quality/runtime/playwright/src/version.ts
128
+ var RUNTIME_VERSION = "0.1.0";
129
+ var RESULT_ORIGIN = "devflow_playwright_runtime";
130
+ var RESULT_SCHEMA_VERSION = 1;
131
+ var DSL_SCHEMA_FILE = "devflow-test-dsl-v1.schema.json";
132
+ var RESULT_ATTACHMENT = "devflow-runtime-result";
133
+
134
+ // plugins/devflow-quality/runtime/playwright/src/reporter.ts
135
+ var now = () => new Date().toISOString();
136
+ function sha256File(file) {
137
+ const data = fs.readFileSync(file);
138
+ return { bytes: data.length, sha256: crypto.createHash("sha256").update(data).digest("hex") };
139
+ }
140
+ function writeAtomic(file, content) {
141
+ const dir = path2.dirname(file);
142
+ const tmp = path2.join(dir, `.${path2.basename(file)}.${process.pid}.${crypto.randomBytes(6).toString("hex")}.tmp`);
143
+ const fd = fs.openSync(tmp, "wx", 384);
144
+ try {
145
+ fs.writeSync(fd, content);
146
+ fs.fsyncSync(fd);
147
+ } finally {
148
+ fs.closeSync(fd);
149
+ }
150
+ fs.renameSync(tmp, file);
151
+ }
152
+ function inside(parent, child) {
153
+ const rel = path2.relative(parent, child);
154
+ return rel !== "" && !rel.startsWith("..") && !path2.isAbsolute(rel);
155
+ }
156
+ function stripStep(step) {
157
+ const { error_code: _ignored, ...rest } = step;
158
+ return rest;
159
+ }
160
+
161
+ class DevflowReporter {
162
+ startedAt = now();
163
+ outcome = null;
164
+ testStatus = null;
165
+ attachments = [];
166
+ errors = [];
167
+ preexisting = false;
168
+ testCount = 0;
169
+ printsToStdio() {
170
+ return true;
171
+ }
172
+ onBegin() {
173
+ const env = rawEnv();
174
+ if (env.resultFile && fs.existsSync(env.resultFile))
175
+ this.preexisting = true;
176
+ if (env.artifactDir && path2.isAbsolute(env.artifactDir))
177
+ fs.mkdirSync(env.artifactDir, { recursive: true, mode: 448 });
178
+ }
179
+ onTestEnd(_test, result) {
180
+ this.testCount += 1;
181
+ this.testStatus = result.status;
182
+ this.attachments = result.attachments;
183
+ const attachment = result.attachments.find((a) => a.name === RESULT_ATTACHMENT && a.body);
184
+ if (attachment?.body) {
185
+ try {
186
+ this.outcome = JSON.parse(attachment.body.toString("utf8"));
187
+ } catch {
188
+ this.outcome = null;
189
+ }
190
+ }
191
+ for (const error of result.errors)
192
+ this.errors.push(error.message ?? String(error.value ?? "error"));
193
+ }
194
+ onError(error) {
195
+ this.errors.push(error.message ?? String(error.value ?? "error"));
196
+ }
197
+ async onExit() {
198
+ const env = rawEnv();
199
+ if (env.resultFile && path2.isAbsolute(env.resultFile)) {
200
+ fs.rmSync(path2.join(path2.dirname(env.resultFile), ".pw-output"), { recursive: true, force: true });
201
+ }
202
+ }
203
+ baselineRedactor() {
204
+ const redactor = new Redactor;
205
+ const env = rawEnv();
206
+ try {
207
+ const profile = JSON.parse(fs.readFileSync(env.environmentFile ?? "", "utf8"));
208
+ for (const envName of Object.values(profile?.secret_env ?? {})) {
209
+ if (typeof envName === "string" && process.env[envName])
210
+ redactor.add(process.env[envName]);
211
+ }
212
+ } catch {}
213
+ for (const value of this.outcome?.redact_values ?? [])
214
+ redactor.add(value);
215
+ return redactor;
216
+ }
217
+ async onEnd(_full) {
218
+ const env = rawEnv();
219
+ if (!env.resultFile || !path2.isAbsolute(env.resultFile) || path2.basename(env.resultFile) !== "result.json") {
220
+ console.error("devflow runtime: DEVFLOW_RESULT_FILE missing or invalid; no result written");
221
+ return;
222
+ }
223
+ const runDir = path2.dirname(env.resultFile);
224
+ const artifactDir = path2.join(runDir, "artifacts");
225
+ const redactor = this.baselineRedactor();
226
+ let status = this.outcome?.status ?? "blocked";
227
+ let errorCode = this.outcome ? this.outcome.error_code : this.testCount === 0 ? "runner_not_executed" : "runner_incomplete";
228
+ if (this.outcome?.status === "passed" && this.testStatus !== "passed") {
229
+ status = "blocked";
230
+ errorCode = "runner_error";
231
+ }
232
+ if (this.preexisting) {
233
+ status = "blocked";
234
+ errorCode = "result_file_preexisting";
235
+ }
236
+ if (!this.outcome && this.errors.length) {
237
+ const joined = this.errors.join(`
238
+ `);
239
+ if (/Executable doesn't exist|browserType\.launch/i.test(joined))
240
+ errorCode = "browser_unavailable";
241
+ console.error(`devflow runtime: ${redactor.error(joined)}`);
242
+ }
243
+ const files = [];
244
+ for (const f of this.outcome?.artifact_files ?? [])
245
+ files.push({ abs: path2.resolve(runDir, f.path), kind: f.kind });
246
+ if (status !== "passed") {
247
+ let traceIndex = 0;
248
+ let shotIndex = 0;
249
+ for (const a of this.attachments) {
250
+ if (!a.path || !fs.existsSync(a.path))
251
+ continue;
252
+ if (a.name === "trace") {
253
+ const dest = path2.join(artifactDir, traceIndex === 0 ? "trace.zip" : `trace-${traceIndex}.zip`);
254
+ traceIndex += 1;
255
+ fs.mkdirSync(artifactDir, { recursive: true, mode: 448 });
256
+ fs.copyFileSync(a.path, dest);
257
+ files.push({ abs: dest, kind: "trace" });
258
+ } else if (a.name === "screenshot" || a.contentType === "image/png") {
259
+ const dir = path2.join(artifactDir, "screenshots");
260
+ fs.mkdirSync(dir, { recursive: true, mode: 448 });
261
+ const dest = path2.join(dir, `failure-${++shotIndex}.png`);
262
+ fs.copyFileSync(a.path, dest);
263
+ files.push({ abs: dest, kind: "screenshot" });
264
+ }
265
+ }
266
+ }
267
+ const artifacts = [];
268
+ for (const f of files) {
269
+ let real;
270
+ try {
271
+ real = fs.realpathSync(f.abs);
272
+ } catch {
273
+ continue;
274
+ }
275
+ const stat = fs.lstatSync(f.abs);
276
+ if (!stat.isFile() || !inside(fs.realpathSync(runDir), real))
277
+ continue;
278
+ artifacts.push({ path: path2.relative(runDir, f.abs).split(path2.sep).join("/"), kind: f.kind, ...sha256File(f.abs) });
279
+ }
280
+ const result = {
281
+ schema_version: RESULT_SCHEMA_VERSION,
282
+ origin: RESULT_ORIGIN,
283
+ execution_id: env.executionId ?? null,
284
+ nonce: env.nonce ?? null,
285
+ tc_id: env.tcId ?? null,
286
+ tc_sha256: env.tcSha256 ?? null,
287
+ dsl_sha256: this.outcome?.dsl_sha256 ?? null,
288
+ runtime_version: RUNTIME_VERSION,
289
+ status,
290
+ error_code: errorCode,
291
+ started_at: this.outcome?.started_at ?? this.startedAt,
292
+ finished_at: this.outcome?.finished_at ?? now(),
293
+ steps: (this.outcome?.steps ?? []).map(stripStep),
294
+ cleanup: this.outcome?.cleanup ?? { status: "skipped", errors: [] },
295
+ artifacts
296
+ };
297
+ const text = redactor.text(JSON.stringify(result, null, 2));
298
+ try {
299
+ writeAtomic(env.resultFile, `${text}
300
+ `);
301
+ } catch (err) {
302
+ console.error(`devflow runtime: failed to write result: ${redactor.error(err)}`);
303
+ return;
304
+ }
305
+ console.log(`devflow runtime: status=${status}${errorCode ? ` error_code=${errorCode}` : ""}`);
306
+ }
307
+ }
308
+ export {
309
+ writeAtomic,
310
+ DevflowReporter as default
311
+ };