From 011d3f81114bfaa695e44fac8c62a0dcc9a325aa Mon Sep 17 00:00:00 2001 From: Ethan Reece Date: Wed, 2 Jul 2025 04:12:43 -0500 Subject: [PATCH] Add custom instructions for AI --- home/home.nix | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/home/home.nix b/home/home.nix index 58f672b..9a0e3d1 100644 --- a/home/home.nix +++ b/home/home.nix @@ -82,6 +82,42 @@ in }; codex = { enable = true; + custom-instructions = '' +## 10. Applying Patch Files with patch + +When the built-in `apply_patch` tool or `git apply` fails to apply a diff/patch file (especially if the file being patched contains special characters that might confuse simpler patch tools), the standard `patch` utility can be a more robust alternative. + +- **Patch File Format**: Ensure your patch file is in a standard unified diff format. Typically, these patches are generated with `git diff > my_feature.patch` or manually crafted. If the patch refers to files with `a/` and `b/` prefixes (e.g., `--- a/file.txt`, `+++ b/file.txt`), you'll use the `-p1` option. + +- **Creating the Patch File**: You can create a patch file using shell redirection, for example: + +```bash` +cat <<'EOF' > fix_descriptive_name.patch +--- a/path/to/your/file.ext ++++ b/path/to/your/file.ext +@@ -line_num,num_lines +line_num,num_lines @@ context_or_change +-old_line_content ++new_line_content +EOF +``` + +*Important*: Ensure the `EOF` marker is on its own line with no trailing spaces. + +- **Applying the Patch**: Use the `patch` command via the `shell` tool. The `-p1` option strips the leading component from file paths in the patch file (`a/`, `b/`). + +``` +# Example: Apply a patch file +default_api.shell(command=["sh", "-c", "patch -p1 < fix_descriptive_name.patch"]) +``` + +- **Verification**: After applying, always verify that the target file has been changed as expected (e.g., using `cat` or `git diff`). + +- **Cleanup**: Remove the patch file if it's no longer needed: + +``` +default_api.shell(command=["rm", "fix_descriptive_name.patch"]) +``` +''; settings = { model = "${localFastModel}"; provider = "ollama";