patch-resolve
v0.1.3
Published
CLI tool for patching files and resolving file includes - useful when working with LLMs
Readme
patch-resolve
A CLI tool for patching files and resolving file includes - designed to make working with LLMs easier.
Installation
npm install -g patch-resolve
# or
bun add -g patch-resolveCommands
patch
Apply file contents from a patch file with special marker separators to their respective files.
patch-resolve patch <file>The patch file uses the separator format: --- <path>:
Example patch file:
--- src/index.ts:
export const foo = 'bar';
--- src/utils.ts:
export function helper() {
return 'hello';
}This will:
- Create/overwrite
src/index.tswithexport const foo = 'bar'; - Create/overwrite
src/utils.tswith the helper function - Create parent directories if they don't exist
resolve
Resolve file includes and copy to clipboard, also write to temp file.
patch-resolve resolve <file>The resolve file uses include patterns like {{path/to/file}}.
Example resolve file:
// Main application code
{{shared/config.ts}}
{{api/endpoints.ts}}This will:
- Read
shared/config.tsand replace{{shared/config.ts}}with its content - Read
api/endpoints.tsand replace{{api/endpoints.ts}}with its content - Write the resolved content to a temp file
- Copy to clipboard (by default)
Options:
-p, --pattern <pattern>- Custom include pattern-o, --output <path>- Custom output path--no-clipboard- Skip copying to clipboard
Use Cases
- With LLMs: LLMs can output patch files with
--- <path>:separators, and you can apply them with one command - With LLMs: LLMs can reference multiple files using
{{path}}patterns, and you can resolve them into a single file - File batch operations: Apply multiple file changes at once from a single patch file
License
MIT
