@aigne/afs-git 1.1.0-beta → 1.11.0-beta
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 +46 -41
- package/dist/index.cjs +501 -0
- package/dist/index.d.cts +148 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +148 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +502 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +29 -43
- package/CHANGELOG.md +0 -45
- package/lib/cjs/index.d.ts +0 -129
- package/lib/cjs/index.js +0 -601
- package/lib/cjs/package.json +0 -3
- package/lib/dts/index.d.ts +0 -129
- package/lib/esm/index.d.ts +0 -129
- package/lib/esm/index.js +0 -597
- package/lib/esm/package.json +0 -3
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { mkdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { basename, dirname, isAbsolute, join } from "node:path";
|
|
6
|
+
import { promisify } from "node:util";
|
|
7
|
+
import { camelize, optionalize, zodParse } from "@aigne/afs/utils/zod";
|
|
8
|
+
import { simpleGit } from "simple-git";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
|
|
11
|
+
//#region src/index.ts
|
|
12
|
+
const execFileAsync = promisify(execFile);
|
|
13
|
+
const LIST_MAX_LIMIT = 1e3;
|
|
14
|
+
const afsGitOptionsSchema = camelize(z.object({
|
|
15
|
+
name: optionalize(z.string()),
|
|
16
|
+
repoPath: z.string().describe("The path to the git repository"),
|
|
17
|
+
description: optionalize(z.string().describe("A description of the repository")),
|
|
18
|
+
branches: optionalize(z.array(z.string()).describe("List of branches to expose")),
|
|
19
|
+
accessMode: optionalize(z.enum(["readonly", "readwrite"]).describe("Access mode for this module")),
|
|
20
|
+
autoCommit: optionalize(z.boolean().describe("Automatically commit changes after write operations")),
|
|
21
|
+
commitAuthor: optionalize(z.object({
|
|
22
|
+
name: z.string(),
|
|
23
|
+
email: z.string()
|
|
24
|
+
}))
|
|
25
|
+
}));
|
|
26
|
+
var AFSGit = class AFSGit {
|
|
27
|
+
static schema() {
|
|
28
|
+
return afsGitOptionsSchema;
|
|
29
|
+
}
|
|
30
|
+
static async load({ filepath, parsed }) {
|
|
31
|
+
return new AFSGit({
|
|
32
|
+
...await AFSGit.schema().parseAsync(parsed),
|
|
33
|
+
cwd: dirname(filepath)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
git;
|
|
37
|
+
tempBase;
|
|
38
|
+
worktrees = /* @__PURE__ */ new Map();
|
|
39
|
+
repoHash;
|
|
40
|
+
constructor(options) {
|
|
41
|
+
this.options = options;
|
|
42
|
+
zodParse(afsGitOptionsSchema, options);
|
|
43
|
+
let repoPath;
|
|
44
|
+
if (isAbsolute(options.repoPath)) repoPath = options.repoPath;
|
|
45
|
+
else repoPath = join(options.cwd || process.cwd(), options.repoPath);
|
|
46
|
+
this.options.repoPath = repoPath;
|
|
47
|
+
this.name = options.name || basename(repoPath) || "git";
|
|
48
|
+
this.description = options.description;
|
|
49
|
+
this.accessMode = options.accessMode ?? "readonly";
|
|
50
|
+
this.git = simpleGit(repoPath);
|
|
51
|
+
this.repoHash = createHash("md5").update(repoPath).digest("hex").substring(0, 8);
|
|
52
|
+
this.tempBase = join(tmpdir(), `afs-git-${this.repoHash}`);
|
|
53
|
+
}
|
|
54
|
+
name;
|
|
55
|
+
description;
|
|
56
|
+
accessMode;
|
|
57
|
+
/**
|
|
58
|
+
* Parse AFS path into branch and file path
|
|
59
|
+
* Branch names may contain slashes and are encoded with ~ in paths
|
|
60
|
+
* Examples:
|
|
61
|
+
* "/" -> { branch: undefined, filePath: "" }
|
|
62
|
+
* "/main" -> { branch: "main", filePath: "" }
|
|
63
|
+
* "/feature~new-feature" -> { branch: "feature/new-feature", filePath: "" }
|
|
64
|
+
* "/main/src/index.ts" -> { branch: "main", filePath: "src/index.ts" }
|
|
65
|
+
*/
|
|
66
|
+
parsePath(path) {
|
|
67
|
+
const segments = join("/", path).split("/").filter(Boolean);
|
|
68
|
+
if (segments.length === 0) return {
|
|
69
|
+
branch: void 0,
|
|
70
|
+
filePath: ""
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
branch: segments[0].replace(/~/g, "/"),
|
|
74
|
+
filePath: segments.slice(1).join("/")
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Detect MIME type based on file extension
|
|
79
|
+
*/
|
|
80
|
+
getMimeType(filePath) {
|
|
81
|
+
return {
|
|
82
|
+
png: "image/png",
|
|
83
|
+
jpg: "image/jpeg",
|
|
84
|
+
jpeg: "image/jpeg",
|
|
85
|
+
gif: "image/gif",
|
|
86
|
+
bmp: "image/bmp",
|
|
87
|
+
webp: "image/webp",
|
|
88
|
+
svg: "image/svg+xml",
|
|
89
|
+
ico: "image/x-icon",
|
|
90
|
+
pdf: "application/pdf",
|
|
91
|
+
txt: "text/plain",
|
|
92
|
+
md: "text/markdown",
|
|
93
|
+
js: "text/javascript",
|
|
94
|
+
ts: "text/typescript",
|
|
95
|
+
json: "application/json",
|
|
96
|
+
html: "text/html",
|
|
97
|
+
css: "text/css",
|
|
98
|
+
xml: "text/xml"
|
|
99
|
+
}[filePath.split(".").pop()?.toLowerCase() || ""] || "application/octet-stream";
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Check if file is likely binary based on extension
|
|
103
|
+
*/
|
|
104
|
+
isBinaryFile(filePath) {
|
|
105
|
+
const ext = filePath.split(".").pop()?.toLowerCase();
|
|
106
|
+
return [
|
|
107
|
+
"png",
|
|
108
|
+
"jpg",
|
|
109
|
+
"jpeg",
|
|
110
|
+
"gif",
|
|
111
|
+
"bmp",
|
|
112
|
+
"webp",
|
|
113
|
+
"ico",
|
|
114
|
+
"pdf",
|
|
115
|
+
"zip",
|
|
116
|
+
"tar",
|
|
117
|
+
"gz",
|
|
118
|
+
"exe",
|
|
119
|
+
"dll",
|
|
120
|
+
"so",
|
|
121
|
+
"dylib",
|
|
122
|
+
"wasm"
|
|
123
|
+
].includes(ext || "");
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get list of available branches
|
|
127
|
+
*/
|
|
128
|
+
async getBranches() {
|
|
129
|
+
const allBranches = (await this.git.branchLocal()).all;
|
|
130
|
+
if (this.options.branches && this.options.branches.length > 0) return allBranches.filter((branch) => this.options.branches.includes(branch));
|
|
131
|
+
return allBranches;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Ensure worktree exists for a branch (lazy creation)
|
|
135
|
+
*/
|
|
136
|
+
async ensureWorktree(branch) {
|
|
137
|
+
if (this.worktrees.has(branch)) return this.worktrees.get(branch);
|
|
138
|
+
if ((await this.git.revparse(["--abbrev-ref", "HEAD"])).trim() === branch) {
|
|
139
|
+
this.worktrees.set(branch, this.options.repoPath);
|
|
140
|
+
return this.options.repoPath;
|
|
141
|
+
}
|
|
142
|
+
const worktreePath = join(this.tempBase, branch);
|
|
143
|
+
if (!await stat(worktreePath).then(() => true).catch(() => false)) {
|
|
144
|
+
await mkdir(this.tempBase, { recursive: true });
|
|
145
|
+
await this.git.raw([
|
|
146
|
+
"worktree",
|
|
147
|
+
"add",
|
|
148
|
+
worktreePath,
|
|
149
|
+
branch
|
|
150
|
+
]);
|
|
151
|
+
}
|
|
152
|
+
this.worktrees.set(branch, worktreePath);
|
|
153
|
+
return worktreePath;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* List files using git ls-tree (no worktree needed)
|
|
157
|
+
*/
|
|
158
|
+
async listWithGitLsTree(branch, path, options) {
|
|
159
|
+
const maxDepth = options?.maxDepth ?? 1;
|
|
160
|
+
const limit = Math.min(options?.limit || LIST_MAX_LIMIT, LIST_MAX_LIMIT);
|
|
161
|
+
const entries = [];
|
|
162
|
+
const targetPath = path || "";
|
|
163
|
+
const treeish = targetPath ? `${branch}:${targetPath}` : branch;
|
|
164
|
+
try {
|
|
165
|
+
const pathType = await this.git.raw([
|
|
166
|
+
"cat-file",
|
|
167
|
+
"-t",
|
|
168
|
+
treeish
|
|
169
|
+
]).then((t) => t.trim()).catch(() => null);
|
|
170
|
+
if (pathType === null) return { data: [] };
|
|
171
|
+
if (pathType === "blob") {
|
|
172
|
+
const size = await this.git.raw([
|
|
173
|
+
"cat-file",
|
|
174
|
+
"-s",
|
|
175
|
+
treeish
|
|
176
|
+
]).then((s) => Number.parseInt(s.trim(), 10));
|
|
177
|
+
const afsPath = this.buildPath(branch, path);
|
|
178
|
+
entries.push({
|
|
179
|
+
id: afsPath,
|
|
180
|
+
path: afsPath,
|
|
181
|
+
metadata: {
|
|
182
|
+
type: "file",
|
|
183
|
+
size
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
return { data: entries };
|
|
187
|
+
}
|
|
188
|
+
const queue = [{
|
|
189
|
+
path: targetPath,
|
|
190
|
+
depth: 0
|
|
191
|
+
}];
|
|
192
|
+
while (queue.length > 0) {
|
|
193
|
+
const { path: itemPath, depth } = queue.shift();
|
|
194
|
+
const itemTreeish = itemPath ? `${branch}:${itemPath}` : branch;
|
|
195
|
+
const lines = (await this.git.raw([
|
|
196
|
+
"ls-tree",
|
|
197
|
+
"-l",
|
|
198
|
+
itemTreeish
|
|
199
|
+
])).split("\n").filter((line) => line.trim()).slice(0, limit - entries.length);
|
|
200
|
+
for (const line of lines) {
|
|
201
|
+
const match = line.match(/^(\d+)\s+(blob|tree)\s+(\w+)\s+(-|\d+)\s+(.+)$/);
|
|
202
|
+
if (!match) continue;
|
|
203
|
+
const type = match[2];
|
|
204
|
+
const sizeStr = match[4];
|
|
205
|
+
const name = match[5];
|
|
206
|
+
const isDirectory = type === "tree";
|
|
207
|
+
const size = sizeStr === "-" ? void 0 : Number.parseInt(sizeStr, 10);
|
|
208
|
+
const fullPath = itemPath ? `${itemPath}/${name}` : name;
|
|
209
|
+
const afsPath = this.buildPath(branch, fullPath);
|
|
210
|
+
entries.push({
|
|
211
|
+
id: afsPath,
|
|
212
|
+
path: afsPath,
|
|
213
|
+
metadata: {
|
|
214
|
+
type: isDirectory ? "directory" : "file",
|
|
215
|
+
size
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
if (isDirectory && depth + 1 < maxDepth) queue.push({
|
|
219
|
+
path: fullPath,
|
|
220
|
+
depth: depth + 1
|
|
221
|
+
});
|
|
222
|
+
if (entries.length >= limit) return { data: entries };
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return { data: entries };
|
|
226
|
+
} catch (error) {
|
|
227
|
+
return {
|
|
228
|
+
data: [],
|
|
229
|
+
message: error.message
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Build AFS path with encoded branch name
|
|
235
|
+
* Branch names with slashes are encoded by replacing / with ~
|
|
236
|
+
* @param branch Branch name (may contain slashes)
|
|
237
|
+
* @param filePath File path within branch
|
|
238
|
+
*/
|
|
239
|
+
buildPath(branch, filePath) {
|
|
240
|
+
const encodedBranch = branch.replace(/\//g, "~");
|
|
241
|
+
if (!filePath) return `/${encodedBranch}`;
|
|
242
|
+
return `/${encodedBranch}/${filePath}`;
|
|
243
|
+
}
|
|
244
|
+
async list(path, options) {
|
|
245
|
+
const { branch, filePath } = this.parsePath(path);
|
|
246
|
+
if (!branch) return { data: (await this.getBranches()).map((name) => {
|
|
247
|
+
const encodedPath = this.buildPath(name);
|
|
248
|
+
return {
|
|
249
|
+
id: encodedPath,
|
|
250
|
+
path: encodedPath,
|
|
251
|
+
metadata: { type: "directory" }
|
|
252
|
+
};
|
|
253
|
+
}) };
|
|
254
|
+
return this.listWithGitLsTree(branch, filePath, options);
|
|
255
|
+
}
|
|
256
|
+
async read(path, _options) {
|
|
257
|
+
const { branch, filePath } = this.parsePath(path);
|
|
258
|
+
if (!branch) return { data: {
|
|
259
|
+
id: "/",
|
|
260
|
+
path: "/",
|
|
261
|
+
metadata: { type: "directory" }
|
|
262
|
+
} };
|
|
263
|
+
if (!filePath) {
|
|
264
|
+
const branchPath = this.buildPath(branch);
|
|
265
|
+
return { data: {
|
|
266
|
+
id: branchPath,
|
|
267
|
+
path: branchPath,
|
|
268
|
+
metadata: { type: "directory" }
|
|
269
|
+
} };
|
|
270
|
+
}
|
|
271
|
+
try {
|
|
272
|
+
if (await this.git.raw([
|
|
273
|
+
"cat-file",
|
|
274
|
+
"-t",
|
|
275
|
+
`${branch}:${filePath}`
|
|
276
|
+
]).then((t) => t.trim()) === "tree") {
|
|
277
|
+
const afsPath$1 = this.buildPath(branch, filePath);
|
|
278
|
+
return { data: {
|
|
279
|
+
id: afsPath$1,
|
|
280
|
+
path: afsPath$1,
|
|
281
|
+
metadata: { type: "directory" }
|
|
282
|
+
} };
|
|
283
|
+
}
|
|
284
|
+
const size = await this.git.raw([
|
|
285
|
+
"cat-file",
|
|
286
|
+
"-s",
|
|
287
|
+
`${branch}:${filePath}`
|
|
288
|
+
]).then((s) => Number.parseInt(s.trim(), 10));
|
|
289
|
+
const mimeType = this.getMimeType(filePath);
|
|
290
|
+
const isBinary = this.isBinaryFile(filePath);
|
|
291
|
+
let content;
|
|
292
|
+
const metadata = {
|
|
293
|
+
type: "file",
|
|
294
|
+
size,
|
|
295
|
+
mimeType
|
|
296
|
+
};
|
|
297
|
+
if (isBinary) {
|
|
298
|
+
const { stdout } = await execFileAsync("git", [
|
|
299
|
+
"cat-file",
|
|
300
|
+
"-p",
|
|
301
|
+
`${branch}:${filePath}`
|
|
302
|
+
], {
|
|
303
|
+
cwd: this.options.repoPath,
|
|
304
|
+
encoding: "buffer",
|
|
305
|
+
maxBuffer: 10 * 1024 * 1024
|
|
306
|
+
});
|
|
307
|
+
content = stdout.toString("base64");
|
|
308
|
+
metadata.contentType = "base64";
|
|
309
|
+
} else content = await this.git.show([`${branch}:${filePath}`]);
|
|
310
|
+
const afsPath = this.buildPath(branch, filePath);
|
|
311
|
+
return { data: {
|
|
312
|
+
id: afsPath,
|
|
313
|
+
path: afsPath,
|
|
314
|
+
content,
|
|
315
|
+
metadata
|
|
316
|
+
} };
|
|
317
|
+
} catch (error) {
|
|
318
|
+
return {
|
|
319
|
+
data: void 0,
|
|
320
|
+
message: error.message
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
async write(path, entry, options) {
|
|
325
|
+
const { branch, filePath } = this.parsePath(path);
|
|
326
|
+
if (!branch || !filePath) throw new Error("Cannot write to root or branch root");
|
|
327
|
+
const worktreePath = await this.ensureWorktree(branch);
|
|
328
|
+
const fullPath = join(worktreePath, filePath);
|
|
329
|
+
const append = options?.append ?? false;
|
|
330
|
+
await mkdir(dirname(fullPath), { recursive: true });
|
|
331
|
+
if (entry.content !== void 0) {
|
|
332
|
+
let contentToWrite;
|
|
333
|
+
if (typeof entry.content === "string") contentToWrite = entry.content;
|
|
334
|
+
else contentToWrite = JSON.stringify(entry.content, null, 2);
|
|
335
|
+
await writeFile(fullPath, contentToWrite, {
|
|
336
|
+
encoding: "utf8",
|
|
337
|
+
flag: append ? "a" : "w"
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
if (this.options.autoCommit) {
|
|
341
|
+
const gitInstance = simpleGit(worktreePath);
|
|
342
|
+
await gitInstance.add(filePath);
|
|
343
|
+
if (this.options.commitAuthor) {
|
|
344
|
+
await gitInstance.addConfig("user.name", this.options.commitAuthor.name, void 0, "local");
|
|
345
|
+
await gitInstance.addConfig("user.email", this.options.commitAuthor.email, void 0, "local");
|
|
346
|
+
}
|
|
347
|
+
await gitInstance.commit(`Update ${filePath}`);
|
|
348
|
+
}
|
|
349
|
+
const stats = await stat(fullPath);
|
|
350
|
+
const afsPath = this.buildPath(branch, filePath);
|
|
351
|
+
return { data: {
|
|
352
|
+
id: afsPath,
|
|
353
|
+
path: afsPath,
|
|
354
|
+
content: entry.content,
|
|
355
|
+
summary: entry.summary,
|
|
356
|
+
createdAt: stats.birthtime,
|
|
357
|
+
updatedAt: stats.mtime,
|
|
358
|
+
metadata: {
|
|
359
|
+
...entry.metadata,
|
|
360
|
+
type: stats.isDirectory() ? "directory" : "file",
|
|
361
|
+
size: stats.size
|
|
362
|
+
},
|
|
363
|
+
userId: entry.userId,
|
|
364
|
+
sessionId: entry.sessionId,
|
|
365
|
+
linkTo: entry.linkTo
|
|
366
|
+
} };
|
|
367
|
+
}
|
|
368
|
+
async delete(path, options) {
|
|
369
|
+
const { branch, filePath } = this.parsePath(path);
|
|
370
|
+
if (!branch || !filePath) throw new Error("Cannot delete root or branch root");
|
|
371
|
+
const worktreePath = await this.ensureWorktree(branch);
|
|
372
|
+
const fullPath = join(worktreePath, filePath);
|
|
373
|
+
const recursive = options?.recursive ?? false;
|
|
374
|
+
if ((await stat(fullPath)).isDirectory() && !recursive) throw new Error(`Cannot delete directory '${path}' without recursive option. Set recursive: true to delete directories.`);
|
|
375
|
+
await rm(fullPath, {
|
|
376
|
+
recursive,
|
|
377
|
+
force: true
|
|
378
|
+
});
|
|
379
|
+
if (this.options.autoCommit) {
|
|
380
|
+
const gitInstance = simpleGit(worktreePath);
|
|
381
|
+
await gitInstance.add(filePath);
|
|
382
|
+
if (this.options.commitAuthor) {
|
|
383
|
+
await gitInstance.addConfig("user.name", this.options.commitAuthor.name, void 0, "local");
|
|
384
|
+
await gitInstance.addConfig("user.email", this.options.commitAuthor.email, void 0, "local");
|
|
385
|
+
}
|
|
386
|
+
await gitInstance.commit(`Delete ${filePath}`);
|
|
387
|
+
}
|
|
388
|
+
return { message: `Successfully deleted: ${path}` };
|
|
389
|
+
}
|
|
390
|
+
async rename(oldPath, newPath, options) {
|
|
391
|
+
const { branch: oldBranch, filePath: oldFilePath } = this.parsePath(oldPath);
|
|
392
|
+
const { branch: newBranch, filePath: newFilePath } = this.parsePath(newPath);
|
|
393
|
+
if (!oldBranch || !oldFilePath) throw new Error("Cannot rename from root or branch root");
|
|
394
|
+
if (!newBranch || !newFilePath) throw new Error("Cannot rename to root or branch root");
|
|
395
|
+
if (oldBranch !== newBranch) throw new Error("Cannot rename across branches");
|
|
396
|
+
const worktreePath = await this.ensureWorktree(oldBranch);
|
|
397
|
+
const oldFullPath = join(worktreePath, oldFilePath);
|
|
398
|
+
const newFullPath = join(worktreePath, newFilePath);
|
|
399
|
+
const overwrite = options?.overwrite ?? false;
|
|
400
|
+
await stat(oldFullPath);
|
|
401
|
+
try {
|
|
402
|
+
await stat(newFullPath);
|
|
403
|
+
if (!overwrite) throw new Error(`Destination '${newPath}' already exists. Set overwrite: true to replace it.`);
|
|
404
|
+
} catch (error) {
|
|
405
|
+
if (error.code !== "ENOENT") throw error;
|
|
406
|
+
}
|
|
407
|
+
await mkdir(dirname(newFullPath), { recursive: true });
|
|
408
|
+
await rename(oldFullPath, newFullPath);
|
|
409
|
+
if (this.options.autoCommit) {
|
|
410
|
+
const gitInstance = simpleGit(worktreePath);
|
|
411
|
+
await gitInstance.add([oldFilePath, newFilePath]);
|
|
412
|
+
if (this.options.commitAuthor) {
|
|
413
|
+
await gitInstance.addConfig("user.name", this.options.commitAuthor.name, void 0, "local");
|
|
414
|
+
await gitInstance.addConfig("user.email", this.options.commitAuthor.email, void 0, "local");
|
|
415
|
+
}
|
|
416
|
+
await gitInstance.commit(`Rename ${oldFilePath} to ${newFilePath}`);
|
|
417
|
+
}
|
|
418
|
+
return { message: `Successfully renamed '${oldPath}' to '${newPath}'` };
|
|
419
|
+
}
|
|
420
|
+
async search(path, query, options) {
|
|
421
|
+
const { branch, filePath } = this.parsePath(path);
|
|
422
|
+
if (!branch) return {
|
|
423
|
+
data: [],
|
|
424
|
+
message: "Search requires a branch path"
|
|
425
|
+
};
|
|
426
|
+
const limit = Math.min(options?.limit || LIST_MAX_LIMIT, LIST_MAX_LIMIT);
|
|
427
|
+
try {
|
|
428
|
+
const args = [
|
|
429
|
+
"grep",
|
|
430
|
+
"-n",
|
|
431
|
+
"-I"
|
|
432
|
+
];
|
|
433
|
+
if (options?.caseSensitive === false) args.push("-i");
|
|
434
|
+
args.push(query, branch);
|
|
435
|
+
if (filePath) args.push("--", filePath);
|
|
436
|
+
const lines = (await this.git.raw(args)).split("\n").filter((line) => line.trim());
|
|
437
|
+
const entries = [];
|
|
438
|
+
const processedFiles = /* @__PURE__ */ new Set();
|
|
439
|
+
for (const line of lines) {
|
|
440
|
+
let matchPath;
|
|
441
|
+
let lineNum;
|
|
442
|
+
let content;
|
|
443
|
+
const matchWithBranch = line.match(/^[^:]+:([^:]+):(\d+):(.+)$/);
|
|
444
|
+
if (matchWithBranch) {
|
|
445
|
+
matchPath = matchWithBranch[1];
|
|
446
|
+
lineNum = matchWithBranch[2];
|
|
447
|
+
content = matchWithBranch[3];
|
|
448
|
+
} else {
|
|
449
|
+
const matchNoBranch = line.match(/^([^:]+):(\d+):(.+)$/);
|
|
450
|
+
if (!matchNoBranch) continue;
|
|
451
|
+
matchPath = matchNoBranch[1];
|
|
452
|
+
lineNum = matchNoBranch[2];
|
|
453
|
+
content = matchNoBranch[3];
|
|
454
|
+
}
|
|
455
|
+
const afsPath = this.buildPath(branch, matchPath);
|
|
456
|
+
if (processedFiles.has(afsPath)) continue;
|
|
457
|
+
processedFiles.add(afsPath);
|
|
458
|
+
entries.push({
|
|
459
|
+
id: afsPath,
|
|
460
|
+
path: afsPath,
|
|
461
|
+
summary: `Line ${lineNum}: ${content}`,
|
|
462
|
+
metadata: { type: "file" }
|
|
463
|
+
});
|
|
464
|
+
if (entries.length >= limit) break;
|
|
465
|
+
}
|
|
466
|
+
return {
|
|
467
|
+
data: entries,
|
|
468
|
+
message: entries.length >= limit ? `Results truncated to limit ${limit}` : void 0
|
|
469
|
+
};
|
|
470
|
+
} catch (error) {
|
|
471
|
+
if (error.message.includes("did not match any file(s)")) return { data: [] };
|
|
472
|
+
return {
|
|
473
|
+
data: [],
|
|
474
|
+
message: error.message
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Cleanup all worktrees (useful when unmounting)
|
|
480
|
+
*/
|
|
481
|
+
async cleanup() {
|
|
482
|
+
for (const [_branch, worktreePath] of this.worktrees) try {
|
|
483
|
+
await this.git.raw([
|
|
484
|
+
"worktree",
|
|
485
|
+
"remove",
|
|
486
|
+
worktreePath,
|
|
487
|
+
"--force"
|
|
488
|
+
]);
|
|
489
|
+
} catch (_error) {}
|
|
490
|
+
this.worktrees.clear();
|
|
491
|
+
try {
|
|
492
|
+
await rm(this.tempBase, {
|
|
493
|
+
recursive: true,
|
|
494
|
+
force: true
|
|
495
|
+
});
|
|
496
|
+
} catch {}
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
//#endregion
|
|
501
|
+
export { AFSGit };
|
|
502
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["afsPath"],"sources":["../src/index.ts"],"sourcesContent":["import { execFile } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport { mkdir, rename, rm, stat, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { basename, dirname, isAbsolute, join } from \"node:path\";\nimport { promisify } from \"node:util\";\n\nconst execFileAsync = promisify(execFile);\n\nimport type {\n AFSAccessMode,\n AFSDeleteOptions,\n AFSDeleteResult,\n AFSEntry,\n AFSListOptions,\n AFSListResult,\n AFSModule,\n AFSModuleClass,\n AFSModuleLoadParams,\n AFSReadOptions,\n AFSReadResult,\n AFSRenameOptions,\n AFSSearchOptions,\n AFSSearchResult,\n AFSWriteEntryPayload,\n AFSWriteOptions,\n AFSWriteResult,\n} from \"@aigne/afs\";\nimport { camelize, optionalize, zodParse } from \"@aigne/afs/utils/zod\";\nimport { type SimpleGit, simpleGit } from \"simple-git\";\nimport { z } from \"zod\";\n\nconst LIST_MAX_LIMIT = 1000;\n\nexport interface AFSGitOptions {\n name?: string;\n repoPath: string;\n description?: string;\n branches?: string[];\n /**\n * Access mode for this module.\n * - \"readonly\": Only read operations are allowed, uses git commands (no worktree)\n * - \"readwrite\": All operations are allowed, creates worktrees as needed\n * @default \"readonly\"\n */\n accessMode?: AFSAccessMode;\n /**\n * Automatically commit changes after write operations\n * @default false\n */\n autoCommit?: boolean;\n /**\n * Author information for commits when autoCommit is enabled\n */\n commitAuthor?: {\n name: string;\n email: string;\n };\n}\n\nconst afsGitOptionsSchema = camelize(\n z.object({\n name: optionalize(z.string()),\n repoPath: z.string().describe(\"The path to the git repository\"),\n description: optionalize(z.string().describe(\"A description of the repository\")),\n branches: optionalize(z.array(z.string()).describe(\"List of branches to expose\")),\n accessMode: optionalize(\n z.enum([\"readonly\", \"readwrite\"]).describe(\"Access mode for this module\"),\n ),\n autoCommit: optionalize(\n z.boolean().describe(\"Automatically commit changes after write operations\"),\n ),\n commitAuthor: optionalize(\n z.object({\n name: z.string(),\n email: z.string(),\n }),\n ),\n }),\n);\n\nexport class AFSGit implements AFSModule {\n static schema() {\n return afsGitOptionsSchema;\n }\n\n static async load({ filepath, parsed }: AFSModuleLoadParams) {\n const valid = await AFSGit.schema().parseAsync(parsed);\n return new AFSGit({ ...valid, cwd: dirname(filepath) });\n }\n\n private git: SimpleGit;\n private tempBase: string;\n private worktrees: Map<string, string> = new Map();\n private repoHash: string;\n\n constructor(public options: AFSGitOptions & { cwd?: string }) {\n zodParse(afsGitOptionsSchema, options);\n\n let repoPath: string;\n if (isAbsolute(options.repoPath)) {\n repoPath = options.repoPath;\n } else {\n repoPath = join(options.cwd || process.cwd(), options.repoPath);\n }\n\n this.options.repoPath = repoPath;\n this.name = options.name || basename(repoPath) || \"git\";\n this.description = options.description;\n this.accessMode = options.accessMode ?? \"readonly\";\n\n this.git = simpleGit(repoPath);\n\n // Create a hash of the repo path for unique temp directory\n this.repoHash = createHash(\"md5\").update(repoPath).digest(\"hex\").substring(0, 8);\n this.tempBase = join(tmpdir(), `afs-git-${this.repoHash}`);\n }\n\n name: string;\n description?: string;\n accessMode: AFSAccessMode;\n\n /**\n * Parse AFS path into branch and file path\n * Branch names may contain slashes and are encoded with ~ in paths\n * Examples:\n * \"/\" -> { branch: undefined, filePath: \"\" }\n * \"/main\" -> { branch: \"main\", filePath: \"\" }\n * \"/feature~new-feature\" -> { branch: \"feature/new-feature\", filePath: \"\" }\n * \"/main/src/index.ts\" -> { branch: \"main\", filePath: \"src/index.ts\" }\n */\n private parsePath(path: string): { branch?: string; filePath: string } {\n const normalized = join(\"/\", path); // Ensure leading slash\n const segments = normalized.split(\"/\").filter(Boolean);\n\n if (segments.length === 0) {\n return { branch: undefined, filePath: \"\" };\n }\n\n // Decode branch name (first segment): replace ~ with /\n const branch = segments[0]!.replace(/~/g, \"/\");\n const filePath = segments.slice(1).join(\"/\");\n\n return { branch, filePath };\n }\n\n /**\n * Detect MIME type based on file extension\n */\n private getMimeType(filePath: string): string {\n const ext = filePath.split(\".\").pop()?.toLowerCase();\n const mimeTypes: Record<string, string> = {\n // Images\n png: \"image/png\",\n jpg: \"image/jpeg\",\n jpeg: \"image/jpeg\",\n gif: \"image/gif\",\n bmp: \"image/bmp\",\n webp: \"image/webp\",\n svg: \"image/svg+xml\",\n ico: \"image/x-icon\",\n // Documents\n pdf: \"application/pdf\",\n txt: \"text/plain\",\n md: \"text/markdown\",\n // Code\n js: \"text/javascript\",\n ts: \"text/typescript\",\n json: \"application/json\",\n html: \"text/html\",\n css: \"text/css\",\n xml: \"text/xml\",\n };\n return mimeTypes[ext || \"\"] || \"application/octet-stream\";\n }\n\n /**\n * Check if file is likely binary based on extension\n */\n private isBinaryFile(filePath: string): boolean {\n const ext = filePath.split(\".\").pop()?.toLowerCase();\n const binaryExtensions = [\n \"png\",\n \"jpg\",\n \"jpeg\",\n \"gif\",\n \"bmp\",\n \"webp\",\n \"ico\",\n \"pdf\",\n \"zip\",\n \"tar\",\n \"gz\",\n \"exe\",\n \"dll\",\n \"so\",\n \"dylib\",\n \"wasm\",\n ];\n return binaryExtensions.includes(ext || \"\");\n }\n\n /**\n * Get list of available branches\n */\n private async getBranches(): Promise<string[]> {\n const branchSummary = await this.git.branchLocal();\n const allBranches = branchSummary.all;\n\n // Filter by allowed branches if specified\n if (this.options.branches && this.options.branches.length > 0) {\n return allBranches.filter((branch) => this.options.branches!.includes(branch));\n }\n\n return allBranches;\n }\n\n /**\n * Ensure worktree exists for a branch (lazy creation)\n */\n private async ensureWorktree(branch: string): Promise<string> {\n if (this.worktrees.has(branch)) {\n return this.worktrees.get(branch)!;\n }\n\n // Check if this is the current branch in the main repo\n const currentBranch = await this.git.revparse([\"--abbrev-ref\", \"HEAD\"]);\n if (currentBranch.trim() === branch) {\n // Use the main repo path for the current branch\n this.worktrees.set(branch, this.options.repoPath);\n return this.options.repoPath;\n }\n\n const worktreePath = join(this.tempBase, branch);\n\n // Check if worktree directory already exists\n const exists = await stat(worktreePath)\n .then(() => true)\n .catch(() => false);\n\n if (!exists) {\n await mkdir(this.tempBase, { recursive: true });\n await this.git.raw([\"worktree\", \"add\", worktreePath, branch]);\n }\n\n this.worktrees.set(branch, worktreePath);\n return worktreePath;\n }\n\n /**\n * List files using git ls-tree (no worktree needed)\n */\n private async listWithGitLsTree(\n branch: string,\n path: string,\n options?: AFSListOptions,\n ): Promise<AFSListResult> {\n const maxDepth = options?.maxDepth ?? 1;\n const limit = Math.min(options?.limit || LIST_MAX_LIMIT, LIST_MAX_LIMIT);\n\n const entries: AFSEntry[] = [];\n const targetPath = path || \"\";\n const treeish = targetPath ? `${branch}:${targetPath}` : branch;\n\n try {\n // Check if the path exists and is a directory\n const pathType = await this.git\n .raw([\"cat-file\", \"-t\", treeish])\n .then((t) => t.trim())\n .catch(() => null);\n\n if (pathType === null) {\n // Path doesn't exist\n return { data: [] };\n }\n\n // If it's a file, just return it\n if (pathType === \"blob\") {\n const size = await this.git\n .raw([\"cat-file\", \"-s\", treeish])\n .then((s) => Number.parseInt(s.trim(), 10));\n\n const afsPath = this.buildPath(branch, path);\n entries.push({\n id: afsPath,\n path: afsPath,\n metadata: {\n type: \"file\",\n size,\n },\n });\n\n return { data: entries };\n }\n\n // It's a directory, list its contents\n interface QueueItem {\n path: string;\n depth: number;\n }\n\n const queue: QueueItem[] = [{ path: targetPath, depth: 0 }];\n\n while (queue.length > 0) {\n const item = queue.shift()!;\n const { path: itemPath, depth } = item;\n\n // List directory contents\n const itemTreeish = itemPath ? `${branch}:${itemPath}` : branch;\n const output = await this.git.raw([\"ls-tree\", \"-l\", itemTreeish]);\n\n const lines = output\n .split(\"\\n\")\n .filter((line) => line.trim())\n .slice(0, limit - entries.length);\n\n for (const line of lines) {\n // Format: <mode> <type> <hash> <size (with padding)> <name>\n // Example: 100644 blob abc123 1234\\tREADME.md\n // Note: size is \"-\" for trees/directories, and there can be multiple spaces/tabs before name\n const match = line.match(/^(\\d+)\\s+(blob|tree)\\s+(\\w+)\\s+(-|\\d+)\\s+(.+)$/);\n if (!match) continue;\n\n const type = match[2]!;\n const sizeStr = match[4]!;\n const name = match[5]!;\n const isDirectory = type === \"tree\";\n const size = sizeStr === \"-\" ? undefined : Number.parseInt(sizeStr, 10);\n\n const fullPath = itemPath ? `${itemPath}/${name}` : name;\n const afsPath = this.buildPath(branch, fullPath);\n\n entries.push({\n id: afsPath,\n path: afsPath,\n metadata: {\n type: isDirectory ? \"directory\" : \"file\",\n size,\n },\n });\n\n // Add to queue if it's a directory and we haven't reached max depth\n if (isDirectory && depth + 1 < maxDepth) {\n queue.push({ path: fullPath, depth: depth + 1 });\n }\n\n // Check limit\n if (entries.length >= limit) {\n return { data: entries };\n }\n }\n }\n\n return { data: entries };\n } catch (error) {\n return { data: [], message: (error as Error).message };\n }\n }\n\n /**\n * Build AFS path with encoded branch name\n * Branch names with slashes are encoded by replacing / with ~\n * @param branch Branch name (may contain slashes)\n * @param filePath File path within branch\n */\n private buildPath(branch: string, filePath?: string): string {\n // Replace / with ~ in branch name\n const encodedBranch = branch.replace(/\\//g, \"~\");\n if (!filePath) {\n return `/${encodedBranch}`;\n }\n return `/${encodedBranch}/${filePath}`;\n }\n\n async list(path: string, options?: AFSListOptions): Promise<AFSListResult> {\n const { branch, filePath } = this.parsePath(path);\n\n // Root path - list branches\n if (!branch) {\n const branches = await this.getBranches();\n return {\n data: branches.map((name) => {\n const encodedPath = this.buildPath(name);\n return {\n id: encodedPath,\n path: encodedPath,\n metadata: {\n type: \"directory\",\n },\n };\n }),\n };\n }\n\n // List files in branch using git ls-tree\n return this.listWithGitLsTree(branch, filePath, options);\n }\n\n async read(path: string, _options?: AFSReadOptions): Promise<AFSReadResult> {\n const { branch, filePath } = this.parsePath(path);\n\n if (!branch) {\n return {\n data: {\n id: \"/\",\n path: \"/\",\n metadata: { type: \"directory\" },\n },\n };\n }\n\n if (!filePath) {\n const branchPath = this.buildPath(branch);\n return {\n data: {\n id: branchPath,\n path: branchPath,\n metadata: { type: \"directory\" },\n },\n };\n }\n\n try {\n // Check if path is a blob (file) or tree (directory)\n const objectType = await this.git\n .raw([\"cat-file\", \"-t\", `${branch}:${filePath}`])\n .then((t) => t.trim());\n\n if (objectType === \"tree\") {\n // It's a directory\n const afsPath = this.buildPath(branch, filePath);\n return {\n data: {\n id: afsPath,\n path: afsPath,\n metadata: {\n type: \"directory\",\n },\n },\n };\n }\n\n // It's a file, get content\n const size = await this.git\n .raw([\"cat-file\", \"-s\", `${branch}:${filePath}`])\n .then((s) => Number.parseInt(s.trim(), 10));\n\n // Determine mimeType based on file extension\n const mimeType = this.getMimeType(filePath);\n const isBinary = this.isBinaryFile(filePath);\n\n let content: string;\n const metadata: Record<string, any> = {\n type: \"file\",\n size,\n mimeType,\n };\n\n if (isBinary) {\n // For binary files, use execFileAsync to get raw buffer\n const { stdout } = await execFileAsync(\"git\", [\"cat-file\", \"-p\", `${branch}:${filePath}`], {\n cwd: this.options.repoPath,\n encoding: \"buffer\",\n maxBuffer: 10 * 1024 * 1024, // 10MB max\n });\n // Store only base64 string without data URL prefix\n content = (stdout as Buffer).toString(\"base64\");\n // Mark content as base64 in metadata\n metadata.contentType = \"base64\";\n } else {\n // For text files, use git.show\n content = await this.git.show([`${branch}:${filePath}`]);\n }\n\n const afsPath = this.buildPath(branch, filePath);\n return {\n data: {\n id: afsPath,\n path: afsPath,\n content,\n metadata,\n },\n };\n } catch (error) {\n return {\n data: undefined,\n message: (error as Error).message,\n };\n }\n }\n\n async write(\n path: string,\n entry: AFSWriteEntryPayload,\n options?: AFSWriteOptions,\n ): Promise<AFSWriteResult> {\n const { branch, filePath } = this.parsePath(path);\n\n if (!branch || !filePath) {\n throw new Error(\"Cannot write to root or branch root\");\n }\n\n // Create worktree for write operations\n const worktreePath = await this.ensureWorktree(branch);\n const fullPath = join(worktreePath, filePath);\n const append = options?.append ?? false;\n\n // Ensure parent directory exists\n const parentDir = dirname(fullPath);\n await mkdir(parentDir, { recursive: true });\n\n // Write content\n if (entry.content !== undefined) {\n let contentToWrite: string;\n if (typeof entry.content === \"string\") {\n contentToWrite = entry.content;\n } else {\n contentToWrite = JSON.stringify(entry.content, null, 2);\n }\n await writeFile(fullPath, contentToWrite, {\n encoding: \"utf8\",\n flag: append ? \"a\" : \"w\",\n });\n }\n\n // Auto commit if enabled\n if (this.options.autoCommit) {\n const gitInstance = simpleGit(worktreePath);\n await gitInstance.add(filePath);\n\n if (this.options.commitAuthor) {\n await gitInstance.addConfig(\n \"user.name\",\n this.options.commitAuthor.name,\n undefined,\n \"local\",\n );\n await gitInstance.addConfig(\n \"user.email\",\n this.options.commitAuthor.email,\n undefined,\n \"local\",\n );\n }\n\n await gitInstance.commit(`Update ${filePath}`);\n }\n\n // Get file stats\n const stats = await stat(fullPath);\n\n const afsPath = this.buildPath(branch, filePath);\n const writtenEntry: AFSEntry = {\n id: afsPath,\n path: afsPath,\n content: entry.content,\n summary: entry.summary,\n createdAt: stats.birthtime,\n updatedAt: stats.mtime,\n metadata: {\n ...entry.metadata,\n type: stats.isDirectory() ? \"directory\" : \"file\",\n size: stats.size,\n },\n userId: entry.userId,\n sessionId: entry.sessionId,\n linkTo: entry.linkTo,\n };\n\n return { data: writtenEntry };\n }\n\n async delete(path: string, options?: AFSDeleteOptions): Promise<AFSDeleteResult> {\n const { branch, filePath } = this.parsePath(path);\n\n if (!branch || !filePath) {\n throw new Error(\"Cannot delete root or branch root\");\n }\n\n // Create worktree for delete operations\n const worktreePath = await this.ensureWorktree(branch);\n const fullPath = join(worktreePath, filePath);\n const recursive = options?.recursive ?? false;\n\n const stats = await stat(fullPath);\n\n if (stats.isDirectory() && !recursive) {\n throw new Error(\n `Cannot delete directory '${path}' without recursive option. Set recursive: true to delete directories.`,\n );\n }\n\n await rm(fullPath, { recursive, force: true });\n\n // Auto commit if enabled\n if (this.options.autoCommit) {\n const gitInstance = simpleGit(worktreePath);\n await gitInstance.add(filePath);\n\n if (this.options.commitAuthor) {\n await gitInstance.addConfig(\n \"user.name\",\n this.options.commitAuthor.name,\n undefined,\n \"local\",\n );\n await gitInstance.addConfig(\n \"user.email\",\n this.options.commitAuthor.email,\n undefined,\n \"local\",\n );\n }\n\n await gitInstance.commit(`Delete ${filePath}`);\n }\n\n return { message: `Successfully deleted: ${path}` };\n }\n\n async rename(\n oldPath: string,\n newPath: string,\n options?: AFSRenameOptions,\n ): Promise<{ message?: string }> {\n const { branch: oldBranch, filePath: oldFilePath } = this.parsePath(oldPath);\n const { branch: newBranch, filePath: newFilePath } = this.parsePath(newPath);\n\n if (!oldBranch || !oldFilePath) {\n throw new Error(\"Cannot rename from root or branch root\");\n }\n\n if (!newBranch || !newFilePath) {\n throw new Error(\"Cannot rename to root or branch root\");\n }\n\n if (oldBranch !== newBranch) {\n throw new Error(\"Cannot rename across branches\");\n }\n\n // Create worktree for rename operations\n const worktreePath = await this.ensureWorktree(oldBranch);\n const oldFullPath = join(worktreePath, oldFilePath);\n const newFullPath = join(worktreePath, newFilePath);\n const overwrite = options?.overwrite ?? false;\n\n // Check if source exists\n await stat(oldFullPath);\n\n // Check if destination exists\n try {\n await stat(newFullPath);\n if (!overwrite) {\n throw new Error(\n `Destination '${newPath}' already exists. Set overwrite: true to replace it.`,\n );\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n }\n\n // Ensure parent directory exists\n const newParentDir = dirname(newFullPath);\n await mkdir(newParentDir, { recursive: true });\n\n // Perform rename\n await rename(oldFullPath, newFullPath);\n\n // Auto commit if enabled\n if (this.options.autoCommit) {\n const gitInstance = simpleGit(worktreePath);\n await gitInstance.add([oldFilePath, newFilePath]);\n\n if (this.options.commitAuthor) {\n await gitInstance.addConfig(\n \"user.name\",\n this.options.commitAuthor.name,\n undefined,\n \"local\",\n );\n await gitInstance.addConfig(\n \"user.email\",\n this.options.commitAuthor.email,\n undefined,\n \"local\",\n );\n }\n\n await gitInstance.commit(`Rename ${oldFilePath} to ${newFilePath}`);\n }\n\n return { message: `Successfully renamed '${oldPath}' to '${newPath}'` };\n }\n\n async search(path: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult> {\n const { branch, filePath } = this.parsePath(path);\n\n if (!branch) {\n return { data: [], message: \"Search requires a branch path\" };\n }\n\n const limit = Math.min(options?.limit || LIST_MAX_LIMIT, LIST_MAX_LIMIT);\n\n try {\n // Use git grep for searching (no worktree needed)\n const args = [\"grep\", \"-n\", \"-I\"]; // -n for line numbers, -I to skip binary files\n\n if (options?.caseSensitive === false) {\n args.push(\"-i\");\n }\n\n args.push(query, branch);\n\n // Add path filter if specified\n if (filePath) {\n args.push(\"--\", filePath);\n }\n\n const output = await this.git.raw(args);\n const lines = output.split(\"\\n\").filter((line) => line.trim());\n\n const entries: AFSEntry[] = [];\n const processedFiles = new Set<string>();\n\n for (const line of lines) {\n // Format when searching in branch: branch:path:linenum:content\n // Try the format with branch prefix first\n let matchPath: string;\n let lineNum: string;\n let content: string;\n\n const matchWithBranch = line.match(/^[^:]+:([^:]+):(\\d+):(.+)$/);\n if (matchWithBranch) {\n matchPath = matchWithBranch[1]!;\n lineNum = matchWithBranch[2]!;\n content = matchWithBranch[3]!;\n } else {\n // Try format without branch: path:linenum:content\n const matchNoBranch = line.match(/^([^:]+):(\\d+):(.+)$/);\n if (!matchNoBranch) continue;\n matchPath = matchNoBranch[1]!;\n lineNum = matchNoBranch[2]!;\n content = matchNoBranch[3]!;\n }\n\n const afsPath = this.buildPath(branch, matchPath);\n\n if (processedFiles.has(afsPath)) continue;\n processedFiles.add(afsPath);\n\n entries.push({\n id: afsPath,\n path: afsPath,\n summary: `Line ${lineNum}: ${content}`,\n metadata: {\n type: \"file\",\n },\n });\n\n if (entries.length >= limit) {\n break;\n }\n }\n\n return {\n data: entries,\n message: entries.length >= limit ? `Results truncated to limit ${limit}` : undefined,\n };\n } catch (error) {\n // git grep returns exit code 1 if no matches found\n if ((error as Error).message.includes(\"did not match any file(s)\")) {\n return { data: [] };\n }\n return { data: [], message: (error as Error).message };\n }\n }\n\n /**\n * Cleanup all worktrees (useful when unmounting)\n */\n async cleanup(): Promise<void> {\n for (const [_branch, worktreePath] of this.worktrees) {\n try {\n await this.git.raw([\"worktree\", \"remove\", worktreePath, \"--force\"]);\n } catch (_error) {\n // Ignore errors during cleanup\n }\n }\n this.worktrees.clear();\n\n // Remove temp directory\n try {\n await rm(this.tempBase, { recursive: true, force: true });\n } catch {\n // Ignore errors\n }\n }\n}\n\nconst _typeCheck: AFSModuleClass<AFSGit, AFSGitOptions> = AFSGit;\n"],"mappings":";;;;;;;;;;;AAOA,MAAM,gBAAgB,UAAU,SAAS;AAyBzC,MAAM,iBAAiB;AA4BvB,MAAM,sBAAsB,SAC1B,EAAE,OAAO;CACP,MAAM,YAAY,EAAE,QAAQ,CAAC;CAC7B,UAAU,EAAE,QAAQ,CAAC,SAAS,iCAAiC;CAC/D,aAAa,YAAY,EAAE,QAAQ,CAAC,SAAS,kCAAkC,CAAC;CAChF,UAAU,YAAY,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,SAAS,6BAA6B,CAAC;CACjF,YAAY,YACV,EAAE,KAAK,CAAC,YAAY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|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0-beta",
|
|
4
4
|
"description": "AIGNE AFS module for git storage",
|
|
5
|
+
"license": "Elastic-2.0",
|
|
5
6
|
"publishConfig": {
|
|
6
7
|
"access": "public"
|
|
7
8
|
},
|
|
8
|
-
"author": "Arcblock <blocklet@arcblock.io> https://github.com/
|
|
9
|
-
"homepage": "https://
|
|
10
|
-
"license": "Elastic-2.0",
|
|
9
|
+
"author": "Arcblock <blocklet@arcblock.io> https://github.com/arcblock",
|
|
10
|
+
"homepage": "https://github.com/arcblock/afs",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/
|
|
13
|
+
"url": "git+https://github.com/arcblock/afs"
|
|
14
14
|
},
|
|
15
15
|
"bugs": {
|
|
16
|
-
"url": "https://github.com/
|
|
16
|
+
"url": "https://github.com/arcblock/afs/issues"
|
|
17
17
|
},
|
|
18
|
-
"files": [
|
|
19
|
-
"lib/cjs",
|
|
20
|
-
"lib/dts",
|
|
21
|
-
"lib/esm",
|
|
22
|
-
"LICENSE",
|
|
23
|
-
"README.md",
|
|
24
|
-
"CHANGELOG.md"
|
|
25
|
-
],
|
|
26
18
|
"type": "module",
|
|
27
|
-
"main": "./
|
|
28
|
-
"module": "./
|
|
29
|
-
"types": "./
|
|
19
|
+
"main": "./dist/index.cjs",
|
|
20
|
+
"module": "./dist/index.mjs",
|
|
21
|
+
"types": "./dist/index.d.cts",
|
|
30
22
|
"exports": {
|
|
31
23
|
".": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"types": "./lib/dts/index.d.ts"
|
|
24
|
+
"require": "./dist/index.cjs",
|
|
25
|
+
"import": "./dist/index.mjs"
|
|
35
26
|
},
|
|
36
|
-
"./*":
|
|
37
|
-
"import": "./lib/esm/*",
|
|
38
|
-
"require": "./lib/cjs/*",
|
|
39
|
-
"types": "./lib/dts/*"
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
"typesVersions": {
|
|
43
|
-
"*": {
|
|
44
|
-
".": [
|
|
45
|
-
"./lib/dts/index.d.ts"
|
|
46
|
-
]
|
|
47
|
-
}
|
|
27
|
+
"./*": "./*"
|
|
48
28
|
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"LICENSE",
|
|
32
|
+
"README.md",
|
|
33
|
+
"CHANGELOG.md"
|
|
34
|
+
],
|
|
49
35
|
"dependencies": {
|
|
50
36
|
"simple-git": "^3.27.0",
|
|
51
37
|
"zod": "^3.25.67",
|
|
52
|
-
"@aigne/afs": "^1.
|
|
53
|
-
"@aigne/core": "^1.72.0-beta.25"
|
|
38
|
+
"@aigne/afs": "^1.11.0-beta"
|
|
54
39
|
},
|
|
55
40
|
"devDependencies": {
|
|
56
|
-
"@types/bun": "^1.
|
|
41
|
+
"@types/bun": "^1.3.6",
|
|
57
42
|
"npm-run-all": "^4.1.5",
|
|
58
|
-
"rimraf": "^6.
|
|
59
|
-
"
|
|
60
|
-
"
|
|
43
|
+
"rimraf": "^6.1.2",
|
|
44
|
+
"tsdown": "0.20.0-beta.3",
|
|
45
|
+
"typescript": "5.9.2",
|
|
46
|
+
"@aigne/scripts": "0.0.0",
|
|
47
|
+
"@aigne/typescript-config": "0.0.0"
|
|
61
48
|
},
|
|
62
49
|
"scripts": {
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"clean": "rimraf
|
|
50
|
+
"build": "tsdown",
|
|
51
|
+
"check-types": "tsc --noEmit",
|
|
52
|
+
"clean": "rimraf dist coverage",
|
|
66
53
|
"test": "bun test",
|
|
67
|
-
"test:coverage": "bun test --coverage --coverage-reporter=lcov --coverage-reporter=text"
|
|
68
|
-
"postbuild": "node ../../scripts/post-build-lib.mjs"
|
|
54
|
+
"test:coverage": "bun test --coverage --coverage-reporter=lcov --coverage-reporter=text"
|
|
69
55
|
}
|
|
70
56
|
}
|