Replies: 1 comment
|
Hey, thanks for the incredibly thorough scoping — this is exactly the kind of contribution we love to see. You've clearly studied the architecture and the mapping makes a lot of sense. Let me answer your three questions: 1. Two PRs — yes, absolutelyThe split is the right call. The tree-sitter 0.21 → 0.25 bump touches all 11 existing languages and has regression potential, so keeping it isolated from the HCL feature makes review and debugging much cleaner. 2. Tree-sitter bump — welcomeWe've been aware that we're falling behind the ecosystem. Several grammars already have newer 3. Semantic mapping — looks rightBlocks →
Next stepsGo ahead with PR 1 (tree-sitter bump) whenever you're ready. We'll review and merge, then you can stack PR 2 (HCL) on top. Looking forward to it! |
Uh oh!
There was an error while loading. Please reload this page.
Summary
I'd like to contribute HCL (HashiCorp Configuration Language) support to AiDex, covering
.tf,.tfvars, and.hclfiles. This would make AiDex useful for Terraform/OpenTofu codebases — a common use case for AI-assisted infrastructure work.What I've scoped out
The language plugin architecture makes this straightforward. The changes would be:
src/parser/languages/hcl.ts— keyword filter + tree-sitter node type sets (~90 lines)languages/index.ts,tree-sitter.ts— register the new language (~30 lines)The npm package
@tree-sitter-grammars/tree-sitter-hcl(v1.2.0) has 100% parse success on 1,892 real-world HCL files from HashiCorp, CoreOS, and Oracle repos.Design question: Semantic mapping
HCL is structurally different from the 11 languages currently supported. It has no classes, functions, or interfaces — everything is blocks and attributes:
My proposed mapping to AiDex's extraction model:
block(resource, module, variable, output, data, locals, provider)'type')resource "aws_instance" "web"function_call(built-in functions)lookup(...),merge(...)attributeami = "..."identifier/variable_expraws_instance,web,var.sizesThis means
aidex_query({ term: "aws_instance" })would find the resource, andaidex_signaturewould show blocks and their attributes — which seems like the most useful behavior for IaC files.Open to other ideas here — especially if there's a preferred way to handle languages without traditional methods/types.
Blocker: tree-sitter version mismatch
@tree-sitter-grammars/tree-sitter-hclrequirestree-sitter ^0.25.0. AiDex currently pinstree-sitter ^0.21.0.This isn't unique to HCL — several existing grammar packages have also moved forward:
peerDependenciesSo the ecosystem is pulling ahead of AiDex's pinned version regardless of HCL.
Proposed approach: 2 PRs
PR 1 — Bump tree-sitter to 0.25 + update all grammar packages
tree-sitterand all 10 grammar dependencies to their latest compatible versionsPR 2 — Add HCL/Terraform support (on top of PR 1)
Alternatively, if a tree-sitter bump is not desired right now, I could investigate building the HCL grammar against 0.21 from source — but that seems like fighting the tide.
Questions for maintainers
Happy to start with either PR once we're aligned.
All reactions