{"id":18598777,"url":"https://github.com/crazypython/tree-query","last_synced_at":"2025-06-22T19:08:50.939Z","repository":{"id":148713614,"uuid":"363546716","full_name":"CrazyPython/tree-query","owner":"CrazyPython","description":"Query indented files based on their hierarchy, inspired by and implements Roam queries. High performance. Beta.","archived":false,"fork":false,"pushed_at":"2021-07-30T13:22:46.000Z","size":93,"stargazers_count":16,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-22T19:08:37.084Z","etag":null,"topics":["markdown","pkm","roamresearch"],"latest_commit_sha":null,"homepage":"","language":"D","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CrazyPython.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2021-05-02T02:03:18.000Z","updated_at":"2024-05-28T19:14:31.000Z","dependencies_parsed_at":"2023-04-06T22:45:58.681Z","dependency_job_id":null,"html_url":"https://github.com/CrazyPython/tree-query","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/CrazyPython/tree-query","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrazyPython%2Ftree-query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrazyPython%2Ftree-query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrazyPython%2Ftree-query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrazyPython%2Ftree-query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CrazyPython","download_url":"https://codeload.github.com/CrazyPython/tree-query/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrazyPython%2Ftree-query/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261348755,"owners_count":23145314,"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":["markdown","pkm","roamresearch"],"created_at":"2024-11-07T01:34:25.029Z","updated_at":"2025-06-22T19:08:45.925Z","avatar_url":"https://github.com/CrazyPython.png","language":"D","readme":"# `tree-query`\n\n\u003e This README is TODO. If you'd like to use this software in a project, **don't hestiate to reach out to me.**\n\n`tree-query` is a tool that lets you execute queries on ordinary directories of files like text and Markdown, inspired by Roam Research's query syntax.\n\nIt is a replacement for Roam's query system. It supports everything Roam does, except for block references.\n\n[Join us on Discord](https://discord.gg/7B9ywS5x)\n\n## Quickstart\n\n**Query in current directory:**\n```\ntree-query '{and: [[Page 1]] [[Page 2]]}' .\n```\n[*Learn to navigate to a working directory with `cd`*](https://linuxize.com/post/linux-cd-command/)\n\n**Query in a folder:**\n```\ntree-query '{and: [[Page 1]] [[Page 2]]}' /Users/steve/myfoldername/\n```\n*Learn to get the location of a folder on [macOS](https://osxdaily.com/2009/11/23/copy-a-files-path-to-the-terminal-by-dragging-and-dropping/), [Windows](https://www.top-password.com/blog/copy-full-path-of-a-folder-file-in-windows/), or [GNU+Linux](https://unix.stackexchange.com/questions/102551/mouse-shortcut-to-copy-the-path-to-a-file-in-the-gnome-file-manager).*\n\nOr query in multiple folders and files:\n\n```\ntree-query '{and: [[Page 1]] [[Page 2]]}' /Users/steve/myfoldername/ file1\n```\n\n**Query stdin with pipes:**\n```\ncat myfile | tree-query '{and: [[Page 1]] [[Page 2]]}'\n```\n[*Learn to build powerful no-code applications using pipes*](https://youtu.be/tc4ROCJYbm0?t=360)\n\n## Installation\n### [Download a copy](https://github.com/CrazyPython/tree-query/releases/tag/v0.1.1)\nThe more convenient method. Click above for instructions.\n\n### Build from source\n\nOn FreeBSD, GNU+Linux, and macOS, open Terminal and go:\n```\ncurl https://dlang.org/install.sh | bash -s\n```\n\nOn Windows, download and install [Git Bash](https://gitforwindows.org/) and [7-Zip to C:\\Program Files](https://www.7-zip.org/), then run:\n```\nmkdir %USERPROFILE%\\dlang\nset PATH=\"%PATH%;C:\\Program Files\\7-Zip\"\nset BASH=\"\\Program Files\\Git\\usr\\bin\\bash.exe\"\nmkdir dlang\npowershell.exe -Command \"wget https://dlang.org/install.sh -OutFile dlang\\install.sh\"\n```\n\nThen:\n```\n~/dlang/install.sh install ldc-1.23.0\n```\n\nThen `cd` into the directory where you cloned this directory (`git clone https://github.com/CrazyPython/tree-query.git \u0026\u0026 cd tree-query`) and type:\n```\n~/dlang/ldc-1.23.0/bin/ldc2 --link-defaultlib-shared=false -O2 -release tree-query.d interp.d query.d parser.d\n```\n\n(Non-Windows) Install to make available eveywhere:\n```\nchmod 700 tree-query\nsudo mv tree-query /usr/local/bin\n```\n\n## Features\n\nThis section is a work-in-progress.\n\n* **Fast**\n\n## Basic usage with the command-line\n\n### Copy result to clipboard\nmacOS:\n```\ntree-query '{and: [[Page 1]] [[Page 2]]}' . | pbcopy\n```\n\nGNU+Linux:\n```\ntree-query '{and: [[Page 1]] [[Page 2]]}' . | xclip\n```\n\n## Contributing\n\n**query.d**: The logic for executing Roam queries\n\n**parser.d**: The Markdown/org-mode parser, which detects the indentation level of each line and uses it to emit a stream of events for a handler like `query.d` to consume.\n\n**tree-query.d**: The command-line tool/wrapper. Recursively parses the string `{and: [[Page 1]] [[Page 2]]}` into a tree of expressions\n\n**interp.d**: Recursively evaluates boolean expressions on behalf of query.d\n\n`tree-query` has doc comments on internals and example code demonstrating how internal APIs work. (Ctrl-F for \"unittest\")\n\nTree-query is written in [Dlang](https://dlang.org) but don't let that put you off- if you know C, C++, or Java, you'll pick it up very quickly.\n\nIf you have any questions on D, feel free to go to #d on freenode or D Forums. People are very nice.\n\n### Internals\n\nI've spent some time writing doc comments inside the code. They provide a conceptual explanation of how the system works. Look for `/**` and `/++`.\n\nInside the unittests, there's an example guide on using `parser.d` as a library to build a Markdown to XML converter. \n\n### Notes\n\nA string in D is a reference to a region of immutable memory. It is a length and a pointer. For this reason, it is is very efficient to copy.\n\nA struct is like a Java record or class.\n\n## Known bugs\n - Mixing tabs and spaces in the same file is not supported, unless an explicit spaces per indent specified\n\n## Your rights\n\nThis is open-source software.\n\nWe use copyleft to gurantee these rights:\n\n0. Free for commercial use and any other purpose\n1. Freedom to remix to fit your needs: You (and if you can't code, by proxy a programmer you hire) have freedom to add new query keywords, completely change the query system, add support for new formats like org-mode, or anything else\n2. Freedom to help friends by sharing\n3. Freedom to share remixes, commercially and noncommercially\n\nI believe knowledge management is a deeply, and everyone should have freedom over their \"digital brain.\" A digital brain is a deeply intimate and personal thing. This means you are the sovereign of your digital brain.\n\nCompatible with permissive licenses like Apache License, MIT License, and Mozilla Public License.\n\n(C) 2021. Affero General Public License v3.0 or any later version\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrazypython%2Ftree-query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrazypython%2Ftree-query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrazypython%2Ftree-query/lists"}