vouchington-tooling 0.53.0 → 0.55.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 +99 -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/optional-peer.d.mts +5 -0
- package/dist/cli/optional-peer.mjs +17 -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/story-coverage-lazy.d.mts +3 -0
- package/dist/cli/story-coverage-lazy.mjs +6 -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 +23 -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 +22 -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 +32 -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/monitored-test-info.d.mts +14 -0
- package/dist/playwright/monitored-test-info.mjs +1 -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 +27 -0
- package/dist/playwright/test-lifecycle-reporter.mjs +57 -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/browser.d.mts +2 -0
- package/dist/vitest-diagnostics/browser.mjs +6 -0
- package/dist/vitest-diagnostics/index.d.mts +14 -23
- package/dist/vitest-diagnostics/index.mjs +8 -124
- package/dist/vitest-diagnostics/report-summary.d.mts +22 -0
- package/dist/vitest-diagnostics/report-summary.mjs +123 -0
- 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 +17 -1
- package/dist/vitest-diagnostics/vitest-fork-leak-diagnostics.mjs +44 -2
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake-samples.d.mts +55 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake-samples.mjs +74 -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 +10 -0
- package/dist/vitest-diagnostics/vitest-process-resources.mjs +54 -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 +37 -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,81 @@
|
|
|
1
|
+
// Playwright rejects an in-flight page.evaluate() with this message when a
|
|
2
|
+
// navigation replaces the document that evaluate was running in.
|
|
3
|
+
const DESTROYED_EXECUTION_CONTEXT_PATTERN = /Execution context was destroyed/i;
|
|
4
|
+
// A redirect chain can replace the document more than once, so re-waiting is
|
|
5
|
+
// bounded: a redirect loop has to fail the test rather than hang it.
|
|
6
|
+
const MAX_DOCUMENT_REPLACEMENTS = 2;
|
|
7
|
+
function isDestroyedExecutionContextError(error) {
|
|
8
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
9
|
+
return DESTROYED_EXECUTION_CONTEXT_PATTERN.test(message);
|
|
10
|
+
}
|
|
11
|
+
function evaluateHydrationSettled(page) {
|
|
12
|
+
return page.evaluate(() => new Promise((resolve) => {
|
|
13
|
+
const requestIdleCallbackMaybe = globalThis.window.requestIdleCallback;
|
|
14
|
+
if (requestIdleCallbackMaybe) {
|
|
15
|
+
requestIdleCallbackMaybe(() => resolve(), { timeout: 500 });
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
// When requestIdleCallback is unavailable, wait for two animation
|
|
19
|
+
// frames so React has had paint cycles to hydrate below-fold
|
|
20
|
+
// components. Race double-RAF against a short timeout so
|
|
21
|
+
// throttled/hidden tabs cannot hang indefinitely; the timeout is a
|
|
22
|
+
// completion bound, not the primary readiness signal.
|
|
23
|
+
let timeoutId;
|
|
24
|
+
let isResolved = false;
|
|
25
|
+
const resolveOnce = () => {
|
|
26
|
+
if (isResolved)
|
|
27
|
+
return;
|
|
28
|
+
isResolved = true;
|
|
29
|
+
if (timeoutId !== undefined) {
|
|
30
|
+
clearTimeout(timeoutId);
|
|
31
|
+
}
|
|
32
|
+
// `isResolved` makes the RAF/timeout race first-winner-only
|
|
33
|
+
resolve();
|
|
34
|
+
};
|
|
35
|
+
const requestFrame = globalThis.requestAnimationFrame;
|
|
36
|
+
requestFrame(() => requestFrame(resolveOnce));
|
|
37
|
+
timeoutId = setTimeout(resolveOnce, 50);
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
async function waitForHydrationSettled(page, waitUntil, remainingReplacements) {
|
|
41
|
+
try {
|
|
42
|
+
await evaluateHydrationSettled(page);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
if (!isDestroyedExecutionContextError(err) || remainingReplacements <= 0)
|
|
46
|
+
throw err;
|
|
47
|
+
// A client-side redirect landed after the first document had already gone
|
|
48
|
+
// quiet, destroying the context this evaluate was waiting in. Wait for the
|
|
49
|
+
// document that replaced it, then measure hydration against that one.
|
|
50
|
+
await page.waitForLoadState(waitUntil);
|
|
51
|
+
await waitForHydrationSettled(page, waitUntil, remainingReplacements - 1);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Wait for React hydration of below-fold streaming components.
|
|
56
|
+
*
|
|
57
|
+
* React 19 prioritises above-fold hydration; components scrolled out of
|
|
58
|
+
* view receive lower-priority MessageChannel callbacks. The idle/animation
|
|
59
|
+
* probe is a bounded readiness heuristic, not proof that every client handler
|
|
60
|
+
* is attached. A control that cannot accept an early interaction must expose
|
|
61
|
+
* its own disabled-until-hydrated state; tests then wait for that state.
|
|
62
|
+
*
|
|
63
|
+
* Use this when navigateTo() alone is insufficient because the element you
|
|
64
|
+
* need to interact with lives inside a below-fold streaming boundary. Prefer
|
|
65
|
+
* scrolling the element into view first (element.scrollIntoViewIfNeeded())
|
|
66
|
+
* so React has a chance to bump its hydration priority before you call this.
|
|
67
|
+
*
|
|
68
|
+
* Tolerates a client-side redirect arriving mid-wait: the document the
|
|
69
|
+
* readiness probe started in can be replaced before the probe resolves, which
|
|
70
|
+
* destroys its execution context. Rather than failing, the wait restarts
|
|
71
|
+
* against the document that replaced it, so hydration is always measured
|
|
72
|
+
* against the document the caller ends up on. `waitUntil` is the load state to
|
|
73
|
+
* settle that replacement document to; callers that navigated under a stricter
|
|
74
|
+
* state should pass their own so a redirect does not silently weaken it.
|
|
75
|
+
*
|
|
76
|
+
* If you find yourself calling this frequently, consider fixing navigate-to.mts
|
|
77
|
+
* to use a more deterministic hydration signal instead.
|
|
78
|
+
*/
|
|
79
|
+
export async function waitForBelowFoldHydration(page, { waitUntil = 'load' } = {}) {
|
|
80
|
+
await waitForHydrationSettled(page, waitUntil, MAX_DOCUMENT_REPLACEMENTS);
|
|
81
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function readAnsiCString(command: string, startIndex: number): {
|
|
2
|
+
value: string;
|
|
3
|
+
endIndex: number;
|
|
4
|
+
} | null;
|
|
5
|
+
export declare function decodeAnsiCStringEscape(command: string, escapeIndex: number): {
|
|
6
|
+
value: string;
|
|
7
|
+
endIndex: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function decodeNumericAnsiEscape(command: string, startIndex: number, maxLength: number, radix: 8 | 16, fallbackPrefix: string): {
|
|
10
|
+
value: string;
|
|
11
|
+
endIndex: number;
|
|
12
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export function readAnsiCString(command, startIndex) {
|
|
2
|
+
let value = '';
|
|
3
|
+
for (let index = startIndex; index < command.length; index += 1) {
|
|
4
|
+
const char = command[index];
|
|
5
|
+
if (char === "'") {
|
|
6
|
+
return { value, endIndex: index };
|
|
7
|
+
}
|
|
8
|
+
if (char !== '\\') {
|
|
9
|
+
value += char;
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
if (index === command.length - 1) {
|
|
13
|
+
value += '\\';
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const escape = decodeAnsiCStringEscape(command, index + 1);
|
|
17
|
+
value += escape.value;
|
|
18
|
+
index = escape.endIndex;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
export function decodeAnsiCStringEscape(command, escapeIndex) {
|
|
23
|
+
const char = command[escapeIndex];
|
|
24
|
+
switch (char) {
|
|
25
|
+
case 'a':
|
|
26
|
+
return { value: '\u0007', endIndex: escapeIndex };
|
|
27
|
+
case 'b':
|
|
28
|
+
return { value: '\b', endIndex: escapeIndex };
|
|
29
|
+
case 'e':
|
|
30
|
+
case 'E':
|
|
31
|
+
return { value: '\u001b', endIndex: escapeIndex };
|
|
32
|
+
case 'f':
|
|
33
|
+
return { value: '\f', endIndex: escapeIndex };
|
|
34
|
+
case 'n':
|
|
35
|
+
return { value: '\n', endIndex: escapeIndex };
|
|
36
|
+
case 'r':
|
|
37
|
+
return { value: '\r', endIndex: escapeIndex };
|
|
38
|
+
case 't':
|
|
39
|
+
return { value: '\t', endIndex: escapeIndex };
|
|
40
|
+
case 'v':
|
|
41
|
+
return { value: '\v', endIndex: escapeIndex };
|
|
42
|
+
case '\\':
|
|
43
|
+
case "'":
|
|
44
|
+
case '"':
|
|
45
|
+
case '?':
|
|
46
|
+
return { value: char, endIndex: escapeIndex };
|
|
47
|
+
case '\n':
|
|
48
|
+
return { value: '', endIndex: escapeIndex };
|
|
49
|
+
case 'x':
|
|
50
|
+
return decodeNumericAnsiEscape(command, escapeIndex + 1, 2, 16, '\\x');
|
|
51
|
+
case 'u':
|
|
52
|
+
return decodeNumericAnsiEscape(command, escapeIndex + 1, 4, 16, '\\u');
|
|
53
|
+
case 'U':
|
|
54
|
+
return decodeNumericAnsiEscape(command, escapeIndex + 1, 8, 16, '\\U');
|
|
55
|
+
default:
|
|
56
|
+
if (/[0-7]/.test(char)) {
|
|
57
|
+
return decodeNumericAnsiEscape(command, escapeIndex, 3, 8, '\\');
|
|
58
|
+
}
|
|
59
|
+
return { value: char, endIndex: escapeIndex };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export function decodeNumericAnsiEscape(command, startIndex, maxLength, radix, fallbackPrefix) {
|
|
63
|
+
const pattern = radix === 16 ? /[0-9a-fA-F]/ : /[0-7]/;
|
|
64
|
+
let digits = '';
|
|
65
|
+
let endIndex = startIndex - 1;
|
|
66
|
+
for (let index = startIndex; index < command.length && digits.length < maxLength && pattern.test(command[index]); index += 1) {
|
|
67
|
+
digits += command[index];
|
|
68
|
+
endIndex = index;
|
|
69
|
+
}
|
|
70
|
+
if (digits.length === 0) {
|
|
71
|
+
return { value: fallbackPrefix, endIndex: startIndex - 1 };
|
|
72
|
+
}
|
|
73
|
+
const codePoint = Number.parseInt(digits, radix);
|
|
74
|
+
try {
|
|
75
|
+
return { value: String.fromCodePoint(codePoint), endIndex };
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return { value: `${fallbackPrefix}${digits}`, endIndex };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { decodeAnsiCStringEscape, decodeNumericAnsiEscape, readAnsiCString, } from './ansi-c-string.mts';
|
|
2
|
+
export { readBacktickSubstitution, readParenthesizedSubstitution, } from './shell-command-substitution-reads.mts';
|
|
3
|
+
export { extractShellCommandSubstitutions } from './shell-command-substitutions.mts';
|
|
4
|
+
export { parseCommandPrefix, readCommandPrefix, withoutRedirections, } from './shell-command-wrappers.mts';
|
|
5
|
+
export type { CommandPrefix } from './shell-command-wrappers.mts';
|
|
6
|
+
export { commandsToInspectForGitPolicy, commandsToInspectPreservingQuotes, envPrefixSetsEditor, extractShellCommandArguments, isInteractiveRebaseContinue, shellCommandInheritsEditor, stripGitGlobalOptionsForPolicy, stripQuotedShellText, } from './shell-commands.mts';
|
|
7
|
+
export type { ShellCommandArgument } from './shell-commands.mts';
|
|
8
|
+
export { readHeredocDelimiter } from './shell-heredoc-delimiter.mts';
|
|
9
|
+
export { heredocSpecsFromLine } from './shell-heredoc-parser.mts';
|
|
10
|
+
export type { HeredocSpec } from './shell-heredoc-parser.mts';
|
|
11
|
+
export { stripNonShellHeredocBodies } from './shell-heredoc.mts';
|
|
12
|
+
export { isRedirectionFd, isShellRedirectionOperatorToken, redirectionOperatorOf, SHELL_REDIRECTION_OPERATORS, shellRedirectionOperatorAt, } from './shell-redirections.mts';
|
|
13
|
+
export { findShellScriptArguments, isShellWord, shellScriptOperandIndex, } from './shell-script-operand.mts';
|
|
14
|
+
export type { ShellScriptArgument } from './shell-script-operand.mts';
|
|
15
|
+
export { shellReadsStdinAt } from './shell-stdin-script.mts';
|
|
16
|
+
export { commandSegmentStart, isShellAssignment, isShellCommandSeparator, nextShellCommandSeparatorIndex, plainShellAssignment, } from './shell-token-utils.mts';
|
|
17
|
+
export { stripUnquotedShellComments } from './shell-tokenizer-comments.mts';
|
|
18
|
+
export { consumeShellSeparator } from './shell-tokenizer-operators.mts';
|
|
19
|
+
export { tokenizeShellWords, tokenizeShellWordsDetailed } from './shell-tokenizer.mts';
|
|
20
|
+
export type { ShellWord } from './shell-tokenizer.mts';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { decodeAnsiCStringEscape, decodeNumericAnsiEscape, readAnsiCString, } from "./ansi-c-string.mjs";
|
|
2
|
+
export { readBacktickSubstitution, readParenthesizedSubstitution, } from "./shell-command-substitution-reads.mjs";
|
|
3
|
+
export { extractShellCommandSubstitutions } from "./shell-command-substitutions.mjs";
|
|
4
|
+
export { parseCommandPrefix, readCommandPrefix, withoutRedirections, } from "./shell-command-wrappers.mjs";
|
|
5
|
+
export { commandsToInspectForGitPolicy, commandsToInspectPreservingQuotes, envPrefixSetsEditor, extractShellCommandArguments, isInteractiveRebaseContinue, shellCommandInheritsEditor, stripGitGlobalOptionsForPolicy, stripQuotedShellText, } from "./shell-commands.mjs";
|
|
6
|
+
export { readHeredocDelimiter } from "./shell-heredoc-delimiter.mjs";
|
|
7
|
+
export { heredocSpecsFromLine } from "./shell-heredoc-parser.mjs";
|
|
8
|
+
export { stripNonShellHeredocBodies } from "./shell-heredoc.mjs";
|
|
9
|
+
export { isRedirectionFd, isShellRedirectionOperatorToken, redirectionOperatorOf, SHELL_REDIRECTION_OPERATORS, shellRedirectionOperatorAt, } from "./shell-redirections.mjs";
|
|
10
|
+
export { findShellScriptArguments, isShellWord, shellScriptOperandIndex, } from "./shell-script-operand.mjs";
|
|
11
|
+
export { shellReadsStdinAt } from "./shell-stdin-script.mjs";
|
|
12
|
+
export { commandSegmentStart, isShellAssignment, isShellCommandSeparator, nextShellCommandSeparatorIndex, plainShellAssignment, } from "./shell-token-utils.mjs";
|
|
13
|
+
export { stripUnquotedShellComments } from "./shell-tokenizer-comments.mjs";
|
|
14
|
+
export { consumeShellSeparator } from "./shell-tokenizer-operators.mjs";
|
|
15
|
+
export { tokenizeShellWords, tokenizeShellWordsDetailed } from "./shell-tokenizer.mjs";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function readParenthesizedSubstitution(command: string, startIndex: number): {
|
|
2
|
+
command: string;
|
|
3
|
+
endIndex: number;
|
|
4
|
+
} | null;
|
|
5
|
+
export declare function readBacktickSubstitution(command: string, startIndex: number): {
|
|
6
|
+
command: string;
|
|
7
|
+
endIndex: number;
|
|
8
|
+
} | null;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export function readParenthesizedSubstitution(command, startIndex) {
|
|
2
|
+
let depth = 1;
|
|
3
|
+
let quote = null;
|
|
4
|
+
let escaping = false;
|
|
5
|
+
for (let index = startIndex; index < command.length; index += 1) {
|
|
6
|
+
const char = command[index];
|
|
7
|
+
if (escaping) {
|
|
8
|
+
escaping = false;
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
if (char === '\\' && quote !== "'") {
|
|
12
|
+
escaping = true;
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (char === "'" && quote !== '"') {
|
|
16
|
+
quote = quote === "'" ? null : "'";
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (char === '"' && quote !== "'") {
|
|
20
|
+
quote = quote === '"' ? null : '"';
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (quote === null && char === '(') {
|
|
24
|
+
depth += 1;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (quote === null && char === ')' && --depth === 0) {
|
|
28
|
+
return { command: command.slice(startIndex, index), endIndex: index };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
export function readBacktickSubstitution(command, startIndex) {
|
|
34
|
+
let value = '';
|
|
35
|
+
let escaping = false;
|
|
36
|
+
for (let index = startIndex; index < command.length; index += 1) {
|
|
37
|
+
const char = command[index];
|
|
38
|
+
if (escaping) {
|
|
39
|
+
value += char === '`' || char === '\\' || char === '$' ? char : `\\${char}`;
|
|
40
|
+
escaping = false;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (char === '\\') {
|
|
44
|
+
escaping = true;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (char === '`') {
|
|
48
|
+
return { command: value, endIndex: index };
|
|
49
|
+
}
|
|
50
|
+
value += char;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { readBacktickSubstitution, readParenthesizedSubstitution } from './shell-command-substitution-reads.mts';
|
|
2
|
+
/**
|
|
3
|
+
* The command substitutions a command's text runs. Heredoc bodies follow other quoting rules, so
|
|
4
|
+
* the caller blanks them first and reads their substitutions from the heredoc scan
|
|
5
|
+
* (shell-heredoc.mts).
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractShellCommandSubstitutions(textWithoutBodies: string): string[];
|
|
8
|
+
export { readBacktickSubstitution, readParenthesizedSubstitution };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { readBacktickSubstitution, readParenthesizedSubstitution, } from "./shell-command-substitution-reads.mjs";
|
|
2
|
+
import { stripUnquotedShellComments } from "./shell-tokenizer.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* The command substitutions a command's text runs. Heredoc bodies follow other quoting rules, so
|
|
5
|
+
* the caller blanks them first and reads their substitutions from the heredoc scan
|
|
6
|
+
* (shell-heredoc.mts).
|
|
7
|
+
*/
|
|
8
|
+
export function extractShellCommandSubstitutions(textWithoutBodies) {
|
|
9
|
+
const source = stripUnquotedShellComments(textWithoutBodies);
|
|
10
|
+
const substitutions = [];
|
|
11
|
+
let quote = null;
|
|
12
|
+
let escaping = false;
|
|
13
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
14
|
+
const char = source[index];
|
|
15
|
+
if (escaping) {
|
|
16
|
+
escaping = false;
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (char === '\\' && quote !== "'") {
|
|
20
|
+
escaping = true;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (char === "'" && quote !== '"') {
|
|
24
|
+
quote = quote === "'" ? null : "'";
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (char === '"' && quote !== "'") {
|
|
28
|
+
quote = quote === '"' ? null : '"';
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (quote === "'") {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (char === '$' && source[index + 1] === '(') {
|
|
35
|
+
const substitution = readParenthesizedSubstitution(source, index + 2);
|
|
36
|
+
if (substitution !== null) {
|
|
37
|
+
substitutions.push(substitution.command);
|
|
38
|
+
index = substitution.endIndex;
|
|
39
|
+
}
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (char === '`') {
|
|
43
|
+
const substitution = readBacktickSubstitution(source, index + 1);
|
|
44
|
+
if (substitution !== null) {
|
|
45
|
+
substitutions.push(substitution.command);
|
|
46
|
+
index = substitution.endIndex;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return substitutions;
|
|
51
|
+
}
|
|
52
|
+
export { readBacktickSubstitution, readParenthesizedSubstitution };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** What a recognized wrapper chain before a command word changes about how that command runs. */
|
|
2
|
+
export type CommandPrefix = {
|
|
3
|
+
/** The effective `env -C` directory of each `env` in the chain, outermost first. */
|
|
4
|
+
chdir: string[];
|
|
5
|
+
/** Assignments and `env -u` unsets the command sees. */
|
|
6
|
+
env: Record<string, string | undefined>;
|
|
7
|
+
/** Wrapper basenames, outermost first. */
|
|
8
|
+
wrappers: string[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Parses the words between a command segment's start and a command word. Returns null when they
|
|
12
|
+
* are not a recognized wrapper chain, i.e. the command word is an argument rather than the
|
|
13
|
+
* program the shell runs. Wrappers chain in any order (`nohup env -C /tmp gh`) and match by
|
|
14
|
+
* basename (`/usr/bin/env`).
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseCommandPrefix(prefixWords: readonly string[]): CommandPrefix | null;
|
|
17
|
+
/**
|
|
18
|
+
* Reads the wrapper chain that opens a simple command's words (redirections already removed) and
|
|
19
|
+
* finds the command word it runs. Returns null when a wrapper's options are unrecognized or only
|
|
20
|
+
* describe the command (`command -v gh`).
|
|
21
|
+
*/
|
|
22
|
+
export declare function readCommandPrefix(words: readonly string[]): {
|
|
23
|
+
commandIndex: number;
|
|
24
|
+
prefix: CommandPrefix;
|
|
25
|
+
} | null;
|
|
26
|
+
export declare function withoutRedirections(words: readonly string[]): string[] | null;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { isShellRedirectionOperatorToken } from "./shell-redirections.mjs";
|
|
2
|
+
import { isShellAssignment, plainShellAssignment } from "./shell-token-utils.mjs";
|
|
3
|
+
// Reserved words that may open a simple command without choosing which program it runs.
|
|
4
|
+
const SHELL_CONTROL_PREFIXES = new Set([
|
|
5
|
+
'!',
|
|
6
|
+
'{',
|
|
7
|
+
'coproc',
|
|
8
|
+
'do',
|
|
9
|
+
'elif',
|
|
10
|
+
'else',
|
|
11
|
+
'if',
|
|
12
|
+
'then',
|
|
13
|
+
'until',
|
|
14
|
+
'while',
|
|
15
|
+
]);
|
|
16
|
+
// Control prefixes that open a compound command whose first command follows in the same segment.
|
|
17
|
+
const COMPOUND_OPENERS = new Set(['{', 'if', 'until', 'while']);
|
|
18
|
+
/**
|
|
19
|
+
* The only wrappers the hook reads through, by basename, with each option spelling they accept.
|
|
20
|
+
* An `arguments` option takes one argument, attached (`-C/tmp`, `--chdir=/tmp`) or the next word.
|
|
21
|
+
* Any other option (`env -S`, a flag cluster) and every other wrapper (`timeout`, `sudo`, `xargs`)
|
|
22
|
+
* leaves the command word unread.
|
|
23
|
+
*/
|
|
24
|
+
const WRAPPERS = new Map([
|
|
25
|
+
['builtin', { arguments: {}, flags: [] }],
|
|
26
|
+
['command', { arguments: {}, flags: ['-p'] }],
|
|
27
|
+
[
|
|
28
|
+
'env',
|
|
29
|
+
{
|
|
30
|
+
arguments: { '--chdir': 'chdir', '--unset': 'unset', '-C': 'chdir', '-u': 'unset' },
|
|
31
|
+
flags: ['-', '-i', '--ignore-environment'],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
['exec', { arguments: { '-a': 'other' }, flags: ['-c', '-l'] }],
|
|
35
|
+
['nohup', { arguments: {}, flags: [] }],
|
|
36
|
+
['time', { arguments: {}, flags: ['-p'] }],
|
|
37
|
+
]);
|
|
38
|
+
/**
|
|
39
|
+
* Parses the words between a command segment's start and a command word. Returns null when they
|
|
40
|
+
* are not a recognized wrapper chain, i.e. the command word is an argument rather than the
|
|
41
|
+
* program the shell runs. Wrappers chain in any order (`nohup env -C /tmp gh`) and match by
|
|
42
|
+
* basename (`/usr/bin/env`).
|
|
43
|
+
*/
|
|
44
|
+
export function parseCommandPrefix(prefixWords) {
|
|
45
|
+
const words = withoutRedirections(prefixWords);
|
|
46
|
+
if (words === null)
|
|
47
|
+
return null;
|
|
48
|
+
const read = readCommandPrefix(words);
|
|
49
|
+
return read?.commandIndex === words.length ? read.prefix : null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Reads the wrapper chain that opens a simple command's words (redirections already removed) and
|
|
53
|
+
* finds the command word it runs. Returns null when a wrapper's options are unrecognized or only
|
|
54
|
+
* describe the command (`command -v gh`).
|
|
55
|
+
*/
|
|
56
|
+
export function readCommandPrefix(words) {
|
|
57
|
+
const prefix = { chdir: [], env: {}, wrappers: [] };
|
|
58
|
+
let controlAllowed = true;
|
|
59
|
+
let cursor = 0;
|
|
60
|
+
while (cursor < words.length) {
|
|
61
|
+
const word = words[cursor];
|
|
62
|
+
if (isShellAssignment(word)) {
|
|
63
|
+
const assignment = plainShellAssignment(word);
|
|
64
|
+
if (assignment !== null)
|
|
65
|
+
prefix.env[assignment.name] = assignment.value;
|
|
66
|
+
cursor += 1;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
// `function NAME` and bash's `coproc NAME` before a compound command (`coproc m { gh …; }`).
|
|
70
|
+
if (controlAllowed &&
|
|
71
|
+
(word === 'function' || (word === 'coproc' && COMPOUND_OPENERS.has(words[cursor + 2]))) &&
|
|
72
|
+
cursor + 1 < words.length) {
|
|
73
|
+
cursor += 2;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (controlAllowed && SHELL_CONTROL_PREFIXES.has(word)) {
|
|
77
|
+
cursor += 1;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const name = word.slice(word.lastIndexOf('/') + 1);
|
|
81
|
+
const grammar = WRAPPERS.get(name);
|
|
82
|
+
if (grammar === undefined)
|
|
83
|
+
return { commandIndex: cursor, prefix };
|
|
84
|
+
cursor = readWrapperOptions(words, cursor + 1, grammar, prefix);
|
|
85
|
+
if (cursor < 0)
|
|
86
|
+
return null;
|
|
87
|
+
prefix.wrappers.push(name);
|
|
88
|
+
// The `time` keyword times a whole pipeline, so `time ! gh` is still a command.
|
|
89
|
+
controlAllowed = name === 'time';
|
|
90
|
+
}
|
|
91
|
+
return { commandIndex: words.length, prefix };
|
|
92
|
+
}
|
|
93
|
+
// The shell applies redirections itself and drops each operator and its target from the argv the
|
|
94
|
+
// command (or wrapper) receives, wherever they appear: `2>/dev/null env -C /tmp gh` runs env with
|
|
95
|
+
// `-C /tmp gh`. A trailing operator's target is the command word, so that word is not a command.
|
|
96
|
+
export function withoutRedirections(words) {
|
|
97
|
+
const argv = [];
|
|
98
|
+
for (let index = 0; index < words.length; index += 1) {
|
|
99
|
+
if (!isShellRedirectionOperatorToken(words[index])) {
|
|
100
|
+
argv.push(words[index]);
|
|
101
|
+
}
|
|
102
|
+
else if (index + 1 === words.length) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
index += 1;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return argv;
|
|
110
|
+
}
|
|
111
|
+
// Applies one wrapper's options to `prefix` and returns the index after them (right after `--` or
|
|
112
|
+
// at the first operand), or -1 for an option outside the grammar. GNU and BSD env keep only the
|
|
113
|
+
// last -C, relative to the directory env started in.
|
|
114
|
+
function readWrapperOptions(words, start, grammar, prefix) {
|
|
115
|
+
let chdir;
|
|
116
|
+
let cursor = start;
|
|
117
|
+
while (words[cursor]?.startsWith('-')) {
|
|
118
|
+
const word = words[cursor++];
|
|
119
|
+
if (word === '--')
|
|
120
|
+
break;
|
|
121
|
+
if (grammar.flags.includes(word))
|
|
122
|
+
continue;
|
|
123
|
+
const spelling = Object.keys(grammar.arguments).find((option) => takesOption(word, option));
|
|
124
|
+
const attached = spelling === undefined ? '' : word.slice(spelling.length).replace(/^=/, '');
|
|
125
|
+
const value = attached || words[cursor++];
|
|
126
|
+
if (spelling === undefined || value === undefined)
|
|
127
|
+
return -1;
|
|
128
|
+
if (grammar.arguments[spelling] === 'unset')
|
|
129
|
+
prefix.env[value] = undefined;
|
|
130
|
+
if (grammar.arguments[spelling] === 'chdir')
|
|
131
|
+
chdir = value;
|
|
132
|
+
}
|
|
133
|
+
if (chdir !== undefined)
|
|
134
|
+
prefix.chdir.push(chdir);
|
|
135
|
+
return cursor;
|
|
136
|
+
}
|
|
137
|
+
// A short option takes its argument attached (`-C/tmp`); a long one only after `=` (`--chdir=/tmp`),
|
|
138
|
+
// so `--chdirx` is an unknown option, not `--chdir x`.
|
|
139
|
+
function takesOption(word, option) {
|
|
140
|
+
if (!option.startsWith('--'))
|
|
141
|
+
return word.startsWith(option);
|
|
142
|
+
return word === option || word.startsWith(`${option}=`);
|
|
143
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Collapse `git -C <path>` / other globals so banned-subcommand regexes still match. */
|
|
2
|
+
export declare function stripGitGlobalOptionsForPolicy(command: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* The scripts the git, hook-bypass, and dev-server policies read: the command text, each heredoc
|
|
5
|
+
* body a shell may read as its script, and each substitution an unquoted-delimiter body runs, each
|
|
6
|
+
* with the `bash -c` scripts nested in it. Any other heredoc body is data (a `git commit -F -`
|
|
7
|
+
* message).
|
|
8
|
+
*
|
|
9
|
+
* Substitutions in the command text itself (`echo $(...)`) are not scanned: callers must also run
|
|
10
|
+
* `extractShellCommandSubstitutions` and inspect each result.
|
|
11
|
+
*/
|
|
12
|
+
export declare function commandsToInspectForGitPolicy(command: string): string[];
|
|
13
|
+
/** The same list with quoted refs readable; it too skips `$(...)` in the command text. */
|
|
14
|
+
export declare function commandsToInspectPreservingQuotes(command: string): string[];
|
|
15
|
+
export type ShellCommandArgument = {
|
|
16
|
+
command: string;
|
|
17
|
+
inheritsEditor: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare function extractShellCommandArguments(command: string): ShellCommandArgument[];
|
|
20
|
+
export declare function shellCommandInheritsEditor(command: string, shellCommandIndex: number): boolean;
|
|
21
|
+
export declare function isInteractiveRebaseContinue(command: string): boolean;
|
|
22
|
+
export declare function envPrefixSetsEditor(prefix: string): boolean;
|
|
23
|
+
/** Blanks quoted text. It does not look inside `$(...)`; see `extractShellCommandSubstitutions`. */
|
|
24
|
+
export declare function stripQuotedShellText(command: string): string;
|