testeiya 0.2.1 → 0.3.1-5.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 (405) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +325 -171
  3. package/dist/prompt/context.js +79 -0
  4. package/dist/prompt/context.js.map +1 -0
  5. package/dist/prompt/index.js +60 -0
  6. package/dist/prompt/index.js.map +1 -0
  7. package/dist/prompt/print.js +30 -0
  8. package/dist/prompt/print.js.map +1 -0
  9. package/dist/prompt/project-info.js +2 -0
  10. package/dist/prompt/project-info.js.map +1 -0
  11. package/{src/prompt/system-prompt.ts → dist/prompt/system-prompt.js} +38 -25
  12. package/dist/prompt/system-prompt.js.map +1 -0
  13. package/dist/prompt/testomatio.js +264 -0
  14. package/dist/prompt/testomatio.js.map +1 -0
  15. package/dist/prompt/tools.js +70 -0
  16. package/dist/prompt/tools.js.map +1 -0
  17. package/dist/prompt/vocab.js +8 -0
  18. package/dist/prompt/vocab.js.map +1 -0
  19. package/dist/src/args.js +224 -0
  20. package/dist/src/args.js.map +1 -0
  21. package/dist/src/cli.js +105 -0
  22. package/dist/src/cli.js.map +1 -0
  23. package/dist/src/doctor.js +171 -0
  24. package/dist/src/doctor.js.map +1 -0
  25. package/dist/src/env.js +103 -0
  26. package/dist/src/env.js.map +1 -0
  27. package/dist/src/mcp-extension.js +9 -0
  28. package/dist/src/mcp-extension.js.map +1 -0
  29. package/dist/src/mcp.js +139 -0
  30. package/dist/src/mcp.js.map +1 -0
  31. package/dist/src/model.js +71 -0
  32. package/dist/src/model.js.map +1 -0
  33. package/dist/src/models.js +38 -0
  34. package/dist/src/models.js.map +1 -0
  35. package/dist/src/output.js +216 -0
  36. package/dist/src/output.js.map +1 -0
  37. package/dist/src/result.js +41 -0
  38. package/dist/src/result.js.map +1 -0
  39. package/dist/src/run.js +313 -0
  40. package/dist/src/run.js.map +1 -0
  41. package/dist/src/session.js +98 -0
  42. package/dist/src/session.js.map +1 -0
  43. package/dist/src/sessions.js +72 -0
  44. package/dist/src/sessions.js.map +1 -0
  45. package/dist/src/skills.js +130 -0
  46. package/dist/src/skills.js.map +1 -0
  47. package/dist/vendor/mcp.js +14801 -0
  48. package/mcp-tools.json +2967 -0
  49. package/package.json +34 -43
  50. package/prompt/context.ts +101 -0
  51. package/prompt/index.ts +102 -0
  52. package/prompt/print.ts +32 -0
  53. package/prompt/project-info.ts +30 -0
  54. package/prompt/system-prompt.ts +187 -0
  55. package/{src/prompt → prompt}/testomatio.ts +120 -9
  56. package/prompt/tools.ts +72 -0
  57. package/prompt/vocab.ts +7 -0
  58. package/skills/codeceptjs/ci-fix-tests/SKILL.md +7 -8
  59. package/skills/codeceptjs/codeceptjs-auth/SKILL.md +47 -64
  60. package/skills/codeceptjs/codeceptjs-exploration/SKILL.md +56 -47
  61. package/skills/codeceptjs/codeceptjs-fundamentals/SKILL.md +144 -106
  62. package/skills/codeceptjs/codeceptjs-run-analysis/SKILL.md +50 -57
  63. package/skills/codeceptjs/debugging-codeceptjs-tests/SKILL.md +88 -196
  64. package/skills/codeceptjs/migrate-codeceptjs-4/SKILL.md +4 -5
  65. package/skills/codeceptjs/migrate-cypress-to-codeceptjs/SKILL.md +25 -36
  66. package/skills/codeceptjs/migrate-protractor-to-codeceptjs/SKILL.md +23 -36
  67. package/skills/codeceptjs/migrate-selenium-java-to-codeceptjs/SKILL.md +23 -36
  68. package/skills/codeceptjs/migrate-testcafe-to-codeceptjs/SKILL.md +23 -35
  69. package/skills/codeceptjs/refactoring-codeceptjs-tests/SKILL.md +50 -53
  70. package/skills/codeceptjs/writing-codeceptjs-tests/SKILL.md +87 -191
  71. package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/SKILL.md +1 -1
  72. package/{skills.lock.json → skills/skills.lock.json} +45 -37
  73. package/skills/skills.yaml +35 -0
  74. package/skills/testomatio/explorbot/explorbot-fundamentals/SKILL.md +49 -61
  75. package/skills/testomatio/explorbot/explorbot-fundamentals/references/no-install.md +36 -0
  76. package/skills/testomatio/explorbot/explorbot-plan/SKILL.md +20 -7
  77. package/skills/testomatio/explorbot/explorbot-setup/SKILL.md +41 -289
  78. package/skills/testomatio/explorbot/prima/SKILL.md +87 -0
  79. package/skills/testomatio/qa-process/qa-explain-behavior/SKILL.md +111 -0
  80. package/skills/testomatio/qa-process/qa-explain-behavior/references/answer-shapes.md +116 -0
  81. package/skills/testomatio/qa-process/qa-explain-behavior/references/examples.md +157 -0
  82. package/skills/testomatio/qa-process/qa-lead-strategy-advisor/SKILL.md +91 -0
  83. package/skills/testomatio/qa-process/qa-lead-strategy-advisor/references/output-format.md +71 -0
  84. package/skills/testomatio/qa-process/testing-workflow/SKILL.md +227 -0
  85. package/skills/testomatio/test-automation/qa-data-seeder/SKILL.md +83 -0
  86. package/skills/testomatio/test-automation/run-tests-with-testomatio-reporter/SKILL.md +5 -3
  87. package/skills/testomatio/test-automation/setup-change-aware-pr-testing/SKILL.md +190 -0
  88. package/skills/testomatio/test-automation/setup-ci-automation/SKILL.md +76 -0
  89. package/skills/testomatio/test-management/qa-split-testing-levels-pyramid/SKILL.md +55 -0
  90. package/skills/testomatio/test-management/qa-sprint-report-by-testomatio/SKILL.md +220 -0
  91. package/skills/testomatio/test-management/qa-sprint-report-by-testomatio/references/qa-sprint-report.md +126 -0
  92. package/skills/testomatio/test-management/qa-test-code-coverage/SKILL.md +1 -1
  93. package/skills/testomatio/test-management/qa-thinking/SKILL.md +25 -25
  94. package/skills/testomatio/test-management/testomatio-mcp/SKILL.md +14 -1
  95. package/skills/testomatio/test-management/testomatio-mcp/references/MCP_SETUP.md +8 -0
  96. package/assets/testeiya-logo-dark.svg +0 -16
  97. package/assets/testeiya-logo.svg +0 -15
  98. package/models.catalog.json +0 -6963
  99. package/skills/playwright-best-practices-skill/LICENSE.md +0 -7
  100. package/skills/playwright-best-practices-skill/README.md +0 -147
  101. package/skills/testeiya/README.md +0 -29
  102. package/skills/testeiya/answer-formatting/SKILL.md +0 -30
  103. package/skills/testeiya/check-cucumber/SKILL.md +0 -200
  104. package/skills/testeiya/check-tests/SKILL.md +0 -260
  105. package/skills/testeiya/manual-run-assistant/SKILL.md +0 -61
  106. package/skills/testeiya/testomatio-docs/INDEX.md +0 -175
  107. package/skills/testeiya/testomatio-docs/SKILL.md +0 -102
  108. package/skills/testeiya/testomatio-docs/docs/advanced/ai-powered-features/ai-agents.md +0 -144
  109. package/skills/testeiya/testomatio-docs/docs/advanced/ai-powered-features/ai-powered-features.md +0 -531
  110. package/skills/testeiya/testomatio-docs/docs/advanced/ai-powered-features/ai-requirements.md +0 -437
  111. package/skills/testeiya/testomatio-docs/docs/advanced/api-access/index.md +0 -191
  112. package/skills/testeiya/testomatio-docs/docs/advanced/branches-folder/index.md +0 -277
  113. package/skills/testeiya/testomatio-docs/docs/advanced/bulk-edit-folder/bulk-edit-demos.mdx +0 -39
  114. package/skills/testeiya/testomatio-docs/docs/advanced/bulk-edit-folder/bulk-edit-on-suite-and-test-level.md +0 -122
  115. package/skills/testeiya/testomatio-docs/docs/advanced/bulk-edit-folder/what-is-bulk-edit.md +0 -170
  116. package/skills/testeiya/testomatio-docs/docs/advanced/jira-plugin/branches.md +0 -53
  117. package/skills/testeiya/testomatio-docs/docs/advanced/jira-plugin/index.mdx +0 -98
  118. package/skills/testeiya/testomatio-docs/docs/advanced/jira-plugin/jira-issue.md +0 -151
  119. package/skills/testeiya/testomatio-docs/docs/advanced/jira-plugin/runs-and-reports.md +0 -377
  120. package/skills/testeiya/testomatio-docs/docs/advanced/jira-plugin/work-in-jira.md +0 -267
  121. package/skills/testeiya/testomatio-docs/docs/advanced/living-doc/index.md +0 -138
  122. package/skills/testeiya/testomatio-docs/docs/advanced/milestones/index.md +0 -220
  123. package/skills/testeiya/testomatio-docs/docs/advanced/shortcuts/index.md +0 -48
  124. package/skills/testeiya/testomatio-docs/docs/advanced/tags-labels/labels-and-custom-fields.md +0 -201
  125. package/skills/testeiya/testomatio-docs/docs/advanced/tags-labels/tags-or-labels.md +0 -94
  126. package/skills/testeiya/testomatio-docs/docs/advanced/tags-labels/tags.md +0 -243
  127. package/skills/testeiya/testomatio-docs/docs/advanced/test-artifacts/index.md +0 -135
  128. package/skills/testeiya/testomatio-docs/docs/advanced/tql/index.md +0 -394
  129. package/skills/testeiya/testomatio-docs/docs/getting-started/index.md +0 -290
  130. package/skills/testeiya/testomatio-docs/docs/integrations/continuous-integration/azure.md +0 -96
  131. package/skills/testeiya/testomatio-docs/docs/integrations/continuous-integration/bamboo.md +0 -94
  132. package/skills/testeiya/testomatio-docs/docs/integrations/continuous-integration/bitbucket.md +0 -106
  133. package/skills/testeiya/testomatio-docs/docs/integrations/continuous-integration/circle.md +0 -115
  134. package/skills/testeiya/testomatio-docs/docs/integrations/continuous-integration/github.md +0 -120
  135. package/skills/testeiya/testomatio-docs/docs/integrations/continuous-integration/gitlab.md +0 -88
  136. package/skills/testeiya/testomatio-docs/docs/integrations/continuous-integration/index.mdx +0 -151
  137. package/skills/testeiya/testomatio-docs/docs/integrations/continuous-integration/jenkins.md +0 -121
  138. package/skills/testeiya/testomatio-docs/docs/integrations/continuous-integration/teamcity.md +0 -96
  139. package/skills/testeiya/testomatio-docs/docs/integrations/issues-management/azure.md +0 -31
  140. package/skills/testeiya/testomatio-docs/docs/integrations/issues-management/clickup.md +0 -54
  141. package/skills/testeiya/testomatio-docs/docs/integrations/issues-management/confluence.md +0 -34
  142. package/skills/testeiya/testomatio-docs/docs/integrations/issues-management/github.md +0 -31
  143. package/skills/testeiya/testomatio-docs/docs/integrations/issues-management/gitlab.md +0 -93
  144. package/skills/testeiya/testomatio-docs/docs/integrations/issues-management/index.md +0 -131
  145. package/skills/testeiya/testomatio-docs/docs/integrations/issues-management/jira.md +0 -164
  146. package/skills/testeiya/testomatio-docs/docs/integrations/issues-management/linear.md +0 -29
  147. package/skills/testeiya/testomatio-docs/docs/integrations/issues-management/shortcut.md +0 -67
  148. package/skills/testeiya/testomatio-docs/docs/integrations/issues-management/youtrack.md +0 -94
  149. package/skills/testeiya/testomatio-docs/docs/integrations/report-notifications/azure-devops.md +0 -53
  150. package/skills/testeiya/testomatio-docs/docs/integrations/report-notifications/email.md +0 -71
  151. package/skills/testeiya/testomatio-docs/docs/integrations/report-notifications/jira.md +0 -52
  152. package/skills/testeiya/testomatio-docs/docs/integrations/report-notifications/ms-teams.md +0 -60
  153. package/skills/testeiya/testomatio-docs/docs/integrations/report-notifications/rules.md +0 -267
  154. package/skills/testeiya/testomatio-docs/docs/integrations/report-notifications/slack.md +0 -82
  155. package/skills/testeiya/testomatio-docs/docs/integrations/report-notifications/telegram.md +0 -73
  156. package/skills/testeiya/testomatio-docs/docs/integrations/scim-provisioning/index.mdx +0 -207
  157. package/skills/testeiya/testomatio-docs/docs/integrations/scim-provisioning/okta.md +0 -204
  158. package/skills/testeiya/testomatio-docs/docs/integrations/single-sign-on/azure.md +0 -95
  159. package/skills/testeiya/testomatio-docs/docs/integrations/single-sign-on/google.md +0 -75
  160. package/skills/testeiya/testomatio-docs/docs/integrations/single-sign-on/index.mdx +0 -33
  161. package/skills/testeiya/testomatio-docs/docs/integrations/single-sign-on/okta.md +0 -108
  162. package/skills/testeiya/testomatio-docs/docs/integrations/single-sign-on/saml.md +0 -66
  163. package/skills/testeiya/testomatio-docs/docs/legal/compliance/gdpr.md +0 -95
  164. package/skills/testeiya/testomatio-docs/docs/legal/compliance/index.mdx +0 -94
  165. package/skills/testeiya/testomatio-docs/docs/legal/compliance/privacy.md +0 -26
  166. package/skills/testeiya/testomatio-docs/docs/legal/compliance/terms.md +0 -32
  167. package/skills/testeiya/testomatio-docs/docs/legal/security/index.mdx +0 -242
  168. package/skills/testeiya/testomatio-docs/docs/legal/security/jira.md +0 -140
  169. package/skills/testeiya/testomatio-docs/docs/legal/security/subprocessors.md +0 -76
  170. package/skills/testeiya/testomatio-docs/docs/management/company/administration.md +0 -363
  171. package/skills/testeiya/testomatio-docs/docs/management/company/audit-log.md +0 -41
  172. package/skills/testeiya/testomatio-docs/docs/management/company/plan-features-comparison.md +0 -240
  173. package/skills/testeiya/testomatio-docs/docs/management/company/subscriptions.md +0 -326
  174. package/skills/testeiya/testomatio-docs/docs/management/company/trials.md +0 -75
  175. package/skills/testeiya/testomatio-docs/docs/management/company/users-and-permissions/accountant.md +0 -49
  176. package/skills/testeiya/testomatio-docs/docs/management/company/users-and-permissions/index.mdx +0 -285
  177. package/skills/testeiya/testomatio-docs/docs/management/company/users-and-permissions/read-only-user.md +0 -67
  178. package/skills/testeiya/testomatio-docs/docs/management/company/users-and-permissions/teams.md +0 -138
  179. package/skills/testeiya/testomatio-docs/docs/management/project/settings.md +0 -87
  180. package/skills/testeiya/testomatio-docs/docs/management/project/templates.md +0 -546
  181. package/skills/testeiya/testomatio-docs/docs/project/analytics/index.md +0 -326
  182. package/skills/testeiya/testomatio-docs/docs/project/import-export/export-tests/classical-tests-markdown-format.md +0 -386
  183. package/skills/testeiya/testomatio-docs/docs/project/import-export/export-tests/download-manual-tests-as-files.md +0 -378
  184. package/skills/testeiya/testomatio-docs/docs/project/import-export/export-tests/export-to-obsidian.md +0 -112
  185. package/skills/testeiya/testomatio-docs/docs/project/import-export/export-tests/export-to-spreadsheet.md +0 -127
  186. package/skills/testeiya/testomatio-docs/docs/project/import-export/import/auto-import.md +0 -63
  187. package/skills/testeiya/testomatio-docs/docs/project/import-export/import/import-tests-from-Allure-TestOps.md +0 -49
  188. package/skills/testeiya/testomatio-docs/docs/project/import-export/import/import-tests-from-QTest.md +0 -41
  189. package/skills/testeiya/testomatio-docs/docs/project/import-export/import/import-tests-from-Qase.md +0 -39
  190. package/skills/testeiya/testomatio-docs/docs/project/import-export/import/import-tests-from-Zephyr.md +0 -37
  191. package/skills/testeiya/testomatio-docs/docs/project/import-export/import/import-tests-from-csv-xlsx.md +0 -117
  192. package/skills/testeiya/testomatio-docs/docs/project/import-export/import/import-tests-from-cucumber.md +0 -93
  193. package/skills/testeiya/testomatio-docs/docs/project/import-export/import/import-tests-from-qmetry.md +0 -44
  194. package/skills/testeiya/testomatio-docs/docs/project/import-export/import/import-tests-from-source-code.md +0 -117
  195. package/skills/testeiya/testomatio-docs/docs/project/import-export/import/import-tests-from-testcaselabs.md +0 -44
  196. package/skills/testeiya/testomatio-docs/docs/project/import-export/import/import-tests-from-testmo.md +0 -47
  197. package/skills/testeiya/testomatio-docs/docs/project/import-export/import/import-tests-from-testrail.md +0 -82
  198. package/skills/testeiya/testomatio-docs/docs/project/import-export/import/import-tests-from-xray.md +0 -55
  199. package/skills/testeiya/testomatio-docs/docs/project/plans/index.md +0 -334
  200. package/skills/testeiya/testomatio-docs/docs/project/pulse/index.md +0 -104
  201. package/skills/testeiya/testomatio-docs/docs/project/runs/archive-runs-and-groups.md +0 -176
  202. package/skills/testeiya/testomatio-docs/docs/project/runs/custom-statuses.md +0 -195
  203. package/skills/testeiya/testomatio-docs/docs/project/runs/environments.md +0 -203
  204. package/skills/testeiya/testomatio-docs/docs/project/runs/managing-runs.md +0 -455
  205. package/skills/testeiya/testomatio-docs/docs/project/runs/merge-strategies.md +0 -137
  206. package/skills/testeiya/testomatio-docs/docs/project/runs/reports.md +0 -329
  207. package/skills/testeiya/testomatio-docs/docs/project/runs/rungroups.md +0 -342
  208. package/skills/testeiya/testomatio-docs/docs/project/runs/running-automated-tests.md +0 -256
  209. package/skills/testeiya/testomatio-docs/docs/project/runs/running-manual-and-automated-tests.md +0 -331
  210. package/skills/testeiya/testomatio-docs/docs/project/runs/running-tests-manually.md +0 -633
  211. package/skills/testeiya/testomatio-docs/docs/project/runs/temporary-tests-notes.md +0 -223
  212. package/skills/testeiya/testomatio-docs/docs/project/steps-snippets/snippets.md +0 -68
  213. package/skills/testeiya/testomatio-docs/docs/project/steps-snippets/steps.md +0 -181
  214. package/skills/testeiya/testomatio-docs/docs/project/tests/bdd-test-case-editor.md +0 -98
  215. package/skills/testeiya/testomatio-docs/docs/project/tests/classical-test-case-editor.md +0 -354
  216. package/skills/testeiya/testomatio-docs/docs/project/tests/classical-vs-bdd.md +0 -169
  217. package/skills/testeiya/testomatio-docs/docs/project/tests/copy-and-move-your-tests.md +0 -156
  218. package/skills/testeiya/testomatio-docs/docs/project/tests/other-features-for-test-case-design.md +0 -412
  219. package/skills/testeiya/testomatio-docs/docs/project/tests/test-case-creation-and-editing.md +0 -527
  220. package/skills/testeiya/testomatio-docs/docs/support/index.md +0 -75
  221. package/skills/testeiya/testomatio-docs/docs/test-reporting/artifacts.md +0 -388
  222. package/skills/testeiya/testomatio-docs/docs/test-reporting/cli.md +0 -215
  223. package/skills/testeiya/testomatio-docs/docs/test-reporting/configuration.md +0 -247
  224. package/skills/testeiya/testomatio-docs/docs/test-reporting/frameworks.md +0 -490
  225. package/skills/testeiya/testomatio-docs/docs/test-reporting/functions.md +0 -144
  226. package/skills/testeiya/testomatio-docs/docs/test-reporting/index.mdx +0 -48
  227. package/skills/testeiya/testomatio-docs/docs/test-reporting/junit.md +0 -248
  228. package/skills/testeiya/testomatio-docs/docs/test-reporting/logger.md +0 -138
  229. package/skills/testeiya/testomatio-docs/docs/test-reporting/php.md +0 -77
  230. package/skills/testeiya/testomatio-docs/docs/test-reporting/pipes/bitbucket.md +0 -72
  231. package/skills/testeiya/testomatio-docs/docs/test-reporting/pipes/csv.md +0 -23
  232. package/skills/testeiya/testomatio-docs/docs/test-reporting/pipes/debug.md +0 -18
  233. package/skills/testeiya/testomatio-docs/docs/test-reporting/pipes/github.md +0 -63
  234. package/skills/testeiya/testomatio-docs/docs/test-reporting/pipes/gitlab.md +0 -29
  235. package/skills/testeiya/testomatio-docs/docs/test-reporting/pipes/html.md +0 -80
  236. package/skills/testeiya/testomatio-docs/docs/test-reporting/pipes/index.mdx +0 -57
  237. package/skills/testeiya/testomatio-docs/docs/test-reporting/pipes/testomatio.md +0 -331
  238. package/skills/testeiya/testomatio-docs/docs/test-reporting/python.md +0 -229
  239. package/skills/testeiya/testomatio-docs/docs/test-reporting/workflows.md +0 -325
  240. package/skills/testeiya/testomatio-docs/docs/tutorials/Interacting-via-API.md +0 -159
  241. package/skills/testeiya/testomatio-docs/docs/tutorials/Manual-Testing-Classic.md +0 -164
  242. package/skills/testeiya/testomatio-docs/docs/tutorials/Set-Up-Read-Only-Access.md +0 -85
  243. package/skills/testeiya/testomatio-docs/docs/tutorials/Using-AI-in-Testing.md +0 -163
  244. package/skills/testeiya/testomatio-docs/docs/tutorials/Working-with-Jira.md +0 -125
  245. package/skills/testeiya/testomatio-docs/docs/tutorials/java.md +0 -478
  246. package/skills/testeiya/testomatio-docs/docs/tutorials/playwright.md +0 -207
  247. package/skills/testeiya/testomatio-docs/docs/tutorials/webdriver.md +0 -218
  248. package/skills/testeiya/testomatio-docs/docs.lock.json +0 -6
  249. package/skills/testeiya/testomatio-reporter/SKILL.md +0 -307
  250. package/skills/testomatio/test-automation/setup-pr-testing/SKILL.md +0 -199
  251. package/skills.yaml +0 -21
  252. package/src/ai-debug.ts +0 -188
  253. package/src/api/agent-get.ts +0 -22
  254. package/src/api/agent-start.ts +0 -384
  255. package/src/api/client-log.ts +0 -29
  256. package/src/api/context.ts +0 -332
  257. package/src/api/debug-layout.ts +0 -47
  258. package/src/api/debug-report.ts +0 -29
  259. package/src/api/debug-snapshot.ts +0 -30
  260. package/src/api/debug-stream.ts +0 -52
  261. package/src/api/files-delete.ts +0 -184
  262. package/src/api/files-read.ts +0 -41
  263. package/src/api/files-rename.ts +0 -99
  264. package/src/api/files-tree.ts +0 -292
  265. package/src/api/files-write.ts +0 -41
  266. package/src/api/mcp.ts +0 -603
  267. package/src/api/memory.ts +0 -69
  268. package/src/api/open-external.ts +0 -39
  269. package/src/api/playwright-cli.ts +0 -606
  270. package/src/api/providers.ts +0 -457
  271. package/src/api/read-env-token.ts +0 -33
  272. package/src/api/sessions.ts +0 -79
  273. package/src/api/settings.ts +0 -120
  274. package/src/api/skills.ts +0 -58
  275. package/src/api/testomatio-attachment.ts +0 -89
  276. package/src/api/testomatio-auth.ts +0 -284
  277. package/src/api/testomatio-proxy.ts +0 -197
  278. package/src/api/testomatio-run-stats.ts +0 -81
  279. package/src/api/testomatio-target.ts +0 -225
  280. package/src/api/testomatio-transcription.ts +0 -82
  281. package/src/api/workspace-search.ts +0 -96
  282. package/src/api/workspace-sync.ts +0 -151
  283. package/src/api/workspace.ts +0 -165
  284. package/src/app-server.ts +0 -556
  285. package/src/bridge.ts +0 -251
  286. package/src/check-tests.ts +0 -156
  287. package/src/cli.ts +0 -17
  288. package/src/commands.ts +0 -244
  289. package/src/config.ts +0 -183
  290. package/src/connection.ts +0 -658
  291. package/src/context-store.ts +0 -265
  292. package/src/debug-bus.ts +0 -405
  293. package/src/extensions/tool-gate.ts +0 -220
  294. package/src/extensions/webui/ask-channel.ts +0 -52
  295. package/src/extensions/webui/index.ts +0 -184
  296. package/src/extensions/webui/tools/ask-question.ts +0 -88
  297. package/src/extensions/webui/tools/query-result.ts +0 -79
  298. package/src/extensions/webui/tools/render-chart.ts +0 -53
  299. package/src/extensions/webui/tools/render-item.ts +0 -61
  300. package/src/extensions/webui/tools/render-list.ts +0 -170
  301. package/src/extensions/webui/tools/render-result.ts +0 -85
  302. package/src/extensions/webui/tools/render-tree.ts +0 -71
  303. package/src/extensions/webui/tools/ui-widget.ts +0 -54
  304. package/src/extensions/webui/tools/widget-result.ts +0 -13
  305. package/src/extensions/webui/widget-channel.ts +0 -50
  306. package/src/file-log.ts +0 -196
  307. package/src/git-tracked.ts +0 -68
  308. package/src/gitignore.ts +0 -53
  309. package/src/json-store.ts +0 -43
  310. package/src/load-env.ts +0 -70
  311. package/src/loader-style.ts +0 -96
  312. package/src/main.ts +0 -140
  313. package/src/mcp-catalog.ts +0 -96
  314. package/src/models-catalog.ts +0 -72
  315. package/src/permissions.ts +0 -120
  316. package/src/project-dir.ts +0 -189
  317. package/src/project-info.ts +0 -108
  318. package/src/prompt/app-ui.ts +0 -59
  319. package/src/prompt/browser.ts +0 -27
  320. package/src/prompt/index.ts +0 -62
  321. package/src/prompt/tools.ts +0 -27
  322. package/src/server-info.ts +0 -62
  323. package/src/session-factory.ts +0 -442
  324. package/src/session-store.ts +0 -115
  325. package/src/shell-env.ts +0 -45
  326. package/src/skills.ts +0 -163
  327. package/src/sync-snapshot.ts +0 -140
  328. package/src/telemetry.ts +0 -239
  329. package/src/testomatio-auth.ts +0 -299
  330. package/src/testomatio.ts +0 -98
  331. package/src/theme.ts +0 -30
  332. package/src/user-env.ts +0 -94
  333. package/src/welcome.ts +0 -194
  334. package/src/workspace/safe-path.ts +0 -85
  335. package/src/workspace/test-md.ts +0 -70
  336. package/src/workspace-model.ts +0 -440
  337. package/testeiya.config.json +0 -14
  338. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/advanced/authentication-flows.md +0 -0
  339. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/advanced/authentication.md +0 -0
  340. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/advanced/clock-mocking.md +0 -0
  341. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/advanced/mobile-testing.md +0 -0
  342. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/advanced/multi-context.md +0 -0
  343. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/advanced/multi-user.md +0 -0
  344. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/advanced/network-advanced.md +0 -0
  345. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/advanced/third-party.md +0 -0
  346. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/architecture/pom-vs-fixtures.md +0 -0
  347. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/architecture/test-architecture.md +0 -0
  348. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/architecture/when-to-mock.md +0 -0
  349. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/browser-apis/browser-apis.md +0 -0
  350. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/browser-apis/iframes.md +0 -0
  351. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/browser-apis/service-workers.md +0 -0
  352. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/browser-apis/websockets.md +0 -0
  353. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/core/annotations.md +0 -0
  354. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/core/assertions-waiting.md +0 -0
  355. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/core/configuration.md +0 -0
  356. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/core/fixtures-hooks.md +0 -0
  357. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/core/global-setup.md +0 -0
  358. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/core/locators.md +0 -0
  359. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/core/page-object-model.md +0 -0
  360. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/core/projects-dependencies.md +0 -0
  361. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/core/test-data.md +0 -0
  362. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/core/test-suite-structure.md +0 -0
  363. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/core/test-tags.md +0 -0
  364. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/debugging/console-errors.md +0 -0
  365. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/debugging/debugging.md +0 -0
  366. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/debugging/error-testing.md +0 -0
  367. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/debugging/flaky-tests.md +0 -0
  368. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/frameworks/angular.md +0 -0
  369. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/frameworks/nextjs.md +0 -0
  370. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/frameworks/react.md +0 -0
  371. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/frameworks/vue.md +0 -0
  372. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/infrastructure-ci-cd/ci-cd.md +0 -0
  373. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/infrastructure-ci-cd/docker.md +0 -0
  374. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/infrastructure-ci-cd/github-actions.md +0 -0
  375. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/infrastructure-ci-cd/gitlab.md +0 -0
  376. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/infrastructure-ci-cd/other-providers.md +0 -0
  377. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/infrastructure-ci-cd/parallel-sharding.md +0 -0
  378. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/infrastructure-ci-cd/performance.md +0 -0
  379. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/infrastructure-ci-cd/reporting.md +0 -0
  380. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/infrastructure-ci-cd/test-coverage.md +0 -0
  381. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/testing-patterns/accessibility.md +0 -0
  382. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/testing-patterns/api-testing.md +0 -0
  383. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/testing-patterns/browser-extensions.md +0 -0
  384. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/testing-patterns/canvas-webgl.md +0 -0
  385. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/testing-patterns/component-testing.md +0 -0
  386. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/testing-patterns/drag-drop.md +0 -0
  387. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/testing-patterns/electron.md +0 -0
  388. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/testing-patterns/file-operations.md +0 -0
  389. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/testing-patterns/file-upload-download.md +0 -0
  390. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/testing-patterns/forms-validation.md +0 -0
  391. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/testing-patterns/graphql-testing.md +0 -0
  392. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/testing-patterns/i18n.md +0 -0
  393. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/testing-patterns/performance-testing.md +0 -0
  394. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/testing-patterns/security-testing.md +0 -0
  395. /package/skills/{playwright-best-practices-skill → playwright/playwright-best-practices}/testing-patterns/visual-regression.md +0 -0
  396. /package/skills/{playwright-cli → playwright/playwright-cli}/SKILL.md +0 -0
  397. /package/skills/{playwright-cli → playwright/playwright-cli}/references/element-attributes.md +0 -0
  398. /package/skills/{playwright-cli → playwright/playwright-cli}/references/playwright-tests.md +0 -0
  399. /package/skills/{playwright-cli → playwright/playwright-cli}/references/request-mocking.md +0 -0
  400. /package/skills/{playwright-cli → playwright/playwright-cli}/references/running-code.md +0 -0
  401. /package/skills/{playwright-cli → playwright/playwright-cli}/references/session-management.md +0 -0
  402. /package/skills/{playwright-cli → playwright/playwright-cli}/references/storage-state.md +0 -0
  403. /package/skills/{playwright-cli → playwright/playwright-cli}/references/test-generation.md +0 -0
  404. /package/skills/{playwright-cli → playwright/playwright-cli}/references/tracing.md +0 -0
  405. /package/skills/{playwright-cli → playwright/playwright-cli}/references/video-recording.md +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B,MAAM,UAAU,mBAAmB,CAAC,OAAkB;IACpD,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,gBAAgB;QACvB,WAAW,EACT,yEAAyE;YACzE,yEAAyE;YACzE,2EAA2E;YAC3E,0EAA0E;YAC1E,6EAA6E;QAC/E,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC;YACtB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE;gBAC/D,WAAW,EAAE,2DAA2D;aACzE,CAAC;YACF,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;gBAClB,WAAW,EACT,qEAAqE;oBACrE,qDAAqD;aACxD,CAAC;SACH,CAAC;QACF,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM;YAC/B,MAAM,CAAC,GAAG,MAAqD,CAAC;YAChE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;YAC1B,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;YAC1B,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,aAAa,CAAC,CAAC,MAAM,2BAA2B,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG;qBAC3E;iBACF;gBACD,OAAO,EAAE,CAAC;aACX,CAAC;QACJ,CAAC;KACgB,CAAC;AACtB,CAAC;AAED,SAAS,OAAO,CAAC,MAAuB;IACtC,IAAI,MAAM,KAAK,MAAM;QAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,313 @@
