pushwork 2.0.0-preview → 2.0.0-preview.3

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 (169) hide show
  1. package/dist/branches.d.ts +1 -0
  2. package/dist/branches.d.ts.map +1 -1
  3. package/dist/cli/commands.d.ts +71 -0
  4. package/dist/cli/commands.d.ts.map +1 -0
  5. package/dist/cli/commands.js +794 -0
  6. package/dist/cli/commands.js.map +1 -0
  7. package/dist/cli/index.d.ts +2 -0
  8. package/dist/cli/index.d.ts.map +1 -0
  9. package/dist/cli/index.js +19 -0
  10. package/dist/cli/index.js.map +1 -0
  11. package/dist/cli.js +67 -112
  12. package/dist/cli.js.map +1 -1
  13. package/dist/commands.d.ts +58 -0
  14. package/dist/commands.d.ts.map +1 -0
  15. package/dist/commands.js +975 -0
  16. package/dist/commands.js.map +1 -0
  17. package/dist/config/index.d.ts +71 -0
  18. package/dist/config/index.d.ts.map +1 -0
  19. package/dist/config/index.js +314 -0
  20. package/dist/config/index.js.map +1 -0
  21. package/dist/config.d.ts +1 -2
  22. package/dist/config.d.ts.map +1 -1
  23. package/dist/config.js +1 -2
  24. package/dist/config.js.map +1 -1
  25. package/dist/core/change-detection.d.ts +80 -0
  26. package/dist/core/change-detection.d.ts.map +1 -0
  27. package/dist/core/change-detection.js +560 -0
  28. package/dist/core/change-detection.js.map +1 -0
  29. package/dist/core/config.d.ts +81 -0
  30. package/dist/core/config.d.ts.map +1 -0
  31. package/dist/core/config.js +304 -0
  32. package/dist/core/config.js.map +1 -0
  33. package/dist/core/index.d.ts +6 -0
  34. package/dist/core/index.d.ts.map +1 -0
  35. package/dist/core/index.js +22 -0
  36. package/dist/core/index.js.map +1 -0
  37. package/dist/core/move-detection.d.ts +34 -0
  38. package/dist/core/move-detection.d.ts.map +1 -0
  39. package/dist/core/move-detection.js +128 -0
  40. package/dist/core/move-detection.js.map +1 -0
  41. package/dist/core/snapshot.d.ts +105 -0
  42. package/dist/core/snapshot.d.ts.map +1 -0
  43. package/dist/core/snapshot.js +254 -0
  44. package/dist/core/snapshot.js.map +1 -0
  45. package/dist/core/sync-engine.d.ts +177 -0
  46. package/dist/core/sync-engine.d.ts.map +1 -0
  47. package/dist/core/sync-engine.js +1471 -0
  48. package/dist/core/sync-engine.js.map +1 -0
  49. package/dist/index.d.ts +2 -4
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +4 -14
  52. package/dist/index.js.map +1 -1
  53. package/dist/pushwork.d.ts +28 -61
  54. package/dist/pushwork.d.ts.map +1 -1
  55. package/dist/pushwork.js +127 -445
  56. package/dist/pushwork.js.map +1 -1
  57. package/dist/shapes/types.d.ts +1 -0
  58. package/dist/shapes/types.d.ts.map +1 -1
  59. package/dist/shapes/types.js.map +1 -1
  60. package/dist/shapes/vfs.d.ts.map +1 -1
  61. package/dist/shapes/vfs.js +6 -2
  62. package/dist/shapes/vfs.js.map +1 -1
  63. package/dist/snarf.d.ts +21 -0
  64. package/dist/snarf.d.ts.map +1 -0
  65. package/dist/snarf.js +117 -0
  66. package/dist/snarf.js.map +1 -0
  67. package/dist/stash.d.ts +0 -2
  68. package/dist/stash.d.ts.map +1 -1
  69. package/dist/stash.js +0 -1
  70. package/dist/stash.js.map +1 -1
  71. package/dist/types/config.d.ts +102 -0
  72. package/dist/types/config.d.ts.map +1 -0
  73. package/dist/types/config.js +10 -0
  74. package/dist/types/config.js.map +1 -0
  75. package/dist/types/documents.d.ts +88 -0
  76. package/dist/types/documents.d.ts.map +1 -0
  77. package/dist/types/documents.js +23 -0
  78. package/dist/types/documents.js.map +1 -0
  79. package/dist/types/index.d.ts +4 -0
  80. package/dist/types/index.d.ts.map +1 -0
  81. package/dist/types/index.js +20 -0
  82. package/dist/types/index.js.map +1 -0
  83. package/dist/types/snapshot.d.ts +64 -0
  84. package/dist/types/snapshot.d.ts.map +1 -0
  85. package/dist/types/snapshot.js +3 -0
  86. package/dist/types/snapshot.js.map +1 -0
  87. package/dist/utils/content-similarity.d.ts +53 -0
  88. package/dist/utils/content-similarity.d.ts.map +1 -0
  89. package/dist/utils/content-similarity.js +155 -0
  90. package/dist/utils/content-similarity.js.map +1 -0
  91. package/dist/utils/content.d.ts +10 -0
  92. package/dist/utils/content.d.ts.map +1 -0
  93. package/dist/utils/content.js +35 -0
  94. package/dist/utils/content.js.map +1 -0
  95. package/dist/utils/directory.d.ts +24 -0
  96. package/dist/utils/directory.d.ts.map +1 -0
  97. package/dist/utils/directory.js +56 -0
  98. package/dist/utils/directory.js.map +1 -0
  99. package/dist/utils/fs.d.ts +74 -0
  100. package/dist/utils/fs.d.ts.map +1 -0
  101. package/dist/utils/fs.js +298 -0
  102. package/dist/utils/fs.js.map +1 -0
  103. package/dist/utils/index.d.ts +5 -0
  104. package/dist/utils/index.d.ts.map +1 -0
  105. package/dist/utils/index.js +21 -0
  106. package/dist/utils/index.js.map +1 -0
  107. package/dist/utils/mime-types.d.ts +13 -0
  108. package/dist/utils/mime-types.d.ts.map +1 -0
  109. package/dist/utils/mime-types.js +247 -0
  110. package/dist/utils/mime-types.js.map +1 -0
  111. package/dist/utils/network-sync.d.ts +30 -0
  112. package/dist/utils/network-sync.d.ts.map +1 -0
  113. package/dist/utils/network-sync.js +391 -0
  114. package/dist/utils/network-sync.js.map +1 -0
  115. package/dist/utils/node-polyfills.d.ts +9 -0
  116. package/dist/utils/node-polyfills.d.ts.map +1 -0
  117. package/dist/utils/node-polyfills.js +9 -0
  118. package/dist/utils/node-polyfills.js.map +1 -0
  119. package/dist/utils/output.d.ts +129 -0
  120. package/dist/utils/output.d.ts.map +1 -0
  121. package/dist/utils/output.js +375 -0
  122. package/dist/utils/output.js.map +1 -0
  123. package/dist/utils/repo-factory.d.ts +15 -0
  124. package/dist/utils/repo-factory.d.ts.map +1 -0
  125. package/dist/utils/repo-factory.js +156 -0
  126. package/dist/utils/repo-factory.js.map +1 -0
  127. package/dist/utils/string-similarity.d.ts +14 -0
  128. package/dist/utils/string-similarity.d.ts.map +1 -0
  129. package/dist/utils/string-similarity.js +43 -0
  130. package/dist/utils/string-similarity.js.map +1 -0
  131. package/dist/utils/text-diff.d.ts +37 -0
  132. package/dist/utils/text-diff.d.ts.map +1 -0
  133. package/dist/utils/text-diff.js +131 -0
  134. package/dist/utils/text-diff.js.map +1 -0
  135. package/dist/utils/trace.d.ts +19 -0
  136. package/dist/utils/trace.d.ts.map +1 -0
  137. package/dist/utils/trace.js +68 -0
  138. package/dist/utils/trace.js.map +1 -0
  139. package/dist/version.d.ts +11 -0
  140. package/dist/version.d.ts.map +1 -0
  141. package/dist/version.js +93 -0
  142. package/dist/version.js.map +1 -0
  143. package/package.json +5 -1
  144. package/.prettierrc +0 -9
  145. package/flake.lock +0 -128
  146. package/flake.nix +0 -66
  147. package/pnpm-workspace.yaml +0 -5
  148. package/src/branches.ts +0 -93
  149. package/src/cli.ts +0 -292
  150. package/src/config.ts +0 -64
  151. package/src/fs-tree.ts +0 -70
  152. package/src/ignore.ts +0 -33
  153. package/src/index.ts +0 -38
  154. package/src/log.ts +0 -8
  155. package/src/pushwork.ts +0 -1055
  156. package/src/repo.ts +0 -76
  157. package/src/shapes/custom.ts +0 -29
  158. package/src/shapes/file.ts +0 -115
  159. package/src/shapes/index.ts +0 -19
  160. package/src/shapes/patchwork-folder.ts +0 -156
  161. package/src/shapes/types.ts +0 -79
  162. package/src/shapes/vfs.ts +0 -93
  163. package/src/stash.ts +0 -106
  164. package/test/integration/branches.test.ts +0 -389
  165. package/test/integration/pushwork.test.ts +0 -547
  166. package/test/setup.ts +0 -29
  167. package/test/unit/doc-shape.test.ts +0 -612
  168. package/tsconfig.json +0 -22
  169. package/vitest.config.ts +0 -14
@@ -0,0 +1,37 @@
1
+ import * as A from "@automerge/automerge";
2
+ /**
3
+ * Read content from an Automerge document, normalizing legacy ImmutableString
4
+ * values to plain strings for backwards compatibility.
5
+ *
6
+ * Old documents may store text as ImmutableString. This helper ensures callers
7
+ * always get back `string | Uint8Array | null`.
8
+ */
9
+ export declare function readDocContent(content: unknown): string | Uint8Array | null;
10
+ /**
11
+ * Update text content on an Automerge document property inside a change
12
+ * callback.
13
+ *
14
+ * If the existing value is already a collaborative text string, we diff and
15
+ * splice for minimal CRDT operations. If the existing value is a legacy
16
+ * ImmutableString we can't splice into it, so we assign the whole string
17
+ * which converts the field to a collaborative text CRDT going forward.
18
+ *
19
+ * @param doc - The mutable Automerge document (inside a change callback)
20
+ * @param path - Property path to the text field, e.g. ["content"]
21
+ * @param newContent - The desired new text value
22
+ */
23
+ export declare function updateTextContent(doc: any, path: A.Prop[], newContent: string): void;
24
+ /**
25
+ * Apply a text diff between oldContent and newContent as Automerge splice
26
+ * operations on the given document property path.
27
+ *
28
+ * This preserves the collaborative text CRDT structure by making minimal
29
+ * character-level edits rather than replacing the entire string.
30
+ *
31
+ * @param doc - The Automerge document (inside a change callback)
32
+ * @param path - The property path to the text field, e.g. ["content"]
33
+ * @param oldContent - The previous text content
34
+ * @param newContent - The desired new text content
35
+ */
36
+ export declare function spliceText(doc: any, path: A.Prop[], oldContent: string, newContent: string): void;
37
+ //# sourceMappingURL=text-diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-diff.d.ts","sourceRoot":"","sources":["../../src/utils/text-diff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,sBAAsB,CAAA;AAGzC;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,IAAI,CAO3E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EACd,UAAU,EAAE,MAAM,GAChB,IAAI,CAeN;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACzB,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GAChB,IAAI,CA8BN"}
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.readDocContent = readDocContent;
37
+ exports.updateTextContent = updateTextContent;
38
+ exports.spliceText = spliceText;
39
+ const A = __importStar(require("@automerge/automerge"));
40
+ const diffLib = __importStar(require("diff"));
41
+ /**
42
+ * Read content from an Automerge document, normalizing legacy ImmutableString
43
+ * values to plain strings for backwards compatibility.
44
+ *
45
+ * Old documents may store text as ImmutableString. This helper ensures callers
46
+ * always get back `string | Uint8Array | null`.
47
+ */
48
+ function readDocContent(content) {
49
+ if (content == null)
50
+ return null;
51
+ if (typeof content === "string")
52
+ return content;
53
+ if (content instanceof Uint8Array)
54
+ return content;
55
+ // Legacy ImmutableString — convert to plain string
56
+ if (A.isImmutableString(content))
57
+ return content.toString();
58
+ return null;
59
+ }
60
+ /**
61
+ * Update text content on an Automerge document property inside a change
62
+ * callback.
63
+ *
64
+ * If the existing value is already a collaborative text string, we diff and
65
+ * splice for minimal CRDT operations. If the existing value is a legacy
66
+ * ImmutableString we can't splice into it, so we assign the whole string
67
+ * which converts the field to a collaborative text CRDT going forward.
68
+ *
69
+ * @param doc - The mutable Automerge document (inside a change callback)
70
+ * @param path - Property path to the text field, e.g. ["content"]
71
+ * @param newContent - The desired new text value
72
+ */
73
+ function updateTextContent(doc, path, newContent) {
74
+ const target = path.reduce((obj, key) => obj?.[key], doc);
75
+ if (typeof target === "string") {
76
+ // Already a collaborative text string — diff and splice
77
+ spliceText(doc, path, target, newContent);
78
+ }
79
+ else {
80
+ // Legacy ImmutableString, undefined, or other — assign directly.
81
+ // This converts the field to a collaborative text CRDT.
82
+ let obj = doc;
83
+ for (let i = 0; i < path.length - 1; i++) {
84
+ obj = obj[path[i]];
85
+ }
86
+ obj[path[path.length - 1]] = newContent;
87
+ }
88
+ }
89
+ /**
90
+ * Apply a text diff between oldContent and newContent as Automerge splice
91
+ * operations on the given document property path.
92
+ *
93
+ * This preserves the collaborative text CRDT structure by making minimal
94
+ * character-level edits rather than replacing the entire string.
95
+ *
96
+ * @param doc - The Automerge document (inside a change callback)
97
+ * @param path - The property path to the text field, e.g. ["content"]
98
+ * @param oldContent - The previous text content
99
+ * @param newContent - The desired new text content
100
+ */
101
+ function spliceText(doc, path, oldContent, newContent) {
102
+ if (oldContent === newContent)
103
+ return;
104
+ // Fast path: if old is empty, just insert everything
105
+ if (oldContent === "") {
106
+ A.splice(doc, path, 0, 0, newContent);
107
+ return;
108
+ }
109
+ // Fast path: if new is empty, just delete everything
110
+ if (newContent === "") {
111
+ A.splice(doc, path, 0, oldContent.length);
112
+ return;
113
+ }
114
+ const changes = diffLib.diffChars(oldContent, newContent);
115
+ let pos = 0;
116
+ for (const part of changes) {
117
+ if (part.removed) {
118
+ A.splice(doc, path, pos, part.value.length);
119
+ // Don't advance pos — text shifted left after deletion
120
+ }
121
+ else if (part.added) {
122
+ A.splice(doc, path, pos, 0, part.value);
123
+ pos += part.value.length;
124
+ }
125
+ else {
126
+ // Unchanged text — just advance the cursor
127
+ pos += part.value.length;
128
+ }
129
+ }
130
+ }
131
+ //# sourceMappingURL=text-diff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-diff.js","sourceRoot":"","sources":["../../src/utils/text-diff.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,wCAOC;AAeD,8CAmBC;AAcD,gCAmCC;AApGD,wDAAyC;AACzC,8CAA+B;AAE/B;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,OAAgB;IAC9C,IAAI,OAAO,IAAI,IAAI;QAAE,OAAO,IAAI,CAAA;IAChC,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAA;IAC/C,IAAI,OAAO,YAAY,UAAU;QAAE,OAAO,OAAO,CAAA;IACjD,mDAAmD;IACnD,IAAI,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAA;IAC3D,OAAO,IAAI,CAAA;AACZ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,iBAAiB,CAChC,GAAQ,EACR,IAAc,EACd,UAAkB;IAElB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAQ,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;IAE9D,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAChC,wDAAwD;QACxD,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM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QACxD,CAAC;aAAM,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACvB,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;YACvC,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAA;QACzB,CAAC;aAAM,CAAC;YACP,2CAA2C;YAC3C,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAA;QACzB,CAAC;IACF,CAAC;AACF,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Enable or disable tracing
3
+ */
4
+ export declare function setTracingEnabled(enabled: boolean): void;
5
+ /**
6
+ * Check if tracing is enabled
7
+ */
8
+ export declare function isTracingEnabled(): boolean;
9
+ /**
10
+ * Trace a span of work by outputting to console
11
+ * Works for both sync and async functions
12
+ * Only outputs if tracing is enabled
13
+ *
14
+ * Usage:
15
+ * await span("operation", async () => { ... })
16
+ * span("operation", () => { ... })
17
+ */
18
+ export declare function span<T>(name: string, fn: () => T | Promise<T>): T | Promise<T>;
19
+ //# sourceMappingURL=trace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/utils/trace.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAExD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAED;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,CAAC,EACpB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACvB,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAqBhB"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setTracingEnabled = setTracingEnabled;
4
+ exports.isTracingEnabled = isTracingEnabled;
5
+ exports.span = span;
6
+ const output_1 = require("./output");
7
+ /**
8
+ * Global tracing state
9
+ */
10
+ let tracingEnabled = false;
11
+ /**
12
+ * Enable or disable tracing
13
+ */
14
+ function setTracingEnabled(enabled) {
15
+ tracingEnabled = enabled;
16
+ }
17
+ /**
18
+ * Check if tracing is enabled
19
+ */
20
+ function isTracingEnabled() {
21
+ return tracingEnabled;
22
+ }
23
+ /**
24
+ * Trace a span of work by outputting to console
25
+ * Works for both sync and async functions
26
+ * Only outputs if tracing is enabled
27
+ *
28
+ * Usage:
29
+ * await span("operation", async () => { ... })
30
+ * span("operation", () => { ... })
31
+ */
32
+ function span(name, fn) {
33
+ if (!tracingEnabled) {
34
+ return fn();
35
+ }
36
+ const start = performance.now();
37
+ const result = fn();
38
+ // Check if it's a promise (async)
39
+ if (result instanceof Promise) {
40
+ return result.then((value) => {
41
+ const duration = performance.now() - start;
42
+ output_1.out.taskLine(`${name} (${formatDuration(duration)})`, true);
43
+ return value;
44
+ });
45
+ }
46
+ // Sync case
47
+ const duration = performance.now() - start;
48
+ output_1.out.taskLine(`${name} (${formatDuration(duration)})`, true);
49
+ return result;
50
+ }
51
+ /**
52
+ * Format duration for display
53
+ */
54
+ function formatDuration(ms) {
55
+ if (ms < 1) {
56
+ return `${ms.toFixed(2)}ms`;
57
+ }
58
+ else if (ms < 1000) {
59
+ return `${Math.round(ms)}ms`;
60
+ }
61
+ else if (ms < 2000) {
62
+ return `${(ms / 1000).toFixed(2)}s`;
63
+ }
64
+ else {
65
+ return `${(ms / 1000).toFixed(1)}s`;
66
+ }
67
+ }
68
+ //# sourceMappingURL=trace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace.js","sourceRoot":"","sources":["../../src/utils/trace.ts"],"names":[],"mappings":";;AAUA,8CAEC;AAKD,4CAEC;AAWD,oBAwBC;AAtDD,qCAA+B;AAE/B;;GAEG;AACH,IAAI,cAAc,GAAG,KAAK,CAAC;AAE3B;;GAEG;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CAAC;SAAM,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;QACrB,OAAO,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACtC,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACtC,CAAC;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare const versions: {
2
+ readonly pushwork: string;
3
+ readonly automerge: string;
4
+ readonly "automerge-repo": string;
5
+ readonly "automerge-subduction": string;
6
+ readonly "automerge-repo-network-websocket": string;
7
+ readonly "automerge-repo-storage-nodefs": string;
8
+ readonly node: string;
9
+ };
10
+ export declare function formatVersions(): string;
11
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AA4CA,eAAO,MAAM,QAAQ;;;;;;;;CAYX,CAAC;AAEX,wBAAgB,cAAc,IAAI,MAAM,CAOvC"}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.versions = void 0;
37
+ exports.formatVersions = formatVersions;
38
+ const fs = __importStar(require("node:fs"));
39
+ const path = __importStar(require("node:path"));
40
+ const node_module_1 = require("node:module");
41
+ const requireHere = (0, node_module_1.createRequire)(__filename);
42
+ function readVersionFromExports(spec) {
43
+ try {
44
+ const pkg = requireHere(`${spec}/package.json`);
45
+ return pkg.version;
46
+ }
47
+ catch {
48
+ return undefined;
49
+ }
50
+ }
51
+ function readVersionFromNodeModules(spec) {
52
+ let dir = __dirname;
53
+ for (let i = 0; i < 10; i++) {
54
+ const candidate = path.join(dir, "node_modules", spec, "package.json");
55
+ try {
56
+ const pkg = JSON.parse(fs.readFileSync(candidate, "utf8"));
57
+ if (pkg.version)
58
+ return pkg.version;
59
+ }
60
+ catch {
61
+ // keep walking
62
+ }
63
+ const parent = path.dirname(dir);
64
+ if (parent === dir)
65
+ break;
66
+ dir = parent;
67
+ }
68
+ return undefined;
69
+ }
70
+ function readVersion(spec) {
71
+ return (readVersionFromExports(spec) ??
72
+ readVersionFromNodeModules(spec) ??
73
+ "(missing)");
74
+ }
75
+ const ownPkg = requireHere("../package.json");
76
+ exports.versions = {
77
+ pushwork: ownPkg.version ?? "(unknown)",
78
+ automerge: readVersion("@automerge/automerge"),
79
+ "automerge-repo": readVersion("@automerge/automerge-repo"),
80
+ "automerge-subduction": readVersion("@automerge/automerge-subduction"),
81
+ "automerge-repo-network-websocket": readVersion("@automerge/automerge-repo-network-websocket"),
82
+ "automerge-repo-storage-nodefs": readVersion("@automerge/automerge-repo-storage-nodefs"),
83
+ node: process.version.replace(/^v/, ""),
84
+ };
85
+ function formatVersions() {
86
+ const max = Math.max(...Object.keys(exports.versions).map((k) => k.length));
87
+ const lines = [];
88
+ for (const [k, v] of Object.entries(exports.versions)) {
89
+ lines.push(`${k.padEnd(max)} ${v}`);
90
+ }
91
+ return lines.join("\n");
92
+ }
93
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,wCAOC;AAjED,4CAA8B;AAC9B,gDAAkC;AAClC,6CAA4C;AAE5C,MAAM,WAAW,GAAG,IAAA,2BAAa,EAAC,UAAU,CAAC,CAAC;AAE9C,SAAS,sBAAsB,CAAC,IAAY;IAC3C,IAAI,CAAC;QACJ,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,IAAI,eAAe,CAAyB,CAAC;QACxE,OAAO,GAAG,CAAC,OAAO,CAAC;IACpB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC;AAED,SAAS,0BAA0B,CAAC,IAAY;IAC/C,IAAI,GAAG,GAAG,SAAS,CAAC;IACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;QACvE,IAAI,CAAC;YACJ,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAExD,CAAC;YACF,IAAI,GAAG,CAAC,OAAO;gBAAE,OAAO,GAAG,CAAC,OAAO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MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pushwork",
3
- "version": "2.0.0-preview",
3
+ "version": "2.0.0-preview.3",
4
4
  "description": "Bidirectional directory synchronization using Automerge CRDTs",
