feat(tools): add ast-grep tools for AST-aware code search and transformation
- Add ast_grep_search for pattern-based code search (25 languages) - Add ast_grep_replace for AST-aware code rewriting with dry-run - Add ast_grep_analyze for in-memory code analysis (NAPI) - Add ast_grep_transform for in-memory code transformation - Add ast_grep_languages to list supported languages
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
// ast-grep CLI path (homebrew installed)
|
||||
export const SG_CLI_PATH = "sg"
|
||||
|
||||
// CLI supported languages (25 total)
|
||||
export const CLI_LANGUAGES = [
|
||||
"bash",
|
||||
"c",
|
||||
"cpp",
|
||||
"csharp",
|
||||
"css",
|
||||
"elixir",
|
||||
"go",
|
||||
"haskell",
|
||||
"html",
|
||||
"java",
|
||||
"javascript",
|
||||
"json",
|
||||
"kotlin",
|
||||
"lua",
|
||||
"nix",
|
||||
"php",
|
||||
"python",
|
||||
"ruby",
|
||||
"rust",
|
||||
"scala",
|
||||
"solidity",
|
||||
"swift",
|
||||
"typescript",
|
||||
"tsx",
|
||||
"yaml",
|
||||
] as const
|
||||
|
||||
// NAPI supported languages (5 total - native bindings)
|
||||
export const NAPI_LANGUAGES = ["html", "javascript", "tsx", "css", "typescript"] as const
|
||||
|
||||
// Language to file extensions mapping
|
||||
export const LANG_EXTENSIONS: Record<string, string[]> = {
|
||||
bash: [".bash", ".sh", ".zsh", ".bats"],
|
||||
c: [".c", ".h"],
|
||||
cpp: [".cpp", ".cc", ".cxx", ".hpp", ".hxx", ".h"],
|
||||
csharp: [".cs"],
|
||||
css: [".css"],
|
||||
elixir: [".ex", ".exs"],
|
||||
go: [".go"],
|
||||
haskell: [".hs", ".lhs"],
|
||||
html: [".html", ".htm"],
|
||||
java: [".java"],
|
||||
javascript: [".js", ".jsx", ".mjs", ".cjs"],
|
||||
json: [".json"],
|
||||
kotlin: [".kt", ".kts"],
|
||||
lua: [".lua"],
|
||||
nix: [".nix"],
|
||||
php: [".php"],
|
||||
python: [".py", ".pyi"],
|
||||
ruby: [".rb", ".rake"],
|
||||
rust: [".rs"],
|
||||
scala: [".scala", ".sc"],
|
||||
solidity: [".sol"],
|
||||
swift: [".swift"],
|
||||
typescript: [".ts", ".cts", ".mts"],
|
||||
tsx: [".tsx"],
|
||||
yaml: [".yml", ".yaml"],
|
||||
}
|
||||
Reference in New Issue
Block a user