diff --git a/.agent/AGENTS.md b/.agent/AGENTS.md index 93c6fa4d2e..806a233bba 100644 --- a/.agent/AGENTS.md +++ b/.agent/AGENTS.md @@ -117,6 +117,14 @@ Run pre-edit-check.sh in `~/Git/aidevops/` BEFORE any changes to either location **Quality Standards**: SonarCloud A-grade, ShellCheck zero violations +**File Discovery** (fastest to slowest): +1. `git ls-files '*.md'` - Instant, git-tracked files only +2. `fd -e md` or `fd -g '*.md'` - Fast, respects .gitignore, Rust-based +3. `rg --files -g '*.md'` - Fast, respects .gitignore (ripgrep) +4. `mcp_glob` tool - Fallback when bash unavailable or for complex patterns + +Use `git ls-files` for tracked files (most common). Use `fd` for untracked files or system-wide searches (e.g., `~/.config/`). The `mcp_glob` tool is CPU-intensive on large codebases. + **Localhost Standards** (for any local service setup): - **Always check port first**: `localhost-helper.sh check-port ` before starting services - **Use .local domains**: `myapp.local` not `localhost:3000` (enables password manager autofill) diff --git a/README.md b/README.md index fd402b4299..23acb713a7 100644 --- a/README.md +++ b/README.md @@ -445,13 +445,33 @@ See `.agent/aidevops/architecture.md` for detailed implementation notes and refe ```bash # Install dependencies (auto-detected by setup.sh) -brew install sshpass jq curl mkcert dnsmasq # macOS -sudo apt-get install sshpass jq curl dnsmasq # Ubuntu/Debian +brew install sshpass jq curl mkcert dnsmasq fd ripgrep # macOS +sudo apt-get install sshpass jq curl dnsmasq fd-find ripgrep # Ubuntu/Debian # Generate SSH key ssh-keygen -t ed25519 -C "your-email@domain.com" ``` +### **File Discovery Tools** + +AI agents use fast file discovery tools for efficient codebase navigation: + +| Tool | Purpose | Speed | +|------|---------|-------| +| `fd` | Fast file finder (replaces `find`) | ~10x faster | +| `ripgrep` | Fast content search (replaces `grep`) | ~10x faster | + +Both tools respect `.gitignore` by default and are written in Rust for maximum performance. + +**Preference order for file discovery:** + +1. `git ls-files '*.md'` - Instant, git-tracked files only +2. `fd -e md` - Fast, respects .gitignore +3. `rg --files -g '*.md'` - Fast, respects .gitignore +4. Built-in glob tools - Fallback when bash unavailable + +The setup script offers to install these tools automatically. + ## **Comprehensive Service Coverage** ### **Infrastructure & Hosting** diff --git a/setup.sh b/setup.sh index 21ffef861f..cfc23f3459 100755 --- a/setup.sh +++ b/setup.sh @@ -562,6 +562,109 @@ setup_git_clis() { return 0 } +# Setup file discovery tools (fd, ripgrep) for efficient file searching +setup_file_discovery_tools() { + print_info "Setting up file discovery tools..." + + local missing_tools=() + local missing_packages=() + local missing_names=() + + # Check for fd (fd-find) + if ! command -v fd >/dev/null 2>&1; then + missing_tools+=("fd") + missing_packages+=("fd") + missing_names+=("fd (fast file finder)") + else + local fd_version + fd_version=$(fd --version 2>/dev/null | head -1 || echo "unknown") + print_success "fd found: $fd_version" + fi + + # Check for ripgrep + if ! command -v rg >/dev/null 2>&1; then + missing_tools+=("rg") + missing_packages+=("ripgrep") + missing_names+=("ripgrep (fast content search)") + else + local rg_version + rg_version=$(rg --version 2>/dev/null | head -1 || echo "unknown") + print_success "ripgrep found: $rg_version" + fi + + # Offer to install missing tools + if [[ ${#missing_tools[@]} -gt 0 ]]; then + print_warning "Missing file discovery tools: ${missing_names[*]}" + echo "" + echo " These tools provide 10x faster file discovery than built-in glob:" + echo " fd - Fast alternative to 'find', respects .gitignore" + echo " ripgrep - Fast alternative to 'grep', respects .gitignore" + echo "" + echo " AI agents use these for efficient codebase navigation." + echo "" + + local pkg_manager + pkg_manager=$(detect_package_manager) + + if [[ "$pkg_manager" != "unknown" ]]; then + read -r -p "Install file discovery tools (${missing_packages[*]}) using $pkg_manager? (y/n): " install_fd_tools + + if [[ "$install_fd_tools" == "y" ]]; then + print_info "Installing ${missing_packages[*]}..." + + # Handle package name differences across package managers + local actual_packages=() + for pkg in "${missing_packages[@]}"; do + case "$pkg_manager" in + apt) + # Debian/Ubuntu uses fd-find instead of fd + if [[ "$pkg" == "fd" ]]; then + actual_packages+=("fd-find") + else + actual_packages+=("$pkg") + fi + ;; + *) + actual_packages+=("$pkg") + ;; + esac + done + + if install_packages "$pkg_manager" "${actual_packages[@]}"; then + print_success "File discovery tools installed" + + # On Debian/Ubuntu, fd is installed as fdfind - create alias + if [[ "$pkg_manager" == "apt" ]] && command -v fdfind >/dev/null 2>&1 && ! command -v fd >/dev/null 2>&1; then + print_info "Note: On Debian/Ubuntu, fd is installed as 'fdfind'" + echo " Consider adding to your shell config: alias fd=fdfind" + fi + else + print_warning "Failed to install some file discovery tools (non-critical)" + fi + else + print_info "Skipped file discovery tools installation" + echo "" + echo " Manual installation:" + echo " macOS: brew install fd ripgrep" + echo " Ubuntu/Debian: sudo apt install fd-find ripgrep" + echo " Fedora: sudo dnf install fd-find ripgrep" + echo " Arch: sudo pacman -S fd ripgrep" + fi + else + echo "" + echo " Manual installation:" + echo " macOS: brew install fd ripgrep" + echo " Ubuntu/Debian: sudo apt install fd-find ripgrep" + echo " Fedora: sudo dnf install fd-find ripgrep" + echo " Arch: sudo pacman -S fd ripgrep" + fi + else + print_success "All file discovery tools installed!" + fi + + return 0 +} + # Setup Worktrunk - Git worktree management for parallel AI agent workflows setup_worktrunk() { print_info "Setting up Worktrunk (git worktree management)..." @@ -2439,6 +2542,7 @@ main() { confirm_step "Check optional dependencies (bun, node, python)" && check_optional_deps confirm_step "Setup recommended tools (Tabby, Zed, etc.)" && setup_recommended_tools confirm_step "Setup Git CLIs (gh, glab, tea)" && setup_git_clis + confirm_step "Setup file discovery tools (fd, ripgrep)" && setup_file_discovery_tools confirm_step "Setup Worktrunk (git worktree management)" && setup_worktrunk confirm_step "Setup SSH key" && setup_ssh_key confirm_step "Setup configuration files" && setup_configs