Add custom instructions for AI
This commit is contained in:
parent
cfeb71b99c
commit
011d3f8111
1 changed files with 36 additions and 0 deletions
|
@ -82,6 +82,42 @@ in
|
||||||
};
|
};
|
||||||
codex = {
|
codex = {
|
||||||
enable = true;
|
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 = {
|
settings = {
|
||||||
model = "${localFastModel}";
|
model = "${localFastModel}";
|
||||||
provider = "ollama";
|
provider = "ollama";
|
||||||
|
|
Reference in a new issue