@dailephd/my-dev-kit-lab 0.4.5 → 0.4.7

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 (263) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/README.md +43 -3
  3. package/dist/scripts/cli.js +9 -0
  4. package/dist/src/audits/core/typescriptJavaScriptAnalyzer.js +30 -12
  5. package/dist/src/browser/index.js +2 -0
  6. package/dist/src/browser/playwrightRuntime.js +74 -0
  7. package/dist/src/browser/types.js +10 -0
  8. package/dist/src/cli/help.js +376 -0
  9. package/dist/src/cli/index.js +2 -0
  10. package/dist/src/cli/runLabCli.js +257 -0
  11. package/dist/src/commands/runAuditCommand.js +132 -0
  12. package/dist/src/commands/runControlledExperimentCommand.js +7 -3
  13. package/dist/{scripts/experiments/describeExperiment.js → src/commands/runExperimentDescribeCommand.js} +14 -10
  14. package/dist/{scripts/experiments/listExperiments.js → src/commands/runExperimentListCommand.js} +3 -6
  15. package/dist/{scripts/experiments/runExperiment.js → src/commands/runExperimentRunCommand.js} +80 -22
  16. package/dist/src/commands/runFinalDemoCommand.js +2 -3
  17. package/dist/src/commands/runSecurityValidationCommand.js +271 -0
  18. package/dist/src/commands/runTutorialRunCommand.js +170 -0
  19. package/dist/src/commands/runTutorialValidateCommand.js +138 -0
  20. package/dist/src/core/processTree.js +52 -0
  21. package/dist/src/core/resolveCommand.js +34 -0
  22. package/dist/src/core/runMeasuredCommand.js +39 -31
  23. package/dist/src/runtime/index.js +4 -0
  24. package/dist/src/runtime/labExecutionContext.js +22 -0
  25. package/dist/src/runtime/managedProcess.js +380 -0
  26. package/dist/src/runtime/packageResource.js +22 -0
  27. package/dist/src/runtime/packageRoot.js +37 -0
  28. package/dist/src/screenshot/captureReportScreenshot.js +30 -27
  29. package/dist/src/securityValidation/packageChecks/requiredPackageContents.js +14 -1
  30. package/dist/src/tutorial/index.js +16 -0
  31. package/dist/src/tutorial/loadTutorialContracts.js +60 -0
  32. package/dist/src/tutorial/markdownTutorialWriter.js +53 -0
  33. package/dist/src/tutorial/runTutorial.js +465 -0
  34. package/dist/src/tutorial/scenarioValidation.js +383 -0
  35. package/dist/src/tutorial/subtitleWriter.js +88 -0
  36. package/dist/src/tutorial/targetContractValidation.js +212 -0
  37. package/dist/src/tutorial/tutorialActions.js +110 -0
  38. package/dist/src/tutorial/tutorialArtifacts.js +176 -0
  39. package/dist/src/tutorial/tutorialAssertions.js +249 -0
  40. package/dist/src/tutorial/tutorialCursor.js +149 -0
  41. package/dist/src/tutorial/tutorialLocators.js +37 -0
  42. package/dist/src/tutorial/tutorialManifest.js +74 -0
  43. package/dist/src/tutorial/tutorialOverlay.js +180 -0
  44. package/dist/src/tutorial/tutorialPaths.js +86 -0
  45. package/dist/src/tutorial/tutorialSession.js +398 -0
  46. package/dist/src/tutorial/types.js +48 -0
  47. package/dist/src/tutorial/validationPrimitives.js +141 -0
  48. package/examples/tutorial-browser/index.html +47 -0
  49. package/examples/tutorial-browser/prepare.mjs +14 -0
  50. package/examples/tutorial-browser/scenario.json +17 -0
  51. package/examples/tutorial-browser/server.mjs +14 -0
  52. package/package.json +13 -9
  53. package/dist/scripts/audits/runAudit.js +0 -135
  54. package/dist/scripts/build-gallery.js +0 -3
  55. package/dist/scripts/capture-demo-report.js +0 -3
  56. package/dist/scripts/evaluate-token-savings.js +0 -2
  57. package/dist/scripts/generate-experiment-plots.js +0 -3
  58. package/dist/scripts/generate-prompt-variants.js +0 -2
  59. package/dist/scripts/render-experiment-report.js +0 -2
  60. package/dist/scripts/report-context-integrity-smoke.js +0 -70
  61. package/dist/scripts/run-agent-prompt.js +0 -2
  62. package/dist/scripts/run-controlled-experiment.js +0 -2
  63. package/dist/scripts/run-lab-demo.js +0 -5
  64. package/dist/scripts/run-visualization-demos.js +0 -3
  65. package/dist/scripts/security/resolveToolRoot.js +0 -16
  66. package/dist/scripts/security/runCodeql.js +0 -58
  67. package/dist/scripts/security/runDependencyChecks.js +0 -58
  68. package/dist/scripts/security/runFuzzSmoke.js +0 -29
  69. package/dist/scripts/security/runPackageChecks.js +0 -57
  70. package/dist/scripts/security/runSemgrep.js +0 -64
  71. package/dist/scripts/security/validate.js +0 -266
  72. package/dist/scripts/verify-benchmarks.js +0 -202
  73. package/examples/demo-report-input.json +0 -78
  74. package/examples/lab-demo-cases.json +0 -35
  75. package/examples/real-agent-campaign-cases.json +0 -118
  76. package/tests/fixtures/android/advanced-security-fixtures/backup-configuration/module-a/src/debug/res/xml/ambiguous_backup_rules.xml +0 -4
  77. package/tests/fixtures/android/advanced-security-fixtures/backup-configuration/module-a/src/main/res/xml/ambiguous_backup_rules.xml +0 -4
  78. package/tests/fixtures/android/advanced-security-fixtures/backup-configuration/module-a/src/main/res/xml/backup_rules.xml +0 -5
  79. package/tests/fixtures/android/advanced-security-fixtures/backup-configuration/module-a/src/main/res/xml/broad_backup_rules.xml +0 -4
  80. package/tests/fixtures/android/advanced-security-fixtures/backup-configuration/module-a/src/main/res/xml/data_extraction_rules.xml +0 -10
  81. package/tests/fixtures/android/advanced-security-fixtures/backup-configuration/module-a/src/main/res/xml/unsupported_domain_rules.xml +0 -4
  82. package/tests/fixtures/android/advanced-security-fixtures/backup-configuration/module-b/src/main/res/xml/malformed_backup_rules.xml +0 -4
  83. package/tests/fixtures/android/advanced-security-fixtures/backup-configuration/module-b/src/main/res/xml/unsupported_root.xml +0 -4
  84. package/tests/fixtures/android/advanced-security-fixtures/network-security/module-a/src/debug/res/xml/ambiguous_config.xml +0 -4
  85. package/tests/fixtures/android/advanced-security-fixtures/network-security/module-a/src/main/res/xml/ambiguous_config.xml +0 -4
  86. package/tests/fixtures/android/advanced-security-fixtures/network-security/module-a/src/main/res/xml/base_cleartext_false.xml +0 -8
  87. package/tests/fixtures/android/advanced-security-fixtures/network-security/module-a/src/main/res/xml/broad_and_duplicate_domains.xml +0 -8
  88. package/tests/fixtures/android/advanced-security-fixtures/network-security/module-a/src/main/res/xml/empty_domain.xml +0 -6
  89. package/tests/fixtures/android/advanced-security-fixtures/network-security/module-a/src/main/res/xml/malformed_pin.xml +0 -11
  90. package/tests/fixtures/android/advanced-security-fixtures/network-security/module-a/src/main/res/xml/network_security_config.xml +0 -26
  91. package/tests/fixtures/android/advanced-security-fixtures/network-security/module-b/src/main/res/xml/malformed_network_security_config.xml +0 -6
  92. package/tests/fixtures/android/advanced-security-fixtures/network-security/module-b/src/main/res/xml/unsupported_root.xml +0 -4
  93. package/tests/fixtures/android/advanced-security-fixtures/release-configuration/groovy-release-debuggable-dynamic.gradle +0 -7
  94. package/tests/fixtures/android/advanced-security-fixtures/release-configuration/groovy-release-debuggable-false.gradle +0 -9
  95. package/tests/fixtures/android/advanced-security-fixtures/release-configuration/groovy-release-debuggable-true.gradle +0 -13
  96. package/tests/fixtures/android/advanced-security-fixtures/release-configuration/kotlin-release-debuggable-false.gradle.kts +0 -7
  97. package/tests/fixtures/android/advanced-security-fixtures/release-configuration/kotlin-release-debuggable-true.gradle.kts +0 -10
  98. package/tests/fixtures/android/advanced-security-fixtures/release-configuration/missing-release-build-type.gradle.kts +0 -7
  99. package/tests/fixtures/android/advanced-security-fixtures/resource-resolution/module-a/src/debug/res/xml/network_security_config.xml +0 -8
  100. package/tests/fixtures/android/advanced-security-fixtures/resource-resolution/module-a/src/main/res/xml/backup_rules.xml +0 -4
  101. package/tests/fixtures/android/advanced-security-fixtures/resource-resolution/module-a/src/main/res/xml/network_security_config.xml +0 -8
  102. package/tests/fixtures/android/advanced-security-fixtures/resource-resolution/module-b/src/main/res/xml/malformed_network_security_config.xml +0 -7
  103. package/tests/fixtures/android/advanced-security-fixtures/secret-candidates/SampleActivity.java +0 -8
  104. package/tests/fixtures/android/advanced-security-fixtures/secret-candidates/SampleActivity.kt +0 -9
  105. package/tests/fixtures/android/advanced-security-fixtures/secret-candidates/build.gradle +0 -11
  106. package/tests/fixtures/android/advanced-security-fixtures/secret-candidates/build.gradle.kts +0 -11
  107. package/tests/fixtures/android/advanced-security-fixtures/secret-candidates/google-services.json +0 -16
  108. package/tests/fixtures/android/advanced-security-fixtures/secret-candidates/local.properties +0 -3
  109. package/tests/fixtures/android/advanced-security-fixtures/secret-candidates-bounds/module/binary.properties +0 -0
  110. package/tests/fixtures/android/advanced-security-fixtures/secret-candidates-bounds/module/oversized.json +0 -1
  111. package/tests/fixtures/android/advanced-security-fixtures/signing-configuration/app/fake-release-keystore.jks +0 -1
  112. package/tests/fixtures/android/advanced-security-fixtures/signing-configuration/build/generated-fake.keystore +0 -1
  113. package/tests/fixtures/android/compose-app/app/build.gradle.kts +0 -21
  114. package/tests/fixtures/android/compose-app/app/src/main/AndroidManifest.xml +0 -22
  115. package/tests/fixtures/android/compose-app/app/src/main/java/com/example/composeapp/MainActivity.kt +0 -11
  116. package/tests/fixtures/android/compose-app/build.gradle.kts +0 -4
  117. package/tests/fixtures/android/compose-app/gradle/wrapper/gradle-wrapper.properties +0 -4
  118. package/tests/fixtures/android/compose-app/settings.gradle.kts +0 -2
  119. package/tests/fixtures/android/gradle-metadata-fixtures/catalog-only-plugin/build.gradle.kts +0 -3
  120. package/tests/fixtures/android/gradle-metadata-fixtures/catalog-only-plugin/gradle/libs.versions.toml +0 -5
  121. package/tests/fixtures/android/gradle-metadata-fixtures/comment-safety.gradle.kts +0 -21
  122. package/tests/fixtures/android/gradle-metadata-fixtures/dynamic-values.gradle.kts +0 -17
  123. package/tests/fixtures/android/gradle-metadata-fixtures/groovy-literal.gradle +0 -23
  124. package/tests/fixtures/android/gradle-metadata-fixtures/wrapper-malformed.properties +0 -4
  125. package/tests/fixtures/android/gradle-metadata-fixtures/wrapper-missing-url.properties +0 -3
  126. package/tests/fixtures/android/gradle-metadata-fixtures/wrapper-with-checksum.properties +0 -5
  127. package/tests/fixtures/android/java-app/app/build.gradle +0 -16
  128. package/tests/fixtures/android/java-app/app/src/main/AndroidManifest.xml +0 -19
  129. package/tests/fixtures/android/java-app/app/src/main/java/com/example/javaapp/MainActivity.java +0 -4
  130. package/tests/fixtures/android/java-app/build.gradle +0 -3
  131. package/tests/fixtures/android/java-app/gradle/wrapper/gradle-wrapper.properties +0 -4
  132. package/tests/fixtures/android/java-app/settings.gradle +0 -2
  133. package/tests/fixtures/android/library/build.gradle.kts +0 -3
  134. package/tests/fixtures/android/library/gradle/wrapper/gradle-wrapper.properties +0 -4
  135. package/tests/fixtures/android/library/mylibrary/build.gradle.kts +0 -13
  136. package/tests/fixtures/android/library/mylibrary/src/main/AndroidManifest.xml +0 -2
  137. package/tests/fixtures/android/library/settings.gradle.kts +0 -2
  138. package/tests/fixtures/android/manifest-audit-fixtures/incomplete-intent-filter.xml +0 -14
  139. package/tests/fixtures/android/manifest-audit-fixtures/malformed-exported.xml +0 -10
  140. package/tests/fixtures/android/manifest-audit-fixtures/malformed.xml +0 -5
  141. package/tests/fixtures/android/manifest-audit-fixtures/missing-application.xml +0 -7
  142. package/tests/fixtures/android/manifest-audit-fixtures/missing-component-name.xml +0 -11
  143. package/tests/fixtures/android/manifest-audit-fixtures/permission-coverage.xml +0 -29
  144. package/tests/fixtures/android/manifest-audit-fixtures/risky-components.xml +0 -62
  145. package/tests/fixtures/android/manifest-audit-fixtures/risky-deep-links.xml +0 -45
  146. package/tests/fixtures/android/manifest-audit-fixtures/unresolved-placeholder.xml +0 -14
  147. package/tests/fixtures/android/manifest-audit-fixtures/unusual-namespace-prefix.xml +0 -11
  148. package/tests/fixtures/android/multi-module/app/build.gradle.kts +0 -22
  149. package/tests/fixtures/android/multi-module/app/src/androidTest/java/com/example/multimodule/app/ExampleInstrumentedTest.kt +0 -3
  150. package/tests/fixtures/android/multi-module/app/src/main/AndroidManifest.xml +0 -11
  151. package/tests/fixtures/android/multi-module/app/src/test/java/com/example/multimodule/app/ExampleUnitTest.kt +0 -3
  152. package/tests/fixtures/android/multi-module/build.gradle.kts +0 -5
  153. package/tests/fixtures/android/multi-module/core/build.gradle.kts +0 -14
  154. package/tests/fixtures/android/multi-module/core/src/main/AndroidManifest.xml +0 -2
  155. package/tests/fixtures/android/multi-module/feature-login/build.gradle.kts +0 -18
  156. package/tests/fixtures/android/multi-module/feature-login/src/main/AndroidManifest.xml +0 -2
  157. package/tests/fixtures/android/multi-module/gradle/libs.versions.toml +0 -8
  158. package/tests/fixtures/android/multi-module/gradle/wrapper/gradle-wrapper.properties +0 -4
  159. package/tests/fixtures/android/multi-module/settings.gradle.kts +0 -4
  160. package/tests/fixtures/android/non-android-gradle/build.gradle.kts +0 -3
  161. package/tests/fixtures/android/non-android-gradle/core/build.gradle.kts +0 -3
  162. package/tests/fixtures/android/non-android-gradle/core/src/main/java/com/example/core/Core.java +0 -4
  163. package/tests/fixtures/android/non-android-gradle/gradle/wrapper/gradle-wrapper.properties +0 -4
  164. package/tests/fixtures/android/non-android-gradle/settings.gradle.kts +0 -2
  165. package/tests/fixtures/android/partial/app/build.gradle.kts +0 -7
  166. package/tests/fixtures/android/partial/settings.gradle.kts +0 -2
  167. package/tests/fixtures/android/xml-view-app/app/build.gradle.kts +0 -17
  168. package/tests/fixtures/android/xml-view-app/app/src/main/AndroidManifest.xml +0 -31
  169. package/tests/fixtures/android/xml-view-app/app/src/main/kotlin/com/example/xmlviewapp/MainActivity.kt +0 -7
  170. package/tests/fixtures/android/xml-view-app/app/src/main/res/layout/activity_main.xml +0 -4
  171. package/tests/fixtures/android/xml-view-app/build.gradle.kts +0 -4
  172. package/tests/fixtures/android/xml-view-app/gradle/wrapper/gradle-wrapper.properties +0 -4
  173. package/tests/fixtures/android/xml-view-app/settings.gradle.kts +0 -2
  174. package/tests/fixtures/audits/mixed-language/mixed-docs-claims/README.md +0 -16
  175. package/tests/fixtures/audits/mixed-language/mixed-docs-claims/build.gradle.kts +0 -4
  176. package/tests/fixtures/audits/mixed-language/mixed-docs-claims/src/main/java/com/example/Widget.java +0 -7
  177. package/tests/fixtures/audits/mixed-language/mixed-docs-claims/src/main/kotlin/com/example/Gadget.kt +0 -7
  178. package/tests/fixtures/audits/mixed-language/mixed-generated-vendor/README.md +0 -10
  179. package/tests/fixtures/audits/mixed-language/mixed-generated-vendor/build/Main.class +0 -1
  180. package/tests/fixtures/audits/mixed-language/mixed-generated-vendor/dist/index.js +0 -1
  181. package/tests/fixtures/audits/mixed-language/mixed-generated-vendor/generated/schema.ts +0 -1
  182. package/tests/fixtures/audits/mixed-language/mixed-generated-vendor/src/index.ts +0 -3
  183. package/tests/fixtures/audits/mixed-language/mixed-generated-vendor/vendor/lib.py +0 -2
  184. package/tests/fixtures/audits/mixed-language/mixed-java-kotlin/README.md +0 -10
  185. package/tests/fixtures/audits/mixed-language/mixed-java-kotlin/build.gradle.kts +0 -8
  186. package/tests/fixtures/audits/mixed-language/mixed-java-kotlin/settings.gradle.kts +0 -1
  187. package/tests/fixtures/audits/mixed-language/mixed-java-kotlin/src/main/java/com/example/FooService.java +0 -7
  188. package/tests/fixtures/audits/mixed-language/mixed-java-kotlin/src/main/kotlin/com/example/BarService.kt +0 -7
  189. package/tests/fixtures/audits/mixed-language/mixed-java-kotlin/src/test/java/com/example/FooServiceTest.java +0 -8
  190. package/tests/fixtures/audits/mixed-language/mixed-java-kotlin/src/test/kotlin/com/example/BarServiceTest.kt +0 -8
  191. package/tests/fixtures/audits/mixed-language/mixed-python-ts/README.md +0 -8
  192. package/tests/fixtures/audits/mixed-language/mixed-python-ts/src/app.py +0 -7
  193. package/tests/fixtures/audits/mixed-language/mixed-python-ts/src/index.ts +0 -3
  194. package/tests/fixtures/audits/mixed-language/mixed-python-ts/tests/test_app.py +0 -5
  195. package/tests/fixtures/audits/mixed-language/mixed-ts-js/README.md +0 -7
  196. package/tests/fixtures/audits/mixed-language/mixed-ts-js/src/helper.js +0 -5
  197. package/tests/fixtures/audits/mixed-language/mixed-ts-js/src/index.ts +0 -3
  198. package/tests/fixtures/audits/mixed-language/mixed-ts-js/tests/index.sample.ts +0 -5
  199. package/tests/fixtures/audits/mixed-language/mixed-ts-python-jvm/README.md +0 -10
  200. package/tests/fixtures/audits/mixed-language/mixed-ts-python-jvm/build.gradle.kts +0 -4
  201. package/tests/fixtures/audits/mixed-language/mixed-ts-python-jvm/pytests/test_app.py +0 -5
  202. package/tests/fixtures/audits/mixed-language/mixed-ts-python-jvm/src/app.py +0 -2
  203. package/tests/fixtures/audits/mixed-language/mixed-ts-python-jvm/src/helper.js +0 -5
  204. package/tests/fixtures/audits/mixed-language/mixed-ts-python-jvm/src/index.ts +0 -3
  205. package/tests/fixtures/audits/mixed-language/mixed-ts-python-jvm/src/main/java/com/example/Multiplier.java +0 -7
  206. package/tests/fixtures/audits/mixed-language/mixed-ts-python-jvm/src/main/kotlin/com/example/Divider.kt +0 -7
  207. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/corrected-replay/derived/run-integrity-evidence.json +0 -99
  208. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/corrected-replay/producer/implementation-audit.json +0 -1585
  209. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/corrected-replay/producer/implementation-capsule.json +0 -11455
  210. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/00-request.txt +0 -1
  211. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/architecture-context-packet.txt +0 -82
  212. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/behavior-model.txt +0 -104
  213. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/final-report.txt +0 -41
  214. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/implementation-context-packet.txt +0 -114
  215. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/implementation-report.txt +0 -92
  216. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/judge-report.txt +0 -34
  217. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/pseudocode-packet.txt +0 -244
  218. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/request-brief.txt +0 -40
  219. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/test-context-packet.txt +0 -93
  220. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/test-implementation-report.txt +0 -69
  221. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/test-strategy-packet.txt +0 -354
  222. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/artifacts/verification-report.txt +0 -85
  223. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/derived/run-integrity-evidence.json +0 -98
  224. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/producer/architecture-audit.json +0 -1169
  225. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/producer/architecture-request.json +0 -29
  226. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/producer/implementation-audit.json +0 -1494
  227. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/producer/implementation-capsule.json +0 -11364
  228. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/producer/implementation-request.json +0 -33
  229. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/producer/test-request.json +0 -74
  230. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/reports/architecture-context-retrieval-report.txt +0 -58
  231. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/reports/implementation-context-retrieval-report.txt +0 -75
  232. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/reports/test-context-retrieval-report.txt +0 -84
  233. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/run.json +0 -62
  234. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/tool-versions/my-dev-kit-version.txt +0 -1
  235. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/failed-run/tool-versions/orchestrator-version.txt +0 -1
  236. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/manifests/corrected-replay-manifest.json +0 -19
  237. package/tests/fixtures/ecosystem/context-integrity/v0.4.5/manifests/failed-run-manifest.json +0 -56
  238. package/tests/fixtures/fake-adversarial-cli.js +0 -152
  239. package/tests/fixtures/fake-my-dev-kit-cli.js +0 -83
  240. package/tests/fixtures/full-workflow-library/complete-v1.0.0.json +0 -24
  241. package/tests/fixtures/full-workflow-library/future-minor-v1.1.0-additive.json +0 -25
  242. package/tests/fixtures/stage-context-expectations/complete-v1.0.0.json +0 -230
  243. package/tests/fixtures/stage-context-expectations/future-minor-v1.1.0-additive.json +0 -232
  244. package/tests/fixtures/stage-context-expectations/invalid/malformed-json.txt +0 -1
  245. package/tests/fixtures/stage-context-expectations/invalid/non-object-root.json +0 -1
  246. package/tests/fixtures/stage-context-expectations/minimal-v1.0.0.json +0 -18
  247. package/tests/fixtures/upstream-artifacts/invalid/malformed-json.txt +0 -1
  248. package/tests/fixtures/upstream-artifacts/invalid/non-object-root.json +0 -1
  249. package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.2/context-capsule/complete-v1.0.0.json +0 -504
  250. package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.2/context-capsule/future-minor-v1.1.0-additive.json +0 -955
  251. package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.2/retrieval-audit-record/complete-v1.0.0.json +0 -190
  252. package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.2/retrieval-audit-record/future-minor-v1.1.0-additive.json +0 -327
  253. package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.4/PROVENANCE.txt +0 -18
  254. package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.4/context-capsule/complete-v1.0.0.json +0 -556
  255. package/tests/fixtures/upstream-artifacts/my-dev-kit/1.10.4/retrieval-audit-record/complete-v1.0.0.json +0 -238
  256. package/tests/fixtures/upstream-artifacts/my-dev-kit-1.10.2-identity/PROVENANCE.txt +0 -13
  257. package/tests/fixtures/upstream-artifacts/my-dev-kit-1.10.2-identity/context-capsule.json +0 -7874
  258. package/tests/fixtures/upstream-artifacts/my-dev-kit-1.10.2-identity/retrieval-audit-record.json +0 -1076
  259. package/tests/fixtures/upstream-artifacts/my-dev-kit-orchestrator/1.2.1/workflow-instruction-packet/complete-v1.0.0.json +0 -160
  260. package/tests/fixtures/upstream-artifacts/my-dev-kit-orchestrator/1.2.1/workflow-instruction-packet/future-minor-v1.1.0-additive.json +0 -186
  261. package/tests/fixtures/upstream-artifacts/my-dev-kit-orchestrator/1.2.3/run-integrity/PROVENANCE.txt +0 -31
  262. package/tests/fixtures/upstream-artifacts/my-dev-kit-orchestrator/1.2.3/run-integrity/ready-pass-final-pass.json +0 -132
  263. package/tests/fixtures/upstream-artifacts/my-dev-kit-orchestrator/1.2.3/run-integrity/refresh-required-need-context.json +0 -146
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  All notable changes to my-dev-kit-lab are documented here.
4
4
 
