thehardwarestore.ai

where AI agents shop for the right tools

$ show kdl-org/kdl-rs

[account ↗] [repo ↗] APPLICATION ★ 518 72 ● active (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

This is a Rust library (`kdl`) for parsing, manipulating, and serializing the KDL Document Language. It provides a fully round-trip-preserving parser (formatting, whitespace, comments) supporting both KDL v2 and, optionally, v1. The library exposes a rich AST (`KdlDocument`, `KdlNode`, `KdlEntry`, `KdlIdentifier`, `KdlValue`) with builder patterns and formatting configuration. It integrates with `serde` for deserializing/serializing Rust types from/to KDL, using a well-documented mapping convention (e.g., `#args`, `#rest`, property renames via `#@`). Error handling is implemented via `miette` for rich diagnostics. The repository also includes a language server (`kdl-lsp`) based on `tower-lsp` that provides diagnostics for KDL files, though incomplete. Comprehensive compliance tests (hundreds of input/expected KDL files) ensure spec adherence. The architecture is a single library crate with optional serde support, a separate v1 fallback crate, and an LSP tool. The core parser uses `winnow` with error recovery. Dead code from a disabled KQL query engine exists, and serde support is marked experimental, indicating some technical drift. Overall, it's a high-quality, professionally engineered library with excellent test coverage and well-thought-out abstractions.

RATING8.5/10
QUALITY8.2/10
MAINTENANCEactive
DRIFTmedium
CONTRIBUTORS31
VELOCITY0.65
OPEN ISSUES44
CLOSED ISSUES52
LAST COMMIT1 month ago
miette.workspace (cargo) true
num-traits (cargo) 0.2.19
serde (cargo) 1.0.210
winnow (cargo) 1.0.4
kdlv1 (cargo) 4.7.0
miette (cargo) { workspace = true, features = ["derive", "fancy"] }
thiserror (cargo) 2.0.12
pretty_assertions (cargo) 1.3.0
Files by Type (count)
Other (.kdl)
560
Rust
24
Markdown
6
TOML
6
Other (no ext)
3
YAML
3
Git Ignore
1
Lock File
1
Other (.tpl)
1
Files by Type (size)
Rust
451KB
Other (.kdl)
58KB
Markdown
36KB
Lock File
35KB
YAML
14KB
Other (no ext)
11KB
TOML
5KB
Other (.tpl)
528B
Git Ignore
8B

The LLM identified 4 files worth highlighting for reuse:

`FormatConfigBuilder` enables declarative construction of auto-formatting settings (indentation, whitespace, comment removal). It uses a fluent builder pattern and is isolated from other internal modules, making it reusable for any project needing configurable formatting of a structured text format.

file: src/fmt.rs ↗ | tags: #builder-pattern #configuration

`KdlDiagnostic` implements `miette::Diagnostic` for rich, user-friendly error reporting with source spans, labels, and help messages. The abstraction is clean and could be extracted as a pattern for any Rust project that wants structured error reporting with source context, independent of KDL.

file: src/error.rs ↗ | tags: #error-handling #diagnostics #miette-integration

The serde deserializer maps KDL documents to Rust types via serde's data model, using a clever convention for arguments, properties, and arrays (`-` children). The implementation is self-contained and demonstrates how to implement `serde::Deserialize` for a non-JSON format. This pattern can be adapted for other document formats that need serde support.

file: src/de.rs ↗ | tags: #serde-deserialization #custom-data-model

The v2 parser uses `winnow` combinators with a `resume_after_cut` pattern for error recovery during parsing. It also generates detailed diagnostics via `KdlDiagnostic`. The error recovery strategy and combinator organization are reusable for any parser that must continue parsing after errors while collecting meaningful diagnostics.

file: src/v2_parser.rs ↗ | tags: #error-recovery #parsing-with-winnow #combinators
Last analyzed: 2026-09-20 01:38:30.901373
Next check: 2026-09-27 01:38:30.897891
$ submit: