testeiya 0.3.9 → 0.3.10

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 (176) hide show
  1. package/README.md +312 -27
  2. package/dist/prompt/index.js +6 -2
  3. package/dist/prompt/index.js.map +1 -1
  4. package/dist/prompt/print.js +8 -0
  5. package/dist/prompt/print.js.map +1 -1
  6. package/dist/prompt/system-prompt.js +14 -4
  7. package/dist/prompt/system-prompt.js.map +1 -1
  8. package/dist/prompt/testomatio.js +3 -3
  9. package/dist/prompt/tools.js +15 -7
  10. package/dist/prompt/tools.js.map +1 -1
  11. package/dist/src/args.js +147 -47
  12. package/dist/src/args.js.map +1 -1
  13. package/dist/src/cli.js +50 -14
  14. package/dist/src/cli.js.map +1 -1
  15. package/dist/src/doctor.js +186 -0
  16. package/dist/src/doctor.js.map +1 -0
  17. package/dist/src/env.js +29 -5
  18. package/dist/src/env.js.map +1 -1
  19. package/dist/src/mcp.js +3 -3
  20. package/dist/src/mcp.js.map +1 -1
  21. package/dist/src/model.js +15 -10
  22. package/dist/src/model.js.map +1 -1
  23. package/dist/src/models.js +38 -0
  24. package/dist/src/models.js.map +1 -0
  25. package/dist/src/output.js +185 -0
  26. package/dist/src/output.js.map +1 -0
  27. package/dist/src/run.js +116 -24
  28. package/dist/src/run.js.map +1 -1
  29. package/dist/src/session.js +38 -23
  30. package/dist/src/session.js.map +1 -1
  31. package/dist/src/sessions.js +61 -0
  32. package/dist/src/sessions.js.map +1 -0
  33. package/package.json +7 -3
  34. package/prompt/index.ts +11 -2
  35. package/prompt/print.ts +9 -0
  36. package/prompt/system-prompt.ts +18 -4
  37. package/prompt/testomatio.ts +3 -3
  38. package/prompt/tools.ts +15 -7
  39. package/skills/codeceptjs/ci-fix-tests/SKILL.md +119 -0
  40. package/skills/codeceptjs/codeceptjs-auth/SKILL.md +141 -0
  41. package/skills/codeceptjs/codeceptjs-exploration/SKILL.md +100 -0
  42. package/skills/codeceptjs/codeceptjs-fundamentals/SKILL.md +196 -0
  43. package/skills/codeceptjs/codeceptjs-run-analysis/SKILL.md +83 -0
  44. package/skills/codeceptjs/debugging-codeceptjs-tests/SKILL.md +126 -0
  45. package/skills/codeceptjs/migrate-codeceptjs-4/SKILL.md +109 -0
  46. package/skills/codeceptjs/migrate-cypress-to-codeceptjs/SKILL.md +295 -0
  47. package/skills/codeceptjs/migrate-protractor-to-codeceptjs/SKILL.md +339 -0
  48. package/skills/codeceptjs/migrate-selenium-java-to-codeceptjs/SKILL.md +459 -0
  49. package/skills/codeceptjs/migrate-testcafe-to-codeceptjs/SKILL.md +338 -0
  50. package/skills/codeceptjs/refactoring-codeceptjs-tests/SKILL.md +78 -0
  51. package/skills/codeceptjs/writing-codeceptjs-tests/SKILL.md +102 -0
  52. package/skills/playwright/playwright-best-practices/SKILL.md +303 -0
  53. package/skills/playwright/playwright-best-practices/advanced/authentication-flows.md +360 -0
  54. package/skills/playwright/playwright-best-practices/advanced/authentication.md +871 -0
  55. package/skills/playwright/playwright-best-practices/advanced/clock-mocking.md +364 -0
  56. package/skills/playwright/playwright-best-practices/advanced/mobile-testing.md +409 -0
  57. package/skills/playwright/playwright-best-practices/advanced/multi-context.md +288 -0
  58. package/skills/playwright/playwright-best-practices/advanced/multi-user.md +393 -0
  59. package/skills/playwright/playwright-best-practices/advanced/network-advanced.md +452 -0
  60. package/skills/playwright/playwright-best-practices/advanced/third-party.md +464 -0
  61. package/skills/playwright/playwright-best-practices/architecture/pom-vs-fixtures.md +363 -0
  62. package/skills/playwright/playwright-best-practices/architecture/test-architecture.md +369 -0
  63. package/skills/playwright/playwright-best-practices/architecture/when-to-mock.md +383 -0
  64. package/skills/playwright/playwright-best-practices/browser-apis/browser-apis.md +391 -0
  65. package/skills/playwright/playwright-best-practices/browser-apis/iframes.md +403 -0
  66. package/skills/playwright/playwright-best-practices/browser-apis/service-workers.md +504 -0
  67. package/skills/playwright/playwright-best-practices/browser-apis/websockets.md +403 -0
  68. package/skills/playwright/playwright-best-practices/core/annotations.md +424 -0
  69. package/skills/playwright/playwright-best-practices/core/assertions-waiting.md +361 -0
  70. package/skills/playwright/playwright-best-practices/core/configuration.md +452 -0
  71. package/skills/playwright/playwright-best-practices/core/fixtures-hooks.md +417 -0
  72. package/skills/playwright/playwright-best-practices/core/global-setup.md +434 -0
  73. package/skills/playwright/playwright-best-practices/core/locators.md +242 -0
  74. package/skills/playwright/playwright-best-practices/core/page-object-model.md +315 -0
  75. package/skills/playwright/playwright-best-practices/core/projects-dependencies.md +453 -0
  76. package/skills/playwright/playwright-best-practices/core/test-data.md +492 -0
  77. package/skills/playwright/playwright-best-practices/core/test-suite-structure.md +361 -0
  78. package/skills/playwright/playwright-best-practices/core/test-tags.md +298 -0
  79. package/skills/playwright/playwright-best-practices/debugging/console-errors.md +420 -0
  80. package/skills/playwright/playwright-best-practices/debugging/debugging.md +504 -0
  81. package/skills/playwright/playwright-best-practices/debugging/error-testing.md +360 -0
  82. package/skills/playwright/playwright-best-practices/debugging/flaky-tests.md +496 -0
  83. package/skills/playwright/playwright-best-practices/frameworks/angular.md +530 -0
  84. package/skills/playwright/playwright-best-practices/frameworks/nextjs.md +469 -0
  85. package/skills/playwright/playwright-best-practices/frameworks/react.md +531 -0
  86. package/skills/playwright/playwright-best-practices/frameworks/vue.md +574 -0
  87. package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/ci-cd.md +468 -0
  88. package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/docker.md +283 -0
  89. package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/github-actions.md +546 -0
  90. package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/gitlab.md +397 -0
  91. package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/other-providers.md +521 -0
  92. package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/parallel-sharding.md +371 -0
  93. package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/performance.md +453 -0
  94. package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/reporting.md +424 -0
  95. package/skills/playwright/playwright-best-practices/infrastructure-ci-cd/test-coverage.md +497 -0
  96. package/skills/playwright/playwright-best-practices/testing-patterns/accessibility.md +359 -0
  97. package/skills/playwright/playwright-best-practices/testing-patterns/api-testing.md +719 -0
  98. package/skills/playwright/playwright-best-practices/testing-patterns/browser-extensions.md +506 -0
  99. package/skills/playwright/playwright-best-practices/testing-patterns/canvas-webgl.md +493 -0
  100. package/skills/playwright/playwright-best-practices/testing-patterns/component-testing.md +500 -0
  101. package/skills/playwright/playwright-best-practices/testing-patterns/drag-drop.md +576 -0
  102. package/skills/playwright/playwright-best-practices/testing-patterns/electron.md +509 -0
  103. package/skills/playwright/playwright-best-practices/testing-patterns/file-operations.md +377 -0
  104. package/skills/playwright/playwright-best-practices/testing-patterns/file-upload-download.md +562 -0
  105. package/skills/playwright/playwright-best-practices/testing-patterns/forms-validation.md +561 -0
  106. package/skills/playwright/playwright-best-practices/testing-patterns/graphql-testing.md +331 -0
  107. package/skills/playwright/playwright-best-practices/testing-patterns/i18n.md +508 -0
  108. package/skills/playwright/playwright-best-practices/testing-patterns/performance-testing.md +476 -0
  109. package/skills/playwright/playwright-best-practices/testing-patterns/security-testing.md +430 -0
  110. package/skills/playwright/playwright-best-practices/testing-patterns/visual-regression.md +634 -0
  111. package/skills/playwright/playwright-cli/SKILL.md +420 -0
  112. package/skills/playwright/playwright-cli/references/element-attributes.md +23 -0
  113. package/skills/playwright/playwright-cli/references/playwright-tests.md +39 -0
  114. package/skills/playwright/playwright-cli/references/request-mocking.md +87 -0
  115. package/skills/playwright/playwright-cli/references/running-code.md +241 -0
  116. package/skills/playwright/playwright-cli/references/session-management.md +225 -0
  117. package/skills/playwright/playwright-cli/references/storage-state.md +275 -0
  118. package/skills/playwright/playwright-cli/references/test-generation.md +433 -0
  119. package/skills/playwright/playwright-cli/references/tracing.md +139 -0
  120. package/skills/playwright/playwright-cli/references/video-recording.md +143 -0
  121. package/skills/skills.lock.json +39 -36
  122. package/skills/testomatio/explorbot/explorbot-fundamentals/SKILL.md +76 -0
  123. package/skills/testomatio/explorbot/explorbot-fundamentals/references/no-install.md +36 -0
  124. package/skills/testomatio/explorbot/explorbot-plan/SKILL.md +108 -0
  125. package/skills/testomatio/explorbot/explorbot-setup/SKILL.md +86 -0
  126. package/skills/testomatio/qa-process/qa-explain-behavior/SKILL.md +111 -0
  127. package/skills/testomatio/qa-process/qa-explain-behavior/references/answer-shapes.md +116 -0
  128. package/skills/testomatio/qa-process/qa-explain-behavior/references/examples.md +157 -0
  129. package/skills/testomatio/qa-process/qa-lead-strategy-advisor/SKILL.md +91 -0
  130. package/skills/testomatio/qa-process/qa-lead-strategy-advisor/references/output-format.md +71 -0
  131. package/skills/testomatio/qa-process/testing-workflow/SKILL.md +227 -0
  132. package/skills/testomatio/test-automation/automate-manual-test-cases/CLAUDE.md +56 -0
  133. package/skills/testomatio/test-automation/automate-manual-test-cases/SKILL.md +242 -0
  134. package/skills/testomatio/test-automation/automate-manual-test-cases/references/CODECEPTJS_BEST_PRACTICES.md +182 -0
  135. package/skills/testomatio/test-automation/automate-manual-test-cases/references/FINAL_SUMMARY_TEMPLATE.md +22 -0
  136. package/skills/testomatio/test-automation/automate-manual-test-cases/references/PLAYWRIGHT_BEST_PRACTICES.md +90 -0
  137. package/skills/testomatio/test-automation/automate-manual-test-cases/references/POM_BEST_PRACTICES.md +53 -0
  138. package/skills/testomatio/test-automation/automate-manual-test-cases/references/TEST_DATA_MANAGEMENT.md +52 -0
  139. package/skills/testomatio/test-automation/debug-fix-failed-flaky-autotests/SKILL.md +107 -0
  140. package/skills/testomatio/test-automation/debug-fix-failed-flaky-autotests/references/DEBUGGING_QUICK_REFERENCE.md +113 -0
  141. package/skills/testomatio/test-automation/qa-automation-test-consolidation/SKILL.md +29 -0
  142. package/skills/testomatio/test-automation/qa-data-seeder/SKILL.md +83 -0
  143. package/skills/testomatio/test-automation/run-tests-with-testomatio-reporter/SKILL.md +153 -0
  144. package/skills/testomatio/test-automation/setup-change-aware-pr-testing/SKILL.md +190 -0
  145. package/skills/testomatio/test-automation/setup-ci-automation/SKILL.md +76 -0
  146. package/skills/testomatio/test-automation/testomat-allure-adapter/SKILL.md +289 -0
  147. package/skills/testomatio/test-management/detect-duplicate-test-cases/SKILL.md +86 -0
  148. package/skills/testomatio/test-management/detect-duplicate-test-cases/references/DUPLICATE_INSTRUCTIONS.md +54 -0
  149. package/skills/testomatio/test-management/improve-test-cases/SKILL.md +114 -0
  150. package/skills/testomatio/test-management/improve-test-cases/references/TESTOMAT_MARKDOWN_EXAMPLE.md +66 -0
  151. package/skills/testomatio/test-management/pull-request-diff-analyzer/SKILL.md +141 -0
  152. package/skills/testomatio/test-management/qa-e2e-tests-reporting/SKILL.md +354 -0
  153. package/skills/testomatio/test-management/qa-e2e-tests-reporting/references/TESTOMATIO_ARTIFACTS.md +82 -0
  154. package/skills/testomatio/test-management/qa-e2e-tests-reporting/references/TESTOMATIO_HTML_REPORT.md +37 -0
  155. package/skills/testomatio/test-management/qa-e2e-tests-reporting/references/TESTOMATIO_REPORTERS_CONFIG.md +118 -0
  156. package/skills/testomatio/test-management/qa-pr-requirements-analyzer/SKILL.md +149 -0
  157. package/skills/testomatio/test-management/qa-pr-requirements-analyzer/references/summary-example.md +54 -0
  158. package/skills/testomatio/test-management/qa-requirement-reviewer/SKILL.md +126 -0
  159. package/skills/testomatio/test-management/qa-requirement-reviewer/references/requirements_reviewer_examples.md +128 -0
  160. package/skills/testomatio/test-management/qa-split-testing-levels-pyramid/SKILL.md +55 -0
  161. package/skills/testomatio/test-management/qa-sprint-report-by-testomatio/SKILL.md +220 -0
  162. package/skills/testomatio/test-management/qa-sprint-report-by-testomatio/references/qa-sprint-report.md +126 -0
  163. package/skills/testomatio/test-management/qa-test-code-coverage/SKILL.md +174 -0
  164. package/skills/testomatio/test-management/qa-test-code-coverage/references/COVERAGE_FILE_FORMAT.md +138 -0
  165. package/skills/testomatio/test-management/qa-test-code-coverage/references/E2E_FRAMEWORKS.md +65 -0
  166. package/skills/testomatio/test-management/qa-test-code-coverage/scripts/check-coverage.mjs +40 -0
  167. package/skills/testomatio/test-management/qa-thinking/SKILL.md +36 -0
  168. package/skills/testomatio/test-management/qa-write-test-cases/SKILL.md +267 -0
  169. package/skills/testomatio/test-management/qa-write-test-cases/references/test-case-format.md +387 -0
  170. package/skills/testomatio/test-management/qa-write-test-cases/references/testomat-tms-guide.md +72 -0
  171. package/skills/testomatio/test-management/qa-write-test-cases/references/writing-rule.md +159 -0
  172. package/skills/testomatio/test-management/scan-automation-project/SKILL.md +152 -0
  173. package/skills/testomatio/test-management/sync-test-cases-with-tms/SKILL.md +107 -0
  174. package/skills/testomatio/test-management/sync-test-cases-with-tms/references/TESTOMATIO_CLI.md +140 -0
  175. package/skills/testomatio/test-management/testomatio-mcp/SKILL.md +195 -0
  176. package/skills/testomatio/test-management/testomatio-mcp/references/MCP_SETUP.md +177 -0
package/dist/src/args.js CHANGED
@@ -1,72 +1,172 @@
1
1
  import { parseArgs } from "node:util";
2
- export const USAGE = `testeiya — AI testing agent
2
+ export const WELCOME = `
3
+ Testeiya, an AI testing agent.
4
+
5
+ testeiya task "analyze this pr and find inconsistencies"
6
+ testeiya ask "is this feature ready"
7
+
8
+ testeiya doctor check your setup
9
+ testeiya --help options and environment
10
+ testeiya help the full guide
11
+ `;
12
+ export const USAGE = `testeiya, an AI testing agent
3
13
 
4
14
  Usage:
5
- testeiya "<task>" --model <provider>/<id> [--output <file>]
6
- cat task.md | testeiya [--output <file>]
15
+ testeiya task "<task>" run one task and write a report
16
+ testeiya ask "<question>" answer a question
17
+ testeiya doctor check what a run would resolve
18
+ testeiya models [pattern] list the models your key can reach
19
+ testeiya sessions list saved sessions for this folder
7
20
 
8
21
  Options:
9
- -o, --output <file.md> file the agent must write its report to
10
- -p, --print <task> same as passing the task positionally
11
- --model <id> provider/model to use, e.g. openrouter/anthropic/claude-sonnet-5
12
- --project <id> Testomat.io project id (same as TESTOMATIO_PROJECT_ID)
13
- -h, --help show this help
14
- -v, --version show version
22
+ -o, --output <dest> report destination, repeatable: file.md, file.json, gh:pr-comment
23
+ --model <id> provider/model to run
24
+ --project <id> Testomat.io project id
25
+ -c, --continue continue the last session in this folder
26
+ --resume <id> continue that session
27
+ --name <label> name the session
28
+ --no-session do not save the session
29
+ --json machine-readable output
30
+ --probe doctor only: test the key with one request
31
+ -h, --help show this
32
+ -v, --version show version
33
+
34
+ Environment:
35
+ TESTEIYA_MODEL model to run, e.g. openrouter/anthropic/claude-sonnet-5
36
+ OPENROUTER_API_KEY provider key, also ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY
37
+ TESTOMATIO Testomat.io project API key
38
+ TESTOMATIO_PROJECT_ID Testomat.io project id, same as --project
39
+ TESTOMATIO_URL Testomat.io base url, for self-hosted
40
+
41
+ Run "testeiya help" for the full guide.`;
42
+ export const HELP = `${USAGE}
43
+
44
+ Running a task
45
+
46
+ The agent runs one task and exits. There is no interactive mode. Progress and
47
+ errors go to stderr, so a run drops into CI as-is.
48
+
49
+ A task can also come from stdin: cat task.md | testeiya task
50
+ A task starting with "-" must follow "--": testeiya task -- "-weird task"
51
+
52
+ Exit codes: 0 pass, 1 failed run or negative verdict, 2 bad usage, 130 interrupted.
15
53
 
