@aigne/afs-git 1.11.0-beta → 1.11.0-beta.2

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.
@@ -1 +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,YAAY,CAAC,CAAC,SAAS,8BAA8B,CAC1E;CACD,YAAY,YACV,EAAE,SAAS,CAAC,SAAS,sDAAsD,CAC5E;CACD,cAAc,YACZ,EAAE,OAAO;EACP,MAAM,EAAE,QAAQ;EAChB,OAAO,EAAE,QAAQ;EAClB,CAAC,CACH;CACF,CAAC,CACH;AAED,IAAa,SAAb,MAAa,OAA4B;CACvC,OAAO,SAAS;AACd,SAAO;;CAGT,aAAa,KAAK,EAAE,UAAU,UAA+B;AAE3D,SAAO,IAAI,OAAO;GAAE,GADN,MAAM,OAAO,QAAQ,CAAC,WAAW,OAAO;GACxB,KAAK,QAAQ,SAAS;GAAE,CAAC;;CAGzD,AAA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UAAU;AAEjD,QAAI,eAAe,IAAI,QAAQ,CAAE;AACjC,mBAAe,IAAI,QAAQ;AAE3B,YAAQ,KAAK;KACX,IAAI;KACJ,MAAM;KACN,SAAS,QAAQ,QAAQ,IAAI;KAC7B,UAAU,EACR,MAAM,QACP;KACF,CAAC;AAEF,QAAI,QAAQ,UAAU,MACpB;;AAIJ,UAAO;IACL,MAAM;IACN,SAAS,QAAQ,UAAU,QAAQ,8BAA8B,UAAU;IAC5E;WACM,OAAO;AAEd,OAAK,MAAgB,QAAQ,SAAS,4BAA4B,CAChE,QAAO,EAAE,MAAM,EAAE,EAAE;AAErB,UAAO;IAAE,MAAM,EAAE;IAAE,SAAU,MAAgB;IAAS;;;;;;CAO1D,MAAM,UAAyB;AAC7B,OAAK,MAAM,CAAC,SAAS,iBAAiB,KAAK,UACzC,KAAI;AACF,SAAM,KAAK,IAAI,IAAI;IAAC;IAAY;IAAU;IAAc;IAAU,CAAC;WAC5D,QAAQ;AAInB,OAAK,UAAU,OAAO;AAGtB,MAAI;AACF,SAAM,GAAG,KAAK,UAAU;IAAE,WAAW;IAAM,OAAO;IAAM,CAAC;UACnD"}
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\";\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\nconst execFileAsync = promisify(execFile);\n\nexport interface AFSGitOptions {\n name?: string;\n /**\n * Local path to git repository.\n * If remoteUrl is provided and repoPath doesn't exist, will clone to this path.\n * If remoteUrl is provided and repoPath is not specified, clones to temp directory.\n */\n repoPath?: string;\n /**\n * Remote repository URL (https or git protocol).\n * If provided, will clone the repository if repoPath doesn't exist.\n * Examples:\n * - https://github.com/user/repo.git\n * - git@github.com:user/repo.git\n */\n remoteUrl?: string;\n description?: string;\n /**\n * List of branches to expose/access.\n * Also used for clone optimization when cloning from remoteUrl:\n * - Single branch (e.g., ['main']): Uses --single-branch for faster clone\n * - Multiple branches: Clones all branches, filters access to specified ones\n * - Not specified: All branches are accessible\n */\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 * Clone depth for shallow clone (only used when cloning from remoteUrl)\n * @default 1\n */\n depth?: number;\n /**\n * Automatically clean up cloned repository on cleanup()\n * Only applies when repository was auto-cloned to temp directory\n * @default true\n */\n autoCleanup?: boolean;\n /**\n * Git clone options (only used when cloning from remoteUrl)\n */\n cloneOptions?: {\n /**\n * Authentication credentials for private repositories\n */\n auth?: {\n username?: string;\n password?: string;\n };\n };\n}\n\nconst afsGitOptionsSchema = camelize(\n z\n .object({\n name: optionalize(z.string()),\n repoPath: optionalize(z.string().describe(\"The path to the git repository\")),\n remoteUrl: optionalize(z.string().describe(\"Remote repository URL (https or git protocol)\")),\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 depth: optionalize(z.number().describe(\"Clone depth for shallow clone\")),\n autoCleanup: optionalize(\n z.boolean().describe(\"Automatically clean up cloned repository on cleanup()\"),\n ),\n cloneOptions: optionalize(\n z.object({\n auth: optionalize(\n z.object({\n username: optionalize(z.string()),\n password: optionalize(z.string()),\n }),\n ),\n }),\n ),\n })\n .refine((data) => data.repoPath || data.remoteUrl, {\n message: \"Either repoPath or remoteUrl must be provided\",\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 const instance = new AFSGit({ ...valid, cwd: dirname(filepath) });\n await instance.ready();\n return instance;\n }\n\n private initPromise: Promise<void>;\n private git: SimpleGit;\n private tempBase: string;\n private worktrees: Map<string, string> = new Map();\n private repoHash: string;\n private isAutoCloned = false;\n private clonedPath?: string;\n private repoPath: string;\n\n constructor(public options: AFSGitOptions & { cwd?: string }) {\n zodParse(afsGitOptionsSchema, options);\n\n // Synchronously determine repoPath to initialize name\n let repoPath: string;\n let repoName: string;\n\n if (options.repoPath) {\n // Use provided repoPath\n repoPath = isAbsolute(options.repoPath)\n ? options.repoPath\n : join(options.cwd || process.cwd(), options.repoPath);\n repoName = basename(repoPath);\n } else if (options.remoteUrl) {\n // Extract repo name from URL for temporary name\n const urlParts = options.remoteUrl.split(\"/\");\n const lastPart = urlParts[urlParts.length - 1];\n repoName = lastPart?.replace(/\\.git$/, \"\") || \"git\";\n\n // Will be updated during async init, use temp path for now\n const repoHash = createHash(\"md5\").update(options.remoteUrl).digest(\"hex\").substring(0, 8);\n repoPath = join(tmpdir(), `afs-git-remote-${repoHash}`);\n } else {\n // This should never happen due to schema validation\n throw new Error(\"Either repoPath or remoteUrl must be provided\");\n }\n\n // Initialize basic properties immediately\n this.repoPath = repoPath;\n this.name = options.name || repoName;\n this.description = options.description;\n this.accessMode = options.accessMode ?? \"readonly\";\n\n // Calculate hash for temp directories\n this.repoHash = createHash(\"md5\").update(repoPath).digest(\"hex\").substring(0, 8);\n this.tempBase = join(tmpdir(), `afs-git-${this.repoHash}`);\n\n // Note: git and other properties will be initialized in initialize() after cloning\n // We need to delay simpleGit() initialization until the directory exists\n this.git = null as any; // Will be set in initialize()\n\n // Start async initialization (cloning if needed)\n this.initPromise = this.initialize();\n }\n\n /**\n * Wait for async initialization to complete\n */\n async ready(): Promise<void> {\n await this.initPromise;\n }\n\n /**\n * Async initialization logic (runs in constructor)\n * Handles cloning remote repositories if needed\n */\n private async initialize(): Promise<void> {\n const options = this.options;\n\n // If remoteUrl is provided, handle cloning\n if (options.remoteUrl) {\n const targetPath = options.repoPath\n ? isAbsolute(options.repoPath)\n ? options.repoPath\n : join(options.cwd || process.cwd(), options.repoPath)\n : this.repoPath; // Use temp path set in constructor\n\n // Mark as auto-cloned if we're using temp directory\n if (!options.repoPath) {\n this.isAutoCloned = true;\n }\n\n // Check if repoPath exists, if not, clone to it\n const exists = await stat(targetPath)\n .then(() => true)\n .catch(() => false);\n\n if (!exists) {\n // Determine if single-branch optimization should be used\n const singleBranch = options.branches?.length === 1 ? options.branches[0] : undefined;\n\n await AFSGit.cloneRepository(options.remoteUrl, targetPath, {\n depth: options.depth ?? 1,\n branch: singleBranch,\n auth: options.cloneOptions?.auth,\n });\n }\n\n // Update properties if targetPath differs from constructor initialization\n if (targetPath !== this.repoPath) {\n this.repoPath = targetPath;\n this.repoHash = createHash(\"md5\").update(targetPath).digest(\"hex\").substring(0, 8);\n this.tempBase = join(tmpdir(), `afs-git-${this.repoHash}`);\n }\n\n this.clonedPath = this.isAutoCloned ? targetPath : undefined;\n }\n\n // Now that the directory exists (either it was there or we cloned it), initialize git\n this.git = simpleGit(this.repoPath);\n }\n\n /**\n * Clone a remote repository to local path\n */\n private static async cloneRepository(\n remoteUrl: string,\n targetPath: string,\n options: {\n depth?: number;\n branch?: string;\n auth?: { username?: string; password?: string };\n } = {},\n ): Promise<void> {\n const git = simpleGit();\n\n // Build clone options\n const cloneArgs: string[] = [];\n\n if (options.depth) {\n cloneArgs.push(\"--depth\", options.depth.toString());\n }\n\n if (options.branch) {\n cloneArgs.push(\"--branch\", options.branch, \"--single-branch\");\n }\n\n // Handle authentication in URL if provided\n let cloneUrl = remoteUrl;\n if (options.auth?.username && options.auth?.password) {\n // Insert credentials into HTTPS URL\n if (remoteUrl.startsWith(\"https://\")) {\n const url = new URL(remoteUrl);\n url.username = encodeURIComponent(options.auth.username);\n url.password = encodeURIComponent(options.auth.password);\n cloneUrl = url.toString();\n }\n }\n\n await git.clone(cloneUrl, targetPath, cloneArgs);\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.repoPath);\n return this.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 await this.ready();\n const { branch, filePath } = this.parsePath(path);\n const maxDepth = options?.maxDepth ?? 1;\n const limit = Math.min(options?.limit || LIST_MAX_LIMIT, LIST_MAX_LIMIT);\n\n // Root path - list branches\n if (!branch) {\n const branches = await this.getBranches();\n const entries: AFSEntry[] = [];\n\n for (const name of branches) {\n if (entries.length >= limit) break;\n\n const encodedPath = this.buildPath(name);\n entries.push({\n id: encodedPath,\n path: encodedPath,\n metadata: {\n type: \"directory\",\n },\n });\n\n // If maxDepth > 1, also list contents of each branch\n if (maxDepth > 1) {\n const branchResult = await this.listWithGitLsTree(name, \"\", {\n ...options,\n maxDepth: maxDepth - 1,\n limit: limit - entries.length,\n });\n entries.push(...branchResult.data);\n }\n }\n\n return { data: entries };\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 await this.ready();\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 await this.ready();\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, { encoding: \"utf8\", flag: append ? \"a\" : \"w\" });\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 await this.ready();\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 await this.ready();\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 await this.ready();\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 * Fetch latest changes from remote\n */\n async fetch(): Promise<void> {\n await this.ready();\n await this.git.fetch();\n }\n\n /**\n * Pull latest changes from remote for current branch\n */\n async pull(): Promise<void> {\n await this.ready();\n await this.git.pull();\n }\n\n /**\n * Push local changes to remote\n */\n async push(branch?: string): Promise<void> {\n await this.ready();\n if (branch) {\n await this.git.push(\"origin\", branch);\n } else {\n await this.git.push();\n }\n }\n\n /**\n * Cleanup all worktrees (useful when unmounting)\n */\n async cleanup(): Promise<void> {\n await this.ready();\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 // Cleanup cloned repository if auto-cloned and autoCleanup enabled\n const autoCleanup = this.options.autoCleanup ?? true;\n if (this.isAutoCloned && autoCleanup && this.clonedPath) {\n try {\n await rm(this.clonedPath, { recursive: true, force: true });\n } catch {\n // Ignore cleanup errors\n }\n }\n }\n}\n\nconst _typeCheck: AFSModuleClass<AFSGit, AFSGitOptions> = AFSGit;\n"],"mappings":";;;;;;;;;;;AA6BA,MAAM,iBAAiB;AAEvB,MAAM,gBAAgB,UAAU,SAAS;AAuEzC,MAAM,sBAAsB,SAC1B,EACG,OAAO;CACN,MAAM,YAAY,EAAE,QAAQ,CAAC;CAC7B,UAAU,YAAY,EAAE,QAAQ,CAAC,SAAS,iCAAiC,CAAC;CAC5E,WAAW,YAAY,EAAE,QAAQ,CAAC,SAAS,gDAAgD,CAAC;CAC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IAAS;;;;;;CAO1D,MAAM,QAAuB;AAC3B,QAAM,KAAK,OAAO;AAClB,QAAM,KAAK,IAAI,OAAO;;;;;CAMxB,MAAM,OAAsB;AAC1B,QAAM,KAAK,OAAO;AAClB,QAAM,KAAK,IAAI,MAAM;;;;;CAMvB,MAAM,KAAK,QAAgC;AACzC,QAAM,KAAK,OAAO;AAClB,MAAI,OACF,OAAM,KAAK,IAAI,KAAK,UAAU,OAAO;MAErC,OAAM,KAAK,IAAI,MAAM;;;;;CAOzB,MAAM,UAAyB;AAC7B,QAAM,KAAK,OAAO;AAClB,OAAK,MAAM,CAAC,SAAS,iBAAiB,KAAK,UACzC,KAAI;AACF,SAAM,KAAK,IAAI,IAAI;IAAC;IAAY;IAAU;IAAc;IAAU,CAAC;WAC5D,QAAQ;AAInB,OAAK,UAAU,OAAO;AAGtB,MAAI;AACF,SAAM,GAAG,KAAK,UAAU;IAAE,WAAW;IAAM,OAAO;IAAM,CAAC;UACnD;EAKR,MAAM,cAAc,KAAK,QAAQ,eAAe;AAChD,MAAI,KAAK,gBAAgB,eAAe,KAAK,WAC3C,KAAI;AACF,SAAM,GAAG,KAAK,YAAY;IAAE,WAAW;IAAM,OAAO;IAAM,CAAC;UACrD"}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@aigne/afs-git",
3
- "version": "1.11.0-beta",
3
+ "version": "1.11.0-beta.2",
4
4
  "description": "AIGNE AFS module for git storage",
5
- "license": "Elastic-2.0",
5
+ "license": "UNLICENSED",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -35,7 +35,7 @@
35
35
  "dependencies": {
36
36
  "simple-git": "^3.27.0",
37
37
  "zod": "^3.25.67",
38
- "@aigne/afs": "^1.11.0-beta"
38
+ "@aigne/afs": "^1.11.0-beta.2"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/bun": "^1.3.6",