vouchington-tooling 0.53.0 → 0.54.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.
- package/README.md +76 -12
- package/dist/agent-blackboard/index.d.mts +0 -1
- package/dist/agent-blackboard/index.mjs +0 -23
- package/dist/cli/commands/agent-blackboard-flags.d.mts +0 -1
- package/dist/cli/commands/agent-blackboard-flags.mjs +0 -9
- package/dist/cli/commands/agent-blackboard.d.mts +0 -2
- package/dist/cli/commands/agent-blackboard.mjs +7 -121
- package/dist/cli/commands/story-coverage.d.mts +2 -0
- package/dist/cli/commands/story-coverage.mjs +56 -0
- package/dist/cli/index.mjs +6 -0
- package/dist/cli/parse-forwarded-commands.d.mts +3 -0
- package/dist/cli/parse-forwarded-commands.mjs +2 -0
- package/dist/cli/parse-story-coverage-fields.d.mts +19 -0
- package/dist/cli/parse-story-coverage-fields.mjs +69 -0
- package/dist/cli/parse-story-coverage.d.mts +8 -0
- package/dist/cli/parse-story-coverage.mjs +34 -0
- package/dist/cli/parse.d.mts +5 -1
- package/dist/cli/parse.mjs +3 -0
- package/dist/cli/usage.d.mts +1 -1
- package/dist/cli/usage.mjs +8 -7
- package/dist/host-storage/check.d.mts +38 -0
- package/dist/host-storage/check.mjs +109 -0
- package/dist/host-storage/cli.d.mts +7 -0
- package/dist/host-storage/cli.mjs +102 -0
- package/dist/host-storage/host-storage.test-helpers.d.mts +26 -0
- package/dist/host-storage/host-storage.test-helpers.mjs +58 -0
- package/dist/host-storage/index.d.mts +3 -0
- package/dist/host-storage/index.mjs +3 -0
- package/dist/host-storage/preflight.d.mts +22 -0
- package/dist/host-storage/preflight.mjs +105 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/playwright/assertions.d.mts +1 -0
- package/dist/playwright/assertions.mjs +5 -0
- package/dist/playwright/blocked-external-network.d.mts +15 -0
- package/dist/playwright/blocked-external-network.mjs +73 -0
- package/dist/playwright/browser-dialog-issues.d.mts +12 -0
- package/dist/playwright/browser-dialog-issues.mjs +29 -0
- package/dist/playwright/browser-errors.d.mts +22 -0
- package/dist/playwright/browser-errors.mjs +130 -0
- package/dist/playwright/browser-issue-monitor.test-helpers.d.mts +31 -0
- package/dist/playwright/browser-issue-monitor.test-helpers.mjs +51 -0
- package/dist/playwright/browser-issue-records.d.mts +42 -0
- package/dist/playwright/browser-issue-records.mjs +148 -0
- package/dist/playwright/browser-test.d.mts +21 -0
- package/dist/playwright/browser-test.mjs +68 -0
- package/dist/playwright/expect-no-broken-images.d.mts +17 -0
- package/dist/playwright/expect-no-broken-images.mjs +39 -0
- package/dist/playwright/index.d.mts +30 -0
- package/dist/playwright/index.mjs +22 -0
- package/dist/playwright/mobile-assertions.d.mts +14 -0
- package/dist/playwright/mobile-assertions.mjs +43 -0
- package/dist/playwright/navigate-to.d.mts +27 -0
- package/dist/playwright/navigate-to.mjs +39 -0
- package/dist/playwright/radix-select.d.mts +18 -0
- package/dist/playwright/radix-select.mjs +19 -0
- package/dist/playwright/random-id.d.mts +34 -0
- package/dist/playwright/random-id.mjs +37 -0
- package/dist/playwright/retry-on-connection-lost.d.mts +7 -0
- package/dist/playwright/retry-on-connection-lost.mjs +107 -0
- package/dist/playwright/scroll-to-load-more.d.mts +37 -0
- package/dist/playwright/scroll-to-load-more.mjs +158 -0
- package/dist/playwright/storybook.d.mts +2 -0
- package/dist/playwright/storybook.mjs +13 -0
- package/dist/playwright/test-fixtures.d.mts +1 -0
- package/dist/playwright/test-fixtures.mjs +2 -0
- package/dist/playwright/test-lifecycle-reporter.d.mts +11 -0
- package/dist/playwright/test-lifecycle-reporter.mjs +35 -0
- package/dist/playwright/totp.d.mts +6 -0
- package/dist/playwright/totp.mjs +37 -0
- package/dist/playwright/turnstile-stub.d.mts +8 -0
- package/dist/playwright/turnstile-stub.mjs +61 -0
- package/dist/playwright/viewport-constants.d.mts +30 -0
- package/dist/playwright/viewport-constants.mjs +9 -0
- package/dist/playwright/virtual-authenticator.d.mts +5 -0
- package/dist/playwright/virtual-authenticator.mjs +15 -0
- package/dist/playwright/wait-for-hydration.d.mts +29 -0
- package/dist/playwright/wait-for-hydration.mjs +81 -0
- package/dist/shell-parse/ansi-c-string.d.mts +12 -0
- package/dist/shell-parse/ansi-c-string.mjs +80 -0
- package/dist/shell-parse/index.d.mts +20 -0
- package/dist/shell-parse/index.mjs +15 -0
- package/dist/shell-parse/shell-command-substitution-reads.d.mts +8 -0
- package/dist/shell-parse/shell-command-substitution-reads.mjs +53 -0
- package/dist/shell-parse/shell-command-substitutions.d.mts +8 -0
- package/dist/shell-parse/shell-command-substitutions.mjs +52 -0
- package/dist/shell-parse/shell-command-wrappers.d.mts +26 -0
- package/dist/shell-parse/shell-command-wrappers.mjs +143 -0
- package/dist/shell-parse/shell-commands.d.mts +24 -0
- package/dist/shell-parse/shell-commands.mjs +155 -0
- package/dist/shell-parse/shell-heredoc-delimiter.d.mts +5 -0
- package/dist/shell-parse/shell-heredoc-delimiter.mjs +52 -0
- package/dist/shell-parse/shell-heredoc-parser.d.mts +7 -0
- package/dist/shell-parse/shell-heredoc-parser.mjs +49 -0
- package/dist/shell-parse/shell-heredoc-quote-state.d.mts +19 -0
- package/dist/shell-parse/shell-heredoc-quote-state.mjs +40 -0
- package/dist/shell-parse/shell-heredoc.d.mts +10 -0
- package/dist/shell-parse/shell-heredoc.mjs +90 -0
- package/dist/shell-parse/shell-redirections.d.mts +5 -0
- package/dist/shell-parse/shell-redirections.mjs +34 -0
- package/dist/shell-parse/shell-script-operand.d.mts +13 -0
- package/dist/shell-parse/shell-script-operand.mjs +103 -0
- package/dist/shell-parse/shell-stdin-script.d.mts +6 -0
- package/dist/shell-parse/shell-stdin-script.mjs +61 -0
- package/dist/shell-parse/shell-token-utils.d.mts +9 -0
- package/dist/shell-parse/shell-token-utils.mjs +33 -0
- package/dist/shell-parse/shell-tokenizer-comments.d.mts +1 -0
- package/dist/shell-parse/shell-tokenizer-comments.mjs +57 -0
- package/dist/shell-parse/shell-tokenizer-operators.d.mts +14 -0
- package/dist/shell-parse/shell-tokenizer-operators.mjs +47 -0
- package/dist/shell-parse/shell-tokenizer.d.mts +12 -0
- package/dist/shell-parse/shell-tokenizer.mjs +104 -0
- package/dist/story-coverage/analyze.d.mts +8 -0
- package/dist/story-coverage/analyze.mjs +24 -0
- package/dist/story-coverage/check.d.mts +11 -0
- package/dist/story-coverage/check.mjs +42 -0
- package/dist/story-coverage/components.d.mts +10 -0
- package/dist/story-coverage/components.mjs +40 -0
- package/dist/story-coverage/coverage.d.mts +10 -0
- package/dist/story-coverage/coverage.mjs +43 -0
- package/dist/story-coverage/index.d.mts +13 -0
- package/dist/story-coverage/index.mjs +7 -0
- package/dist/story-coverage/messages.d.mts +10 -0
- package/dist/story-coverage/messages.mjs +42 -0
- package/dist/story-coverage/options.d.mts +27 -0
- package/dist/story-coverage/options.mjs +51 -0
- package/dist/story-coverage/workspace.d.mts +2 -0
- package/dist/story-coverage/workspace.mjs +27 -0
- package/dist/test-helpers/cancel-runs.test-helpers.d.mts +39 -0
- package/dist/test-helpers/cancel-runs.test-helpers.mjs +124 -0
- package/dist/test-helpers/run-bounded-exit-observer.test-helpers.d.mts +12 -0
- package/dist/test-helpers/run-bounded-exit-observer.test-helpers.mjs +68 -0
- package/dist/test-helpers/run-bounded-output-fixture.test-helpers.d.mts +18 -0
- package/dist/test-helpers/run-bounded-output-fixture.test-helpers.mjs +162 -0
- package/dist/vitest-diagnostics/index.d.mts +9 -1
- package/dist/vitest-diagnostics/index.mjs +5 -1
- package/dist/vitest-diagnostics/vitest-fake-timer-guard.d.mts +6 -0
- package/dist/vitest-diagnostics/vitest-fake-timer-guard.mjs +34 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-detection.d.mts +1 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-detection.mjs +8 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-diagnostics.d.mts +10 -1
- package/dist/vitest-diagnostics/vitest-fork-leak-diagnostics.mjs +43 -2
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake-samples.d.mts +50 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake-samples.mjs +69 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake.d.mts +19 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake.mjs +136 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-dns.d.mts +7 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-dns.mjs +54 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-host.d.mts +8 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-host.mjs +48 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-socket.d.mts +14 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-socket.mjs +39 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist.d.mts +7 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist.mjs +72 -0
- package/dist/vitest-diagnostics/vitest-process-resources.d.mts +6 -0
- package/dist/vitest-diagnostics/vitest-process-resources.mjs +51 -0
- package/dist/vitest-effective-timeout/cap.d.mts +9 -0
- package/dist/vitest-effective-timeout/cap.mjs +28 -0
- package/dist/vitest-effective-timeout/check-profiles.d.mts +15 -0
- package/dist/vitest-effective-timeout/check-profiles.mjs +52 -0
- package/dist/vitest-effective-timeout/config-file.d.mts +6 -0
- package/dist/vitest-effective-timeout/config-file.mjs +23 -0
- package/dist/vitest-effective-timeout/fixtures.d.mts +2 -0
- package/dist/vitest-effective-timeout/fixtures.mjs +18 -0
- package/dist/vitest-effective-timeout/index.d.mts +7 -0
- package/dist/vitest-effective-timeout/index.mjs +4 -0
- package/dist/vitest-effective-timeout/profiles.d.mts +10 -0
- package/dist/vitest-effective-timeout/profiles.mjs +33 -0
- package/dist/vitest-effective-timeout/run-profile.d.mts +31 -0
- package/dist/vitest-effective-timeout/run-profile.mjs +95 -0
- package/docs/mcp-server.md +2 -13
- package/package.json +32 -2
- package/scripts/__pycache__/run_bounded_process.cpython-312.pyc +0 -0
- package/scripts/chromium-launch-probe.d.mts +7 -0
- package/scripts/chromium-launch-probe.mjs +101 -0
- package/scripts/run-bounded-fixtures/run-bounded-backpressure.py +186 -0
- package/scripts/run-bounded-fixtures/run-bounded-merged-output.py +75 -0
- package/scripts/run-bounded-fixtures/run-bounded-reset-socket.py +25 -0
- package/scripts/run-bounded.py +199 -0
- package/scripts/run_bounded_process.py +129 -0
- package/scripts/worktree/git-index-lock.sh +16 -0
- package/scripts/worktree/git-worktrees.sh +23 -20
- package/scripts/worktree/reset-worktree-run.sh +199 -0
- package/scripts/worktree/reset-worktree.sh +122 -0
- package/skills/blackboard/SKILL.md +4 -64
- package/skills/stacked-prs/SKILL.md +1 -1
- package/skills/stacked-prs/references/drain.md +2 -2
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function formatProcessResources(): string;
|
|
2
|
+
export declare function formatActiveResources(): string;
|
|
3
|
+
export declare function countResourcesByType(resources: readonly string[]): Map<string, number>;
|
|
4
|
+
export declare function formatResourceCounts(counts: ReadonlyMap<string, number>): string;
|
|
5
|
+
export declare function formatBytes(bytes: number): string;
|
|
6
|
+
export declare function formatPercent(numerator: number, denominator: number): string;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Used by the teardown-overrun diagnostics (onProcessTimeout) to snapshot the main process's
|
|
2
|
+
// resource usage at the boundary where Vitest force-exits.
|
|
3
|
+
import { getHeapStatistics } from 'node:v8';
|
|
4
|
+
export function formatProcessResources() {
|
|
5
|
+
const usage = process.resourceUsage();
|
|
6
|
+
const memory = process.memoryUsage();
|
|
7
|
+
const heapLimitBytes = getHeapStatistics().heap_size_limit;
|
|
8
|
+
return [
|
|
9
|
+
`pid=${process.pid}`,
|
|
10
|
+
`rssMB=${formatBytes(memory.rss)}`,
|
|
11
|
+
`heapUsedMB=${formatBytes(memory.heapUsed)}`,
|
|
12
|
+
`heapTotalMB=${formatBytes(memory.heapTotal)}`,
|
|
13
|
+
// heap_size_limit and its ratio to heapUsed — not heapTotal, which is steady-state V8
|
|
14
|
+
// bookkeeping and was previously misread as "occupancy" against a limit it never carried.
|
|
15
|
+
`heapLimitMB=${formatBytes(heapLimitBytes)}`,
|
|
16
|
+
`heapPctOfLimit=${formatPercent(memory.heapUsed, heapLimitBytes)}`,
|
|
17
|
+
`userCpuMs=${Math.round(usage.userCPUTime / 1000)}`,
|
|
18
|
+
`systemCpuMs=${Math.round(usage.systemCPUTime / 1000)}`,
|
|
19
|
+
].join(' ');
|
|
20
|
+
}
|
|
21
|
+
export function formatActiveResources() {
|
|
22
|
+
const resources = process.getActiveResourcesInfo?.();
|
|
23
|
+
if (!resources || resources.length === 0)
|
|
24
|
+
return '(none)';
|
|
25
|
+
return resources.slice(0, 20).join(', ');
|
|
26
|
+
}
|
|
27
|
+
// Used by the fork-leak failure text to name per-type counts instead of the flat list above.
|
|
28
|
+
export function countResourcesByType(resources) {
|
|
29
|
+
const counts = new Map();
|
|
30
|
+
for (const resource of resources) {
|
|
31
|
+
counts.set(resource, (counts.get(resource) ?? 0) + 1);
|
|
32
|
+
}
|
|
33
|
+
return counts;
|
|
34
|
+
}
|
|
35
|
+
export function formatResourceCounts(counts) {
|
|
36
|
+
if (counts.size === 0)
|
|
37
|
+
return '(none)';
|
|
38
|
+
return [...counts.entries()]
|
|
39
|
+
.toSorted(([a], [b]) => a.localeCompare(b))
|
|
40
|
+
.map(([type, count]) => `${type}=${count}`)
|
|
41
|
+
.join(' ');
|
|
42
|
+
}
|
|
43
|
+
// Rounding shared by the main-process resource line and its unit test.
|
|
44
|
+
export function formatBytes(bytes) {
|
|
45
|
+
return (bytes / (1024 * 1024)).toFixed(1);
|
|
46
|
+
}
|
|
47
|
+
export function formatPercent(numerator, denominator) {
|
|
48
|
+
if (denominator <= 0)
|
|
49
|
+
return '0.0';
|
|
50
|
+
return ((numerator / denominator) * 100).toFixed(1);
|
|
51
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Plugin } from 'vitest/config';
|
|
2
|
+
export declare const DEFAULT_EFFECTIVE_TIMEOUT_MS = 30000;
|
|
3
|
+
export declare const DEFAULT_EFFECTIVE_TIMEOUT_PLUGIN = "effective-test-timeout-cap";
|
|
4
|
+
export type EffectiveTimeoutCapOptions = {
|
|
5
|
+
maxTimeoutMs?: number;
|
|
6
|
+
name?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function assertEffectiveTimeoutCap(maxTimeoutMs: number): number;
|
|
9
|
+
export declare function effectiveTimeoutCap(options?: EffectiveTimeoutCapOptions): Plugin;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const DEFAULT_EFFECTIVE_TIMEOUT_MS = 30_000;
|
|
2
|
+
export const DEFAULT_EFFECTIVE_TIMEOUT_PLUGIN = 'effective-test-timeout-cap';
|
|
3
|
+
const MIN_FIXTURE_TIMEOUT_MS = 5_000;
|
|
4
|
+
export function assertEffectiveTimeoutCap(maxTimeoutMs) {
|
|
5
|
+
if (!Number.isFinite(maxTimeoutMs) || maxTimeoutMs < MIN_FIXTURE_TIMEOUT_MS) {
|
|
6
|
+
throw new RangeError(`effective timeout cap must be finite and at least ${MIN_FIXTURE_TIMEOUT_MS}ms; received ${maxTimeoutMs}`);
|
|
7
|
+
}
|
|
8
|
+
return maxTimeoutMs;
|
|
9
|
+
}
|
|
10
|
+
// Validate selected projects after framework normalization, before global setup imports.
|
|
11
|
+
export function effectiveTimeoutCap(options = {}) {
|
|
12
|
+
const maxTimeoutMs = assertEffectiveTimeoutCap(options.maxTimeoutMs ?? DEFAULT_EFFECTIVE_TIMEOUT_MS);
|
|
13
|
+
const name = options.name ?? DEFAULT_EFFECTIVE_TIMEOUT_PLUGIN;
|
|
14
|
+
return {
|
|
15
|
+
name,
|
|
16
|
+
configureVitest({ project }) {
|
|
17
|
+
for (const field of ['testTimeout', 'hookTimeout']) {
|
|
18
|
+
const value = project.config[field];
|
|
19
|
+
if (typeof value !== 'number' ||
|
|
20
|
+
!Number.isFinite(value) ||
|
|
21
|
+
value <= 0 ||
|
|
22
|
+
value > maxTimeoutMs) {
|
|
23
|
+
throw new RangeError(`Project ${project.config.name}: effective ${field} must be finite, positive, and at most ${maxTimeoutMs}ms; received ${value}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type CliOptions } from 'vitest/node';
|
|
2
|
+
import { type OpenTimeoutRun, type TimeoutProfileRow } from './run-profile.mts';
|
|
3
|
+
export type FiniteTimeoutProfileOptions = {
|
|
4
|
+
maxTimeoutMs?: number;
|
|
5
|
+
pluginName?: string;
|
|
6
|
+
scratchDir?: string;
|
|
7
|
+
open?: OpenTimeoutRun;
|
|
8
|
+
removeScratch?: (path: string) => Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
export declare function openVitestTimeoutRun(input: {
|
|
11
|
+
root: string;
|
|
12
|
+
configFile: string;
|
|
13
|
+
cli: CliOptions;
|
|
14
|
+
}): Promise<Awaited<ReturnType<OpenTimeoutRun>>>;
|
|
15
|
+
export declare function checkFiniteTimeoutProfiles(repoRoot: string, options?: FiniteTimeoutProfileOptions): Promise<TimeoutProfileRow[]>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { mkdir, mkdtemp, rm } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { createVitest } from 'vitest/node';
|
|
4
|
+
import { assertEffectiveTimeoutCap, DEFAULT_EFFECTIVE_TIMEOUT_MS, DEFAULT_EFFECTIVE_TIMEOUT_PLUGIN, } from "./cap.mjs";
|
|
5
|
+
import { timeoutProfiles } from "./profiles.mjs";
|
|
6
|
+
import { runTimeoutProfile } from "./run-profile.mjs";
|
|
7
|
+
export async function openVitestTimeoutRun(input) {
|
|
8
|
+
const context = await createVitest({
|
|
9
|
+
root: input.root,
|
|
10
|
+
config: input.configFile,
|
|
11
|
+
watch: false,
|
|
12
|
+
run: true,
|
|
13
|
+
reporters: [],
|
|
14
|
+
...input.cli,
|
|
15
|
+
});
|
|
16
|
+
return { start: () => context.start(), close: () => context.close() };
|
|
17
|
+
}
|
|
18
|
+
export async function checkFiniteTimeoutProfiles(repoRoot, options = {}) {
|
|
19
|
+
const maxTimeoutMs = assertEffectiveTimeoutCap(options.maxTimeoutMs ?? DEFAULT_EFFECTIVE_TIMEOUT_MS);
|
|
20
|
+
const pluginName = options.pluginName ?? DEFAULT_EFFECTIVE_TIMEOUT_PLUGIN;
|
|
21
|
+
const open = options.open ?? openVitestTimeoutRun;
|
|
22
|
+
const removeScratch = options.removeScratch ?? ((path) => rm(path, { recursive: true, force: true }));
|
|
23
|
+
const scratchParent = options.scratchDir ?? join(repoRoot, '.cache');
|
|
24
|
+
await mkdir(scratchParent, { recursive: true });
|
|
25
|
+
const scratch = await mkdtemp(join(scratchParent, 'effective-timeout-cap-'));
|
|
26
|
+
const rows = [];
|
|
27
|
+
let failed = false;
|
|
28
|
+
let primary;
|
|
29
|
+
const cleanup = [];
|
|
30
|
+
try {
|
|
31
|
+
for (const profile of timeoutProfiles(maxTimeoutMs)) {
|
|
32
|
+
rows.push(await runTimeoutProfile(profile, { scratch, maxTimeoutMs, pluginName, open }));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
failed = true;
|
|
37
|
+
primary = err;
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
try {
|
|
41
|
+
await removeScratch(scratch);
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
cleanup.push(err);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (failed || cleanup.length) {
|
|
48
|
+
const errors = [...(failed ? [primary] : []), ...cleanup];
|
|
49
|
+
throw new AggregateError(errors, 'Finite timeout admission failed', { cause: errors[0] });
|
|
50
|
+
}
|
|
51
|
+
return rows;
|
|
52
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const DEFAULT_ROOT_VITEST_CONFIG = "vitest.config.mts";
|
|
2
|
+
export declare function assertCanonicalRootVitestConfig(files: readonly string[], configFileName?: string): void;
|
|
3
|
+
export declare function checkCanonicalRootVitestConfigControls(configFileName?: string): {
|
|
4
|
+
name: string;
|
|
5
|
+
admitted: boolean;
|
|
6
|
+
}[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
export const DEFAULT_ROOT_VITEST_CONFIG = 'vitest.config.mts';
|
|
3
|
+
export function assertCanonicalRootVitestConfig(files, configFileName = DEFAULT_ROOT_VITEST_CONFIG) {
|
|
4
|
+
assert.deepEqual(files.filter((file) => file.startsWith('vitest.config.')).toSorted(), [
|
|
5
|
+
configFileName,
|
|
6
|
+
]);
|
|
7
|
+
}
|
|
8
|
+
export function checkCanonicalRootVitestConfigControls(configFileName = DEFAULT_ROOT_VITEST_CONFIG) {
|
|
9
|
+
const alternate = configFileName.endsWith('.mts') ? 'vitest.config.ts' : 'vitest.config.mts';
|
|
10
|
+
const cases = [
|
|
11
|
+
{ name: 'canonical', files: ['README.md', configFileName], admitted: true },
|
|
12
|
+
{ name: 'missing', files: ['README.md'], admitted: false },
|
|
13
|
+
{ name: 'alternate', files: [alternate], admitted: false },
|
|
14
|
+
{ name: 'additional', files: [configFileName, alternate], admitted: false },
|
|
15
|
+
];
|
|
16
|
+
for (const control of cases) {
|
|
17
|
+
if (control.admitted)
|
|
18
|
+
assertCanonicalRootVitestConfig(control.files, configFileName);
|
|
19
|
+
else
|
|
20
|
+
assert.throws(() => assertCanonicalRootVitestConfig(control.files, configFileName), assert.AssertionError);
|
|
21
|
+
}
|
|
22
|
+
return cases.map(({ name, admitted }) => ({ name, admitted }));
|
|
23
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const EFFECTIVE_TIMEOUT_CASE = "import { readFile, writeFile } from 'node:fs/promises'\nimport { describe, expect, it } from 'vitest'\n\ndescribe('effective timeout admission', () => {\n it('runs its owned setup before the body', async () => {\n expect(await readFile(new URL('./setup-call.marker', import.meta.url), 'utf8')).toBe('called')\n await writeFile(new URL('./body.marker', import.meta.url), 'ran')\n })\n})\n";
|
|
2
|
+
export declare const EFFECTIVE_TIMEOUT_SETUP = "import { writeFileSync } from 'node:fs'\n\nwriteFileSync(new URL('./setup-import.marker', import.meta.url), 'imported')\n\nexport default function setup() {\n writeFileSync(new URL('./setup-call.marker', import.meta.url), 'called')\n}\n";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const EFFECTIVE_TIMEOUT_CASE = `import { readFile, writeFile } from 'node:fs/promises'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
|
|
4
|
+
describe('effective timeout admission', () => {
|
|
5
|
+
it('runs its owned setup before the body', async () => {
|
|
6
|
+
expect(await readFile(new URL('./setup-call.marker', import.meta.url), 'utf8')).toBe('called')
|
|
7
|
+
await writeFile(new URL('./body.marker', import.meta.url), 'ran')
|
|
8
|
+
})
|
|
9
|
+
})
|
|
10
|
+
`;
|
|
11
|
+
export const EFFECTIVE_TIMEOUT_SETUP = `import { writeFileSync } from 'node:fs'
|
|
12
|
+
|
|
13
|
+
writeFileSync(new URL('./setup-import.marker', import.meta.url), 'imported')
|
|
14
|
+
|
|
15
|
+
export default function setup() {
|
|
16
|
+
writeFileSync(new URL('./setup-call.marker', import.meta.url), 'called')
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { assertEffectiveTimeoutCap, DEFAULT_EFFECTIVE_TIMEOUT_MS, DEFAULT_EFFECTIVE_TIMEOUT_PLUGIN, effectiveTimeoutCap, } from './cap.mts';
|
|
2
|
+
export type { EffectiveTimeoutCapOptions } from './cap.mts';
|
|
3
|
+
export { assertCanonicalRootVitestConfig, checkCanonicalRootVitestConfigControls, DEFAULT_ROOT_VITEST_CONFIG, } from './config-file.mts';
|
|
4
|
+
export { checkFiniteTimeoutProfiles, openVitestTimeoutRun } from './check-profiles.mts';
|
|
5
|
+
export type { FiniteTimeoutProfileOptions } from './check-profiles.mts';
|
|
6
|
+
export { effectiveTimeoutGuardHref } from './run-profile.mts';
|
|
7
|
+
export type { OpenTimeoutRun, TimeoutProfileRow } from './run-profile.mts';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { assertEffectiveTimeoutCap, DEFAULT_EFFECTIVE_TIMEOUT_MS, DEFAULT_EFFECTIVE_TIMEOUT_PLUGIN, effectiveTimeoutCap, } from "./cap.mjs";
|
|
2
|
+
export { assertCanonicalRootVitestConfig, checkCanonicalRootVitestConfigControls, DEFAULT_ROOT_VITEST_CONFIG, } from "./config-file.mjs";
|
|
3
|
+
export { checkFiniteTimeoutProfiles, openVitestTimeoutRun } from "./check-profiles.mjs";
|
|
4
|
+
export { effectiveTimeoutGuardHref } from "./run-profile.mjs";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CliOptions } from 'vitest/node';
|
|
2
|
+
export type TimeoutProfile = {
|
|
3
|
+
name: string;
|
|
4
|
+
admitted: boolean;
|
|
5
|
+
options?: CliOptions;
|
|
6
|
+
configHookTimeout?: number;
|
|
7
|
+
child?: boolean;
|
|
8
|
+
withoutGuard?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function timeoutProfiles(maxTimeoutMs: number): readonly TimeoutProfile[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function timeoutProfiles(maxTimeoutMs) {
|
|
2
|
+
const midCap = maxTimeoutMs >= 15_000
|
|
3
|
+
? [{ name: 'bounded-fifteen', options: { testTimeout: 15_000 }, admitted: true }]
|
|
4
|
+
: [];
|
|
5
|
+
return [
|
|
6
|
+
{ name: 'bounded-five', admitted: true },
|
|
7
|
+
...midCap,
|
|
8
|
+
{ name: 'bounded-thirty', options: { testTimeout: maxTimeoutMs }, admitted: true },
|
|
9
|
+
{ name: 'oversized-cli', options: { testTimeout: maxTimeoutMs + 1 }, admitted: false },
|
|
10
|
+
{ name: 'disabled-test', options: { testTimeout: 0 }, admitted: false },
|
|
11
|
+
{ name: 'infinite-test', options: { testTimeout: Infinity }, admitted: false },
|
|
12
|
+
{ name: 'disabled-hook', configHookTimeout: 0, admitted: false },
|
|
13
|
+
{ name: 'infinite-hook', configHookTimeout: Infinity, admitted: false },
|
|
14
|
+
{ name: 'unused-root-zero', child: true, admitted: true },
|
|
15
|
+
{
|
|
16
|
+
name: 'reporter-does-not-bypass',
|
|
17
|
+
options: { testTimeout: maxTimeoutMs + 1, reporters: ['json'] },
|
|
18
|
+
admitted: false,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'normalized-child-hook-zero',
|
|
22
|
+
options: { hookTimeout: 0 },
|
|
23
|
+
child: true,
|
|
24
|
+
admitted: true,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'removed-guard-negative',
|
|
28
|
+
options: { testTimeout: maxTimeoutMs + 1 },
|
|
29
|
+
withoutGuard: true,
|
|
30
|
+
admitted: true,
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CliOptions } from 'vitest/node';
|
|
2
|
+
import type { TimeoutProfile } from './profiles.mts';
|
|
3
|
+
type StartedTimeoutRun = {
|
|
4
|
+
testModules: readonly {
|
|
5
|
+
ok: () => boolean;
|
|
6
|
+
}[];
|
|
7
|
+
unhandledErrors: readonly unknown[];
|
|
8
|
+
};
|
|
9
|
+
export type OpenTimeoutRun = (input: {
|
|
10
|
+
root: string;
|
|
11
|
+
configFile: string;
|
|
12
|
+
cli: CliOptions;
|
|
13
|
+
}) => Promise<{
|
|
14
|
+
start: () => Promise<StartedTimeoutRun>;
|
|
15
|
+
close: () => Promise<void>;
|
|
16
|
+
}>;
|
|
17
|
+
export type TimeoutProfileRow = {
|
|
18
|
+
profile: string;
|
|
19
|
+
body: boolean;
|
|
20
|
+
setupImport: boolean;
|
|
21
|
+
setupCall: boolean;
|
|
22
|
+
rejected: boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare function effectiveTimeoutGuardHref(moduleUrl?: string): string;
|
|
25
|
+
export declare function runTimeoutProfile(profile: TimeoutProfile, input: {
|
|
26
|
+
scratch: string;
|
|
27
|
+
maxTimeoutMs: number;
|
|
28
|
+
pluginName: string;
|
|
29
|
+
open: OpenTimeoutRun;
|
|
30
|
+
}): Promise<TimeoutProfileRow>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { access, mkdir, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { EFFECTIVE_TIMEOUT_CASE, EFFECTIVE_TIMEOUT_SETUP } from "./fixtures.mjs";
|
|
5
|
+
export function effectiveTimeoutGuardHref(moduleUrl = import.meta.url) {
|
|
6
|
+
const fileName = moduleUrl.endsWith('.mjs') ? 'cap.mjs' : 'cap.mts';
|
|
7
|
+
return new URL(fileName, moduleUrl).href;
|
|
8
|
+
}
|
|
9
|
+
function renderConfig(input) {
|
|
10
|
+
const test = {
|
|
11
|
+
name: 'owned-effective-timeout',
|
|
12
|
+
include: ['case.mts'],
|
|
13
|
+
testTimeout: 5000,
|
|
14
|
+
hookTimeout: 5000,
|
|
15
|
+
globalSetup: [join(input.root, 'setup.mts')],
|
|
16
|
+
};
|
|
17
|
+
const plugins = input.profile.withoutGuard
|
|
18
|
+
? '[]'
|
|
19
|
+
: `[effectiveTimeoutCap(${JSON.stringify({ maxTimeoutMs: input.maxTimeoutMs, name: input.pluginName })})]`;
|
|
20
|
+
const testConfig = input.profile.child
|
|
21
|
+
? '{ testTimeout: 0, hookTimeout: 0, projects: [{ extends: true, test }] }'
|
|
22
|
+
: 'test';
|
|
23
|
+
return `import { effectiveTimeoutCap } from ${JSON.stringify(effectiveTimeoutGuardHref())};
|
|
24
|
+
const test = { ...${JSON.stringify(test)}, hookTimeout: ${String(input.profile.configHookTimeout ?? 5000)} };
|
|
25
|
+
export default {
|
|
26
|
+
root: ${JSON.stringify(input.root)},
|
|
27
|
+
plugins: ${plugins},
|
|
28
|
+
test: ${testConfig},
|
|
29
|
+
};
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
async function markerExists(path) {
|
|
33
|
+
try {
|
|
34
|
+
await access(path);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
if (err instanceof Error && 'code' in err && err.code === 'ENOENT')
|
|
39
|
+
return false;
|
|
40
|
+
throw err;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export async function runTimeoutProfile(profile, input) {
|
|
44
|
+
const root = join(input.scratch, profile.name);
|
|
45
|
+
await mkdir(root, { recursive: true });
|
|
46
|
+
await writeFile(join(root, 'case.mts'), EFFECTIVE_TIMEOUT_CASE);
|
|
47
|
+
await writeFile(join(root, 'setup.mts'), EFFECTIVE_TIMEOUT_SETUP);
|
|
48
|
+
const configFile = join(root, 'vitest.config.mts');
|
|
49
|
+
await writeFile(configFile, renderConfig({ root, profile, maxTimeoutMs: input.maxTimeoutMs, pluginName: input.pluginName }));
|
|
50
|
+
let opened;
|
|
51
|
+
let rejected = false;
|
|
52
|
+
let rejection;
|
|
53
|
+
let result;
|
|
54
|
+
const closeErrors = [];
|
|
55
|
+
try {
|
|
56
|
+
opened = await input.open({ root, configFile, cli: profile.options ?? {} });
|
|
57
|
+
result = await opened.start();
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
rejected = true;
|
|
61
|
+
rejection = err;
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
try {
|
|
65
|
+
await opened?.close();
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
closeErrors.push(err);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (closeErrors.length) {
|
|
72
|
+
const errors = [...(rejected ? [rejection] : []), ...closeErrors];
|
|
73
|
+
throw new AggregateError(errors, 'Profile context close failed', { cause: errors[0] });
|
|
74
|
+
}
|
|
75
|
+
const row = {
|
|
76
|
+
profile: profile.name,
|
|
77
|
+
body: await markerExists(join(root, 'body.marker')),
|
|
78
|
+
setupImport: await markerExists(join(root, 'setup-import.marker')),
|
|
79
|
+
setupCall: await markerExists(join(root, 'setup-call.marker')),
|
|
80
|
+
rejected,
|
|
81
|
+
};
|
|
82
|
+
for (const field of ['body', 'setupImport', 'setupCall']) {
|
|
83
|
+
assert.equal(row[field], profile.admitted, JSON.stringify(row));
|
|
84
|
+
}
|
|
85
|
+
assert.equal(rejected, !profile.admitted, String(rejection));
|
|
86
|
+
if (profile.admitted) {
|
|
87
|
+
assert.equal(result?.testModules.length, 1);
|
|
88
|
+
assert.equal(result?.testModules[0]?.ok(), true);
|
|
89
|
+
assert.equal(result?.unhandledErrors.length, 0);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
assert.match(String(rejection), /effective (testTimeout|hookTimeout) must be/);
|
|
93
|
+
}
|
|
94
|
+
return row;
|
|
95
|
+
}
|
package/docs/mcp-server.md
CHANGED
|
@@ -38,17 +38,6 @@ status 1.
|
|
|
38
38
|
The connection comes from `AGENT_BLACKBOARD_URL` and `AGENT_BLACKBOARD_TOKEN` in the server's
|
|
39
39
|
environment. The server never searches for, prints, or mints them.
|
|
40
40
|
|
|
41
|
-
## CLI fallback
|
|
42
|
-
|
|
43
|
-
MCP is the supported path. If it is unavailable, restore it first as the blackboard skill describes.
|
|
44
|
-
As a last resort, use `vouchington agent-blackboard journal append|entries|flush|status` as described
|
|
45
|
-
there; sandboxed Claude Code and Codex withhold the token, so it can only retain records in the
|
|
46
|
-
outbox the server later flushes. Record the fallback and delivery status in the journal and tell the human. The CLI resolves its
|
|
47
|
-
client from its own installation, so install `agent-blackboard` alongside that trusted CLI.
|
|
48
|
-
Run the script with a verified absolute `node` and a cleared environment (`env -i`), never through
|
|
49
|
-
its `#!/usr/bin/env node` line, which takes `node` from a possibly repository-controlled `PATH`.
|
|
50
|
-
A missing MCP connection does not waive persistence or readback requirements.
|
|
51
|
-
|
|
52
41
|
## Launch
|
|
53
42
|
|
|
54
43
|
```bash
|
|
@@ -118,7 +107,7 @@ whatever its timestamp, is a conflict.
|
|
|
118
107
|
|
|
119
108
|
A session that already exists with a different `version` (an agent upgrade, or a session another
|
|
120
109
|
writer created) is not a conflict: the entry is delivered into it and the result reports
|
|
121
|
-
`storedVersion`, in `journal_append
|
|
110
|
+
`storedVersion`, in `journal_append`. A
|
|
122
111
|
different `parentSessionId` or `agent` is an `identity-conflict`, and the error names each
|
|
123
112
|
differing field with its stored and supplied value, for example
|
|
124
113
|
`identity-conflict: agent stored "claude", supplied "codex"`.
|
|
@@ -128,7 +117,7 @@ client returns (`sessionId`, `createdAt`, `data`), so `data` keeps its envelope
|
|
|
128
117
|
`repositories`, `sourceEventId`, `workOutcome`, and `feedbackCoverage`. Entries of every type come
|
|
129
118
|
back, including `retrospective` and legacy entries without an envelope. The client documents no
|
|
130
119
|
order, so they are sorted stably by `createdAt`, oldest first. An empty session returns
|
|
131
|
-
`entries: []`.
|
|
120
|
+
`entries: []`.
|
|
132
121
|
|
|
133
122
|
`sessionId` on `outbox_status`, `outbox_flush`, and `snapshot_export` only identifies the caller.
|
|
134
123
|
The outbox is per worktree, so the results name two counts apart. `pendingCount` is the number of
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vouchington-tooling",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.0",
|
|
4
4
|
"description": "Vouchington CLI and extractable tooling libraries.",
|
|
5
5
|
"homepage": "https://github.com/vouchington/vouchington-tooling/tree/main/packages/vouchington-tooling#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -55,6 +55,16 @@
|
|
|
55
55
|
"import": "./dist/runner-port-policy/index.mjs",
|
|
56
56
|
"default": "./dist/runner-port-policy/index.mjs"
|
|
57
57
|
},
|
|
58
|
+
"./host-storage": {
|
|
59
|
+
"types": "./dist/host-storage/index.d.mts",
|
|
60
|
+
"import": "./dist/host-storage/index.mjs",
|
|
61
|
+
"default": "./dist/host-storage/index.mjs"
|
|
62
|
+
},
|
|
63
|
+
"./shell-parse": {
|
|
64
|
+
"types": "./dist/shell-parse/index.d.mts",
|
|
65
|
+
"import": "./dist/shell-parse/index.mjs",
|
|
66
|
+
"default": "./dist/shell-parse/index.mjs"
|
|
67
|
+
},
|
|
58
68
|
"./retrospective-transcript": {
|
|
59
69
|
"types": "./dist/retrospective-transcript/index.d.mts",
|
|
60
70
|
"import": "./dist/retrospective-transcript/index.mjs",
|
|
@@ -146,6 +156,11 @@
|
|
|
146
156
|
"import": "./dist/source-module-graph/index.mjs",
|
|
147
157
|
"default": "./dist/source-module-graph/index.mjs"
|
|
148
158
|
},
|
|
159
|
+
"./story-coverage": {
|
|
160
|
+
"types": "./dist/story-coverage/index.d.mts",
|
|
161
|
+
"import": "./dist/story-coverage/index.mjs",
|
|
162
|
+
"default": "./dist/story-coverage/index.mjs"
|
|
163
|
+
},
|
|
149
164
|
"./gha-selected-files": {
|
|
150
165
|
"types": "./dist/gha-selected-files/index.d.mts",
|
|
151
166
|
"import": "./dist/gha-selected-files/index.mjs",
|
|
@@ -311,6 +326,16 @@
|
|
|
311
326
|
"import": "./dist/vitest-diagnostics/index.mjs",
|
|
312
327
|
"default": "./dist/vitest-diagnostics/index.mjs"
|
|
313
328
|
},
|
|
329
|
+
"./vitest-effective-timeout": {
|
|
330
|
+
"types": "./dist/vitest-effective-timeout/index.d.mts",
|
|
331
|
+
"import": "./dist/vitest-effective-timeout/index.mjs",
|
|
332
|
+
"default": "./dist/vitest-effective-timeout/index.mjs"
|
|
333
|
+
},
|
|
334
|
+
"./playwright": {
|
|
335
|
+
"types": "./dist/playwright/index.d.mts",
|
|
336
|
+
"import": "./dist/playwright/index.mjs",
|
|
337
|
+
"default": "./dist/playwright/index.mjs"
|
|
338
|
+
},
|
|
314
339
|
"./gh-cli": {
|
|
315
340
|
"types": "./dist/gh-cli/index.d.mts",
|
|
316
341
|
"import": "./dist/gh-cli/index.mjs",
|
|
@@ -374,7 +399,7 @@
|
|
|
374
399
|
"dependencies": {
|
|
375
400
|
"@types/mdast": "4.0.4",
|
|
376
401
|
"@types/unist": "3.0.3",
|
|
377
|
-
"@typescript-eslint/parser": "^8.71.
|
|
402
|
+
"@typescript-eslint/parser": "^8.71.2",
|
|
378
403
|
"agent-blackboard": "^0.7.0",
|
|
379
404
|
"csv-parse": "7.0.3",
|
|
380
405
|
"csv-stringify": "6.9.0",
|
|
@@ -389,6 +414,7 @@
|
|
|
389
414
|
"devDependencies": {
|
|
390
415
|
"@ast-grep/cli": "0.50.0",
|
|
391
416
|
"@modelcontextprotocol/sdk": "1.32.1",
|
|
417
|
+
"@playwright/test": "1.64.1",
|
|
392
418
|
"@types/picomatch": "^4.0.3",
|
|
393
419
|
"@types/spdx-expression-parse": "4.0.0",
|
|
394
420
|
"no-mistakes": "0.83.0",
|
|
@@ -397,6 +423,7 @@
|
|
|
397
423
|
},
|
|
398
424
|
"peerDependencies": {
|
|
399
425
|
"@modelcontextprotocol/sdk": "^1.31.0",
|
|
426
|
+
"@playwright/test": ">=1.64.1",
|
|
400
427
|
"no-mistakes": "*",
|
|
401
428
|
"typescript": ">=5",
|
|
402
429
|
"vitest": ">=5"
|
|
@@ -405,6 +432,9 @@
|
|
|
405
432
|
"@modelcontextprotocol/sdk": {
|
|
406
433
|
"optional": true
|
|
407
434
|
},
|
|
435
|
+
"@playwright/test": {
|
|
436
|
+
"optional": true
|
|
437
|
+
},
|
|
408
438
|
"no-mistakes": {
|
|
409
439
|
"optional": true
|
|
410
440
|
},
|
|
Binary file
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Exit 0 when the selected browser launches and closes cleanly, 1 otherwise.
|
|
3
|
+
// Plain JavaScript so a Node 20 runner can execute it. setup-playwright runs this
|
|
4
|
+
// before it spends an apt download on playwright install-deps. Chromium also
|
|
5
|
+
// launches with channel chromium, because that build can need different host
|
|
6
|
+
// libraries than the headless shell. Chrome and Edge are Chromium channels, not
|
|
7
|
+
// separate Playwright exports. Any failure counts, and the cause is only printed,
|
|
8
|
+
// so the probe never depends on Playwright's error wording.
|
|
9
|
+
|
|
10
|
+
import { realpathSync } from 'node:fs'
|
|
11
|
+
import { createRequire } from 'node:module'
|
|
12
|
+
import { join } from 'node:path'
|
|
13
|
+
import { pathToFileURL } from 'node:url'
|
|
14
|
+
|
|
15
|
+
const chromiumChannels = new Set([
|
|
16
|
+
'chrome',
|
|
17
|
+
'chrome-beta',
|
|
18
|
+
'chrome-dev',
|
|
19
|
+
'chrome-canary',
|
|
20
|
+
'msedge',
|
|
21
|
+
'msedge-beta',
|
|
22
|
+
'msedge-dev',
|
|
23
|
+
'msedge-canary',
|
|
24
|
+
])
|
|
25
|
+
|
|
26
|
+
export async function chromiumLaunchProbeExitCode(launches) {
|
|
27
|
+
try {
|
|
28
|
+
for (const launch of launches) {
|
|
29
|
+
const browser = await launch()
|
|
30
|
+
await browser.close()
|
|
31
|
+
}
|
|
32
|
+
return 0
|
|
33
|
+
} catch (err) {
|
|
34
|
+
process.stderr.write(`Browser failed to launch: ${String(err)}\n`)
|
|
35
|
+
return 1
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function probeLaunches(browserName, playwright) {
|
|
40
|
+
if (!/^[A-Za-z0-9_-]+$/.test(browserName)) return 'browser must be a single token'
|
|
41
|
+
if (browserName === 'chromium' || chromiumChannels.has(browserName)) {
|
|
42
|
+
const browser = playwright.chromium
|
|
43
|
+
if (!browser) return 'Playwright has no browser chromium'
|
|
44
|
+
if (browserName === 'chromium') {
|
|
45
|
+
return [() => browser.launch(), () => browser.launch({ channel: 'chromium' })]
|
|
46
|
+
}
|
|
47
|
+
return [() => browser.launch({ channel: browserName })]
|
|
48
|
+
}
|
|
49
|
+
const browser = playwright[browserName]
|
|
50
|
+
if (!browser) return `Playwright has no browser ${browserName}`
|
|
51
|
+
return [() => browser.launch()]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function hasCode(err, code) {
|
|
55
|
+
return typeof err === 'object' && err !== null && 'code' in err && err.code === code
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function loadPlaywright(workspace) {
|
|
59
|
+
const require = createRequire(join(workspace, 'package.json'))
|
|
60
|
+
let missing
|
|
61
|
+
for (const specifier of ['playwright', '@playwright/test']) {
|
|
62
|
+
try {
|
|
63
|
+
return require(specifier)
|
|
64
|
+
} catch (err) {
|
|
65
|
+
if (hasCode(err, 'ERR_REQUIRE_ESM')) {
|
|
66
|
+
return import(pathToFileURL(require.resolve(specifier)).href)
|
|
67
|
+
}
|
|
68
|
+
if (!hasCode(err, 'MODULE_NOT_FOUND')) throw err
|
|
69
|
+
missing = err
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
throw missing
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function ranAsScript() {
|
|
76
|
+
const entry = process.argv[1]
|
|
77
|
+
if (entry === undefined) return false
|
|
78
|
+
// argv keeps the path the caller passed. import.meta.url is the real file,
|
|
79
|
+
// which differs when that path goes through a symlink such as macOS /var.
|
|
80
|
+
try {
|
|
81
|
+
return import.meta.url === pathToFileURL(realpathSync(entry)).href
|
|
82
|
+
} catch {
|
|
83
|
+
return false
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (ranAsScript()) {
|
|
88
|
+
const browserName = process.env.PLAYWRIGHT_BROWSER ?? 'chromium'
|
|
89
|
+
const workspace = process.env.GITHUB_WORKSPACE || process.cwd()
|
|
90
|
+
let exitCode = 1
|
|
91
|
+
try {
|
|
92
|
+
// Resolve from the caller workspace. The script itself lives in the action checkout.
|
|
93
|
+
const playwright = await loadPlaywright(workspace)
|
|
94
|
+
const launches = probeLaunches(browserName, playwright)
|
|
95
|
+
exitCode = typeof launches === 'string' ? 1 : await chromiumLaunchProbeExitCode(launches)
|
|
96
|
+
if (typeof launches === 'string') process.stderr.write(`${launches}\n`)
|
|
97
|
+
} catch (err) {
|
|
98
|
+
process.stderr.write(`Browser failed to launch: ${String(err)}\n`)
|
|
99
|
+
}
|
|
100
|
+
process.exit(exitCode)
|
|
101
|
+
}
|