pushwork 1.1.4 → 2.0.0-a.sub.1

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 (100) hide show
  1. package/CLAUDE.md +9 -5
  2. package/dist/cli.js +48 -55
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands.d.ts +5 -1
  5. package/dist/commands.d.ts.map +1 -1
  6. package/dist/commands.js +262 -263
  7. package/dist/commands.js.map +1 -1
  8. package/dist/core/change-detection.d.ts +1 -1
  9. package/dist/core/change-detection.d.ts.map +1 -1
  10. package/dist/core/change-detection.js +66 -103
  11. package/dist/core/change-detection.js.map +1 -1
  12. package/dist/core/config.d.ts +1 -1
  13. package/dist/core/config.d.ts.map +1 -1
  14. package/dist/core/config.js +14 -57
  15. package/dist/core/config.js.map +1 -1
  16. package/dist/core/index.d.ts +5 -5
  17. package/dist/core/index.d.ts.map +1 -1
  18. package/dist/core/index.js +5 -21
  19. package/dist/core/index.js.map +1 -1
  20. package/dist/core/move-detection.d.ts +2 -2
  21. package/dist/core/move-detection.d.ts.map +1 -1
  22. package/dist/core/move-detection.js +9 -13
  23. package/dist/core/move-detection.js.map +1 -1
  24. package/dist/core/snapshot.d.ts +1 -1
  25. package/dist/core/snapshot.d.ts.map +1 -1
  26. package/dist/core/snapshot.js +9 -46
  27. package/dist/core/snapshot.js.map +1 -1
  28. package/dist/core/sync-engine.d.ts +8 -2
  29. package/dist/core/sync-engine.d.ts.map +1 -1
  30. package/dist/core/sync-engine.js +171 -175
  31. package/dist/core/sync-engine.js.map +1 -1
  32. package/dist/index.d.ts +4 -4
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +4 -20
  35. package/dist/index.js.map +1 -1
  36. package/dist/types/config.d.ts +7 -6
  37. package/dist/types/config.d.ts.map +1 -1
  38. package/dist/types/config.js +1 -5
  39. package/dist/types/config.js.map +1 -1
  40. package/dist/types/documents.js +4 -7
  41. package/dist/types/documents.js.map +1 -1
  42. package/dist/types/index.d.ts +3 -3
  43. package/dist/types/index.d.ts.map +1 -1
  44. package/dist/types/index.js +3 -19
  45. package/dist/types/index.js.map +1 -1
  46. package/dist/types/snapshot.js +1 -2
  47. package/dist/utils/content.js +4 -8
  48. package/dist/utils/content.js.map +1 -1
  49. package/dist/utils/directory.js +5 -9
  50. package/dist/utils/directory.js.map +1 -1
  51. package/dist/utils/fs.d.ts +1 -1
  52. package/dist/utils/fs.d.ts.map +1 -1
  53. package/dist/utils/fs.js +34 -84
  54. package/dist/utils/fs.js.map +1 -1
  55. package/dist/utils/index.d.ts +4 -4
  56. package/dist/utils/index.d.ts.map +1 -1
  57. package/dist/utils/index.js +4 -20
  58. package/dist/utils/index.js.map +1 -1
  59. package/dist/utils/mime-types.js +5 -43
  60. package/dist/utils/mime-types.js.map +1 -1
  61. package/dist/utils/network-sync.d.ts +13 -8
  62. package/dist/utils/network-sync.d.ts.map +1 -1
  63. package/dist/utils/network-sync.js +65 -137
  64. package/dist/utils/network-sync.js.map +1 -1
  65. package/dist/utils/node-polyfills.d.ts +9 -0
  66. package/dist/utils/node-polyfills.d.ts.map +1 -0
  67. package/dist/utils/node-polyfills.js +9 -0
  68. package/dist/utils/node-polyfills.js.map +1 -0
  69. package/dist/utils/output.js +32 -39
  70. package/dist/utils/output.js.map +1 -1
  71. package/dist/utils/repo-factory.d.ts +8 -2
  72. package/dist/utils/repo-factory.d.ts.map +1 -1
  73. package/dist/utils/repo-factory.js +38 -47
  74. package/dist/utils/repo-factory.js.map +1 -1
  75. package/dist/utils/string-similarity.js +1 -5
  76. package/dist/utils/string-similarity.js.map +1 -1
  77. package/dist/utils/text-diff.js +5 -43
  78. package/dist/utils/text-diff.js.map +1 -1
  79. package/dist/utils/trace.js +6 -11
  80. package/dist/utils/trace.js.map +1 -1
  81. package/package.json +7 -5
  82. package/src/cli.ts +25 -34
  83. package/src/commands.ts +75 -11
  84. package/src/core/change-detection.ts +4 -4
  85. package/src/core/config.ts +2 -12
  86. package/src/core/index.ts +5 -5
  87. package/src/core/move-detection.ts +4 -4
  88. package/src/core/snapshot.ts +3 -3
  89. package/src/core/sync-engine.ts +82 -50
  90. package/src/index.ts +4 -4
  91. package/src/types/config.ts +8 -8
  92. package/src/types/index.ts +3 -3
  93. package/src/utils/directory.ts +1 -1
  94. package/src/utils/fs.ts +6 -4
  95. package/src/utils/index.ts +4 -4
  96. package/src/utils/network-sync.ts +62 -115
  97. package/src/utils/node-polyfills.ts +8 -0
  98. package/src/utils/repo-factory.ts +55 -10
  99. package/src/utils/trace.ts +1 -1
  100. package/tsconfig.json +2 -1
@@ -1,28 +1,73 @@
1
+ import "./node-polyfills.js";
1
2
  import { Repo } from "@automerge/automerge-repo";
2
3
  import { NodeFSStorageAdapter } from "@automerge/automerge-repo-storage-nodefs";
3
- import { BrowserWebSocketClientAdapter } from "@automerge/automerge-repo-network-websocket";
4
+ import * as subductionModule from "@automerge/automerge-subduction";
5
+ import {
6
+ initSubductionModule,
7
+ SubductionStorageBridge,
8
+ } from "@automerge/automerge-repo-subduction-bridge";
4
9
  import * as path from "path";
5
- import { DirectoryConfig } from "../types";
10
+ import * as os from "os";
11
+ import { DirectoryConfig } from "../types/index.js";
12
+
13
+ const { WebCryptoSigner, Subduction } = subductionModule;
14
+
15
+ let subductionModuleInitialized = false;
16
+
17
+ function ensureSubductionModuleInit() {
18
+ if (!subductionModuleInitialized) {
19
+ initSubductionModule(subductionModule);
20
+ subductionModuleInitialized = true;
21
+ }
22
+ }
6
23
 
7
24
  /**
8
- * Create an Automerge repository with configuration-based setup
25
+ * Create an Automerge repository with Subduction-based setup
9
26
  */
10
27
  export async function createRepo(
11
28
  workingDir: string,
12
29
  config: DirectoryConfig
13
30
  ): Promise<Repo> {
31
+ ensureSubductionModuleInit();
32
+
14
33
  const syncToolDir = path.join(workingDir, ".pushwork");
15
- const storage = new NodeFSStorageAdapter(path.join(syncToolDir, "automerge"));
34
+ const nodeStorage = new NodeFSStorageAdapter(path.join(syncToolDir, "automerge"));
16
35
 
17
- const repoConfig: any = { storage };
36
+ const signer = await WebCryptoSigner.setup();
37
+ const storageBridge = new SubductionStorageBridge(nodeStorage);
38
+ const subduction = await Subduction.hydrate(signer, storageBridge);
18
39
 
19
- // Add network adapter only if sync is enabled and server is configured
40
+ // Connect to sync server if sync is enabled
20
41
  if (config.sync_enabled && config.sync_server) {
21
- const networkAdapter = new BrowserWebSocketClientAdapter(
22
- config.sync_server
42
+ await subduction.connectDiscover(
43
+ new URL(config.sync_server),
44
+ signer
23
45
  );
24
- repoConfig.network = [networkAdapter];
25
46
  }
26
47
 
27
- return new Repo(repoConfig);
48
+ return new Repo({ subduction } as any);
49
+ }
50
+
51
+ /**
52
+ * Create an ephemeral Automerge repository for remote reads.
53
+ * Uses a temporary directory for storage.
54
+ */
55
+ export async function createEphemeralRepo(
56
+ syncServer: string
57
+ ): Promise<Repo> {
58
+ ensureSubductionModuleInit();
59
+
60
+ const tmpDir = path.join(os.tmpdir(), `pushwork-ephemeral-${Date.now()}`);
61
+ const nodeStorage = new NodeFSStorageAdapter(tmpDir);
62
+
63
+ const signer = await WebCryptoSigner.setup();
64
+ const storageBridge = new SubductionStorageBridge(nodeStorage);
65
+ const subduction = await Subduction.hydrate(signer, storageBridge);
66
+
67
+ await subduction.connectDiscover(
68
+ new URL(syncServer),
69
+ signer
70
+ );
71
+
72
+ return new Repo({ subduction } as any);
28
73
  }
@@ -1,4 +1,4 @@
1
- import { out } from "./output";
1
+ import { out } from "./output.js";
2
2
 
3
3
  /**
4
4
  * Global tracing state
package/tsconfig.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ES2020",
4
- "module": "commonjs",
4
+ "module": "nodenext",
5
+ "moduleResolution": "nodenext",
5
6
  "lib": ["ES2020"],
6
7
  "outDir": "./dist",
7
8
  "rootDir": "./src",