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.
Files changed (187) hide show
  1. package/README.md +76 -12
  2. package/dist/agent-blackboard/index.d.mts +0 -1
  3. package/dist/agent-blackboard/index.mjs +0 -23
  4. package/dist/cli/commands/agent-blackboard-flags.d.mts +0 -1
  5. package/dist/cli/commands/agent-blackboard-flags.mjs +0 -9
  6. package/dist/cli/commands/agent-blackboard.d.mts +0 -2
  7. package/dist/cli/commands/agent-blackboard.mjs +7 -121
  8. package/dist/cli/commands/story-coverage.d.mts +2 -0
  9. package/dist/cli/commands/story-coverage.mjs +56 -0
  10. package/dist/cli/index.mjs +6 -0
  11. package/dist/cli/parse-forwarded-commands.d.mts +3 -0
  12. package/dist/cli/parse-forwarded-commands.mjs +2 -0
  13. package/dist/cli/parse-story-coverage-fields.d.mts +19 -0
  14. package/dist/cli/parse-story-coverage-fields.mjs +69 -0
  15. package/dist/cli/parse-story-coverage.d.mts +8 -0
  16. package/dist/cli/parse-story-coverage.mjs +34 -0
  17. package/dist/cli/parse.d.mts +5 -1
  18. package/dist/cli/parse.mjs +3 -0
  19. package/dist/cli/usage.d.mts +1 -1
  20. package/dist/cli/usage.mjs +8 -7
  21. package/dist/host-storage/check.d.mts +38 -0
  22. package/dist/host-storage/check.mjs +109 -0
  23. package/dist/host-storage/cli.d.mts +7 -0
  24. package/dist/host-storage/cli.mjs +102 -0
  25. package/dist/host-storage/host-storage.test-helpers.d.mts +26 -0
  26. package/dist/host-storage/host-storage.test-helpers.mjs +58 -0
  27. package/dist/host-storage/index.d.mts +3 -0
  28. package/dist/host-storage/index.mjs +3 -0
  29. package/dist/host-storage/preflight.d.mts +22 -0
  30. package/dist/host-storage/preflight.mjs +105 -0
  31. package/dist/index.d.mts +2 -0
  32. package/dist/index.mjs +1 -0
  33. package/dist/playwright/assertions.d.mts +1 -0
  34. package/dist/playwright/assertions.mjs +5 -0
  35. package/dist/playwright/blocked-external-network.d.mts +15 -0
  36. package/dist/playwright/blocked-external-network.mjs +73 -0
  37. package/dist/playwright/browser-dialog-issues.d.mts +12 -0
  38. package/dist/playwright/browser-dialog-issues.mjs +29 -0
  39. package/dist/playwright/browser-errors.d.mts +22 -0
  40. package/dist/playwright/browser-errors.mjs +130 -0
  41. package/dist/playwright/browser-issue-monitor.test-helpers.d.mts +31 -0
  42. package/dist/playwright/browser-issue-monitor.test-helpers.mjs +51 -0
  43. package/dist/playwright/browser-issue-records.d.mts +42 -0
  44. package/dist/playwright/browser-issue-records.mjs +148 -0
  45. package/dist/playwright/browser-test.d.mts +21 -0
  46. package/dist/playwright/browser-test.mjs +68 -0
  47. package/dist/playwright/expect-no-broken-images.d.mts +17 -0
  48. package/dist/playwright/expect-no-broken-images.mjs +39 -0
  49. package/dist/playwright/index.d.mts +30 -0
  50. package/dist/playwright/index.mjs +22 -0
  51. package/dist/playwright/mobile-assertions.d.mts +14 -0
  52. package/dist/playwright/mobile-assertions.mjs +43 -0
  53. package/dist/playwright/navigate-to.d.mts +27 -0
  54. package/dist/playwright/navigate-to.mjs +39 -0
  55. package/dist/playwright/radix-select.d.mts +18 -0
  56. package/dist/playwright/radix-select.mjs +19 -0
  57. package/dist/playwright/random-id.d.mts +34 -0
  58. package/dist/playwright/random-id.mjs +37 -0
  59. package/dist/playwright/retry-on-connection-lost.d.mts +7 -0
  60. package/dist/playwright/retry-on-connection-lost.mjs +107 -0
  61. package/dist/playwright/scroll-to-load-more.d.mts +37 -0
  62. package/dist/playwright/scroll-to-load-more.mjs +158 -0
  63. package/dist/playwright/storybook.d.mts +2 -0
  64. package/dist/playwright/storybook.mjs +13 -0
  65. package/dist/playwright/test-fixtures.d.mts +1 -0
  66. package/dist/playwright/test-fixtures.mjs +2 -0
  67. package/dist/playwright/test-lifecycle-reporter.d.mts +11 -0
  68. package/dist/playwright/test-lifecycle-reporter.mjs +35 -0
  69. package/dist/playwright/totp.d.mts +6 -0
  70. package/dist/playwright/totp.mjs +37 -0
  71. package/dist/playwright/turnstile-stub.d.mts +8 -0
  72. package/dist/playwright/turnstile-stub.mjs +61 -0
  73. package/dist/playwright/viewport-constants.d.mts +30 -0
  74. package/dist/playwright/viewport-constants.mjs +9 -0
  75. package/dist/playwright/virtual-authenticator.d.mts +5 -0
  76. package/dist/playwright/virtual-authenticator.mjs +15 -0
  77. package/dist/playwright/wait-for-hydration.d.mts +29 -0
  78. package/dist/playwright/wait-for-hydration.mjs +81 -0
  79. package/dist/shell-parse/ansi-c-string.d.mts +12 -0
  80. package/dist/shell-parse/ansi-c-string.mjs +80 -0
  81. package/dist/shell-parse/index.d.mts +20 -0
  82. package/dist/shell-parse/index.mjs +15 -0
  83. package/dist/shell-parse/shell-command-substitution-reads.d.mts +8 -0
  84. package/dist/shell-parse/shell-command-substitution-reads.mjs +53 -0
  85. package/dist/shell-parse/shell-command-substitutions.d.mts +8 -0
  86. package/dist/shell-parse/shell-command-substitutions.mjs +52 -0
  87. package/dist/shell-parse/shell-command-wrappers.d.mts +26 -0
  88. package/dist/shell-parse/shell-command-wrappers.mjs +143 -0
  89. package/dist/shell-parse/shell-commands.d.mts +24 -0
  90. package/dist/shell-parse/shell-commands.mjs +155 -0
  91. package/dist/shell-parse/shell-heredoc-delimiter.d.mts +5 -0
  92. package/dist/shell-parse/shell-heredoc-delimiter.mjs +52 -0
  93. package/dist/shell-parse/shell-heredoc-parser.d.mts +7 -0
  94. package/dist/shell-parse/shell-heredoc-parser.mjs +49 -0
  95. package/dist/shell-parse/shell-heredoc-quote-state.d.mts +19 -0
  96. package/dist/shell-parse/shell-heredoc-quote-state.mjs +40 -0
  97. package/dist/shell-parse/shell-heredoc.d.mts +10 -0
  98. package/dist/shell-parse/shell-heredoc.mjs +90 -0
  99. package/dist/shell-parse/shell-redirections.d.mts +5 -0
  100. package/dist/shell-parse/shell-redirections.mjs +34 -0
  101. package/dist/shell-parse/shell-script-operand.d.mts +13 -0
  102. package/dist/shell-parse/shell-script-operand.mjs +103 -0
  103. package/dist/shell-parse/shell-stdin-script.d.mts +6 -0
  104. package/dist/shell-parse/shell-stdin-script.mjs +61 -0
  105. package/dist/shell-parse/shell-token-utils.d.mts +9 -0
  106. package/dist/shell-parse/shell-token-utils.mjs +33 -0
  107. package/dist/shell-parse/shell-tokenizer-comments.d.mts +1 -0
  108. package/dist/shell-parse/shell-tokenizer-comments.mjs +57 -0
  109. package/dist/shell-parse/shell-tokenizer-operators.d.mts +14 -0
  110. package/dist/shell-parse/shell-tokenizer-operators.mjs +47 -0
  111. package/dist/shell-parse/shell-tokenizer.d.mts +12 -0
  112. package/dist/shell-parse/shell-tokenizer.mjs +104 -0
  113. package/dist/story-coverage/analyze.d.mts +8 -0
  114. package/dist/story-coverage/analyze.mjs +24 -0
  115. package/dist/story-coverage/check.d.mts +11 -0
  116. package/dist/story-coverage/check.mjs +42 -0
  117. package/dist/story-coverage/components.d.mts +10 -0
  118. package/dist/story-coverage/components.mjs +40 -0
  119. package/dist/story-coverage/coverage.d.mts +10 -0
  120. package/dist/story-coverage/coverage.mjs +43 -0
  121. package/dist/story-coverage/index.d.mts +13 -0
  122. package/dist/story-coverage/index.mjs +7 -0
  123. package/dist/story-coverage/messages.d.mts +10 -0
  124. package/dist/story-coverage/messages.mjs +42 -0
  125. package/dist/story-coverage/options.d.mts +27 -0
  126. package/dist/story-coverage/options.mjs +51 -0
  127. package/dist/story-coverage/workspace.d.mts +2 -0
  128. package/dist/story-coverage/workspace.mjs +27 -0
  129. package/dist/test-helpers/cancel-runs.test-helpers.d.mts +39 -0
  130. package/dist/test-helpers/cancel-runs.test-helpers.mjs +124 -0
  131. package/dist/test-helpers/run-bounded-exit-observer.test-helpers.d.mts +12 -0
  132. package/dist/test-helpers/run-bounded-exit-observer.test-helpers.mjs +68 -0
  133. package/dist/test-helpers/run-bounded-output-fixture.test-helpers.d.mts +18 -0
  134. package/dist/test-helpers/run-bounded-output-fixture.test-helpers.mjs +162 -0
  135. package/dist/vitest-diagnostics/index.d.mts +9 -1
  136. package/dist/vitest-diagnostics/index.mjs +5 -1
  137. package/dist/vitest-diagnostics/vitest-fake-timer-guard.d.mts +6 -0
  138. package/dist/vitest-diagnostics/vitest-fake-timer-guard.mjs +34 -0
  139. package/dist/vitest-diagnostics/vitest-fork-leak-detection.d.mts +1 -0
  140. package/dist/vitest-diagnostics/vitest-fork-leak-detection.mjs +8 -0
  141. package/dist/vitest-diagnostics/vitest-fork-leak-diagnostics.d.mts +10 -1
  142. package/dist/vitest-diagnostics/vitest-fork-leak-diagnostics.mjs +43 -2
  143. package/dist/vitest-diagnostics/vitest-fork-leak-handshake-samples.d.mts +50 -0
  144. package/dist/vitest-diagnostics/vitest-fork-leak-handshake-samples.mjs +69 -0
  145. package/dist/vitest-diagnostics/vitest-fork-leak-handshake.d.mts +19 -0
  146. package/dist/vitest-diagnostics/vitest-fork-leak-handshake.mjs +136 -0
  147. package/dist/vitest-diagnostics/vitest-network-allowlist-dns.d.mts +7 -0
  148. package/dist/vitest-diagnostics/vitest-network-allowlist-dns.mjs +54 -0
  149. package/dist/vitest-diagnostics/vitest-network-allowlist-host.d.mts +8 -0
  150. package/dist/vitest-diagnostics/vitest-network-allowlist-host.mjs +48 -0
  151. package/dist/vitest-diagnostics/vitest-network-allowlist-socket.d.mts +14 -0
  152. package/dist/vitest-diagnostics/vitest-network-allowlist-socket.mjs +39 -0
  153. package/dist/vitest-diagnostics/vitest-network-allowlist.d.mts +7 -0
  154. package/dist/vitest-diagnostics/vitest-network-allowlist.mjs +72 -0
  155. package/dist/vitest-diagnostics/vitest-process-resources.d.mts +6 -0
  156. package/dist/vitest-diagnostics/vitest-process-resources.mjs +51 -0
  157. package/dist/vitest-effective-timeout/cap.d.mts +9 -0
  158. package/dist/vitest-effective-timeout/cap.mjs +28 -0
  159. package/dist/vitest-effective-timeout/check-profiles.d.mts +15 -0
  160. package/dist/vitest-effective-timeout/check-profiles.mjs +52 -0
  161. package/dist/vitest-effective-timeout/config-file.d.mts +6 -0
  162. package/dist/vitest-effective-timeout/config-file.mjs +23 -0
  163. package/dist/vitest-effective-timeout/fixtures.d.mts +2 -0
  164. package/dist/vitest-effective-timeout/fixtures.mjs +18 -0
  165. package/dist/vitest-effective-timeout/index.d.mts +7 -0
  166. package/dist/vitest-effective-timeout/index.mjs +4 -0
  167. package/dist/vitest-effective-timeout/profiles.d.mts +10 -0
  168. package/dist/vitest-effective-timeout/profiles.mjs +33 -0
  169. package/dist/vitest-effective-timeout/run-profile.d.mts +31 -0
  170. package/dist/vitest-effective-timeout/run-profile.mjs +95 -0
  171. package/docs/mcp-server.md +2 -13
  172. package/package.json +32 -2
  173. package/scripts/__pycache__/run_bounded_process.cpython-312.pyc +0 -0
  174. package/scripts/chromium-launch-probe.d.mts +7 -0
  175. package/scripts/chromium-launch-probe.mjs +101 -0
  176. package/scripts/run-bounded-fixtures/run-bounded-backpressure.py +186 -0
  177. package/scripts/run-bounded-fixtures/run-bounded-merged-output.py +75 -0
  178. package/scripts/run-bounded-fixtures/run-bounded-reset-socket.py +25 -0
  179. package/scripts/run-bounded.py +199 -0
  180. package/scripts/run_bounded_process.py +129 -0
  181. package/scripts/worktree/git-index-lock.sh +16 -0
  182. package/scripts/worktree/git-worktrees.sh +23 -20
  183. package/scripts/worktree/reset-worktree-run.sh +199 -0
  184. package/scripts/worktree/reset-worktree.sh +122 -0
  185. package/skills/blackboard/SKILL.md +4 -64
  186. package/skills/stacked-prs/SKILL.md +1 -1
  187. package/skills/stacked-prs/references/drain.md +2 -2
