pushwork 1.1.3 → 2.0.0-a.sub.0
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 +9 -5
- package/dist/cli/commands.d.ts +71 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +794 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +19 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli.js +48 -55
- package/dist/cli.js.map +1 -1
- package/dist/commands.d.ts +5 -1
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +262 -263
- package/dist/commands.js.map +1 -1
- package/dist/config/index.d.ts +71 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +314 -0
- package/dist/config/index.js.map +1 -0
- package/dist/core/change-detection.d.ts +2 -2
- package/dist/core/change-detection.d.ts.map +1 -1
- package/dist/core/change-detection.js +82 -109
- 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 +14 -57
- package/dist/core/config.js.map +1 -1
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +5 -21
- package/dist/core/index.js.map +1 -1
- package/dist/core/move-detection.d.ts +2 -2
- package/dist/core/move-detection.d.ts.map +1 -1
- package/dist/core/move-detection.js +9 -13
- package/dist/core/move-detection.js.map +1 -1
- package/dist/core/snapshot.d.ts +1 -1
- package/dist/core/snapshot.d.ts.map +1 -1
- package/dist/core/snapshot.js +9 -46
- package/dist/core/snapshot.js.map +1 -1
- package/dist/core/sync-engine.d.ts +1 -1
- package/dist/core/sync-engine.d.ts.map +1 -1
- package/dist/core/sync-engine.js +126 -151
- package/dist/core/sync-engine.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -20
- package/dist/index.js.map +1 -1
- package/dist/types/config.d.ts +7 -6
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +1 -5
- package/dist/types/config.js.map +1 -1
- package/dist/types/documents.js +4 -7
- package/dist/types/documents.js.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +3 -19
- package/dist/types/index.js.map +1 -1
- package/dist/types/snapshot.js +1 -2
- package/dist/utils/content-similarity.d.ts +53 -0
- package/dist/utils/content-similarity.d.ts.map +1 -0
- package/dist/utils/content-similarity.js +155 -0
- package/dist/utils/content-similarity.js.map +1 -0
- package/dist/utils/content.js +4 -8
- package/dist/utils/content.js.map +1 -1
- package/dist/utils/directory.js +5 -9
- package/dist/utils/directory.js.map +1 -1
- package/dist/utils/fs.d.ts +1 -1
- package/dist/utils/fs.d.ts.map +1 -1
- package/dist/utils/fs.js +34 -84
- package/dist/utils/fs.js.map +1 -1
- package/dist/utils/index.d.ts +4 -4
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +4 -20
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/mime-types.js +5 -43
- package/dist/utils/mime-types.js.map +1 -1
- package/dist/utils/network-sync.d.ts +13 -8
- package/dist/utils/network-sync.d.ts.map +1 -1
- package/dist/utils/network-sync.js +65 -137
- package/dist/utils/network-sync.js.map +1 -1
- package/dist/utils/node-polyfills.d.ts +9 -0
- package/dist/utils/node-polyfills.d.ts.map +1 -0
- package/dist/utils/node-polyfills.js +9 -0
- package/dist/utils/node-polyfills.js.map +1 -0
- package/dist/utils/output.js +32 -39
- package/dist/utils/output.js.map +1 -1
- package/dist/utils/repo-factory.d.ts +8 -2
- package/dist/utils/repo-factory.d.ts.map +1 -1
- package/dist/utils/repo-factory.js +38 -47
- package/dist/utils/repo-factory.js.map +1 -1
- package/dist/utils/string-similarity.js +1 -5
- package/dist/utils/string-similarity.js.map +1 -1
- package/dist/utils/text-diff.js +5 -43
- package/dist/utils/text-diff.js.map +1 -1
- package/dist/utils/trace.js +6 -11
- package/dist/utils/trace.js.map +1 -1
- package/package.json +7 -5
- package/src/cli.ts +25 -34
- package/src/commands.ts +75 -11
- package/src/core/change-detection.ts +25 -10
- package/src/core/config.ts +2 -12
- package/src/core/index.ts +5 -5
- package/src/core/move-detection.ts +4 -4
- package/src/core/snapshot.ts +3 -3
- package/src/core/sync-engine.ts +24 -17
- package/src/index.ts +4 -4
- package/src/types/config.ts +8 -8
- package/src/types/index.ts +3 -3
- package/src/utils/directory.ts +1 -1
- package/src/utils/fs.ts +6 -4
- package/src/utils/index.ts +4 -4
- package/src/utils/network-sync.ts +62 -115
- package/src/utils/node-polyfills.ts +8 -0
- package/src/utils/repo-factory.ts +55 -10
- package/src/utils/trace.ts +1 -1
- package/tsconfig.json +2 -1
|
@@ -0,0 +1,155 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|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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/content.js
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.contentHash = contentHash;
|
|
4
|
-
exports.isContentEqual = isContentEqual;
|
|
5
|
-
const crypto_1 = require("crypto");
|
|
1
|
+
import { createHash } from "crypto";
|
|
6
2
|
/**
|
|
7
3
|
* Compute a SHA-256 hash of file content.
|
|
8
4
|
* Used to detect local changes for artifact files without reading remote docs.
|
|
9
5
|
*/
|
|
10
|
-
function contentHash(content) {
|
|
11
|
-
return
|
|
6
|
+
export function contentHash(content) {
|
|
7
|
+
return createHash("sha256").update(content).digest("hex");
|
|
12
8
|
}
|
|
13
9
|
/**
|
|
14
10
|
* Compare two content pieces for equality
|
|
15
11
|
*/
|
|
16
|
-
function isContentEqual(content1, content2) {
|
|
12
|
+
export function isContentEqual(content1, content2) {
|
|
17
13
|
if (content1 === content2)
|
|
18
14
|
return true;
|
|
19
15
|
if (!content1 || !content2)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/utils/content.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/utils/content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAA4B;IACtD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC5D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,QAAoC,EACpC,QAAoC;IAEpC,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACvC,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAEzC,IAAI,OAAO,QAAQ,KAAK,OAAO,QAAQ;QAAE,OAAO,KAAK,CAAC;IAEtD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,QAAQ,KAAK,QAAQ,CAAC;IAC/B,CAAC;SAAM,CAAC;QACN,yEAAyE;QACzE,MAAM,IAAI,GAAG,QAAsB,CAAC;QACpC,MAAM,IAAI,GAAG,QAAsB,CAAC;QAEpC,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QAE9C,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
|
package/dist/utils/directory.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPlainUrl = getPlainUrl;
|
|
4
|
-
exports.findFileInDirectoryHierarchy = findFileInDirectoryHierarchy;
|
|
5
|
-
const automerge_repo_1 = require("@automerge/automerge-repo");
|
|
1
|
+
import { parseAutomergeUrl, stringifyAutomergeUrl, } from "@automerge/automerge-repo";
|
|
6
2
|
/**
|
|
7
3
|
* Get a plain URL (without heads) from any URL.
|
|
8
4
|
* Versioned URLs with heads return view handles, which show a frozen point in time.
|
|
9
5
|
* For internal navigation, we always want to see the CURRENT state of documents.
|
|
10
6
|
*/
|
|
11
|
-
function getPlainUrl(url) {
|
|
12
|
-
const { documentId } =
|
|
13
|
-
return
|
|
7
|
+
export function getPlainUrl(url) {
|
|
8
|
+
const { documentId } = parseAutomergeUrl(url);
|
|
9
|
+
return stringifyAutomergeUrl({ documentId });
|
|
14
10
|
}
|
|
15
11
|
/**
|
|
16
12
|
* Find a file in the directory hierarchy by path.
|
|
@@ -23,7 +19,7 @@ function getPlainUrl(url) {
|
|
|
23
19
|
* 3. Using versioned URLs would make files appear to not exist
|
|
24
20
|
* 4. This would trigger false "remote deletion" detection
|
|
25
21
|
*/
|
|
26
|
-
async function findFileInDirectoryHierarchy(repo, directoryUrl, filePath) {
|
|
22
|
+
export async function findFileInDirectoryHierarchy(repo, directoryUrl, filePath) {
|
|
27
23
|
try {
|
|
28
24
|
const pathParts = filePath.split("/");
|
|
29
25
|
let currentDirUrl = getPlainUrl(directoryUrl);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../../src/utils/directory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"directory.js","sourceRoot":"","sources":["../../src/utils/directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAGnC;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,GAAiB;IAC3C,MAAM,EAAE,UAAU,EAAE,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAC9C,OAAO,qBAAqB,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,IAAU,EACV,YAA0B,EAC1B,QAAgB;IAEhB,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,aAAa,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC;QAE9C,4DAA4D;QAC5D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC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
|
|
|
1
|
-
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"AAQA,OAAO,EAAC,eAAe,EAAW,MAAM,mBAAmB,CAAA;AAG3D;;GAEG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnE;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACvC,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAmBjC;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAwBnE;AAED;;GAEG;AACH,wBAAsB,eAAe,CACpC,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,GAAG,UAAU,CAAC,CAS9B;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACrC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,UAAU,GAC1B,OAAO,CAAC,IAAI,CAAC,CAQf;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ1E;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAahE;AAsBD;;GAEG;AACH,wBAAsB,aAAa,CAClC,OAAO,EAAE,MAAM,EACf,SAAS,UAAQ,EACjB,eAAe,GAAE,MAAM,EAAO,GAC5B,OAAO,CAAC,eAAe,EAAE,CAAC,CAoC5B;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAC7B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAOf;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAC7B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAGf;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACzC,OAAO,EAAE,MAAM,GAAG,UAAU,GAC1B,OAAO,CAAC,MAAM,CAAC,CAIjB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAK/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAO3D"}
|
package/dist/utils/fs.js
CHANGED
|
@@ -1,67 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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.pathExists = pathExists;
|
|
37
|
-
exports.getFileSystemEntry = getFileSystemEntry;
|
|
38
|
-
exports.isTextFile = isTextFile;
|
|
39
|
-
exports.readFileContent = readFileContent;
|
|
40
|
-
exports.writeFileContent = writeFileContent;
|
|
41
|
-
exports.ensureDirectoryExists = ensureDirectoryExists;
|
|
42
|
-
exports.removePath = removePath;
|
|
43
|
-
exports.listDirectory = listDirectory;
|
|
44
|
-
exports.copyFile = copyFile;
|
|
45
|
-
exports.movePath = movePath;
|
|
46
|
-
exports.calculateContentHash = calculateContentHash;
|
|
47
|
-
exports.getMimeType = getMimeType;
|
|
48
|
-
exports.getFileExtension = getFileExtension;
|
|
49
|
-
exports.normalizePath = normalizePath;
|
|
50
|
-
exports.joinAndNormalizePath = joinAndNormalizePath;
|
|
51
|
-
exports.getRelativePath = getRelativePath;
|
|
52
|
-
exports.formatRelativePath = formatRelativePath;
|
|
53
|
-
const fs = __importStar(require("fs/promises"));
|
|
54
|
-
const path = __importStar(require("path"));
|
|
55
|
-
const crypto = __importStar(require("crypto"));
|
|
56
|
-
const glob_1 = require("glob");
|
|
57
|
-
const mimeTypes = __importStar(require("mime-types"));
|
|
58
|
-
const ignore = __importStar(require("ignore"));
|
|
59
|
-
const types_1 = require("../types");
|
|
60
|
-
const mime_types_1 = require("./mime-types");
|
|
1
|
+
import * as fs from "fs/promises";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import * as crypto from "crypto";
|
|
4
|
+
import { glob } from "glob";
|
|
5
|
+
import * as mimeTypes from "mime-types";
|
|
6
|
+
import ignoreModule from "ignore";
|
|
7
|
+
// CJS default export compat under nodenext
|
|
8
|
+
const ignore = ignoreModule.default || ignoreModule;
|
|
9
|
+
import { FileType } from "../types/index.js";
|
|
10
|
+
import { isEnhancedTextFile } from "./mime-types.js";
|
|
61
11
|
/**
|
|
62
12
|
* Check if a path exists
|
|
63
13
|
*/
|
|
64
|
-
async function pathExists(filePath) {
|
|
14
|
+
export async function pathExists(filePath) {
|
|
65
15
|
try {
|
|
66
16
|
await fs.access(filePath);
|
|
67
17
|
return true;
|
|
@@ -73,14 +23,14 @@ async function pathExists(filePath) {
|
|
|
73
23
|
/**
|
|
74
24
|
* Get file system entry metadata
|
|
75
25
|
*/
|
|
76
|
-
async function getFileSystemEntry(filePath) {
|
|
26
|
+
export async function getFileSystemEntry(filePath) {
|
|
77
27
|
try {
|
|
78
28
|
const stats = await fs.stat(filePath);
|
|
79
29
|
const type = stats.isDirectory()
|
|
80
|
-
?
|
|
81
|
-
: (await
|
|
82
|
-
?
|
|
83
|
-
:
|
|
30
|
+
? FileType.DIRECTORY
|
|
31
|
+
: (await isEnhancedTextFile(filePath))
|
|
32
|
+
? FileType.TEXT
|
|
33
|
+
: FileType.BINARY;
|
|
84
34
|
return {
|
|
85
35
|
path: filePath,
|
|
86
36
|
type,
|
|
@@ -96,7 +46,7 @@ async function getFileSystemEntry(filePath) {
|
|
|
96
46
|
/**
|
|
97
47
|
* Determine if a file is text or binary
|
|
98
48
|
*/
|
|
99
|
-
async function isTextFile(filePath) {
|
|
49
|
+
export async function isTextFile(filePath) {
|
|
100
50
|
try {
|
|
101
51
|
const mimeType = mimeTypes.lookup(filePath);
|
|
102
52
|
if (mimeType) {
|
|
@@ -121,8 +71,8 @@ async function isTextFile(filePath) {
|
|
|
121
71
|
/**
|
|
122
72
|
* Read file content as string or buffer
|
|
123
73
|
*/
|
|
124
|
-
async function readFileContent(filePath) {
|
|
125
|
-
const isText = await
|
|
74
|
+
export async function readFileContent(filePath) {
|
|
75
|
+
const isText = await isEnhancedTextFile(filePath);
|
|
126
76
|
if (isText) {
|
|
127
77
|
return await fs.readFile(filePath, "utf8");
|
|
128
78
|
}
|
|
@@ -134,7 +84,7 @@ async function readFileContent(filePath) {
|
|
|
134
84
|
/**
|
|
135
85
|
* Write file content from string or buffer
|
|
136
86
|
*/
|
|
137
|
-
async function writeFileContent(filePath, content) {
|
|
87
|
+
export async function writeFileContent(filePath, content) {
|
|
138
88
|
await ensureDirectoryExists(path.dirname(filePath));
|
|
139
89
|
if (typeof content === "string") {
|
|
140
90
|
await fs.writeFile(filePath, content, "utf8");
|
|
@@ -146,7 +96,7 @@ async function writeFileContent(filePath, content) {
|
|
|
146
96
|
/**
|
|
147
97
|
* Ensure directory exists, creating it if necessary
|
|
148
98
|
*/
|
|
149
|
-
async function ensureDirectoryExists(dirPath) {
|
|
99
|
+
export async function ensureDirectoryExists(dirPath) {
|
|
150
100
|
try {
|
|
151
101
|
await fs.mkdir(dirPath, { recursive: true });
|
|
152
102
|
}
|
|
@@ -159,7 +109,7 @@ async function ensureDirectoryExists(dirPath) {
|
|
|
159
109
|
/**
|
|
160
110
|
* Remove file or directory
|
|
161
111
|
*/
|
|
162
|
-
async function removePath(filePath) {
|
|
112
|
+
export async function removePath(filePath) {
|
|
163
113
|
try {
|
|
164
114
|
const stats = await fs.stat(filePath);
|
|
165
115
|
if (stats.isDirectory()) {
|
|
@@ -185,13 +135,13 @@ function isExcluded(filePath, basePath, excludePatterns) {
|
|
|
185
135
|
const relativePath = path.relative(basePath, filePath);
|
|
186
136
|
// Use the ignore library which implements proper .gitignore semantics
|
|
187
137
|
// This is the same library used by ESLint and other major tools
|
|
188
|
-
const ig = ignore
|
|
138
|
+
const ig = ignore().add(excludePatterns);
|
|
189
139
|
return ig.ignores(relativePath);
|
|
190
140
|
}
|
|
191
141
|
/**
|
|
192
142
|
* List directory contents with metadata
|
|
193
143
|
*/
|
|
194
|
-
async function listDirectory(dirPath, recursive = false, excludePatterns = []) {
|
|
144
|
+
export async function listDirectory(dirPath, recursive = false, excludePatterns = []) {
|
|
195
145
|
const entries = [];
|
|
196
146
|
try {
|
|
197
147
|
// Construct pattern using path.join for proper cross-platform handling
|
|
@@ -202,7 +152,7 @@ async function listDirectory(dirPath, recursive = false, excludePatterns = []) {
|
|
|
202
152
|
const normalizedPattern = pattern.replace(/\\/g, "/");
|
|
203
153
|
// Use glob to get all paths (with dot files)
|
|
204
154
|
// Note: We don't use glob's ignore option because it doesn't support gitignore semantics
|
|
205
|
-
const paths = await
|
|
155
|
+
const paths = await glob(normalizedPattern, {
|
|
206
156
|
dot: true,
|
|
207
157
|
});
|
|
208
158
|
// Parallelize all stat calls for better performance
|
|
@@ -224,7 +174,7 @@ async function listDirectory(dirPath, recursive = false, excludePatterns = []) {
|
|
|
224
174
|
/**
|
|
225
175
|
* Copy file with metadata preservation
|
|
226
176
|
*/
|
|
227
|
-
async function copyFile(sourcePath, destPath) {
|
|
177
|
+
export async function copyFile(sourcePath, destPath) {
|
|
228
178
|
await ensureDirectoryExists(path.dirname(destPath));
|
|
229
179
|
await fs.copyFile(sourcePath, destPath);
|
|
230
180
|
// Preserve file permissions
|
|
@@ -234,14 +184,14 @@ async function copyFile(sourcePath, destPath) {
|
|
|
234
184
|
/**
|
|
235
185
|
* Move/rename file or directory
|
|
236
186
|
*/
|
|
237
|
-
async function movePath(sourcePath, destPath) {
|
|
187
|
+
export async function movePath(sourcePath, destPath) {
|
|
238
188
|
await ensureDirectoryExists(path.dirname(destPath));
|
|
239
189
|
await fs.rename(sourcePath, destPath);
|
|
240
190
|
}
|
|
241
191
|
/**
|
|
242
192
|
* Calculate content hash for change detection
|
|
243
193
|
*/
|
|
244
|
-
async function calculateContentHash(content) {
|
|
194
|
+
export async function calculateContentHash(content) {
|
|
245
195
|
const hash = crypto.createHash("sha256");
|
|
246
196
|
hash.update(content);
|
|
247
197
|
return hash.digest("hex");
|
|
@@ -249,13 +199,13 @@ async function calculateContentHash(content) {
|
|
|
249
199
|
/**
|
|
250
200
|
* Get MIME type for file
|
|
251
201
|
*/
|
|
252
|
-
function getMimeType(filePath) {
|
|
202
|
+
export function getMimeType(filePath) {
|
|
253
203
|
return mimeTypes.lookup(filePath) || "application/octet-stream";
|
|
254
204
|
}
|
|
255
205
|
/**
|
|
256
206
|
* Get file extension
|
|
257
207
|
*/
|
|
258
|
-
function getFileExtension(filePath) {
|
|
208
|
+
export function getFileExtension(filePath) {
|
|
259
209
|
const ext = path.extname(filePath);
|
|
260
210
|
return ext.startsWith(".") ? ext.slice(1) : ext;
|
|
261
211
|
}
|
|
@@ -263,14 +213,14 @@ function getFileExtension(filePath) {
|
|
|
263
213
|
* Normalize path separators for cross-platform compatibility
|
|
264
214
|
* Converts all path separators to forward slashes for consistent storage
|
|
265
215
|
*/
|
|
266
|
-
function normalizePath(filePath) {
|
|
216
|
+
export function normalizePath(filePath) {
|
|
267
217
|
return path.posix.normalize(filePath.replace(/\\/g, "/"));
|
|
268
218
|
}
|
|
269
219
|
/**
|
|
270
220
|
* Join paths and normalize separators for cross-platform compatibility
|
|
271
221
|
* Use this instead of string concatenation to ensure proper path handling on Windows
|
|
272
222
|
*/
|
|
273
|
-
function joinAndNormalizePath(...paths) {
|
|
223
|
+
export function joinAndNormalizePath(...paths) {
|
|
274
224
|
// Use path.join to properly handle path construction (handles Windows drive letters, etc.)
|
|
275
225
|
const joined = path.join(...paths);
|
|
276
226
|
// Then normalize to forward slashes for consistent storage/comparison
|
|
@@ -279,7 +229,7 @@ function joinAndNormalizePath(...paths) {
|
|
|
279
229
|
/**
|
|
280
230
|
* Get relative path from base directory
|
|
281
231
|
*/
|
|
282
|
-
function getRelativePath(basePath, filePath) {
|
|
232
|
+
export function getRelativePath(basePath, filePath) {
|
|
283
233
|
return normalizePath(path.relative(basePath, filePath));
|
|
284
234
|
}
|
|
285
235
|
/**
|
|
@@ -287,7 +237,7 @@ function getRelativePath(basePath, filePath) {
|
|
|
287
237
|
* Ensures paths like "src" become "./src" for clarity
|
|
288
238
|
* Leaves absolute paths and paths already starting with . or .. unchanged
|
|
289
239
|
*/
|
|
290
|
-
function formatRelativePath(filePath) {
|
|
240
|
+
export function formatRelativePath(filePath) {
|
|
291
241
|
// Already starts with . or / - leave as-is
|
|
292
242
|
if (filePath.startsWith(".") || filePath.startsWith("/")) {
|
|
293
243
|
return filePath;
|
package/dist/utils/fs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAA;AACzB,OAAO,KAAK,SAAS,MAAM,YAAY,CAAA;AACvC,OAAO,YAAY,MAAM,QAAQ,CAAA;AACjC,2CAA2C;AAC3C,MAAM,MAAM,GAAI,YAAoB,CAAC,OAAO,IAAI,YAAY,CAAA;AAC5D,OAAO,EAAkB,QAAQ,EAAC,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAA;AAElD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,QAAgB;IAChD,IAAI,CAAC;QACJ,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QACzB,OAAO,IAAI,CAAA;IACZ,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAA;IACb,CAAC;AACF,CAAC;AAED;;GAEG;AACH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KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAA;AAC1D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAG,KAAe;IACtD,2FAA2F;IAC3F,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAA;IAClC,sEAAsE;IACtE,OAAO,aAAa,CAAC,MAAM,CAAC,CAAA;AAC7B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB,EAAE,QAAgB;IACjE,OAAO,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAA;AACxD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IAClD,2CAA2C;IAC3C,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1D,OAAO,QAAQ,CAAA;IAChB,CAAC;IACD,4BAA4B;IAC5B,OAAO,KAAK,QAAQ,EAAE,CAAA;AACvB,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from "./fs";
|
|
2
|
-
export * from "./mime-types";
|
|
3
|
-
export * from "./directory";
|
|
4
|
-
export * from "./text-diff";
|
|
1
|
+
export * from "./fs.js";
|
|
2
|
+
export * from "./mime-types.js";
|
|
3
|
+
export * from "./directory.js";
|
|
4
|
+
export * from "./text-diff.js";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./fs"), exports);
|
|
18
|
-
__exportStar(require("./mime-types"), exports);
|
|
19
|
-
__exportStar(require("./directory"), exports);
|
|
20
|
-
__exportStar(require("./text-diff"), exports);
|
|
1
|
+
export * from "./fs.js";
|
|
2
|
+
export * from "./mime-types.js";
|
|
3
|
+
export * from "./directory.js";
|
|
4
|
+
export * from "./text-diff.js";
|
|
21
5
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA"}
|