Repomix文档体系:API参考与用户手册终极指南 Repomix文档体系API参考与用户手册终极指南【免费下载链接】repomix Repomix (formerly Repopack) is a powerful tool that packs your entire repository into a single, AI-friendly file. Perfect for when you need to feed your codebase to Large Language Models (LLMs) or other AI tools like Claude, ChatGPT, DeepSeek, Perplexity, Gemini, Gemma, Llama, Grok, and more.项目地址: https://gitcode.com/GitHub_Trending/rep/repomixRepomix是一个强大的代码仓库打包工具能够将整个代码库打包成单个AI友好的文件完美适配Claude、ChatGPT、DeepSeek、Perplexity、Gemini、Gemma、Llama、Grok等大型语言模型LLMs。这份完整的文档体系将为您提供API参考和用户手册帮助您快速掌握这个终极代码分析工具。 核心文档结构Repomix的文档体系分为三大核心部分用户指南、配置参考和API文档。每个部分都针对不同的使用场景和需求深度优化。用户指南快速上手与最佳实践用户指南位于 website/client/src/en/guide/ 目录包含以下关键文档入门指南- 从零开始使用Repomix的完整教程配置指南- 深度配置选项详解命令行选项- 所有CLI参数的完整参考输出格式- XML、Markdown、JSON和纯文本输出详解MCP服务器- AI工具集成指南Repomix将代码库打包为单一文件AI助手可基于完整上下文提供代码审查和重构建议配置系统深度解析Repomix支持多种配置文件格式优先级从高到低为TypeScript配置(repomix.config.ts,repomix.config.mts,repomix.config.cts)JavaScript/ES模块(repomix.config.js,repomix.config.mjs,repomix.config.cjs)JSON配置(repomix.config.json5,repomix.config.jsonc,repomix.config.json)TypeScript配置示例// repomix.config.ts import { defineConfig } from repomix; export default defineConfig({ output: { filePath: output.xml, style: xml, removeComments: true, }, include: [src/**/*.ts, *.md], ignore: [node_modules/**, dist/**], });全局配置位置Windows:%LOCALAPPDATA%\Repomix\macOS/Linux:~/.config/repomix/API参考程序化使用Repomix提供完整的TypeScript API位于 src/core/packager.ts核心接口如下export interface PackResult { totalFiles: number; totalCharacters: number; totalTokens: number; fileCharCounts: Recordstring, number; fileTokenCounts: Recordstring, number; gitDiffTokenCount: number; gitLogTokenCount: number; outputFiles?: string[]; suspiciousFilesResults: SuspiciousFileResult[]; suspiciousGitDiffResults: SuspiciousFileResult[]; suspiciousGitLogResults: SuspiciousFileResult[]; processedFiles: ProcessedFile[]; safeFilePaths: string[]; skippedFiles: SkippedFileInfo[]; } export interface PackOptions { skillName?: string; // ... 更多选项 }核心模块结构文件处理src/core/file/ - 文件收集、处理、搜索Git集成src/core/git/ - Git差异、日志、远程仓库处理输出生成src/core/output/ - XML、Markdown、JSON格式输出安全检测src/core/security/ - 敏感信息检测Tree-sitter解析src/core/treeSitter/ - 代码结构解析Repomix的GitHub Actions集成界面支持自定义输出格式和文件过滤选项 快速开始指南基础使用# 安装Repomix npm install -D repomix # 打包当前目录 npx repomixlatest # 自定义输出格式 npx repomixlatest -o my-output.md --style markdown # 压缩输出提取核心代码结构 npx repomixlatest --compress高级功能示例# 包含Git差异和提交历史 npx repomixlatest --include-diffs --include-logs # 处理远程仓库 npx repomixlatest --remote https://github.com/user/repo # 分块输出适合大仓库 npx repomixlatest --split-output 20mb # 令牌计数分析 npx repomixlatest --token-count-tree 1000程序化API使用import { pack } from repomix; const result await pack({ output: { filePath: analysis.xml, style: xml, }, include: [src/**/*.ts], compress: true, }); console.log(处理了 ${result.totalFiles} 个文件); console.log(总计 ${result.totalTokens} 个令牌);Repomix帮助生成测试代码提高代码覆盖率并优化依赖注入 配置选项详解输出配置{ output: { filePath: repomix-output.xml, style: xml, removeComments: false, removeEmptyLines: false, truncateBase64: true, headerText: 自定义标题文本, splitOutput: 10mb } }文件选择配置{ include: [src/**/*.ts, *.md], ignore: [node_modules/**, dist/**, *.test.ts], noGitignore: false, noDotIgnore: false, noDefaultPatterns: false }Git集成配置{ includeDiffs: true, includeLogs: true, includeLogsCount: 50, noGitSortByChanges: false } 多语言支持Repomix提供完整的多语言文档支持覆盖12种语言英语website/client/src/en/中文website/client/src/zh-cn/日语website/client/src/ja/韩语website/client/src/ko/法语website/client/src/fr/西班牙语website/client/src/es/德语website/client/src/de/葡萄牙语website/client/src/pt-br/俄语website/client/src/ru/土耳其语website/client/src/tr/越南语website/client/src/vi/印度尼西亚语website/client/src/id/️ 安全特性Repomix内置强大的安全检测系统位于 src/core/security/包括敏感信息检测自动识别API密钥、密码、令牌等文件安全验证检查文件权限和潜在风险Git安全过滤处理Git差异和日志时的安全检查可配置安全级别通过--no-security-check禁用谨慎使用 扩展与集成MCP服务器集成通过 src/mcp/mcpServer.ts 提供的MCP服务器Repomix可以与AI工具深度集成# 启动MCP服务器 npx repomixlatest --mcp # 支持的MCP工具 - packCodebaseTool - 打包代码库 - packRemoteRepositoryTool - 处理远程仓库 - generateSkillTool - 生成AI技能 - fileSystemReadFileTool - 文件系统读取浏览器扩展位于 browser/ 目录的Chrome扩展提供一键打包直接从浏览器打包GitHub仓库实时预览查看打包结果配置管理保存常用配置多格式输出XML、Markdown、纯文本 性能优化技巧令牌管理# 查看令牌分布 npx repomixlatest --token-count-tree # 仅显示大文件 npx repomixlatest --token-count-tree 1000 # 自定义令牌编码 npx repomixlatest --token-count-encoding cl100k_base内存优化对于大型仓库建议使用# 分块输出 npx repomixlatest --split-output 50mb # 移除注释减少大小 npx repomixlatest --remove-comments # 压缩代码结构 npx repomixlatest --compress 最佳实践配置文件优先使用repomix.config.ts获得最佳类型支持和IDE自动完成Git集成启用--include-diffs和--include-logs获取完整上下文安全第一始终启用安全检测除非处理公开仓库令牌监控使用--token-count-tree监控LLM上下文限制渐进式采用从简单配置开始逐步添加高级功能 故障排除常见问题Q: 输出文件太大怎么办A: 使用--compress压缩代码结构或--split-output分块输出Q: 如何处理特定文件类型A: 使用--include和--ignore模式过滤文件Q: Git集成不工作A: 确保在Git仓库中运行或使用--remote处理远程仓库Q: 类型错误A: 确保安装了TypeScript依赖npm install -D repomix调试模式# 启用详细日志 npx repomixlatest --verbose # 静默模式仅错误 npx repomixlatest --quiet # 输出到控制台 npx repomixlatest --stdout 深入学习资源核心源码src/core/ - 深入了解Repomix内部机制测试用例tests/ - 查看各种使用场景的测试配置示例tests/fixtures/config-ts/ - TypeScript配置示例集成测试tests/integration-tests/ - 端到端测试场景Repomix的文档体系持续更新确保您始终能够获得最新的API参考和使用指南。无论是简单的代码库打包还是复杂的AI集成场景这份完整的文档都将为您提供所需的全部信息。【免费下载链接】repomix Repomix (formerly Repopack) is a powerful tool that packs your entire repository into a single, AI-friendly file. Perfect for when you need to feed your codebase to Large Language Models (LLMs) or other AI tools like Claude, ChatGPT, DeepSeek, Perplexity, Gemini, Gemma, Llama, Grok, and more.项目地址: https://gitcode.com/GitHub_Trending/rep/repomix创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考