@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
package/dist/git-utils.js CHANGED
@@ -2,12 +2,120 @@
2
2
  * Centralized git command wrapper.
3
3
  * All git commands should go through this module for consistency and testability.
4
4
  */
5
- import { spawnSync } from 'node:child_process';
6
5
  import { existsSync } from 'node:fs';
7
6
  import { dirname, parse } from 'node:path';
8
- import which from 'which';
7
+ import { directoryRefusalFor, listingFailure } from './fs-utils.js';
9
8
  import { lookupGitRoot, rememberGitRoot } from './git-root-cache.js';
9
+ import { runGit } from './git-run.js';
10
+ import { requireUnreadablePolicy, settleRefusal } from './listing-refusal.js';
10
11
  import { safePath } from './path-utils.js';
12
+ /**
13
+ * One line of git's stderr that means "I skipped this directory".
14
+ *
15
+ * `git ls-files --others` (and `--ignored`, and `git add --all`) walks the
16
+ * working tree to find untracked files. On a directory it cannot open it prints
17
+ * this warning, exits 0, and omits the subtree — so stdout alone is a shorter
18
+ * list that nothing can tell from a complete one. The path is spelled
19
+ * **relative to the worktree root** with a trailing slash, even when git was
20
+ * run from a subdirectory (measured: cwd `docs/open`, warning names
21
+ * `'docs/open/sub/'`).
22
+ *
23
+ * Anchored to the line so an unrelated warning naming a directory in passing
24
+ * is not read as a refusal. The reason after the colon is `strerror` text —
25
+ * see {@link STRERROR_TO_ERRNO}.
26
+ */
27
+ const UNLISTABLE_DIRECTORY_LINE = /^warning: could not open directory '(.+?)\/?': (.*)$/gm;
28
+ /**
29
+ * C-locale `strerror` text → errno, for the reasons git can print here.
30
+ *
31
+ * git does not print the errno name, only its message; every listing below
32
+ * runs with `LC_ALL=C` so the message is the C-locale one and this table can
33
+ * be short. An unlisted reason is still a refusal — it becomes `UNKNOWN`, the
34
+ * same answer `listingFailure` gives an error carrying no errno — because
35
+ * dropping the line would reinstate the silent gap for exactly the errnos
36
+ * nobody thought of.
37
+ *
38
+ * The two ABSENCE reasons are listed so that `listingFailure` — the one owner
39
+ * of the absent/unreadable split — can recognise them and the line can be
40
+ * skipped: git prints "No such file or directory" for an untracked directory
41
+ * deleted between its parent's `readdir` and its own `opendir` (a concurrent
42
+ * `rm -rf tmp/`), and the walk route treats that same race as "no longer in
43
+ * the population" rather than as a refusal. Left unmapped it read as an
44
+ * `UNKNOWN` refusal, and the git route aborted a run the walk completed.
45
+ */
46
+ const STRERROR_TO_ERRNO = new Map([
47
+ ['Permission denied', 'EACCES'],
48
+ ['Too many open files', 'EMFILE'],
49
+ ['Too many open files in system', 'ENFILE'],
50
+ ['Too many levels of symbolic links', 'ELOOP'],
51
+ ['Resource temporarily unavailable', 'EAGAIN'],
52
+ ['Input/output error', 'EIO'],
53
+ ['Stale file handle', 'ESTALE'],
54
+ ['Stale NFS file handle', 'ESTALE'],
55
+ ['No such file or directory', 'ENOENT'],
56
+ ['Not a directory', 'ENOTDIR'],
57
+ ]);
58
+ /**
59
+ * The directories a git listing was REFUSED, read off its stderr.
60
+ *
61
+ * Pure. Returns each refused directory once, worktree-relative and without
62
+ * git's trailing slash, with the errno its reason maps to. A directory git
63
+ * could not open because it no longer exists is not returned: that is the
64
+ * `absent` outcome of {@link listingFailure}, decided there and not here, so
65
+ * the two routes classify a vanished directory the same way.
66
+ *
67
+ * @param stderr - What the listing wrote to stderr
68
+ * @returns The refusals, in the order git printed them, deduplicated
69
+ */
70
+ export function unlistableDirectoriesIn(stderr) {
71
+ const seen = new Set();
72
+ const refusals = [];
73
+ for (const match of stderr.matchAll(UNLISTABLE_DIRECTORY_LINE)) {
74
+ const directory = match[1] ?? '';
75
+ if (directory === '' || seen.has(directory))
76
+ continue;
77
+ seen.add(directory);
78
+ const listing = listingFailure({ code: STRERROR_TO_ERRNO.get((match[2] ?? '').trim()) });
79
+ if (listing.outcome === 'unreadable')
80
+ refusals.push({ directory, code: listing.code });
81
+ }
82
+ return refusals;
83
+ }
84
+ /**
85
+ * Run one NUL-delimited `ls-files` listing and report what git skipped.
86
+ *
87
+ * `LC_ALL=C` so the stderr reason is the C-locale `strerror` text the parser
88
+ * knows; `trim: false` because the output is NUL-delimited (see the callers).
89
+ *
90
+ * @param args - The `ls-files` argv
91
+ * @param cwd - Where to run it
92
+ * @param api - The entry point, for the sentence an omitted policy gets
93
+ * @param unreadable - What a skipped directory means to the caller
94
+ * @returns The listed paths, or null when git did not answer
95
+ */
96
+ function runListing(args, cwd, api, unreadable) {
97
+ // Before the spawn: an omitted policy is a programming error, not a fact
98
+ // about the tree, and a tree with nothing unreadable must not hide it.
99
+ requireUnreadablePolicy(unreadable, api);
100
+ const result = runGit(args, { cwd, trim: false, env: { LC_ALL: 'C' } });
101
+ // Every failure means the same thing to this caller — no listing. That covers
102
+ // "not a repository" (128), git missing entirely, and a listing too large for
103
+ // the buffer, which `ok` folds in because a truncated answer here is files
104
+ // silently missing rather than a short list.
105
+ if (!result.ok) {
106
+ return null;
107
+ }
108
+ if (result.stderr !== '') {
109
+ // The warning is worktree-root-relative regardless of `cwd`.
110
+ const worktreeRoot = gitFindRoot(cwd) ?? cwd;
111
+ for (const { directory, code } of unlistableDirectoriesIn(result.stderr)) {
112
+ settleRefusal(unreadable, directoryRefusalFor({ outcome: 'unreadable', code }, safePath.resolve(worktreeRoot, directory)));
113
+ }
114
+ }
115
+ // NUL-separated (from -z), so no path can ever need quote-unescaping — a
116
+ // trailing NUL just produces one empty string at the end, dropped here.
117
+ return result.stdout.split('\0').filter((line) => line.length > 0);
118
+ }
11
119
  /**
12
120
  * Find the git repository root by walking up from the given directory.
13
121
  *
@@ -35,7 +143,6 @@ export function gitFindRoot(startDir) {
35
143
  return rememberGitRoot(climbed, memoized);
36
144
  climbed.push(currentDir);
37
145
  const gitDir = safePath.join(currentDir, '.git');
38
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- walking up from validated startDir
39
146
  if (existsSync(gitDir)) {
40
147
  return rememberGitRoot(climbed, currentDir);
41
148
  }
@@ -50,6 +157,8 @@ export function gitFindRoot(startDir) {
50
157
  * @param options.cwd - Working directory (git repository root or subdirectory)
51
158
  * @param options.patterns - Optional glob patterns to filter files (e.g., '*.md', 'docs/**\/*.ts')
52
159
  * @param options.includeUntracked - Include untracked files that aren't gitignored (default: false)
160
+ * @param options.unreadable - See {@link GitListingOptions}. Only the untracked
161
+ * listing walks the working tree, so only it can have skipped a directory
53
162
  * @returns Array of file paths relative to the git root, or null if not in a git repo
54
163
  *
55
164
  * @example
@@ -62,44 +171,79 @@ export function gitFindRoot(startDir) {
62
171
  * ```
63
172
  */
64
173
  export function gitLsFiles(options) {
65
- try {
66
- // Resolve git path using which for security (avoids PATH manipulation)
67
- const gitPath = which.sync('git');
68
- // -z emits NUL-separated, UNQUOTED paths regardless of byte content. Without
69
- // it, git quotes any path containing non-ASCII bytes (wraps it in double
70
- // quotes with octal escapes, e.g. `café.md` -> `"caf\303\251.md"`), which is
71
- // unusable to any exact-string lookup against the real filename.
72
- const args = ['ls-files', '-z'];
73
- // Include untracked files that aren't gitignored
74
- if (options.includeUntracked) {
75
- args.push('--cached', '--others', '--exclude-standard');
76
- }
77
- // Add patterns if provided
78
- if (options.patterns && options.patterns.length > 0) {
79
- args.push('--', ...options.patterns);
80
- }
81
- const result = spawnSync(gitPath, args, {
82
- cwd: options.cwd,
83
- encoding: 'utf-8',
84
- stdio: 'pipe',
85
- shell: false, // No shell interpreter for security
86
- });
87
- // Exit code 128 typically means not a git repository
88
- if (result.status === 128 || result.error) {
89
- return null;
90
- }
91
- if (result.status !== 0) {
92
- return null;
93
- }
94
- // Parse output into array of file paths. NUL-separated (from -z above), so
95
- // no path can ever need trimming or quote-unescaping — a trailing NUL just
96
- // produces one empty string at the end, which the filter below drops.
97
- return result.stdout.split('\0').filter((line) => line.length > 0);
174
+ // -z emits NUL-separated, UNQUOTED paths regardless of byte content. Without
175
+ // it, git quotes any path containing non-ASCII bytes (wraps it in double
176
+ // quotes with octal escapes, e.g. `café.md` -> `"caf\303\251.md"`), which is
177
+ // unusable to any exact-string lookup against the real filename.
178
+ const args = ['ls-files', '-z'];
179
+ // Include untracked files that aren't gitignored
180
+ if (options.includeUntracked) {
181
+ args.push('--cached', '--others', '--exclude-standard');
98
182
  }
99
- catch {
100
- // Git not available or other error
101
- return null;
183
+ // Add patterns if provided
184
+ if (options.patterns && options.patterns.length > 0) {
185
+ args.push('--', ...options.patterns);
102
186
  }
187
+ // `trim: false` (inside `runListing`) because the output is NUL-delimited:
188
+ // git sorts by byte value, so a path beginning with a space sorts FIRST and a
189
+ // trim would silently rename it to a path that does not exist.
190
+ return runListing(args, options.cwd, 'gitLsFiles', options.unreadable);
191
+ }
192
+ /**
193
+ * List paths git does NOT track, with each wholly-untracked directory collapsed
194
+ * to a single entry.
195
+ *
196
+ * This is the **prune list**, not a file list, and the distinction is the whole
197
+ * value. `--others --ignored --exclude-standard` alone returns every ignored file
198
+ * individually: measured on an 8,496-path adopter working tree that is 533,557
199
+ * paths in 1.19 s — worse than the crawl it was meant to replace, because
200
+ * `.turbo/cache` alone contributed 418,518 of them. Adding `--directory`
201
+ * collapses each wholly-ignored directory to one entry: **369 entries in 60 ms**.
202
+ * A caller can then decide per directory whether to descend, and skip a
203
+ * half-million paths by name without ever entering them.
204
+ *
205
+ * A collapsed directory entry is returned with a trailing `/`, exactly as git
206
+ * spells it. That is how a caller tells "this whole subtree" from "this one
207
+ * file", so it is deliberately not normalized away here.
208
+ *
209
+ * @param options - Configuration options
210
+ * @param options.cwd - Working directory inside the repository
211
+ * @param options.ignored - Restrict to ignored paths. Off, the listing is
212
+ * untracked-but-not-ignored paths — which is the only way to see an EMPTY
213
+ * untracked directory, since a directory with no files in it is invisible to
214
+ * `ls-files` and to any tree object
215
+ * @param options.directory - Collapse a wholly-untracked directory to one entry
216
+ * @param options.unreadable - See {@link GitListingOptions}. ⚠️ The two
217
+ * listings meet different refusals: without `--ignored`, git collapses a
218
+ * WHOLLY-untracked directory without opening it, but it still opens a
219
+ * non-ignored directory that holds tracked files (to look for untracked
220
+ * siblings) and warns when it cannot; the `ignored` listing opens every
221
+ * non-ignored directory and so meets every refusal the first one does and
222
+ * more (measured on git 2.50)
223
+ * @returns Paths relative to the git root, or null if git did not answer
224
+ *
225
+ * @example
226
+ * ```typescript
227
+ * // The prune list: where the ignored territory is, without enumerating it.
228
+ * const prune = gitLsOthers({ cwd: root, ignored: true, directory: true });
229
+ * // → ['dist/', 'node_modules/', '.turbo/', 'notes.local.md']
230
+ * ```
231
+ */
232
+ export function gitLsOthers(options) {
233
+ // `--exclude-standard` is unconditional: `--ignored` is rejected outright by
234
+ // git without an exclude source, and without it the not-ignored listing would
235
+ // report every ignored path as merely untracked — the exact inversion of what
236
+ // either caller asked for.
237
+ const args = ['ls-files', '-z', '--others', '--exclude-standard'];
238
+ if (options.ignored) {
239
+ args.push('--ignored');
240
+ }
241
+ if (options.directory) {
242
+ args.push('--directory');
243
+ }
244
+ // See `gitLsFiles`: NUL-delimited output must not be trimmed, or a path
245
+ // beginning with a space — which git sorts FIRST — comes back renamed.
246
+ return runListing(args, options.cwd, 'gitLsOthers', options.unreadable);
103
247
  }
104
248
  /**
105
249
  * Check if a file path is ignored by git
@@ -137,51 +281,33 @@ export function isGitIgnored(filePath, cwd = process.cwd()) {
137
281
  if (gitFindRoot(cwd) === null) {
138
282
  return false;
139
283
  }
140
- try {
141
- // Resolve git path using which for security (avoids PATH manipulation)
142
- const gitPath = which.sync('git');
143
- const checkIgnoreArgs = ['check-ignore', '-q'];
144
- // git check-ignore returns exit code 0 if file is ignored, 1 if not
145
- const result = spawnSync(gitPath, [...checkIgnoreArgs, filePath], {
146
- cwd,
147
- encoding: 'utf-8',
148
- stdio: 'pipe',
149
- shell: false, // No shell interpreter for security
150
- });
151
- if (result.status === 0) {
152
- return true;
153
- }
154
- // Exit code 128 = fatal error (e.g., path beyond a symbolic link).
155
- // Walk up ancestor directories to check if a parent is gitignored.
156
- // Example: data/ is gitignored, data/symlink/deep/file.md fails with 128,
157
- // but checking data/ directly returns 0.
158
- if (result.status !== 1) {
159
- const resolvedCwd = safePath.resolve(cwd);
160
- const resolvedFile = safePath.resolve(cwd, filePath);
161
- let current = dirname(resolvedFile);
162
- while (current !== resolvedCwd && !current.endsWith(parse(current).root)) {
163
- const ancestorResult = spawnSync(gitPath, [...checkIgnoreArgs, current], {
164
- cwd,
165
- encoding: 'utf-8',
166
- stdio: 'pipe',
167
- shell: false,
168
- });
169
- if (ancestorResult.status === 0) {
170
- return true;
171
- }
172
- // If this ancestor check also fails fatally, keep walking up
173
- // If it returns 1 (not ignored), the parent is tracked — stop walking
174
- if (ancestorResult.status === 1) {
175
- break;
176
- }
177
- current = dirname(current);
284
+ const checkIgnoreArgs = ['check-ignore', '-q'];
285
+ // git check-ignore returns exit code 0 if file is ignored, 1 if not
286
+ const result = runGit([...checkIgnoreArgs, filePath], { cwd });
287
+ if (result.status === 0) {
288
+ return true;
289
+ }
290
+ // Exit code 128 = fatal error (e.g., path beyond a symbolic link).
291
+ // Walk up ancestor directories to check if a parent is gitignored.
292
+ // Example: data/ is gitignored, data/symlink/deep/file.md fails with 128,
293
+ // but checking data/ directly returns 0.
294
+ if (result.status !== 1) {
295
+ const resolvedCwd = safePath.resolve(cwd);
296
+ const resolvedFile = safePath.resolve(cwd, filePath);
297
+ let current = dirname(resolvedFile);
298
+ while (current !== resolvedCwd && !current.endsWith(parse(current).root)) {
299
+ const ancestorResult = runGit([...checkIgnoreArgs, current], { cwd });
300
+ if (ancestorResult.status === 0) {
301
+ return true;
302
+ }
303
+ // If this ancestor check also fails fatally, keep walking up
304
+ // If it returns 1 (not ignored), the parent is tracked — stop walking
305
+ if (ancestorResult.status === 1) {
306
+ break;
178
307
  }
308
+ current = dirname(current);
179
309
  }
180
- return false;
181
- }
182
- catch {
183
- // If git is not available or other error, assume not ignored
184
- return false;
185
310
  }
311
+ return false;
186
312
  }
187
313
  //# sourceMappingURL=git-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"git-utils.js","sourceRoot":"","sources":["../src/git-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,WAAW,CAAC,QAAgB;IAC1C,IAAI,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC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C,IAAI,CAAC,EAAE,CAAC;YACzE,MAAM,cAAc,GAAG,MAAM,CAAC,CAAC,GAAG,eAAe,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;YACtE,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAChC,OAAO,IAAI,CAAC;YACd,CAAC;YACD,6DAA6D;YAC7D,sEAAsE;YACtE,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAChC,MAAM;YACR,CAAC;YACD,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
package/dist/git.d.ts CHANGED
@@ -1,9 +1,15 @@
1
1
  /**
2
2
  * @vibe-agent-toolkit/utils/git
3
3
  *
4
- * Git primitives for build guards and gates: root discovery, tracked-file
5
- * enumeration, gitignore evaluation, and git URL parsing. Node-only —
6
- * shells out to `git` and reads the filesystem.
4
+ * Git primitives for build guards and gates: command execution, root discovery,
5
+ * tracked-file enumeration, tree snapshots, gitignore evaluation, and git URL
6
+ * parsing. Node-only — shells out to `git` and reads the filesystem.
7
+ *
8
+ * This is the ONLY published route to `runGit`. `safeExecSync`/`safeExecResult`
9
+ * on `./process` refuse the `git` binary outright and point here, so a caller
10
+ * that wants git gets the scrubbed environment rather than the ambient one by
11
+ * construction. The scrub itself, and dirty-corrected tree snapshots, come from
12
+ * `@vibe-validate/git`.
7
13
  *
8
14
  * The re-exports below are explicit rather than `export *` on purpose. A
9
15
  * blanket re-export surfaced TWO root finders under two names — `gitFindRoot`
@@ -16,7 +22,10 @@
16
22
  * old code rather than maintain two APIs). `gitFindRoot` is the only root
17
23
  * finder in the package.
18
24
  */
19
- export { gitFindRoot, gitLsFiles, isGitIgnored } from './git-utils.js';
25
+ export { runGit, runGitOrThrow, type GitRunOptions, type GitRunResult, } from './git-run.js';
26
+ export { gitFindRoot, gitLsFiles, gitLsOthers, isGitIgnored } from './git-utils.js';
27
+ export type { RefuseListingContext, UnreadablePolicy } from './listing-refusal.js';
28
+ export { freshGitTreeSnapshot, gitTreeSnapshot, peekGitTreeSnapshot, withGitSnapshotCache, type GitSnapshotEntry, type GitTreeSnapshot, } from './git-snapshot.js';
20
29
  export { loadGitignoreRules } from './gitignore-checker.js';
21
30
  export { GitTracker, type GitTrackerInitOptions } from './git-tracker.js';
22
31
  export { isGitUrl, nonInteractiveGitOverrides, parseGitUrl, type NonInteractiveGitOverrides, type ParsedGitUrl, } from './git-url.js';
package/dist/git.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,KAAK,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EACL,QAAQ,EACR,0BAA0B,EAC1B,WAAW,EACX,KAAK,0BAA0B,EAC/B,KAAK,YAAY,GAClB,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,MAAM,EACN,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAIpF,YAAY,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,KAAK,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EACL,QAAQ,EACR,0BAA0B,EAC1B,WAAW,EACX,KAAK,0BAA0B,EAC/B,KAAK,YAAY,GAClB,MAAM,cAAc,CAAC"}
package/dist/git.js CHANGED
@@ -1,9 +1,15 @@
1
1
  /**
2
2
  * @vibe-agent-toolkit/utils/git
3
3
  *
4
- * Git primitives for build guards and gates: root discovery, tracked-file
5
- * enumeration, gitignore evaluation, and git URL parsing. Node-only —
6
- * shells out to `git` and reads the filesystem.
4
+ * Git primitives for build guards and gates: command execution, root discovery,
5
+ * tracked-file enumeration, tree snapshots, gitignore evaluation, and git URL
6
+ * parsing. Node-only — shells out to `git` and reads the filesystem.
7
+ *
8
+ * This is the ONLY published route to `runGit`. `safeExecSync`/`safeExecResult`
9
+ * on `./process` refuse the `git` binary outright and point here, so a caller
10
+ * that wants git gets the scrubbed environment rather than the ambient one by
11
+ * construction. The scrub itself, and dirty-corrected tree snapshots, come from
12
+ * `@vibe-validate/git`.
7
13
  *
8
14
  * The re-exports below are explicit rather than `export *` on purpose. A
9
15
  * blanket re-export surfaced TWO root finders under two names — `gitFindRoot`
@@ -16,7 +22,9 @@
16
22
  * old code rather than maintain two APIs). `gitFindRoot` is the only root
17
23
  * finder in the package.
18
24
  */
19
- export { gitFindRoot, gitLsFiles, isGitIgnored } from './git-utils.js';
25
+ export { runGit, runGitOrThrow, } from './git-run.js';
26
+ export { gitFindRoot, gitLsFiles, gitLsOthers, isGitIgnored } from './git-utils.js';
27
+ export { freshGitTreeSnapshot, gitTreeSnapshot, peekGitTreeSnapshot, withGitSnapshotCache, } from './git-snapshot.js';
20
28
  export { loadGitignoreRules } from './gitignore-checker.js';
21
29
  export { GitTracker } from './git-tracker.js';
22
30
  export { isGitUrl, nonInteractiveGitOverrides, parseGitUrl, } from './git-url.js';
package/dist/git.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAA8B,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EACL,QAAQ,EACR,0BAA0B,EAC1B,WAAW,GAGZ,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,MAAM,EACN,aAAa,GAGd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAKpF,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,oBAAoB,GAGrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAA8B,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EACL,QAAQ,EACR,0BAA0B,EAC1B,WAAW,GAGZ,MAAM,cAAc,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"gitignore-checker.d.ts","sourceRoot":"","sources":["../src/gitignore-checker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAe,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAI7C;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAwCnF"}
1
+ {"version":3,"file":"gitignore-checker.d.ts","sourceRoot":"","sources":["../src/gitignore-checker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAe,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAM7C;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA8CnF"}
@@ -8,7 +8,9 @@
8
8
  import fs from 'node:fs';
9
9
  import path from 'node:path';
10
10
  import ignore from 'ignore';
11
+ import { isPathAbsentError } from './errors/errno.js';
11
12
  import { safePath, toForwardSlash } from './path-utils.js';
13
+ import { readTextContentSync } from './text-file.js';
12
14
  /**
13
15
  * Load and parse .gitignore files from git root to baseDir.
14
16
  * Returns an ignore instance configured with all applicable .gitignore rules.
@@ -39,15 +41,22 @@ export function loadGitignoreRules(gitRoot, baseDir) {
39
41
  // Load .gitignore files from git root down to baseDir
40
42
  for (const dir of dirsToCheck) {
41
43
  const gitignorePath = safePath.join(dir, '.gitignore');
42
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- constructed from validated gitRoot and baseDir
43
44
  if (fs.existsSync(gitignorePath)) {
44
45
  try {
45
- // eslint-disable-next-line security/detect-non-literal-fs-filename -- validated above
46
- const content = fs.readFileSync(gitignorePath, 'utf-8');
47
- ig.add(content);
46
+ // Through the decoding seam. A `.gitignore` written by PowerShell's `>`
47
+ // is UTF-16LE, and `readFileSync(p, 'utf-8')` would hand `ignore` a
48
+ // string of NUL-interleaved garbage — every pattern silently wrong, with
49
+ // no error anywhere.
50
+ ig.add(readTextContentSync(gitignorePath).text);
48
51
  }
49
- catch {
50
- // Skip gitignore files we can't read
52
+ catch (error) {
53
+ // Gone between `existsSync` and the read: no rules here. A `.gitignore`
54
+ // the OS refuses to read (`EACCES`), or one that is a directory
55
+ // (`EISDIR`), holds rules this checker cannot honour — and a crawl that
56
+ // quietly proceeded without them enumerated the ignored tree with
57
+ // nothing anywhere saying so. Those stay loud.
58
+ if (!isPathAbsentError(error))
59
+ throw error;
51
60
  }
52
61
  }
53
62
  }
@@ -1 +1 @@
1
- {"version":3,"file":"gitignore-checker.js","sourceRoot":"","sources":["../src/gitignore-checker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,MAAuB,MAAM,QAAQ,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAG,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe,EAAE,OAAgB;IAClE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IACpB,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,+BAA+B;IAC/B,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACf,QAAQ,GAAG,IAAI,CAAC;IAEhB,kDAAkD;IAClD,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,IAAI,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,CAAC;IACtD,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAElD,+CAA+C;IAC/C,MAAM,iBAAiB,GAAG,cAAc,CAAC,eAAe,CAAC,CAAC;IAE1D,OAAO,cAAc,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAChE,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAChC,IAAI,UAAU,KAAK,eAAe,EAAE,CAAC;YACnC,MAAM;QACR,CAAC;QACD,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED,sDAAsD;IACtD,KAAK,MAAM,GAAG,IAAI,WAA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AAO,CAAC,CAAC;IACtD,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAElD,+CAA+C;IAC/C,MAAM,iBAAiB,GAAG,cAAc,CAAC,eAAe,CAAC,CAAC;IAE1D,OAAO,cAAc,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAChE,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAChC,IAAI,UAAU,KAAK,eAAe,EAAE,CAAC;YACnC,MAAM;QACR,CAAC;QACD,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED,sDAAsD;IACtD,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,MAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QACvD,IAAI,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC;gBACH,wEAAwE;gBACxE,oEAAoE;gBACpE,yEAAyE;gBACzE,qBAAqB;gBACrB,EAAE,CAAC,GAAG,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC;YAClD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,wEAAwE;gBACxE,gEAAgE;gBAChE,wEAAwE;gBACxE,kEAAkE;gBAClE,+CAA+C;gBAC/C,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC;oBAAE,MAAM,KAAK,CAAC;YAC7C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9B,CAAC"}
@@ -11,7 +11,7 @@
11
11
  * sets an `escaped` flag when it sees `\`; the *next* character is skipped for
12
12
  * magic detection if `escaped` is true.
13
13
  */
14
- import { toForwardSlash } from '../path-core.js';
14
+ import { toForwardSlashAnyPlatform } from '../path-core.js';
15
15
  /** The glob metacharacters recognised by this module. */
16
16
  const MAGIC_CHARS = new Set(['*', '?', '[']);
17
17
  /** Sentinel returned by {@link staticGlobBase} when the first segment is magic. */
@@ -69,9 +69,9 @@ export function isGlob(source) {
69
69
  * staticGlobBase('foo/bar.txt') // 'foo/bar.txt'
70
70
  */
71
71
  export function staticGlobBase(pattern) {
72
- // Glob patterns are always forward-slash; toForwardSlash() satisfies the
73
- // no-hardcoded-path-split lint rule while being a no-op in practice.
74
- const normalized = toForwardSlash(pattern);
72
+ // A glob is author-written text: a Windows-spelled separator reads as `/` on
73
+ // every host, whatever platform VAT runs on.
74
+ const normalized = toForwardSlashAnyPlatform(pattern);
75
75
  const segments = normalized.split('/');
76
76
  const staticSegments = [];
77
77
  for (const segment of segments) {
@@ -112,7 +112,7 @@ export function staticGlobBase(pattern) {
112
112
  * globMagicRemainder('../mycli/dist/*.mjs') // '*.mjs'
113
113
  */
114
114
  export function globMagicRemainder(pattern) {
115
- const forward = toForwardSlash(pattern);
115
+ const forward = toForwardSlashAnyPlatform(pattern);
116
116
  const base = staticGlobBase(pattern);
117
117
  if (base === DOT) {
118
118
  // First segment was magic — the remainder is the full (forward-slash) pattern.
@@ -1 +1 @@
1
- {"version":3,"file":"glob-pattern.js","sourceRoot":"","sources":["../../src/glob/glob-pattern.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,yDAAyD;AACzD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAE7C,mFAAmF;AACnF,MAAM,GAAG,GAAG,GAAG,CAAC;AAEhB;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,MAAM,CAAC,MAAc;IACnC,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,KAAK,MAAM,EAAE,IAAI,MAAM,EAAE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U,kBAAkB,CAAC,OAAe;IAChD,MAAM,OAAO,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IACnD,MAAM,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACrC,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;QACjB,+EAA+E;QAC/E,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACrB,yDAAyD;QACzD,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;QACjB,yEAAyE;QACzE,yEAAyE;QACzE,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IACD,wDAAwD;IACxD,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACxC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -3,33 +3,45 @@
3
3
  * Core shared utilities with no dependencies on other packages
4
4
  *
5
5
  * Utilities are added as needed by other packages, not speculatively.
6
+ *
7
+ * **A module that brings a third-party dependency belongs on a subpath, not
8
+ * here.** This entry has ~245 in-repo importers plus published adopters, and
9
+ * every one of them pays for the whole graph reachable from it — a bundler that
10
+ * cannot tree-shake a dependency (a CJS package, or one reached through
11
+ * `new URL(..., import.meta.url)`) inlines it into every consumer that touched
12
+ * a path helper. The domains that carry weight each have their own entry:
13
+ * `./crawl`, `./git`, `./process`, `./skill-test`, `./template`, `./yaml`.
14
+ * `./skill-test` is there for a *transitive* reason rather than a direct one —
15
+ * it declares no dependency itself, but spawning a headless agent goes through
16
+ * `./process`, which reaches `which` and (because `safeExecSync` refuses `git`
17
+ * and delegates) `@vibe-validate/git`. Reachability is the criterion, not the
18
+ * import a module happens to write.
19
+ *
20
+ * The rule is enforced, not merely stated: `test/subpath-purity.test.ts` asserts
21
+ * this entry's reachable third-party set by equality, so a dependency arriving
22
+ * here — directly or transitively, through any module below — turns that row red
23
+ * and has to be an argued edit rather than an unnoticed one.
6
24
  */
7
- export * from './safe-exec.js';
8
- export * from './windows-shell.js';
9
- export * from './spawn-hardened.js';
25
+ export * from './errors/vat-error.js';
10
26
  export * from './path-utils.js';
11
- export * from './stdio-blocking.js';
27
+ export * from './path-containment.js';
28
+ export * from './dirent-kind.js';
29
+ export * from './text-content.js';
30
+ export * from './text-file.js';
12
31
  export * from './asset-reference.js';
13
- export { classifyFilenameCaseFrom, copyDirectory, fillRealpaths, fillSiblingNames, FsLookupCache, realpathFrom, } from './fs-utils.js';
14
- export type { FilenameCaseVerdict, FilenameMatch, PathProbe, PathProbeStats, RealpathTable, SiblingNamesTable, } from './fs-utils.js';
15
- export * from './file-crawler.js';
16
- export * from './gitignore-checker.js';
17
- export * from './git-url.js';
18
- export * from './git-utils.js';
32
+ export { isFilesystemAccessError, isPathAbsentError } from './errors/errno.js';
33
+ export { copyDirectory, CopyLinkEscapesSourceError, FsLookupCache, transientRefusalClause, } from './fs-utils.js';
34
+ export { DirectorySpellingIndex, fillPathSpellings, fillRealpaths, pathSpellingFrom, realpathFrom, spellingWalkRoot, } from './fs-utils.js';
35
+ export type { AbsenceCause, ComponentMatch, FilenameMatch, PathProbe, PathProbeStats, PathSpelling, PathSpellingRequest, PathSpellingTable, RealpathTable, VerifiedPrefix, } from './fs-utils.js';
19
36
  export * from './project-utils.js';
20
- export * from './git-tracker.js';
21
- export * from './test-helpers.js';
37
+ export { createSymlink, createSymlinkAsync, detachGitEnv, errnoError, INHERITED_GIT_ENV, symlinkCapability, type SymlinkCapability, } from './test-helpers.js';
22
38
  export * from './zod-introspection.js';
23
- export * from './template.js';
24
39
  export * from './skill-targets.js';
25
- export { type LinkAuthConfig, type Provider, type ProviderAuth, type ProviderCheck, resolveAuthenticatedUrl, type ResolveOutcome, } from './link-auth/resolve.js';
26
- export type { ProviderMatch } from './link-auth/select-provider.js';
27
- export type { RewriteRule } from './link-auth/rewrite.js';
28
- export { defaultRunCommand, type TokenSource } from './link-auth/resolve-token.js';
29
- export { expandMacro, UnknownMacroError } from './link-auth/expand-macro.js';
30
- export * from './skill-test/index.js';
31
40
  export * from './glob/glob-pattern.js';
32
41
  export * from './fs/file-hash.js';
33
- export * from './yaml/surgical-yaml.js';
34
42
  export { parseWholeNumberAtLeast } from './numeric-args.js';
43
+ export { parseEnvBoolean } from './env-flag.js';
44
+ export { compareCodeUnits } from './compare-code-units.js';
45
+ export { CRAWL_BLOB_POPULATE_ID, CRAWL_CLOSURE_CONTRIBUTE_ID, CRAWL_CLOSURE_RESOLVE_ID, CRAWL_PASS_INSIDE, CRAWL_REGISTRY_ADMIT_ID, CRAWL_REGISTRY_ENUMERATE_ID, CRAWL_REGISTRY_ID_PREFIX, CRAWL_REGISTRY_RESOLVE_LINKS_ID, CRAWL_SHARED_GIT_TRACKER_ID, CRAWL_STORE_READ_ID, CRAWL_STORE_WRITE_ID, CRAWL_STRATA, CRAWL_WALKER_GITIGNORE_ID, CRAWL_WALKER_ID, crawlTimingStart, recordContributorInvocation, recordCrawlPass, recordRegistryPass, recordSharedPass, withContributorStratum, withOuterBracket, type CrawlDriverStratum, type CrawlStratum, type CrawlTimingDump, type CrawlTimingEntry, type CrawlTimingProcess, } from './crawl-timing.js';
46
+ export { ensureTimingDirectory, normalizeTimingDirectory, readTimingProcess, type TimingProcess, writeTimingDump, } from './timing-dump.js';
35
47
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,gBAAgB,CAAC;AAG/B,cAAc,oBAAoB,CAAC;AAGnC,cAAc,qBAAqB,CAAC;AAGpC,cAAc,iBAAiB,CAAC;AAGhC,cAAc,qBAAqB,CAAC;AAGpC,cAAc,sBAAsB,CAAC;AAqCrC,OAAO,EACL,wBAAwB,EACxB,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,YAAY,GACb,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