@vibe-agent-toolkit/utils 0.2.0-rc.1 → 0.2.0-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/README.md +69 -23
  2. package/dist/asset-reference.js +3 -11
  3. package/dist/asset-reference.js.map +1 -1
  4. package/dist/compare-code-units.d.ts +28 -0
  5. package/dist/compare-code-units.d.ts.map +1 -0
  6. package/dist/compare-code-units.js +33 -0
  7. package/dist/compare-code-units.js.map +1 -0
  8. package/dist/crawl-timing.d.ts +657 -0
  9. package/dist/crawl-timing.d.ts.map +1 -0
  10. package/dist/crawl-timing.js +765 -0
  11. package/dist/crawl-timing.js.map +1 -0
  12. package/dist/crawl.d.ts +2 -4
  13. package/dist/crawl.d.ts.map +1 -1
  14. package/dist/crawl.js +2 -4
  15. package/dist/crawl.js.map +1 -1
  16. package/dist/dirent-kind.d.ts +83 -0
  17. package/dist/dirent-kind.d.ts.map +1 -0
  18. package/dist/dirent-kind.js +129 -0
  19. package/dist/dirent-kind.js.map +1 -0
  20. package/dist/entrypoint.d.ts +54 -0
  21. package/dist/entrypoint.d.ts.map +1 -0
  22. package/dist/entrypoint.js +71 -0
  23. package/dist/entrypoint.js.map +1 -0
  24. package/dist/env-flag.d.ts +51 -0
  25. package/dist/env-flag.d.ts.map +1 -0
  26. package/dist/env-flag.js +62 -0
  27. package/dist/env-flag.js.map +1 -0
  28. package/dist/errors/errno.d.ts +51 -0
  29. package/dist/errors/errno.d.ts.map +1 -0
  30. package/dist/errors/errno.js +112 -0
  31. package/dist/errors/errno.js.map +1 -0
  32. package/dist/errors/vat-error.d.ts +60 -0
  33. package/dist/errors/vat-error.d.ts.map +1 -0
  34. package/dist/errors/vat-error.js +86 -0
  35. package/dist/errors/vat-error.js.map +1 -0
  36. package/dist/file-crawler.d.ts +60 -0
  37. package/dist/file-crawler.d.ts.map +1 -1
  38. package/dist/file-crawler.js +133 -29
  39. package/dist/file-crawler.js.map +1 -1
  40. package/dist/fs/file-hash.d.ts.map +1 -1
  41. package/dist/fs/file-hash.js +0 -1
  42. package/dist/fs/file-hash.js.map +1 -1
  43. package/dist/fs-utils.d.ts +422 -191
  44. package/dist/fs-utils.d.ts.map +1 -1
  45. package/dist/fs-utils.js +534 -204
  46. package/dist/fs-utils.js.map +1 -1
  47. package/dist/fs.d.ts +5 -2
  48. package/dist/fs.d.ts.map +1 -1
  49. package/dist/fs.js +9 -7
  50. package/dist/fs.js.map +1 -1
  51. package/dist/git-run.d.ts +167 -0
  52. package/dist/git-run.d.ts.map +1 -0
  53. package/dist/git-run.js +154 -0
  54. package/dist/git-run.js.map +1 -0
  55. package/dist/git-snapshot.d.ts +199 -0
  56. package/dist/git-snapshot.d.ts.map +1 -0
  57. package/dist/git-snapshot.js +250 -0
  58. package/dist/git-snapshot.js.map +1 -0
  59. package/dist/git-tracker.d.ts +166 -3
  60. package/dist/git-tracker.d.ts.map +1 -1
  61. package/dist/git-tracker.js +250 -22
  62. package/dist/git-tracker.js.map +1 -1
  63. package/dist/git-utils.d.ts +84 -1
  64. package/dist/git-utils.d.ts.map +1 -1
  65. package/dist/git-utils.js +208 -82
  66. package/dist/git-utils.js.map +1 -1
  67. package/dist/git.d.ts +13 -4
  68. package/dist/git.d.ts.map +1 -1
  69. package/dist/git.js +12 -4
  70. package/dist/git.js.map +1 -1
  71. package/dist/gitignore-checker.d.ts.map +1 -1
  72. package/dist/gitignore-checker.js +15 -6
  73. package/dist/gitignore-checker.js.map +1 -1
  74. package/dist/glob/glob-pattern.js +5 -5
  75. package/dist/glob/glob-pattern.js.map +1 -1
  76. package/dist/index.d.ts +32 -20
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +95 -50
  79. package/dist/index.js.map +1 -1
  80. package/dist/listing-refusal.d.ts +112 -0
  81. package/dist/listing-refusal.d.ts.map +1 -0
  82. package/dist/listing-refusal.js +105 -0
  83. package/dist/listing-refusal.js.map +1 -0
  84. package/dist/path-containment.d.ts +64 -0
  85. package/dist/path-containment.d.ts.map +1 -0
  86. package/dist/path-containment.js +111 -0
  87. package/dist/path-containment.js.map +1 -0
  88. package/dist/path-core.d.ts +113 -18
  89. package/dist/path-core.d.ts.map +1 -1
  90. package/dist/path-core.js +139 -23
  91. package/dist/path-core.js.map +1 -1
  92. package/dist/path-utils.d.ts.map +1 -1
  93. package/dist/path-utils.js +42 -47
  94. package/dist/path-utils.js.map +1 -1
  95. package/dist/path.d.ts +1 -1
  96. package/dist/path.d.ts.map +1 -1
  97. package/dist/path.js +1 -1
  98. package/dist/path.js.map +1 -1
  99. package/dist/process.d.ts +7 -0
  100. package/dist/process.d.ts.map +1 -1
  101. package/dist/process.js +7 -0
  102. package/dist/process.js.map +1 -1
  103. package/dist/project-utils.d.ts.map +1 -1
  104. package/dist/project-utils.js +15 -9
  105. package/dist/project-utils.js.map +1 -1
  106. package/dist/project.d.ts +7 -5
  107. package/dist/project.d.ts.map +1 -1
  108. package/dist/project.js +7 -5
  109. package/dist/project.js.map +1 -1
  110. package/dist/safe-exec.d.ts +40 -11
  111. package/dist/safe-exec.d.ts.map +1 -1
  112. package/dist/safe-exec.js +111 -25
  113. package/dist/safe-exec.js.map +1 -1
  114. package/dist/skill-targets.d.ts +2 -2
  115. package/dist/skill-targets.js +2 -2
  116. package/dist/skill-test/auth-resolver.d.ts +10 -2
  117. package/dist/skill-test/auth-resolver.d.ts.map +1 -1
  118. package/dist/skill-test/auth-resolver.js +26 -11
  119. package/dist/skill-test/auth-resolver.js.map +1 -1
  120. package/dist/skill-test/index.d.ts +1 -1
  121. package/dist/skill-test/index.d.ts.map +1 -1
  122. package/dist/skill-test/index.js +1 -1
  123. package/dist/skill-test/index.js.map +1 -1
  124. package/dist/skill-test/spawn-claude.d.ts +30 -1
  125. package/dist/skill-test/spawn-claude.d.ts.map +1 -1
  126. package/dist/skill-test/spawn-claude.js +71 -5
  127. package/dist/skill-test/spawn-claude.js.map +1 -1
  128. package/dist/skill-test/transcript.d.ts +41 -2
  129. package/dist/skill-test/transcript.d.ts.map +1 -1
  130. package/dist/skill-test/transcript.js +55 -10
  131. package/dist/skill-test/transcript.js.map +1 -1
  132. package/dist/spawn-hardened.js +0 -1
  133. package/dist/spawn-hardened.js.map +1 -1
  134. package/dist/stdio-blocking.js +13 -14
  135. package/dist/stdio-blocking.js.map +1 -1
  136. package/dist/test-helpers.d.ts +135 -100
  137. package/dist/test-helpers.d.ts.map +1 -1
  138. package/dist/test-helpers.js +224 -146
  139. package/dist/test-helpers.js.map +1 -1
  140. package/dist/testing/executables.d.ts +32 -0
  141. package/dist/testing/executables.d.ts.map +1 -0
  142. package/dist/testing/executables.js +70 -0
  143. package/dist/testing/executables.js.map +1 -0
  144. package/dist/testing/hostile-tree.d.ts +79 -0
  145. package/dist/testing/hostile-tree.d.ts.map +1 -0
  146. package/dist/testing/hostile-tree.js +164 -0
  147. package/dist/testing/hostile-tree.js.map +1 -0
  148. package/dist/testing/platform-gates.d.ts +31 -0
  149. package/dist/testing/platform-gates.d.ts.map +1 -0
  150. package/dist/testing/platform-gates.js +31 -0
  151. package/dist/testing/platform-gates.js.map +1 -0
  152. package/dist/testing/temp-dir.d.ts +255 -0
  153. package/dist/testing/temp-dir.d.ts.map +1 -0
  154. package/dist/testing/temp-dir.js +363 -0
  155. package/dist/testing/temp-dir.js.map +1 -0
  156. package/dist/testing.d.ts +94 -3
  157. package/dist/testing.d.ts.map +1 -1
  158. package/dist/testing.js +119 -3
  159. package/dist/testing.js.map +1 -1
  160. package/dist/text-content.d.ts +197 -0
  161. package/dist/text-content.d.ts.map +1 -0
  162. package/dist/text-content.js +354 -0
  163. package/dist/text-content.js.map +1 -0
  164. package/dist/text-file.d.ts +45 -0
  165. package/dist/text-file.d.ts.map +1 -0
  166. package/dist/text-file.js +51 -0
  167. package/dist/text-file.js.map +1 -0
  168. package/dist/text.d.ts +16 -0
  169. package/dist/text.d.ts.map +1 -0
  170. package/dist/text.js +16 -0
  171. package/dist/text.js.map +1 -0
  172. package/dist/timing-dump.d.ts +136 -0
  173. package/dist/timing-dump.d.ts.map +1 -0
  174. package/dist/timing-dump.js +229 -0
  175. package/dist/timing-dump.js.map +1 -0
  176. package/dist/windows-shell.d.ts +0 -1
  177. package/dist/windows-shell.d.ts.map +1 -1
  178. package/dist/windows-shell.js +0 -1
  179. package/dist/windows-shell.js.map +1 -1
  180. package/dist/zod-introspection.js +2 -2
  181. package/dist/zod-introspection.js.map +1 -1
  182. package/eslint/README.md +223 -49
  183. package/eslint/index.cjs +111 -97
  184. package/eslint/index.d.cts +16 -6
  185. package/eslint/rules/callee-name.cjs +23 -0
  186. package/eslint/rules/commands-import-boundary.cjs +148 -0
  187. package/eslint/rules/dead-import.cjs +1 -1
  188. package/eslint/rules/dirent-type-needs-symlink-check.cjs +282 -0
  189. package/eslint/rules/eslint-rule-factory.cjs +5 -2
  190. package/eslint/rules/exempt-path-matcher.cjs +2 -1
  191. package/eslint/rules/explicit-zod-strictness.cjs +120 -0
  192. package/eslint/rules/no-bare-dynamic-import-path.cjs +5 -1
  193. package/eslint/rules/no-bare-executable-spawn.cjs +70 -0
  194. package/eslint/rules/no-bare-symlink-in-tests.cjs +213 -0
  195. package/eslint/rules/no-blind-catch.cjs +171 -0
  196. package/eslint/rules/no-child-process-execSync.cjs +8 -0
  197. package/eslint/rules/no-decaying-referent.cjs +217 -0
  198. package/eslint/rules/no-dotdot-containment.cjs +160 -0
  199. package/eslint/rules/no-file-url-string-concat.cjs +4 -1
  200. package/eslint/rules/no-fragile-entrypoint-guard.cjs +228 -0
  201. package/eslint/rules/no-fs-mkdirSync.cjs +8 -0
  202. package/eslint/rules/no-fs-promises-cp.cjs +7 -0
  203. package/eslint/rules/no-fs-realpathSync.cjs +8 -0
  204. package/eslint/rules/no-hardcoded-path-split.cjs +29 -18
  205. package/eslint/rules/no-io-in-unit-tier.cjs +129 -0
  206. package/eslint/rules/no-literal-process-exit.cjs +129 -0
  207. package/eslint/rules/no-manual-path-normalize.cjs +136 -107
  208. package/eslint/rules/no-os-tmpdir.cjs +8 -0
  209. package/eslint/rules/no-path-operations-in-comparisons.cjs +7 -2
  210. package/eslint/rules/no-path-sep-in-strings.cjs +7 -2
  211. package/eslint/rules/no-path-startswith.cjs +7 -2
  212. package/eslint/rules/no-process-exit-in-phase.cjs +127 -0
  213. package/eslint/rules/no-raw-node-path.cjs +563 -0
  214. package/eslint/rules/no-raw-text-decode.cjs +305 -0
  215. package/eslint/rules/no-registry-count-pin.cjs +255 -0
  216. package/eslint/rules/no-self-package-import.cjs +168 -0
  217. package/eslint/rules/no-test-scoped-functions.cjs +10 -3
  218. package/eslint/rules/no-unix-shell-commands.cjs +6 -2
  219. package/eslint/rules/no-unsafe-root-join.cjs +23 -2
  220. package/eslint/rules/no-url-pathname-for-fs.cjs +5 -1
  221. package/eslint/rules/no-version-literal.cjs +151 -0
  222. package/eslint/rules/prefer-startswith-over-regex.cjs +9 -0
  223. package/eslint/rules/require-justified-skip.cjs +8 -2
  224. package/eslint/rules/safe-import.cjs +1 -1
  225. package/package.json +16 -16
  226. package/dist/link-auth/build-headers.d.ts +0 -34
  227. package/dist/link-auth/build-headers.d.ts.map +0 -1
  228. package/dist/link-auth/build-headers.js +0 -58
  229. package/dist/link-auth/build-headers.js.map +0 -1
  230. package/dist/link-auth/expand-macro.d.ts +0 -38
  231. package/dist/link-auth/expand-macro.d.ts.map +0 -1
  232. package/dist/link-auth/expand-macro.js +0 -133
  233. package/dist/link-auth/expand-macro.js.map +0 -1
  234. package/dist/link-auth/macros.yaml +0 -50
  235. package/dist/link-auth/resolve-token.d.ts +0 -83
  236. package/dist/link-auth/resolve-token.d.ts.map +0 -1
  237. package/dist/link-auth/resolve-token.js +0 -101
  238. package/dist/link-auth/resolve-token.js.map +0 -1
  239. package/dist/link-auth/resolve.d.ts +0 -102
  240. package/dist/link-auth/resolve.d.ts.map +0 -1
  241. package/dist/link-auth/resolve.js +0 -66
  242. package/dist/link-auth/resolve.js.map +0 -1
  243. package/dist/link-auth/rewrite.d.ts +0 -52
  244. package/dist/link-auth/rewrite.d.ts.map +0 -1
  245. package/dist/link-auth/rewrite.js +0 -102
  246. package/dist/link-auth/rewrite.js.map +0 -1
  247. package/dist/link-auth/select-provider.d.ts +0 -30
  248. package/dist/link-auth/select-provider.d.ts.map +0 -1
  249. package/dist/link-auth/select-provider.js +0 -55
  250. package/dist/link-auth/select-provider.js.map +0 -1
  251. package/dist/link-auth/template.d.ts +0 -40
  252. package/dist/link-auth/template.d.ts.map +0 -1
  253. package/dist/link-auth/template.js +0 -89
  254. package/dist/link-auth/template.js.map +0 -1
  255. package/dist/link-auth/transforms.d.ts +0 -46
  256. package/dist/link-auth/transforms.d.ts.map +0 -1
  257. package/dist/link-auth/transforms.js +0 -52
  258. package/dist/link-auth/transforms.js.map +0 -1
  259. package/dist/template-entry.d.ts +0 -10
  260. package/dist/template-entry.d.ts.map +0 -1
  261. package/dist/template-entry.js +0 -10
  262. package/dist/template-entry.js.map +0 -1
  263. package/dist/template.d.ts +0 -7
  264. package/dist/template.d.ts.map +0 -1
  265. package/dist/template.js +0 -18
  266. package/dist/template.js.map +0 -1
  267. package/eslint/rules/no-path-join.cjs +0 -14
  268. package/eslint/rules/no-path-relative.cjs +0 -14
  269. package/eslint/rules/no-path-resolve.cjs +0 -14
  270. package/eslint/rules/path-function-rule-factory.cjs +0 -496