5
+ ## [0.4.7] - 2026-09-18
6
+
7
+ The v0.4.7 implementation adds generic declarative browser tutorial automation while preserving product-specific demo ownership outside this repository.
8
+
9
+ - Added the shared Playwright browser runtime, managed local process lifecycle/readiness, and persistent tutorial browser sessions.
10
+ - Added strict `TutorialScenarioV1` and `TutorialTargetContractV1` contracts with bounded locators, actions, and assertions.
11
+ - Added tutorial-only cursor/click feedback, highlights, callouts, WebM recording, step screenshots, SRT/VTT subtitles, Markdown, and `tutorial-manifest.json`.
12
+ - Added installed `tutorial validate` and `tutorial run` routes, an exact Playwright runtime dependency, and the packaged generic `examples/tutorial-browser/` fixture.
13
+ - Extended exact packed-tarball clean-consumer acceptance to validate tutorial help/contracts, browser-unavailable behavior without auto-download, real Chromium execution, canonical artifacts, manifest boundaries, workspace routing, and package/example immutability.
14
+ - v0.4.7 was released after cross-platform CI, security validation, code-rot audit, package validation, and packed-package acceptance passed.
15
+
16
+ ## [0.4.6] - 2026-08-29
17
+
18
+ Installed-package CLI and runtime-boundary correction. `@dailephd/my-dev-kit-lab` now ships a supported, cross-platform installed CLI (`my-dev-kit-lab`) alongside the existing contributor npm scripts.
19
+
20
+ - Added a compiled, cross-platform installed CLI router (`dist/scripts/cli.js`, `src/cli/runLabCli.ts`) exposing `my-dev-kit-lab --help`/`--version`, `security validate`, `audit`, the `experiment` family (`list`/`describe`/`run`/`controlled`), `report render`, `plots generate`, `gallery build`, and `demo final`, plus the historical direct final-demo invocation form for backward compatibility. A global `--workspace <path>` option is supported before any subcommand.
21
+ - Added a `LabExecutionContext` runtime foundation (`src/runtime/`) distinguishing `invocationCwd`, read-only `packageRoot` (discovered independent of `process.cwd()`), writable `workspaceRoot` (default `<home>/.my-dev-kit-lab`, overridable with `--workspace`), `resourceRoot`, and the separately resolved inspected target root, plus cwd-independent, containment-checked package-resource resolution.
22
+ - `security validate`, `audit`, and `experiment` npm scripts now delegate to shared `src/commands/` owners also used by the installed CLI, so both surfaces run the same implementation. Installed `audit`/`security validate` default implicit report output under the writable workspace instead of the package root; installed `experiment run`'s implicit output is under the workspace's `lab-output/experiments/` tree. Explicit output paths and all target-resolution semantics are unchanged.
23
+ - Added a permanent packed-tarball installation/execution acceptance gate (`npm run verify:packed-package`): builds, runs a real `npm pack`, installs the exact tarball into a clean temporary consumer project, executes the installed binary, and verifies default/explicit workspace output and target/installed-package immutability via recursive SHA-256 snapshot comparison.
24
+ - Fixed an installed-runtime defect the acceptance gate surfaced: the TypeScript/JavaScript audit source-facts analyzer imported the `typescript` devDependency eagerly at module load, so even `--help` required it in a clean install; it now loads lazily, only when a source file is actually analyzed. Detector output is unchanged.
25
+ - Reconciled the npm package `files` allowlist against proven installed-runtime requirements: narrowed `dist/scripts/` to the two files the installed CLI and legacy bin target need, narrowed `examples/` to the one file an installed command reads by default, and removed `tests/fixtures/` (developer/test-only, not read by any installed command). `benchmarks/` and `docs/METRICS.md` remain packaged.
26
+ - Raised `engines.node` to `>=24`. Standardized GitHub Actions CI on Node `24` and `latest` across Ubuntu/macOS/Windows, and switched the pre-release readiness workflow from a hard-coded Node version to Node `latest`; both workflows run the packed-package acceptance gate.
27
+ - Resolved a transitive devDependency vulnerability (nanoid, GHSA-2v37-7h3g-55p8) via a lockfile-only update; the published runtime dependency tree was unaffected throughout.
28
+ - No security check, security verdict rule, audit detector, Android behavior, experiment scoring, report schema, or existing CLI syntax changed.
29
+
5
30
  ## [0.4.5] - 2026-08-01
