Skip to content

Conversation

@code-yeongyu
Copy link
Owner

Summary

  • ast_grep_search에서 불완전한 함수 선언 패턴(export async function $METHOD)이 조용히 실패하는 문제 수정
  • 불완전 패턴 검증 함수(validatePatternForCli) 추가
  • 친절한 에러 메시지와 올바른 패턴 예시 제공

Problem

LLM 에이전트가 ast_grep_search [pattern=export async function $METHOD, lang=typescript] 패턴을 사용할 때 결과가 없거나 애매한 에러가 발생했습니다.

원인: ast-grep은 완전한 AST 노드만 매칭 가능하며, export async function $METHOD는 파라미터와 바디가 없어 불완전한 패턴입니다.

Solution

  1. validatePatternForCli 함수 추가: JS/TS 언어에서 불완전한 함수 선언 패턴 감지
  2. 에러 메시지 개선: 올바른 패턴 예시 포함
  3. 도구 description 업데이트: "완전한 AST 노드 필요" 명시

Changes

  • src/tools/ast-grep/tools.ts: 패턴 검증 로직 및 description 업데이트 (+45 lines)

Testing

  • TypeScript typecheck 통과
  • Oracle 코드 리뷰 완료

Correct Pattern Examples

// ❌ Incomplete - will now show helpful error
"export async function $METHOD"

// ✅ Correct
"export async function $NAME($$$) { $$$ }"
"function $NAME($$$) { $$$ }"
"async function $NAME($$$) { $$$ }"

- Check for staged changes before commit
- Check if tag exists before creating
- Check if release exists before creating
…terns

- Add validatePatternForCli function to detect incomplete patterns like
  'export async function $METHOD' (missing params and body)
- Only validates JS/TS languages (javascript, typescript, tsx)
- Provides helpful error message with correct pattern examples
- Update tool description to clarify complete AST nodes required

This fixes the issue where incomplete patterns would fail silently
with no results instead of providing actionable feedback.
@code-yeongyu code-yeongyu merged commit 2464473 into master Dec 5, 2025
1 check passed
@code-yeongyu code-yeongyu deleted the fix-ast-grep-search-function-pattern branch December 21, 2025 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants