Skip to content

feat: add grep link functionality to rules and implement codemod grep link generator - #1056

Open
mohebifar wants to merge 1 commit into
ast-grep:mainfrom
mohebifar:feat/codemod-grep-link
Open

feat: add grep link functionality to rules and implement codemod grep link generator#1056
mohebifar wants to merge 1 commit into
ast-grep:mainfrom
mohebifar:feat/codemod-grep-link

Conversation

@mohebifar

@mohebifar mohebifar commented Sep 2, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features
    • Added “Search in public repositories” links to catalog rule pages.
    • Links generate searches based on each rule and supported language, including rules shared through the Playground.
    • Added the new search option alongside “Try in Playground,” with responsive layout updates.

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 67ea8873-50c2-4e36-8c0d-1fd70b9eded3

📥 Commits

Reviewing files that changed from the base of the PR and between e247341 and a3c10d5.

📒 Files selected for processing (5)
  • website/.vitepress/config.ts
  • website/_data/catalog.data.ts
  • website/_data/codemod-grep.ts
  • website/_data/utils.ts
  • website/src/catalog/RuleItem.vue

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Catalog pages now generate public repository search links from catalog YAML or Playground state. VitePress inserts links into catalog Markdown, and catalog rule items render them when available.

Changes

Catalog grep links

Layer / File(s) Summary
Grep link generation and YAML utilities
website/_data/codemod-grep.ts, website/_data/utils.ts
The new utilities extract catalog YAML, decode Playground state, build grep queries, and create supported-language grep.codemod.com URLs.
Catalog metadata integration
website/_data/catalog.data.ts
RuleMeta now includes grepLink. Rule extraction computes the link from the catalog language, type, YAML, and Playground Link.
Page processing and catalog rendering
website/.vitepress/config.ts, website/src/catalog/RuleItem.vue
VitePress adds grep links to catalog Markdown. RuleItem displays the link beside the Playground action and applies responsive layout styles.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to a3c10

The PR adds optional repository-search links to catalog entries without changing existing catalog behavior or introducing a material security or availability risk; it is merge-ready after normal checks and review, with no actionable merge-blocking risk remaining.

Sequence Diagram(s)

sequenceDiagram
  participant Visitor
  participant VitePress
  participant GrepLinkBuilder
  participant RuleItem
  Visitor->>VitePress: open catalog page
  VitePress->>GrepLinkBuilder: process catalog source and path
  GrepLinkBuilder-->>VitePress: add public repository search link
  VitePress->>RuleItem: provide RuleMeta.grepLink
  RuleItem-->>Visitor: display repository search action
Loading

Suggested reviewers: herringtondarkholme

Poem

A rabbit found a pattern bright
And linked it to the grep moonlight
YAML hopped into the query stream
Playground state joined the dream
Catalog cards now point the way

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 4 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main changes: adding grep link functionality to rules and implementing the Codemod grep link generator.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 4 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

<a :href="meta.playgroundLink" class="playground link" target="_blank">
Try in Playground →
</a>
<div class="rule-links">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No, i don't like having too many links in the catalog page

markdown: {
config(md) {
md.core.ruler.before('normalize', 'catalog-codemod-grep-link', (state) => {
state.src = addCodemodGrepLinkToCatalogPage(state.src, String(state.env.path || ''))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this should be added in source code markdown, or have a component to render it, instead of hiding behind a global transformation in config.ts

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