feat: add edit_file tool + code-navigation tools (grep, glob, ls) #951

Closed
sleepy wants to merge 1 commit from fix/936-edit-file-code-nav-tools into dev
Owner

Summary

Port diff-based edit_file tool and code-navigation tools (grep, glob, ls, get_workspace) from upstream commits 7443c36, 1f00fff. Replaces raw overwrite behavior with safer diff-based editing.

Changes

  • edit_file: Exact string replacement with unified diff output, replace_all support, uniqueness validation
  • grep: Regex search across directory tree, ripgrep-first with Python fallback, .gitignore-aware
  • glob: Recursive file pattern matching, skips hidden/vendor dirs, newest-first
  • ls: Directory listing, folders-first with file sizes
  • get_workspace: Report active workspace folder
  • read_file: Enhanced with line-range support (offset/limit parameters)
  • write_file: Enhanced with unified diff output when overwriting

Files Changed

  • src/tools/filesystem_tools.py — New: all 7 tool implementations
  • src/tools/_shared.py — Added MAX_DIFF_LINES, _CODENAV_SKIP_DIRS, _unified_diff
  • src/tool_schemas/core_schemas.py — Schemas for all new tools + updated read_file
  • src/tool_execution_utils.py — Native handler factory + _direct_fallback integration
  • src/tool_execution.py — Handler registration for all new tools
  • src/tool_security.py — Added new tools to NON_ADMIN_BLOCKED_TOOLS
  • src/tools/__init__.py + src/tool_implementations.py — Re-exports
  • tests/test_filesystem_tools.py — 38 tests covering all new tools

Closes #936

## Summary Port diff-based `edit_file` tool and code-navigation tools (`grep`, `glob`, `ls`, `get_workspace`) from upstream commits `7443c36`, `1f00fff`. Replaces raw overwrite behavior with safer diff-based editing. ## Changes - **edit_file**: Exact string replacement with unified diff output, `replace_all` support, uniqueness validation - **grep**: Regex search across directory tree, ripgrep-first with Python fallback, `.gitignore`-aware - **glob**: Recursive file pattern matching, skips hidden/vendor dirs, newest-first - **ls**: Directory listing, folders-first with file sizes - **get_workspace**: Report active workspace folder - **read_file**: Enhanced with line-range support (`offset`/`limit` parameters) - **write_file**: Enhanced with unified diff output when overwriting ## Files Changed - `src/tools/filesystem_tools.py` — New: all 7 tool implementations - `src/tools/_shared.py` — Added `MAX_DIFF_LINES`, `_CODENAV_SKIP_DIRS`, `_unified_diff` - `src/tool_schemas/core_schemas.py` — Schemas for all new tools + updated `read_file` - `src/tool_execution_utils.py` — Native handler factory + `_direct_fallback` integration - `src/tool_execution.py` — Handler registration for all new tools - `src/tool_security.py` — Added new tools to `NON_ADMIN_BLOCKED_TOOLS` - `src/tools/__init__.py` + `src/tool_implementations.py` — Re-exports - `tests/test_filesystem_tools.py` — 38 tests covering all new tools Closes #936
- Port edit_file with unified diff output (exact string replacement, replace_all support)
- Port grep tool (regex search, ripgrep-first with Python fallback, .gitignore-aware)
- Port glob tool (recursive file pattern matching, skips hidden dirs)
- Port ls tool (directory listing, folders-first, sizes)
- Port get_workspace tool (report active workspace folder)
- Add line-range support to read_file (offset/limit parameters)
- Add diff output to write_file (unified diff when overwriting)
- Register all new tools in tool handler registry and execution dispatch
- Add schemas for all new tools in core_schemas.py
- Add new tools to NON_ADMIN_BLOCKED_TOOLS security policy
- Add diff display support in format_tool_result
- 38 comprehensive tests covering all new tools

Refs: #936
sleepy closed this pull request 2026-06-18 18:33:45 +02:00

Pull request closed

Sign in to join this conversation.
No description provided.