[{"data":1,"prerenderedAt":422},["ShallowReactive",2],{"project-39770908":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":29,"sentiment":30,"stance_mix":31,"scored_comments":35,"aspects":36,"strip":45,"post_text":48,"what":49,"said":102,"maker_in_thread":235,"shape":246,"grid":250,"attempts":384,"same_week":385,"maker_shows":38,"maker_hidden":414,"reader_version":415,"card":416},"39770908","GritQL","A Rust CLI for rewriting source code","title","Show HN: GritQL, a Rust CLI for rewriting source code","https:\u002F\u002Fgithub.com\u002Fgetgrit\u002Fgritql","github.com","morgante",1710962591,2024,280,54,232,3515,7,"legend","dev_tools","code rewriting and migration","cli",[24,25,26,27,28],"code migration","codemod","ast rewriting","source code refactoring","tree-sitter","loved",0.344,{"positive":32,"neutral":33,"mixed":34,"critical":34},11,14,2,29,{"design":37,"idea":40,"pricing":41,"docs":42,"execution":43,"performance":44},{"positive":38,"critical":39},1,0,{"positive":34,"critical":38},{"positive":38,"critical":39},{"positive":38,"critical":39},{"positive":34,"critical":39},{"positive":39,"critical":38},[46,46,46,47,39,46,46,39,39,47,39,47,39,47,47,47,46,46,39,38,39,46,47,39,46,46,47,46,38,39,46,47,39,46,46,39,46,47,46,39],3,5,"Hi everyone!\n\nI’m excited to open source GritQL, a Rust CLI for searching and transforming source code.\n\nGritQL comes from my experiences with conducting large scale refactors and migrations.\n\nUsually, I would start exploring a codebase with grep. This is easy to start with, but most migrations end up accumulating additional requirements like ensuring the right packages are imported and excluding cases which don’t have a viable migration path.\n\nEventually, to build a complex migration, I usually ended up having to write a full codemod program with a tool like jscodeshift. This comes with its o",{"problem":50,"audience":56,"pricing":65,"motivation":75,"time_to_build":79,"stack":80,"openness":99,"stage":100,"team_size":101},{"value":51,"source":52,"evidence":53},"Large-scale code refactors and migrations are hard to express with grep or full codemod programs","maker",[54],{"id":55},"post",{"value":57,"source":58,"evidence":59},"Developers doing large refactors, migrations and shared API changes across codebases","inferred",[60,61],{"id":55},{"id":62,"by":63,"text":64},"39771635","rattray","Very happy Grit customer here. Wish I'd had this instead of jscodeshift et al back when I was doing oodles of migrations at Stripe, but glad I have it now, and very excited to…",{"value":66,"source":52,"evidence":67},"Open source CLI; paid hosted version and managed migration services offered by Grit",[68,71],{"id":69,"by":11,"text":70},"39773624","Thank you! We definitely want to give useful value to everyone. To expand more on our business model, we see GritQL as a powerful but also relatively low-level tool. It can speed…",{"id":72,"by":73,"text":74},"39773587","primitivesuave","This is a great example of an open-core business model that I hope others will follow. Make something useful for everyone, and sell additional features in a hosted version…",{"value":76,"source":52,"evidence":77},"Maker's experience with large-scale refactors and migrations where grep and jscodeshift fell short",[78],{"id":55},null,[81,88],{"value":82,"source":52,"evidence":83},"Rust",[84,85],{"id":55},{"id":86,"by":11,"text":87},"39772240","The C is all generated parsers, all our actual coding is done in Rust.",{"value":89,"source":90,"evidence":91},"Tree-sitter","commenter",[92,96],{"id":93,"by":94,"text":95},"39772612","herrington_d","Congrats from ast-grep team! Nice job Morgante! GritQL shares a lot of common ground with ast-grep, which is also a code rewriter based on tree-sitter. Interested folks may…",{"id":97,"by":11,"text":98},"39775205","Yes, Grit does support embedded languages. Right now we support Vue syntax:…","open_source","launched","company",{"praise":103,"objections":129,"requests":156,"questions":182,"alternatives":206},[104,115,121],{"value":105,"source":90,"evidence":106},"Saves time on complex migrations, e.g. OpenAI SDK 1.0 and mobx to hooks",[107,111],{"id":108,"by":109,"text":110},"39771223","psalv","++ congratulations to the team! We've tackled some pretty gnarly migrations with GritQL and it has saved us a lot of time. We have used ts-morph in the past for similar types of…",{"id":112,"by":113,"text":114},"39771473","jxnlco","this definitly helped a tonne to migrate from openai \u003C1.0 to 1.0",{"value":116,"source":52,"evidence":117},"Good design for composing simple patterns into complex migrations",[118],{"id":119,"by":11,"text":120},"39772177","ast-grep is great too, we've learned a lot from it. If you like yaml, you should definitely try ast-grep. The main area GritQL shines is in taking simpler transformation patterns…",{"value":122,"source":90,"evidence":123},"Maker team is responsive and helpful",[124,128],{"id":125,"by":126,"text":127},"39771043","mlejva","Congrats to the launch! Managing tech debt is and will be an important issue in the world of AI software. I'm glad there's a company solving this. Additionally, this is something…",{"id":62,"by":63,"text":64},[130,141,148],{"value":131,"source":90,"evidence":132},"Lacks semantic type information, so type-dependent rewrites are hard",[133,137],{"id":134,"by":135,"text":136},"39773440","jcranmer","Sounds like a cool tool. The ability to write rewrites as regular code fragments with metavariables feels like some ideas I've had in the past. However, it seems to me that your…",{"id":138,"by":139,"text":140},"39788843","setr","Are either of these exposed conveniently to build on? One scenario I dealt with recently was replacing a pattern that required rudimentary type resolution to apply properly.…",{"value":142,"source":90,"evidence":143},"Documentation is hard to understand without complex examples",[144],{"id":145,"by":146,"text":147},"39775526","ryanjshaw","Consider linking this and other complex examples in your readme, with before\u002Fafter blocks to demonstrate the power of your software. I've spent the last 6 months building a…",{"value":149,"source":90,"evidence":150},"Written in a repo where C is 96.5 percent of the code by GitHub stats",[151,155],{"id":152,"by":153,"text":154},"39772204","practicalrs","\"a Rust CLI\" - \"C 96.5% Rust 1.4%\" Not that I'm complaining ;) Is it a new way to market a C tool?",{"id":86,"by":11,"text":87},[157,165,174],{"value":158,"source":90,"evidence":159},"Support for HTML and other embedded languages",[160,164],{"id":161,"by":162,"text":163},"39775184","snthpy","This looks great! Thank you for building it. I'm looking forward to learning to use it. I'm just starting to learn about tree-sitter but my understanding is that it can also…",{"id":97,"by":11,"text":98},{"value":166,"source":90,"evidence":167},"Dynamic loading of custom tree-sitter grammars",[168,171],{"id":169,"by":162,"text":170},"39775215","I have the same question. I'm particularly interested in the SQL dialects case. Does the rewrite code also have to be syntactically correct or is that a simple text replacement…",{"id":172,"by":11,"text":173},"39775248","> Does the rewrite code also have to be syntactically correct or is that a simple text replacement because that's what I see as the main impediment; if I'm using the sqlite…",{"value":175,"source":90,"evidence":176},"Semantic analysis and type information",[177,181],{"id":178,"by":179,"text":180},"39772233","mdaniel","apologies if this should be a discussion\u002Fissue\u002Fwhatever but: Do you envision going up against CodeQL and\u002For \u003Chttps:\u002F\u002Fwww.jetbrains.com\u002Fhelp\u002Fqodana\u002Fabout-qodana.html> by making…",{"id":134,"by":135,"text":136},[183,191,201],{"value":184,"source":90,"evidence":185},"How does it compare to ast-grep",[186,187],{"id":93,"by":94,"text":95},{"id":188,"by":189,"text":190},"39772073","anotherpaulg","This looks great, thanks for building and sharing it. Interested folks may also want to check out ast-grep: https:\u002F\u002Fgithub.com\u002Fast-grep\u002Fast-grep",{"value":192,"source":90,"evidence":193},"Can it translate between programming languages",[194,198],{"id":195,"by":196,"text":197},"39773378","MichaelMug","Can I use this to translate one language to another?",{"id":199,"by":11,"text":200},"39773429","In theory, you could write a full transpiler in GritQL. In practice, it's not really the ideal tool for translating between languages. It does work well for cases where the…",{"value":202,"source":90,"evidence":203},"Can it handle SQL dialect conversion",[204,205],{"id":169,"by":162,"text":170},{"id":199,"by":11,"text":200},[207,212,219,223,227,231],{"value":208,"source":90,"evidence":209},"ast-grep",[210,211],{"id":93,"by":94,"text":95},{"id":188,"by":189,"text":190},{"value":213,"source":90,"evidence":214},"comby",[215],{"id":216,"by":217,"text":218},"39774945","lightandlight","The first tool like this I saw was [comby](https:\u002F\u002Fcomby.dev\u002F). I remember it being a bit annoying to use for small-to-medium refactors. Next time I'll try `grit` and see how it…",{"value":220,"source":52,"evidence":221},"jscodeshift",[222],{"id":55},{"value":224,"source":90,"evidence":225},"CodeQL",[226],{"id":178,"by":179,"text":180},{"value":228,"source":90,"evidence":229},"Qodana",[230],{"id":178,"by":179,"text":180},{"value":232,"source":90,"evidence":233},"ts-morph",[234],{"id":108,"by":109,"text":110},{"comments":236,"answered":237,"key":238},15,8,[239,240,243],{"id":69,"text":70},{"id":241,"text":242},"39772274","One of the specific design goals we had was to make sure that the query engine isn't tightly coupled to AST nodes. We started with the AST, since that's ultimately the foundation…",{"id":244,"text":245},"39772470","Makes sense, we internally use GritQL as a super linter for some codebase-specific patterns. It's pretty easy to set up: https:\u002F\u002Fdocs.grit.io\u002Fguides\u002Fci We've looked at both LSIF…",{"commenters":247,"max_depth":47,"maker_replies":236,"first_comment_mins":248,"lifespan_hours":249},30,10,149,[251,253,256,259,261,263,265,266,267,269,271,273,274,276,278,280,283,286,289,290,292,296,298,300,301,303,306,309,313,315,316,317,321,324,328,331,333,336,340,343,346,350,354,358,362,364,365,368,371,372,374,377,379,381],[93,39,46,252,94,39],"project\u002Fneutral\u002Fdesign",[254,39,46,255,162,39],"39775116","project\u002Fneutral\u002Fnone",[257,39,39,258,94,39],"39775593","other\u002Fneutral\u002Fdocs",[138,39,46,260,139,39],"project\u002Fneutral\u002Fidea",[72,38,47,262,73,39],"project\u002Fpositive\u002Fpricing",[69,38,39,264,11,38],"maker\u002Fneutral\u002Fpricing",[178,34,46,260,179,39],[241,34,39,252,11,38],[268,34,46,260,179,39],"39772430",[244,34,39,270,11,38],"project\u002Fpositive\u002Fidea",[188,46,39,272,189,39],"other\u002Fneutral\u002Fnone",[119,46,39,270,11,38],[145,46,47,275,146,39],"maker\u002Fpositive\u002Fdocs",[277,46,39,275,11,38],"39780797",[279,46,39,272,94,39],"39772510",[62,281,47,282,63,39],4,"project\u002Fpositive\u002Fexecution",[284,281,39,285,11,38],"39771763","maker\u002Fpositive\u002Fexecution",[287,281,47,288,63,39],"39774275","maker\u002Fpositive\u002Fnone",[108,47,47,282,109,39],[291,47,39,288,11,38],"39771262",[293,294,47,270,295,39],"39773775",6,"bilekas",[134,18,46,297,135,39],"project\u002Fmixed\u002Fidea",[299,18,39,260,11,38],"39773568",[152,237,46,255,153,39],[86,237,39,302,11,38],"project\u002Fneutral\u002Fexecution",[304,237,38,305,179,39],"39772581","project\u002Fcritical\u002Fperformance",[307,237,39,272,308,39],"39777141","sesm",[310,237,39,311,312,39],"39777343","commenter\u002Fneutral\u002Fnone","couchand",[161,314,46,255,162,39],9,[97,314,39,302,11,38],[125,248,47,270,126,39],[318,32,39,319,320,39],"39776801","other\u002Fneutral\u002Fidea","imvetri",[216,322,46,323,217,39],12,"project\u002Fmixed\u002Fexecution",[325,326,46,255,327,39],"39776431",13,"codesnik",[329,326,39,272,330,39],"39776623","ThouYS",[112,33,47,332,113,39],"project\u002Fpositive\u002Fnone",[334,236,46,260,335,39],"39775496","CJefferson",[337,236,38,338,339,39],"39775734","project\u002Fcritical\u002Fidea","worldsayshi",[341,236,39,272,342,39],"39834300","tempaccount420",[344,236,39,345,11,38],"39778986","maker\u002Fpositive\u002Fidea",[347,348,46,260,349,39],"39771619",16,"ranman",[351,352,47,332,353,39],"39774499",17,"jkrubin",[355,356,47,332,357,39],"39778783",18,"jackbridger",[359,360,39,272,361,39],"39788726",19,"joshxyz",[195,363,46,260,196,39],20,[199,363,39,297,11,38],[366,363,46,260,367,39],"39775127","ayewo",[369,363,39,370,11,38],"39775193","maker\u002Fneutral\u002Fidea",[169,363,46,260,162,39],[172,363,39,373,11,38],"maker\u002Fneutral\u002Fdesign",[375,363,47,376,162,39],"39775342","project\u002Fpositive\u002Fdesign",[378,363,46,260,162,39],"39775299",[380,363,39,370,11,38],"39775350",[382,363,39,383,162,39],"39775392","commenter\u002Fpositive\u002Fnone",[],[386,391,395,400,405,410],{"id":387,"name":388,"points":389,"category":390},"39706004","Skyvern",422,"ai",{"id":392,"name":393,"points":394,"category":20},"39759325","jnv",373,{"id":396,"name":397,"points":398,"category":399},"39756325","Godspeed",328,"productivity",{"id":401,"name":402,"points":403,"category":404},"39714053","algebraic-nnhw",310,"hardware",{"id":406,"name":407,"points":408,"category":409},"39755858","Causal 2.0",261,"web_saas",{"id":411,"name":412,"points":413,"category":390},"39726781","flash-attention-minimal",230,false,"v2",{"id":417,"name":5,"line":6,"ai":414,"cat":20,"year":13,"points":14,"comments":15,"rec":29,"s":418,"top":18,"kw":419,"maker":11,"domain":10,"tier":19,"attempts":39,"strip":420,"url":9,"mix":421,"praise":105,"objection":131,"sub":21},39770908,0.34,[24,25,26,27,28],"3335033005050555330103503353103503303530",[32,33,34,34],1794036651547]