6
31
 
7
32
  Context-integrity validation for the published my-dev-kit v1.10.4 and my-dev-kit-orchestrator v1.2.3 contracts.
@@ -24,7 +49,7 @@ Context-integrity validation for the published my-dev-kit v1.10.4 and my-dev-kit
24
49
 
25
50
  ## [0.4.3] - 2026-07-22
26
51
 
27
- `v0.4.3` (stage-specific bounded-context and workflow-instruction evaluation) is published. `v0.4.4` is the current release. Its complete scope, dependencies, exclusions, and acceptance criteria are preserved in [docs/ROADMAP.md](docs/ROADMAP.md).
52
+ `v0.4.3` (stage-specific bounded-context and workflow-instruction evaluation) was published and was later superseded by `v0.4.4`. Its complete scope, dependencies, exclusions, and acceptance criteria are preserved in [docs/ROADMAP.md](docs/ROADMAP.md).
28
53
 
29
54
  ### Added
30
55
 
package/README.md CHANGED
@@ -4,7 +4,9 @@ my-dev-kit-lab is the experiment, audit, and evidence companion for [my-dev-kit]
4
4
 
5
5
  my-dev-kit provides local repository indexing and graph-guided retrieval. my-dev-kit-lab supplies the controlled benchmarks, agent adapters, metrics, security checks, and reports needed to evaluate when that retrieval is useful. Results are evidence for a specific target and configuration; they do not guarantee token savings or security.
