pushwork 1.0.4 → 1.0.7
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.
- package/README.md +87 -328
- package/dist/.pushwork/automerge/3P/Dm3ekE2pmjGnWvDaG3vSR7ww98/snapshot/aa2349c94955ea561f698720142f9d884a6872d9f82dc332d578c216beb0df0e +0 -0
- package/dist/.pushwork/automerge/st/orage-adapter-id +1 -0
- package/dist/.pushwork/config.json +15 -0
- package/dist/.pushwork/snapshot.json +7 -0
- package/dist/cli.js +231 -170
- package/dist/cli.js.map +1 -1
- package/dist/commands.d.ts +51 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +799 -0
- package/dist/commands.js.map +1 -0
- package/dist/core/change-detection.d.ts +6 -19
- package/dist/core/change-detection.d.ts.map +1 -1
- package/dist/core/change-detection.js +101 -80
- package/dist/core/change-detection.js.map +1 -1
- package/dist/{config/index.d.ts → core/config.d.ts} +13 -3
- package/dist/core/config.d.ts.map +1 -0
- package/dist/{config/index.js → core/config.js} +55 -73
- package/dist/core/config.js.map +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/move-detection.d.ts +12 -50
- package/dist/core/move-detection.d.ts.map +1 -1
- package/dist/core/move-detection.js +58 -139
- package/dist/core/move-detection.js.map +1 -1
- package/dist/core/snapshot.d.ts +0 -4
- package/dist/core/snapshot.d.ts.map +1 -1
- package/dist/core/snapshot.js +2 -11
- package/dist/core/snapshot.js.map +1 -1
- package/dist/core/sync-engine.d.ts +5 -11
- package/dist/core/sync-engine.d.ts.map +1 -1
- package/dist/core/sync-engine.js +220 -362
- package/dist/core/sync-engine.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -6
- package/dist/index.js.map +1 -1
- package/dist/types/config.d.ts +43 -67
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +6 -0
- package/dist/types/config.js.map +1 -1
- package/dist/types/documents.d.ts +15 -3
- package/dist/types/documents.d.ts.map +1 -1
- package/dist/types/documents.js.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -3
- package/dist/types/index.js.map +1 -1
- package/dist/types/snapshot.d.ts +3 -21
- package/dist/types/snapshot.d.ts.map +1 -1
- package/dist/types/snapshot.js +0 -14
- package/dist/types/snapshot.js.map +1 -1
- package/dist/utils/content.d.ts.map +1 -1
- package/dist/utils/content.js +2 -6
- package/dist/utils/content.js.map +1 -1
- package/dist/utils/directory.d.ts +10 -0
- package/dist/utils/directory.d.ts.map +1 -0
- package/dist/utils/directory.js +37 -0
- package/dist/utils/directory.js.map +1 -0
- package/dist/utils/fs.d.ts +15 -2
- package/dist/utils/fs.d.ts.map +1 -1
- package/dist/utils/fs.js +63 -53
- package/dist/utils/fs.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -4
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/mime-types.d.ts.map +1 -1
- package/dist/utils/mime-types.js +11 -4
- package/dist/utils/mime-types.js.map +1 -1
- package/dist/utils/network-sync.d.ts +0 -6
- package/dist/utils/network-sync.d.ts.map +1 -1
- package/dist/utils/network-sync.js +55 -99
- package/dist/utils/network-sync.js.map +1 -1
- package/dist/utils/output.d.ts +129 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +375 -0
- package/dist/utils/output.js.map +1 -0
- package/dist/utils/repo-factory.d.ts +2 -6
- package/dist/utils/repo-factory.d.ts.map +1 -1
- package/dist/utils/repo-factory.js +8 -22
- package/dist/utils/repo-factory.js.map +1 -1
- package/dist/utils/string-similarity.d.ts +14 -0
- package/dist/utils/string-similarity.d.ts.map +1 -0
- package/dist/utils/string-similarity.js +43 -0
- package/dist/utils/string-similarity.js.map +1 -0
- package/dist/utils/trace.d.ts +19 -0
- package/dist/utils/trace.d.ts.map +1 -0
- package/dist/utils/trace.js +68 -0
- package/dist/utils/trace.js.map +1 -0
- package/package.json +17 -12
- package/src/cli.ts +326 -252
- package/src/commands.ts +988 -0
- package/src/core/change-detection.ts +199 -162
- package/src/{config/index.ts → core/config.ts} +65 -82
- package/src/core/index.ts +1 -1
- package/src/core/move-detection.ts +74 -180
- package/src/core/snapshot.ts +2 -12
- package/src/core/sync-engine.ts +248 -499
- package/src/index.ts +0 -10
- package/src/types/config.ts +50 -72
- package/src/types/documents.ts +16 -3
- package/src/types/index.ts +0 -5
- package/src/types/snapshot.ts +1 -23
- package/src/utils/content.ts +2 -6
- package/src/utils/directory.ts +50 -0
- package/src/utils/fs.ts +67 -56
- package/src/utils/index.ts +1 -6
- package/src/utils/mime-types.ts +12 -4
- package/src/utils/network-sync.ts +79 -137
- package/src/utils/output.ts +450 -0
- package/src/utils/repo-factory.ts +13 -31
- package/src/utils/string-similarity.ts +54 -0
- package/src/utils/trace.ts +70 -0
- package/test/integration/exclude-patterns.test.ts +6 -15
- package/test/integration/fuzzer.test.ts +308 -391
- package/test/integration/init-sync.test.ts +89 -0
- package/test/integration/sync-deletion.test.ts +2 -61
- package/test/integration/sync-flow.test.ts +4 -24
- package/test/jest.setup.ts +34 -0
- package/test/unit/deletion-behavior.test.ts +3 -14
- package/test/unit/enhanced-mime-detection.test.ts +0 -22
- package/test/unit/snapshot.test.ts +2 -29
- package/test/unit/sync-convergence.test.ts +3 -198
- package/test/unit/sync-timing.test.ts +0 -44
- package/test/unit/utils.test.ts +0 -2
- package/tsconfig.json +3 -3
- package/dist/browser/browser-sync-engine.d.ts +0 -64
- package/dist/browser/browser-sync-engine.d.ts.map +0 -1
- package/dist/browser/browser-sync-engine.js +0 -303
- package/dist/browser/browser-sync-engine.js.map +0 -1
- package/dist/browser/filesystem-adapter.d.ts +0 -84
- package/dist/browser/filesystem-adapter.d.ts.map +0 -1
- package/dist/browser/filesystem-adapter.js +0 -413
- package/dist/browser/filesystem-adapter.js.map +0 -1
- package/dist/browser/index.d.ts +0 -36
- package/dist/browser/index.d.ts.map +0 -1
- package/dist/browser/index.js +0 -90
- package/dist/browser/index.js.map +0 -1
- package/dist/browser/types.d.ts +0 -70
- package/dist/browser/types.d.ts.map +0 -1
- package/dist/browser/types.js +0 -6
- package/dist/browser/types.js.map +0 -1
- package/dist/cli/commands.d.ts +0 -77
- package/dist/cli/commands.d.ts.map +0 -1
- package/dist/cli/commands.js +0 -904
- package/dist/cli/commands.js.map +0 -1
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -19
- package/dist/cli/index.js.map +0 -1
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js.map +0 -1
- package/dist/core/isomorphic-snapshot.d.ts +0 -58
- package/dist/core/isomorphic-snapshot.d.ts.map +0 -1
- package/dist/core/isomorphic-snapshot.js +0 -204
- package/dist/core/isomorphic-snapshot.js.map +0 -1
- package/dist/platform/browser-filesystem.d.ts +0 -26
- package/dist/platform/browser-filesystem.d.ts.map +0 -1
- package/dist/platform/browser-filesystem.js +0 -91
- package/dist/platform/browser-filesystem.js.map +0 -1
- package/dist/platform/filesystem.d.ts +0 -29
- package/dist/platform/filesystem.d.ts.map +0 -1
- package/dist/platform/filesystem.js +0 -65
- package/dist/platform/filesystem.js.map +0 -1
- package/dist/platform/node-filesystem.d.ts +0 -21
- package/dist/platform/node-filesystem.d.ts.map +0 -1
- package/dist/platform/node-filesystem.js +0 -93
- package/dist/platform/node-filesystem.js.map +0 -1
- package/dist/utils/content-similarity.d.ts +0 -53
- package/dist/utils/content-similarity.d.ts.map +0 -1
- package/dist/utils/content-similarity.js +0 -155
- package/dist/utils/content-similarity.js.map +0 -1
- package/dist/utils/fs-browser.d.ts +0 -57
- package/dist/utils/fs-browser.d.ts.map +0 -1
- package/dist/utils/fs-browser.js +0 -311
- package/dist/utils/fs-browser.js.map +0 -1
- package/dist/utils/fs-node.d.ts +0 -53
- package/dist/utils/fs-node.d.ts.map +0 -1
- package/dist/utils/fs-node.js +0 -220
- package/dist/utils/fs-node.js.map +0 -1
- package/dist/utils/isomorphic.d.ts +0 -29
- package/dist/utils/isomorphic.d.ts.map +0 -1
- package/dist/utils/isomorphic.js +0 -139
- package/dist/utils/isomorphic.js.map +0 -1
- package/dist/utils/pure.d.ts +0 -25
- package/dist/utils/pure.d.ts.map +0 -1
- package/dist/utils/pure.js +0 -112
- package/dist/utils/pure.js.map +0 -1
- package/src/cli/commands.ts +0 -1207
- package/src/cli/index.ts +0 -2
- package/src/utils/content-similarity.ts +0 -194
- package/test/README-TESTING-GAPS.md +0 -174
- package/test/unit/content-similarity.test.ts +0 -236
|
@@ -37,6 +37,7 @@ exports.ConfigManager = void 0;
|
|
|
37
37
|
const fs = __importStar(require("fs/promises"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
39
|
const os = __importStar(require("os"));
|
|
40
|
+
const types_1 = require("../types");
|
|
40
41
|
const utils_1 = require("../utils");
|
|
41
42
|
/**
|
|
42
43
|
* Configuration manager for pushwork
|
|
@@ -58,7 +59,7 @@ class ConfigManager {
|
|
|
58
59
|
if (!this.workingDir) {
|
|
59
60
|
throw new Error("Working directory not set for local config");
|
|
60
61
|
}
|
|
61
|
-
return path.join(this.workingDir, ConfigManager.
|
|
62
|
+
return path.join(this.workingDir, ConfigManager.CONFIG_DIR, ConfigManager.CONFIG_FILENAME);
|
|
62
63
|
}
|
|
63
64
|
/**
|
|
64
65
|
* Load global configuration
|
|
@@ -73,7 +74,7 @@ class ConfigManager {
|
|
|
73
74
|
return JSON.parse(content);
|
|
74
75
|
}
|
|
75
76
|
catch (error) {
|
|
76
|
-
|
|
77
|
+
// Failed to load global config
|
|
77
78
|
return null;
|
|
78
79
|
}
|
|
79
80
|
}
|
|
@@ -107,7 +108,7 @@ class ConfigManager {
|
|
|
107
108
|
return JSON.parse(content);
|
|
108
109
|
}
|
|
109
110
|
catch (error) {
|
|
110
|
-
|
|
111
|
+
// Failed to load local config
|
|
111
112
|
return null;
|
|
112
113
|
}
|
|
113
114
|
}
|
|
@@ -128,32 +129,50 @@ class ConfigManager {
|
|
|
128
129
|
throw new Error(`Failed to save local config: ${error}`);
|
|
129
130
|
}
|
|
130
131
|
}
|
|
132
|
+
getDefaultGlobalConfig() {
|
|
133
|
+
return {
|
|
134
|
+
exclude_patterns: [
|
|
135
|
+
".git",
|
|
136
|
+
"node_modules",
|
|
137
|
+
"*.tmp",
|
|
138
|
+
".DS_Store",
|
|
139
|
+
".pushwork",
|
|
140
|
+
],
|
|
141
|
+
sync_server: types_1.DEFAULT_SYNC_SERVER,
|
|
142
|
+
sync_server_storage_id: types_1.DEFAULT_SYNC_SERVER_STORAGE_ID,
|
|
143
|
+
sync: {
|
|
144
|
+
move_detection_threshold: 0.7,
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
}
|
|
131
148
|
/**
|
|
132
|
-
* Get
|
|
149
|
+
* Get default configuration
|
|
133
150
|
*/
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const localConfig = await this.load();
|
|
137
|
-
// Create default configuration
|
|
138
|
-
const defaultConfig = {
|
|
151
|
+
getDefaultConfig() {
|
|
152
|
+
return {
|
|
139
153
|
sync_enabled: true,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
154
|
+
sync_server: types_1.DEFAULT_SYNC_SERVER,
|
|
155
|
+
sync_server_storage_id: types_1.DEFAULT_SYNC_SERVER_STORAGE_ID,
|
|
156
|
+
exclude_patterns: [
|
|
157
|
+
".git",
|
|
158
|
+
"node_modules",
|
|
159
|
+
"*.tmp",
|
|
160
|
+
".pushwork",
|
|
161
|
+
".DS_Store",
|
|
162
|
+
],
|
|
148
163
|
sync: {
|
|
149
|
-
move_detection_threshold: 0.
|
|
150
|
-
prompt_threshold: 0.5,
|
|
151
|
-
auto_sync: false,
|
|
152
|
-
parallel_operations: 4,
|
|
164
|
+
move_detection_threshold: 0.7,
|
|
153
165
|
},
|
|
154
166
|
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Get merged configuration (global + local)
|
|
170
|
+
*/
|
|
171
|
+
async getMerged() {
|
|
172
|
+
const globalConfig = await this.loadGlobal();
|
|
173
|
+
const localConfig = await this.load();
|
|
155
174
|
// Merge configurations: default < global < local
|
|
156
|
-
let merged =
|
|
175
|
+
let merged = this.getDefaultConfig();
|
|
157
176
|
if (globalConfig) {
|
|
158
177
|
merged = this.mergeConfigs(merged, globalConfig);
|
|
159
178
|
}
|
|
@@ -162,6 +181,15 @@ class ConfigManager {
|
|
|
162
181
|
}
|
|
163
182
|
return merged;
|
|
164
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Initialize with CLI option overrides
|
|
186
|
+
* Creates a new config with defaults + CLI overrides and saves it
|
|
187
|
+
*/
|
|
188
|
+
async initializeWithOverrides(overrides = {}) {
|
|
189
|
+
const config = this.mergeConfigs(this.getDefaultConfig(), overrides);
|
|
190
|
+
await this.save(config);
|
|
191
|
+
return config;
|
|
192
|
+
}
|
|
165
193
|
/**
|
|
166
194
|
* Merge two configuration objects
|
|
167
195
|
*/
|
|
@@ -179,22 +207,7 @@ class ConfigManager {
|
|
|
179
207
|
}
|
|
180
208
|
// Handle GlobalConfig structure
|
|
181
209
|
if ("exclude_patterns" in override && override.exclude_patterns) {
|
|
182
|
-
merged.
|
|
183
|
-
}
|
|
184
|
-
if ("large_file_threshold" in override && override.large_file_threshold) {
|
|
185
|
-
merged.defaults.large_file_threshold = override.large_file_threshold;
|
|
186
|
-
}
|
|
187
|
-
// Handle DirectoryConfig structure
|
|
188
|
-
if ("defaults" in override && override.defaults) {
|
|
189
|
-
merged.defaults = { ...merged.defaults, ...override.defaults };
|
|
190
|
-
}
|
|
191
|
-
if ("diff" in override && override.diff) {
|
|
192
|
-
// Merge diff settings, ensuring show_binary has a default
|
|
193
|
-
merged.diff = {
|
|
194
|
-
...merged.diff,
|
|
195
|
-
...override.diff,
|
|
196
|
-
show_binary: override.diff.show_binary ?? merged.diff.show_binary,
|
|
197
|
-
};
|
|
210
|
+
merged.exclude_patterns = override.exclude_patterns;
|
|
198
211
|
}
|
|
199
212
|
if ("sync" in override && override.sync) {
|
|
200
213
|
merged.sync = { ...merged.sync, ...override.sync };
|
|
@@ -205,27 +218,7 @@ class ConfigManager {
|
|
|
205
218
|
* Create default global configuration
|
|
206
219
|
*/
|
|
207
220
|
async createDefaultGlobal() {
|
|
208
|
-
const defaultGlobal =
|
|
209
|
-
exclude_patterns: [
|
|
210
|
-
".git",
|
|
211
|
-
"node_modules",
|
|
212
|
-
"*.tmp",
|
|
213
|
-
".DS_Store",
|
|
214
|
-
".pushwork",
|
|
215
|
-
],
|
|
216
|
-
large_file_threshold: "100MB",
|
|
217
|
-
sync_server: "wss://sync3.automerge.org",
|
|
218
|
-
sync_server_storage_id: "3760df37-a4c6-4f66-9ecd-732039a9385d",
|
|
219
|
-
diff: {
|
|
220
|
-
show_binary: false,
|
|
221
|
-
},
|
|
222
|
-
sync: {
|
|
223
|
-
move_detection_threshold: 0.8,
|
|
224
|
-
prompt_threshold: 0.5,
|
|
225
|
-
auto_sync: false,
|
|
226
|
-
parallel_operations: 4,
|
|
227
|
-
},
|
|
228
|
-
};
|
|
221
|
+
const defaultGlobal = this.getDefaultGlobalConfig();
|
|
229
222
|
await this.saveGlobal(defaultGlobal);
|
|
230
223
|
}
|
|
231
224
|
/**
|
|
@@ -243,7 +236,7 @@ class ConfigManager {
|
|
|
243
236
|
return await (0, utils_1.pathExists)(this.getLocalConfigPath());
|
|
244
237
|
}
|
|
245
238
|
/**
|
|
246
|
-
* Get configuration value by path (e.g., 'sync.
|
|
239
|
+
* Get configuration value by path (e.g., 'sync.move_detection_threshold')
|
|
247
240
|
*/
|
|
248
241
|
async getValue(keyPath) {
|
|
249
242
|
const config = await this.getMerged();
|
|
@@ -290,17 +283,6 @@ class ConfigManager {
|
|
|
290
283
|
errors.push("move_detection_threshold must be between 0 and 1");
|
|
291
284
|
}
|
|
292
285
|
}
|
|
293
|
-
if (config.sync?.prompt_threshold !== undefined) {
|
|
294
|
-
if (config.sync.prompt_threshold < 0 ||
|
|
295
|
-
config.sync.prompt_threshold > 1) {
|
|
296
|
-
errors.push("prompt_threshold must be between 0 and 1");
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
if (config.sync?.parallel_operations !== undefined) {
|
|
300
|
-
if (config.sync.parallel_operations < 1) {
|
|
301
|
-
errors.push("parallel_operations must be at least 1");
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
286
|
return {
|
|
305
287
|
valid: errors.length === 0,
|
|
306
288
|
errors,
|
|
@@ -310,5 +292,5 @@ class ConfigManager {
|
|
|
310
292
|
exports.ConfigManager = ConfigManager;
|
|
311
293
|
ConfigManager.GLOBAL_CONFIG_DIR = ".pushwork";
|
|
312
294
|
ConfigManager.CONFIG_FILENAME = "config.json";
|
|
313
|
-
ConfigManager.
|
|
314
|
-
//# sourceMappingURL=
|
|
295
|
+
ConfigManager.CONFIG_DIR = ".pushwork";
|
|
296
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,2CAA6B;AAC7B,uCAAyB;AACzB,oCAKkB;AAClB,oCAA6D;AAE7D;;GAEG;AACH,MAAa,aAAa;IAMxB,YAAoB,UAAmB;QAAnB,eAAU,GAAV,UAAU,CAAS;IAAG,CAAC;IAE3C;;OAEG;IACK,mBAAmB;QACzB,OAAO,IAAI,CAAC,IAAI,CACd,EAAE,CAAC,OAAO,EAAE,EACZ,aAAa,CAAC,iBAAiB,EAC/B,aAAa,CAAC,eAAe,CAC9B,CAAC;IACJ,CAAC;IAED;;OAEG;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AAG,OAAO,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;QAED,gBAAgB;QAChB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACvC,OAAO,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;QAE1B,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,MAAuB;QAC9B,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,IAAI,MAAM,CAAC,IAAI,EAAE,wBAAwB,KAAK,SAAS,EAAE,CAAC;YACxD,IACE,MAAM,CAAC,IAAI,CAAC,wBAAwB,GAAG,CAAC;gBACxC,MAAM,CAAC,IAAI,CAAC,wBAAwB,GAAG,CAAC,EACxC,CAAC;gBACD,MAAM,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAC;YAClE,CAAC;QACH,CAAC;QAED,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;YAC1B,MAAM;SACP,CAAC;IACJ,CAAC;;AA7SH,sCA8SC;AA7SyB,+BAAiB,GAAG,WAAW,CAAC;AAChC,6BAAe,GAAG,aAAa,CAAC;AAExC,wBAAU,GAAG,WAAW,CAAC"}
|
package/dist/core/index.d.ts
CHANGED
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC"}
|
package/dist/core/index.js
CHANGED
|
@@ -14,9 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
// Core sync components
|
|
18
17
|
__exportStar(require("./snapshot"), exports);
|
|
19
18
|
__exportStar(require("./change-detection"), exports);
|
|
20
19
|
__exportStar(require("./move-detection"), exports);
|
|
21
20
|
__exportStar(require("./sync-engine"), exports);
|
|
21
|
+
__exportStar(require("./config"), exports);
|
|
22
22
|
//# sourceMappingURL=index.js.map
|
package/dist/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,qDAAmC;AACnC,mDAAiC;AACjC,gDAA8B;AAC9B,2CAAyB"}
|
|
@@ -1,72 +1,34 @@
|
|
|
1
1
|
import { SyncSnapshot, MoveCandidate } from "../types";
|
|
2
|
-
import { DetectedChange } from "
|
|
2
|
+
import { DetectedChange } from "../types";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Simplified move detection engine
|
|
5
5
|
*/
|
|
6
6
|
export declare class MoveDetector {
|
|
7
|
-
private
|
|
8
|
-
|
|
7
|
+
private readonly moveThreshold;
|
|
8
|
+
constructor(moveThreshold?: number);
|
|
9
9
|
/**
|
|
10
10
|
* Detect file moves by analyzing deleted and created files
|
|
11
11
|
*/
|
|
12
|
-
detectMoves(changes: DetectedChange[], snapshot: SyncSnapshot
|
|
12
|
+
detectMoves(changes: DetectedChange[], snapshot: SyncSnapshot): Promise<{
|
|
13
13
|
moves: MoveCandidate[];
|
|
14
14
|
remainingChanges: DetectedChange[];
|
|
15
15
|
}>;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Calculate similarity between two content pieces
|
|
18
|
+
* Optimized for speed while maintaining accuracy
|
|
18
19
|
*/
|
|
19
|
-
private
|
|
20
|
+
private calculateSimilarity;
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
+
* Get representative samples from content (beginning, middle, end)
|
|
22
23
|
*/
|
|
23
|
-
|
|
24
|
-
autoMoves: MoveCandidate[];
|
|
25
|
-
promptMoves: MoveCandidate[];
|
|
26
|
-
lowConfidenceMoves: MoveCandidate[];
|
|
27
|
-
};
|
|
24
|
+
private getSamples;
|
|
28
25
|
/**
|
|
29
|
-
*
|
|
26
|
+
* Convert buffer to string (for text comparison)
|
|
30
27
|
*/
|
|
31
|
-
|
|
32
|
-
validMoves: MoveCandidate[];
|
|
33
|
-
conflicts: Array<{
|
|
34
|
-
moves: MoveCandidate[];
|
|
35
|
-
reason: string;
|
|
36
|
-
}>;
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Apply move detection heuristics
|
|
40
|
-
*/
|
|
41
|
-
applyHeuristics(moves: MoveCandidate[]): MoveCandidate[];
|
|
42
|
-
/**
|
|
43
|
-
* Get directory path from file path
|
|
44
|
-
*/
|
|
45
|
-
private getDirectoryPath;
|
|
46
|
-
/**
|
|
47
|
-
* Get file extension from file path
|
|
48
|
-
*/
|
|
49
|
-
private getFileExtension;
|
|
50
|
-
/**
|
|
51
|
-
* Check if a move should be auto-applied
|
|
52
|
-
*/
|
|
53
|
-
shouldAutoApply(move: MoveCandidate): boolean;
|
|
54
|
-
/**
|
|
55
|
-
* Check if a move should prompt the user
|
|
56
|
-
*/
|
|
57
|
-
shouldPromptUser(move: MoveCandidate): boolean;
|
|
28
|
+
private bufferToString;
|
|
58
29
|
/**
|
|
59
30
|
* Format move for display
|
|
60
31
|
*/
|
|
61
32
|
formatMove(move: MoveCandidate): string;
|
|
62
|
-
/**
|
|
63
|
-
* Calculate move statistics
|
|
64
|
-
*/
|
|
65
|
-
calculateStats(moves: MoveCandidate[]): {
|
|
66
|
-
total: number;
|
|
67
|
-
auto: number;
|
|
68
|
-
prompt: number;
|
|
69
|
-
averageSimilarity: number;
|
|
70
|
-
};
|
|
71
33
|
}
|
|
72
34
|
//# sourceMappingURL=move-detection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"move-detection.d.ts","sourceRoot":"","sources":["../../src/core/move-detection.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"move-detection.d.ts","sourceRoot":"","sources":["../../src/core/move-detection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGvD,OAAO,EAAc,cAAc,EAAE,MAAM,UAAU,CAAC;AAEtD;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;gBAE3B,aAAa,GAAE,MAAY;IAIvC;;OAEG;IACG,WAAW,CACf,OAAO,EAAE,cAAc,EAAE,EACzB,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC;QAAE,KAAK,EAAE,aAAa,EAAE,CAAC;QAAC,gBAAgB,EAAE,cAAc,EAAE,CAAA;KAAE,CAAC;IAkE1E;;;OAGG;YACW,mBAAmB;IA0CjC;;OAEG;IACH,OAAO,CAAC,UAAU;IAkBlB;;OAEG;IACH,OAAO,CAAC,cAAc;IAItB;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM;CAIxC"}
|
|
@@ -2,19 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MoveDetector = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
|
-
const
|
|
5
|
+
const string_similarity_1 = require("../utils/string-similarity");
|
|
6
|
+
const types_1 = require("../types");
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* Simplified move detection engine
|
|
8
9
|
*/
|
|
9
10
|
class MoveDetector {
|
|
11
|
+
constructor(moveThreshold = 0.7) {
|
|
12
|
+
this.moveThreshold = moveThreshold;
|
|
13
|
+
}
|
|
10
14
|
/**
|
|
11
15
|
* Detect file moves by analyzing deleted and created files
|
|
12
16
|
*/
|
|
13
|
-
async detectMoves(changes, snapshot
|
|
14
|
-
|
|
15
|
-
const deletedFiles = changes.filter((c) => !c.localContent && c.changeType === change_detection_1.ChangeType.LOCAL_ONLY);
|
|
17
|
+
async detectMoves(changes, snapshot) {
|
|
18
|
+
const deletedFiles = changes.filter((c) => !c.localContent && c.changeType === types_1.ChangeType.LOCAL_ONLY);
|
|
16
19
|
const createdFiles = changes.filter((c) => c.localContent &&
|
|
17
|
-
c.changeType ===
|
|
20
|
+
c.changeType === types_1.ChangeType.LOCAL_ONLY &&
|
|
18
21
|
!snapshot.files.has(c.path));
|
|
19
22
|
if (deletedFiles.length === 0 || createdFiles.length === 0) {
|
|
20
23
|
return { moves: [], remainingChanges: changes };
|
|
@@ -24,163 +27,91 @@ class MoveDetector {
|
|
|
24
27
|
const usedDeletions = new Set();
|
|
25
28
|
// Find potential moves by comparing content
|
|
26
29
|
for (const deletedFile of deletedFiles) {
|
|
27
|
-
const deletedContent =
|
|
28
|
-
// CRITICAL: Check for null explicitly, not falsy values
|
|
29
|
-
// Empty strings "" are valid file content!
|
|
30
|
+
const deletedContent = deletedFile.remoteContent;
|
|
30
31
|
if (deletedContent === null)
|
|
31
32
|
continue;
|
|
32
33
|
let bestMatch = null;
|
|
33
34
|
for (const createdFile of createdFiles) {
|
|
34
35
|
if (usedCreations.has(createdFile.path))
|
|
35
36
|
continue;
|
|
36
|
-
// CRITICAL: Check for null explicitly, not falsy values
|
|
37
|
-
// Empty strings "" are valid file content!
|
|
38
37
|
if (createdFile.localContent === null)
|
|
39
38
|
continue;
|
|
40
|
-
const similarity = await
|
|
41
|
-
if (similarity >=
|
|
39
|
+
const similarity = await this.calculateSimilarity(deletedContent, createdFile.localContent, deletedFile.path);
|
|
40
|
+
if (similarity >= this.moveThreshold) {
|
|
42
41
|
if (!bestMatch || similarity > bestMatch.similarity) {
|
|
43
42
|
bestMatch = { file: createdFile, similarity };
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
if (bestMatch) {
|
|
48
|
-
|
|
49
|
-
// Always report the potential move (for logging/prompting)
|
|
47
|
+
// If we detected a move above threshold, we apply it
|
|
50
48
|
moves.push({
|
|
51
49
|
fromPath: deletedFile.path,
|
|
52
50
|
toPath: bestMatch.file.path,
|
|
53
51
|
similarity: bestMatch.similarity,
|
|
54
|
-
confidence,
|
|
55
|
-
// Capture new content (may include modifications)
|
|
56
52
|
newContent: bestMatch.file.localContent || undefined,
|
|
57
53
|
});
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (bestMatch.similarity >= MoveDetector.AUTO_THRESHOLD) {
|
|
62
|
-
usedCreations.add(bestMatch.file.path);
|
|
63
|
-
usedDeletions.add(deletedFile.path);
|
|
64
|
-
}
|
|
54
|
+
// Consume the deletion and creation (move replaces both)
|
|
55
|
+
usedCreations.add(bestMatch.file.path);
|
|
56
|
+
usedDeletions.add(deletedFile.path);
|
|
65
57
|
}
|
|
66
58
|
}
|
|
67
|
-
// Filter out changes that are part of moves
|
|
68
59
|
const remainingChanges = changes.filter((change) => !usedCreations.has(change.path) && !usedDeletions.has(change.path));
|
|
69
60
|
return { moves, remainingChanges };
|
|
70
61
|
}
|
|
71
62
|
/**
|
|
72
|
-
*
|
|
73
|
-
|
|
74
|
-
async getDeletedFileContent(deletedFile, snapshot) {
|
|
75
|
-
const snapshotEntry = snapshot.files.get(deletedFile.path);
|
|
76
|
-
if (!snapshotEntry)
|
|
77
|
-
return null;
|
|
78
|
-
// Return remote content if available, otherwise null
|
|
79
|
-
return deletedFile.remoteContent || null;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Group moves by confidence level
|
|
83
|
-
*/
|
|
84
|
-
groupMovesByConfidence(moves) {
|
|
85
|
-
const autoMoves = moves.filter((m) => m.confidence === "auto");
|
|
86
|
-
const promptMoves = moves.filter((m) => m.confidence === "prompt");
|
|
87
|
-
const lowConfidenceMoves = moves.filter((m) => m.confidence === "low");
|
|
88
|
-
return { autoMoves, promptMoves, lowConfidenceMoves };
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Validate move candidates to avoid conflicts
|
|
63
|
+
* Calculate similarity between two content pieces
|
|
64
|
+
* Optimized for speed while maintaining accuracy
|
|
92
65
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
//
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
66
|
+
async calculateSimilarity(content1, content2, path) {
|
|
67
|
+
if (content1 === content2)
|
|
68
|
+
return 1.0;
|
|
69
|
+
// Early exit: size difference too large
|
|
70
|
+
const size1 = typeof content1 === "string" ? content1.length : content1.length;
|
|
71
|
+
const size2 = typeof content2 === "string" ? content2.length : content2.length;
|
|
72
|
+
const sizeDiff = Math.abs(size1 - size2) / Math.max(size1, size2);
|
|
73
|
+
if (sizeDiff > 0.5)
|
|
74
|
+
return 0.0;
|
|
75
|
+
// Binary files: hash mismatch = not a move
|
|
76
|
+
const isText = await (0, utils_1.isTextFile)(path);
|
|
77
|
+
if (!isText)
|
|
78
|
+
return 0.0;
|
|
79
|
+
// Text files: use string similarity
|
|
80
|
+
const str1 = typeof content1 === "string" ? content1 : this.bufferToString(content1);
|
|
81
|
+
const str2 = typeof content2 === "string" ? content2 : this.bufferToString(content2);
|
|
82
|
+
// For small files (<4KB), compare full content
|
|
83
|
+
if (size1 < 4096 && size2 < 4096) {
|
|
84
|
+
return (0, string_similarity_1.stringSimilarity)(str1, str2);
|
|
111
85
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
reason: `Multiple files moving to ${move.toPath}`,
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
else if (sourceConflicts.length > 1) {
|
|
122
|
-
conflicts.push({
|
|
123
|
-
moves: sourceConflicts,
|
|
124
|
-
reason: `File ${move.fromPath} has multiple potential destinations`,
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
validMoves.push(move);
|
|
129
|
-
}
|
|
86
|
+
// For large files, sample 3 locations
|
|
87
|
+
const samples1 = this.getSamples(str1);
|
|
88
|
+
const samples2 = this.getSamples(str2);
|
|
89
|
+
let totalSimilarity = 0;
|
|
90
|
+
for (let i = 0; i < Math.min(samples1.length, samples2.length); i++) {
|
|
91
|
+
totalSimilarity += (0, string_similarity_1.stringSimilarity)(samples1[i], samples2[i]);
|
|
130
92
|
}
|
|
131
|
-
return
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Apply move detection heuristics
|
|
135
|
-
*/
|
|
136
|
-
applyHeuristics(moves) {
|
|
137
|
-
return moves
|
|
138
|
-
.filter((move) => {
|
|
139
|
-
// Filter out moves within the same directory unless similarity is very high
|
|
140
|
-
const fromDir = this.getDirectoryPath(move.fromPath);
|
|
141
|
-
const toDir = this.getDirectoryPath(move.toPath);
|
|
142
|
-
if (fromDir === toDir && move.similarity < 0.9) {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
// Filter out moves with very different file extensions unless similarity is perfect
|
|
146
|
-
const fromExt = this.getFileExtension(move.fromPath);
|
|
147
|
-
const toExt = this.getFileExtension(move.toPath);
|
|
148
|
-
if (fromExt !== toExt && move.similarity < 1.0) {
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
return true;
|
|
152
|
-
})
|
|
153
|
-
.sort((a, b) => b.similarity - a.similarity); // Sort by similarity descending
|
|
93
|
+
return totalSimilarity / Math.min(samples1.length, samples2.length);
|
|
154
94
|
}
|
|
155
95
|
/**
|
|
156
|
-
* Get
|
|
96
|
+
* Get representative samples from content (beginning, middle, end)
|
|
157
97
|
*/
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
* Get file extension from file path
|
|
164
|
-
*/
|
|
165
|
-
getFileExtension(filePath) {
|
|
166
|
-
const lastDot = filePath.lastIndexOf(".");
|
|
167
|
-
const lastSlash = filePath.lastIndexOf("/");
|
|
168
|
-
if (lastDot > lastSlash && lastDot >= 0) {
|
|
169
|
-
return filePath.substring(lastDot + 1).toLowerCase();
|
|
98
|
+
getSamples(str) {
|
|
99
|
+
const CHUNK_SIZE = 1024;
|
|
100
|
+
const length = str.length;
|
|
101
|
+
if (length <= CHUNK_SIZE) {
|
|
102
|
+
return [str];
|
|
170
103
|
}
|
|
171
|
-
return
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
shouldAutoApply(move) {
|
|
177
|
-
return move.confidence === "auto";
|
|
104
|
+
return [
|
|
105
|
+
str.slice(0, CHUNK_SIZE), // Beginning
|
|
106
|
+
str.slice(Math.floor(length / 2) - Math.floor(CHUNK_SIZE / 2), Math.floor(length / 2) + Math.floor(CHUNK_SIZE / 2)), // Middle
|
|
107
|
+
str.slice(-CHUNK_SIZE), // End
|
|
108
|
+
];
|
|
178
109
|
}
|
|
179
110
|
/**
|
|
180
|
-
*
|
|
111
|
+
* Convert buffer to string (for text comparison)
|
|
181
112
|
*/
|
|
182
|
-
|
|
183
|
-
return
|
|
113
|
+
bufferToString(buffer) {
|
|
114
|
+
return new TextDecoder().decode(buffer);
|
|
184
115
|
}
|
|
185
116
|
/**
|
|
186
117
|
* Format move for display
|
|
@@ -189,18 +120,6 @@ class MoveDetector {
|
|
|
189
120
|
const percentage = Math.round(move.similarity * 100);
|
|
190
121
|
return `${move.fromPath} → ${move.toPath} (${percentage}% similar)`;
|
|
191
122
|
}
|
|
192
|
-
/**
|
|
193
|
-
* Calculate move statistics
|
|
194
|
-
*/
|
|
195
|
-
calculateStats(moves) {
|
|
196
|
-
const total = moves.length;
|
|
197
|
-
const auto = moves.filter((m) => m.confidence === "auto").length;
|
|
198
|
-
const prompt = moves.filter((m) => m.confidence === "prompt").length;
|
|
199
|
-
const averageSimilarity = total > 0 ? moves.reduce((sum, m) => sum + m.similarity, 0) / total : 0;
|
|
200
|
-
return { total, auto, prompt, averageSimilarity };
|
|
201
|
-
}
|
|
202
123
|
}
|
|
203
124
|
exports.MoveDetector = MoveDetector;
|
|
204
|
-
MoveDetector.AUTO_THRESHOLD = 0.8;
|
|
205
|
-
MoveDetector.PROMPT_THRESHOLD = 0.5;
|
|
206
125
|
//# sourceMappingURL=move-detection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"move-detection.js","sourceRoot":"","sources":["../../src/core/move-detection.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"move-detection.js","sourceRoot":"","sources":["../../src/core/move-detection.ts"],"names":[],"mappings":";;;AACA,oCAAsC;AACtC,kEAA8D;AAC9D,oCAAsD;AAEtD;;GAEG;AACH,MAAa,YAAY;IAGvB,YAAY,gBAAwB,GAAG;QACrC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CACf,OAAyB,EACzB,QAAsB;QAEtB,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CACjC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,UAAU,KAAK,kBAAU,CAAC,UAAU,CACjE,CAAC;QACF,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CACjC,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,YAAY;YACd,CAAC,CAAC,UAAU,KAAK,kBAAU,CAAC,UAAU;YACtC,CAAC,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