You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Enhance code block file path resolution and parsing
Improve handling of file paths in code blocks by normalizing repository root paths and refining markdown parsing logic. This ensures more accurate and robust file reference detection and processing.
Copy file name to clipboardExpand all lines: docs/apply-md.md
+47-15Lines changed: 47 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
## Overview
4
4
5
-
The `apply-md` tool extracts code blocks from markdown (typically LLM responses) and applies them to your filesystem.
5
+
The `apply-md` tool extracts code blocks from markdown (typically LLM responses) and applies them to your filesystem. It supports both relative and absolute paths, with absolute paths resolved relative to the git repository root when run within a git repository.
The language specification is optional, but the filename is required.
100
+
### Absolute Path (from git root)
101
+
```markdown
102
+
```bash /scripts/deploy.sh
103
+
#!/bin/bash
104
+
echo "Deploying..."
105
+
```
106
+
```
107
+
108
+
The language specification is optional, but the filename is required. Absolute paths (starting with /) will be resolved relative to the git repository root when run within a git repository.
90
109
91
110
## Tips
92
111
93
112
- Always use `--dry-run` first to preview changes
113
+
- Use `--verbose` to see the detected git root and normalized paths
94
114
- Consider using `--backup` for important changes
95
-
- Use `--verbose` to see details about what's changing
96
-
- For complex changes, use `--confirm` to review each change individually
115
+
- Use `--confirm` to review each change individually
116
+
- When using absolute paths, ensure you're running from within a git repository
117
+
- If not in a git repository, absolute paths will be treated as system paths
118
+
119
+
## Git Integration
120
+
121
+
When run within a git repository:
122
+
- Detects the repository root automatically
123
+
- Converts absolute paths (e.g., `/src/main.js`) to relative paths from the git root
124
+
- Shows the detected git root in verbose mode
125
+
126
+
If not in a git repository:
127
+
- Absolute paths are treated as system absolute paths
0 commit comments