Robix是一种功能强大的工具,可将您的整个存储库包装到一个易于友好的文件中。
当您需要将代码库馈送到大型语言模型(LLMS)或其他AI工具(例如Claude,Chatgpt和Gemini)时,它是完美的选择。
笔记
由于法律考虑,该项目已从“ Repopack”重命名为“ robomix”。只有名称正在更改; ROPOMIX所有功能和维护器(@yamadashy)保持不变。我们致力于确保所有用户的平稳过渡。
要继续使用该工具,只需安装新软件包:
# Install new package
npm install -g repomix
# Or use directly with npx
npx repomix可选,您也可以卸载旧包:
npm uninstall -g repopack您现有的配置文件( repopack.config.json和.repopackignore )将在过渡期内继续工作。
repomix将自动检测到这些文件,并提出将其迁移到新格式( repomix.config.json和.repomixignore )。
感谢您在此过渡期间的理解与合作。
您可以在项目目录中立即尝试不安装ropomix:
npx repomix或全球安装以备重复使用:
# Install using npm
npm install -g repomix
# Alternatively using yarn
yarn global add repomix
# Alternatively using Homebrew (macOS)
brew install repomix
# Then run in any project directory
repomix就是这样! Robix将在您当前目录中生成repomix-output.txt文件,其中包含您的整个存储库,以AI友好的格式。
打包您的整个存储库:
repomix包装特定目录:
repomix path/to/directory使用球形模式包装特定的文件或目录:
repomix --include " src/**/*.ts,**/*.md "排除特定文件或目录:
repomix --ignore " **/*.log,tmp/ "包装远程存储库:
repomix --remote https://github.com/yamadashy/repomix
# You can also use GitHub shorthand:
repomix --remote yamadashy/repomix初始化一个新的配置文件( repomix.config.json ):
repomix --init生成包装的文件后,您可以将其与Claude,Chatgpt和Gemini这样的生成AI工具使用。
使用Ropomix生成包装的文件后,您可以将其与Claude,Chatgpt和Gemini等AI工具一起使用。以下是一些示例提示,可以让您入门:
有关全面的代码审查和重构建议:
This file contains my entire codebase. Please review the overall structure and suggest any improvements or refactoring opportunities, focusing on maintainability and scalability.
生成项目文档:
Based on the codebase in this file, please generate a detailed README.md that includes an overview of the project, its main features, setup instructions, and usage examples.
用于生成测试案例:
Analyze the code in this file and suggest a comprehensive set of unit tests for the main functions and classes. Include edge cases and potential error scenarios.
评估代码质量和遵守最佳实践:
Review the codebase for adherence to coding best practices and industry standards. Identify areas where the code could be improved in terms of readability, maintainability, and efficiency. Suggest specific changes to align the code with best practices.
对图书馆有高级理解
This file contains the entire codebase of library. Please provide a comprehensive overview of the library, including its main purpose, key features, and overall architecture.
根据您的特定需求和您使用的AI工具的功能,可以随意修改这些提示。
查看我们的社区讨论用户共享的地方:
随时加入讨论并分享自己的经验!您的见解可以帮助他人更好地利用综合体。
Robix在代码库的不同部分之间生成一个带有清晰分离器的单个文件。
为了增强AI理解,输出文件从面向AI的解释开始,使AI模型更容易理解包装存储库的上下文和结构。
This file is a merged representation of the entire codebase, combining all repository files into a single document.
================================================================
File Summary
================================================================
(Metadata and usage AI instructions)
================================================================
Repository Structure
================================================================
src/
cli/
cliOutput.ts
index.ts
config/
configLoader.ts
(...remaining directories)
================================================================
Repository Files
================================================================
================
File: src/index.js
================
// File contents here
================
File: src/utils.js
================
// File contents here
(...remaining files)
================================================================
Instruction
================================================================
(Custom instructions from `output.instructionFilePath`)
要以XML格式生成输出,请使用--style xml选项:
repomix --style xmlXML格式以层次的方式构造内容:
This file is a merged representation of the entire codebase, combining all repository files into a single document.
< file_summary >
(Metadata and usage AI instructions)
</ file_summary >
< repository_structure >
src/
cli/
cliOutput.ts
index.ts
(...remaining directories)
</ repository_structure >
< repository_files >
< file path = " src/index.js " >
// File contents here
</ file >
(...remaining files)
</ repository_files >
< instruction >
(Custom instructions from `output.instructionFilePath`)
</ instruction >对于那些对AI上下文中XML标签潜力感兴趣的人:
https://docs.anththropic.com/en/docs/build-with-with-claude/prompt-engineering/use-xml-tags
当您的提示涉及多个组件(例如上下文,说明和示例)时,XML标签可能会改变游戏规则。它们帮助克劳德(Claude)更准确地解析您的提示,从而导致更高质量的输出。
这意味着来自Robix的XML输出不仅是一种不同的格式,而且可能是将代码库馈送到AI系统中的更有效方法,以进行分析,代码审查或其他任务。
要以降价格式生成输出,请使用--style markdown选项:
repomix --style markdown降价格式以层次的方式结构内容:
This file is a merged representation of the entire codebase, combining all repository files into a single document.
# File Summary
(Metadata and usage AI instructions)
# Repository Structure
```
src/
cli/
cliOutput.ts
index.ts
```
(...remaining directories)
# Repository Files
## File: src/index.js
```
// File contents here
```
(...remaining files)
# Instruction
(Custom instructions from ` output.instructionFilePath ` )这种格式提供了一种干净,可读性的结构,既可以通过人工智能系统友好且易于解析。
-v, --version :显示工具版本-o, --output <file> :指定输出文件名--include <patterns> :包括模式的列表(逗号分隔)-i, --ignore <patterns> :其他忽略模式(逗号分隔)-c, --config <path> :通往自定义配置文件的路径--style <style> :指定输出样式( plain , xml , markdown )--top-files-len <number> :在摘要中显示的顶级文件数量--output-show-line-numbers :输出中显示行号--copy :此外,将生成的输出复制到系统剪贴板--remote <url> :处理一个远程git存储库--verbose :启用详细记录示例:
repomix -o custom-output.txt
repomix -i " *.log,tmp " -v
repomix -c ./custom-config.json
repomix --style xml
repomix --remote https://github.com/user/repo.git
npx repomix src要更新全球安装的综合体:
# Using npm
npm update -g repomix
# Using yarn
yarn global upgrade repomix使用npx repomix通常更方便,因为它始终使用最新版本。
Robix支持处理远程GIT存储库,而无需手动克隆。此功能使您可以通过单个命令快速分析任何公共GIT存储库。
要处理一个远程存储库,请使用--remote选项,然后使用存储库URL:
repomix --remote https://github.com/user/repo.git您也可以使用GitHub的速记格式:
repomix --remote user/repo在您的项目root中创建一个repomix.config.json文件以进行自定义配置。
repomix --init这是配置选项的解释:
| 选项 | 描述 | 默认 |
|---|---|---|
output.filePath | 输出文件的名称 | "repomix-output.txt" |
output.style | 输出的样式( plain , xml , markdown ) | "plain" |
output.headerText | 自定义文本要包含在文件标头中 | null |
output.instructionFilePath | 通往包含详细自定义说明的文件的路径 | null |
output.removeComments | 是否从支持的文件类型中删除注释 | false |
output.removeEmptyLines | 是否要从输出中删除空线 | false |
output.showLineNumbers | 是否将线号添加到输出中的每一行 | false |
output.copyToClipboard | 除保存文件外,是否将输出复制到系统剪贴板 | false |
output.topFilesLength | 摘要中要显示的顶级文件数量。如果设置为0,则不会显示摘要 | 5 |
output.includeEmptyDirectories | 是否在存储库结构中包括空目录 | false |
include | 要包含的文件模式(使用Glog模式) | [] |
ignore.useGitignore | 是否使用项目的.gitignore文件中的模式 | true |
ignore.useDefaultPatterns | 是否使用默认忽略模式 | true |
ignore.customPatterns | 忽略的其他模式(使用球形模式) | [] |
security.enableSecurityCheck | 是否对文件执行安全检查 | true |
示例配置:
{
"output" : {
"filePath" : " repomix-output.xml " ,
"style" : " xml " ,
"headerText" : " Custom header information for the packed file. " ,
"removeComments" : false ,
"removeEmptyLines" : false ,
"showLineNumbers" : false ,
"copyToClipboard" : true ,
"topFilesLength" : 5 ,
"includeEmptyDirectories" : false
},
"include" : [ " **/* " ],
"ignore" : {
"useGitignore" : true ,
"useDefaultPatterns" : true ,
"customPatterns" : [ " additional-folder " , " **/*.log " ]
},
"security" : {
"enableSecurityCheck" : true
}
}创建一个全局配置文件:
repomix --init --global全局配置文件将创建在:
%LOCALAPPDATA%Repomixrepomix.config.json$XDG_CONFIG_HOME/repomix/repomix.config.json或~/.config/repomix/repomix.config.json注意:本地配置(如果存在)优先于全局配置。
Robix现在支持指定文件,以包括使用Glob模式。这允许更灵活,更强大的文件选择:
**/*.js将所有JavaScript文件包含在任何目录中src/**/*将所有文件包括在src目录及其子目录中["src/**/*.js", "**/*.md"]以在src中包含JavaScript文件和所有Markdown Files ropomix提供了多种方法来设置忽略模式,用于在包装过程中排除特定文件或目录:
.gitignore文件中列出的模式。可以通过ignore.useGitignore设置来控制此行为。ignore.useDefaultPatterns设置来控制此功能。有关更多详细信息,请参见Defaultignore.ts。.repomixignore文件,以定义综合症特定的忽略模式。该文件遵循与.gitignore相同的格式。ignore.customPatterns选项指定其他忽略模式。您可以使用-i, --ignore命令行选项覆盖此设置。优先顺序(从最高到最低):
ignore.customPatterns.repomixignore.gitignore (如果ignore.useGitignore使用。ignore.useDefaultPatterns为true)这种方法允许根据项目的需求进行灵活的文件排除配置。通过确保排除对安全敏感的文件和大型二进制文件,它有助于优化生成的包装文件的大小,同时防止机密信息的泄漏。
注意:默认情况下,二进制文件不包含在包装的输出中,但是它们的路径在输出文件的“存储库结构”部分中列出。这为存储库结构提供了完整的概述,同时保持包装的文件有效和基于文本。
output.instructionFilePath选项允许您指定一个包含有关项目的详细说明或上下文的单独文件。这使AI系统可以理解项目的特定上下文和要求,这可能会导致更相关和量身定制的分析或建议。
这是您如何使用此功能的一个示例:
repomix-instruction.md的文件: # Coding Guidelines
- Follow the Airbnb JavaScript Style Guide
- Suggest splitting files into smaller, focused units when appropriate
- Add comments for non-obvious logic. Keep all text in English
- All new features should have corresponding unit tests
# Generate Comprehensive Output
- Include all content without abbreviation, unless specified otherwise
- Optimize for handling large codebases while maintaining output qualityrepomix.config.json中,添加instructionFilePath选项: {
"output" : {
"instructionFilePath" : "repomix-instruction.md" ,
// other options...
}
}当ropomix生成输出时,它将在专用部分中包含repomix-instruction.md的内容。
注意:指令内容附加在输出文件的末尾。此放置对于AI系统可能特别有效。对于那些有兴趣了解为什么这可能是有益的人,众人可以在其文档中提供一些见解:
https://docs.anththropic.com/en/docs/build-with-with-claude/prompt-engineering/long-context-tips
将长格式数据放在顶部:将长文档和输入(〜20k+令牌)放在提示的顶部,高于查询,说明和示例之上。这可以显着提高Claude在所有模型中的性能。最终的查询可以在测试中提高响应质量高达30%,尤其是复杂的多文件输入。
当output.removeComments设置为true时,Robix将尝试从支持的文件类型中删除注释。此功能可以帮助减少输出文件的大小,并专注于基本代码内容。
支持的语言包括:
HTML,CSS,JavaScript,Typescript,Vue,Svelte,Python,Php,Ruby,C,C#,Java,Go,Rust,Swift,Swift,Kotlin,kotlin,Dart,Shell,Shell和Yaml。
注意:评论删除过程是保守的,避免意外删除代码。在复杂的情况下,可能会保留一些评论。
ROSPOMIX包括一个安全检查功能,该功能使用Sermerlint检测文件中潜在的敏感信息。此功能可帮助您在共享包装存储库之前确定可能的安全风险。
包装过程完成后,安全检查结果将显示在CLI输出中。如果检测到任何可疑文件,您将看到这些文件的列表以及警告消息。
示例输出:
? Security Check:
──────────────────
2 suspicious file(s) detected:
1. src/utils/test.txt
2. tests/utils/secretLintUtils.test.ts
Please review these files for potentially sensitive information.
默认情况下,启用了Robix的安全检查功能。您可以通过设置security.enableSecurityCheck false
{
"security" : {
"enableSecurityCheck" : false
}
}我们欢迎社区的捐款!要开始,请参考我们的贡献指南。
该项目已根据MIT许可获得许可。
回到顶部