16
- Runs show progress and errors on stderr; the result is the report file.
17
- Without --output the agent's final answer is printed to stdout instead.
54
+ Where the report goes
18
55
 
19
- There is no default model: pass --model or set TESTEIYA_MODEL, or the run exits 2.
20
- The provider API key comes from the environment, ~/.testeiya/.env, or
21
- ~/.testeiya/auth.json.
56
+ --output names a destination and can repeat. Without one the report goes to
57
+ stdout. --json prints the run envelope to stdout instead.
22
58
 
23
- Set TESTOMATIO to a project API key to work with that Testomat.io project. Add
24
- the project id (--project or TESTOMATIO_PROJECT_ID) and the agent also gets the
25
- Testomat.io tools; with the token alone it uses check-tests and the REST API.
59
+ report.md the agent writes the report there
60
+ run.json the run envelope: verdict, reason, report, tokens, session id
61
+ gh:pr-comment posted on this branch's pull request, through the GitHub CLI
62
+ gh:pr#123 posted on that pull request
26
63
 
27
- A task starting with "-" must follow "--": testeiya -- "-weird task"
64
+ Every destination is checked before the run starts, so a missing gh costs no
65
+ tokens.
28
66
 
29
- Exit codes: 0 pass · 1 failed run or verdict · 2 bad usage · 130 interrupted.`;
67
+ Models and keys
68
+
69
+ There is no default model. Pass --model or set TESTEIYA_MODEL. A resumed run
70
+ reuses its session's model. "testeiya models" lists what your key can reach.
71
+
72
+ The provider key comes from the environment, from ~/.testeiya/.env, or from
73
+ ~/.testeiya/auth.json, which is the file the desktop app's Settings dialog
74
+ writes.
75
+
76
+ Sessions
77
+
78
+ Runs are saved under ~/.testeiya, so a follow-up picks up where the last one
79
+ stopped. -c continues the last session in this folder, --resume <id> picks
80
+ another, --name labels one, and --no-session saves nothing.
81
+
82
+ Testomat.io
83
+
84
+ Set TESTOMATIO to a project API key and the agent reads and writes that
85
+ project's tests, suites, runs and plans through check-tests and the REST API.
86
+ Add the project id, with --project or TESTOMATIO_PROJECT_ID, and it also gets
87
+ the Testomat.io tools. The MCP server needs the id: a token alone does not say
88
+ which project to talk to.`;
89
+ export const COMMANDS = ["task", "ask", "models", "doctor", "sessions", "help"];
30
90
  export function parseCliArgs(argv) {
91
+ const first = argv[0];
92
+ if (!first)
93
+ return { command: "welcome" };
94
+ if (first === "-h" || first === "--help")
95
+ return { command: "usage" };
96
+ if (first === "-v" || first === "--version")
97
+ return { command: "version" };
98
+ if (!isCommand(first))
99
+ return { error: unknownCommand(first) };
100
+ if (first === "help")
101
+ return { command: "help" };
102
+ const options = OPTIONS[first];
31
103
  let parsed;
32
104
  try {
33
- parsed = parseArgs({
34
- args: argv,
35
- options: {
36
- output: { type: "string", short: "o" },
37
- print: { type: "string", short: "p" },
38
- model: { type: "string" },
39
- project: { type: "string" },
40
- help: { type: "boolean", short: "h" },
41
- version: { type: "boolean", short: "v" },
42
- },
43
- allowPositionals: true,
44
- strict: true,
45
- });
105
+ parsed = parseArgs({ args: argv.slice(1), options, allowPositionals: true, strict: true });
46
106
  }
47
107
  catch (err) {
48
108
  if (err instanceof Error)
49
109
  return { error: err.message };
50
110
  return { error: String(err) };
51
111
  }
52
- const { values, positionals } = parsed;
112
+ const values = parsed.values;
53
113
  if (values.help)
54
- return { help: true };
55
- if (values.version)
56
- return { version: true };
57
- const parts = [...positionals];
58
- if (values.print)
59
- parts.unshift(values.print);
60
- const prompt = parts.join(" ").trim();
61
- const args = {};
62
- if (prompt)
63
- args.prompt = prompt;
64
- if (values.output)
65
- args.output = values.output;
66
- if (values.model)
114
+ return { command: "usage" };
115
+ const args = { command: first };
116
+ const text = parsed.positionals.join(" ").trim();
117
+ if ((first === "task" || first === "ask") && text)
118
+ args.prompt = text;
119
+ if (first === "models" && text)
120
+ args.pattern = text;
121
+ if (Array.isArray(values.output))
122
+ args.outputs = values.output;
123
+ if (values.json)
124
+ args.json = true;
125
+ if (values.probe)
126
+ args.probe = true;
127
+ if (typeof values.model === "string")
67
128
  args.model = values.model;
68
- if (values.project)
129
+ if (typeof values.project === "string")
69
130
  args.project = values.project;
131
+ if (values.continue)
132
+ args.continueLast = true;
133
+ if (typeof values.resume === "string")
134
+ args.resume = values.resume;
135
+ if (typeof values.name === "string")
136
+ args.name = values.name;
137
+ if (values["no-session"])
138
+ args.noSession = true;
70
139
  return args;
71
140
  }
141
+ const HELP_FLAG = { type: "boolean", short: "h" };
142
+ const JSON_FLAG = { type: "boolean" };
143
+ const RUN_OPTIONS = {
144
+ output: { type: "string", short: "o", multiple: true },
145
+ json: JSON_FLAG,
146
+ model: { type: "string" },
147
+ project: { type: "string" },
148
+ continue: { type: "boolean", short: "c" },
149
+ resume: { type: "string" },
150
+ name: { type: "string" },
151
+ "no-session": { type: "boolean" },
152
+ help: HELP_FLAG,
153
+ };
154
+ const OPTIONS = {
155
+ task: RUN_OPTIONS,
156
+ ask: RUN_OPTIONS,
157
+ models: { json: JSON_FLAG, help: HELP_FLAG },
158
+ doctor: { json: JSON_FLAG, probe: { type: "boolean" }, model: { type: "string" }, help: HELP_FLAG },
159
+ sessions: { json: JSON_FLAG, help: HELP_FLAG },
160
+ help: {},
161
+ };
162
+ function isCommand(value) {
163
+ return COMMANDS.includes(value);
164
+ }
165
+ // The task used to be the first positional, so a bare prompt is the mistake to
166
+ // expect. Name the fix rather than printing the whole usage at them.
167
+ function unknownCommand(value) {
168
+ if (value.startsWith("-"))
169
+ return `unknown option "${value}"`;
170
+ return `unknown command "${value}" — did you mean: testeiya task "${value}"`;
171
+ }
72
172
  //# sourceMappingURL=args.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,CAAC,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;8EA2ByD,CAAC;AAE/E,MAAM,UAAU,YAAY,CAAC,IAAc;IACzC,IAAI,MAAM,CAAC;IACX,IAAI,CAAC;QACH,MAAM,GAAG,SAAS,CAAC;YACjB,IAAI,EAAE,IAAI;YACV,OAAO,EAAE;gBACP,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE;gBACtC,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE;gBACrC,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC3B,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE;gBACrC,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE;aACzC;YACD,gBAAgB,EAAE,IAAI;YACtB,MAAM,EAAE,IAAI;SACb,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,KA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E;CACT,CAAC;AAEF,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAQ,QAA8B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACzD,CAAC;AAED,+EAA+E;AAC/E,qEAAqE;AACrE,SAAS,cAAc,CAAC,KAAa;IACnC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,mBAAmB,KAAK,GAAG,CAAC;IAC9D,OAAO,oBAAoB,KAAK,qCAAqC,KAAK,GAAG,CAAC;AAChF,CAAC"}