1
+ import { existsSync, statSync } from "node:fs";
2
+ import { readFile } from "node:fs/promises";
3
+ import { chalkStderr as c } from "chalk";
4
+ import { VERSION } from "./env.js";
5
+ import { hasTestomatio } from "./mcp.js";
6
+ import { UsageError } from "./model.js";
7
+ import { decorate, defaultFooter, deliver, markdownPath, modelName, } from "./output.js";
8
+ import { shortId } from "./sessions.js";
9
+ import { createTesteiyaSession } from "./session.js";
10
+ import { expandSkills } from "./skills.js";
11
+ export async function runPrint(options) {
12
+ const started = Date.now();
13
+ const result = {};
14
+ const outputPath = markdownPath(options.destinations);
15
+ const stampBefore = fileStamp(outputPath);
16
+ const cwd = process.cwd();
17
+ let created;
18
+ try {
19
+ created = await createTesteiyaSession({
20
+ cwd,
21
+ result,
22
+ sessionManager: options.sessionManager,
23
+ model: options.model,
24
+ outputFile: outputPath,
25
+ brief: options.brief,
26
+ ...connectionOptions(),
27
+ });
28
+ }
29
+ catch (err) {
30
+ // A misconfigured model or missing key is bad usage (exit 2), not a failed
31
+ // run — cli.ts turns it into that. Everything else is a failed run.
32
+ if (err instanceof UsageError)
33
+ throw err;
34
+ note(c.red(` ✗ ${errorText(err)}`));
35
+ return 1;
36
+ }
37
+ const { session, model, skills } = created;
38
+ const task = expandSkills(options.prompt, skills);
39
+ process.on("SIGINT", () => {
40
+ note(c.yellow("\n ⨯ interrupted"));
41
+ void session.abort().finally(() => process.exit(130));
42
+ });
43
+ // With nothing but stdout to write to, the answer is the output: one line of
44
+ // run info on stderr, no banner in front of it.
45
+ const verbose = options.destinations.some((destination) => destination.kind !== "stdout");
46
+ if (verbose) {
47
+ note(` Testeiya ${c.dim(`v${VERSION}`)} ${c.dim("·")} ${model} ${c.dim("·")} ${cwd}`);
48
+ note(c.dim(` ${skills.length} skills`));
49
+ if (task.loaded.length > 0)
50
+ note(c.dim(` ↳ ${task.loaded.join(", ")}`));
51
+ for (const line of describe(options.destinations))
52
+ note(c.dim(` → ${line}`));
53
+ note("");
54
+ }
55
+ const run = watchRun(session);
56
+ await promptOnce(session, task.prompt, run);
57
+ const written = await collectReport(session, run, outputPath, stampBefore, result.status);
58
+ const report = sign(written, options, model);
59
+ run.unsubscribe();
60
+ if (verbose)
61
+ note("");
62
+ let code = exitCode(run.error, result.status, Boolean(outputPath), report, options.exitZero);
63
+ const envelope = {
64
+ status: result.status ?? (code === 0 ? "pass" : "fail"),
65
+ reason: result.reason ?? run.error,
66
+ report,
67
+ reportPath: outputPath ?? null,
68
+ model,
69
+ steps: run.steps,
70
+ tokens: { input: run.input, output: run.output },
71
+ durationMs: Date.now() - started,
72
+ sessionId: options.sessionId ?? null,
73
+ };
74
+ // Nobody is watching this run, so the status goes above the answer rather
75
+ // than after it: the last thing on screen should be the agent's output.
76
+ summarize({ run, result, envelope, started });
77
+ if (willPrint(options.destinations, report)) {
78
+ note(c.dim(` ${"─".repeat(rule())}`));
79
+ note("");
80
+ }
81
+ const failure = await deliver(options.destinations, envelope);
82
+ if (failure) {
83
+ note(` ${c.red(`✗ ${failure}`)}`);
84
+ // The report is worth more than the destination: never lose it.
85
+ if (report)
86
+ process.stdout.write(report);
87
+ code = 1;
88
+ }
89
+ await session.dispose();
90
+ return code;
91
+ }
92
+ export function exitCode(error, status, wantsReport, report, exitZero) {
93
+ if (error)
94
+ return 1;
95
+ // --exit-zero only forgives the verdict. A run that broke still broke, and a
96
+ // pipeline that reads the envelope still sees status "fail".
97
+ if (exitZero)
98
+ return 0;
99
+ if (status === "fail")
100
+ return 1;
101
+ if (wantsReport && !report)
102
+ return 1;
103
+ return 0;
104
+ }
105
+ // The header and footer go wherever the report goes, so they are added once,
106
+ // before anything is delivered.
107
+ function sign(report, options, model) {
108
+ if (!report)
109
+ return report;
110
+ return decorate(report, { header: options.header, footer: footerFor(options, model) });
111
+ }
112
+ // Every report says what wrote it, until someone says otherwise.
113
+ function footerFor(options, model) {
114
+ if (options.footer !== undefined)
115
+ return options.footer;
116
+ if (options.noDefaultFooter)
117
+ return undefined;
118
+ if (process.env.TESTEIYA_NO_DEFAULT_FOOTER)
119
+ return undefined;
120
+ return defaultFooter(model);
121
+ }
122
+ // A tool name alone says the run is alive and nothing else. The command or the
123
+ // path is what a watcher actually reads.
124
+ function target(args) {
125
+ if (!args || typeof args !== "object")
126
+ return "";
127
+ const values = args;
128
+ const raw = text(values.command) || text(values.pattern) || text(values.path);
129
+ if (!raw)
130
+ return "";
131
+ let line = raw.split("\n")[0].trim();
132
+ const cwd = `${process.cwd()}/`;
133
+ if (line.startsWith(cwd))
134
+ line = line.slice(cwd.length);
135
+ if (line.length <= 64)
136
+ return line;
137
+ return `${line.slice(0, 63)}…`;
138
+ }
139
+ function text(value) {
140
+ if (typeof value === "string")
141
+ return value;
142
+ return "";
143
+ }
144
+ function pad(name) {
145
+ return name.padEnd(6);
146
+ }
147
+ function rule() {
148
+ const width = process.stderr.columns ?? 60;
149
+ return Math.max(20, Math.min(width - 4, 68));
150
+ }
151
+ // Only rule off the status when something actually follows it on stdout.
152
+ function willPrint(destinations, report) {
153
+ return destinations.some((destination) => {
154
+ if (destination.kind === "json" && !destination.path)
155
+ return true;
156
+ return destination.kind === "stdout" && Boolean(report);
157
+ });
158
+ }
159
+ function describe(destinations) {
160
+ const lines = [];
161
+ for (const destination of destinations) {
162
+ if (destination.kind === "markdown")
163
+ lines.push(destination.path);
164
+ if (destination.kind === "json")
165
+ lines.push(destination.path ?? "stdout (json)");
166
+ if (destination.kind === "gh")
167
+ lines.push(`pull request #${destination.pr}`);
168
+ }
169
+ return lines;
170
+ }
171
+ // A project token in the environment is the CLI's whole notion of a connection:
172
+ // no slugs, nothing pulled per project. `tokenAvailable` renders the section
173
+ // that says exactly that, and the TMS rules alongside it.
174
+ function connectionOptions() {
175
+ if (!hasTestomatio())
176
+ return {};
177
+ return {
178
+ connection: { tokenAvailable: true },
179
+ backendUrl: process.env.TESTOMATIO_URL,
180
+ };
181
+ }
182
+ function watchRun(session) {
183
+ const run = { steps: 0, input: 0, output: 0, error: null, unsubscribe: () => { } };
184
+ run.unsubscribe = session.subscribe((event) => {
185
+ if (event.type === "tool_execution_start") {
186
+ run.steps++;
187
+ note(` ${c.dim("▸")} ${c.cyan(pad(event.toolName))} ${c.dim(target(event.args))}`);
188
+ }
189
+ if (event.type === "tool_execution_end" && event.isError) {
190
+ note(` ${c.red("✗")} ${c.red(pad(event.toolName))}`);
191
+ }
192
+ if (event.type === "turn_end" && event.message.role === "assistant") {
193
+ run.input += event.message.usage.input;
194
+ run.output += event.message.usage.output;
195
+ run.error = null;
196
+ if (event.message.stopReason === "error") {
197
+ run.error = event.message.errorMessage || "The model request failed.";
198
+ }
199
+ }
200
+ if (event.type === "agent_end" && event.willRetry) {
201
+ run.error = null;
202
+ }
203
+ });
204
+ return run;
205
+ }
206
+ async function promptOnce(session, text, run) {
207
+ try {
208
+ await session.prompt(text, { expandPromptTemplates: false });
209
+ }
210
+ catch (err) {
211
+ run.error = errorText(err);
212
+ }
213
+ }
214
+ async function collectReport(session, run, path, before, status) {
215
+ if (run.error)
216
+ return null;
217
+ if (!path)
218
+ return lastAssistantText(session);
219
+ const report = await readIfFresh(path, before);
220
+ if (report)
221
+ return report;
222
+ if (status === "fail")
223
+ return null;
224
+ return nudgeForReport(session, run, path, before);
225
+ }
226
+ async function nudgeForReport(session, run, path, before) {
227
+ note(c.yellow(" ⟳ report missing, asking once more"));
228
+ await promptOnce(session, `You have not written the report to ${path} yet. Write it now with the write tool: ` +
229
+ `the complete report in markdown, nothing else.`, run);
230
+ if (run.error)
231
+ return null;
232
+ const report = await readIfFresh(path, before);
233
+ if (report)
234
+ return report;
235
+ run.error = `no report written to ${path}`;
236
+ return null;
237
+ }
238
+ function summarize(s) {
239
+ const parts = [elapsed(s.started), modelName(s.envelope.model)];
240
+ if (s.run.steps === 1)
241
+ parts.push("1 step");
242
+ if (s.run.steps > 1)
243
+ parts.push(`${s.run.steps} steps`);
244
+ parts.push(`tokens ${tokens(s.run.input)} in / ${tokens(s.run.output)} out`);
245
+ if (s.envelope.sessionId)
246
+ parts.push(`--resume ${shortId(s.envelope.sessionId)}`);
247
+ const stats = parts.join(` ${c.dim("·")} `);
248
+ if (s.run.error) {
249
+ note(` ${c.red("✗ failed")} ${c.dim("·")} ${stats}`);
250
+ note(` ${c.red(s.run.error)}`);
251
+ return;
252
+ }
253
+ if (s.result.status === "fail") {
254
+ note(` ${c.red("✗ fail")} ${c.dim("·")} ${stats}`);
255
+ if (s.result.reason)
256
+ note(` ${c.red(s.result.reason)}`);
257
+ return;
258
+ }
259
+ note(` ${c.green("✓")} ${stats}`);
260
+ }
261
+ async function readIfFresh(path, before) {
262
+ if (fileStamp(path) === before)
263
+ return null;
264
+ const text = await readFile(path, "utf8").catch(() => "");
265
+ if (!text.trim())
266
+ return null;
267
+ if (text.endsWith("\n"))
268
+ return text;
269
+ return `${text}\n`;
270
+ }
271
+ function fileStamp(path) {
272
+ if (!path || !existsSync(path))
273
+ return null;
274
+ const stat = statSync(path);
275
+ return `${stat.mtimeMs}:${stat.size}`;
276
+ }
277
+ function lastAssistantText(session) {
278
+ const messages = session.state.messages ?? [];
279
+ for (let i = messages.length - 1; i >= 0; i--) {
280
+ const message = messages[i];
281
+ if (message?.role !== "assistant")
282
+ continue;
283
+ const parts = [];
284
+ for (const part of message.content) {
285
+ if (part.type === "text")
286
+ parts.push(part.text);
287
+ }
288
+ const text = parts.join("").trim();
289
+ if (text)
290
+ return `${text}\n`;
291
+ }
292
+ return null;
293
+ }
294
+ function errorText(err) {
295
+ if (err instanceof Error)
296
+ return err.message;
297
+ return String(err);
298
+ }
299
+ function note(line) {
300
+ process.stderr.write(`${line}\n`);
301
+ }
302
+ function elapsed(started) {
303
+ const seconds = Math.round((Date.now() - started) / 1000);
304
+ if (seconds < 60)
305
+ return `${seconds}s`;
306
+ return `${Math.floor(seconds / 60)}m ${seconds % 60}s`;
307
+ }
308
+ function tokens(count) {
309
+ if (count < 1000)
310
+ return String(count);
311
+ return `${(count / 1000).toFixed(1)}k`;
312
+ }
313
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,WAAW,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC;AAGzC,OAAO,E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AAE,OAAO,GAAG,CAAC,OAAO,CAAC;IAC7C,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC;AAED,SAAS,IAAI,CAAC,IAAY;IACxB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,OAAO,CAAC,OAAe;IAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IAC1D,IAAI,OAAO,GAAG,EAAE;QAAE,OAAO,GAAG,OAAO,GAAG,CAAC;IACvC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,KAAK,OAAO,GAAG,EAAE,GAAG,CAAC;AACzD,CAAC;AAED,SAAS,MAAM,CAAC,KAAa;IAC3B,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;AACzC,CAAC"}
@@ -0,0 +1,98 @@
1
+ import { join } from "node:path";
2
+ import { createAgentSession, DefaultResourceLoader, ModelRuntime, SettingsManager, } from "@earendil-works/pi-coding-agent";
3
+ import { buildSystemPrompt } from "../prompt/index.js";
4
+ import { pathClis } from "../prompt/tools.js";
5
+ import { PACKAGE_ROOT, PI_STATE_DIR, TESTEIYA_HOME } from "./env.js";
6
+ import { hasMcp, tmsAccess } from "./mcp.js";
7
+ import { applyEnvKeys, resolveModel } from "./model.js";
8
+ import { createSetResultTool } from "./result.js";
9
+ import { sessionModel } from "./sessions.js";
10
+ // From the package root, never this file's own directory: `../skills` would
11
+ // resolve to dist/skills, and the filter below would silently drop everything.
12
+ export const BUNDLED_SKILLS_DIR = join(PACKAGE_ROOT, "skills");
13
+ const MCP_EXTENSION = join(import.meta.dirname, "mcp-extension.js");
14
+ /** The one runtime factory, so every command reads the same auth. */
15
+ export async function createRuntime() {
16
+ const runtime = await ModelRuntime.create({
17
+ authPath: join(TESTEIYA_HOME, "auth.json"),
18
+ modelsPath: null,
19
+ });
20
+ await applyEnvKeys(runtime);
21
+ return runtime;
22
+ }
23
+ /**
24
+ * The loader every command shares, so `doctor` reports the skills a run would
25
+ * actually load. A filter, not a loader: pi also discovers skills from the
26
+ * checkout it is pointed at (`.agents/skills`, `.pi/skills`, and the user's
27
+ * own), and an arbitrary CI clone must not be able to hand the model its own.
28
+ */
29
+ export function createLoader(options) {
30
+ return new DefaultResourceLoader({
31
+ cwd: options.cwd,
32
+ agentDir: PI_STATE_DIR,
33
+ settingsManager: options.settingsManager,
34
+ additionalSkillPaths: [BUNDLED_SKILLS_DIR],
35
+ additionalExtensionPaths: options.extensionPaths,
36
+ systemPromptOverride: options.systemPrompt,
37
+ skillsOverride: (current) => ({
38
+ skills: current.skills.filter((s) => s.baseDir.startsWith(BUNDLED_SKILLS_DIR)),
39
+ diagnostics: current.diagnostics,
40
+ }),
41
+ });
42
+ }
43
+ export async function createTesteiyaSession(options) {
44
+ const runtime = await createRuntime();
45
+ const model = resolveModel(runtime, options.model, sessionModel(options.sessionManager));
46
+ const settingsManager = SettingsManager.inMemory();
47
+ const extensionPaths = [];
48
+ const connectedMcps = [];
49
+ if (hasMcp()) {
50
+ extensionPaths.push(MCP_EXTENSION);
51
+ connectedMcps.push("Testomat.io");
52
+ }
53
+ const loader = createLoader({
54
+ cwd: options.cwd,
55
+ settingsManager,
56
+ extensionPaths,
57
+ systemPrompt: () => buildSystemPrompt({
58
+ cwd: options.cwd,
59
+ mode: "print",
60
+ tms: tmsAccess(),
61
+ tokens: options.tokens,
62
+ connection: options.connection,
63
+ backendUrl: options.backendUrl,
64
+ outputFile: options.outputFile,
65
+ brief: options.brief,
66
+ connectedClis: pathClis(),
67
+ connectedMcps,
68
+ }),
69
+ });
70
+ await loader.reload();
71
+ const { session } = await createAgentSession({
72
+ cwd: options.cwd,
73
+ agentDir: PI_STATE_DIR,
74
+ model,
75
+ modelRuntime: runtime,
76
+ resourceLoader: loader,
77
+ settingsManager,
78
+ sessionManager: options.sessionManager,
79
+ customTools: [createSetResultTool(options.result)],
80
+ // Extensions start their runtime on this event. Without it the MCP adapter
81
+ // registers its tools but never connects, and every call answers
82
+ // "MCP not initialized".
83
+ sessionStartEvent: { type: "session_start", reason: "startup" },
84
+ });
85
+ // Starts the extension runtime and fires session_start. createAgentSession
86
+ // does not do this — pi's own modes do — and without it an extension is
87
+ // constructed but never initialized: the MCP adapter registers its tools and
88
+ // then answers "MCP not initialized" for every call.
89
+ await session.bindExtensions({
90
+ mode: "print",
91
+ onError: (err) => {
92
+ process.stderr.write(` extension error (${err.extensionPath}): ${err.error}\n`);
93
+ },
94
+ });
95
+ const skills = loader.getSkills().skills;
96
+ return { session, model: `${model.provider}/${model.id}`, skills };
97
+ }
98
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,eAAe,GAIhB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAkB,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,C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,EAAE,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE;KAChE,CAAC,CAAC;IAEH,2EAA2E;IAC3E,wEAAwE;IACxE,6EAA6E;IAC7E,qDAAqD;IACrD,MAAM,OAAO,CAAC,cAAc,CAAC;QAC3B,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,GAAG,CAAC,aAAa,MAAM,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC;QACnF,CAAC;KACF,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC;IACzC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;AACrE,CAAC"}
@@ -0,0 +1,72 @@
1
+ import { buildSessionContext, SessionManager } from "@earendil-works/pi-coding-agent";
2
+ /**
3
+ * Sessions are pi's, not ours: it stores, lists and reopens them under
4
+ * PI_STATE_DIR. `--no-session` keeps a run entirely in memory.
5
+ */
6
+ export async function openSessionManager(cwd, args) {
7
+ if (args.noSession)
8
+ return SessionManager.inMemory(cwd);
9
+ // One label, one thread: a CI job that restores the same store every round
10
+ // says --session <label> and never has to know whether a session exists yet.
11
+ if (args.session) {
12
+ const sessions = await SessionManager.list(cwd);
13
+ const named = sessions.find((s) => s.name === args.session);
14
+ if (named)
15
+ return SessionManager.open(named.path);
16
+ const manager = SessionManager.create(cwd);
17
+ manager.appendSessionInfo(args.session);
18
+ return manager;
19
+ }
20
+ if (args.resume) {
21
+ const sessions = await SessionManager.list(cwd);
22
+ const matched = sessions.filter((s) => s.id.startsWith(args.resume ?? ""));
23
+ if (matched.length === 0)
24
+ return `no session "${args.resume}" in this folder`;
25
+ if (matched.length > 1) {
26
+ const ids = matched.map((s) => shortId(s.id)).join(", ");
27
+ return `"${args.resume}" matches ${matched.length} sessions: ${ids}`;
28
+ }
29
+ return SessionManager.open(matched[0].path);
30
+ }
31
+ if (args.continueLast)
32
+ return SessionManager.continueRecent(cwd);
33
+ return SessionManager.create(cwd);
34
+ }
35
+ /** The model a resumed session was last running, so `-c` needs no --model. */
36
+ export function sessionModel(manager) {
37
+ const entries = manager.getEntries();
38
+ if (entries.length === 0)
39
+ return null;
40
+ return buildSessionContext(entries, manager.getLeafId()).model;
41
+ }
42
+ export async function runSessions(cwd, json) {
43
+ const sessions = await SessionManager.list(cwd);
44
+ if (json) {
45
+ const rows = sessions.map((s) => ({
46
+ id: s.id,
47
+ name: s.name ?? null,
48
+ modified: s.modified.toISOString(),
49
+ messages: s.messageCount,
50
+ first: s.firstMessage,
51
+ }));
52
+ process.stdout.write(`${JSON.stringify({ sessions: rows }, null, 2)}\n`);
53
+ return 0;
54
+ }
55
+ if (sessions.length === 0) {
56
+ process.stdout.write(" no saved sessions in this folder\n");
57
+ return 0;
58
+ }
59
+ process.stdout.write("\n");
60
+ for (const session of sessions) {
61
+ const label = session.name ?? session.firstMessage.slice(0, 60);
62
+ const when = session.modified.toISOString().slice(0, 16).replace("T", " ");
63
+ process.stdout.write(` ${shortId(session.id)} ${when} ${session.messageCount} msg ${label}\n`);
64
+ }
65
+ process.stdout.write("\n Continue one with: testeiya task \"...\" --resume <id>\n\n");
66
+ return 0;
67
+ }
68
+ /** Long enough to clear the UUIDv7 timestamp prefix, which repeats per minute. */
69
+ export function shortId(id) {
70
+ return id.slice(0, 13);
71
+ }
72
+ //# sourceMappingURL=sessions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../src/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,GAAW,EACX,IAAiB;IAEjB,IAAI,IAAI,CAAC,S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,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC7D,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAChE,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC3E,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,IAAI,KAAK,OAAO,CAAC,YAAY,SAAS,KAAK,IAAI,CAAC,CAAC;IACrG,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iEAAiE,CAAC,CAAC;IACxF,OAAO,CAAC,CAAC;AACX,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,OAAO,CAAC,EAAU;IAChC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACzB,CAAC"}
@@ -0,0 +1,130 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, relative } from "node:path";
3
+ import { SettingsManager, stripFrontmatter, } from "@earendil-works/pi-coding-agent";
4
+ import { BUNDLED_SKILLS_DIR, createLoader } from "./session.js";
5
+ /**
6
+ * A skill named in the task loads before the run: `/qa-thinking` puts that
7
+ * SKILL.md in front of the prompt. pi does not do this for us — its own
8
+ * `/skill:name` form expands only with prompt templates on, and a task carrying
9
+ * a comment from a stranger never runs with those on. A name we do not ship
10
+ * stays plain text, so `/testeiya` in a comment is still just words.
11
+ */
12
+ export function expandSkills(prompt, skills) {
13
+ const byName = new Map(skills.map((skill) => [skill.name, skill]));
14
+ const loaded = [];
15
+ for (const word of prompt.split(/\s+/)) {
16
+ if (!word.startsWith("/"))
17
+ continue;
18
+ const skill = byName.get(skillName(word));
19
+ if (!skill)
20
+ continue;
21
+ if (loaded.includes(skill))
22
+ continue;
23
+ loaded.push(skill);
24
+ }
25
+ if (loaded.length === 0)
26
+ return { prompt, loaded: [] };
27
+ const blocks = loaded.map(block).join("\n\n");
28
+ return { prompt: `${blocks}\n\n${prompt}`, loaded: loaded.map((skill) => skill.name) };
29
+ }
30
+ /**
31
+ * The skills a run can actually reach. Loaded through the loader every command
32
+ * shares, so this list, `doctor` and the model's own list cannot drift — and a
33
+ * checkout's skills are filtered out here exactly as they are in a run.
34
+ */
35
+ export async function loadBundledSkills() {
36
+ const loader = createLoader({
37
+ cwd: process.cwd(),
38
+ settingsManager: SettingsManager.inMemory(),
39
+ extensionPaths: [],
40
+ systemPrompt: () => "",
41
+ });
42
+ await loader.reload();
43
+ const { skills, diagnostics } = loader.getSkills();
44
+ return { count: skills.length, groups: byGroup(skills), diagnostics };
45
+ }
46
+ export async function runSkills(pattern, json) {
47
+ const { groups } = await loadBundledSkills();
48
+ const matched = filter(groups, pattern);
49
+ const count = matched.reduce((total, group) => total + group.skills.length, 0);
50
+ if (json) {
51
+ const rows = matched.flatMap((group) => group.skills.map((skill) => ({
52
+ name: skill.name,
53
+ group: group.group,
54
+ description: skill.description,
55
+ })));
56
+ process.stdout.write(`${JSON.stringify({ skills: rows }, null, 2)}\n`);
57
+ return 0;
58
+ }
59
+ if (count === 0 && pattern) {
60
+ process.stdout.write(` no bundled skill matches "${pattern}"\n`);
61
+ return 1;
62
+ }
63
+ if (count === 0) {
64
+ process.stdout.write(" no skills bundled — reinstall the package\n");
65
+ return 1;
66
+ }
67
+ process.stdout.write(`\n ${count} skills, bundled with testeiya\n`);
68
+ for (const { group, skills } of matched) {
69
+ process.stdout.write(`\n ${group}\n`);
70
+ for (const skill of skills) {
71
+ process.stdout.write(` ${skill.name.padEnd(32)} ${summary(skill.description)}\n`);
72
+ }
73
+ }
74
+ process.stdout.write('\n Load one in the task: testeiya task "review this pr /qa-thinking"\n\n');
75
+ return 0;
76
+ }
77
+ /** `/qa-thinking`, `/skill:qa-thinking`, `/qa-thinking.` — all the same skill. */
78
+ function skillName(word) {
79
+ let token = word.slice(1).toLowerCase();
80
+ if (token.startsWith("skill:"))
81
+ token = token.slice(6);
82
+ while (token.length > 0 && !NAME_CHARS.includes(token.at(-1)))
83
+ token = token.slice(0, -1);
84
+ return token;
85
+ }
86
+ /** The block pi builds for `/skill:name`, so a loaded skill reads the same way. */
87
+ function block(skill) {
88
+ const body = stripFrontmatter(readFileSync(skill.filePath, "utf8")).trim();
89
+ return (`<skill name="${skill.name}" location="${skill.filePath}">\n` +
90
+ `References are relative to ${skill.baseDir}.\n\n${body}\n</skill>`);
91
+ }
92
+ const NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-";
93
+ /** Match the name or what the skill says it is for, like `models <pattern>`. */
94
+ function filter(groups, pattern) {
95
+ if (!pattern)
96
+ return groups;
97
+ const needle = pattern.toLowerCase();
98
+ const matched = [];
99
+ for (const group of groups) {
100
+ const skills = group.skills.filter((skill) => {
101
+ const haystack = `${group.group} ${skill.name} ${skill.description}`.toLowerCase();
102
+ return haystack.includes(needle);
103
+ });
104
+ if (skills.length > 0)
105
+ matched.push({ group: group.group, skills });
106
+ }
107
+ return matched;
108
+ }
109
+ /** The first sentence, cut to whatever the terminal has room for. */
110
+ function summary(description) {
111
+ const width = Math.max(30, (process.stdout.columns ?? 100) - 40);
112
+ const first = description.split(". ")[0].trim();
113
+ if (first.length <= width)
114
+ return first;
115
+ return `${first.slice(0, width - 1)}…`;
116
+ }
117
+ /** The vendor folder a skill came from — the category it is published under. */
118
+ function byGroup(skills) {
119
+ const groups = new Map();
120
+ for (const skill of skills) {
121
+ let group = dirname(relative(BUNDLED_SKILLS_DIR, skill.baseDir));
122
+ if (group === "." || group.startsWith(".."))
123
+ group = "bundled";
124
+ const members = groups.get(group) ?? [];
125
+ members.push(skill);
126
+ groups.set(group, members);
127
+ }
128
+ return [...groups].map(([group, members]) => ({ group, skills: members }));
129
+ }
130
+ //# sourceMappingURL=skills.js.map