6
6
 
7
- The latest published release is v0.4.5 (context-integrity validation), compatible with published `@dailephd/my-dev-kit@1.10.4` and `@dailephd/my-dev-kit-orchestrator@1.2.3`. See [docs/CURRENT_STATE.md](docs/CURRENT_STATE.md).
7
+ The latest published release is v0.4.7 (declarative browser tutorial and video automation). It adds bounded browser scenarios, persistent tutorial sessions, synchronized runtime artifacts, and a packaged generic example while preserving product-specific demo ownership outside this repository. The v0.4.5 context-integrity evaluation remains intentionally frozen against the published `@dailephd/my-dev-kit@1.10.4` and `@dailephd/my-dev-kit-orchestrator@1.2.3` contracts; those versions are historical validation baselines, not a statement that they are the ecosystem's current releases. See [docs/CURRENT_STATE.md](docs/CURRENT_STATE.md).
8
+
9
+ v0.4.6 adds a supported `my-dev-kit-lab` installed CLI router (`--help`, `--version`, `security validate`, `audit`, the `experiment` family, `report render`, `plots generate`, `gallery build`, `demo final`, and the historical direct final-demo invocation form), a writable lab workspace model kept separate from the installed package and the inspected target, and a permanent packed-tarball installation/execution acceptance gate (`npm run verify:packed-package`). See [docs/ROADMAP.md](docs/ROADMAP.md) and [docs/CURRENT_STATE.md](docs/CURRENT_STATE.md) for status detail and [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for the runtime path model. The "Installed CLI" section below documents the shipped command surface; the source-checkout `npm run` workflow in Quickstart remains available for contributors.
8
10
 
9
11
  ## Current capabilities
10
12
 
@@ -13,11 +15,48 @@ The latest published release is v0.4.5 (context-integrity validation), compatibl
13
15
  - **Validate CLI/package security:** inspect dependencies, package contents, path and subprocess boundaries, malformed inputs, optional static scanners, and bounded fuzz targets.
14
16
  - **Validate Android projects:** run nineteen static checks by default, with Gradle operations, external tools, and network access available only through explicit opt-in flags.
15
17
  - **Review evidence:** generate JSON and HTML reports, SVG plots, optional screenshots, visualization demos, and a static gallery.
18
+ - **Generate declarative browser tutorials:** validate and execute bounded local browser scenarios with WebM recording, step screenshots, SRT/VTT subtitles, Markdown, and a tutorial manifest. Tutorial execution requires a compatible locally installed Chromium; see [docs/COMMANDS.md](docs/COMMANDS.md) and [docs/TUTORIAL.md](docs/TUTORIAL.md) for details.
16
19
  - **Evaluate stage-context strategies:** compare the two legacy strategies against six additional bounded stage-context strategies — `architecture-context-only`, `architecture-plus-implementation-refresh`, `architecture-plus-implementation-and-test-refresh`, `full-workflow-library`, `bounded-workflow-instruction-packet`, and `combined-bounded-stage-context` — selected through programmatic configuration, not CLI flags. Each strategy's evidence is reported through bounded `report.json`, `report.html`, and `report.txt` output with an explicit `available`/`unavailable`/`not-applicable` metric-availability model and no composite score, grade, ranking, or winning strategy.
17
20
  - **Evaluate the producer-readiness bridge (v0.4.4):** optionally extend `combined-bounded-stage-context` with the frozen my-dev-kit-orchestrator supplemental implementation/test-context packet and retrieval-report documents plus an observed readiness result, all supplied programmatically (there is no CLI flag), to measure owner, allocation, truncation-cause, supplemental/raw agreement, readiness-agreement, and criticality-overlay evidence without reimplementing upstream owner-selection, allocation, producer-parity, or readiness policy.
18
21
  - **Evaluate context integrity (v0.4.5):** compare condition-aware producer evidence from my-dev-kit v1.10.4 (role condition coverage, allocation/spillover, required-evidence-loss) against my-dev-kit-orchestrator v1.2.3 run-integrity evidence (run-integrity gate, judge integrity, final-report eligibility, artifact lifecycle state), reporting agreement or contradiction between them rather than re-deriving a verdict. Evaluation runs against a frozen, hash-verified regression fixture pair — a byte-exact real historical failed run and a hand-distilled corrected-replay counterpart representing the same validated contracts — and is programmatic/test-driven only. `npm run report:context-integrity-smoke` renders both fixtures' reports for manual inspection; it takes no arguments and is a developer convenience, not a configurable evaluation CLI.
19
22
 
20
- ## Quickstart
23
+ ## Installed CLI
24
+
25
+ Installing or invoking the package (for example via `npm install -g @dailephd/my-dev-kit-lab` or `npx @dailephd/my-dev-kit-lab@<version>`) exposes one `my-dev-kit-lab` binary. Users do not need to clone this repository to use these commands. The installed CLI requires Node `>=24`.
26
+
27
+ ```
28
+ my-dev-kit-lab --help
29
+ my-dev-kit-lab --version
30
+
31
+ my-dev-kit-lab security validate [options]
32
+ my-dev-kit-lab audit [options]
33
+
34
+ my-dev-kit-lab experiment list
35
+ my-dev-kit-lab experiment describe --experiment <id>
36
+ my-dev-kit-lab experiment run --experiment <id> [options]
37
+ my-dev-kit-lab experiment controlled [options]
38
+
39
+ my-dev-kit-lab report render [options]
40
+ my-dev-kit-lab plots generate [options]
41
+ my-dev-kit-lab gallery build [options]
42
+ my-dev-kit-lab demo final [options]
43
+ my-dev-kit-lab tutorial validate --scenario <path> [--target-contract <path>] [--json]
44
+ my-dev-kit-lab tutorial run --scenario <path> --target-contract <path> [--out <dir>] [--json]
45
+ ```
46
+
47
+ A global `--workspace <path>` option, placed before the command, selects the writable lab workspace. The default workspace, used when `--workspace` is omitted, is `<home>/.my-dev-kit-lab`. Generated reports and experiment output are written under the workspace by default, never under the installed package directory or an inspected `--target` project. Explicit output paths (`--out`, and similar flags) keep their existing resolution behavior and are never redirected under the workspace.
48
+
49
+ The historical direct final-demo invocation form — the same flags `demo final` accepts, without the `demo final` prefix — continues to work for backward compatibility.
50
+
51
+ Low-level developer helpers (`security:deps`, `security:package`, `security:codeql`, `security:semgrep`, fuzz smoke, visualization demos, build/test/verify) are not part of the installed CLI. They remain source-checkout contributor workflows; see below.
52
+
53
+ See [docs/COMMANDS.md](docs/COMMANDS.md) for full command syntax and flags.
54
+
55
+ Tutorial runs keep the scenario source, disposable target, logs, browser recording, and generated artifacts separate. The canonical generic example is packaged at `examples/tutorial-browser/`; product-specific demo sites and scenarios remain owned by their product repositories.
56
+
57
+ ## Quickstart (contributor / source-checkout workflow)
58
+
59
+ The commands in this section run from a cloned repository checkout and are the contributor/development workflow. They are not required to use the installed CLI documented above.
21
60
 
22
61
  ### Install
23
62
 
@@ -169,12 +208,13 @@ See [docs/METRICS.md](docs/METRICS.md) for full metric definitions.
169
208
  - The published upstream artifacts the stage-context strategies read do not expose considered-but-unselected reads or unnecessary-read evidence; those metrics report `unavailable` rather than zero
170
209
  - The v0.4.4 producer-readiness bridge is released. All bridge inputs are programmatic — there is no CLI flag. The coordinated upstream releases my-dev-kit@1.10.3 and orchestrator@1.2.2 were verified published before lab publication.
171
210
  - The v0.4.5 context-integrity evaluation is released. It has no CLI flags, no plots/screenshot/gallery integration, and produces no composite score, grade, ranking, or winner. Its corrected-replay fixture is a hand-distilled representation of the validated my-dev-kit v1.10.4 and my-dev-kit-orchestrator v1.2.3 contracts, not a live capture of a complete ten-stage workflow. The orchestrator agreement evidence does not read a literal upstream `promptMode` field; `stageMayRenderNormalPrompt`, derived from structured blocked-stage evidence, is the bounded substitute used instead.
211
+ - v0.4.7 adds declarative browser tutorial validation and execution with bounded actions/assertions, persistent Chromium sessions, WebM, screenshots, SRT/VTT, Markdown, and `tutorial-manifest.json`. Chromium is a separate local runtime prerequisite; the package does not download browser binaries automatically. Gallery consumption remains future scope.
172
212
 
173
213
  ---
174
214
 
175
215
  ## Security validation
176
216
 
177
- `npm run security:validate` is the standalone security-validation command. It checks local CLI/package boundaries and can inspect another local project with `--target <path>`. The generic audit command can reuse those results through `--types security`, but it does not replace the standalone validator or its reports.
217
+ `npm run security:validate` (contributor/source-checkout) and `my-dev-kit-lab security validate` (installed CLI) both call the same standalone security-validation command owner. It checks local CLI/package boundaries and can inspect another local project with `--target <path>`. The generic audit command can reuse those results through `--types security`, but it does not replace the standalone validator or its reports.
178
218
 
179
219
  Android validation uses `--profile android`. Its default path is static and non-destructive: it starts zero Gradle processes, zero external tools, and zero network operations. Only confirmed `SecurityFinding` records can become audit issues; Android `CandidateEvidence` remains review-only evidence.
180
220
 
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import { runLabCli } from "../src/cli/index.js";
3
+ try {
4
+ process.exitCode = await runLabCli(process.argv.slice(2));
5
+ }
6
+ catch (error) {
7
+ console.error(error instanceof Error ? error.message : String(error));
8
+ process.exitCode = 1;
9
+ }
@@ -1,4 +1,3 @@
1
- import ts from "typescript";
2
1
  // ---------------------------------------------------------------------------
3
2
  // v0.3.1 Batch 3 -- TypeScript/JavaScript source analyzer.
4
3
  //
@@ -36,7 +35,25 @@ export const TYPESCRIPT_JAVASCRIPT_ANALYZER = {
36
35
  supportedExtensions: SUPPORTED_EXTENSIONS,
37
36
  analyzeFile,
38
37
  };
39
- function analyzeFile(input) {
38
+ // v0.4.6 Batch 5 -- the `typescript` package is a devDependency, not a
39
+ // runtime dependency: an installed my-dev-kit-lab consumer does not have it.
40
+ // The compiler API is loaded lazily (once, memoized) only when a file is
41
+ // actually analyzed, rather than imported at module scope, so merely
42
+ // loading this module (which happens on every CLI invocation, since the
43
+ // language analyzer registry is wired in unconditionally) never requires
44
+ // `typescript` to be present. Only the *type* import above is needed at the
45
+ // top level -- type-only imports are erased entirely at compile time.
46
+ let cachedTypeScriptModule;
47
+ async function loadTypeScript() {
48
+ if (!cachedTypeScriptModule) {
49
+ const imported = await import("typescript");
50
+ cachedTypeScriptModule =
51
+ imported.default ??
52
+ imported;
53
+ }
54
+ return cachedTypeScriptModule;
55
+ }
56
+ async function analyzeFile(input) {
40
57
  const { relativePath, language, role, content, inventoryEntry } = input;
41
58
  if (Buffer.byteLength(content, "utf8") > MAX_ANALYZABLE_BYTES) {
42
59
  return {
@@ -61,17 +78,18 @@ function analyzeFile(input) {
61
78
  ],
62
79
  };
63
80
  }
64
- const scriptKind = resolveScriptKind(inventoryEntry.extension);
81
+ const ts = await loadTypeScript();
82
+ const scriptKind = resolveScriptKind(ts, inventoryEntry.extension);
65
83
  const sourceFile = ts.createSourceFile(relativePath, content, ts.ScriptTarget.Latest, true, scriptKind);
66
- const diagnostics = getSyntaxDiagnostics(relativePath, sourceFile);
84
+ const diagnostics = getSyntaxDiagnostics(ts, relativePath, sourceFile);
67
85
  const imports = [];
68
86
  const exports = [];
69
87
  const declarations = [];
70
88
  const references = [];
71
89
  const lineOf = (node) => sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1;
72
90
  function pushDeclaration(node, name, kind) {
73
- const isExported = hasModifier(node, ts.SyntaxKind.ExportKeyword);
74
- const isDefault = hasModifier(node, ts.SyntaxKind.DefaultKeyword);
91
+ const isExported = hasModifier(ts, node, ts.SyntaxKind.ExportKeyword);
92
+ const isDefault = hasModifier(ts, node, ts.SyntaxKind.DefaultKeyword);
75
93
  if (name) {
76
94
  declarations.push({ name, kind, exported: isExported, line: lineOf(node) });
77
95
  }
@@ -141,7 +159,7 @@ function analyzeFile(input) {
141
159
  exports.push({ name, kind: "default", line: lineOf(node) });
142
160
  }
143
161
  function handleVariableStatement(node) {
144
- const isExported = hasModifier(node, ts.SyntaxKind.ExportKeyword);
162
+ const isExported = hasModifier(ts, node, ts.SyntaxKind.ExportKeyword);
145
163
  const isConst = (node.declarationList.flags & ts.NodeFlags.Const) !== 0;
146
164
  for (const decl of node.declarationList.declarations) {
147
165
  // Destructuring patterns (`const { a, b } = x`) are conservatively
@@ -247,7 +265,7 @@ function analyzeFile(input) {
247
265
  diagnostics,
248
266
  };
249
267
  }
250
- function resolveScriptKind(extension) {
268
+ function resolveScriptKind(ts, extension) {
251
269
  switch (extension) {
252
270
  case ".tsx":
253
271
  return ts.ScriptKind.TSX;
@@ -264,7 +282,7 @@ function resolveScriptKind(extension) {
264
282
  return ts.ScriptKind.TS;
265
283
  }
266
284
  }
267
- function hasModifier(node, kind) {
285
+ function hasModifier(ts, node, kind) {
268
286
  if (!ts.canHaveModifiers(node))
269
287
  return false;
270
288
  const modifiers = ts.getModifiers(node);
@@ -280,11 +298,11 @@ function hasModifier(node, kind) {
280
298
  // transpileModule() over this repo's own ~375 TS/JS files, which matters
281
299
  // because collectSourceFacts.ts calls this analyzer once per eligible file
282
300
  // on every audit run (including this repo's own self-audit).
283
- function getSyntaxDiagnostics(relativePath, sourceFile) {
301
+ function getSyntaxDiagnostics(ts, relativePath, sourceFile) {
284
302
  const parseDiagnostics = sourceFile.parseDiagnostics ?? [];
285
- return parseDiagnostics.map((diagnostic) => toSourceFactDiagnostic(relativePath, diagnostic));
303
+ return parseDiagnostics.map((diagnostic) => toSourceFactDiagnostic(ts, relativePath, diagnostic));
286
304
  }
287
- function toSourceFactDiagnostic(relativePath, diagnostic) {
305
+ function toSourceFactDiagnostic(ts, relativePath, diagnostic) {
288
306
  const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
289
307
  const line = diagnostic.file && diagnostic.start !== undefined
290
308
  ? diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start).line + 1
@@ -0,0 +1,2 @@
1
+ export * from "./types.js";
2
+ export * from "./playwrightRuntime.js";
@@ -0,0 +1,74 @@
1
+ export const DEFAULT_BROWSER_HEADLESS = true;
2
+ /**
3
+ * Message fragments that identify a genuinely missing Chromium/browser binary.
4
+ *
5
+ * This is an intentionally closed list carried over unchanged from the v0.4.6
6
+ * screenshot classifier so existing skip/fail behavior is preserved exactly. It
7
+ * is not a general-purpose error classifier and must not be broadened into one.
8
+ */
9
+ export const MISSING_BROWSER_RUNTIME_MESSAGE_FRAGMENTS = [
10
+ "Executable doesn't exist",
11
+ "browserType.launch",
12
+ "playwright install",
13
+ "Failed to launch",
14
+ "Could not find Chrome",
15
+ "ENOENT"
16
+ ];
17
+ export function isMissingBrowserRuntimeError(error) {
18
+ const message = errorMessage(error);
19
+ return MISSING_BROWSER_RUNTIME_MESSAGE_FRAGMENTS.some((fragment) => message.includes(fragment));
20
+ }
21
+ export async function loadPlaywrightModule() {
22
+ return (await import("playwright"));
23
+ }
24
+ /**
25
+ * Launches Chromium and classifies the three outcomes callers care about.
26
+ *
27
+ * Returns a structured result rather than throwing for the two expected
28
+ * environment states (module missing, browser binary missing), because every
29
+ * current and planned consumer has to make its own policy decision about them.
30
+ * This function owns no consumer-specific status names or warning text.
31
+ */
32
+ export async function launchChromium(options = {}) {
33
+ const loadPlaywright = options.loadPlaywright ?? loadPlaywrightModule;
34
+ const headless = options.headless ?? DEFAULT_BROWSER_HEADLESS;
35
+ let playwright;
36
+ try {
37
+ playwright = await loadPlaywright();
38
+ }
39
+ catch (error) {
40
+ return {
41
+ status: "unavailable",
42
+ reason: "playwright-module-unavailable",
43
+ error: errorMessage(error)
44
+ };
45
+ }
46
+ try {
47
+ const browser = await playwright.chromium.launch({ headless });
48
+ return { status: "launched", browser };
49
+ }
50
+ catch (error) {
51
+ if (isMissingBrowserRuntimeError(error)) {
52
+ return {
53
+ status: "unavailable",
54
+ reason: "browser-runtime-unavailable",
55
+ error: errorMessage(error)
56
+ };
57
+ }
58
+ return { status: "failed", error: errorMessage(error) };
59
+ }
60
+ }
61
+ /**
62
+ * Best-effort cleanup shared by every browser consumer. Closing a browser that
63
+ * is already gone, or whose transport already failed, must never mask the error
64
+ * the caller is actually reporting.
65
+ */
66
+ export async function closeBrowserQuietly(browser) {
67
+ if (!browser) {
68
+ return;
69
+ }
70
+ await browser.close().catch(() => undefined);
71
+ }
72
+ export function errorMessage(error) {
73
+ return error instanceof Error ? error.message : String(error);
74
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Minimal structural types for the parts of Playwright this repository actually
3
+ * uses. They exist so production code and tests can depend on a narrow shape
4
+ * instead of the full Playwright type surface, and so a fake runtime can be
5
+ * injected without installing a browser.
6
+ *
7
+ * These are deliberately generic: they describe a browser runtime, not report
8
+ * screenshots and not tutorials.
9
+ */
10
+ export {};