@@ -0,0 +1,103 @@
1
+ import { readAnsiCString } from "./ansi-c-string.mjs";
2
+ // Every shell that reads a script from stdin or `-c`. `busybox` and `toybox` run `sh` / `ash` as an
3
+ // applet, so `segmentMayRunStdin` fails closed on them rather than parsing the applet name.
4
+ const SHELLS = new Set(['ash', 'bash', 'csh', 'dash', 'fish', 'ksh', 'mksh', 'sh', 'tcsh', 'zsh']);
5
+ // Long options that take the next word: bash `--rcfile FILE` / `--init-file FILE`, zsh
6
+ // `--emulate NAME`. Listing an extra name only makes a malformed invocation look scriptless.
7
+ const LONG_OPTIONS_WITH_ARGUMENT = new Set(['emulate', 'init-file', 'rcfile']);
8
+ const SHELL_WORD = /(?:^|[\s;&|()])(?:\S*\/)?(?:ash|bash|csh|dash|fish|ksh|mksh|sh|tcsh|zsh)(?=\s)/g;
9
+ const NEXT_WORD = /\s*(\S+)/y;
10
+ // A backslash is literal inside single quotes. Inside double quotes it escapes one character, and
11
+ // the two branches start with different characters so a run of backslashes has one reading.
12
+ const SINGLE_QUOTED_SCRIPT = /'([^']*)'/y;
13
+ const DOUBLE_QUOTED_SCRIPT = /"((?:\\[\s\S]|[^"\\])*)"/y;
14
+ /**
15
+ * How bash, sh, and zsh read one word before their first operand. `--` and `-` end the options.
16
+ * Each `o` / `O` letter in a `-` or `+` cluster consumes the next word (`-euo pipefail`,
17
+ * `+O extglob`), and a `c` letter in a `-` cluster makes the first operand the script.
18
+ */
19
+ function readShellOption(word) {
20
+ if (word === '--' || word === '-')
21
+ return 'end';
22
+ if (/^[-+][A-Za-z]+$/.test(word)) {
23
+ return {
24
+ argumentWords: word.replace(/[^oO]/g, '').length,
25
+ runsScript: word.startsWith('-') && word.includes('c'),
26
+ };
27
+ }
28
+ if (/^--[A-Za-z]/.test(word)) {
29
+ return {
30
+ argumentWords: LONG_OPTIONS_WITH_ARGUMENT.has(word.slice(2)) ? 1 : 0,
31
+ runsScript: false,
32
+ };
33
+ }
34
+ return 'operand';
35
+ }
36
+ /** Whether a command word runs bash, sh, or zsh, by any path. */
37
+ export function isShellWord(word) {
38
+ return SHELLS.has(word.slice(word.lastIndexOf('/') + 1));
39
+ }
40
+ /** The index of the script a `bash` / `sh` / `zsh -c` word at `index` runs, if it runs one. */
41
+ export function shellScriptOperandIndex(words, index) {
42
+ if (!isShellWord(words[index]))
43
+ return undefined;
44
+ let runsScript = false;
45
+ let cursor = index + 1;
46
+ while (cursor < words.length) {
47
+ const option = readShellOption(words[cursor]);
48
+ if (option === 'operand')
49
+ break;
50
+ cursor += 1;
51
+ if (option === 'end')
52
+ break;
53
+ runsScript ||= option.runsScript;
54
+ cursor += option.argumentWords;
55
+ }
56
+ return runsScript && cursor < words.length ? cursor : undefined;
57
+ }
58
+ /**
59
+ * The quoted or ANSI-C quoted scripts that `bash` / `sh` / `zsh -c` run in raw command text, each
60
+ * with the index where its shell word's match starts.
61
+ */
62
+ export function findShellScriptArguments(command) {
63
+ const scripts = [];
64
+ for (const match of command.matchAll(SHELL_WORD)) {
65
+ const start = scriptStart(command, match.index + match[0].length);
66
+ const script = start === undefined ? undefined : readQuotedScript(command, start);
67
+ if (script !== undefined)
68
+ scripts.push({ script, shellIndex: match.index });
69
+ }
70
+ return scripts;
71
+ }
72
+ function scriptStart(command, position) {
73
+ let runsScript = false;
74
+ let optionsEnded = false;
75
+ let pendingArguments = 0;
76
+ NEXT_WORD.lastIndex = position;
77
+ for (let match = NEXT_WORD.exec(command); match !== null; match = NEXT_WORD.exec(command)) {
78
+ if (pendingArguments > 0) {
79
+ pendingArguments -= 1;
80
+ continue;
81
+ }
82
+ const option = optionsEnded ? 'operand' : readShellOption(match[1]);
83
+ if (option === 'operand')
84
+ return runsScript ? NEXT_WORD.lastIndex - match[1].length : undefined;
85
+ if (option === 'end') {
86
+ optionsEnded = true;
87
+ continue;
88
+ }
89
+ runsScript ||= option.runsScript;
90
+ pendingArguments = option.argumentWords;
91
+ }
92
+ return undefined;
93
+ }
94
+ function readQuotedScript(command, start) {
95
+ if (command.startsWith("$'", start))
96
+ return readAnsiCString(command, start + 2)?.value;
97
+ if (command[start] === "'") {
98
+ SINGLE_QUOTED_SCRIPT.lastIndex = start;
99
+ return SINGLE_QUOTED_SCRIPT.exec(command)?.[1];
100
+ }
101
+ DOUBLE_QUOTED_SCRIPT.lastIndex = start;
102
+ return DOUBLE_QUOTED_SCRIPT.exec(command)?.[1]?.replace(/\\([$`"\\\n])/g, '$1');
103
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Whether a shell may read the stdin redirection (heredoc or here-string) at `operatorIndex` of
3
+ * `tokens` (tokenized with `splitRedirections`) as its script: the redirected command, or any later
4
+ * stage of its pipeline, is one the hook cannot rule out as a scriptless shell.
5
+ */
6
+ export declare function shellReadsStdinAt(tokens: string[], operatorIndex: number): boolean;
@@ -0,0 +1,61 @@
1
+ import { readCommandPrefix, withoutRedirections } from "./shell-command-wrappers.mjs";
2
+ import { isShellWord, shellScriptOperandIndex } from "./shell-script-operand.mjs";
3
+ import { commandSegmentStart, nextShellCommandSeparatorIndex } from "./shell-token-utils.mjs";
4
+ // Words that close a compound command. Its redirections feed every command inside it.
5
+ const COMPOUND_CLOSERS = new Set(['done', 'esac', 'fi']);
6
+ const EXEC_WRAPPERS = new Set([
7
+ 'busybox',
8
+ 'chroot',
9
+ 'doas',
10
+ 'ionice',
11
+ 'nice',
12
+ 'setsid',
13
+ 'stdbuf',
14
+ 'su',
15
+ 'sudo',
16
+ 'timeout',
17
+ 'toybox',
18
+ 'xargs',
19
+ ]);
20
+ const EXPANSION = /[$`*?[]/;
21
+ /**
22
+ * Whether a shell may read the stdin redirection (heredoc or here-string) at `operatorIndex` of
23
+ * `tokens` (tokenized with `splitRedirections`) as its script: the redirected command, or any later
24
+ * stage of its pipeline, is one the hook cannot rule out as a scriptless shell.
25
+ */
26
+ export function shellReadsStdinAt(tokens, operatorIndex) {
27
+ let start = commandSegmentStart(tokens, operatorIndex);
28
+ let end = nextShellCommandSeparatorIndex(tokens, operatorIndex);
29
+ if (segmentMayRunStdin(tokens, start, end))
30
+ return true;
31
+ while (tokens[end] === '|') {
32
+ // `|&` pipes stderr too.
33
+ start = tokens[end + 1] === '&' ? end + 2 : end + 1;
34
+ // A pipeline that continues after the heredoc body names its next stage on a later line.
35
+ if (start >= tokens.length)
36
+ return true;
37
+ end = nextShellCommandSeparatorIndex(tokens, start);
38
+ if (segmentMayRunStdin(tokens, start, end))
39
+ return true;
40
+ }
41
+ return false;
42
+ }
43
+ // A shell reads stdin as its script unless a `-c` script comes before its first operand. The hook
44
+ // also fails closed on a compound command (`{ bash; }`, `(bash)`, `done`), a wrapper option it
45
+ // cannot read (`env -S`), and a command word an expansion chooses (`$SHELL`).
46
+ function segmentMayRunStdin(tokens, start, end) {
47
+ if (tokens[start - 1] === ')' || tokens[start - 1] === '}')
48
+ return true;
49
+ const words = withoutRedirections(tokens.slice(start, end));
50
+ if (words === null || words.length === 0 || COMPOUND_CLOSERS.has(words[0]))
51
+ return true;
52
+ const read = readCommandPrefix(words);
53
+ if (read === null)
54
+ return true;
55
+ const command = words[read.commandIndex];
56
+ if (command === undefined || EXPANSION.test(command))
57
+ return true;
58
+ if (EXEC_WRAPPERS.has(command.slice(command.lastIndexOf('/') + 1)))
59
+ return true;
60
+ return isShellWord(command) && shellScriptOperandIndex(words, read.commandIndex) === undefined;
61
+ }
@@ -0,0 +1,9 @@
1
+ export declare function commandSegmentStart(tokens: string[], index: number, isSeparator?: typeof isShellCommandSeparator): number;
2
+ export declare function isShellAssignment(token: string): boolean;
3
+ /** The variable a plain `NAME=value` assignment sets, or null for any other word. */
4
+ export declare function plainShellAssignment(token: string): {
5
+ name: string;
6
+ value: string;
7
+ } | null;
8
+ export declare function isShellCommandSeparator(token: string): boolean;
9
+ export declare function nextShellCommandSeparatorIndex(tokens: string[], startIndex: number): number;
@@ -0,0 +1,33 @@
1
+ // `NAME=value`, `NAME+=value`, and `NAME[SUB]=value`. Only the plain form gives the command a value
2
+ // the hook can read: `+=` appends to a value it cannot see, and an array element is never exported.
3
+ const SHELL_ASSIGNMENT_RE = /^([A-Za-z_][A-Za-z0-9_]*)(\[[^\]]*\])?(\+)?=/;
4
+ const SHELL_COMMAND_SEPARATORS = new Set(['&&', '&', '(', ')', ';', '|', '||', '\n', '{', '}']);
5
+ export function commandSegmentStart(tokens, index, isSeparator = isShellCommandSeparator) {
6
+ for (let cursor = index - 1; cursor >= 0; cursor -= 1) {
7
+ if (isSeparator(tokens[cursor])) {
8
+ return cursor + 1;
9
+ }
10
+ }
11
+ return 0;
12
+ }
13
+ export function isShellAssignment(token) {
14
+ return SHELL_ASSIGNMENT_RE.test(token);
15
+ }
16
+ /** The variable a plain `NAME=value` assignment sets, or null for any other word. */
17
+ export function plainShellAssignment(token) {
18
+ const match = SHELL_ASSIGNMENT_RE.exec(token);
19
+ if (match === null || match[2] !== undefined || match[3] !== undefined)
20
+ return null;
21
+ return { name: match[1], value: token.slice(match[0].length) };
22
+ }
23
+ export function isShellCommandSeparator(token) {
24
+ return SHELL_COMMAND_SEPARATORS.has(token);
25
+ }
26
+ export function nextShellCommandSeparatorIndex(tokens, startIndex) {
27
+ for (let index = startIndex; index < tokens.length; index += 1) {
28
+ if (isShellCommandSeparator(tokens[index])) {
29
+ return index;
30
+ }
31
+ }
32
+ return tokens.length;
33
+ }
@@ -0,0 +1 @@
1
+ export declare function stripUnquotedShellComments(command: string): string;
@@ -0,0 +1,57 @@
1
+ import { readAnsiCString } from "./ansi-c-string.mjs";
2
+ export function stripUnquotedShellComments(command) {
3
+ let result = '';
4
+ let quote = null;
5
+ let escaping = false;
6
+ let wordStarted = false;
7
+ for (let index = 0; index < command.length; index += 1) {
8
+ const char = command[index];
9
+ if (escaping) {
10
+ result += char;
11
+ escaping = false;
12
+ continue;
13
+ }
14
+ if (quote === null && char === '$' && command[index + 1] === "'") {
15
+ const ansiString = readAnsiCString(command, index + 2);
16
+ if (ansiString !== null) {
17
+ result += command.slice(index, ansiString.endIndex + 1);
18
+ wordStarted = true;
19
+ index = ansiString.endIndex;
20
+ continue;
21
+ }
22
+ }
23
+ if (char === '\\' && quote !== "'") {
24
+ result += char;
25
+ wordStarted = true;
26
+ escaping = true;
27
+ continue;
28
+ }
29
+ if (quote !== null) {
30
+ result += char;
31
+ if (char === quote) {
32
+ quote = null;
33
+ }
34
+ continue;
35
+ }
36
+ if (char === "'" || char === '"') {
37
+ result += char;
38
+ quote = char;
39
+ wordStarted = true;
40
+ continue;
41
+ }
42
+ if (char === '#' && !wordStarted) {
43
+ while (index + 1 < command.length && command[index + 1] !== '\n') {
44
+ index += 1;
45
+ }
46
+ continue;
47
+ }
48
+ result += char;
49
+ if (char === '\n' || /\s/.test(char) || /[&|;()]/.test(char)) {
50
+ wordStarted = false;
51
+ }
52
+ else {
53
+ wordStarted = true;
54
+ }
55
+ }
56
+ return result;
57
+ }
@@ -0,0 +1,14 @@
1
+ import type { ShellWord } from './shell-tokenizer.mts';
2
+ type SeparatorState = {
3
+ char: string;
4
+ command: string;
5
+ expandable: boolean;
6
+ index: number;
7
+ options: {
8
+ splitRedirections?: boolean;
9
+ };
10
+ token: string;
11
+ tokens: ShellWord[];
12
+ };
13
+ export declare function consumeShellSeparator(state: SeparatorState): number | undefined;
14
+ export {};
@@ -0,0 +1,47 @@
1
+ import { isRedirectionFd, shellRedirectionOperatorAt } from "./shell-redirections.mjs";
2
+ function pushStateToken(state) {
3
+ if (state.token === '')
4
+ return;
5
+ state.tokens.push({ expandable: state.expandable, value: state.token });
6
+ state.token = '';
7
+ state.expandable = false;
8
+ }
9
+ export function consumeShellSeparator(state) {
10
+ const redirectionOperator = state.options.splitRedirections === true
11
+ ? shellRedirectionOperatorAt(state.command, state.index)
12
+ : null;
13
+ if (redirectionOperator !== null) {
14
+ if (isRedirectionFd(state.token)) {
15
+ state.tokens.push({
16
+ expandable: state.expandable,
17
+ value: `${state.token}${redirectionOperator}`,
18
+ });
19
+ state.token = '';
20
+ state.expandable = false;
21
+ }
22
+ else if (state.token !== '') {
23
+ pushStateToken(state);
24
+ state.tokens.push({ expandable: false, value: redirectionOperator });
25
+ }
26
+ else {
27
+ state.tokens.push({ expandable: false, value: redirectionOperator });
28
+ }
29
+ return state.index + redirectionOperator.length - 1;
30
+ }
31
+ const { char } = state;
32
+ if (char === '&' || char === '|' || char === ';' || char === '(' || char === ')') {
33
+ pushStateToken(state);
34
+ const previousToken = state.tokens.at(-1)?.value;
35
+ if ((char === '&' && previousToken === '&') || (char === '|' && previousToken === '|')) {
36
+ state.tokens[state.tokens.length - 1] = {
37
+ expandable: false,
38
+ value: `${previousToken}${char}`,
39
+ };
40
+ }
41
+ else {
42
+ state.tokens.push({ expandable: false, value: char });
43
+ }
44
+ return state.index;
45
+ }
46
+ return undefined;
47
+ }
@@ -0,0 +1,12 @@
1
+ import { stripUnquotedShellComments } from './shell-tokenizer-comments.mts';
2
+ export type ShellWord = {
3
+ expandable: boolean;
4
+ value: string;
5
+ };
6
+ export declare function tokenizeShellWordsDetailed(command: string, options?: {
7
+ splitRedirections?: boolean;
8
+ }): ShellWord[];
9
+ export declare function tokenizeShellWords(command: string, options?: {
10
+ splitRedirections?: boolean;
11
+ }): string[];
12
+ export { stripUnquotedShellComments };
@@ -0,0 +1,104 @@
1
+ import { readAnsiCString } from "./ansi-c-string.mjs";
2
+ import { consumeShellSeparator } from "./shell-tokenizer-operators.mjs";
3
+ import { stripUnquotedShellComments } from "./shell-tokenizer-comments.mjs";
4
+ const DOUBLE_QUOTE_ESCAPE_CHARS = new Set(['$', '`', '"', '\\', '\n']);
5
+ export function tokenizeShellWordsDetailed(command, options = {}) {
6
+ const commandWithoutComments = stripUnquotedShellComments(command);
7
+ const tokens = [];
8
+ let token = '';
9
+ let expandable = false;
10
+ let quote = null;
11
+ let escaping = false;
12
+ function pushToken() {
13
+ if (token === '')
14
+ return;
15
+ tokens.push({ expandable, value: token });
16
+ token = '';
17
+ expandable = false;
18
+ }
19
+ for (let index = 0; index < commandWithoutComments.length; index += 1) {
20
+ const char = commandWithoutComments[index];
21
+ if (escaping) {
22
+ if (char === '\n') {
23
+ // Line continuation: bash removes `\<newline>` unquoted and in double quotes.
24
+ }
25
+ else if (quote === '"' && !DOUBLE_QUOTE_ESCAPE_CHARS.has(char)) {
26
+ token += `\\${char}`;
27
+ }
28
+ else {
29
+ token += char;
30
+ }
31
+ escaping = false;
32
+ continue;
33
+ }
34
+ if (quote === null && char === '$' && commandWithoutComments[index + 1] === "'") {
35
+ const ansiString = readAnsiCString(commandWithoutComments, index + 2);
36
+ if (ansiString !== null) {
37
+ token += ansiString.value;
38
+ index = ansiString.endIndex;
39
+ continue;
40
+ }
41
+ }
42
+ if (char === '\\') {
43
+ if (quote === "'") {
44
+ token += char;
45
+ continue;
46
+ }
47
+ escaping = true;
48
+ continue;
49
+ }
50
+ if (quote !== "'" && (char === '$' || char === '`'))
51
+ expandable = true;
52
+ if (quote !== null) {
53
+ if (char === quote) {
54
+ quote = null;
55
+ }
56
+ else {
57
+ token += char;
58
+ }
59
+ continue;
60
+ }
61
+ if (char === "'" || char === '"') {
62
+ quote = char;
63
+ continue;
64
+ }
65
+ if (char === '\n') {
66
+ pushToken();
67
+ tokens.push({ expandable: false, value: '\n' });
68
+ continue;
69
+ }
70
+ if (/\s/.test(char)) {
71
+ pushToken();
72
+ continue;
73
+ }
74
+ const separator = {
75
+ char,
76
+ command: commandWithoutComments,
77
+ expandable,
78
+ index,
79
+ options,
80
+ token,
81
+ tokens,
82
+ };
83
+ const consumedIndex = consumeShellSeparator(separator);
84
+ token = separator.token;
85
+ expandable = separator.expandable;
86
+ if (consumedIndex !== undefined) {
87
+ index = consumedIndex;
88
+ continue;
89
+ }
90
+ if (quote === null &&
91
+ (char === '*' ||
92
+ char === '?' ||
93
+ char === '[' ||
94
+ (char === '{' && /^\{[^}]*(?:,|\.\.)[^}]*\}/.test(commandWithoutComments.slice(index)))))
95
+ expandable = true;
96
+ token += char;
97
+ }
98
+ pushToken();
99
+ return tokens;
100
+ }
101
+ export function tokenizeShellWords(command, options = {}) {
102
+ return tokenizeShellWordsDetailed(command, options).map((token) => token.value);
103
+ }
104
+ export { stripUnquotedShellComments };
@@ -0,0 +1,8 @@
1
+ import { type TypeScriptModuleFacts } from 'no-mistakes';
2
+ import { type SourceModuleGraph } from '../source-module-graph/index.mts';
3
+ import type { StoryCoverageConfig } from './options.mts';
4
+ export type StorySourceAnalysis = {
5
+ graph: SourceModuleGraph;
6
+ modules: ReadonlyMap<string, TypeScriptModuleFacts>;
7
+ };
8
+ export declare function analyzeStorySources(files: readonly string[], config: StoryCoverageConfig): Promise<StorySourceAnalysis>;
@@ -0,0 +1,24 @@
1
+ import { relative, resolve } from 'node:path';
2
+ import { analyzeTypeScriptModules } from 'no-mistakes';
3
+ import { createSourceModuleGraph } from "../source-module-graph/index.mjs";
4
+ export async function analyzeStorySources(files, config) {
5
+ const facts = await analyzeTypeScriptModules({ root: config.root, files: [...files] });
6
+ const modules = new Map();
7
+ for (const item of facts.modules) {
8
+ const file = relative(config.root, resolve(config.root, item.fileName)).replaceAll('\\', '/');
9
+ if (!item.complete)
10
+ throw new Error(`Incomplete source module facts: ${file}`);
11
+ modules.set(file, item);
12
+ }
13
+ if (modules.size !== files.length || files.some((file) => !modules.has(file))) {
14
+ throw new Error('Incomplete story source inventory');
15
+ }
16
+ const graph = createSourceModuleGraph({
17
+ root: config.root,
18
+ extensions: config.sourceExtensions,
19
+ aliases: config.aliases,
20
+ files,
21
+ facts,
22
+ });
23
+ return { graph, modules };
24
+ }
@@ -0,0 +1,11 @@
1
+ import { type NamespaceComponentImport } from './coverage.mts';
2
+ import { type MissingComponent } from './messages.mts';
3
+ import { type StoryCoverageRequest } from './options.mts';
4
+ export type StoryCoverageReport = {
5
+ ok: boolean;
6
+ namespaceImports: NamespaceComponentImport[];
7
+ excludedKeys: string[];
8
+ missingComponents: MissingComponent[];
9
+ messages: string[];
10
+ };
11
+ export declare function checkStoryCoverage(request: StoryCoverageRequest, files?: readonly string[]): Promise<StoryCoverageReport>;
@@ -0,0 +1,42 @@
1
+ import { analyzeStorySources } from "./analyze.mjs";
2
+ import { componentExports } from "./components.mjs";
3
+ import { coveredComponentKeys, namespaceComponentImports, reachableStoryFiles, } from "./coverage.mjs";
4
+ import { formatExclusionsMessage, formatMissingComponentsMessage, formatNamespaceImportsMessage, } from "./messages.mjs";
5
+ import { storyCoverageConfig, } from "./options.mjs";
6
+ import { workspaceFiles } from "./workspace.mjs";
7
+ export async function checkStoryCoverage(request, files) {
8
+ const config = storyCoverageConfig(request);
9
+ const inventory = [...new Set(files ?? workspaceFiles(config))];
10
+ if (inventory.length === 0)
11
+ return coverageReport(config, [], new Set(), []);
12
+ const analysis = await analyzeStorySources(inventory, config);
13
+ const storyFiles = reachableStoryFiles(inventory, analysis.graph, config);
14
+ return coverageReport(config, namespaceComponentImports(storyFiles, analysis.graph, config), coveredComponentKeys(storyFiles, analysis.graph, config), componentExports(inventory, analysis.modules, config));
15
+ }
16
+ function coverageReport(config, namespaceImports, covered, components) {
17
+ const excludedKeys = Object.keys(config.exclusions).toSorted();
18
+ const excluded = new Set(excludedKeys);
19
+ const missingComponents = components
20
+ .flatMap((component) => covered.has(component.key) || excluded.has(component.key)
21
+ ? []
22
+ : [
23
+ {
24
+ component: component.displayName,
25
+ exportName: component.exportName,
26
+ file: component.file,
27
+ },
28
+ ])
29
+ .toSorted((left, right) => left.file.localeCompare(right.file) || left.exportName.localeCompare(right.exportName));
30
+ const messages = [
31
+ formatNamespaceImportsMessage(namespaceImports, config),
32
+ formatExclusionsMessage(excludedKeys),
33
+ formatMissingComponentsMessage(missingComponents, config),
34
+ ].filter((message) => message !== '');
35
+ return {
36
+ ok: messages.length === 0,
37
+ namespaceImports,
38
+ excludedKeys,
39
+ missingComponents,
40
+ messages,
41
+ };
42
+ }
@@ -0,0 +1,10 @@
1
+ import type { TypeScriptModuleFacts } from 'no-mistakes';
2
+ import { type StoryCoverageConfig } from './options.mts';
3
+ export type ComponentExport = {
4
+ key: string;
5
+ file: string;
6
+ exportName: string;
7
+ displayName: string;
8
+ };
9
+ export declare function exportKey(file: string, exportName: string): string;
10
+ export declare function componentExports(files: readonly string[], modules: ReadonlyMap<string, TypeScriptModuleFacts>, config: StoryCoverageConfig): ComponentExport[];
@@ -0,0 +1,40 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { patternMatches } from "./options.mjs";
4
+ export function exportKey(file, exportName) {
5
+ return `${file}#${exportName}`;
6
+ }
7
+ export function componentExports(files, modules, config) {
8
+ const found = [];
9
+ for (const file of files) {
10
+ if (!isComponentFile(file, config))
11
+ continue;
12
+ if (!patternMatches(config.marker, readFileSync(join(config.root, file), 'utf8')))
13
+ continue;
14
+ const facts = modules.get(file);
15
+ if (!facts?.complete)
16
+ throw new Error(`Incomplete component module facts: ${file}`);
17
+ for (const item of facts.exports) {
18
+ if (item.specifier || item.typeOnly)
19
+ continue;
20
+ if (item.exported !== 'default' && !/^[A-Z][A-Za-z0-9]*$/.test(item.exported))
21
+ continue;
22
+ found.push({
23
+ key: exportKey(file, item.exported),
24
+ file,
25
+ exportName: item.exported,
26
+ displayName: item.exported === 'default' ? item.local || 'default' : item.exported,
27
+ });
28
+ }
29
+ }
30
+ return found;
31
+ }
32
+ function isComponentFile(file, config) {
33
+ if (!file.startsWith(config.componentRoot))
34
+ return false;
35
+ if (!config.componentExtensions.some((extension) => file.endsWith(extension)))
36
+ return false;
37
+ if (file.includes('/__tests__/') || file.includes('.test.'))
38
+ return false;
39
+ return true;
40
+ }
@@ -0,0 +1,10 @@
1
+ import type { SourceModuleGraph } from '../source-module-graph/index.mts';
2
+ import { type StoryCoverageConfig } from './options.mts';
3
+ export type NamespaceComponentImport = {
4
+ file: string;
5
+ source: string;
6
+ local: string;
7
+ };
8
+ export declare function reachableStoryFiles(files: readonly string[], graph: SourceModuleGraph, config: StoryCoverageConfig): string[];
9
+ export declare function coveredComponentKeys(storyFiles: readonly string[], graph: SourceModuleGraph, config: StoryCoverageConfig): Set<string>;
10
+ export declare function namespaceComponentImports(storyFiles: readonly string[], graph: SourceModuleGraph, config: StoryCoverageConfig): NamespaceComponentImport[];
@@ -0,0 +1,43 @@
1
+ import { patternMatches } from "./options.mjs";
2
+ import { exportKey } from "./components.mjs";
3
+ export function reachableStoryFiles(files, graph, config) {
4
+ const stories = files.filter((file) => file.startsWith(config.storyRoot) && patternMatches(config.storyFilePattern, file));
5
+ return graph
6
+ .reachableFrom(stories, { runtimeOnly: true })
7
+ .filter((file) => file.startsWith(config.storyRoot));
8
+ }
9
+ export function coveredComponentKeys(storyFiles, graph, config) {
10
+ const covered = new Set();
11
+ for (const file of storyFiles) {
12
+ for (const entry of graph.runtimeImports(file)) {
13
+ const resolved = graph.resolveSource(file, entry.specifier);
14
+ if (!resolved?.startsWith(config.componentRoot))
15
+ continue;
16
+ for (const binding of entry.bindings) {
17
+ if (binding.kind === 'namespace')
18
+ continue;
19
+ covered.add(exportKey(resolved, binding.imported));
20
+ const owner = graph.resolveExportOwner(resolved, binding.imported);
21
+ if (owner)
22
+ covered.add(exportKey(owner.file, owner.exportName));
23
+ }
24
+ }
25
+ }
26
+ return covered;
27
+ }
28
+ export function namespaceComponentImports(storyFiles, graph, config) {
29
+ const imports = [];
30
+ for (const file of storyFiles) {
31
+ for (const entry of graph.runtimeImports(file)) {
32
+ const resolved = graph.resolveSource(file, entry.specifier);
33
+ if (!resolved?.startsWith(config.componentRoot))
34
+ continue;
35
+ for (const binding of entry.bindings) {
36
+ if (binding.kind !== 'namespace')
37
+ continue;
38
+ imports.push({ file, source: entry.specifier, local: binding.local });
39
+ }
40
+ }
41
+ }
42
+ return imports;
43
+ }