{"id":48037496,"url":"https://github.com/dantleech/xstq","last_synced_at":"2026-04-04T14:00:12.479Z","repository":{"id":298080525,"uuid":"998475807","full_name":"dantleech/xstq","owner":"dantleech","description":"POC to query source code with xpath","archived":false,"fork":false,"pushed_at":"2025-06-09T10:12:49.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-09T10:19:49.538Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dantleech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2025-06-08T17:29:30.000Z","updated_at":"2025-06-09T10:12:52.000Z","dependencies_parsed_at":"2025-06-09T10:30:21.130Z","dependency_job_id":null,"html_url":"https://github.com/dantleech/xstq","commit_stats":null,"previous_names":["dantleech/xstq"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dantleech/xstq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantleech%2Fxstq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantleech%2Fxstq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantleech%2Fxstq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantleech%2Fxstq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dantleech","download_url":"https://codeload.github.com/dantleech/xstq/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantleech%2Fxstq/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31402277,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T10:20:44.708Z","status":"ssl_error","status_checked_at":"2026-04-04T10:20:06.846Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-04-04T14:00:10.581Z","updated_at":"2026-04-04T14:00:12.419Z","avatar_url":"https://github.com/dantleech.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"XSTQ\n====\n\nXPath Syntax Tree Query - query your source code with XPath expressions.\n\n\u003e **CAUTION**: Not to be used by anybody at this point. Pull requests not accepted.\n\nHow it Works\n------------\n\nXSTQ uses [TreeSitter](https://github.com/tree-sitter/tree-sitter) to parse\nyour source code and internally converts your source code to an XML document\nthat can be queried with XPath (supporting XPath 2.0 and 3.0 thanks to\n[xee](https://github.com/Paligo/xee)).\n\nWhy not AST-Grep\n----------------\n\n[AST-Grep](https://ast-grep.github.io/) is a similar tool that allows you to\nsearch your code base using the AST itself as a query language in addition to\nbeing able to more complex rules.\n\nXSTQ allows you to write more complex queries but also allows you to\n**extract results**.\n\nWhy?\n----\n\nYou can extract data from your source code, for example, list all methods that\ncontain calls to `dropDatabase`:\n\n```\nxstq eval \"src/**/*.php\" \\\n    './/scoped_call_expression[name[1]=\"Database\"][name[2]=\"dropDatabase\"]/ancestor::method_declaration/name/string()' \n```\n\nIf you are unsure what to query you can view the entire trees:\n\n```\nxstq eval \"src/**/*.php\" \".\"\n```\n\nEval\n----\n\nEval let's you execute an arbitrary XPath on a path or list of paths (globs\nare also natively supported):\n\n```\nxstq eval src/Path/ToFile.php './/method_declaration/name/string()' \n```\n\nAnalyze\n-------\n\nAnalyze allows you to specify a configuration file with rules in it:\n\n```\n[[rules]]\nname = 'orm_find_one'\nxpath = './/scoped_call_expression[./name[1]=\"Posts\"][./name[2]=\"findOne\"]/ancestor::method_declaration/name/string()'\n\n[[rules]]\nname = 'drop_database'\nxpath = '//scoped_call_expression[name[1]=\"Database\"][name[2]=\"dropDatabase\"]/ancestor::method_declaration/name/string()'\n```\n\nYou can then run an analysis and output in JSON format:\n\n```\nxstq --config rules.toml analyze \"tests/**/*Test.php\" --json \u003e out.json\n```\n\nTODO\n----\n\n- [ ] Multi-threading\n- [ ] Language selection (currently hardcoded to PHP)\n- [ ] ...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdantleech%2Fxstq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdantleech%2Fxstq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdantleech%2Fxstq/lists"}