<< All versions

Skill v1.0.1

Automated scan100/100
opentidehq/language-server/tree-sitter

+4 new

──Details
PublishedOctober 25, 2026 at 11:51 PM
Content Hashsha256:2e5d86a480d7dc38...
Git SHA760a2c659119
Bump Typepatch
Compare with v1.0.0
──Files
Files (1 file, 4.8 KB)
SKILL.md4.8 KBactive
SKILL.md · 86 lines · 4.8 KB

version: "1.0.1" name: tree-sitter description: Author and bind tree-sitter 0.25.10 grammars for opentide KQL and SPL. Covers grammar.js, vendored parser.c, the tree-sitter CLI pin, Language::from_raw, QueryCursor StreamingIterator, and highlights.scm first-wins. Use when editing grammars/, crates/opentide-syntax, or highlights/queries. license: EUPL-1.2 metadata: author: opentidehq


tree-sitter 0.25

The Rust crate and the CLI are both 0.25.10. CI installs tree-sitter-cli@0.25.10 (npm install --prefix /tmp/ts-cli tree-sitter-cli@0.25.10). scripts/cloud-agent-install.sh installs that same version. A parser generated by any other CLI fails scripts/check-grammars.sh.

Grammars are vendored under grammars/tree-sitter-opentide-{kql,spl}/. There is no scanner (scanner.c). crates/opentide-syntax/build.rs compiles src/parser.c with the cc crate. Do not publish these grammars as separate crates and do not depend on a crates.io grammar.

Read references/grammar-workflow.md before editing grammar.js. Read references/query-api.md before calling QueryCursor.

Generate, do not hand-edit

Generated files:

  • grammars/tree-sitter-opentide-<id>/src/parser.c
  • src/grammar.json
  • src/node-types.json
  • the headers under src/tree_sitter/

Edit grammar.js only, then run this from the repository root. tree-sitter generate has to see grammar.js, and scripts/check-grammars.sh is not on the path from inside the grammar directory:

bash
(cd grammars/tree-sitter-opentide-kql && tree-sitter generate) # or -spl
bash scripts/check-grammars.sh

check-grammars.sh copies the grammar to a temp directory, runs tree-sitter generate, and diffs parser.c. Commit the regenerated files. A hand-edited parser.c will not match the next generate and will fail CI.

Grammar shape this repo uses

grammar.js starts with /// <reference types="tree-sitter-cli/dsl" /> and module.exports = grammar({...}).

  • name is opentide_kql or opentide_spl (underscores). That becomes the C symbol tree_sitter_opentide_kql. It is not the LSP language id (kql).
  • extras are whitespace and $.comment.
  • word is $.identifier.
  • Pipelines are prec.left sequences of primary then repeat(seq("|", operator)).
  • KQL control commands (. plus a name) are a real production so the engine can emit kql_control_command_unsupported. They are not valid detections.
  • SPL unknown commands are a production (unknown_command), not a parse error, so spl_unknown_command can be diagnosed.
  • SQL is not a grammar. Do not add a select statement production "for later".

Prefer a JS DSL rule over an external scanner. Adding scanner.c means updating build.rs (compile the extra C file) and check-grammars.sh. Do not add one unless the DSL cannot express the token.

Corpus gate

Every production the engine claims is covered by a fixture under testdata/corpus/<id>/. The first line tags the production:

// prod:take_operator valid
SecurityEvent | take 1

crates/opentide-syntax/tests/corpus_gate.rs requires those prod:<rule> tags and checks named rules in grammar.json. A new named rule is either added to the required list and given a fixture, or added to the explicit skip set with a reason (structural rules such as expression and source_file are skipped today). docs/LANGUAGE.md gets a row: id, grammar rule, fixture, capture.

A fixture that only lives in a unit-test string does not satisfy the gate.

Highlight queries

highlights/queries/<id>/highlights.scm capture names are a subset of highlights/spec.toml [meta].legend. An unknown capture fails highlight generation.

Order matters. query_captures keeps the earliest pattern for a span, then drops overlaps so semantic tokens never overlap. Specific patterns go before (identifier) @variable. A keyword pattern listed after @variable loses.

; comments in .scm files are query comments, not KQL comments.

Rust binding

opentide-syntax does not use the crates.io LANGUAGE: LanguageFn constant. It calls the generated C symbol and Language::from_raw. That is the supported 0.25 constructor for a raw *const TSLanguage. The pointer must be non-null and point at the static language from tree_sitter_opentide_*. See references/query-api.md for the cast and for StreamingIterator.

Parser::set_language returns Result. Parser::parse returns Option<Tree>. Tree::root_node().has_error() is the parse-error bit. Do not unwrap a parse of user source; surface kql_parse_error / spl_parse_error.

Tests

bash
cargo test -p opentide-syntax
bash scripts/check-grammars.sh
cargo run -p opentide-lsp -- generate-highlights --check

A grammar change that shifts node kinds must update the .scm file and the engine's node.kind() matches in the same change. Kind strings are the rule names (where_operator), not display names.

← v1.0.0All versionsv1.0.2 →