refactor(tools): rename safe-grep to grep with override capability

This commit is contained in:
YeonGyu-Kim
2025-12-08 13:35:02 +09:00
parent 64b3564760
commit b77dd2fcdf
10 changed files with 14 additions and 16 deletions

View File

@@ -13,7 +13,7 @@
- [Tools](#tools) - [Tools](#tools)
- [내장 LSP Tools](#내장-lsp-tools) - [내장 LSP Tools](#내장-lsp-tools)
- [내장 AST-Grep Tools](#내장-ast-grep-tools) - [내장 AST-Grep Tools](#내장-ast-grep-tools)
- [Safe Grep](#safe-grep) - [Grep](#grep)
- [내장 MCPs](#내장-mcps) - [내장 MCPs](#내장-mcps)
- [기타 편의 기능](#기타-편의-기능) - [기타 편의 기능](#기타-편의-기능)
- [설정](#설정) - [설정](#설정)
@@ -185,11 +185,10 @@ OpenCode 는 아주 확장가능하고 아주 커스터마이저블합니다.
- **ast_grep_search**: AST 인식 코드 패턴 검색 (25개 언어) - **ast_grep_search**: AST 인식 코드 패턴 검색 (25개 언어)
- **ast_grep_replace**: AST 인식 코드 교체 - **ast_grep_replace**: AST 인식 코드 교체
#### Safe Grep #### Grep
- **safe_grep**: 안전 제한이 있는 콘텐츠 검색 (5분 타임아웃, 10MB 출력 제한). - **grep**: 안전 제한이 있는 콘텐츠 검색 (5분 타임아웃, 10MB 출력 제한). OpenCode의 내장 `grep` 도구를 대체합니다.
- 기본 grep 도구는 시간제한이 걸려있지 않습니다. 대형 코드베이스에서 광범위한 패턴을 검색하면 CPU가 폭발하고 무한히 멈출 수 있습니다. - 기본 grep 도구는 시간제한이 걸려있지 않습니다. 대형 코드베이스에서 광범위한 패턴을 검색하면 CPU가 폭발하고 무한히 멈출 수 있습니다.
- safe_grep 은 timeout 과 더 엄격한 출력 제한을 적용합니다. - 이 도구는 엄격한 제한을 적용하며, 내장 `grep`을 완전히 대체합니다.
- **주의**: 기본 grep 도구는 Agent 를 햇갈리게 하지 않기 위해 비활성화됩니다. 그러나 SafeGrep 은 Grep 이 제공하는 모든 기능을 제공합니다.
#### 내장 MCPs #### 내장 MCPs

View File

@@ -13,7 +13,7 @@ English | [한국어](README.ko.md)
- [Tools](#tools) - [Tools](#tools)
- [Built-in LSP Tools](#built-in-lsp-tools) - [Built-in LSP Tools](#built-in-lsp-tools)
- [Built-in AST-Grep Tools](#built-in-ast-grep-tools) - [Built-in AST-Grep Tools](#built-in-ast-grep-tools)
- [Safe Grep](#safe-grep) - [Grep](#grep)
- [Built-in MCPs](#built-in-mcps) - [Built-in MCPs](#built-in-mcps)
- [Other Features](#other-features) - [Other Features](#other-features)
- [Configuration](#configuration) - [Configuration](#configuration)
@@ -181,12 +181,11 @@ The features you use in your editor—other agents cannot access them. Oh My Ope
- **ast_grep_search**: AST-aware code pattern search (25 languages) - **ast_grep_search**: AST-aware code pattern search (25 languages)
- **ast_grep_replace**: AST-aware code replacement - **ast_grep_replace**: AST-aware code replacement
#### Safe Grep #### Grep
- **safe_grep**: Content search with safety limits (5min timeout, 10MB output). - **grep**: Content search with safety limits (5min timeout, 10MB output). Overrides OpenCode's built-in `grep` tool.
- The default `grep` lacks safeguards. On a large codebase, a broad pattern can cause CPU overload and indefinite hanging. - The default `grep` lacks safeguards. On a large codebase, a broad pattern can cause CPU overload and indefinite hanging.
- `safe_grep` enforces strict limits. - This tool enforces strict limits and completely replaces the built-in `grep`.
- **Note**: Default `grep` is disabled to prevent Agent confusion. `safe_grep` delivers full `grep` functionality with safety assurance.
#### Built-in MCPs #### Built-in MCPs

3
src/tools/grep/index.ts Normal file
View File

@@ -0,0 +1,3 @@
import { grep } from "./tools"
export { grep }

View File

@@ -2,7 +2,7 @@ import { tool } from "@opencode-ai/plugin/tool"
import { runRg } from "./cli" import { runRg } from "./cli"
import { formatGrepResult } from "./utils" import { formatGrepResult } from "./utils"
export const safe_grep = tool({ export const grep = tool({
description: description:
"Fast content search tool with safety limits (60s timeout, 10MB output). " + "Fast content search tool with safety limits (60s timeout, 10MB output). " +
"Searches file contents using regular expressions. " + "Searches file contents using regular expressions. " +

View File

@@ -17,7 +17,7 @@ import {
ast_grep_replace, ast_grep_replace,
} from "./ast-grep" } from "./ast-grep"
import { safe_grep } from "./safe-grep" import { grep } from "./grep"
export const builtinTools = { export const builtinTools = {
lsp_hover, lsp_hover,
@@ -33,5 +33,5 @@ export const builtinTools = {
lsp_code_action_resolve, lsp_code_action_resolve,
ast_grep_search, ast_grep_search,
ast_grep_replace, ast_grep_replace,
safe_grep, grep,
} }

View File

@@ -1,3 +0,0 @@
import { safe_grep } from "./tools"
export { safe_grep }