pushwork 1.0.15 → 1.0.16
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/CLAUDE.md +114 -0
- package/README.md +1 -1
- package/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +38 -11
- package/dist/commands.js.map +1 -1
- package/dist/core/change-detection.d.ts.map +1 -1
- package/dist/core/change-detection.js +4 -12
- package/dist/core/change-detection.js.map +1 -1
- package/dist/core/config.d.ts +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +3 -3
- package/dist/core/config.js.map +1 -1
- package/dist/core/sync-engine.d.ts +25 -40
- package/dist/core/sync-engine.d.ts.map +1 -1
- package/dist/core/sync-engine.js +277 -317
- package/dist/core/sync-engine.js.map +1 -1
- package/dist/types/config.d.ts +1 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/documents.d.ts +1 -2
- package/dist/types/documents.d.ts.map +1 -1
- package/dist/types/documents.js.map +1 -1
- package/dist/utils/fs.d.ts +2 -3
- package/dist/utils/fs.d.ts.map +1 -1
- package/dist/utils/fs.js +1 -11
- package/dist/utils/fs.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/cli.ts +12 -0
- package/src/commands.ts +41 -11
- package/src/core/change-detection.ts +557 -564
- package/src/core/config.ts +3 -3
- package/src/core/sync-engine.ts +1399 -1427
- package/src/types/config.ts +1 -0
- package/src/types/documents.ts +38 -39
- package/src/utils/fs.ts +170 -178
- package/src/utils/index.ts +4 -3
- package/src/utils/text-diff.ts +101 -0
- package/dist/cli/commands.d.ts +0 -61
- package/dist/cli/commands.d.ts.map +0 -1
- package/dist/cli/commands.js +0 -661
- 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/cli/output.d.ts +0 -61
- package/dist/cli/output.d.ts.map +0 -1
- package/dist/cli/output.js +0 -176
- package/dist/cli/output.js.map +0 -1
- package/dist/config/index.d.ts +0 -71
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js +0 -314
- package/dist/config/index.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/keyhive.d.ts +0 -9
- package/dist/utils/keyhive.d.ts.map +0 -1
- package/dist/utils/keyhive.js +0 -26
- package/dist/utils/keyhive.js.map +0 -1
package/dist/config/index.js
DELETED
|
@@ -1,314 +0,0 @@
|
|
|
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.ConfigManager = void 0;
|
|
37
|
-
const fs = __importStar(require("fs/promises"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
39
|
-
const os = __importStar(require("os"));
|
|
40
|
-
const utils_1 = require("../utils");
|
|
41
|
-
/**
|
|
42
|
-
* Configuration manager for pushwork
|
|
43
|
-
*/
|
|
44
|
-
class ConfigManager {
|
|
45
|
-
constructor(workingDir) {
|
|
46
|
-
this.workingDir = workingDir;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Get global configuration path
|
|
50
|
-
*/
|
|
51
|
-
getGlobalConfigPath() {
|
|
52
|
-
return path.join(os.homedir(), ConfigManager.GLOBAL_CONFIG_DIR, ConfigManager.CONFIG_FILENAME);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Get local configuration path
|
|
56
|
-
*/
|
|
57
|
-
getLocalConfigPath() {
|
|
58
|
-
if (!this.workingDir) {
|
|
59
|
-
throw new Error("Working directory not set for local config");
|
|
60
|
-
}
|
|
61
|
-
return path.join(this.workingDir, ConfigManager.LOCAL_CONFIG_DIR, ConfigManager.CONFIG_FILENAME);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Load global configuration
|
|
65
|
-
*/
|
|
66
|
-
async loadGlobal() {
|
|
67
|
-
try {
|
|
68
|
-
const configPath = this.getGlobalConfigPath();
|
|
69
|
-
if (!(await (0, utils_1.pathExists)(configPath))) {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
const content = await fs.readFile(configPath, "utf8");
|
|
73
|
-
return JSON.parse(content);
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
console.warn(`Failed to load global config: ${error}`);
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Save global configuration
|
|
82
|
-
*/
|
|
83
|
-
async saveGlobal(config) {
|
|
84
|
-
try {
|
|
85
|
-
const configPath = this.getGlobalConfigPath();
|
|
86
|
-
await (0, utils_1.ensureDirectoryExists)(path.dirname(configPath));
|
|
87
|
-
const content = JSON.stringify(config, null, 2);
|
|
88
|
-
await fs.writeFile(configPath, content, "utf8");
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
throw new Error(`Failed to save global config: ${error}`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Load local/directory configuration
|
|
96
|
-
*/
|
|
97
|
-
async load() {
|
|
98
|
-
if (!this.workingDir) {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
try {
|
|
102
|
-
const configPath = this.getLocalConfigPath();
|
|
103
|
-
if (!(await (0, utils_1.pathExists)(configPath))) {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
const content = await fs.readFile(configPath, "utf8");
|
|
107
|
-
return JSON.parse(content);
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
console.warn(`Failed to load local config: ${error}`);
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Save local/directory configuration
|
|
116
|
-
*/
|
|
117
|
-
async save(config) {
|
|
118
|
-
if (!this.workingDir) {
|
|
119
|
-
throw new Error("Working directory not set for local config");
|
|
120
|
-
}
|
|
121
|
-
try {
|
|
122
|
-
const configPath = this.getLocalConfigPath();
|
|
123
|
-
await (0, utils_1.ensureDirectoryExists)(path.dirname(configPath));
|
|
124
|
-
const content = JSON.stringify(config, null, 2);
|
|
125
|
-
await fs.writeFile(configPath, content, "utf8");
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
throw new Error(`Failed to save local config: ${error}`);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Get merged configuration (global + local)
|
|
133
|
-
*/
|
|
134
|
-
async getMerged() {
|
|
135
|
-
const globalConfig = await this.loadGlobal();
|
|
136
|
-
const localConfig = await this.load();
|
|
137
|
-
// Create default configuration
|
|
138
|
-
const defaultConfig = {
|
|
139
|
-
sync_enabled: true,
|
|
140
|
-
sync_server_storage_id: "3760df37-a4c6-4f66-9ecd-732039a9385d",
|
|
141
|
-
defaults: {
|
|
142
|
-
exclude_patterns: [".git", "node_modules", "*.tmp", ".pushwork"],
|
|
143
|
-
large_file_threshold: "100MB",
|
|
144
|
-
},
|
|
145
|
-
diff: {
|
|
146
|
-
show_binary: false,
|
|
147
|
-
},
|
|
148
|
-
sync: {
|
|
149
|
-
move_detection_threshold: 0.8,
|
|
150
|
-
prompt_threshold: 0.5,
|
|
151
|
-
auto_sync: false,
|
|
152
|
-
parallel_operations: 4,
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
// Merge configurations: default < global < local
|
|
156
|
-
let merged = { ...defaultConfig };
|
|
157
|
-
if (globalConfig) {
|
|
158
|
-
merged = this.mergeConfigs(merged, globalConfig);
|
|
159
|
-
}
|
|
160
|
-
if (localConfig) {
|
|
161
|
-
merged = this.mergeConfigs(merged, localConfig);
|
|
162
|
-
}
|
|
163
|
-
return merged;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Merge two configuration objects
|
|
167
|
-
*/
|
|
168
|
-
mergeConfigs(base, override) {
|
|
169
|
-
const merged = { ...base };
|
|
170
|
-
if ("sync_server" in override && override.sync_server !== undefined) {
|
|
171
|
-
merged.sync_server = override.sync_server;
|
|
172
|
-
}
|
|
173
|
-
if ("sync_server_storage_id" in override &&
|
|
174
|
-
override.sync_server_storage_id !== undefined) {
|
|
175
|
-
merged.sync_server_storage_id = override.sync_server_storage_id;
|
|
176
|
-
}
|
|
177
|
-
if ("sync_enabled" in override && override.sync_enabled !== undefined) {
|
|
178
|
-
merged.sync_enabled = override.sync_enabled;
|
|
179
|
-
}
|
|
180
|
-
// Handle GlobalConfig structure
|
|
181
|
-
if ("exclude_patterns" in override && override.exclude_patterns) {
|
|
182
|
-
merged.defaults.exclude_patterns = override.exclude_patterns;
|
|
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
|
-
};
|
|
198
|
-
}
|
|
199
|
-
if ("sync" in override && override.sync) {
|
|
200
|
-
merged.sync = { ...merged.sync, ...override.sync };
|
|
201
|
-
}
|
|
202
|
-
return merged;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Create default global configuration
|
|
206
|
-
*/
|
|
207
|
-
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
|
-
};
|
|
229
|
-
await this.saveGlobal(defaultGlobal);
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Check if global configuration exists
|
|
233
|
-
*/
|
|
234
|
-
async globalConfigExists() {
|
|
235
|
-
return await (0, utils_1.pathExists)(this.getGlobalConfigPath());
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Check if local configuration exists
|
|
239
|
-
*/
|
|
240
|
-
async localConfigExists() {
|
|
241
|
-
if (!this.workingDir)
|
|
242
|
-
return false;
|
|
243
|
-
return await (0, utils_1.pathExists)(this.getLocalConfigPath());
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Get configuration value by path (e.g., 'sync.auto_sync')
|
|
247
|
-
*/
|
|
248
|
-
async getValue(keyPath) {
|
|
249
|
-
const config = await this.getMerged();
|
|
250
|
-
const keys = keyPath.split(".");
|
|
251
|
-
let value = config;
|
|
252
|
-
for (const key of keys) {
|
|
253
|
-
if (value && typeof value === "object" && key in value) {
|
|
254
|
-
value = value[key];
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
return undefined;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
return value;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Set configuration value by path
|
|
264
|
-
*/
|
|
265
|
-
async setValue(keyPath, value) {
|
|
266
|
-
const config = (await this.load()) || {};
|
|
267
|
-
const keys = keyPath.split(".");
|
|
268
|
-
let current = config;
|
|
269
|
-
// Navigate to the parent of the target key
|
|
270
|
-
for (let i = 0; i < keys.length - 1; i++) {
|
|
271
|
-
const key = keys[i];
|
|
272
|
-
if (!(key in current) || typeof current[key] !== "object") {
|
|
273
|
-
current[key] = {};
|
|
274
|
-
}
|
|
275
|
-
current = current[key];
|
|
276
|
-
}
|
|
277
|
-
// Set the value
|
|
278
|
-
const finalKey = keys[keys.length - 1];
|
|
279
|
-
current[finalKey] = value;
|
|
280
|
-
await this.save(config);
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Validate configuration
|
|
284
|
-
*/
|
|
285
|
-
validate(config) {
|
|
286
|
-
const errors = [];
|
|
287
|
-
if (config.sync?.move_detection_threshold !== undefined) {
|
|
288
|
-
if (config.sync.move_detection_threshold < 0 ||
|
|
289
|
-
config.sync.move_detection_threshold > 1) {
|
|
290
|
-
errors.push("move_detection_threshold must be between 0 and 1");
|
|
291
|
-
}
|
|
292
|
-
}
|
|
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
|
-
return {
|
|
305
|
-
valid: errors.length === 0,
|
|
306
|
-
errors,
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
exports.ConfigManager = ConfigManager;
|
|
311
|
-
ConfigManager.GLOBAL_CONFIG_DIR = ".pushwork";
|
|
312
|
-
ConfigManager.CONFIG_FILENAME = "config.json";
|
|
313
|
-
ConfigManager.LOCAL_CONFIG_DIR = ".pushwork";
|
|
314
|
-
//# sourceMappingURL=index.js.map
|
package/dist/config/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,2CAA6B;AAC7B,uCAAyB;AAEzB,oCAA6D;AAE7D;;GAEG;AACH,MAAa,aAAa;IAKxB,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;IACK,kBAAkB;QACxB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CACd,IAAI,CAAC,UAAU,EACf,aAAa,CAAC,gBAAgB,EAC9B,aAAa,CAAC,eAAe,CAC9B,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC9C,IAAI,CAAC,CAAC,MAAM,IAAA,kBAAU,EAAC,UAAU,CAAC,CAAC,EAAE,CAAC;gBACpC,OAAO,IAAI,CAAC;YACd,CAAC;YAED,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YACtD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAiB,CAAC;QAC7C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,iCAAiC,KAAK,EAAE,CAAC,CAAC;YACvD,OAAO,IAAI,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CAAC;AAChC,8BAAgB,GAAG,WAAW,CAAC"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Content similarity calculation for move detection
|
|
3
|
-
*/
|
|
4
|
-
export declare class ContentSimilarity {
|
|
5
|
-
private static readonly CHUNK_SIZE;
|
|
6
|
-
private static readonly AUTO_THRESHOLD;
|
|
7
|
-
private static readonly PROMPT_THRESHOLD;
|
|
8
|
-
/**
|
|
9
|
-
* Calculate similarity between two content pieces
|
|
10
|
-
*/
|
|
11
|
-
static calculateSimilarity(content1: string | Uint8Array, content2: string | Uint8Array): Promise<number>;
|
|
12
|
-
/**
|
|
13
|
-
* Check if two content pieces are identical
|
|
14
|
-
*/
|
|
15
|
-
private static areIdentical;
|
|
16
|
-
/**
|
|
17
|
-
* Calculate similarity for small files using full content
|
|
18
|
-
*/
|
|
19
|
-
private static calculateFullSimilarity;
|
|
20
|
-
/**
|
|
21
|
-
* Calculate similarity for large files using sampling
|
|
22
|
-
*/
|
|
23
|
-
private static calculateSampledSimilarity;
|
|
24
|
-
/**
|
|
25
|
-
* Get representative samples from content
|
|
26
|
-
*/
|
|
27
|
-
private static getSamples;
|
|
28
|
-
/**
|
|
29
|
-
* Calculate Levenshtein similarity (0-1 scale)
|
|
30
|
-
*/
|
|
31
|
-
private static levenshteinSimilarity;
|
|
32
|
-
/**
|
|
33
|
-
* Calculate Levenshtein distance
|
|
34
|
-
*/
|
|
35
|
-
private static levenshteinDistance;
|
|
36
|
-
/**
|
|
37
|
-
* Convert buffer to string for comparison
|
|
38
|
-
*/
|
|
39
|
-
private static bufferToString;
|
|
40
|
-
/**
|
|
41
|
-
* Determine confidence level based on similarity score
|
|
42
|
-
*/
|
|
43
|
-
static getConfidenceLevel(similarity: number): "auto" | "prompt" | "low";
|
|
44
|
-
/**
|
|
45
|
-
* Should auto-apply move based on similarity
|
|
46
|
-
*/
|
|
47
|
-
static shouldAutoApply(similarity: number): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Should prompt user for move confirmation
|
|
50
|
-
*/
|
|
51
|
-
static shouldPromptUser(similarity: number): boolean;
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=content-similarity.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content-similarity.d.ts","sourceRoot":"","sources":["../../src/utils/content-similarity.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAQ;IAC1C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAO;IAC7C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAO;IAE/C;;OAEG;WACU,mBAAmB,CAC9B,QAAQ,EAAE,MAAM,GAAG,UAAU,EAC7B,QAAQ,EAAE,MAAM,GAAG,UAAU,GAC5B,OAAO,CAAC,MAAM,CAAC;IA0BlB;;OAEG;mBACkB,YAAY;IASjC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAYtC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAkBzC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAwBzB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAUpC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAsBlC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAO7B;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK;IAUxE;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAInD;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;CAKrD"}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContentSimilarity = void 0;
|
|
4
|
-
const fs_1 = require("./fs");
|
|
5
|
-
/**
|
|
6
|
-
* Content similarity calculation for move detection
|
|
7
|
-
*/
|
|
8
|
-
class ContentSimilarity {
|
|
9
|
-
/**
|
|
10
|
-
* Calculate similarity between two content pieces
|
|
11
|
-
*/
|
|
12
|
-
static async calculateSimilarity(content1, content2) {
|
|
13
|
-
// Quick early exit for identical content
|
|
14
|
-
if (await this.areIdentical(content1, content2)) {
|
|
15
|
-
return 1.0;
|
|
16
|
-
}
|
|
17
|
-
// Size-based quick rejection
|
|
18
|
-
const size1 = typeof content1 === "string" ? content1.length : content1.length;
|
|
19
|
-
const size2 = typeof content2 === "string" ? content2.length : content2.length;
|
|
20
|
-
const sizeDiff = Math.abs(size1 - size2) / Math.max(size1, size2);
|
|
21
|
-
if (sizeDiff > 0.5) {
|
|
22
|
-
return 0.0; // Too different in size
|
|
23
|
-
}
|
|
24
|
-
// For small files, use full content comparison
|
|
25
|
-
if (size1 < this.CHUNK_SIZE * 4 && size2 < this.CHUNK_SIZE * 4) {
|
|
26
|
-
return this.calculateFullSimilarity(content1, content2);
|
|
27
|
-
}
|
|
28
|
-
// For large files, use sampling
|
|
29
|
-
return this.calculateSampledSimilarity(content1, content2);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Check if two content pieces are identical
|
|
33
|
-
*/
|
|
34
|
-
static async areIdentical(content1, content2) {
|
|
35
|
-
const hash1 = await (0, fs_1.calculateContentHash)(content1);
|
|
36
|
-
const hash2 = await (0, fs_1.calculateContentHash)(content2);
|
|
37
|
-
return hash1 === hash2;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Calculate similarity for small files using full content
|
|
41
|
-
*/
|
|
42
|
-
static calculateFullSimilarity(content1, content2) {
|
|
43
|
-
const str1 = typeof content1 === "string" ? content1 : this.bufferToString(content1);
|
|
44
|
-
const str2 = typeof content2 === "string" ? content2 : this.bufferToString(content2);
|
|
45
|
-
return this.levenshteinSimilarity(str1, str2);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Calculate similarity for large files using sampling
|
|
49
|
-
*/
|
|
50
|
-
static calculateSampledSimilarity(content1, content2) {
|
|
51
|
-
const samples1 = this.getSamples(content1);
|
|
52
|
-
const samples2 = this.getSamples(content2);
|
|
53
|
-
let totalSimilarity = 0;
|
|
54
|
-
let comparisons = 0;
|
|
55
|
-
for (let i = 0; i < Math.min(samples1.length, samples2.length); i++) {
|
|
56
|
-
totalSimilarity += this.levenshteinSimilarity(samples1[i], samples2[i]);
|
|
57
|
-
comparisons++;
|
|
58
|
-
}
|
|
59
|
-
return comparisons > 0 ? totalSimilarity / comparisons : 0;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Get representative samples from content
|
|
63
|
-
*/
|
|
64
|
-
static getSamples(content) {
|
|
65
|
-
const str = typeof content === "string" ? content : this.bufferToString(content);
|
|
66
|
-
const length = str.length;
|
|
67
|
-
const samples = [];
|
|
68
|
-
if (length <= this.CHUNK_SIZE) {
|
|
69
|
-
samples.push(str);
|
|
70
|
-
return samples;
|
|
71
|
-
}
|
|
72
|
-
// Beginning
|
|
73
|
-
samples.push(str.slice(0, this.CHUNK_SIZE));
|
|
74
|
-
// Middle
|
|
75
|
-
const midStart = Math.floor(length / 2) - Math.floor(this.CHUNK_SIZE / 2);
|
|
76
|
-
samples.push(str.slice(midStart, midStart + this.CHUNK_SIZE));
|
|
77
|
-
// End
|
|
78
|
-
samples.push(str.slice(-this.CHUNK_SIZE));
|
|
79
|
-
return samples;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Calculate Levenshtein similarity (0-1 scale)
|
|
83
|
-
*/
|
|
84
|
-
static levenshteinSimilarity(str1, str2) {
|
|
85
|
-
if (str1 === str2)
|
|
86
|
-
return 1.0;
|
|
87
|
-
if (str1.length === 0 || str2.length === 0)
|
|
88
|
-
return 0.0;
|
|
89
|
-
const distance = this.levenshteinDistance(str1, str2);
|
|
90
|
-
const maxLength = Math.max(str1.length, str2.length);
|
|
91
|
-
return 1 - distance / maxLength;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Calculate Levenshtein distance
|
|
95
|
-
*/
|
|
96
|
-
static levenshteinDistance(str1, str2) {
|
|
97
|
-
const matrix = Array(str2.length + 1)
|
|
98
|
-
.fill(null)
|
|
99
|
-
.map(() => Array(str1.length + 1).fill(null));
|
|
100
|
-
for (let i = 0; i <= str1.length; i++)
|
|
101
|
-
matrix[0][i] = i;
|
|
102
|
-
for (let j = 0; j <= str2.length; j++)
|
|
103
|
-
matrix[j][0] = j;
|
|
104
|
-
for (let j = 1; j <= str2.length; j++) {
|
|
105
|
-
for (let i = 1; i <= str1.length; i++) {
|
|
106
|
-
const indicator = str1[i - 1] === str2[j - 1] ? 0 : 1;
|
|
107
|
-
matrix[j][i] = Math.min(matrix[j][i - 1] + 1, // deletion
|
|
108
|
-
matrix[j - 1][i] + 1, // insertion
|
|
109
|
-
matrix[j - 1][i - 1] + indicator // substitution
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return matrix[str2.length][str1.length];
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Convert buffer to string for comparison
|
|
117
|
-
*/
|
|
118
|
-
static bufferToString(buffer) {
|
|
119
|
-
// For binary content, use hex representation for comparison
|
|
120
|
-
return Array.from(buffer)
|
|
121
|
-
.map((b) => b.toString(16).padStart(2, "0"))
|
|
122
|
-
.join("");
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Determine confidence level based on similarity score
|
|
126
|
-
*/
|
|
127
|
-
static getConfidenceLevel(similarity) {
|
|
128
|
-
if (similarity >= this.AUTO_THRESHOLD) {
|
|
129
|
-
return "auto";
|
|
130
|
-
}
|
|
131
|
-
else if (similarity >= this.PROMPT_THRESHOLD) {
|
|
132
|
-
return "prompt";
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
return "low";
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Should auto-apply move based on similarity
|
|
140
|
-
*/
|
|
141
|
-
static shouldAutoApply(similarity) {
|
|
142
|
-
return similarity >= this.AUTO_THRESHOLD;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Should prompt user for move confirmation
|
|
146
|
-
*/
|
|
147
|
-
static shouldPromptUser(similarity) {
|
|
148
|
-
return (similarity >= this.PROMPT_THRESHOLD && similarity < this.AUTO_THRESHOLD);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
exports.ContentSimilarity = ContentSimilarity;
|
|
152
|
-
ContentSimilarity.CHUNK_SIZE = 1024; // 1KB chunks for sampling
|
|
153
|
-
ContentSimilarity.AUTO_THRESHOLD = 0.8;
|
|
154
|
-
ContentSimilarity.PROMPT_THRESHOLD = 0.5;
|
|
155
|
-
//# sourceMappingURL=content-similarity.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content-similarity.js","sourceRoot":"","sources":["../../src/utils/content-similarity.ts"],"names":[],"mappings":";;;AAAA,6BAA4C;AAE5C;;GAEG;AACH,MAAa,iBAAiB;IAK5B;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAC9B,QAA6B,EAC7B,QAA6B;QAE7B,yCAAyC;QACzC,IAAI,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;YAChD,OAAO,GAAG,CAAC;QACb,CAAC;QAED,6BAA6B;QAC7B,MAAM,KAAK,GACT,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;QACnE,MAAM,KAAK,GACT,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CA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AAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;aAC3C,IAAI,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAkB;QAC1C,IAAI,UAAU,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACtC,OAAO,MAAM,CAAC;QAChB,CAAC;aAAM,IAAI,UAAU,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC/C,OAAO,QAAQ,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,UAAkB;QACvC,OAAO,UAAU,IAAI,IAAI,CAAC,cAAc,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,UAAkB;QACxC,OAAO,CACL,UAAU,IAAI,IAAI,CAAC,gBAAgB,IAAI,UAAU,GAAG,IAAI,CAAC,cAAc,CACxE,CAAC;IACJ,CAAC;;AA3LH,8CA4LC;AA3LyB,4BAAU,GAAG,IAAI,CAAC,CAAC,0BAA0B;AAC7C,gCAAc,GAAG,GAAG,CAAC;AACrB,kCAAgB,GAAG,GAAG,CAAC"}
|
package/dist/utils/keyhive.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Keyhive, Signer } from "@keyhive/keyhive/slim";
|
|
2
|
-
import type { NetworkAdapter, PeerId, StorageAdapterInterface } from "@automerge/automerge-repo/slim";
|
|
3
|
-
export declare function setupKeyhive(storageAdapter: StorageAdapterInterface, networkAdapter: NetworkAdapter): Promise<{
|
|
4
|
-
adapter: NetworkAdapter;
|
|
5
|
-
signer: Signer;
|
|
6
|
-
keyhive: Keyhive;
|
|
7
|
-
peerId: PeerId;
|
|
8
|
-
}>;
|
|
9
|
-
//# sourceMappingURL=keyhive.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keyhive.d.ts","sourceRoot":"","sources":["../../src/utils/keyhive.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,OAAO,EACP,MAAM,EAEP,MAAM,uBAAuB,CAAC;AAM/B,OAAO,KAAK,EACV,cAAc,EACd,MAAM,EACN,uBAAuB,EACxB,MAAM,gCAAgC,CAAC;AAGxC,wBAAsB,YAAY,CAChC,cAAc,EAAE,uBAAuB,EACvC,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC;IACT,OAAO,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAmBD"}
|
package/dist/utils/keyhive.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { CiphertextStore, Keyhive, Signer, initFromBase64Wasm, } from "@keyhive/keyhive/slim";
|
|
2
|
-
// @ts-expect-error
|
|
3
|
-
import { wasmBase64 } from "@keyhive/keyhive/keyhive_wasm.base64.js";
|
|
4
|
-
initFromBase64Wasm(wasmBase64);
|
|
5
|
-
import { initializeKeyhive } from "@automerge/automerge-repo-keyhive";
|
|
6
|
-
import * as os from "node:os";
|
|
7
|
-
export async function setupKeyhive(storageAdapter, networkAdapter) {
|
|
8
|
-
const signer = Signer.generateMemory();
|
|
9
|
-
const store = CiphertextStore.newInMemory();
|
|
10
|
-
const hive = await Keyhive.init(signer, store, console.info);
|
|
11
|
-
const hivekit = await initializeKeyhive({
|
|
12
|
-
storage: storageAdapter,
|
|
13
|
-
peerIdSuffix: `pushwork-${os.hostname}-${os.platform}-${Math.random()
|
|
14
|
-
.toString(32)
|
|
15
|
-
.slice(2)}`,
|
|
16
|
-
automaticArchiveIngestion: false,
|
|
17
|
-
networkAdapter: networkAdapter,
|
|
18
|
-
});
|
|
19
|
-
return {
|
|
20
|
-
adapter: hivekit.networkAdapter,
|
|
21
|
-
signer,
|
|
22
|
-
keyhive: hive,
|
|
23
|
-
peerId: hivekit.peerId,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=keyhive.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keyhive.js","sourceRoot":"","sources":["../../src/utils/keyhive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,OAAO,EACP,MAAM,EACN,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,mBAAmB;AACnB,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AACrE,kBAAkB,CAAC,UAAU,CAAC,CAAC;AAE/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAMtE,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,cAAuC,EACvC,cAA8B;IAO9B,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc,EAAE,CAAC;IACvC,MAAM,KAAK,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC;IAC5C,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC;QACtC,OAAO,EAAE,cAAc;QACvB,YAAY,EAAE,YAAY,EAAE,CAAC,QAAQ,IAAI,EAAE,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,EAAE;aAClE,QAAQ,CAAC,EAAE,CAAC;aACZ,KAAK,CAAC,CAAC,CAAC,EAAE;QACb,yBAAyB,EAAE,KAAK;QAChC,cAAc,EAAE,cAAc;KAC/B,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,cAAc;QAC/B,MAAM;QACN,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC;AACJ,CAAC"}
|