@@ -1,118 +1,153 @@
1
+ declare const symlinkCapabilityBrand: unique symbol;
1
2
  /**
2
- * Get isolated test output directory for current test run
3
- *
4
- * Creates a unique directory under `packages/{packageName}/.test-output/{testType}/{runId}`
5
- * where runId is `{timestamp}-{randomId}` to ensure isolation across parallel test runs.
6
- *
7
- * @param packageName - Name of package (e.g., 'rag-lancedb')
8
- * @param testType - Type of test ('unit', 'integration', 'system')
9
- * @param subdirs - Optional subdirectories to create within the test output directory
10
- * @returns Absolute path to the created directory
11
- *
12
- * @example
13
- * ```typescript
14
- * // Create isolated database directory for system tests
15
- * const dbPath = getTestOutputDir('rag-lancedb', 'system', 'databases', 'test-db');
16
- * // Result: packages/rag-lancedb/.test-output/system/20260105-143022-abc123/databases/test-db
17
- *
18
- * // Create temporary file directory for integration tests
19
- * const tempDir = getTestOutputDir('agent-skills', 'integration', 'temp-files');
20
- * // Result: packages/agent-skills/.test-output/integration/20260105-143022-def456/temp-files
21
- * ```
3
+ * Proof that this process can create filesystem symlinks.
4
+ *
5
+ * The only way to obtain one is {@link symlinkCapability}, and it exists at
6
+ * all only when a real probe already succeeded — so a function that requires
7
+ * this as a parameter cannot be reached by code that skipped the check. That
8
+ * is the point of branding it rather than passing a `boolean`: forgetting the
9
+ * check becomes a type error instead of a runtime `EPERM` on a machine you
10
+ * don't control.
22
11
  */
