Skip to content

feat: add ast-grep SessionStart hook and setup command#58

Merged
amondnet merged 6 commits into
mainfrom
feat/ast-grep-hook
Dec 23, 2025
Merged

feat: add ast-grep SessionStart hook and setup command#58
amondnet merged 6 commits into
mainfrom
feat/ast-grep-hook

Conversation

@amondnet

Copy link
Copy Markdown
Contributor

Summary

Implement comprehensive ast-grep integration with SessionStart hook and setup command:

  • SessionStart hook (ast-grep-context.ts) that detects projects and recommends ast-grep over grep/ripgrep for code search
  • Setup command (npx @pleaseai/code setup) to install and verify required tools like ast-grep
  • @pleaseai/binaries package with shared utilities for binary download, caching, and platform detection
  • Updated packages (code, lsp, dora) to use @pleaseai/binaries for consistent tool management
  • Updated SKILL.md with Linux compatibility notes

Benefits

Developers can now:

  1. Get smart recommendations for code search tools via SessionStart hook
  2. Install required tools with a single command
  3. Benefit from centralized binary management across all packages
  4. Have consistent binary handling and caching strategies

Test plan

  • Verify commit message follows conventional format
  • ESLint hooks passed (fixed return types and process imports)
  • All new files created successfully
  • Package structure follows project conventions
  • Run full test suite to ensure no regressions
  • Test code setup command manually
  • Verify ast-grep binary installation works

Related Issues

Closes #58

Implement comprehensive ast-grep integration with:

- SessionStart hook (ast-grep-context.ts) that detects projects and recommends ast-grep over grep/ripgrep for code search
- New `npx @pleaseai/code setup` command to install and verify required tools
- @pleaseai/binaries package: shared utilities for binary download, caching, and platform detection
- Updated packages (code, lsp, dora) to use @pleaseai/binaries for consistent tool management
- Updated ast-grep SKILL.md with Linux compatibility note

This enables developers to:
1. Get smart recommendations for code search tools via SessionStart hook
2. Install required tools (ast-grep) with a single command
3. Have centralized binary management across all packages
4. Benefit from cross-package code reuse in binary handling

Closes #58
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @amondnet, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the developer experience by integrating ast-grep for advanced code search capabilities and streamlining tool management. It introduces a new SessionStart hook to intelligently recommend ast-grep and a unified setup command to easily install and verify development tools. A new @pleaseai/binaries package centralizes binary handling, improving consistency and maintainability across various project components.

Highlights

  • AST-grep Integration: Introduced a SessionStart hook to detect projects and recommend ast-grep for code search, along with a new setup command to install and verify ast-grep and other tools.
  • Centralized Binary Management: A new @pleaseai/binaries package was created to provide shared utilities for binary download, caching, and platform detection, ensuring consistent tool management across the project.
  • Tool Setup Command: Added a npx @pleaseai/code setup command to simplify the installation and verification of required development tools, including ast-grep.
  • Dependency Updates: Several existing packages (code, lsp, dora) were updated to leverage the new @pleaseai/binaries package for improved tool handling.
  • Documentation Enhancement: The SKILL.md for ast-grep was updated to include important compatibility notes for Linux users regarding the sg command alias.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Dec 22, 2025

Copy link
Copy Markdown

Deploying code-please with  Cloudflare Pages  Cloudflare Pages

Latest commit: c002a28
Status:🚫  Build failed.

View logs

@amondnet amondnet self-assigned this Dec 22, 2025

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new @pleaseai/binaries package to centralize binary download, caching, and platform detection utilities, which is then integrated into @pleaseai/code, @pleaseai/dora, and @pleaseai/lsp packages. It adds a new setup command to @pleaseai/code for checking and installing required tools like ast-grep, and includes a SessionStart hook to provide dynamic ast-grep context to Claude Code sessions. Additionally, the PR updates bun.lock to reflect new dependencies and chalk version, modifies Claude plugin settings to reduce command timeouts and enable hookify and plugin-dev, and disables LSP in .please/config.json. Review comments highlight an inconsistency in packages/binaries/package.json and tsconfig.json regarding build output, point out that the confirm function in setup.ts needs a SIGINT handler to prevent terminal issues, and recommend using a specific stable version for ast-grep downloads instead of the unstable /latest/ URL.

Comment thread packages/binaries/package.json
Comment thread packages/binaries/src/download.ts
Comment thread packages/code/src/commands/setup.ts
Comment thread packages/code/src/tools/ast-grep.ts Outdated
- Add cross-platform support for extractZip (PowerShell on Windows, unzip on Unix)
- Add SIGINT handler to confirm() to restore terminal state on Ctrl+C
- Pin ast-grep version to 0.40.3 for stability and reproducibility
@pleaseai

pleaseai Bot commented Dec 23, 2025

Copy link
Copy Markdown

@amondnet님의 요청을 완료했습니다 —— View job


- Update packages/dora and packages/lsp to use zod ^3.25.0 || ^4.0.0
- Update apps/docs to use zod ^4.0.0
- Update docs-please dependency to ^0.2.6
- Resolves excessive type depth error in TypeScript compilation
…ities

- Add comprehensive tests for cache utilities (ensure cache dir, get cached binary path, clear cache)
- Add tests for platform detection and binary validation
- Add tests for download utilities and binary extraction
- Total 37 new tests covering core functionality
Update ast-grep hook to use the correct environment variable
for plugin root path resolution.
Refactor ast-grep-context.ts to export testable functions and add
comprehensive tests covering context strings, installation detection,
output generation, and end-to-end script execution.

- Register hooks/scripts as workspace package
- Add package.json and tsconfig.json for hooks/scripts
- Export checkAstGrepInstalled, getAdditionalContext, createHookOutput
- Add 17 tests with full coverage
@amondnet
amondnet merged commit b2d2910 into main Dec 23, 2025
1 of 4 checks passed
@amondnet
amondnet deleted the feat/ast-grep-hook branch December 23, 2025 05:23
@passionfactory-bot passionfactory-bot Bot mentioned this pull request Dec 22, 2025
@passionfactory-bot passionfactory-bot Bot mentioned this pull request Jan 29, 2026
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