Skip to content

Conversation

@JordanCoin
Copy link
Owner

@JordanCoin JordanCoin commented Dec 4, 2025

Summary

Major refactoring that replaces tree-sitter with ast-grep for the --deps feature, dramatically simplifying the build and distribution process.

Why this change?

Tree-sitter required:

  • ~27MB of grammar .so/.dylib files bundled with each release
  • CGO for building (complex cross-compilation)
  • Separate grammar build scripts for each platform
  • Grammars without tagged releases blocked homebrew-core submission

ast-grep provides:

  • Single external dependency (brew install ast-grep)
  • Pure Go build (no CGO needed)
  • 6-8x faster dependency scanning
  • Already in homebrew-core

Changes

Removed:

  • Tree-sitter grammar loading code
  • Tree-sitter query files (.scm)
  • Grammar build scripts
  • CGO requirement

Added:

  • ast-grep scanner with YAML rules
  • GoReleaser for simplified releases
  • Auto-install of ast-grep dependency (Homebrew & Scoop)

Languages supported (14)

Go, Python, JavaScript, TypeScript, Rust, Ruby, C, C++, Java, Swift, Kotlin, C#, PHP, Bash

Performance

  • Build: Pure Go cross-compilation (no Zig/CGO)
  • Scan: 6-8x faster than tree-sitter
  • Install: brew install ast-grep takes ~4 seconds

Test plan

  • go build ./... passes
  • go test ./... passes
  • codemap . works
  • codemap --deps works
  • codemap --diff works
  • codemap --skyline works
  • CI passes on all platforms
  • GoReleaser config validates

🤖 Generated with Claude Code

JordanCoin and others added 2 commits December 5, 2025 12:16
- Update all tree-sitter grammar resources to use tagged releases
- Remove Swift and Dart (no upstream tagged releases available)
- Switch Swift grammar to alex-pinkus/tree-sitter-swift (more active)
- Add query files installation to formula
- Update formula to v2.8.3
- Improve test coverage in formula
- Update README to reflect 14 supported languages
- Add note about Swift/Dart temporary unavailability

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This is a major refactoring that removes the tree-sitter dependency
in favor of ast-grep (sg), dramatically simplifying the build and
distribution process.

Changes:
- Remove tree-sitter grammar loading code (grammar.go, grammar_unix.go,
  grammar_windows.go)
- Remove tree-sitter query files (scanner/queries/*.scm)
- Remove grammar build scripts (build-grammars.sh)
- Add ast-grep scanner (scanner/astgrep.go) with YAML rules
- Add ast-grep rules for 12 languages (scanner/sg-rules/*.yml)
- Simplify release workflow using GoReleaser (.goreleaser.yml)
- Update Homebrew formula to depend on ast-grep instead of bundling
  grammars

Benefits:
- No CGO required (pure Go cross-compilation)
- No 27MB grammar files to distribute
- 6-8x faster dependency scanning
- Simpler CI/CD (release.yml: 480 → 106 lines)
- Ready for homebrew-core (ast-grep already in homebrew-core)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
JordanCoin and others added 5 commits December 5, 2025 13:56
The ast-grep scanner tests require `sg` to be installed.
- Add ast-grep installation step for Ubuntu (pip) and macOS (brew)
- Add --deps integration test

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Ensures Windows users get ast-grep auto-installed when they
run `scoop install codemap`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add ast-grep rules for C# and PHP (14 languages total)
- Update README to reflect ast-grep instead of tree-sitter
- Update supported languages table (Swift added, R/Dart removed)
- Simplify installation docs (no grammars to install)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Future feature: entry points, key types, exported function counts
for richer LLM context in --deps output.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
New ast-grep rules for 4 additional languages:
- Lua: require, dofile imports
- Scala: import declarations
- Elixir: import, alias, use, require
- Solidity: import directives (for Web3 devs)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@JordanCoin JordanCoin merged commit 5473226 into main Dec 5, 2025
12 checks passed
@JordanCoin JordanCoin deleted the homebrew-core-prep branch December 5, 2025 20:25
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