pushwork 2.0.0-a.sub.1 → 2.0.0-preview

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 (251) hide show
  1. package/dist/branches.d.ts +19 -0
  2. package/dist/branches.d.ts.map +1 -0
  3. package/dist/branches.js +111 -0
  4. package/dist/branches.js.map +1 -0
  5. package/dist/cli.d.ts +1 -1
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cli.js +238 -272
  8. package/dist/cli.js.map +1 -1
  9. package/dist/config.d.ts +17 -0
  10. package/dist/config.d.ts.map +1 -0
  11. package/dist/config.js +84 -0
  12. package/dist/config.js.map +1 -0
  13. package/dist/fs-tree.d.ts +6 -0
  14. package/dist/fs-tree.d.ts.map +1 -0
  15. package/dist/fs-tree.js +99 -0
  16. package/dist/fs-tree.js.map +1 -0
  17. package/dist/ignore.d.ts +6 -0
  18. package/dist/ignore.d.ts.map +1 -0
  19. package/dist/ignore.js +74 -0
  20. package/dist/ignore.js.map +1 -0
  21. package/dist/index.d.ts +8 -4
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +34 -4
  24. package/dist/index.js.map +1 -1
  25. package/dist/log.d.ts +3 -0
  26. package/dist/log.d.ts.map +1 -0
  27. package/dist/log.js +14 -0
  28. package/dist/log.js.map +1 -0
  29. package/dist/pushwork.d.ts +115 -0
  30. package/dist/pushwork.d.ts.map +1 -0
  31. package/dist/pushwork.js +918 -0
  32. package/dist/pushwork.js.map +1 -0
  33. package/dist/repo.d.ts +14 -0
  34. package/dist/repo.d.ts.map +1 -0
  35. package/dist/repo.js +60 -0
  36. package/dist/repo.js.map +1 -0
  37. package/dist/shapes/custom.d.ts +3 -0
  38. package/dist/shapes/custom.d.ts.map +1 -0
  39. package/dist/shapes/custom.js +57 -0
  40. package/dist/shapes/custom.js.map +1 -0
  41. package/dist/shapes/file.d.ts +20 -0
  42. package/dist/shapes/file.d.ts.map +1 -0
  43. package/dist/shapes/file.js +140 -0
  44. package/dist/shapes/file.js.map +1 -0
  45. package/dist/shapes/index.d.ts +10 -0
  46. package/dist/shapes/index.d.ts.map +1 -0
  47. package/dist/shapes/index.js +35 -0
  48. package/dist/shapes/index.js.map +1 -0
  49. package/dist/shapes/patchwork-folder.d.ts +3 -0
  50. package/dist/shapes/patchwork-folder.d.ts.map +1 -0
  51. package/dist/shapes/patchwork-folder.js +160 -0
  52. package/dist/shapes/patchwork-folder.js.map +1 -0
  53. package/dist/shapes/types.d.ts +37 -0
  54. package/dist/shapes/types.d.ts.map +1 -0
  55. package/dist/shapes/types.js +52 -0
  56. package/dist/shapes/types.js.map +1 -0
  57. package/dist/shapes/vfs.d.ts +3 -0
  58. package/dist/shapes/vfs.d.ts.map +1 -0
  59. package/dist/shapes/vfs.js +88 -0
  60. package/dist/shapes/vfs.js.map +1 -0
  61. package/dist/stash.d.ts +23 -0
  62. package/dist/stash.d.ts.map +1 -0
  63. package/dist/stash.js +118 -0
  64. package/dist/stash.js.map +1 -0
  65. package/flake.lock +128 -0
  66. package/flake.nix +66 -0
  67. package/package.json +15 -48
  68. package/patches/@automerge__automerge-repo@2.6.0-subduction.15.patch +26 -0
  69. package/pnpm-workspace.yaml +5 -0
  70. package/src/branches.ts +93 -0
  71. package/src/cli.ts +258 -408
  72. package/src/config.ts +64 -0
  73. package/src/fs-tree.ts +70 -0
  74. package/src/ignore.ts +33 -0
  75. package/src/index.ts +38 -4
  76. package/src/log.ts +8 -0
  77. package/src/pushwork.ts +1055 -0
  78. package/src/repo.ts +76 -0
  79. package/src/shapes/custom.ts +29 -0
  80. package/src/shapes/file.ts +115 -0
  81. package/src/shapes/index.ts +19 -0
  82. package/src/shapes/patchwork-folder.ts +156 -0
  83. package/src/shapes/types.ts +79 -0
  84. package/src/shapes/vfs.ts +93 -0
  85. package/src/stash.ts +106 -0
  86. package/test/integration/branches.test.ts +389 -0
  87. package/test/integration/pushwork.test.ts +547 -0
  88. package/test/setup.ts +29 -0
  89. package/test/unit/doc-shape.test.ts +612 -0
  90. package/tsconfig.json +2 -3
  91. package/vitest.config.ts +14 -0
  92. package/ARCHITECTURE-ACCORDING-TO-CLAUDE.md +0 -248
  93. package/CLAUDE.md +0 -141
  94. package/README.md +0 -221
  95. package/babel.config.js +0 -5
  96. package/dist/cli/commands.d.ts +0 -71
  97. package/dist/cli/commands.d.ts.map +0 -1
  98. package/dist/cli/commands.js +0 -794
  99. package/dist/cli/commands.js.map +0 -1
  100. package/dist/cli/index.d.ts +0 -2
  101. package/dist/cli/index.d.ts.map +0 -1
  102. package/dist/cli/index.js +0 -19
  103. package/dist/cli/index.js.map +0 -1
  104. package/dist/commands.d.ts +0 -61
  105. package/dist/commands.d.ts.map +0 -1
  106. package/dist/commands.js +0 -861
  107. package/dist/commands.js.map +0 -1
  108. package/dist/config/index.d.ts +0 -71
  109. package/dist/config/index.d.ts.map +0 -1
  110. package/dist/config/index.js +0 -314
  111. package/dist/config/index.js.map +0 -1
  112. package/dist/core/change-detection.d.ts +0 -80
  113. package/dist/core/change-detection.d.ts.map +0 -1
  114. package/dist/core/change-detection.js +0 -523
  115. package/dist/core/change-detection.js.map +0 -1
  116. package/dist/core/config.d.ts +0 -81
  117. package/dist/core/config.d.ts.map +0 -1
  118. package/dist/core/config.js +0 -258
  119. package/dist/core/config.js.map +0 -1
  120. package/dist/core/index.d.ts +0 -6
  121. package/dist/core/index.d.ts.map +0 -1
  122. package/dist/core/index.js +0 -6
  123. package/dist/core/index.js.map +0 -1
  124. package/dist/core/move-detection.d.ts +0 -34
  125. package/dist/core/move-detection.d.ts.map +0 -1
  126. package/dist/core/move-detection.js +0 -121
  127. package/dist/core/move-detection.js.map +0 -1
  128. package/dist/core/snapshot.d.ts +0 -105
  129. package/dist/core/snapshot.d.ts.map +0 -1
  130. package/dist/core/snapshot.js +0 -217
  131. package/dist/core/snapshot.js.map +0 -1
  132. package/dist/core/sync-engine.d.ts +0 -157
  133. package/dist/core/sync-engine.d.ts.map +0 -1
  134. package/dist/core/sync-engine.js +0 -1379
  135. package/dist/core/sync-engine.js.map +0 -1
  136. package/dist/types/config.d.ts +0 -99
  137. package/dist/types/config.d.ts.map +0 -1
  138. package/dist/types/config.js +0 -5
  139. package/dist/types/config.js.map +0 -1
  140. package/dist/types/documents.d.ts +0 -88
  141. package/dist/types/documents.d.ts.map +0 -1
  142. package/dist/types/documents.js +0 -20
  143. package/dist/types/documents.js.map +0 -1
  144. package/dist/types/index.d.ts +0 -4
  145. package/dist/types/index.d.ts.map +0 -1
  146. package/dist/types/index.js +0 -4
  147. package/dist/types/index.js.map +0 -1
  148. package/dist/types/snapshot.d.ts +0 -64
  149. package/dist/types/snapshot.d.ts.map +0 -1
  150. package/dist/types/snapshot.js +0 -2
  151. package/dist/types/snapshot.js.map +0 -1
  152. package/dist/utils/content-similarity.d.ts +0 -53
  153. package/dist/utils/content-similarity.d.ts.map +0 -1
  154. package/dist/utils/content-similarity.js +0 -155
  155. package/dist/utils/content-similarity.js.map +0 -1
  156. package/dist/utils/content.d.ts +0 -10
  157. package/dist/utils/content.d.ts.map +0 -1
  158. package/dist/utils/content.js +0 -31
  159. package/dist/utils/content.js.map +0 -1
  160. package/dist/utils/directory.d.ts +0 -24
  161. package/dist/utils/directory.d.ts.map +0 -1
  162. package/dist/utils/directory.js +0 -52
  163. package/dist/utils/directory.js.map +0 -1
  164. package/dist/utils/fs.d.ts +0 -74
  165. package/dist/utils/fs.d.ts.map +0 -1
  166. package/dist/utils/fs.js +0 -248
  167. package/dist/utils/fs.js.map +0 -1
  168. package/dist/utils/index.d.ts +0 -5
  169. package/dist/utils/index.d.ts.map +0 -1
  170. package/dist/utils/index.js +0 -5
  171. package/dist/utils/index.js.map +0 -1
  172. package/dist/utils/mime-types.d.ts +0 -13
  173. package/dist/utils/mime-types.d.ts.map +0 -1
  174. package/dist/utils/mime-types.js +0 -209
  175. package/dist/utils/mime-types.js.map +0 -1
  176. package/dist/utils/network-sync.d.ts +0 -36
  177. package/dist/utils/network-sync.d.ts.map +0 -1
  178. package/dist/utils/network-sync.js +0 -250
  179. package/dist/utils/network-sync.js.map +0 -1
  180. package/dist/utils/node-polyfills.d.ts +0 -9
  181. package/dist/utils/node-polyfills.d.ts.map +0 -1
  182. package/dist/utils/node-polyfills.js +0 -9
  183. package/dist/utils/node-polyfills.js.map +0 -1
  184. package/dist/utils/output.d.ts +0 -129
  185. package/dist/utils/output.d.ts.map +0 -1
  186. package/dist/utils/output.js +0 -368
  187. package/dist/utils/output.js.map +0 -1
  188. package/dist/utils/repo-factory.d.ts +0 -13
  189. package/dist/utils/repo-factory.d.ts.map +0 -1
  190. package/dist/utils/repo-factory.js +0 -46
  191. package/dist/utils/repo-factory.js.map +0 -1
  192. package/dist/utils/string-similarity.d.ts +0 -14
  193. package/dist/utils/string-similarity.d.ts.map +0 -1
  194. package/dist/utils/string-similarity.js +0 -39
  195. package/dist/utils/string-similarity.js.map +0 -1
  196. package/dist/utils/text-diff.d.ts +0 -37
  197. package/dist/utils/text-diff.d.ts.map +0 -1
  198. package/dist/utils/text-diff.js +0 -93
  199. package/dist/utils/text-diff.js.map +0 -1
  200. package/dist/utils/trace.d.ts +0 -19
  201. package/dist/utils/trace.d.ts.map +0 -1
  202. package/dist/utils/trace.js +0 -63
  203. package/dist/utils/trace.js.map +0 -1
  204. package/src/commands.ts +0 -1134
  205. package/src/core/change-detection.ts +0 -712
  206. package/src/core/config.ts +0 -313
  207. package/src/core/index.ts +0 -5
  208. package/src/core/move-detection.ts +0 -169
  209. package/src/core/snapshot.ts +0 -275
  210. package/src/core/sync-engine.ts +0 -1795
  211. package/src/types/config.ts +0 -111
  212. package/src/types/documents.ts +0 -91
  213. package/src/types/index.ts +0 -3
  214. package/src/types/snapshot.ts +0 -67
  215. package/src/utils/content.ts +0 -34
  216. package/src/utils/directory.ts +0 -73
  217. package/src/utils/fs.ts +0 -297
  218. package/src/utils/index.ts +0 -4
  219. package/src/utils/mime-types.ts +0 -244
  220. package/src/utils/network-sync.ts +0 -319
  221. package/src/utils/node-polyfills.ts +0 -8
  222. package/src/utils/output.ts +0 -450
  223. package/src/utils/repo-factory.ts +0 -73
  224. package/src/utils/string-similarity.ts +0 -54
  225. package/src/utils/text-diff.ts +0 -101
  226. package/src/utils/trace.ts +0 -70
  227. package/test/integration/README.md +0 -328
  228. package/test/integration/clone-test.sh +0 -310
  229. package/test/integration/conflict-resolution-test.sh +0 -309
  230. package/test/integration/debug-both-nested.sh +0 -74
  231. package/test/integration/debug-concurrent-nested.sh +0 -87
  232. package/test/integration/debug-nested.sh +0 -73
  233. package/test/integration/deletion-behavior-test.sh +0 -487
  234. package/test/integration/deletion-sync-test-simple.sh +0 -193
  235. package/test/integration/deletion-sync-test.sh +0 -297
  236. package/test/integration/exclude-patterns.test.ts +0 -144
  237. package/test/integration/full-integration-test.sh +0 -363
  238. package/test/integration/fuzzer.test.ts +0 -818
  239. package/test/integration/in-memory-sync.test.ts +0 -830
  240. package/test/integration/init-sync.test.ts +0 -89
  241. package/test/integration/manual-sync-test.sh +0 -84
  242. package/test/integration/sync-deletion.test.ts +0 -280
  243. package/test/integration/sync-flow.test.ts +0 -291
  244. package/test/jest.setup.ts +0 -34
  245. package/test/run-tests.sh +0 -225
  246. package/test/unit/deletion-behavior.test.ts +0 -249
  247. package/test/unit/enhanced-mime-detection.test.ts +0 -244
  248. package/test/unit/snapshot.test.ts +0 -404
  249. package/test/unit/sync-convergence.test.ts +0 -298
  250. package/test/unit/sync-timing.test.ts +0 -134
  251. package/test/unit/utils.test.ts +0 -366
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-similarity.js","sourceRoot":"","sources":["../../src/utils/content-similarity.ts"],"names":[],"mappings":";;;AAAA,6BAA4C;AAE5C;;GAEG;AACH,MAAa,iBAAiB;IAK5B;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAC9B,QAA6B,EAC7B,QAA6B;QAE7B,yCAAyC;QACzC,IAAI,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,CA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ote docs.
4
- */
5
- export declare function contentHash(content: string | Uint8Array): string;
6
- /**
7
- * Compare two content pieces for equality
8
- */
9
- export declare function isContentEqual(content1: string | Uint8Array | null, content2: string | Uint8Array | null): boolean;
10
- //# sourceMappingURL=content.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/utils/content.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAEhE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,EACpC,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,GACnC,OAAO,CAiBT"}
@@ -1,31 +0,0 @@
1
- import { createHash } from "crypto";
2
- /**
3
- * Compute a SHA-256 hash of file content.
4
- * Used to detect local changes for artifact files without reading remote docs.
5
- */
6
- export function contentHash(content) {
7
- return createHash("sha256").update(content).digest("hex");
8
- }
9
- /**
10
- * Compare two content pieces for equality
11
- */
12
- export function isContentEqual(content1, content2) {
13
- if (content1 === content2)
14
- return true;
15
- if (!content1 || !content2)
16
- return false;
17
- if (typeof content1 !== typeof content2)
18
- return false;
19
- if (typeof content1 === "string") {
20
- return content1 === content2;
21
- }
22
- else {
23
- // Compare Uint8Array using native Buffer.equals() for better performance
24
- const buf1 = content1;
25
- const buf2 = content2;
26
- if (buf1.length !== buf2.length)
27
- return false;
28
- return Buffer.from(buf1).equals(Buffer.from(buf2));
29
- }
30
- }
31
- //# sourceMappingURL=content.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/utils/content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAA4B;IACtD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC5D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,QAAoC,EACpC,QAAoC;IAEpC,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACvC,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAEzC,IAAI,OAAO,QAAQ,KAAK,OAAO,QAAQ;QAAE,OAAO,KAAK,CAAC;IAEtD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,QAAQ,KAAK,QAAQ,CAAC;IAC/B,CAAC;SAAM,CAAC;QACN,yEAAyE;QACzE,MAAM,IAAI,GAAG,QAAsB,CAAC;QACpC,MAAM,IAAI,GAAG,QAAsB,CAAC;QAEpC,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QAE9C,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
@@ -1,24 +0,0 @@
1
- import { AutomergeUrl, Repo } from "@automerge/automerge-repo";
2
- /**
3
- * Get a plain URL (without heads) from any URL.
4
- * Versioned URLs with heads return view handles, which show a frozen point in time.
5
- * For internal navigation, we always want to see the CURRENT state of documents.
6
- */
7
- export declare function getPlainUrl(url: AutomergeUrl): AutomergeUrl;
8
- /**
9
- * Find a file in the directory hierarchy by path.
10
- *
11
- * IMPORTANT: This function strips heads from all URLs before navigation.
12
- * This ensures we always see the CURRENT state of directories, not a frozen
13
- * point-in-time view. This is critical because:
14
- * 1. Directory documents store versioned URLs for subdirectories
15
- * 2. These URLs may have been captured when the subdirectory was empty
16
- * 3. Using versioned URLs would make files appear to not exist
17
- * 4. This would trigger false "remote deletion" detection
18
- */
19
- export declare function findFileInDirectoryHierarchy(repo: Repo, directoryUrl: AutomergeUrl, filePath: string): Promise<{
20
- name: string;
21
- type: string;
22
- url: AutomergeUrl;
23
- } | null>;
24
- //# sourceMappingURL=directory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../../src/utils/directory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,IAAI,EAGL,MAAM,2BAA2B,CAAC;AAGnC;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,YAAY,GAAG,YAAY,CAG3D;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,YAAY,CAAA;CAAE,GAAG,IAAI,CAAC,CAuCnE"}
@@ -1,52 +0,0 @@
1
- import { parseAutomergeUrl, stringifyAutomergeUrl, } from "@automerge/automerge-repo";
2
- /**
3
- * Get a plain URL (without heads) from any URL.
4
- * Versioned URLs with heads return view handles, which show a frozen point in time.
5
- * For internal navigation, we always want to see the CURRENT state of documents.
6
- */
7
- export function getPlainUrl(url) {
8
- const { documentId } = parseAutomergeUrl(url);
9
- return stringifyAutomergeUrl({ documentId });
10
- }
11
- /**
12
- * Find a file in the directory hierarchy by path.
13
- *
14
- * IMPORTANT: This function strips heads from all URLs before navigation.
15
- * This ensures we always see the CURRENT state of directories, not a frozen
16
- * point-in-time view. This is critical because:
17
- * 1. Directory documents store versioned URLs for subdirectories
18
- * 2. These URLs may have been captured when the subdirectory was empty
19
- * 3. Using versioned URLs would make files appear to not exist
20
- * 4. This would trigger false "remote deletion" detection
21
- */
22
- export async function findFileInDirectoryHierarchy(repo, directoryUrl, filePath) {
23
- try {
24
- const pathParts = filePath.split("/");
25
- let currentDirUrl = getPlainUrl(directoryUrl);
26
- // Navigate through directories to find the parent directory
27
- for (let i = 0; i < pathParts.length - 1; i++) {
28
- const dirName = pathParts[i];
29
- const dirHandle = await repo.find(currentDirUrl);
30
- const dirDoc = await dirHandle.doc();
31
- if (!dirDoc)
32
- return null;
33
- const subDirEntry = dirDoc.docs.find((entry) => entry.name === dirName && entry.type === "folder");
34
- if (!subDirEntry)
35
- return null;
36
- currentDirUrl = getPlainUrl(subDirEntry.url);
37
- }
38
- // Now look for the file in the final directory
39
- const fileName = pathParts[pathParts.length - 1];
40
- const finalDirHandle = await repo.find(currentDirUrl);
41
- const finalDirDoc = await finalDirHandle.doc();
42
- if (!finalDirDoc)
43
- return null;
44
- const fileEntry = finalDirDoc.docs.find((entry) => entry.name === fileName && entry.type === "file");
45
- return fileEntry || null;
46
- }
47
- catch (error) {
48
- // Failed to find file in hierarchy
49
- return null;
50
- }
51
- }
52
- //# sourceMappingURL=directory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"directory.js","sourceRoot":"","sources":["../../src/utils/directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAGnC;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,GAAiB;IAC3C,MAAM,EAAE,UAAU,EAAE,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAC9C,OAAO,qBAAqB,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,IAAU,EACV,YAA0B,EAC1B,QAAgB;IAEhB,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,aAAa,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC;QAE9C,4DAA4D;QAC5D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,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../types/index.js";
2
- /**
3
- * Check if a path exists
4
- */
5
- export declare function pathExists(filePath: string): Promise<boolean>;
6
- /**
7
- * Get file system entry metadata
8
- */
9
- export declare function getFileSystemEntry(filePath: string): Promise<FileSystemEntry | null>;
10
- /**
11
- * Determine if a file is text or binary
12
- */
13
- export declare function isTextFile(filePath: string): Promise<boolean>;
14
- /**
15
- * Read file content as string or buffer
16
- */
17
- export declare function readFileContent(filePath: string): Promise<string | Uint8Array>;
18
- /**
19
- * Write file content from string or buffer
20
- */
21
- export declare function writeFileContent(filePath: string, content: string | Uint8Array): Promise<void>;
22
- /**
23
- * Ensure directory exists, creating it if necessary
24
- */
25
- export declare function ensureDirectoryExists(dirPath: string): Promise<void>;
26
- /**
27
- * Remove file or directory
28
- */
29
- export declare function removePath(filePath: string): Promise<void>;
30
- /**
31
- * List directory contents with metadata
32
- */
33
- export declare function listDirectory(dirPath: string, recursive?: boolean, excludePatterns?: string[]): Promise<FileSystemEntry[]>;
34
- /**
35
- * Copy file with metadata preservation
36
- */
37
- export declare function copyFile(sourcePath: string, destPath: string): Promise<void>;
38
- /**
39
- * Move/rename file or directory
40
- */
41
- export declare function movePath(sourcePath: string, destPath: string): Promise<void>;
42
- /**
43
- * Calculate content hash for change detection
44
- */
45
- export declare function calculateContentHash(content: string | Uint8Array): Promise<string>;
46
- /**
47
- * Get MIME type for file
48
- */
49
- export declare function getMimeType(filePath: string): string;
50
- /**
51
- * Get file extension
52
- */
53
- export declare function getFileExtension(filePath: string): string;
54
- /**
55
- * Normalize path separators for cross-platform compatibility
56
- * Converts all path separators to forward slashes for consistent storage
57
- */
58
- export declare function normalizePath(filePath: string): string;
59
- /**
60
- * Join paths and normalize separators for cross-platform compatibility
61
- * Use this instead of string concatenation to ensure proper path handling on Windows
62
- */
63
- export declare function joinAndNormalizePath(...paths: string[]): string;
64
- /**
65
- * Get relative path from base directory
66
- */
67
- export declare function getRelativePath(basePath: string, filePath: string): string;
68
- /**
69
- * Format a path as a relative path with proper prefix
70
- * Ensures paths like "src" become "./src" for clarity
71
- * Leaves absolute paths and paths already starting with . or .. unchanged
72
- */
73
- export declare function formatRelativePath(filePath: string): string;
74
- //# sourceMappingURL=fs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"AAQA,OAAO,EAAC,eAAe,EAAW,MAAM,mBAAmB,CAAA;AAG3D;;GAEG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnE;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACvC,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAmBjC;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAwBnE;AAED;;GAEG;AACH,wBAAsB,eAAe,CACpC,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,GAAG,UAAU,CAAC,CAS9B;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACrC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,UAAU,GAC1B,OAAO,CAAC,IAAI,CAAC,CAQf;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ1E;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAahE;AAsBD;;GAEG;AACH,wBAAsB,aAAa,CAClC,OAAO,EAAE,MAAM,EACf,SAAS,UAAQ,EACjB,eAAe,GAAE,MAAM,EAAO,GAC5B,OAAO,CAAC,eAAe,EAAE,CAAC,CAoC5B;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAC7B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAOf;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAC7B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAGf;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACzC,OAAO,EAAE,MAAM,GAAG,UAAU,GAC1B,OAAO,CAAC,MAAM,CAAC,CAIjB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAK/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAO3D"}
package/dist/utils/fs.js DELETED
@@ -1,248 +0,0 @@
1
- import * as fs from "fs/promises";
2
- import * as path from "path";
3
- import * as crypto from "crypto";
4
- import { glob } from "glob";
5
- import * as mimeTypes from "mime-types";
6
- import ignoreModule from "ignore";
7
- // CJS default export compat under nodenext
8
- const ignore = ignoreModule.default || ignoreModule;
9
- import { FileType } from "../types/index.js";
10
- import { isEnhancedTextFile } from "./mime-types.js";
11
- /**
12
- * Check if a path exists
13
- */
14
- export async function pathExists(filePath) {
15
- try {
16
- await fs.access(filePath);
17
- return true;
18
- }
19
- catch {
20
- return false;
21
- }
22
- }
23
- /**
24
- * Get file system entry metadata
25
- */
26
- export async function getFileSystemEntry(filePath) {
27
- try {
28
- const stats = await fs.stat(filePath);
29
- const type = stats.isDirectory()
30
- ? FileType.DIRECTORY
31
- : (await isEnhancedTextFile(filePath))
32
- ? FileType.TEXT
33
- : FileType.BINARY;
34
- return {
35
- path: filePath,
36
- type,
37
- size: stats.size,
38
- mtime: stats.mtime,
39
- permissions: stats.mode & parseInt("777", 8),
40
- };
41
- }
42
- catch {
43
- return null;
44
- }
45
- }
46
- /**
47
- * Determine if a file is text or binary
48
- */
49
- export async function isTextFile(filePath) {
50
- try {
51
- const mimeType = mimeTypes.lookup(filePath);
52
- if (mimeType) {
53
- return (mimeType.startsWith("text/") ||
54
- mimeType === "application/json" ||
55
- mimeType === "application/xml" ||
56
- mimeType.includes("javascript") ||
57
- mimeType.includes("typescript"));
58
- }
59
- // Sample first 8KB to detect binary content
60
- const handle = await fs.open(filePath, "r");
61
- const buffer = Buffer.alloc(Math.min(8192, (await handle.stat()).size));
62
- await handle.read(buffer, 0, buffer.length, 0);
63
- await handle.close();
64
- // Check for null bytes which indicate binary content
65
- return !buffer.includes(0);
66
- }
67
- catch {
68
- return false;
69
- }
70
- }
71
- /**
72
- * Read file content as string or buffer
73
- */
74
- export async function readFileContent(filePath) {
75
- const isText = await isEnhancedTextFile(filePath);
76
- if (isText) {
77
- return await fs.readFile(filePath, "utf8");
78
- }
79
- else {
80
- const buffer = await fs.readFile(filePath);
81
- return new Uint8Array(buffer);
82
- }
83
- }
84
- /**
85
- * Write file content from string or buffer
86
- */
87
- export async function writeFileContent(filePath, content) {
88
- await ensureDirectoryExists(path.dirname(filePath));
89
- if (typeof content === "string") {
90
- await fs.writeFile(filePath, content, "utf8");
91
- }
92
- else {
93
- await fs.writeFile(filePath, content);
94
- }
95
- }
96
- /**
97
- * Ensure directory exists, creating it if necessary
98
- */
99
- export async function ensureDirectoryExists(dirPath) {
100
- try {
101
- await fs.mkdir(dirPath, { recursive: true });
102
- }
103
- catch (error) {
104
- if (error.code !== "EEXIST") {
105
- throw error;
106
- }
107
- }
108
- }
109
- /**
110
- * Remove file or directory
111
- */
112
- export async function removePath(filePath) {
113
- try {
114
- const stats = await fs.stat(filePath);
115
- if (stats.isDirectory()) {
116
- await fs.rm(filePath, { recursive: true });
117
- }
118
- else {
119
- await fs.unlink(filePath);
120
- }
121
- }
122
- catch (error) {
123
- if (error.code !== "ENOENT") {
124
- throw error;
125
- }
126
- }
127
- }
128
- /**
129
- * Check if a path matches any of the exclude patterns using the ignore library
130
- * Supports proper gitignore-style patterns (e.g., "node_modules", "*.tmp", ".git")
131
- */
132
- function isExcluded(filePath, basePath, excludePatterns) {
133
- if (excludePatterns.length === 0)
134
- return false;
135
- const relativePath = path.relative(basePath, filePath);
136
- // Use the ignore library which implements proper .gitignore semantics
137
- // This is the same library used by ESLint and other major tools
138
- const ig = ignore().add(excludePatterns);
139
- return ig.ignores(relativePath);
140
- }
141
- /**
142
- * List directory contents with metadata
143
- */
144
- export async function listDirectory(dirPath, recursive = false, excludePatterns = []) {
145
- const entries = [];
146
- try {
147
- // Construct pattern using path.join for proper cross-platform handling
148
- const pattern = recursive
149
- ? path.join(dirPath, "**/*")
150
- : path.join(dirPath, "*");
151
- // glob expects forward slashes, even on Windows
152
- const normalizedPattern = pattern.replace(/\\/g, "/");
153
- // Use glob to get all paths (with dot files)
154
- // Note: We don't use glob's ignore option because it doesn't support gitignore semantics
155
- const paths = await glob(normalizedPattern, {
156
- dot: true,
157
- });
158
- // Parallelize all stat calls for better performance
159
- const allEntries = await Promise.all(paths.map(async (filePath) => {
160
- // Filter using proper gitignore semantics from the ignore library
161
- if (isExcluded(filePath, dirPath, excludePatterns)) {
162
- return null;
163
- }
164
- return await getFileSystemEntry(filePath);
165
- }));
166
- // Filter out null entries (excluded files or files that couldn't be read)
167
- entries.push(...allEntries.filter((e) => e !== null));
168
- }
169
- catch {
170
- // Return empty array if directory doesn't exist or can't be read
171
- }
172
- return entries;
173
- }
174
- /**
175
- * Copy file with metadata preservation
176
- */
177
- export async function copyFile(sourcePath, destPath) {
178
- await ensureDirectoryExists(path.dirname(destPath));
179
- await fs.copyFile(sourcePath, destPath);
180
- // Preserve file permissions
181
- const stats = await fs.stat(sourcePath);
182
- await fs.chmod(destPath, stats.mode);
183
- }
184
- /**
185
- * Move/rename file or directory
186
- */
187
- export async function movePath(sourcePath, destPath) {
188
- await ensureDirectoryExists(path.dirname(destPath));
189
- await fs.rename(sourcePath, destPath);
190
- }
191
- /**
192
- * Calculate content hash for change detection
193
- */
194
- export async function calculateContentHash(content) {
195
- const hash = crypto.createHash("sha256");
196
- hash.update(content);
197
- return hash.digest("hex");
198
- }
199
- /**
200
- * Get MIME type for file
201
- */
202
- export function getMimeType(filePath) {
203
- return mimeTypes.lookup(filePath) || "application/octet-stream";
204
- }
205
- /**
206
- * Get file extension
207
- */
208
- export function getFileExtension(filePath) {
209
- const ext = path.extname(filePath);
210
- return ext.startsWith(".") ? ext.slice(1) : ext;
211
- }
212
- /**
213
- * Normalize path separators for cross-platform compatibility
214
- * Converts all path separators to forward slashes for consistent storage
215
- */
216
- export function normalizePath(filePath) {
217
- return path.posix.normalize(filePath.replace(/\\/g, "/"));
218
- }
219
- /**
220
- * Join paths and normalize separators for cross-platform compatibility
221
- * Use this instead of string concatenation to ensure proper path handling on Windows
222
- */
223
- export function joinAndNormalizePath(...paths) {
224
- // Use path.join to properly handle path construction (handles Windows drive letters, etc.)
225
- const joined = path.join(...paths);
226
- // Then normalize to forward slashes for consistent storage/comparison
227
- return normalizePath(joined);
228
- }
229
- /**
230
- * Get relative path from base directory
231
- */
232
- export function getRelativePath(basePath, filePath) {
233
- return normalizePath(path.relative(basePath, filePath));
234
- }
235
- /**
236
- * Format a path as a relative path with proper prefix
237
- * Ensures paths like "src" become "./src" for clarity
238
- * Leaves absolute paths and paths already starting with . or .. unchanged
239
- */
240
- export function formatRelativePath(filePath) {
241
- // Already starts with . or / - leave as-is
242
- if (filePath.startsWith(".") || filePath.startsWith("/")) {
243
- return filePath;
244
- }
245
- // Add ./ prefix for clarity
246
- return `./${filePath}`;
247
- }
248
- //# sourceMappingURL=fs.js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C,CAAA;AACxD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IAClD,2CAA2C;IAC3C,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1D,OAAO,QAAQ,CAAA;IAChB,CAAC;IACD,4BAA4B;IAC5B,OAAO,KAAK,QAAQ,EAAE,CAAA;AACvB,CAAC"}
@@ -1,5 +0,0 @@
1
- export * from "./fs.js";
2
- export * from "./mime-types.js";
3
- export * from "./directory.js";
4
- export * from "./text-diff.js";
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA"}
@@ -1,5 +0,0 @@
1
- export * from "./fs.js";
2
- export * from "./mime-types.js";
3
- export * from "./directory.js";
4
- export * from "./text-diff.js";
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA"}
@@ -1,13 +0,0 @@
1
- /**
2
- * Get enhanced MIME type for file with custom dev file support
3
- */
4
- export declare function getEnhancedMimeType(filePath: string): string;
5
- /**
6
- * Check if file extension should be forced to text type
7
- */
8
- export declare function shouldForceAsText(filePath: string): boolean;
9
- /**
10
- * Enhanced text file detection with developer file support
11
- */
12
- export declare function isEnhancedTextFile(filePath: string): Promise<boolean>;
13
- //# sourceMappingURL=mime-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mime-types.d.ts","sourceRoot":"","sources":["../../src/utils/mime-types.ts"],"names":[],"mappings":"AA2GA;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAuB5D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAG3D;AAiBD;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAmB3E"}