
Repository Instructions【免费下载链接】repomix Repomix 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/repomixThis repository contains the source code for the Repomix tool. Please follow these guidelines when analyzing the code:Focus on the core functionality in thesrc/coredirectory.Pay special attention to the security checks insrc/core/security.Ignore any files in thetestsdirectory.这段内容会被完整地包含进输出。在默认 XML 输出风格下对应生成如下片段 xml instruction # Repository Instructions This repository contains the source code for the Repomix tool. Please follow these guidelines when analyzing the code: 1. Focus on the core functionality in the src/core directory. 2. Pay special attention to the security checks in src/core/security. 3. Ignore any files in the tests directory. /instruction可以看到指令内容被原样保留包括 Markdown 标题、列表并由instruction标签包裹便于 AI 与后续解析工具识别。输出格式中的呈现方式自定义指令并非只出现在 XML 输出中Repomix 的每种输出风格都有对应的渲染位置这可以从模板源码中直接确认XML 风格xmlStyle.ts使用{{#if instruction}}条件包裹渲染为instruction标签块Markdown 风格markdownStyle.ts渲染为# Instruction一级标题下的内容块Plain 纯文本风格plainStyle.ts以纯文本段落形式输出可解析 JSON 风格parsableStyle: true时在 outputGenerate.ts 中通过...(renderContext.instruction { instruction: renderContext.instruction })生成instruction顶层字段指令以结构化键值形式呈现便于程序化读取。由此可见无论你偏好哪种输出风格自定义指令都会以该风格最自然的形式被保留下来不会因切换格式而丢失。源码级原理指令文件如何被读取与注入自定义指令的完整数据流在 outputGenerate.ts 中清晰可见核心逻辑如下let repositoryInstruction ; if (config.output.instructionFilePath) { const instructionPath path.resolve(config.cwd, config.output.instructionFilePath); try { repositoryInstruction await fs.readFile(instructionPath, utf-8); } catch { throw new RepomixError(Instruction file not found at ${instructionPath}); } }这段实现透露出几个关键事实相对路径基于当前工作目录解析path.resolve(config.cwd, ...)说明配置中的路径是相对于运行 Repomix 时的工作目录cwd解析的因此官方示例建议将指令文件放在仓库根目录恰好与默认运行目录一致按 UTF-8 读取纯文本文件以utf-8编码读取Markdown 内容会保持原样文件缺失时直接报错若指令文件不存在会抛出Instruction file not found at 路径错误打包流程终止——这保证了输出中不会静默缺失指令未配置时优雅降级当instructionFilePath未设置或为空时repositoryInstruction保持空字符串后续模板渲染中的{{#if instruction}}条件为假指令段落不会出现在输出中。读取结果随后被放入OutputGeneratorContext第 440 行instruction: repositoryInstruction再经 createRenderContext 转发给各输出风格的模板引擎完成渲染。配置项定义与默认值从配置模式定义configSchema.ts 与默认值定义configSchema.ts可以确认instructionFilePath属于output配置节点类型为可选的字符串该字段没有默认值未配置时功能处于关闭状态它与其他output子项如headerText、style、fileSummary等平级可自由组合。值得区分的是output.headerTextheaderText 用于在输出头部添加一段固定说明文本而instructionFilePath是从外部文件读取的指令内容两者注入的位置与语义不同可根据需要同时使用。本仓库中的真实用法dogfooding 实践Repomix 项目自身就在使用该功能。仓库根目录的 repomix.config.json 中配置了{ output: { instructionFilePath: repomix-instruction.md } }【免费下载链接】repomix Repomix 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),仅供参考