23
- export declare function getTestOutputDir(packageName: string, testType: 'unit' | 'integration' | 'system', ...subdirs: string[]): string;
12
+ export type SymlinkCapability = {
13
+ readonly [symlinkCapabilityBrand]: true;
14
+ };
24
15
  /**
25
- * Get the base test output directory for a package
26
- * Useful for cleanup operations that need to remove all test output
16
+ * Whether this PROCESS can create symlinks — probed once and memoized.
27
17
  *
28
- * @param packageName - Name of package (e.g., 'rag-lancedb')
29
- * @returns Absolute path to packages/{packageName}/.test-output
30
- *
31
- * @example
32
- * ```typescript
33
- * const baseDir = getTestOutputBase('rag-lancedb');
34
- * // Result: packages/rag-lancedb/.test-output
35
- * ```
18
+ * On Windows, `symlink()` needs either Developer Mode or
19
+ * `SeCreateSymbolicLinkPrivilege`. That privilege lives on the process's
20
+ * security token, not on any one directory: it cannot change between calls
21
+ * within a single run, so probing it once and reusing the result is a
22
+ * memoization, not a shortcut that risks a stale answer. (A filesystem that
23
+ * itself has no symlinks — some network shares, some FAT variants — answers
24
+ * `ENOTSUP` and is read as the same "no"; every fixture in this repo creates
25
+ * its roots under {@link normalizedTmpdir}, so it never arises here.)
26
+ *
27
+ * Because the answer is memoized for the whole process, what reads as "no"
28
+ * matters more than usual: a `null` here silently `skip()`s every symlink test
29
+ * for the rest of the run. So ONLY {@link SYMLINK_UNSUPPORTED_ERRNOS} is a
30
+ * no. A tmpdir that is unwritable or missing, or a bug, is not an answer about
31
+ * symlinks at all and stays loud rather than becoming a process-wide skip for
32
+ * a reason nothing reported.
33
+ *
34
+ * Fixtures that depend on symlinks must ask rather than assume — and, having
35
+ * asked, must SAY they skipped. A symlink case that silently no-ops reads as
36
+ * a passing test for a property nobody exercised.
37
+ *
38
+ * @returns A {@link SymlinkCapability} token when this process can create
39
+ * symlinks, else `null`. Route the `null` case through vitest's `skip()`
40
+ * rather than a plain `return`, so the skip is visible in the report.
36
41
  */
37
- export declare function getTestOutputBase(packageName: string): string;
42
+ export declare function symlinkCapability(): SymlinkCapability | null;
38
43
  /**
39
- * Per-suite temp directory pattern (async version)
40
- * Creates a single temp directory for the entire test suite,
41
- * with subdirectories for each test. This is 3-5x faster on Windows
42
- * than creating a new mkdtemp for each test.
43
- *
44
- * @param prefix - Prefix for the suite temp directory name
45
- * @returns Suite helper with beforeAll, afterAll, beforeEach, afterEach, and getTempDir
46
- *
47
- * @example
48
- * ```typescript
49
- * const suite = setupAsyncTempDirSuite('my-test');
50
- *
51
- * describe('my tests', () => {
52
- * beforeAll(suite.beforeAll);
53
- * afterAll(suite.afterAll);
54
- * beforeEach(suite.beforeEach);
44
+ * Create a symlink — the one sanctioned call site for `fs.symlinkSync` in
45
+ * test code. Requires a {@link SymlinkCapability}, which only
46
+ * {@link symlinkCapability} can mint, so a test cannot reach the real
47
+ * syscall without first proving (or explicitly bypassing via `skip()`) that
48
+ * this host supports it.
49
+ *
50
+ * @param _cap - Proof from {@link symlinkCapability} that this host can create symlinks
51
+ * @param target - The existing path the new link should point at
52
+ * @param path - Where to create the link
53
+ * @param type - Windows-only link-type hint (`'file'` \| `'dir'` \| `'junction'`); ignored on POSIX
54
+ */
55
+ export declare function createSymlink(_cap: SymlinkCapability, target: string, path: string, type?: 'dir' | 'file' | 'junction'): void;
56
+ /**
57
+ * The async counterpart of {@link createSymlink}, for fixtures already using
58
+ * `node:fs/promises`. Same capability requirement, same reasoning.
55
59
  *
56
- * it('test 1', async () => {
57
- * const tempDir = suite.getTempDir();
58
- * // Use tempDir...
59
- * });
60
- * });
61
- * ```
60
+ * @param _cap - Proof from {@link symlinkCapability} that this host can create symlinks
61
+ * @param target - The existing path the new link should point at
62
+ * @param path - Where to create the link
63
+ * @param type - Windows-only link-type hint (`'file'` \| `'dir'` \| `'junction'`); ignored on POSIX
62
64
  */
63
- export declare function setupAsyncTempDirSuite(prefix: string): {
64
- beforeAll: () => Promise<void>;
65
- afterAll: () => Promise<void>;
66
- beforeEach: () => Promise<void>;
67
- afterEach: () => Promise<void>;
68
- getTempDir: () => string;
69
- };
65
+ export declare function createSymlinkAsync(_cap: SymlinkCapability, target: string, path: string, type?: 'dir' | 'file' | 'junction'): Promise<void>;
70
66
  /**
71
- * Per-suite temp directory pattern (sync version)
72
- * Creates a single temp directory for the entire test suite,
73
- * with subdirectories for each test. This is 3-5x faster on Windows
74
- * than creating a new mkdtemp for each test.
67
+ * The variables git exports into a hook, which a fixture must clear before it
68
+ * can fabricate its own.
75
69
  *
76
- * @param prefix - Prefix for the suite temp directory name
77
- * @returns Suite helper with beforeAll, afterAll, beforeEach, afterEach, and getTempDir
70
+ * These are the ones git sets *for* you. Deliberately **not** the operator's own
71
+ * `GIT_CONFIG_COUNT`/`KEY_n`/`VALUE_n`/`GLOBAL`/`SYSTEM` channel — a test may be
72
+ * using that on purpose to point a clone at a local path, and clearing it sends
73
+ * the clone to the network instead.
74
+ */
75
+ export declare const INHERITED_GIT_ENV: readonly ["GIT_ALTERNATE_OBJECT_DIRECTORIES", "GIT_CEILING_DIRECTORIES", "GIT_COMMON_DIR", "GIT_CONFIG_PARAMETERS", "GIT_DIR", "GIT_DISCOVERY_ACROSS_FILESYSTEM", "GIT_GRAFT_FILE", "GIT_INDEX_FILE", "GIT_INDEX_VERSION", "GIT_NAMESPACE", "GIT_NOTES_REF", "GIT_OBJECT_DIRECTORY", "GIT_PREFIX", "GIT_SHALLOW_FILE", "GIT_WORK_TREE"];
76
+ /**
77
+ * Remove every inherited git redirection from `process.env`, and hand back the
78
+ * undo.
79
+ *
80
+ * A test that fabricates a hook environment has to start from a known-clean one,
81
+ * or it inherits whatever the *outer* runner exported and can no longer tell its
82
+ * own fixture apart from the ambient state — it then passes or fails for reasons
83
+ * it never set up. Restoring afterwards matters just as much: these are
84
+ * process-global, so a test that leaks `GIT_DIR` silently redirects every later
85
+ * test sharing the worker.
86
+ *
87
+ * ⚠️ **The key list is restated here on purpose, not by oversight.** Deriving it
88
+ * from `@vibe-validate/git`'s `stripGitEnv()` would be tidier, and it is exactly
89
+ * what this function did for one revision — but this module is the `./testing`
90
+ * subpath, which `subpath-purity.test.ts` pins as reaching **no third-party
91
+ * package at all** so it stays importable with zero dependencies installed. One
92
+ * import cost that property. The drift risk the derivation was avoiding is
93
+ * handled instead by {@link "../test/test-helpers-git-env.test".default}, which
94
+ * asserts this list equals what the shipped scrub removes.
95
+ *
96
+ * @returns A function restoring every variable to its prior value, putting back
97
+ * "was not set" as unset rather than as an empty string
78
98
  *
79
99
  * @example
80
100
  * ```typescript
81
- * const suite = setupSyncTempDirSuite('my-test');
82
- *
83
- * describe('my tests', () => {
84
- * beforeAll(suite.beforeAll);
85
- * afterAll(suite.afterAll);
86
- * beforeEach(suite.beforeEach);
87
- *
88
- * it('test 1', () => {
89
- * const tempDir = suite.getTempDir();
90
- * // Use tempDir...
91
- * });
92
- * });
101
+ * let restoreGitEnv: () => void;
102
+ * beforeEach(() => { restoreGitEnv = detachGitEnv(); });
103
+ * afterEach(() => { restoreGitEnv(); });
93
104
  * ```
94
105
  */
