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

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 (234) hide show
  1. package/dist/branches.d.ts +20 -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 +245 -270
  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 +35 -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 +129 -0
  30. package/dist/pushwork.d.ts.map +1 -0
  31. package/dist/pushwork.js +1062 -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 +38 -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 +92 -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/dist/version.d.ts +11 -0
  66. package/dist/version.d.ts.map +1 -0
  67. package/dist/version.js +93 -0
  68. package/dist/version.js.map +1 -0
  69. package/package.json +19 -48
  70. package/patches/@automerge__automerge-repo@2.6.0-subduction.15.patch +26 -0
  71. package/.prettierrc +0 -9
  72. package/ARCHITECTURE-ACCORDING-TO-CLAUDE.md +0 -248
  73. package/CLAUDE.md +0 -141
  74. package/README.md +0 -221
  75. package/babel.config.js +0 -5
  76. package/dist/cli/commands.d.ts +0 -71
  77. package/dist/cli/commands.d.ts.map +0 -1
  78. package/dist/cli/commands.js +0 -794
  79. package/dist/cli/commands.js.map +0 -1
  80. package/dist/cli/index.d.ts +0 -2
  81. package/dist/cli/index.d.ts.map +0 -1
  82. package/dist/cli/index.js +0 -19
  83. package/dist/cli/index.js.map +0 -1
  84. package/dist/commands.d.ts +0 -61
  85. package/dist/commands.d.ts.map +0 -1
  86. package/dist/commands.js +0 -861
  87. package/dist/commands.js.map +0 -1
  88. package/dist/config/index.d.ts +0 -71
  89. package/dist/config/index.d.ts.map +0 -1
  90. package/dist/config/index.js +0 -314
  91. package/dist/config/index.js.map +0 -1
  92. package/dist/core/change-detection.d.ts +0 -80
  93. package/dist/core/change-detection.d.ts.map +0 -1
  94. package/dist/core/change-detection.js +0 -523
  95. package/dist/core/change-detection.js.map +0 -1
  96. package/dist/core/config.d.ts +0 -81
  97. package/dist/core/config.d.ts.map +0 -1
  98. package/dist/core/config.js +0 -258
  99. package/dist/core/config.js.map +0 -1
  100. package/dist/core/index.d.ts +0 -6
  101. package/dist/core/index.d.ts.map +0 -1
  102. package/dist/core/index.js +0 -6
  103. package/dist/core/index.js.map +0 -1
  104. package/dist/core/move-detection.d.ts +0 -34
  105. package/dist/core/move-detection.d.ts.map +0 -1
  106. package/dist/core/move-detection.js +0 -121
  107. package/dist/core/move-detection.js.map +0 -1
  108. package/dist/core/snapshot.d.ts +0 -105
  109. package/dist/core/snapshot.d.ts.map +0 -1
  110. package/dist/core/snapshot.js +0 -217
  111. package/dist/core/snapshot.js.map +0 -1
  112. package/dist/core/sync-engine.d.ts +0 -157
  113. package/dist/core/sync-engine.d.ts.map +0 -1
  114. package/dist/core/sync-engine.js +0 -1379
  115. package/dist/core/sync-engine.js.map +0 -1
  116. package/dist/types/config.d.ts +0 -99
  117. package/dist/types/config.d.ts.map +0 -1
  118. package/dist/types/config.js +0 -5
  119. package/dist/types/config.js.map +0 -1
  120. package/dist/types/documents.d.ts +0 -88
  121. package/dist/types/documents.d.ts.map +0 -1
  122. package/dist/types/documents.js +0 -20
  123. package/dist/types/documents.js.map +0 -1
  124. package/dist/types/index.d.ts +0 -4
  125. package/dist/types/index.d.ts.map +0 -1
  126. package/dist/types/index.js +0 -4
  127. package/dist/types/index.js.map +0 -1
  128. package/dist/types/snapshot.d.ts +0 -64
  129. package/dist/types/snapshot.d.ts.map +0 -1
  130. package/dist/types/snapshot.js +0 -2
  131. package/dist/types/snapshot.js.map +0 -1
  132. package/dist/utils/content-similarity.d.ts +0 -53
  133. package/dist/utils/content-similarity.d.ts.map +0 -1
  134. package/dist/utils/content-similarity.js +0 -155
  135. package/dist/utils/content-similarity.js.map +0 -1
  136. package/dist/utils/content.d.ts +0 -10
  137. package/dist/utils/content.d.ts.map +0 -1
  138. package/dist/utils/content.js +0 -31
  139. package/dist/utils/content.js.map +0 -1
  140. package/dist/utils/directory.d.ts +0 -24
  141. package/dist/utils/directory.d.ts.map +0 -1
  142. package/dist/utils/directory.js +0 -52
  143. package/dist/utils/directory.js.map +0 -1
  144. package/dist/utils/fs.d.ts +0 -74
  145. package/dist/utils/fs.d.ts.map +0 -1
  146. package/dist/utils/fs.js +0 -248
  147. package/dist/utils/fs.js.map +0 -1
  148. package/dist/utils/index.d.ts +0 -5
  149. package/dist/utils/index.d.ts.map +0 -1
  150. package/dist/utils/index.js +0 -5
  151. package/dist/utils/index.js.map +0 -1
  152. package/dist/utils/mime-types.d.ts +0 -13
  153. package/dist/utils/mime-types.d.ts.map +0 -1
  154. package/dist/utils/mime-types.js +0 -209
  155. package/dist/utils/mime-types.js.map +0 -1
  156. package/dist/utils/network-sync.d.ts +0 -36
  157. package/dist/utils/network-sync.d.ts.map +0 -1
  158. package/dist/utils/network-sync.js +0 -250
  159. package/dist/utils/network-sync.js.map +0 -1
  160. package/dist/utils/node-polyfills.d.ts +0 -9
  161. package/dist/utils/node-polyfills.d.ts.map +0 -1
  162. package/dist/utils/node-polyfills.js +0 -9
  163. package/dist/utils/node-polyfills.js.map +0 -1
  164. package/dist/utils/output.d.ts +0 -129
  165. package/dist/utils/output.d.ts.map +0 -1
  166. package/dist/utils/output.js +0 -368
  167. package/dist/utils/output.js.map +0 -1
  168. package/dist/utils/repo-factory.d.ts +0 -13
  169. package/dist/utils/repo-factory.d.ts.map +0 -1
  170. package/dist/utils/repo-factory.js +0 -46
  171. package/dist/utils/repo-factory.js.map +0 -1
  172. package/dist/utils/string-similarity.d.ts +0 -14
  173. package/dist/utils/string-similarity.d.ts.map +0 -1
  174. package/dist/utils/string-similarity.js +0 -39
  175. package/dist/utils/string-similarity.js.map +0 -1
  176. package/dist/utils/text-diff.d.ts +0 -37
  177. package/dist/utils/text-diff.d.ts.map +0 -1
  178. package/dist/utils/text-diff.js +0 -93
  179. package/dist/utils/text-diff.js.map +0 -1
  180. package/dist/utils/trace.d.ts +0 -19
  181. package/dist/utils/trace.d.ts.map +0 -1
  182. package/dist/utils/trace.js +0 -63
  183. package/dist/utils/trace.js.map +0 -1
  184. package/src/cli.ts +0 -442
  185. package/src/commands.ts +0 -1134
  186. package/src/core/change-detection.ts +0 -712
  187. package/src/core/config.ts +0 -313
  188. package/src/core/index.ts +0 -5
  189. package/src/core/move-detection.ts +0 -169
  190. package/src/core/snapshot.ts +0 -275
  191. package/src/core/sync-engine.ts +0 -1795
  192. package/src/index.ts +0 -4
  193. package/src/types/config.ts +0 -111
  194. package/src/types/documents.ts +0 -91
  195. package/src/types/index.ts +0 -3
  196. package/src/types/snapshot.ts +0 -67
  197. package/src/utils/content.ts +0 -34
  198. package/src/utils/directory.ts +0 -73
  199. package/src/utils/fs.ts +0 -297
  200. package/src/utils/index.ts +0 -4
  201. package/src/utils/mime-types.ts +0 -244
  202. package/src/utils/network-sync.ts +0 -319
  203. package/src/utils/node-polyfills.ts +0 -8
  204. package/src/utils/output.ts +0 -450
  205. package/src/utils/repo-factory.ts +0 -73
  206. package/src/utils/string-similarity.ts +0 -54
  207. package/src/utils/text-diff.ts +0 -101
  208. package/src/utils/trace.ts +0 -70
  209. package/test/integration/README.md +0 -328
  210. package/test/integration/clone-test.sh +0 -310
  211. package/test/integration/conflict-resolution-test.sh +0 -309
  212. package/test/integration/debug-both-nested.sh +0 -74
  213. package/test/integration/debug-concurrent-nested.sh +0 -87
  214. package/test/integration/debug-nested.sh +0 -73
  215. package/test/integration/deletion-behavior-test.sh +0 -487
  216. package/test/integration/deletion-sync-test-simple.sh +0 -193
  217. package/test/integration/deletion-sync-test.sh +0 -297
  218. package/test/integration/exclude-patterns.test.ts +0 -144
  219. package/test/integration/full-integration-test.sh +0 -363
  220. package/test/integration/fuzzer.test.ts +0 -818
  221. package/test/integration/in-memory-sync.test.ts +0 -830
  222. package/test/integration/init-sync.test.ts +0 -89
  223. package/test/integration/manual-sync-test.sh +0 -84
  224. package/test/integration/sync-deletion.test.ts +0 -280
  225. package/test/integration/sync-flow.test.ts +0 -291
  226. package/test/jest.setup.ts +0 -34
  227. package/test/run-tests.sh +0 -225
  228. package/test/unit/deletion-behavior.test.ts +0 -249
  229. package/test/unit/enhanced-mime-detection.test.ts +0 -244
  230. package/test/unit/snapshot.test.ts +0 -404
  231. package/test/unit/sync-convergence.test.ts +0 -298
  232. package/test/unit/sync-timing.test.ts +0 -134
  233. package/test/unit/utils.test.ts +0 -366
  234. package/tsconfig.json +0 -23
@@ -1,217 +0,0 @@
1
- /**
2
- * pvh TODO: the files & directories could be unified into a single map of entries with a type field
3
- */
4
- import * as fs from "fs/promises";
5
- import * as path from "path";
6
- import { pathExists, ensureDirectoryExists } from "../utils/index.js";
7
- import { out } from "../utils/output.js";
8
- /**
9
- * Manages sync snapshots for local state tracking
10
- */
11
- export class SnapshotManager {
12
- constructor(rootPath) {
13
- this.rootPath = rootPath;
14
- }
15
- /**
16
- * Get path to sync tool directory
17
- */
18
- getSyncToolDir() {
19
- return path.join(this.rootPath, SnapshotManager.SYNC_TOOL_DIR);
20
- }
21
- /**
22
- * Get path to snapshot file
23
- */
24
- getSnapshotPath() {
25
- return path.join(this.getSyncToolDir(), SnapshotManager.SNAPSHOT_FILENAME);
26
- }
27
- /**
28
- * Check if snapshot exists
29
- */
30
- async exists() {
31
- return await pathExists(this.getSnapshotPath());
32
- }
33
- /**
34
- * Load snapshot from disk
35
- */
36
- async load() {
37
- try {
38
- const snapshotPath = this.getSnapshotPath();
39
- if (!(await pathExists(snapshotPath))) {
40
- return null;
41
- }
42
- const content = await fs.readFile(snapshotPath, "utf8");
43
- const serializable = JSON.parse(content);
44
- return this.deserializeSnapshot(serializable);
45
- }
46
- catch (error) {
47
- out.taskLine(`Failed to load snapshot: ${error}`);
48
- return null;
49
- }
50
- }
51
- /**
52
- * Save snapshot to disk
53
- */
54
- async save(snapshot) {
55
- try {
56
- await ensureDirectoryExists(this.getSyncToolDir());
57
- const serializable = this.serializeSnapshot(snapshot);
58
- const content = JSON.stringify(serializable, null, 2);
59
- await fs.writeFile(this.getSnapshotPath(), content, "utf8");
60
- }
61
- catch (error) {
62
- throw new Error(`Failed to save snapshot: ${error}`);
63
- }
64
- }
65
- /**
66
- * Create empty snapshot
67
- */
68
- createEmpty() {
69
- return {
70
- timestamp: Date.now(),
71
- rootPath: this.rootPath,
72
- rootDirectoryUrl: undefined,
73
- files: new Map(),
74
- directories: new Map(),
75
- };
76
- }
77
- /**
78
- * Update file entry in snapshot
79
- */
80
- updateFileEntry(snapshot, relativePath, entry) {
81
- snapshot.files.set(relativePath, entry);
82
- snapshot.timestamp = Date.now();
83
- }
84
- /**
85
- * Update directory entry in snapshot
86
- */
87
- updateDirectoryEntry(snapshot, relativePath, entry) {
88
- snapshot.directories.set(relativePath, entry);
89
- snapshot.timestamp = Date.now();
90
- }
91
- /**
92
- * Remove file entry from snapshot
93
- */
94
- removeFileEntry(snapshot, relativePath) {
95
- snapshot.files.delete(relativePath);
96
- snapshot.timestamp = Date.now();
97
- }
98
- /**
99
- * Remove directory entry from snapshot
100
- */
101
- removeDirectoryEntry(snapshot, relativePath) {
102
- snapshot.directories.delete(relativePath);
103
- snapshot.timestamp = Date.now();
104
- }
105
- /**
106
- * Get all file paths in snapshot
107
- */
108
- getFilePaths(snapshot) {
109
- return Array.from(snapshot.files.keys());
110
- }
111
- /**
112
- * Get all directory paths in snapshot
113
- */
114
- getDirectoryPaths(snapshot) {
115
- return Array.from(snapshot.directories.keys());
116
- }
117
- /**
118
- * Get file entry by path
119
- */
120
- getFileEntry(snapshot, relativePath) {
121
- return snapshot.files.get(relativePath);
122
- }
123
- /**
124
- * Get directory entry by path
125
- */
126
- getDirectoryEntry(snapshot, relativePath) {
127
- return snapshot.directories.get(relativePath);
128
- }
129
- /**
130
- * Check if path is tracked in snapshot
131
- */
132
- isTracked(snapshot, relativePath) {
133
- return (snapshot.files.has(relativePath) || snapshot.directories.has(relativePath));
134
- }
135
- /**
136
- * Get snapshot statistics
137
- */
138
- getStats(snapshot) {
139
- return {
140
- files: snapshot.files.size,
141
- directories: snapshot.directories.size,
142
- timestamp: new Date(snapshot.timestamp),
143
- };
144
- }
145
- /**
146
- * Validate snapshot integrity
147
- */
148
- validate(snapshot) {
149
- const errors = [];
150
- if (!snapshot.timestamp || snapshot.timestamp <= 0) {
151
- errors.push("Invalid timestamp");
152
- }
153
- if (!snapshot.rootPath) {
154
- errors.push("Missing root path");
155
- }
156
- if (!snapshot.files || !snapshot.directories) {
157
- errors.push("Missing files or directories map");
158
- }
159
- // Check for path conflicts (file and directory with same path)
160
- for (const filePath of snapshot.files.keys()) {
161
- if (snapshot.directories.has(filePath)) {
162
- errors.push(`Path conflict: ${filePath} exists as both file and directory`);
163
- }
164
- }
165
- return {
166
- valid: errors.length === 0,
167
- errors,
168
- };
169
- }
170
- /**
171
- * Convert snapshot to serializable format
172
- */
173
- serializeSnapshot(snapshot) {
174
- return {
175
- timestamp: snapshot.timestamp,
176
- rootPath: snapshot.rootPath,
177
- rootDirectoryUrl: snapshot.rootDirectoryUrl,
178
- files: Array.from(snapshot.files.entries()),
179
- directories: Array.from(snapshot.directories.entries()),
180
- };
181
- }
182
- /**
183
- * Convert serializable format back to snapshot
184
- */
185
- deserializeSnapshot(serializable) {
186
- return {
187
- timestamp: serializable.timestamp,
188
- rootPath: serializable.rootPath,
189
- rootDirectoryUrl: serializable.rootDirectoryUrl,
190
- files: new Map(serializable.files),
191
- directories: new Map(serializable.directories),
192
- };
193
- }
194
- /**
195
- * Clear all snapshot data
196
- */
197
- clear(snapshot) {
198
- snapshot.files.clear();
199
- snapshot.directories.clear();
200
- snapshot.timestamp = Date.now();
201
- }
202
- /**
203
- * Clone snapshot for safe manipulation
204
- */
205
- clone(snapshot) {
206
- return {
207
- timestamp: snapshot.timestamp,
208
- rootPath: snapshot.rootPath,
209
- rootDirectoryUrl: snapshot.rootDirectoryUrl,
210
- files: new Map(snapshot.files),
211
- directories: new Map(snapshot.directories),
212
- };
213
- }
214
- }
215
- SnapshotManager.SNAPSHOT_FILENAME = "snapshot.json";
216
- SnapshotManager.SYNC_TOOL_DIR = ".pushwork";
217
- //# sourceMappingURL=snapshot.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/core/snapshot.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAO7B,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAEzC;;GAEG;AACH,MAAM,OAAO,eAAe;IAI1B,YAAoB,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;IAAG,CAAC;IAExC;;OAEG;IACK,cAAc;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;IACjE,CAAC;IAED;;OAEG;IACK,eAAe;QACrB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,eAAe,CAAC,iBAAiB,CAAC,CAAC;IAC7E,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM;QACV,OAAO,MAAM,UAAU,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;YAC5C,IAAI,CAAC,CAAC,MAAM,UAAU,CA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AAG,CAAC,QAAQ,CAAC,WAAW,CAAC;SAC3C,CAAC;IACJ,CAAC;;AA9PuB,iCAAiB,GAAG,eAAe,CAAC;AACpC,6BAAa,GAAG,WAAW,CAAC"}
@@ -1,157 +0,0 @@
1
- import { AutomergeUrl, Repo } from "@automerge/automerge-repo";
2
- import { SyncSnapshot, SyncResult, MoveCandidate, DirectoryConfig, DetectedChange } from "../types/index.js";
3
- /**
4
- * Bidirectional sync engine implementing two-phase sync
5
- */
6
- export declare class SyncEngine {
7
- private repo;
8
- private rootPath;
9
- private snapshotManager;
10
- private changeDetector;
11
- private moveDetector;
12
- private handlesByPath;
13
- private config;
14
- constructor(repo: Repo, rootPath: string, config: DirectoryConfig);
15
- /**
16
- * Determine if content should be treated as text for Automerge text operations
17
- * Note: This method checks the runtime type. File type detection happens
18
- * during reading with isEnhancedTextFile() which now has better dev file support.
19
- */
20
- private isTextContent;
21
- /**
22
- * Get a versioned URL from a handle (includes current heads).
23
- * This ensures clients can fetch the exact version of the document.
24
- */
25
- private getVersionedUrl;
26
- /**
27
- * Determine if a file path is inside an artifact directory.
28
- * Artifact files are stored as immutable strings (RawString) and
29
- * referenced with versioned URLs in directory entries.
30
- */
31
- private isArtifactPath;
32
- /**
33
- * Get the appropriate URL for a file's directory entry.
34
- * Artifact paths get versioned URLs (with heads) for exact version fetching.
35
- * Non-artifact paths get plain URLs for collaborative editing.
36
- */
37
- private getEntryUrl;
38
- /**
39
- * Get the appropriate URL for a subdirectory's directory entry.
40
- * Always uses plain URLs — versioned URLs on directories can cause
41
- * issues where consumers see a version without the docs array.
42
- */
43
- private getDirEntryUrl;
44
- /**
45
- * Set the root directory URL in the snapshot
46
- */
47
- setRootDirectoryUrl(url: AutomergeUrl): Promise<void>;
48
- /**
49
- * Reset the snapshot, clearing all tracked files and directories.
50
- * Preserves the rootDirectoryUrl so sync can still operate.
51
- * Used by --force to re-sync every file.
52
- */
53
- resetSnapshot(): Promise<void>;
54
- /**
55
- * Nuclear reset: clear the snapshot AND wipe the root directory document's
56
- * entries so that every file and subdirectory gets brand-new Automerge
57
- * documents. The root directory document itself is preserved.
58
- */
59
- nuclearReset(): Promise<void>;
60
- /**
61
- * Commit local changes only (no network sync)
62
- */
63
- commitLocal(): Promise<SyncResult>;
64
- /**
65
- * Recreate documents that failed to sync. Creates new Automerge documents
66
- * with the same content and updates all references (snapshot, parent directory).
67
- * Returns new handles that should be retried for sync.
68
- */
69
- private recreateFailedDocuments;
70
- /**
71
- * Run full bidirectional sync
72
- */
73
- sync(): Promise<SyncResult>;
74
- /**
75
- * Phase 1: Push local changes to Automerge documents.
76
- *
77
- * Works depth-first: processes the deepest files first, creates/updates all
78
- * file docs at each level, then batch-updates the parent directory document
79
- * in a single change. Propagates subdirectory URL updates as we walk up
80
- * toward the root. This eliminates the need for a separate URL update pass.
81
- */
82
- private pushLocalChanges;
83
- /**
84
- * Phase 2: Pull remote changes to local filesystem
85
- */
86
- private pullRemoteChanges;
87
- /**
88
- * Apply remote change to local filesystem
89
- */
90
- private applyRemoteChangeToLocal;
91
- /**
92
- * Apply move to remote documents
93
- */
94
- private applyMoveToRemote;
95
- /**
96
- * Create new remote file document
97
- */
98
- private createRemoteFile;
99
- /**
100
- * Update existing remote file document
101
- */
102
- private updateRemoteFile;
103
- /**
104
- * Delete remote file document
105
- */
106
- private deleteRemoteFile;
107
- /**
108
- * Add file entry to appropriate directory document (maintains hierarchy)
109
- */
110
- private addFileToDirectory;
111
- /**
112
- * Ensure directory document exists for the given path, creating hierarchy as needed
113
- * First checks for existing shared directories before creating new ones
114
- */
115
- private ensureDirectoryDocument;
116
- /**
117
- * Remove file entry from directory document
118
- */
119
- private removeFileFromDirectory;
120
- /**
121
- * Batch-update a directory document in a single change: add new file entries,
122
- * update URLs for modified files, remove deleted entries, and update
123
- * subdirectory URLs. This replaces the separate per-file directory mutations
124
- * and the post-hoc URL update pass.
125
- */
126
- private batchUpdateDirectory;
127
- /**
128
- * Sort changes by dependency order
129
- */
130
- private sortChangesByDependency;
131
- /**
132
- * Get sync status
133
- */
134
- getStatus(): Promise<{
135
- snapshot: SyncSnapshot | null;
136
- hasChanges: boolean;
137
- changeCount: number;
138
- lastSync: Date | null;
139
- }>;
140
- /**
141
- * Preview changes without applying them
142
- */
143
- previewChanges(): Promise<{
144
- changes: DetectedChange[];
145
- moves: MoveCandidate[];
146
- summary: string;
147
- }>;
148
- /**
149
- * Generate human-readable summary of changes
150
- */
151
- private generateChangeSummary;
152
- /**
153
- * Update the lastSyncAt timestamp on the root directory document
154
- */
155
- private touchRootDirectory;
156
- }
157
- //# sourceMappingURL=sync-engine.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync-engine.d.ts","sourceRoot":"","sources":["../../src/core/sync-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,EACZ,IAAI,EAKJ,MAAM,2BAA2B,CAAA;AAElC,OAAO,EACN,YAAY,EACZ,UAAU,EAKV,aAAa,EACb,eAAe,EACf,cAAc,EACd,MAAM,mBAAmB,CAAA;AA+C1B;;GAEG;AACH,qBAAa,UAAU;IAUrB,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,QAAQ;IAVjB,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,YAAY,CAAc;IAGlC,OAAO,CAAC,aAAa,CAA6C;IAClE,OAAO,CAAC,MAAM,CAAiB;gBAGtB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,MAAM,EACxB,MAAM,EAAE,eAAe;IAaxB;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAKrB;;;OAGG;IACH,OAAO,CAAC,eAAe;IAMvB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAOtB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAOnB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAItB;;OAEG;IACG,mBAAmB,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAS3D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