Skip to content

fix(ast-grep): add validation for incomplete function declaration patterns#5

Merged
code-yeongyu merged 2 commits into
masterfrom
fix-ast-grep-search-function-pattern
Dec 5, 2025
Merged

fix(ast-grep): add validation for incomplete function declaration patterns#5
code-yeongyu merged 2 commits into
masterfrom
fix-ast-grep-search-function-pattern

Conversation

@code-yeongyu

Copy link
Copy Markdown
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
sssgun pushed a commit to sssgun/oh-my-opencode that referenced this pull request Jan 18, 2026
…terns (code-yeongyu#5)

* fix(publish): make git operations idempotent

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

* fix(ast-grep): add validation for incomplete function declaration patterns

- 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.
qwertystars added a commit to qwertystars/oh-my-opencode that referenced this pull request Jan 29, 2026
- Remove sisyphusJuniorModel fallback bypass (BUG #1)
  - userModel fallback was incorrectly bypassing category fallbackChain
  - Now correctly uses category requirements before system default

- Fix variant preservation in actualModel fallback path (BUG #2)
  - Variant was lost when categoryModel undefined but actualModel existed
  - Now preserves variant when falling back to actualModel parsing

- Add variant to session continuation (BUG code-yeongyu#3)
  - Session resume didn't pass variant from message history
  - Now extracts resumeVariant and passes as body.variant

- Remove unused inheritedModel parameter (BUG code-yeongyu#4)
  - resolveCategoryConfig had misleading unused parameter
  - Cleaned up function signature and all call sites

- Add variant-model compatibility validation (BUG code-yeongyu#5)
  - No warning when variant might not be supported by provider
  - Added isVariantLikelySupported() validation with console.warn

Test coverage:
- Updated 10+ existing tests to remove inheritedModel references
- Added 9 new tests for variant validation functions
- All 110 tests pass (77 delegate-task + 33 model-requirements)
luobosibing2 pushed a commit to luobosibing2/oh-my-opencode that referenced this pull request Feb 23, 2026
…-yeongyu#309)

Critical fixes:
- Bug #1: SubagentStop hook defaulted all agents to 'failed' because SDK
  doesn't provide `success` field. Now defaults to 'completed' when undefined.
- Bug code-yeongyu#4: Token stats lost across TokenTracker instances. Constructor now
  restores session stats from global state for the same session ID.
- Bug code-yeongyu#5: Ultrawork session isolation bypassed when both session IDs were
  undefined (undefined === undefined). Now rejects all falsy session IDs.

High priority fixes:
- Bug code-yeongyu#6: Cancel skill force-clear missed 12+ state files (boulder,
  hud-state, subagent-tracking, checkpoints, etc). Added comprehensive list.
- Bug code-yeongyu#7: HUD semverCompare() returned NaN on pre-release versions like
  "3.9.5-beta". Fixed to use parseInt and handle pre-release ordering.
- Bug code-yeongyu#8: Silent JSON parse failures in critical state readers. Added
  error logging to ralph and ultrawork state readers.
- Bug code-yeongyu#9: Stale task detection had no default behavior when onStaleSession
  callback was not configured. Now auto-cleans after 2x threshold.
- Bug code-yeongyu#10: Hardcoded 3-architect assumption in validation. Extracted to
  REQUIRED_ARCHITECTS constant.

Medium priority fixes:
- Bug code-yeongyu#11: Auto-invoke history used non-atomic writes. Now uses
  atomicWriteJson to prevent corruption from concurrent sessions.
- Bug code-yeongyu#12: Ecomode docs said "all tasks" use Haiku, contradicting the
  escalation paths. Clarified to "most tasks" with upgrade criteria.
- Bug code-yeongyu#13: Added safeUnlinkSync/safeRmSync utilities to prevent ENOENT
  crashes during cleanup operations.
- Bug code-yeongyu#14: State files containing user prompts written with 0644
  permissions. Now writes with 0600 (owner-only read/write).
- Bug code-yeongyu#15: Model names recorded inconsistently (e.g., 'claude-3-5-haiku'
  vs 'claude-haiku-4'). Now normalizes at recording time via exported
  normalizeModelName().

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
code-yeongyu pushed a commit that referenced this pull request Feb 24, 2026
…hardening

Fixes from multi-model council audit (7 members, 19 findings, 9 selected):

- Use parseModelString() for cross-provider Anthropic thinking config (#3)
- Update stale AGENTS.md athena directory listing (#4)
- Replace prompt in appendMissingCouncilPrompt instead of appending (#5)
- Extract duplicated session cleanup logic in agent-switch hook (#6)
- Surface skipped council members when >=2 valid members exist (#9)
- Expand fallback handoff regex with negation guards (#11)
- Remove dead council-member agent from agentSources and tests (#12)
- Make runtime council member duplicate check case-insensitive (#14)
- Fix false-positive schema tests by adding required name field (#18)
code-yeongyu pushed a commit that referenced this pull request Apr 15, 2026
…hardening

Fixes from multi-model council audit (7 members, 19 findings, 9 selected):

- Use parseModelString() for cross-provider Anthropic thinking config (#3)
- Update stale AGENTS.md athena directory listing (#4)
- Replace prompt in appendMissingCouncilPrompt instead of appending (#5)
- Extract duplicated session cleanup logic in agent-switch hook (#6)
- Surface skipped council members when >=2 valid members exist (#9)
- Expand fallback handoff regex with negation guards (#11)
- Remove dead council-member agent from agentSources and tests (#12)
- Make runtime council member duplicate check case-insensitive (#14)
- Fix false-positive schema tests by adding required name field (#18)
hexstyle pushed a commit to hexstyle/oh-my-openagent that referenced this pull request Apr 15, 2026
…hardening

Fixes from multi-model council audit (7 members, 19 findings, 9 selected):

- Use parseModelString() for cross-provider Anthropic thinking config (code-yeongyu#3)
- Update stale AGENTS.md athena directory listing (code-yeongyu#4)
- Replace prompt in appendMissingCouncilPrompt instead of appending (code-yeongyu#5)
- Extract duplicated session cleanup logic in agent-switch hook (code-yeongyu#6)
- Surface skipped council members when >=2 valid members exist (code-yeongyu#9)
- Expand fallback handoff regex with negation guards (code-yeongyu#11)
- Remove dead council-member agent from agentSources and tests (code-yeongyu#12)
- Make runtime council member duplicate check case-insensitive (code-yeongyu#14)
- Fix false-positive schema tests by adding required name field (code-yeongyu#18)
Coldaine referenced this pull request in Coldaine/oh-my-openagent May 20, 2026
**Justification — Oracle analysis #5:**
Oracle: 'Replace infinite retry language with debugger-style escalation:
after three materially different failed fix attempts, stop guessing,
gather evidence, consult Oracle, then resume with implementation_handoff.'

Atlas's current 'no retry cap' policy (default-prompt-sections.ts:149)
creates failure loops — agents retry the same broken approach indefinitely,
burning tokens without progress.

**What changed — default-prompt-sections.ts:**
- Section 3.5 renamed from 'NEVER GIVE UP' to 'Three-Fail Rule'
- Hard 3-attempt cap: attempts 1-2 use task_id retry with different
  approaches, attempt 3 triggers Oracle escalation
- Escalation path: gather evidence bundle → consult Oracle → receive
  implementation_handoff → resume with handoff (do_not_reinvestigate)
- Red flags section: conditions that trigger immediate escalation
  ('just one more fix', fixing before understanding, quick-fix mindset)
- Removed 'There is no retry cap' language and infinite-retry guidance
- Retained task_id usage instructions for attempts 1-2

**Remaining work:**
gpt-prompt-sections.ts, gemini-prompt-sections.ts, kimi-prompt-sections.ts,
and opus-4-7-prompt-sections.ts all have the same 'no retry cap' language
and need the same Three-Fail Rule update.

**Gem-team source:**
- gem-debugger Three-Fail Rule (gem-debugger.agent.md:170-197)
- implementation_handoff schema (gem-debugger.agent.md:224-229)
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.

1 participant