package/dist/src/cli.js CHANGED
@@ -1,10 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import { readFileSync } from "node:fs";
3
3
  import { join } from "node:path";
4
- import { parseCliArgs, USAGE } from "./args.js";
5
- import { loadEnvFiles } from "./env.js";
4
+ import { HELP, parseCliArgs, USAGE, WELCOME } from "./args.js";
5
+ import { runDoctor } from "./doctor.js";
6
+ import { loadEnvFiles, PACKAGE_ROOT } from "./env.js";
6
7
  import { UsageError } from "./model.js";
8
+ import { runModels } from "./models.js";
9
+ import { parseDestinations, preflight } from "./output.js";
7
10
  import { runPrint } from "./run.js";
11
+ import { openSessionManager, runSessions } from "./sessions.js";
8
12
  main(process.argv.slice(2)).catch((err) => {
9
13
  process.stderr.write(`${err?.message ?? err}\n`);
10
14
  process.exit(1);
@@ -16,28 +20,36 @@ async function main(argv) {
16
20
  process.stderr.write(`${args.error}\n\n${USAGE}\n`);
17
21
  process.exit(2);
18
22
  }
19
- if (args.help) {
23
+ if (args.command === "welcome") {
24
+ process.stdout.write(`${WELCOME}\n`);
25
+ return;
26
+ }
27
+ if (args.command === "usage") {
20
28
  process.stdout.write(`${USAGE}\n`);
21
29
  return;
22
30
  }
23
- if (args.version) {
31
+ if (args.command === "help") {
32
+ process.stdout.write(`${HELP}\n`);
33
+ return;
34
+ }
35
+ if (args.command === "version") {
24
36
  process.stdout.write(`${version()}\n`);
25
37
  return;
26
38
  }
27
- loadEnvFiles();
39
+ const envSources = loadEnvFiles();
28
40
  // --project is a spelling of the env var the MCP server needs, so the rest of
29
41
  // the CLI only ever reads the environment.
30
42
  if (args.project)
31
43
  process.env.TESTOMATIO_PROJECT_ID = args.project;
32
- // No task and nothing piped in: there is no interactive mode, so this is a
33
- // usage error rather than a prompt.
34
- const prompt = args.prompt ?? (await readStdin());
35
- if (!prompt.trim()) {
36
- process.stderr.write(`${USAGE}\n`);
37
- process.exit(2);
38
- }
39
44
  try {
40
- process.exit(await runPrint({ prompt, outputFile: args.output, model: args.model }));
45
+ if (args.command === "models")
46
+ process.exit(await runModels(args.pattern, args.json));
47
+ if (args.command === "doctor") {
48
+ process.exit(await runDoctor({ envSources, json: args.json, probe: args.probe, model: args.model }));
49
+ }
50
+ if (args.command === "sessions")
51
+ process.exit(await runSessions(process.cwd(), args.json));
52
+ process.exit(await task(args));
41
53
  }
42
54
  catch (err) {
43
55
  if (!(err instanceof UsageError))
@@ -46,6 +58,30 @@ async function main(argv) {
46
58
  process.exit(2);
47
59
  }
48
60
  }
61
+ async function task(args) {
62
+ const prompt = args.prompt ?? (await readStdin());
63
+ if (!prompt.trim()) {
64
+ process.stderr.write(` ${args.command} needs something to work on\n\n${USAGE}\n`);
65
+ process.exit(2);
66
+ }
67
+ const destinations = parseDestinations(args.outputs ?? [], args.json);
68
+ if (typeof destinations === "string")
69
+ throw new UsageError(destinations);
70
+ // Everything a destination needs is checked before a single token is spent.
71
+ const unreachable = await preflight(destinations);
72
+ if (unreachable)
73
+ throw new UsageError(unreachable);
74
+ const sessionManager = await openSessionManager(process.cwd(), args);
75
+ if (typeof sessionManager === "string")
76
+ throw new UsageError(sessionManager);
77
+ if (args.name)
78
+ sessionManager.appendSessionInfo(args.name);
79
+ let sessionId = null;
80
+ if (!args.noSession)
81
+ sessionId = sessionManager.getSessionId();
82
+ const brief = args.command === "ask";
83
+ return runPrint({ prompt, destinations, sessionManager, sessionId, brief, model: args.model });
84
+ }
49
85
  async function readStdin() {
50
86
  if (process.stdin.isTTY)
51
87
  return "";
@@ -55,7 +91,7 @@ async function readStdin() {
55
91
  return Buffer.concat(chunks).toString("utf8");
56
92
  }
57
93
  function version() {
58
- const pkg = JSON.parse(readFileSync(join(import.meta.dirname, "..", "..", "package.json"), "utf8"));
94
+ const pkg = JSON.parse(readFileSync(join(PACKAGE_ROOT, "package.json"), "utf8"));
59
95
  return pkg.version;
60
96
  }
61
97
  //# sourceMappingURL=cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACxC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,EAAE,OAAO,IAAI,GAAG,IAAI,CAAC,CAAC;IACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,KAAK,UAAU,IAAI,CAAC,IAAc;IAChC,OAAO,CAAC,KAAK,GAAG,UAAU,CAAC;IAE3B,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,OAAO,KAAK,IAAI,CAAC,CAAC;QACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CA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O,CAAC,KAAK;QAAE,MAAM,CAAC,IAAI,CAAC,KAAe,CAAC,CAAC;IACtE,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,OAAO;IACd,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CACpB,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CACzD,CAAC;IACF,OAAO,GAAG,CAAC,OAAO,CAAC;AACrB,CAAC"}
@@ -0,0 +1,186 @@
1
+ import { existsSync } from "node:fs";
2
+ import { SettingsManager } from "@earendil-works/pi-coding-agent";
3
+ import { dirname, relative } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { TESTEIYA_HOME } from "./env.js";
6
+ import { hasMcp, hasTestomatio, metadataCachePath, vendorBundle } from "./mcp.js";
7
+ import { PROVIDER_KEYS, resolveModel, UsageError } from "./model.js";
8
+ import { BUNDLED_SKILLS_DIR, createLoader, createRuntime } from "./session.js";
9
+ const MIN_NODE = [22, 19];
10
+ /**
11
+ * Everything a run resolves silently: which key file won, whether skills loaded,
12
+ * whether MCP is on. Reads config only — `--probe` is the one check that spends.
13
+ */
14
+ export async function runDoctor(options) {
15
+ const checks = [nodeCheck(), homeCheck()];
16
+ const runtime = await createRuntime();
17
+ checks.push(keyCheck(runtime, options.envSources));
18
+ const model = modelCheck(runtime, options.model);
19
+ checks.push(model.check);
20
+ const skills = await skillsChecks();
21
+ checks.push(...skills.checks);
22
+ checks.push(testomatioCheck(), mcpCacheCheck());
23
+ if (options.probe)
24
+ checks.push(await probeCheck(runtime, model.resolved));
25
+ if (options.json) {
26
+ const report = {
27
+ checks: checks.filter((check) => check.status !== "list"),
28
+ skills: skills.groups,
29
+ };
30
+ process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
31
+ return worst(checks) === "fail" ? 1 : 0;
32
+ }
33
+ process.stdout.write("\n");
34
+ for (const check of checks) {
35
+ process.stdout.write(` ${MARK[check.status]} ${check.name.padEnd(12)} ${check.detail}\n`);
36
+ }
37
+ process.stdout.write("\n");
38
+ return worst(checks) === "fail" ? 1 : 0;
39
+ }
40
+ function nodeCheck() {
41
+ const version = process.versions.node;
42
+ const [major = 0, minor = 0] = version.split(".").map(Number);
43
+ if (major > MIN_NODE[0] || (major === MIN_NODE[0] && minor >= MIN_NODE[1])) {
44
+ return { name: "node", status: "ok", detail: `v${version}` };
45
+ }
46
+ return { name: "node", status: "fail", detail: `v${version}, needs v22.19 or newer` };
47
+ }
48
+ function homeCheck() {
49
+ if (!existsSync(TESTEIYA_HOME)) {
50
+ return { name: "home", status: "warn", detail: `${TESTEIYA_HOME} (not created yet)` };
51
+ }
52
+ return { name: "home", status: "ok", detail: TESTEIYA_HOME };
53
+ }
54
+ // The key can come from four places and nothing else ever says which one won.
55
+ function keyCheck(runtime, sources) {
56
+ const found = [];
57
+ for (const { provider, env } of PROVIDER_KEYS) {
58
+ if (process.env[env]) {
59
+ found.push(`${provider} from ${sources.get(env) ?? "environment"}`);
60
+ continue;
61
+ }
62
+ if (runtime.hasConfiguredAuth(provider))
63
+ found.push(`${provider} from auth.json`);
64
+ }
65
+ if (found.length === 0) {
66
+ return { name: "key", status: "fail", detail: "none — set OPENROUTER_API_KEY or similar" };
67
+ }
68
+ return { name: "key", status: "ok", detail: found.join(", ") };
69
+ }
70
+ function modelCheck(runtime, explicit) {
71
+ try {
72
+ const model = resolveModel(runtime, explicit);
73
+ return {
74
+ check: { name: "model", status: "ok", detail: `${model.provider}/${model.id}` },
75
+ resolved: model,
76
+ };
77
+ }
78
+ catch (err) {
79
+ const detail = err instanceof UsageError ? err.message : String(err);
80
+ return { check: { name: "model", status: "warn", detail } };
81
+ }
82
+ }
83
+ async function skillsChecks() {
84
+ const loader = createLoader({
85
+ cwd: process.cwd(),
86
+ settingsManager: SettingsManager.inMemory(),
87
+ extensionPaths: [],
88
+ systemPrompt: () => "",
89
+ });
90
+ await loader.reload();
91
+ const { skills, diagnostics } = loader.getSkills();
92
+ const groups = byGroup(skills);
93
+ const checks = [];
94
+ if (skills.length === 0) {
95
+ checks.push({ name: "skills", status: "warn", detail: "none loaded" });
96
+ }
97
+ if (skills.length > 0) {
98
+ checks.push({ name: "skills", status: "ok", detail: `${skills.length} loaded` });
99
+ for (const [group, names] of groups) {
100
+ checks.push({ name: "", status: "list", detail: `${group.padEnd(28)} ${summarize(names)}` });
101
+ }
102
+ }
103
+ // Collisions and parse errors were dropped on the floor before this command.
104
+ for (const diagnostic of diagnostics) {
105
+ const status = diagnostic.type === "error" ? "fail" : "warn";
106
+ let detail = diagnostic.message;
107
+ if (diagnostic.path)
108
+ detail = `${detail} — ${shorten(diagnostic.path)}`;
109
+ checks.push({ name: "skills", status, detail });
110
+ }
111
+ return { checks, groups: [...groups].map(([group, names]) => ({ group, skills: names })) };
112
+ }
113
+ function shorten(path) {
114
+ const inBundle = relative(BUNDLED_SKILLS_DIR, path);
115
+ if (inBundle.startsWith(".."))
116
+ return path;
117
+ return inBundle;
118
+ }
119
+ // The full list is in --json; this line only has to prove the right set loaded.
120
+ function summarize(names) {
121
+ if (names.length <= 6)
122
+ return names.join(", ");
123
+ return `${names.slice(0, 6).join(", ")}, +${names.length - 6}`;
124
+ }
125
+ function byGroup(skills) {
126
+ const groups = new Map();
127
+ for (const skill of skills) {
128
+ let group = dirname(relative(BUNDLED_SKILLS_DIR, skill.baseDir));
129
+ if (group === "." || group.startsWith(".."))
130
+ group = "bundled";
131
+ const names = groups.get(group) ?? [];
132
+ names.push(skill.name);
133
+ groups.set(group, names);
134
+ }
135
+ return groups;
136
+ }
137
+ function testomatioCheck() {
138
+ if (!hasTestomatio()) {
139
+ return { name: "testomatio", status: "warn", detail: "no TESTOMATIO token, not connected" };
140
+ }
141
+ if (!hasMcp()) {
142
+ return {
143
+ name: "testomatio",
144
+ status: "warn",
145
+ detail: "token set, no project id — check-tests and REST only",
146
+ };
147
+ }
148
+ return { name: "testomatio", status: "ok", detail: "token and project id, MCP tools on" };
149
+ }
150
+ function mcpCacheCheck() {
151
+ if (!hasMcp())
152
+ return { name: "mcp", status: "ok", detail: "off" };
153
+ const bundle = fileURLToPath(vendorBundle());
154
+ if (!existsSync(bundle)) {
155
+ return { name: "mcp", status: "fail", detail: "vendor bundle missing — run npm run build" };
156
+ }
157
+ if (!existsSync(metadataCachePath())) {
158
+ return { name: "mcp", status: "warn", detail: "tool cache empty, first run is proxy-only" };
159
+ }
160
+ return { name: "mcp", status: "ok", detail: "direct tools and proxy" };
161
+ }
162
+ async function probeCheck(runtime, model) {
163
+ if (!model)
164
+ return { name: "probe", status: "warn", detail: "skipped, no model to probe" };
165
+ const message = await runtime
166
+ .completeSimple(model, { messages: [{ role: "user", content: "ping", timestamp: Date.now() }] })
167
+ .catch((err) => ({ stopReason: "error", errorMessage: String(err) }));
168
+ if (message.stopReason === "error") {
169
+ return { name: "probe", status: "fail", detail: message.errorMessage ?? "request failed" };
170
+ }
171
+ return { name: "probe", status: "ok", detail: "the key works" };
172
+ }
173
+ function worst(checks) {
174
+ if (checks.some((check) => check.status === "fail"))
175
+ return "fail";
176
+ if (checks.some((check) => check.status === "warn"))
177
+ return "warn";
178
+ return "ok";
179
+ }
180
+ const MARK = {
181
+ ok: "✓",
182
+ warn: "!",
183
+ fail: "✗",
184
+ list: " ",
185
+ };
186
+ //# sourceMappingURL=doctor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,eAAe,EAAc,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAgB,aAAa,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,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EAAE,EAAE,CAAC,EAAE,CAAC;SAC/F,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAU,CAAC,CAAC;IAC1F,IAAI,OAAO,CAAC,UAAU,KAAK,OAAO,EAAE,CAAC;QACnC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,YAAY,IAAI,gBAAgB,EAAE,CAAC;IAC7F,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;AAClE,CAAC;AAED,SAAS,KAAK,CAAC,MAAe;IAC5B,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IACnE,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IACnE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,IAAI,GAA2B;IACnC,EAAE,EAAE,GAAG;IACP,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;CACV,CAAC"}
package/dist/src/env.js CHANGED
@@ -6,11 +6,19 @@ import { dirname, join } from "node:path";
6
6
  * in its Settings dialog works here with no extra step.
7
7
  */
8
8
  export const TESTEIYA_HOME = join(homedir(), ".testeiya");
9
+ /**
10
+ * This package's root, found by walking up to package.json — `dist/src` when
11
+ * built, `src` when run from source. Bundled files resolve from here.
12
+ */
13
+ export const PACKAGE_ROOT = packageRoot();
9
14
  /**
10
15
  * Where pi keeps its own state for this CLI. Deliberately not `~/.pi` — running
11
16
  * `npx testeiya` must not write into a user's own pi installation.
12
17
  */
13
18
  export const PI_STATE_DIR = join(TESTEIYA_HOME, "pi");
19
+ // pi reads this at import time to place sessions and its MCP cache, and a
20
+ // SessionManager is built before any session exists to read it from.
21
+ process.env.PI_CODING_AGENT_DIR = PI_STATE_DIR;
14
22
  /**
15
23
  * Fill gaps in process.env from `~/.testeiya/.env`, then from any `.env` found
16
24
  * walking up from the working directory — so running in a repo picks up that
@@ -19,17 +27,21 @@ export const PI_STATE_DIR = join(TESTEIYA_HOME, "pi");
19
27
  * The walk starts at cwd, never at this file: an installed package sits under
20
28
  * some node_modules whose ancestors are none of the agent's business, and
21
29
  * silently adopting a key from there is a surprise, not a convenience.
30
+ *
31
+ * Returns the file each variable came from, which is what `doctor` reports.
22
32
  */
23
33
  export function loadEnvFiles() {
24
- loadFile(join(TESTEIYA_HOME, ".env"));
34
+ const sources = new Map();
35
+ loadFile(join(TESTEIYA_HOME, ".env"), sources);
25
36
  let dir = process.cwd();
26
37
  for (let i = 0; i < 8; i++) {
27
- loadFile(join(dir, ".env"));
38
+ loadFile(join(dir, ".env"), sources);
28
39
  const parent = dirname(dir);
29
40
  if (parent === dir)
30
41
  break;
31
42
  dir = parent;
32
43
  }
44
+ return sources;
33
45
  }
34
46
  export function parseEnv(content) {
35
47
  const out = {};
@@ -51,7 +63,7 @@ export function parseEnv(content) {
51
63
  }
52
64
  return out;
53
65
  }
54
- function loadFile(path) {
66
+ function loadFile(path, sources) {
55
67
  if (!existsSync(path))
56
68
  return;
57
69
  let vars;
@@ -62,8 +74,20 @@ function loadFile(path) {
62
74
  return;
63
75
  }
64
76
  for (const [key, value] of Object.entries(vars)) {
65
- if (process.env[key] === undefined)
66
- process.env[key] = value;
77
+ if (process.env[key] !== undefined)
78
+ continue;
79
+ process.env[key] = value;
80
+ sources.set(key, path);
81
+ }
82
+ }
83
+ function packageRoot() {
84
+ let dir = import.meta.dirname;
85
+ while (!existsSync(join(dir, "package.json"))) {
86
+ const parent = dirname(dir);
87
+ if (parent === dir)
88
+ return import.meta.dirname;
89
+ dir = parent;
67
90
  }
91
+ return dir;
68
92
  }
69
93
  //# sourceMappingURL=env.js.map