diff --git a/AGENTS.md b/AGENTS.md index 4590e6dd..faad5584 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -168,7 +168,7 @@ docs/ # CLI Reference -Run: `cargo run -p plotnik-cli -- ` +Run: `cargo run -p plotnik -- ` | Command | Purpose | | ------- | ----------------------------- | @@ -185,10 +185,10 @@ Run: `cargo run -p plotnik-cli -- ` Show AST of query and/or source file. ```sh -cargo run -p plotnik-cli -- ast query.ptk # query AST -cargo run -p plotnik-cli -- ast app.ts # source AST (tree-sitter) -cargo run -p plotnik-cli -- ast query.ptk app.ts # both ASTs -cargo run -p plotnik-cli -- ast query.ptk app.ts --raw # CST / include anonymous nodes +cargo run -p plotnik -- ast query.ptk # query AST +cargo run -p plotnik -- ast app.ts # source AST (tree-sitter) +cargo run -p plotnik -- ast query.ptk app.ts # both ASTs +cargo run -p plotnik -- ast query.ptk app.ts --raw # CST / include anonymous nodes ``` ## check @@ -196,9 +196,9 @@ cargo run -p plotnik-cli -- ast query.ptk app.ts --raw # CST / include anonymou Validate a query (silent on success, like `cargo check`). ```sh -cargo run -p plotnik-cli -- check query.ptk -l typescript -cargo run -p plotnik-cli -- check queries.ts/ # workspace with lang inference -cargo run -p plotnik-cli -- check -q '(identifier) @id' -l javascript +cargo run -p plotnik -- check query.ptk -l typescript +cargo run -p plotnik -- check queries.ts/ # workspace with lang inference +cargo run -p plotnik -- check -q '(identifier) @id' -l javascript ``` ## dump @@ -206,9 +206,9 @@ cargo run -p plotnik-cli -- check -q '(identifier) @id' -l javascript Show compiled bytecode. ```sh -cargo run -p plotnik-cli -- dump query.ptk # unlinked -cargo run -p plotnik-cli -- dump query.ptk -l typescript # linked -cargo run -p plotnik-cli -- dump -q '(identifier) @id' +cargo run -p plotnik -- dump query.ptk # unlinked +cargo run -p plotnik -- dump query.ptk -l typescript # linked +cargo run -p plotnik -- dump -q '(identifier) @id' ``` ## infer @@ -216,9 +216,9 @@ cargo run -p plotnik-cli -- dump -q '(identifier) @id' Generate TypeScript type definitions from a query. ```sh -cargo run -p plotnik-cli -- infer query.ptk -l javascript -cargo run -p plotnik-cli -- infer queries.ts/ -o types.d.ts -cargo run -p plotnik-cli -- infer -q '(identifier) @id' -l typescript +cargo run -p plotnik -- infer query.ptk -l javascript +cargo run -p plotnik -- infer queries.ts/ -o types.d.ts +cargo run -p plotnik -- infer -q '(identifier) @id' -l typescript ``` Options: `--verbose-nodes`, `--no-node-type`, `--no-export`, `-o ` @@ -236,9 +236,9 @@ exec -q -s -l # all inline ``` ```sh -cargo run -p plotnik-cli -- exec query.ptk app.ts -cargo run -p plotnik-cli -- exec -q 'Q = (identifier) @id' app.ts -cargo run -p plotnik-cli -- exec -q 'Q = (identifier) @id' -s 'let x' -l javascript +cargo run -p plotnik -- exec query.ptk app.ts +cargo run -p plotnik -- exec -q 'Q = (identifier) @id' app.ts +cargo run -p plotnik -- exec -q 'Q = (identifier) @id' -s 'let x' -l javascript ``` Options: `--compact`, `--verbose-nodes`, `--check`, `--entry ` @@ -256,9 +256,9 @@ trace -q -s -l # all inline ``` ```sh -cargo run -p plotnik-cli -- trace query.ptk app.ts -cargo run -p plotnik-cli -- trace -q 'Q = (identifier) @id' app.ts -cargo run -p plotnik-cli -- trace query.ptk app.ts --no-result -vv +cargo run -p plotnik -- trace query.ptk app.ts +cargo run -p plotnik -- trace -q 'Q = (identifier) @id' app.ts +cargo run -p plotnik -- trace query.ptk app.ts --no-result -vv ``` Options: `-v` (verbose), `-vv` (very verbose), `--no-result`, `--fuel ` @@ -268,7 +268,7 @@ Options: `-v` (verbose), `-vv` (very verbose), `--no-result`, `--fuel ` List supported tree-sitter languages. ```sh -cargo run -p plotnik-cli -- langs +cargo run -p plotnik -- langs ``` # Coding Rules diff --git a/Cargo.lock b/Cargo.lock index 706728ea..2fe81ea6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1533,8 +1533,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] -name = "plotnik-cli" -version = "0.1.1" +name = "plotnik" +version = "0.2.0" dependencies = [ "arborium-tree-sitter", "clap", @@ -1548,7 +1548,7 @@ dependencies = [ [[package]] name = "plotnik-core" -version = "0.1.1" +version = "0.2.0" dependencies = [ "serde", "serde_json", @@ -1556,7 +1556,7 @@ dependencies = [ [[package]] name = "plotnik-langs" -version = "0.1.1" +version = "0.2.0" dependencies = [ "arborium-ada", "arborium-agda", @@ -1665,7 +1665,7 @@ dependencies = [ [[package]] name = "plotnik-lib" -version = "0.1.1" +version = "0.2.0" dependencies = [ "annotate-snippets", "arborium-tree-sitter", @@ -1686,7 +1686,7 @@ dependencies = [ [[package]] name = "plotnik-macros" -version = "0.1.1" +version = "0.2.0" dependencies = [ "arborium-ada", "arborium-agda", diff --git a/README.md b/README.md index d026ec4b..e1ea26ba 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,24 @@ Tree-sitter gives you the syntax tree. Extracting structured data from it still - [ ] LSP server - [ ] Editor extensions +## Installation + +```sh +cargo install plotnik +``` + +By default, 15 common languages are included. To add specific languages: + +```sh +cargo install plotnik --features lang-ruby,lang-elixir +``` + +Or with all 80+ languages: + +```sh +cargo install plotnik --features all-languages +``` + ## Example Extract function signatures from Rust. `Type` references itself to handle nested generics like `Option>`. @@ -81,7 +99,7 @@ fn set(key: String, val: i32) {} Plotnik infers TypeScript types from the query structure. `Type` is recursive: `args: Type[]`. ```sh -❯ plotnik infer query.ptk -l rust +❯ plotnik infer query.ptk --lang rust export type Type = | { $tag: "Simple"; $data: { name: string } } | { $tag: "Generic"; $data: { name: string; args: Type[] } }; diff --git a/crates/plotnik-cli/Cargo.toml b/crates/plotnik-cli/Cargo.toml index 6e5df60e..ec61bc98 100644 --- a/crates/plotnik-cli/Cargo.toml +++ b/crates/plotnik-cli/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "plotnik-cli" -version = "0.1.1" +name = "plotnik" +version = "0.2.0" edition = "2024" license = "Apache-2.0" description = "CLI for plotnik - typed query language for tree-sitter AST" repository = "https://github.com/plotnik-lang/plotnik" -documentation = "https://docs.rs/plotnik-cli" +documentation = "https://docs.rs/plotnik" keywords = ["tree-sitter", "query", "ast", "parser", "cli"] categories = ["command-line-utilities", "development-tools"] readme = "../../README.md" @@ -234,9 +234,9 @@ lang-zsh = ["plotnik-langs/lang-zsh"] [dependencies] clap = { version = "4.5", features = ["derive"] } -plotnik-core = { version = "0.1.0", path = "../plotnik-core" } -plotnik-langs = { version = "0.1.0", path = "../plotnik-langs", default-features = false } -plotnik-lib = { version = "0.1.0", path = "../plotnik-lib" } +plotnik-core = { version = "0.2", path = "../plotnik-core" } +plotnik-langs = { version = "0.2", path = "../plotnik-langs", default-features = false } +plotnik-lib = { version = "0.2", path = "../plotnik-lib" } arborium-tree-sitter = "2.5.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/crates/plotnik-core/Cargo.toml b/crates/plotnik-core/Cargo.toml index c1435e47..5355dbeb 100644 --- a/crates/plotnik-core/Cargo.toml +++ b/crates/plotnik-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "plotnik-core" -version = "0.1.1" +version = "0.2.0" edition = "2024" license = "Apache-2.0" description = "Core data structures for Plotnik" diff --git a/crates/plotnik-langs/Cargo.toml b/crates/plotnik-langs/Cargo.toml index 75b58287..1b58e958 100644 --- a/crates/plotnik-langs/Cargo.toml +++ b/crates/plotnik-langs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "plotnik-langs" -version = "0.1.1" +version = "0.2.0" edition = "2024" license = "Apache-2.0" description = "Tree-sitter language bindings for Plotnik query language" @@ -233,8 +233,8 @@ lang-zsh = ["dep:arborium-zsh", "plotnik-macros/lang-zsh"] [dependencies] paste = "1.0" -plotnik-core = { version = "0.1.0", path = "../plotnik-core" } -plotnik-macros = { version = "0.1.0", path = "../plotnik-macros" } +plotnik-core = { version = "0.2", path = "../plotnik-core" } +plotnik-macros = { version = "0.2", path = "../plotnik-macros" } arborium-tree-sitter = "2.5.0" arborium-ada = { version = "2.5.0", optional = true } arborium-agda = { version = "2.5.0", optional = true } diff --git a/crates/plotnik-lib/Cargo.toml b/crates/plotnik-lib/Cargo.toml index 9d2c70ff..4138c0ca 100644 --- a/crates/plotnik-lib/Cargo.toml +++ b/crates/plotnik-lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "plotnik-lib" -version = "0.1.1" +version = "0.2.0" edition = "2024" license = "Apache-2.0" description = "Typed query language for tree-sitter AST" @@ -23,8 +23,8 @@ thiserror = "2.0.17" arborium-tree-sitter = "2.5.0" crc32fast = "1.4" memmap2 = "0.9" -plotnik-core = { version = "0.1", path = "../plotnik-core" } -plotnik-langs = { version = "0.1", path = "../plotnik-langs", optional = true } +plotnik-core = { version = "0.2", path = "../plotnik-core" } +plotnik-langs = { version = "0.2", path = "../plotnik-langs", optional = true } [features] default = ["plotnik-langs"] diff --git a/crates/plotnik-macros/Cargo.toml b/crates/plotnik-macros/Cargo.toml index 061fb2ae..01eb60e5 100644 --- a/crates/plotnik-macros/Cargo.toml +++ b/crates/plotnik-macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "plotnik-macros" -version = "0.1.1" +version = "0.2.0" edition = "2024" license = "Apache-2.0" description = "Procedural macros for Plotnik" @@ -114,7 +114,7 @@ lang-zsh = ["dep:arborium-zsh"] proc-macro2 = "1" quote = "1" syn = "2" -plotnik-core = { version = "0.1.0", path = "../plotnik-core" } +plotnik-core = { version = "0.2", path = "../plotnik-core" } serde_json = "1" arborium-tree-sitter = "2.5.0" arborium-ada = { version = "2.5.0", optional = true }