{"id":14155601,"url":"https://github.com/langston-barrett/mogglo","last_synced_at":"2025-06-19T09:34:54.694Z","repository":{"id":148373537,"uuid":"619226824","full_name":"langston-barrett/mogglo","owner":"langston-barrett","description":"Multi-language AST-based code search and rewriting tool that supports embedding Lua code in patterns","archived":false,"fork":false,"pushed_at":"2024-07-08T01:54:35.000Z","size":1312,"stargazers_count":30,"open_issues_count":14,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-24T00:47:39.787Z","etag":null,"topics":["ast","code-search","codemod","lua","refactoring","semantic-search","tree-sitter"],"latest_commit_sha":null,"homepage":"https://langston-barrett.github.io/mogglo/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/langston-barrett.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-26T16:31:14.000Z","updated_at":"2025-02-01T18:59:59.000Z","dependencies_parsed_at":"2023-09-25T05:58:42.620Z","dependency_job_id":"bf07ca9d-af85-48f9-8ab7-76b38cf76cb9","html_url":"https://github.com/langston-barrett/mogglo","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/langston-barrett/mogglo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langston-barrett%2Fmogglo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langston-barrett%2Fmogglo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langston-barrett%2Fmogglo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langston-barrett%2Fmogglo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/langston-barrett","download_url":"https://codeload.github.com/langston-barrett/mogglo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langston-barrett%2Fmogglo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260169375,"owners_count":22969158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ast","code-search","codemod","lua","refactoring","semantic-search","tree-sitter"],"created_at":"2024-08-17T08:04:18.150Z","updated_at":"2025-06-19T09:34:49.682Z","avatar_url":"https://github.com/langston-barrett.png","language":"Rust","funding_links":[],"categories":["lua"],"sub_categories":[],"readme":"# Mogglo\n\nMogglo is a multi-language AST-based code search and rewriting tool. Mogglo\nsupports embedding [Lua][lua] code in search patterns and replacements.\n\nMogglo focuses on the following goals:\n\n- *Minimal setup*: Mogglo will work right away on any codebase in a\n  supported language.\n- *Many languages*: 12 and counting!\n- *High-quality grammars*: Mogglo is based on [tree-sitter][tree-sitter]\n  grammars.\n- *Lua*: Mogglo exposes a rich API to embedded Lua snippets.\n\n[lua]: https://www.lua.org/\n[tree-sitter]: https://tree-sitter.github.io/tree-sitter/\n\n## Introduction\n\nThe following examples give a taste of Mogglo. Here's how to find pointless\nassignments of an expression to itself:\n```sh\nmogglo-rust --detail 'let $x = $x;' ./**/*.rs\n```\n\nLua code is wrapped in braces. Lua can recursively match patterns with `rec`.\nHere's a pattern to detect out-of-bounds array accesses:\n```sh\nmogglo-rust 'while $i \u003c= $buf.len() { ${{ rec(\"$buf.get($i)\") }} }' ./**/*.rs\n```\n\nHere's how to [unroll][unroll] a simple loop:\n```sh\nmogglo-rust \\\n  'for $i in 0..$h { $b; }' \\\n  --where 'h_num = tonumber(h); return h_num ~= nil and h_num % 4 == 0' \\\n  --replace 'for $i in 0..${{ string.format(\"%.0f\", h / 4) }} { $b; $b; $b; $b; }' \\\n  ./*/**.rs\n```\nThis transformation demonstrates the power of using Lua: it can't be done with\nregular expression substitutions and would be very difficult with other codemod\ntools.\n\nSee [the documentation][doc] for more details!\n\n[doc]: https://langston-barrett.github.io/mogglo/\n[cargo]: https://doc.rust-lang.org/cargo/\n[crates-io]: https://crates.io/\n[releases]: https://github.com/langston-barrett/mogglo/releases\n[rustup]: https://rustup.rs/\n[unroll]: https://en.wikipedia.org/wiki/Loop_unrolling\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flangston-barrett%2Fmogglo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flangston-barrett%2Fmogglo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flangston-barrett%2Fmogglo/lists"}