5
5
  "main": "dist/index.js",
6
6
  "exports": {
@@ -22,6 +22,10 @@
22
22
  ],
23
23
  "author": "Peter van Hardenberg",
24
24
  "license": "MIT",
25
+ "files": [
26
+ "dist",
27
+ "patches"
28
+ ],
25
29
  "dependencies": {
26
30
  "@automerge/automerge": "^3.2.6",
27
31
  "@automerge/automerge-repo": "2.6.0-subduction.15",
package/.prettierrc DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "useTabs": true,
3
- "printWidth": 80,
4
- "semi": false,
5
- "bracketSpacing": false,
6
- "trailingComma": "es5",
7
- "arrowParens": "avoid",
8
- "objectWrap": "collapse"
9
- }
package/flake.lock DELETED
@@ -1,128 +0,0 @@
1
- {
2
- "nodes": {
3
- "command-utils": {
4
- "inputs": {
5
- "flake-utils": "flake-utils",
6
- "nixpkgs": "nixpkgs"
7
- },
8
- "locked": {
9
- "lastModified": 1769220798,
10
- "narHash": "sha256-ulD8bbh5eV4rUH61JC4gS8Ik0R2hBEEyCom3f8w2vXE=",
11
- "ref": "refs/heads/main",
12
- "rev": "6c72a70e0241a5af26ba664ab63f3e2d89c45cd0",
13
- "revCount": 5,
14
- "type": "git",
15
- "url": "https://codeberg.org/expede/nix-command-utils"
16
- },
17
- "original": {
18
- "type": "git",
19
- "url": "https://codeberg.org/expede/nix-command-utils"
20
- }
21
- },
22
- "flake-utils": {
23
- "inputs": {
24
- "systems": "systems"
25
- },
26
- "locked": {
27
- "lastModified": 1709126324,
28
- "narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=",
29
- "owner": "numtide",
30
- "repo": "flake-utils",
31
- "rev": "d465f4819400de7c8d874d50b982301f28a84605",
32
- "type": "github"
33
- },
34
- "original": {
35
- "id": "flake-utils",
36
- "type": "indirect"
37
- }
38
- },
39
- "flake-utils_2": {
40
- "inputs": {
41
- "systems": "systems_2"
42
- },
43
- "locked": {
44
- "lastModified": 1731533236,
45
- "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
46
- "owner": "numtide",
47
- "repo": "flake-utils",
48
- "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
49
- "type": "github"
50
- },
51
- "original": {
52
- "owner": "numtide",
53
- "repo": "flake-utils",
54
- "type": "github"
55
- }
56
- },
57
- "nixpkgs": {
58
- "locked": {
59
- "lastModified": 1769089682,
60
- "narHash": "sha256-9yA/LIuAVQq0lXelrZPjLuLVuZdm03p8tfmHhnDIkms=",
61
- "owner": "NixOS",
62
- "repo": "nixpkgs",
63
- "rev": "078d69f03934859a181e81ba987c2bb033eebfc5",
64
- "type": "github"
65
- },
66
- "original": {
67
- "id": "nixpkgs",
68
- "ref": "nixos-25.11",
69
- "type": "indirect"
70
- }
71
- },
72
- "nixpkgs_2": {
73
- "locked": {
74
- "lastModified": 1775002709,
75
- "narHash": "sha256-d3Yx83vSrN+2z/loBh4mJpyRqr9aAJqlke4TkpFmRJA=",
76
- "owner": "nixos",
77
- "repo": "nixpkgs",
78
- "rev": "bcd464ccd2a1a7cd09aa2f8d4ffba83b761b1d0e",
79
- "type": "github"
80
- },
81
- "original": {
82
- "owner": "nixos",
83
- "ref": "nixos-25.11",
84
- "repo": "nixpkgs",
85
- "type": "github"
86
- }
87
- },
88
- "root": {
89
- "inputs": {
90
- "command-utils": "command-utils",
91
- "flake-utils": "flake-utils_2",
92
- "nixpkgs": "nixpkgs_2"
93
- }
94
- },
95
- "systems": {
96
- "locked": {
97
- "lastModified": 1681028828,
98
- "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
99
- "owner": "nix-systems",
100
- "repo": "default",
101
- "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
102
- "type": "github"
103
- },
104
- "original": {
105
- "owner": "nix-systems",
106
- "repo": "default",
107
- "type": "github"
108
- }
109
- },
110
- "systems_2": {
111
- "locked": {
112
- "lastModified": 1681028828,
113
- "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
114
- "owner": "nix-systems",
115
- "repo": "default",
116
- "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
117
- "type": "github"
118
- },
119
- "original": {
120
- "owner": "nix-systems",
121
- "repo": "default",
122
- "type": "github"
123
- }
124
- }
125
- },
126
- "root": "root",
127
- "version": 7
128
- }
package/flake.nix DELETED
@@ -1,66 +0,0 @@
1
- {
2
- description = "Pushwork: Bidirectional directory synchronization using Automerge CRDTs";
3
-
4
- inputs = {
5
- command-utils.url = "git+https://codeberg.org/expede/nix-command-utils";
6
- flake-utils.url = "github:numtide/flake-utils";
7
- nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
8
- };
9
-
10
- outputs = {
11
- self,
12
- command-utils,
13
- flake-utils,
14
- nixpkgs,
15
- }:
16
- flake-utils.lib.eachDefaultSystem (system: let
17
- pkgs = import nixpkgs {inherit system;};
18
-
19
- nodejs = pkgs.nodejs_24;
20
- pnpm-pkg = pkgs.pnpm;
21
- pnpm' = "${pnpm-pkg}/bin/pnpm";
22
-
23
- asModule = command-utils.asModule.${system};
24
- cmd = command-utils.cmd.${system};
25
- pnpm = command-utils.pnpm.${system};
26
-
27
- pnpm-cfg = {pnpm = pnpm';};
28
-
29
- menu =
30
- command-utils.commands.${system}
31
- [
32
- (pnpm.build pnpm-cfg)
33
- (pnpm.dev pnpm-cfg)
34
- (pnpm.install pnpm-cfg)
35
- (pnpm.lint pnpm-cfg)
36
- (pnpm.test pnpm-cfg)
37
- (pnpm.typecheck pnpm-cfg)
38
- (asModule {
39
- "clean" = cmd "Remove dist and node_modules" "rm -rf dist node_modules";
40
- "start" = cmd "Run pushwork CLI" "node dist/cli.js \"$@\"";
41
- "sync" = cmd "Build and run sync" "${pnpm'} build && node dist/cli.js sync \"$@\"";
42
- "watch" = cmd "Watch, build, and sync loop" "node dist/cli.js watch \"$@\"";
43
- })
44
- ];
45
- in {
46
- devShells.default = pkgs.mkShell {
47
- name = "Pushwork Dev Shell";
48
-
49
- nativeBuildInputs =
50
- [
51
- nodejs
52
- pkgs.nodePackages.vscode-langservers-extracted
53
- pkgs.typescript
54
- pkgs.typescript-language-server
55
- pnpm-pkg
56
- ]
57
- ++ menu;
58
-
59
- shellHook = ''
60
- menu
61
- '';
62
- };
63
-
64
- formatter = pkgs.alejandra;
65
- });
66
- }
@@ -1,5 +0,0 @@
1
- allowBuilds:
2
- cbor-extract: true
3
- esbuild: true
4
- patchedDependencies:
5
- '@automerge/automerge-repo@2.6.0-subduction.15': patches/@automerge__automerge-repo@2.6.0-subduction.15.patch