@orion-qa/orion 3.1.0 → 3.2.0

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 (109) hide show
  1. package/.claude/agents/automation-strategist.md +1 -0
  2. package/.claude/agents/change-agent.md +1 -0
  3. package/.claude/agents/codebase-analyst.md +2 -1
  4. package/.claude/agents/environment-discovery.md +1 -0
  5. package/.claude/agents/evidence-validator.md +1 -0
  6. package/.claude/agents/executor.md +1 -0
  7. package/.claude/agents/failure-analyst.md +2 -1
  8. package/.claude/agents/implementer.md +2 -1
  9. package/.claude/agents/requirement-analyst.md +1 -0
  10. package/.claude/agents/reviewer.md +1 -0
  11. package/.claude/agents/test-reporter.md +1 -0
  12. package/.claude/settings.json +16 -0
  13. package/.claude/skills/architecture-analysis/SKILL.md +1 -1
  14. package/.claude/skills/automation-implementation/SKILL.md +7 -5
  15. package/.claude/skills/automation-review/references/assertion-guard.md +1 -1
  16. package/.claude/skills/code-review/SKILL.md +2 -0
  17. package/.claude/skills/execution/SKILL.md +5 -4
  18. package/.claude/skills/orion/SKILL.md +11 -6
  19. package/.claude/skills/orion/references/assess-fix.md +4 -3
  20. package/.claude/skills/orion/references/batch.md +64 -0
  21. package/.claude/skills/orion/references/blockers.md +1 -1
  22. package/.claude/skills/orion/references/conversation.md +59 -15
  23. package/.claude/skills/orion/references/delivery-formats.md +23 -35
  24. package/.claude/skills/orion/references/doctor.md +1 -1
  25. package/.claude/skills/orion/references/hosts.md +1 -0
  26. package/.claude/skills/orion/references/modes.md +4 -2
  27. package/.claude/skills/orion/references/plain-language.md +55 -0
  28. package/.claude/skills/orion/references/project-context-files.md +2 -1
  29. package/.claude/skills/orion/references/recovery-loop.md +8 -0
  30. package/.claude/skills/orion/references/setup-card.md +18 -3
  31. package/.claude/skills/orion/references/status-lines.md +4 -3
  32. package/.claude/skills/orion/scripts/batch_detect.mjs +98 -0
  33. package/.claude/skills/orion/scripts/batch_state.mjs +179 -0
  34. package/.claude/skills/orion/scripts/browser_setup.mjs +12 -7
  35. package/.claude/skills/orion/scripts/cases_export.py +724 -0
  36. package/.claude/skills/orion/scripts/codemap.mjs +116 -0
  37. package/.claude/skills/orion/scripts/done_check.mjs +195 -0
  38. package/.claude/skills/orion/scripts/fix_plan.mjs +21 -0
  39. package/.claude/skills/orion/scripts/hooks/lean_guard.mjs +162 -0
  40. package/.claude/skills/orion/scripts/lib/table.mjs +116 -0
  41. package/.claude/skills/orion/scripts/quiet.mjs +160 -0
  42. package/.claude/skills/orion/scripts/report_check.mjs +1 -1
  43. package/.claude/skills/orion/scripts/results_parse.mjs +9 -3
  44. package/.claude/skills/orion/scripts/rules.mjs +92 -0
  45. package/.claude/skills/orion/scripts/run_state.mjs +67 -0
  46. package/.claude/skills/orion/scripts/suite_check.mjs +41 -2
  47. package/.claude/skills/orion/templates/project-context/assessment.md +1 -1
  48. package/.claude/skills/orion/templates/project-context/retry-policy.md +6 -0
  49. package/.claude/skills/orion/templates/project-context/test-design.md +6 -0
  50. package/.claude/skills/playwright/templates/dotnet/PageObjects/BasePage.cs +4 -0
  51. package/.claude/skills/playwright/templates/javascript/fixtures/index.js +4 -2
  52. package/.claude/skills/playwright/templates/javascript/fixtures/session.js +9 -6
  53. package/.claude/skills/playwright/templates/javascript/jsconfig.json +3 -2
  54. package/.claude/skills/playwright/templates/javascript/pageObjects/basePage.js +4 -0
  55. package/.claude/skills/playwright/templates/javascript/playwright.config.js +3 -0
  56. package/.claude/skills/playwright/templates/javascript/reporters/summaryReporter.js +1 -1
  57. package/.claude/skills/playwright/templates/javascript/src/config/env.js +29 -1
  58. package/.claude/skills/playwright/templates/project/fixtures/index.ts +4 -2
  59. package/.claude/skills/playwright/templates/project/fixtures/session.ts +7 -5
  60. package/.claude/skills/playwright/templates/project/pageObjects/basePage.ts +4 -0
  61. package/.claude/skills/playwright/templates/project/playwright.config.ts +3 -0
  62. package/.claude/skills/playwright/templates/project/src/config/env.ts +29 -1
  63. package/.claude/skills/playwright/templates/python/page_objects/base_page.py +3 -0
  64. package/.claude/skills/playwright/templates/python/src/config/env.py +34 -2
  65. package/.claude/skills/selenium/templates/csharp-nunit/PageObjects/BasePage.cs +4 -0
  66. package/.claude/skills/selenium/templates/java-testng/src/test/java/automation/pageObjects/BasePage.java +3 -0
  67. package/.claude/skills/selenium/templates/python-pytest/page_objects/base_page.py +3 -0
  68. package/.claude/skills/self-healing/SKILL.md +1 -1
  69. package/.claude/skills/test-reporting/references/tool-mapping.md +13 -9
  70. package/.claude/skills/ui-observation/SKILL.md +1 -0
  71. package/.claude-plugin/plugin.json +15 -2
  72. package/.codex/agents/automation-strategist.toml +1 -0
  73. package/.codex/agents/change-agent.toml +1 -0
  74. package/.codex/agents/codebase-analyst.toml +1 -0
  75. package/.codex/agents/environment-discovery.toml +1 -0
  76. package/.codex/agents/evidence-validator.toml +1 -0
  77. package/.codex/agents/executor.toml +1 -0
  78. package/.codex/agents/failure-analyst.toml +1 -0
  79. package/.codex/agents/implementer.toml +2 -1
  80. package/.codex/agents/requirement-analyst.toml +1 -0
  81. package/.codex/agents/reviewer.toml +1 -0
  82. package/.codex/agents/test-reporter.toml +1 -0
  83. package/.codex/hooks.json +15 -0
  84. package/.cursor/commands/orion.md +1 -1
  85. package/.cursor/hooks.json +10 -0
  86. package/.devin/hooks.v1.json +13 -0
  87. package/.gemini/agents/automation-strategist.md +1 -0
  88. package/.gemini/agents/change-agent.md +1 -0
  89. package/.gemini/agents/codebase-analyst.md +1 -0
  90. package/.gemini/agents/environment-discovery.md +1 -0
  91. package/.gemini/agents/evidence-validator.md +1 -0
  92. package/.gemini/agents/executor.md +1 -0
  93. package/.gemini/agents/failure-analyst.md +1 -0
  94. package/.gemini/agents/implementer.md +2 -1
  95. package/.gemini/agents/requirement-analyst.md +1 -0
  96. package/.gemini/agents/reviewer.md +1 -0
  97. package/.gemini/agents/test-reporter.md +1 -0
  98. package/.gemini/commands/orion.toml +2 -2
  99. package/.github/hooks/orion-lean.json +13 -0
  100. package/.github/prompts/orion.prompt.md +2 -2
  101. package/.windsurf/workflows/orion.md +2 -2
  102. package/AGENTS.md +5 -5
  103. package/README.md +55 -160
  104. package/assets/run-flow.svg +1 -1
  105. package/bin/orion.mjs +6 -6
  106. package/hosts/gemini-extension/gemini-extension.json +1 -1
  107. package/hosts/gemini-extension/hooks/hooks.json +16 -0
  108. package/hosts/gemini-extension/policies/platform.toml +5 -0
  109. package/package.json +5 -1
@@ -0,0 +1,160 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Quiet runner: runs a test, build or install command and prints only what an agent needs (the outcome, every failure
4
+ * with its context, warnings and the runner's summary), saving the full output to a log file it can grep. Command
5
+ * output was the largest part of an agent's context in a measured run (101 KB of tool output in one story, re-read on
6
+ * every later turn: evals/workflows/runs/2026-11-18-cost-breakdown.md), so this is Orion's own version of the
7
+ * "token killer" idea, with nothing to install.
8
+ *
9
+ * Usage (from anywhere inside the workspace):
10
+ * node .claude/skills/orion/scripts/quiet.mjs <command and its arguments>
11
+ * e.g. node .claude/skills/orion/scripts/quiet.mjs npm test --silent -- tests/ui/x.spec.js --retries=0
12
+ * Prints: the command, exit code and duration; the kept lines (failures with up to 8 lines of context each, errors,
13
+ * warnings, the runner's counts and summary, the last lines); `full log: <path>`. Exits with the command's own exit
14
+ * code, so nothing that checks it changes. A redirect or a leading `cd <dir> &&` works as in the shell when the whole
15
+ * command is one quoted argument: `quiet.mjs "cd sut/app && npm test -- x > out.json"`.
16
+ * Allowing quiet.mjs for good allows the commands it runs, so it runs only test, build and install commands (npm test,
17
+ * npm run test/build/lint/e2e/verify…, npm ci/install, npx playwright, pytest, python -m pytest, mvn,
18
+ * gradle/gradlew, dotnet test/build/restore, k6, newman, pip install, node run.js / test*.js / *.spec.js, yarn, pnpm),
19
+ * one command at a time, redirects only inside the workspace; anything else exits 2,
20
+ * so it can't become a way round the host's approval rules. Never prints a secret: values of variables whose names
21
+ * look secret (PASSWORD, TOKEN, SECRET, KEY, AUTH, COOKIE) and Bearer / JWT strings are masked as ***.
22
+ * Logs go to <workspace>/project-context/logs/ (the folder with project-context/ or .claude/ above the current one),
23
+ * never into the suite, with a .gitignore of their own so they are never committed. `ORION_QUIET_LINES=<n>` changes the cap on kept lines (default 60).
24
+ * Exit code: the command's own · 2 a command it doesn't run, or no command.
25
+ */
26
+ import fs from 'node:fs';
27
+ import path from 'node:path';
28
+ import { spawnSync } from 'node:child_process';
29
+ import { pathToFileURL } from 'node:url';
30
+
31
+ const ALLOWED = /^(npm (test|t|ci|install|i)\b|npm run (test|build|lint|typecheck|check|e2e|verify|smoke|compile)[\w:.-]*|npx (--no-install )?playwright (test|install|show-report|--version)\b|pytest\b|python3? -m pytest\b|py -m pytest\b|mvn\b|\.\/mvnw\b|gradle\b|\.\/gradlew\b|dotnet (test|build|restore)\b|k6 (run|version)\b|newman run\b|npx newman run\b|pip3? install\b|python3? -m pip install\b|node (?!-e\b|--eval\b)(?:[\w.-]+\/)*(?:run|test[\w-]*|[\w-]+\.(?:spec|test))\.(?:m?js|cjs)\b|yarn(\s*$| (test|install)\b| run (test|build|lint|typecheck|check|e2e|verify|smoke|compile)[\w:.-]*)|pnpm (test|install|i|run (test|build|lint|typecheck|check|e2e|verify|smoke|compile)[\w:.-]*)\b)/;
32
+ const KEEP = /(\b(error|errors|failed|failing|failure|fail|exception|traceback|assert(ion)?error|timed? ?out|warning|warn|deprecated|npm err|err!|build (success|failure)|tests? run:|passed|skipped|flaky|did not run|interrupted|expected|received|not found|cannot find|unable to)\b|✘|✗|×|^\s*\d+\) |^\s*at .*\.(spec|test)\.|^={3,}|^-{3,} |^\s*\d+ (passed|failed|skipped|flaky))/i;
33
+ const NOISE = /^\s*at .*(node_modules|internal\/|node:)|^\s*$|^\s*(✓|✔|ok \d+|\[\d+\/\d+\].*(✓|passed))/;
34
+ const SECRET_NAME = /(PASSWORD|PASSWD|TOKEN|SECRET|API[_-]?KEY|AUTH|COOKIE)/i;
35
+
36
+ function mask(text) {
37
+ let t = text;
38
+ for (const [k, v] of Object.entries(process.env)) {
39
+ if (SECRET_NAME.test(k) && v && v.length >= 4) t = t.split(v).join('***');
40
+ }
41
+ return t.replace(/\bBearer\s+[A-Za-z0-9._~+/=-]{8,}/g, 'Bearer ***').replace(/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g, '***')
42
+ .replace(/((?:password|passwd|token|secret)\s*[=:]\s*)\S+/gi, '$1***');
43
+ }
44
+
45
+ /** The workspace root: the nearest folder at or above `from` holding project-context/ or .claude/. */
46
+ function workspaceRoot(from) {
47
+ let d = path.resolve(from);
48
+ for (;;) {
49
+ if (fs.existsSync(path.join(d, 'project-context')) || fs.existsSync(path.join(d, '.claude'))) return d;
50
+ const up = path.dirname(d);
51
+ if (up === d) return path.resolve(from);
52
+ d = up;
53
+ }
54
+ }
55
+
56
+ /** The lines worth keeping from a run's output: failures with context, warnings, counts and the tail. */
57
+ export function summarize(raw, cap = 60) {
58
+ const lines = raw.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, '').replace(/\r(?!\n)/g, '\n').split('\n');
59
+ const keep = new Set();
60
+ lines.forEach((l, i) => {
61
+ if (!KEEP.test(l) || NOISE.test(l)) return;
62
+ keep.add(i);
63
+ if (/\b(error|failed|failure|exception|traceback|✘|✗|×)\b|^\s*\d+\) /i.test(l)) {
64
+ for (let j = i + 1; j <= Math.min(lines.length - 1, i + 8); j++) if (!NOISE.test(lines[j])) keep.add(j);
65
+ }
66
+ });
67
+ const tail = lines.map((l, i) => [l, i]).filter(([l]) => l.trim() && !NOISE.test(l)).slice(-8).map(([, i]) => i);
68
+ tail.forEach((i) => keep.add(i));
69
+ const seen = new Set(); const out = [];
70
+ for (const i of [...keep].sort((a, b) => a - b)) {
71
+ const l = lines[i].replace(/\s+$/, '');
72
+ const k = l.trim();
73
+ if (!k || seen.has(k)) continue;
74
+ seen.add(k); out.push(l.length > 300 ? `${l.slice(0, 300)} …` : l);
75
+ }
76
+ if (out.length > cap) return [...out.slice(0, cap - 10), `… ${out.length - cap} more kept lines in the full log …`, ...out.slice(-9)];
77
+ return out;
78
+ }
79
+
80
+ /** Leading `cd <dir> &&` steps and VAR=value assignments, which the shell keeps; the check looks past them. */
81
+ const PREFIX = /^\s*((cd\s+("[^"]*"|'[^']*'|\S+)\s*&&\s*)|([A-Za-z_][A-Za-z0-9_]*=("[^"]*"|'[^']*'|\S*)\s+))*/;
82
+
83
+ /** Several arguments are joined back into one command, each quoted again when it holds a space or a quote, so
84
+ * `quiet.mjs npx playwright test --grep "log in"` runs with "log in" as one argument. One argument is used as given
85
+ * (the form for a redirect or a `cd … &&`: `quiet.mjs "npm test -- x > out.json"`). */
86
+ export function commandOf(argv, win = process.platform === 'win32') {
87
+ if (argv.length === 1) return argv[0].trim();
88
+ const q = (a) => (!/[\s"'$`\\]/.test(a) || /^[<>|&;]+$/.test(a) ? a
89
+ : win ? `"${a.replace(/"/g, '\\"')}"` : `'${a.replace(/'/g, `'\\''`)}'`);
90
+ return argv.map(q).join(' ').trim();
91
+ }
92
+
93
+ /** Why a command is refused, or null. One test, build or install command only: after the leading `cd`/VAR= steps, no
94
+ * second command (`;`, `&&`, `||`, a pipe, `&`, backticks, `$(…)`, a new line), and a redirect only into the workspace
95
+ * (the folder holding project-context/ or .claude/). Once a person allows quiet.mjs, it must not become a way to run
96
+ * anything else. */
97
+ export function refusal(cmd, from = process.cwd()) {
98
+ const rest = cmd.replace(PREFIX, '');
99
+ // Where the command runs: the folder after its leading `cd` steps; a redirect is resolved from there.
100
+ let at = path.resolve(from);
101
+ for (const m of (cmd.match(PREFIX)?.[0] || '').matchAll(/cd\s+("[^"]*"|'[^']*'|\S+)/g)) at = path.resolve(at, m[1].replace(/^["']|["']$/g, ''));
102
+ const root = workspaceRoot(from);
103
+ if (!ALLOWED.test(rest)) return 'runs only test, build and install commands';
104
+ if (/\$\(|`/.test(rest.replace(/'[^']*'/g, "''"))) return 'runs one command only (no $(…) or backticks)';
105
+ const bare = rest.replace(/'[^']*'|"[^"]*"/g, '""');
106
+ if (/[;|`\n\r]|&&|\$\(|<\(|(^|[^>0-9])&(?!>)|&\s/.test(bare.replace(/\d?>&\d/g, ''))) return 'runs one command only (no ;, &&, ||, pipes, & or $(…) after it)';
107
+ for (const m of bare.matchAll(/\d?>>?\s*([^\s&]+)/g)) {
108
+ if (/^&\d$/.test(m[1])) continue;
109
+ const target = path.resolve(at, m[1]);
110
+ if (/^~/.test(m[1]) || (target !== root && !target.startsWith(root + path.sep))) return `writes output only inside the workspace (not ${m[1]})`;
111
+ }
112
+ return null;
113
+ }
114
+
115
+ /** The folders a command's redirects write into (inside the workspace, checked by refusal), so a first run doesn't
116
+ * fail with "Directory nonexistent" before project-context/results/ exists. */
117
+ export function redirectDirs(cmd, from = process.cwd()) {
118
+ let at = path.resolve(from);
119
+ for (const m of (cmd.match(PREFIX)?.[0] || '').matchAll(/cd\s+("[^"]*"|'[^']*'|\S+)/g)) at = path.resolve(at, m[1].replace(/^["']|["']$/g, ''));
120
+ const bare = cmd.replace(PREFIX, '').replace(/'[^']*'|"[^"]*"/g, '""');
121
+ return [...bare.matchAll(/\d?>>?\s*([^\s&]+)/g)].filter((m) => !/^&\d$/.test(m[1])).map((m) => path.dirname(path.resolve(at, m[1])));
122
+ }
123
+
124
+ export const allowed = (cmd) => !refusal(cmd);
125
+
126
+ function main() {
127
+ const argv = process.argv.slice(2);
128
+ const cmd = commandOf(argv);
129
+ if (!cmd) { console.log('usage: node .claude/skills/orion/scripts/quiet.mjs <test, build or install command>'); process.exit(2); }
130
+ const why = refusal(cmd);
131
+ if (why) {
132
+ console.log(`quiet: ${why}; run this one directly: ${mask(cmd).slice(0, 120)}`);
133
+ process.exit(2);
134
+ }
135
+ for (const d of redirectDirs(cmd)) { try { fs.mkdirSync(d, { recursive: true }); } catch { /* the shell reports it */ } }
136
+ const root = workspaceRoot(process.cwd());
137
+ const logs = path.join(root, 'project-context', 'logs');
138
+ fs.mkdirSync(logs, { recursive: true });
139
+ // The logs stay out of git: an ignore file of their own, never an edit to the project's own .gitignore.
140
+ const ignore = path.join(logs, '.gitignore');
141
+ if (!fs.existsSync(ignore)) fs.writeFileSync(ignore, '*\n');
142
+ const stamp = new Date().toISOString().replace(/[-:]/g, '').replace(/\..*/, '');
143
+ const slug = cmd.replace(/[^\w]+/g, '-').slice(0, 40).replace(/-+$/, '');
144
+ const log = path.join(logs, `${stamp}-${slug}.log`);
145
+ const t0 = Date.now();
146
+ const r = spawnSync(cmd, { shell: true, encoding: 'utf8', maxBuffer: 256 * 1024 * 1024,
147
+ env: { ...process.env, FORCE_COLOR: '0', npm_config_progress: 'false', npm_config_fund: 'false', npm_config_audit: 'false' } });
148
+ const raw = mask(`${r.stdout || ''}${r.stderr || ''}`);
149
+ fs.writeFileSync(log, raw);
150
+ const code = r.status === null ? 1 : r.status;
151
+ const cap = Number(process.env.ORION_QUIET_LINES) || 60;
152
+ const kept = summarize(raw, cap);
153
+ const secs = ((Date.now() - t0) / 1000).toFixed(1);
154
+ console.log(`$ ${mask(cmd)}\nexit ${code} · ${secs}s · ${raw.split('\n').length} lines of output, ${kept.length} kept`);
155
+ if (kept.length) console.log(kept.join('\n'));
156
+ console.log(`full log: ${path.relative(process.cwd(), log) || log}`);
157
+ process.exit(code);
158
+ }
159
+
160
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) main();
@@ -20,7 +20,7 @@ const AGENTS = 'requirement-analyst|environment-discovery|codebase-analyst|autom
20
20
  const BANNED = [
21
21
  [/\bD-\d{3}\b/, 'a decision id: move it to the details block'],
22
22
  [/\bGate \d\b/, 'a gate number: say what happened in plain words'],
23
- [new RegExp(`\\b(${AGENTS})\\b`), 'an agent name: say what was done, not who did it'],
23
+ [new RegExp(`(?<![\\w./-])(${AGENTS})(?![\\w/-]|\\.\\w)`), 'an agent name: say what was done, not who did it'], // not inside a name such as performance-reviewer.web.app
24
24
  [/\b[UPM]\d{1,2}\b(?!\/)/, 'a rule code: describe the issue in plain words'],
25
25
  [/\/tmp\/|\\Temp\\|AppData/, 'a temporary-folder path: use a path inside the workspace'],
26
26
  [/\(unknown\)|: unknown\b|\bunknown\./, 'a bare "unknown": say what was not checked and why'],
@@ -4,7 +4,7 @@
4
4
  * counted run (execution skill); the Orion graph and the failure analyst read its output.
5
5
  *
6
6
  * Usage (from the workspace root):
7
- * node .claude/skills/orion/scripts/results_parse.mjs <report file or folder> [...] --run <run id> [--attempt-run <n>]
7
+ * node .claude/skills/orion/scripts/results_parse.mjs <report file or folder> [...] --run <run id>-<n>
8
8
  * [--out project-context/results/<run id>.json]
9
9
  *
10
10
  * Reads: JUnit XML (Playwright `junit`, Maven Surefire/Failsafe, Gradle, pytest `--junitxml`, Cypress and WebdriverIO
@@ -159,7 +159,7 @@ function main() {
159
159
  if (!inputs.length || !opt.run) usage();
160
160
  if (!/^[\w.-]+$/.test(opt.run)) usage('--run takes a run id such as 20261112-1430');
161
161
 
162
- const rows = []; const sources = []; const skipped = [];
162
+ const rows = []; const sources = []; const skipped = []; const runErrors = [];
163
163
  for (const f of reportFiles(inputs)) {
164
164
  let text;
165
165
  try { text = fs.readFileSync(f, 'utf8').replace(/^/, ''); } catch { usage(`can't read ${f}`); }
@@ -167,7 +167,12 @@ function main() {
167
167
  let found = [];
168
168
  let format = null;
169
169
  if (/^\s*\{/.test(text)) {
170
- try { const j = JSON.parse(text); if (Array.isArray(j.suites) && j.stats) { format = 'playwright-json'; found = parsePlaywrightJson(j, rel); } } catch { /* not JSON */ }
170
+ try {
171
+ const j = JSON.parse(text);
172
+ if (Array.isArray(j.suites) && j.stats) { format = 'playwright-json'; found = parsePlaywrightJson(j, rel); }
173
+ // A run that failed before any test (global setup, sign-in, config) lists it in errors[]: say so, never "no tests".
174
+ if (Array.isArray(j.errors) && j.errors.length) runErrors.push(`${rel}: ${String(j.errors[0].message || j.errors[0].value || j.errors[0]).split('\n')[0].replace(/((?:password|passwd|token|secret)\s*[=:]\s*)\S+/gi, '$1***').slice(0, 200)}`);
175
+ } catch { /* not JSON */ }
171
176
  } else if (/<TestRun\b/.test(text)) { format = 'trx'; found = parseTrx(text, rel); }
172
177
  else if (/<testsuites?\b/.test(text)) { format = 'junit'; found = parseJUnit(text, rel); }
173
178
  if (!format) { skipped.push(rel); continue; }
@@ -191,6 +196,7 @@ function main() {
191
196
  for (const t of tests) totals[t.status]++;
192
197
  const report = { format: FORMAT, run_id: opt.run, sources, skipped_files: skipped, totals, tests };
193
198
  const text = `${JSON.stringify(report, null, 2)}\n`;
199
+ if (!tests.length && runErrors.length) { console.log(`results: the run failed before any test ran: ${runErrors[0]}`); process.exit(1); }
194
200
  if (!tests.length) { console.log(`results: no test results in ${inputs.join(', ')}${skipped.length ? ` (not reports: ${skipped.join(', ')})` : ''}`); process.exit(1); }
195
201
  if (opt.out) {
196
202
  insideWorkspace(opt.out, '--out');
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Rules digest: prints only the section of a skill or reference file that a step needs, instead of the whole file.
4
+ * In measured runs the agent's largest tool output was Orion's own rule files dumped whole (`conversation.md`,
5
+ * `setup-card.md`, 9–24 KB per read) and then re-read on every later turn (evals/workflows/runs/2026-11-18-cost-
6
+ * breakdown.md). Orion's own version of the "knowledge graph instead of whole files" idea, for its rules.
7
+ *
8
+ * Usage (from the workspace root; a plugin install: run it from the skill's own folder):
9
+ * node .claude/skills/orion/scripts/rules.mjs <file> --list the sections, each with its size
10
+ * node .claude/skills/orion/scripts/rules.mjs <file> <words>... the section(s) whose title holds all the words
11
+ * node .claude/skills/orion/scripts/rules.mjs <file> --all the whole file (only when you need all of it)
12
+ * <file>: a path, or a short name looked up under .claude/skills/ (`conversation`, `setup-card`, `orion/SKILL`,
13
+ * `execution/SKILL`, `delivery-formats`, …).
14
+ * Sections are the Markdown headings (##, ###) and the top-level numbered items of a list (`3.`, `3b.`, `10.`), whose
15
+ * title is their bold text. Fenced code blocks inside a section stay with it. Output is capped at 8 KB unless --all.
16
+ * Exit code: 0 printed · 1 no section matched (the list is printed instead) · 2 wrong arguments or no such file.
17
+ */
18
+ import fs from 'node:fs';
19
+ import path from 'node:path';
20
+ import { fileURLToPath, pathToFileURL } from 'node:url';
21
+
22
+ const CAP = 8 * 1024;
23
+
24
+ function resolve(name) {
25
+ if (fs.existsSync(name) && fs.statSync(name).isFile()) return name;
26
+ const roots = ['.claude/skills', path.join(path.dirname(fileURLToPath(import.meta.url)), '..', '..')];
27
+ for (const root of roots) {
28
+ if (!fs.existsSync(root)) continue;
29
+ const want = name.replace(/\.md$/, '').toLowerCase();
30
+ const hits = [];
31
+ const walk = (d) => {
32
+ for (const e of fs.readdirSync(d, { withFileTypes: true })) {
33
+ const p = path.join(d, e.name);
34
+ if (e.isDirectory()) { if (!['templates', 'node_modules', 'scripts'].includes(e.name)) walk(p); }
35
+ else if (e.name.endsWith('.md')) {
36
+ const rel = p.replace(/\\/g, '/').toLowerCase().replace(/\.md$/, '');
37
+ if (rel.endsWith(`/${want}`)) hits.push(p);
38
+ }
39
+ }
40
+ };
41
+ walk(root);
42
+ if (hits.length === 1) return hits[0];
43
+ if (hits.length > 1) { console.log(`rules: "${name}" is ambiguous: ${hits.join(', ')}`); process.exit(2); }
44
+ }
45
+ return null;
46
+ }
47
+
48
+ /** Sections of a Markdown file: headings and top-level numbered items, with their line ranges. */
49
+ export function sections(text) {
50
+ const lines = text.split('\n');
51
+ const starts = [];
52
+ let fence = false;
53
+ lines.forEach((l, i) => {
54
+ if (/^\s*(```|~~~)/.test(l)) fence = !fence;
55
+ if (fence) return;
56
+ const h = l.match(/^(#{2,4})\s+(.*)/);
57
+ const n = l.match(/^(\d+[a-z]?)\.\s+(?:\*\*(.+?)\*\*)?(.*)/);
58
+ if (h) starts.push({ line: i, level: h[1].length, title: h[2].trim() });
59
+ else if (n) starts.push({ line: i, level: 9, title: `${n[1]}. ${(n[2] || n[3]).trim().slice(0, 90)}` });
60
+ });
61
+ return starts.map((s, k) => {
62
+ let end = lines.length;
63
+ for (let j = k + 1; j < starts.length; j++) {
64
+ if (starts[j].level <= s.level || (s.level === 9 && starts[j].level === 9) || (s.level < 9 && starts[j].level < 9 && starts[j].level <= s.level)) { end = starts[j].line; break; }
65
+ }
66
+ const body = lines.slice(s.line, end).join('\n').replace(/\s+$/, '');
67
+ return { title: s.title, start: s.line + 1, bytes: Buffer.byteLength(body), body };
68
+ });
69
+ }
70
+
71
+ function main() {
72
+ const [name, ...rest] = process.argv.slice(2);
73
+ if (!name) { console.log('usage: node .claude/skills/orion/scripts/rules.mjs <file> (--list | --all | <words>...)'); process.exit(2); }
74
+ const file = resolve(name);
75
+ if (!file) { console.log(`rules: no such file: ${name}`); process.exit(2); }
76
+ const text = fs.readFileSync(file, 'utf8');
77
+ if (rest[0] === '--all') { process.stdout.write(text); return; }
78
+ const secs = sections(text);
79
+ const list = () => {
80
+ console.log(`${file} · ${Buffer.byteLength(text)} bytes · ${secs.length} sections (read one with: rules.mjs ${name} <words from its title>)`);
81
+ for (const s of secs) console.log(` ${String(s.start).padStart(4)} ${(s.bytes / 1024).toFixed(1).padStart(5)} KB ${s.title}`);
82
+ };
83
+ if (!rest.length || rest[0] === '--list') { list(); return; }
84
+ const words = rest.join(' ').toLowerCase().split(/\s+/).filter(Boolean);
85
+ const hits = secs.filter((s) => words.every((w) => s.title.toLowerCase().includes(w)));
86
+ if (!hits.length) { console.log(`rules: no section of ${file} has "${rest.join(' ')}" in its title`); list(); process.exit(1); }
87
+ let out = hits.map((s) => `<!-- ${file}:${s.start} · ${s.title} -->\n${s.body}`).join('\n\n');
88
+ if (Buffer.byteLength(out) > CAP) out = `${out.slice(0, CAP)}\n… cut at 8 KB: narrow the words, or use --all`;
89
+ console.log(out);
90
+ }
91
+
92
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) main();
@@ -20,6 +20,16 @@
20
20
  * state <stack|ui_map|design|build|run|heals|code> "<value>" replaces that Run state line (code: the header line)
21
21
  * metric <name>=<value> [<name>=<value> …] sets fields of the Metrics line (`stopped` defaults to now when given
22
22
  * as `stopped=now`); `+1` adds one to a number (e.g. delegations=+1)
23
+ * Read-only (nothing is written; use them alone, not with `+`):
24
+ * status where the run stands, for a run cut off or picked up in a new session:
25
+ * each gate's state, the first gate not ✓ (the loop's next step), the
26
+ * gates already passed (not redone unless their inputs changed), the Run
27
+ * state lines and the last 3 log rows. Exit 0 open · 4 COMPLETE (gate 8 ✓)
28
+ * budget [--usage <usage.json>] minutes since the run started (and est. USD from usage_report.mjs's
29
+ * totals.usd_est, Claude Code only; else "unknown") against the run budget
30
+ * in project-context/retry-policy.md ("Run budget"; defaults 60 min, USD 10).
31
+ * Minutes are wall time since the run started, waits for the user included.
32
+ * Exit 0 within · 3 over (ask the user at the next gate: carry on or stop)
23
33
  * Output: one line per action. Exit code: 0 done · 1 the run file or a row wasn't found · 2 wrong arguments.
24
34
  * Never writes secrets: refuses a value that looks like `password=…`, a bearer token or a JWT.
25
35
  */
@@ -153,8 +163,65 @@ function apply(lines, act, t) {
153
163
  return lines;
154
164
  }
155
165
 
166
+ /** `status`: where a run stands, so a new session continues it instead of starting over. */
167
+ function status(file, lines) {
168
+ const gates = [];
169
+ for (const l of lines) {
170
+ const m = l.match(/^\| ([1-8]) \| (\S+) \| ([^|]*)\| ([^|]*)\| ([^|]*)\| ([^|]*)\| ([^|]*)\|/);
171
+ if (m) gates.push({ gate: +m[1], state: m[2], agent: m[3].trim(), task: m[4].trim(), status: m[7].trim() });
172
+ }
173
+ if (gates.length !== 8) die(1, `${file}: expected 8 gate rows, found ${gates.length}`);
174
+ const req = (lines.find((l) => /^requirement: /.test(l)) || '').slice(13);
175
+ console.log(`run: ${path.basename(file, '.md')} · ${req}`);
176
+ console.log(`gates: ${gates.map((g) => `${g.gate} ${g.state}`).join(' ')}`);
177
+ const done = gates.filter((g) => g.state === '✓').map((g) => g.gate);
178
+ const next = gates.find((g) => g.state !== '✓');
179
+ if (!next) { console.log('state: COMPLETE (gate 8 ✓): nothing to resume'); process.exit(4); }
180
+ console.log(`passed: ${done.length ? done.join(', ') : 'none'} (not redone unless the requirement, the code or the app changed since)`);
181
+ console.log(`next: gate ${next.gate} (${next.state}${next.task ? `, task: ${next.task}` : ''}${next.status ? `, last status: ${next.status}` : ''}) · ${next.agent}`);
182
+ for (const l of lines.filter((x) => /^- (stack|ui_map|design|build|run|heals): /.test(x))) {
183
+ console.log(`state ${/<[^>]+>/.test(l) ? `${l.slice(2, l.indexOf(':'))}: not recorded` : l.slice(2)}`);
184
+ }
185
+ const i = lines.findIndex((l) => /^### Log/.test(l));
186
+ const log = i < 0 ? [] : lines.slice(i + 3).filter((l, k, arr) => l.startsWith('|') && arr.slice(0, k).every((x) => x.startsWith('|')));
187
+ for (const l of log.slice(-3)) console.log(`log ${l}`);
188
+ }
189
+
190
+ /** `budget`: minutes (and est. USD where known) against the run budget in retry-policy.md. */
191
+ function budget(file, lines, rest) {
192
+ const req = (lines.find((l) => /^requirement: /.test(l)) || '');
193
+ const st = req.match(/started (\d{4}-\d\d-\d\dT\d\d:\d\d)/);
194
+ if (!st) die(1, `${file}: no start time on the requirement line`);
195
+ const mins = Math.round((Date.now() - new Date(st[1]).getTime()) / 60000);
196
+ const policy = path.join('project-context', 'retry-policy.md');
197
+ const ptext = fs.existsSync(policy) ? fs.readFileSync(policy, 'utf8') : '';
198
+ const limMin = +((ptext.match(/^- minutes:\s*(\d+)/m) || [])[1] || 60);
199
+ const limUsd = +((ptext.match(/^- usd:\s*([\d.]+)/m) || [])[1] || 10);
200
+ let usd = 'unknown';
201
+ const ui = rest.indexOf('--usage');
202
+ if (ui >= 0) {
203
+ const f = rest[ui + 1];
204
+ try { const v = JSON.parse(fs.readFileSync(f, 'utf8')).totals?.usd_est; if (typeof v === 'number') usd = v; } catch { /* stays unknown */ }
205
+ }
206
+ const over = [];
207
+ if (mins > limMin) over.push(`${mins} min of ${limMin}`);
208
+ if (typeof usd === 'number' && usd > limUsd) over.push(`est. USD ${usd.toFixed(2)} of ${limUsd}`);
209
+ console.log(`budget: ${mins} min of ${limMin} (wall time, waits included) · est. USD ${typeof usd === 'number' ? usd.toFixed(2) : 'unknown'} of ${limUsd}${ptext ? '' : ' (defaults: no project-context/retry-policy.md)'}`);
210
+ if (over.length) {
211
+ console.log(`over: ${over.join(', ')}: at the next gate, ask the user one line: carry on (and by how much) or stop here with what exists`);
212
+ process.exit(3);
213
+ }
214
+ }
215
+
156
216
  function main() {
157
217
  const argv = process.argv.slice(2);
218
+ if (['status', 'budget'].includes(argv[1])) {
219
+ const file = argv[0];
220
+ if (!file || !fs.existsSync(file)) die(file ? 1 : 2, file ? `no run file ${file}` : 'usage: run_state.mjs <run file> status | budget [--usage <usage.json>]');
221
+ insideWorkspace(file, 'the run file');
222
+ const lines = fs.readFileSync(file, 'utf8').split('\n');
223
+ return argv[1] === 'status' ? status(file, lines) : budget(file, lines, argv.slice(2));
224
+ }
158
225
  if (argv[0] === 'init') return init(argv.slice(1));
159
226
  const file = argv[0];
160
227
  if (!file || !fs.existsSync(file)) die(file ? 1 : 2, file ? `no run file ${file}` : 'usage: run_state.mjs <run file> <action> [+ <action> …] | init <key> …');
@@ -33,6 +33,11 @@ import { scan } from './lib/scan.mjs';
33
33
 
34
34
  const SKIP = new Set(['node_modules', '.git', 'auth', 'playwright-report', 'test-results', 'allure-results', 'blob-report',
35
35
  'bin', 'obj', 'target', 'reports', 'TestResults', '.venv', 'venv', '__pycache__', '.pytest_cache', 'test-output']);
36
+ // Orion's own install and records, skipped only at the project's top level (where the installer puts them): in an
37
+ // existing suite they sit inside the project folder and their starter templates hold {{TOKENS}} by design (an
38
+ // existing-suite run on 2026-11-18 was told its suite had placeholders). A suite's own `src/registry/` is still read.
39
+ const SKIP_TOP = new Set(['.claude', 'registry', '.cursor', '.cursor-plugin', '.gemini', '.codex', '.windsurf',
40
+ 'project-context', '.ui-map']);
36
41
 
37
42
  /** Layer patterns per language: `ui` holds the layers only UI suites need, `api` those only API suites need. */
38
43
  const LANGS = {
@@ -131,7 +136,7 @@ function filesUnder(root) {
131
136
  const out = [];
132
137
  const walk = (dir) => {
133
138
  for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
134
- if (e.isDirectory()) { if (!SKIP.has(e.name)) walk(path.join(dir, e.name)); }
139
+ if (e.isDirectory()) { if (!SKIP.has(e.name) && !(dir === root && SKIP_TOP.has(e.name))) walk(path.join(dir, e.name)); }
135
140
  else out.push(path.relative(root, path.join(dir, e.name)).split(path.sep).join('/'));
136
141
  }
137
142
  };
@@ -140,6 +145,23 @@ function filesUnder(root) {
140
145
  }
141
146
 
142
147
  /** The findings for one suite folder, as printable lines (null when no suite is found there). */
148
+ /**
149
+ * Starter placeholders left in a project: a starter copied but not filled turns every {{TOKEN}} into a URL like
150
+ * /%7B%7BLOGIN_PATH%7D%7D or a label no page has, and every test times out (team demo, 2026-11-13). Every kind of
151
+ * project, including k6, Pact, Newman and Karate; text files only; node_modules and reports are skipped.
152
+ */
153
+ function unfilled(root, files = filesUnder(root)) {
154
+ const out = [];
155
+ for (const f of files) {
156
+ if (!/\.(m?[jt]sx?|py|java|cs|json|properties|xml|ya?ml|feature|md|csproj|cfg|ini|toml|txt)$|(^|\/)\.env\.example$|(^|\/)gitignore$/.test(f)) continue;
157
+ let text = '';
158
+ try { text = fs.readFileSync(path.join(root, f), 'utf8'); } catch { continue; }
159
+ const left = [...new Set(text.match(/\{\{[A-Z][A-Z0-9_]*\}\}/g) || [])];
160
+ if (left.length) out.push(`${root}/${f}: unfilled starter placeholder(s) ${left.join(', ')}: fill every {{TOKEN}} from the UI map or the API's answers before running (the starter's templates README)`);
161
+ }
162
+ return out;
163
+ }
164
+
143
165
  function check(root) {
144
166
  const files = filesUnder(root);
145
167
  const lang = Object.keys(LANGS).find((k) => files.some((f) => LANGS[k].detect.test(f)));
@@ -155,6 +177,7 @@ function check(root) {
155
177
  for (const [layer, rx] of Object.entries(layers)) {
156
178
  if (!files.some((f) => rx.test(f))) out.push(`${root}: missing the ${layer} layer`);
157
179
  }
180
+ out.push(...unfilled(root, files));
158
181
  for (const f of files) {
159
182
  if (LOCATORS_FILE.test(f)) out.push(`${root}/${f}: a separate locators file; locators belong in their page object (P17)`);
160
183
  }
@@ -166,6 +189,19 @@ function check(root) {
166
189
  for (const [rx, what] of rules) if (!rx.test(text)) out.push(`${root}/${file}: lacks ${what} (P14)`);
167
190
  }
168
191
  }
192
+ // Every Playwright project a package.json script names must exist in the config, or `npm test` stops at once with
193
+ // 'Project(s) "api" not found' (a rehearsal on a real site: the API project was removed, the script kept naming it).
194
+ const config = files.find((f) => /^playwright\.config\.(js|ts|mjs|cjs)$/.test(f));
195
+ if (config && files.includes('package.json')) {
196
+ let scripts = {};
197
+ try { scripts = JSON.parse(read('package.json')).scripts || {}; } catch { /* not JSON: other checks report it */ }
198
+ const names = new Set([...read(config).matchAll(/name:\s*['"]([\w-]+)['"]/g)].map((m) => m[1]));
199
+ for (const [script, cmd] of Object.entries(scripts)) {
200
+ for (const m of String(cmd).matchAll(/--project[=\s]+['"]?([\w-]+)/g)) {
201
+ if (!names.has(m[1])) out.push(`${root}/package.json: script "${script}" runs project "${m[1]}", which ${config} doesn't define (npm run ${script} would stop at once): remove it from the script or keep the project`);
202
+ }
203
+ }
204
+ }
169
205
  for (const f of files) {
170
206
  if (!L.source.test(f) || L.envAllowed.test(f)) continue;
171
207
  read(f).split('\n').forEach((line, i) => {
@@ -214,7 +250,10 @@ function main() {
214
250
  }
215
251
  const findings = check(clean);
216
252
  if (findings === null) {
217
- console.log(`${root}: no suite found (no playwright.config, conftest.py, pom.xml or .csproj at its root)`);
253
+ // Not one of the suites whose layers this script knows (k6, Pact, Newman, Karate): still no placeholder may remain.
254
+ const left = unfilled(clean);
255
+ if (left.length) { left.forEach((f) => console.log(f)); console.log(`suite check: ${left.length} finding(s)`); process.exit(1); }
256
+ console.log(`${root}: no suite found (no playwright.config, conftest.py, pom.xml or .csproj at its root); no starter placeholders left`);
218
257
  process.exit(2);
219
258
  }
220
259
  findings.forEach((f) => console.log(f));
@@ -24,7 +24,7 @@
24
24
  <summary>All findings and details for engineers</summary>
25
25
 
26
26
  ### Findings
27
- Severity: critical = a secret in code (U2) · blocking = U rules · major = P rules · minor = M rules. "Detected by": `script` (suite_check --existing, reuse_check) or `judged` (reviewer). Quotes never show a secret. "Changes": every file the fix edits (a fix may change only these, once ticked), never the app's files.
27
+ Severity: critical = a secret in code (U2) · blocking = U rules · major = P rules · minor = M rules. "Rule": one rule id (U, P or M), never a description; something that breaks no rule is a note under the table, not a finding; a script finding keeps the id its script printed (`unused (U9)` is U9). "Detected by": `script` (suite_check --existing, reuse_check) or `judged` (reviewer). Quotes never show a secret. "Changes": every file the fix edits (a fix may change only these, once ticked), including every file that calls a method the fix moves, renames or removes (a P1 move changes the tests that called the page method), never the app's files.
28
28
 
29
29
  | F | Rule | Severity | File:line | Quote | Detected by | Effort (S/M/L) | Proposed fix | Changes | Parity risk |
30
30
  |---|---|---|---|---|---|---|---|---|---|
@@ -22,6 +22,12 @@ Defaults; edit to change. Read by the orchestrator before every RETRY.
22
22
  | APPLICATION_DEFECT | 0 | defect draft; never heal |
23
23
  | UNKNOWN | 0 | ESCALATE |
24
24
  | Rejected RESULT (any agent) | 1 | retry with the rejection reason in the brief |
25
+ | Done check (`done_check.mjs`, SKILL step 4d) | 3 rounds | act on the first FAIL row's `next:`, run it again; then deliver with the failing rows as ⚠️ lines |
25
26
 
26
27
  ## Run-level cap
27
28
  Stop and escalate if a run exceeds 6 heal attempts in total or 3 rejected RESULTs.
29
+
30
+ ## Run budget (single run; batch mode has its own cap in `batch.json`)
31
+ A soft limit: when `run_state.mjs <run file> budget` exits 3, the orchestrator asks one line at the next gate ("This run has taken 64 minutes (budget 60). Carry on, and for how long, or stop here with what exists?") and records the reply. Never a silent stop, never a silent overrun. Minutes are wall time since the run started, waits for the user included; USD is Claude Code's estimate from `usage_report.mjs` (other hosts: unknown, so only minutes count there).
32
+ - minutes: 60
33
+ - usd: 10
@@ -1,6 +1,12 @@
1
1
  # Test design: <story> · <date> · accepted by the user on <date> (decisions.md D-nnn)
2
2
  Saved by the orchestrator at Gate 4 as `project-context/test-designs/<story>/design.md`, every run, so later runs, the graph and reviews read the accepted cases instead of rebuilding them.
3
3
 
4
+ ## Files (existing suite: the plan the user approved with the test cases)
5
+ | File | New or change | Why (a new file says why no existing one fits) |
6
+ |---|---|---|
7
+ | <pages/SettingsPage.ts> | new | <no page object for Settings yet> |
8
+ | <pages/DashboardPage.ts> | change | <add openSettings()> |
9
+
4
10
  ## Intent
5
11
  <one paragraph: what the story must prove, in the requirement's words>
6
12
 
@@ -28,6 +28,10 @@ public abstract class BasePage(IPage page)
28
28
  /// <exception cref="AutomationError">With the URL and the HTTP status (or the network error) when the page doesn't open.</exception>
29
29
  public async Task<BasePage> OpenAsync()
30
30
  {
31
+ if (System.Text.RegularExpressions.Regex.IsMatch(PagePath, @"\{\{[A-Z_]+\}\}"))
32
+ {
33
+ throw new AutomationError("Open", PagePath, "unfilled starter placeholder: fill it in the test data from the UI map");
34
+ }
31
35
  IResponse? response;
32
36
  try
33
37
  {
@@ -38,10 +38,12 @@ const test = base.test.extend(/** @type {import('@playwright/test').Fixtures<Sui
38
38
  * stale (the setup project didn't run, e.g. UI mode with only the tests' project ticked, or the session is old).
39
39
  * Normal runs, where setup has just signed in, reuse its session and do nothing here.
40
40
  */
41
- session: [async ({ browser }, use, workerInfo) => {
41
+ session: [async ({ playwright, browserName, channel, headless, launchOptions }, use, workerInfo) => {
42
42
  const projectUse = workerInfo.project.use;
43
43
  if (projectUse.storageState === paths.userSession) {
44
- const why = await ensureSession(browser, projectUse);
44
+ /** Starts this project's browser, with its channel, only when the session must be renewed. */
45
+ const launch = () => playwright[browserName].launch({ ...launchOptions, channel, headless });
46
+ const why = await ensureSession(launch, projectUse);
45
47
  if (why) logger.info(`Signed in again before the tests: ${why}`);
46
48
  }
47
49
  await use();
@@ -59,19 +59,22 @@ function staleReason(file = paths.userSession, maxAgeMinutes = flags.sessionMaxA
59
59
  }
60
60
 
61
61
  /**
62
- * Signs in again in a fresh context when the saved session can't be used; does nothing when it can.
63
- * @param {import('@playwright/test').Browser} browser The worker's browser.
64
- * @param {{ baseURL?: string, httpCredentials?: import('@playwright/test').HTTPCredentials }} use The project's settings.
62
+ * Signs in again in a fresh browser when the saved session can't be used; does nothing (and starts no browser) when
63
+ * it can, so projects that never sign in again, such as API tests, don't need a browser at all.
64
+ * @param {() => Promise<import('@playwright/test').Browser>} launch Starts the project's browser (its channel included).
65
+ * @param {{ baseURL?: string, httpCredentials?: import('@playwright/test').HTTPCredentials | import('@playwright/test').HTTPCredentials[] }} use The project's settings (newer Playwright types allow a list of credentials; the first is used).
65
66
  * @returns {Promise<string | null>} Why it signed in again, or `null` when the saved session was used.
66
67
  */
67
- async function ensureSession(browser, use) {
68
+ async function ensureSession(launch, use) {
68
69
  const why = staleReason();
69
70
  if (!why) return null;
70
- const context = await browser.newContext({ baseURL: use.baseURL, httpCredentials: use.httpCredentials });
71
+ const browser = await launch();
71
72
  try {
73
+ const httpCredentials = Array.isArray(use.httpCredentials) ? use.httpCredentials[0] : use.httpCredentials;
74
+ const context = await browser.newContext({ baseURL: use.baseURL, httpCredentials });
72
75
  await signInAndSave(await context.newPage());
73
76
  } finally {
74
- await context.close();
77
+ await browser.close();
75
78
  }
76
79
  return why;
77
80
  }
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "checkJs": true,
4
- "module": "commonjs",
4
+ "module": "nodenext",
5
5
  "target": "es2022",
6
- "moduleResolution": "node",
6
+ "moduleResolution": "nodenext",
7
+ "types": ["node"],
7
8
  "resolveJsonModule": true,
8
9
  "strict": false
9
10
  },
@@ -26,6 +26,10 @@ class BasePage {
26
26
  * @throws {AutomationError} With the URL and the HTTP status (or the network error) when the page doesn't open.
27
27
  */
28
28
  async open() {
29
+ if (/\{\{[A-Z_]+\}\}/.test(String(this.path))) {
30
+ // A starter copied but not filled: say so now, instead of opening /%7B%7BLOGIN_PATH%7D%7D and timing out.
31
+ throw new AutomationError('Open', this.path, 'unfilled starter placeholder: fill it in resources/testData from the UI map');
32
+ }
29
33
  let response;
30
34
  try {
31
35
  response = await this.page.goto(this.path, { waitUntil: 'domcontentloaded' });
@@ -30,6 +30,9 @@ module.exports = defineConfig({
30
30
  reporter: [['list'], [path.join(__dirname, 'reporters', 'summaryReporter.js'), { outputFile: paths.summaryReport }], ['html', { open: 'never', outputFolder: paths.htmlReport }]],
31
31
  use: {
32
32
  baseURL: env.baseUrl(),
33
+ // The installed Chrome or Edge for every project, not only the UI ones: the session fixture may start a browser in
34
+ // any signed-in project (api too), and a project without a channel would need Playwright's own browser download.
35
+ channel: env.browserChannel(),
33
36
  httpCredentials: env.httpCredentials(),
34
37
  trace: 'retain-on-failure',
35
38
  screenshot: 'only-on-failure',
@@ -205,7 +205,7 @@ class SummaryReporter {
205
205
  acs: test.tags.filter((t) => /^@AC-/.test(t)).map((t) => t.slice(1)),
206
206
  project: test.parent.project()?.name || '',
207
207
  file: `${path.relative(paths.root, test.location.file).split(path.sep).join('/')}:${test.location.line}`,
208
- outcome: /** @type {Row['outcome']} */ ({ expected: 'passed', unexpected: 'failed', flaky: 'flaky', skipped: 'skipped' })[outcome],
208
+ outcome: /** @type {Row['outcome']} */ (({ expected: 'passed', unexpected: 'failed', flaky: 'flaky', skipped: 'skipped' })[outcome]),
209
209
  durationMs: last ? last.duration : 0,
210
210
  attempts: results.length,
211
211
  // eslint-disable-next-line no-control-regex