95
- export declare function setupSyncTempDirSuite(prefix: string): {
96
- beforeAll: () => void;
97
- afterAll: () => void;
98
- beforeEach: () => void;
99
- afterEach: () => void;
100
- getTempDir: () => string;
101
- };
106
+ export declare function detachGitEnv(): () => void;
102
107
  /**
103
- * Probe whether this host can create symbolic links inside `dir`.
104
- *
105
- * On Windows, `symlink()` needs either Developer Mode or
106
- * `SeCreateSymbolicLinkPrivilege`; CI agents frequently have neither. Fixtures
107
- * that depend on symlinks must therefore ask rather than assume — and, having
108
- * asked, must SAY they skipped. A symlink case that silently no-ops reads as a
109
- * passing test for a property nobody exercised.
110
- *
111
- * The probe creates and removes one link, because the privilege cannot be
112
- * inferred from `process.platform` alone.
113
- *
114
- * @param dir - An existing directory to probe in (the probe cleans up after itself)
115
- * @returns True when a symlink was created successfully
108
+ * The errno-shaped error a refused `fs` call throws: a message, the `code`,
109
+ * and the `syscall`, exactly as Node shapes one.
110
+ */
111
+ export declare function errnoError(code: string, syscall: string, target: string): NodeJS.ErrnoException;
112
+ /** The sync `node:fs` calls a refusal can be injected into. */
113
+ export type RefusableSyncFsMethod = 'readdirSync' | 'readFileSync' | 'statSync' | 'lstatSync' | 'realpathSync' | 'renameSync' | 'rmSync' | 'unlinkSync';
114
+ /** The `node:fs/promises` calls a refusal can be injected into. */
115
+ export type RefusableAsyncFsMethod = 'readdir' | 'readFile' | 'stat' | 'lstat' | 'access';
116
+ /**
117
+ * Make `fs[method]` throw `code` for exactly `targetPath` until the returned
118
+ * restore is called; every other path, and every other method, stays real.
119
+ *
120
+ * A patch rather than a `chmod`: `chmod` reaches one errno (`EACCES`), only
121
+ * where POSIX modes bind, and not as root — and the property under test is
122
+ * "any refusal that is not an absence", so `EACCES`, `ELOOP`, `EMFILE` must all
123
+ * be reachable. What a walk under test meets is ONE refused call inside an
124
+ * otherwise ordinary tree; a walk that gave up entirely would pass a test where
125
+ * everything was refused.
126
+ *
127
+ * Lives in the shipped helpers because consumers in five packages each need to
128
+ * refuse a call, and the duplication gate refuses five copies.
129
+ */
130
+ export declare function refuseSyncFs(method: RefusableSyncFsMethod, targetPath: string, code: string): () => void;
131
+ /**
132
+ * `fs/promises[method]` rejects with `code` for exactly `targetPath` until the
133
+ * returned restore is called; every other path, and every other method, is real.
134
+ */
135
+ export declare function refuseAsyncFs(method: RefusableAsyncFsMethod, targetPath: string, code: string): () => void;
136
+ /**
137
+ * Run `body` while `fs[method]` throws `code` for exactly `targetPath`; the
138
+ * patch is lifted however `body` exits. See {@link refuseSyncFs}.
139
+ */
140
+ export declare function withSyncFsRefused<T>(method: RefusableSyncFsMethod, targetPath: string, code: string, body: () => T | Promise<T>): Promise<T>;
141
+ /**
142
+ * Run `body` with `fs.readdirSync` of exactly `directory` throwing an error
143
+ * carrying errno `code`. The listing case of {@link withSyncFsRefused}, named
144
+ * because refusing a LISTING is the question the crawler's consumers ask.
145
+ *
146
+ * @param directory - Absolute path of the one directory to refuse
147
+ * @param code - The errno to reject with
148
+ * @param body - Runs while the refusal is in force; may be async
149
+ * @returns Whatever `body` returned
116
150
  */
117
- export declare function canCreateSymlinks(dir: string): boolean;
151
+ export declare function withReaddirSyncRefused<T>(directory: string, code: string, body: () => T | Promise<T>): Promise<T>;
152
+ export {};
118
153
  //# sourceMappingURL=test-helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"test-helpers.d.ts","sourceRoot":"","sources":["../src/test-helpers.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GAAG,aAAa,GAAG,QAAQ,EAC3C,GAAG,OAAO,EAAE,MAAM,EAAE,GACnB,MAAM,CAuBR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAG7D;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG;IACtD,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IA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