Show HN: GritQL, a Rust CLI for rewriting source code

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • gritql

    GritQL is a query language for searching, linting, and modifying code.

  • Yes, Grit does support embedded languages. Right now we support Vue syntax: https://github.com/getgrit/gritql/blob/4ff989e8d665cc9ffa2cb...

    We don't have support for HTML yet, but if you open an issue we're happy to explore it.

  • openai-python

    The official Python library for the OpenAI API

  • - Iterate on large codebases quickly: we use Rust for maximum performance

    GritQL has already been used on thousands of repositories for complex migrations[1] but we're excited to collaborate more with the open source community.

    [1] Ex. https://github.com/openai/openai-python/discussions/742

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • ast-grep

    ⚡A CLI tool for code structural search, lint and rewriting. Written in Rust

  • This looks great, thanks for building and sharing it.

    Interested folks may also want to check out ast-grep:

    https://github.com/ast-grep/ast-grep

  • stdlib

    The GritQL standard library provides common patterns for refactoring and upgrading code. (by getgrit)

  • ast-grep is great too, we've learned a lot from them. If you like yaml, you should definitely try ast-grep.

    The main area GritQL shines is taking simpler transformation patterns and composing them into complex migrations. For example, the OpenAI migration was built by incrementally handling the different edge cases we've seen in the wild: https://github.com/getgrit/stdlib/blob/main/.grit/patterns/p...

  • codeql

    CodeQL: the libraries and queries that power security researchers around the world, as well as code scanning in GitHub Advanced Security

  • apologies if this should be a discussion/issue/whatever but:

    Do you envision going up against CodeQL and/or <https://www.jetbrains.com/help/qodana/about-qodana.html> by making semantic information available to the ast nodes? OT1H, I can imagine it could be an overwhelming increase in project scope, but OTOH it could also truly lead to some stunning transformation patterns

    e.g. https://github.com/github/codeql/blob/v1.27.0/java/ql/exampl... or even more "textual" semantics such as

      var foo = "hello".substring(1); // knowing "foo" is a String

  • scip

    SCIP Code Intelligence Protocol

  • security is up there, but from reading the examples in CodeQL it just seemed like it would be possible to express some truly great versions of "don't do that" rules in it. I am a total JetBrains fanboi, and their introspections are world-class, but getting Qodana to run to completion before the heat death of the universe has proven to require more glucose than I have to offer it. Thus, I'm always interested in alternate implementations, even though I am acutely aware of the computational complexity of what I'm asking

    I recalled another link I wish I had included in my question from the SourceGraph folks https://github.com/sourcegraph/scip#scip-code-intelligence-p... which started out life as "Language Server Indexing Protocol" and seems to solve some similar project-wide introspection questions but TBH since their rug pull I've been a lot less willing to hitch my wagon to their train

  • topiary

  • You should check out https://github.com/tweag/topiary

    Yes, theoretically if you had ~identical grammars you could use it to do a full transpilation. There's a lot of challenges with that though. Writing a correct grammar for 1 language is complicated enough, but writing one for two where all your nodes and fields end up the same is likely insurmountable.

    In practice, languages are either:

    - Far enough apart that any pure AST transformation is insufficient and you need an AI component to produce usable output

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts