feat(tools): add glob tool with timeout protection

- Override OpenCode's built-in glob with 60s timeout
- Kill process on expiration to prevent indefinite hanging
- Reuse grep's CLI resolver for ripgrep detection

Generated by [OpenCode](https://opencode.ai/)
This commit is contained in:
YeonGyu-Kim
2025-12-08 14:04:37 +09:00
parent b77dd2fcdf
commit ed3d7a55f4
9 changed files with 241 additions and 0 deletions

26
src/tools/glob/utils.ts Normal file
View File

@@ -0,0 +1,26 @@
import type { GlobResult } from "./types"
export function formatGlobResult(result: GlobResult): string {
if (result.error) {
return `Error: ${result.error}`
}
if (result.files.length === 0) {
return "No files found"
}
const lines: string[] = []
lines.push(`Found ${result.totalFiles} file(s)`)
lines.push("")
for (const file of result.files) {
lines.push(file.path)
}
if (result.truncated) {
lines.push("")
lines.push("(Results are truncated. Consider using a more specific path or pattern.)")
}
return lines.join("\n")
}