Skip to content

YAML language support#283

Open
selfagency wants to merge 4 commits into
alexpovel:mainfrom
selfagency:feature/yaml-language-support
Open

YAML language support#283
selfagency wants to merge 4 commits into
alexpovel:mainfrom
selfagency:feature/yaml-language-support

Conversation

@selfagency

@selfagency selfagency commented May 10, 2026

Copy link
Copy Markdown

Summary

Adds comprehensive YAML language support to srgn, enabling syntax-aware manipulation of .yaml and .yml configuration files.

Changes

  • Package: Added tree-sitter-yaml v0.7.2 (1,813,985 downloads, official tree-sitter grammar)
  • 8 Working PreparedQuery variants:
    • Scalar values: string-scalar, integer-scalar, float-scalar, boolean-scalar
    • Structure: block-sequence, block-mapping, flow-sequence, flow-mapping
  • CLI Integration: --yaml, --yaml-query, --yaml-query-file
  • Test Coverage: 8 snapshot-based tests for all prepared queries
  • All tests passing: 501 unit + 195 module + 59 CLI + 2 regression

Why This Matters

YAML is the most popular configuration format across:

  • DevOps & CI/CD pipelines (GitHub Actions, GitLab CI, CircleCI)
  • Kubernetes configs and Helm charts
  • Application configuration files
  • Data serialization and API specs

This enables srgn to work effectively with the most widely-used configuration format in the ecosystem.

Example Usage

# Extract string values from YAML config
cat config.yaml | srgn --yaml string-scalar -- your-replacement

# Find all integer values
cat config.yaml | srgn --yaml integer-scalar -- resize

# Target block mappings
cat config.yaml | srgn --yaml block-mapping update-all

# Interactive replacement with scope awareness
cat config.yaml | srgn --yaml boolean-scalar toggle-features

Implementation Quality

  • 100% coverage - All 8 defined variants work correctly
  • Compatible - Native tree-sitter 0.25.10 compatibility (no version conflicts)
  • Production ready - Fully tested and integrated

selfagency and others added 2 commits May 9, 2026 23:10
- Add tree-sitter-yaml v0.7.2 dependency
- Implement 8 working YAML PreparedQuery variants:
  * string-scalar, integer-scalar, float-scalar, boolean-scalar
  * block-sequence, block-mapping, flow-sequence, flow-mapping
- Add YAML CLI integration with --yaml, --yaml-query, --yaml-query-file
- Add 8 comprehensive YAML tests with snapshot validation
- All tests passing (501 unit + 195 module + 59 CLI + 2 regression)
Agent-Logs-Url: https://github.com/selfagency/srgn/sessions/4fe563b4-4394-4e3f-8bc1-6f874505c938

Co-authored-by: selfagency <2541728+selfagency@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 10, 2026 04:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds YAML language scoping to srgn using tree-sitter-yaml, wiring it into the CLI and test suite so YAML files (.yaml / .yml) can be scoped via prepared queries or custom tree-sitter queries.

Changes:

  • Add a new YAML language scoper (src/scoping/langs/yaml.rs) with 8 prepared query variants.
  • Integrate YAML scoping into the CLI (--yaml, --yaml-query, --yaml-query-file) and documentation output.
  • Add YAML fixture + snapshot tests covering the prepared queries.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Cargo.toml Adds the tree-sitter-yaml dependency.
Cargo.lock Locks tree-sitter-yaml and updates dependency graph.
src/scoping/langs.rs Exposes the new yaml language module.
src/scoping/langs/yaml.rs Implements YAML CompiledQuery + prepared query variants and file detection (yaml/yml).
src/main.rs Adds CLI flags and scope-group wiring for YAML queries.
README.md Documents the new YAML CLI options and prepared query values.
tests/langs/mod.rs Adds YAML prepared-query snapshots and a custom-query language-selection test case.
tests/langs/yaml/base.yaml Adds a YAML fixture used by the snapshot tests.
tests/langs/snapshots/r#mod__langs__base.yaml_string_scalar.snap Snapshot for --yaml string-scalar.
tests/langs/snapshots/r#mod__langs__base.yaml_integer_scalar.snap Snapshot for --yaml integer-scalar.
tests/langs/snapshots/r#mod__langs__base.yaml_float_scalar.snap Snapshot for --yaml float-scalar.
tests/langs/snapshots/r#mod__langs__base.yaml_boolean_scalar.snap Snapshot for --yaml boolean-scalar.
tests/langs/snapshots/r#mod__langs__base.yaml_block_sequence.snap Snapshot for --yaml block-sequence.
tests/langs/snapshots/r#mod__langs__base.yaml_block_mapping.snap Snapshot for --yaml block-mapping.
tests/langs/snapshots/r#mod__langs__base.yaml_flow_sequence.snap Snapshot for --yaml flow-sequence.
tests/langs/snapshots/r#mod__langs__base.yaml_flow_mapping.snap Snapshot for --yaml flow-mapping.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/scoping/langs/yaml.rs Outdated
selfagency and others added 2 commits May 10, 2026 21:24
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants