Skip to content

Add ast-grep provider for AST-aware code search and transformation #34

Description

@amondnet

Summary

Add ast-grep tools and skill to dora MCP server for AST-aware code search and transformation capabilities.

AST-aware search understands code structure (unlike text-based grep), enabling queries like "find async functions without error handling".

Context

  • Reference implementation: ref/oh-my-opencode/src/tools/ast-grep/
  • Architecture decision: docs/adr/0001-ast-grep-integration-architecture.md

Features to Implement

MCP Tools

  • ast_grep_search - AST-aware code search
  • ast_grep_replace - AST-aware code transformation

Language Support

  • CLI: 25+ languages supported
  • NAPI bindings: 5 languages (faster in-memory transforms)
  • Binary auto-download from GitHub releases
  • YAML rule file support

Agent/Skill

  • Rule writing guidance and examples

Architecture

packages/dora/src/providers/ast-grep/
├── index.ts        # AstGrepProvider
├── cli.ts          # CLI wrapper
├── downloader.ts   # Binary download
├── napi.ts         # NAPI bindings
├── constants.ts    # Config
├── types.ts        # Types
└── utils.ts        # Formatting

agents/ast-grep.md  # Rule writing skill

Tasks

  • T001 [P] Create types.ts with interfaces (CliMatch, SgResult, etc.)
  • T002 [P] Create constants.ts with languages, platform config, defaults
  • T003 Create downloader.ts for binary auto-download (depends on T002)
  • T004 Create cli.ts with runSg function (depends on T002, T003)
  • T005 [P] Create napi.ts for in-memory transforms
  • T006 [P] Create utils.ts for result formatting
  • T007 Create index.ts AstGrepProvider (depends on T001-T006)
  • T008 Export provider from packages/dora/src/providers/index.ts (depends on T007)
  • T009 Register provider in packages/dora/src/server.ts (depends on T008)
  • T010 Create agents/ast-grep.md skill for rule writing
  • T011 Add unit tests for ast-grep provider
  • T012 Add integration tests for ast-grep tools

Acceptance Criteria

  • All tasks completed and tested
  • ast-grep provider fully functional and integrated into dora MCP server
  • Documentation updated with ast-grep tool usage
  • Agent skill provides helpful guidance for rule writing

Metadata

Metadata

Assignees

No one assigned

    Labels

    p1Priority 1 - Hightype:featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions