What would be involved
Looking at the existing language extractors in src/extraction/languages/, it seems like adding HCL would need:
- Tree-sitter grammars — tree-sitter-hcl and tree-sitter-terraform are available as WASM builds from the tree-sitter-hcl
(https://github.com/Mitchell-Sandrock/tree-sitter-hcl) project
- Grammar registration in src/extraction/grammars.ts — map .hcl → hcl and .tf/.tfvars → terraform with WASM paths
- Language extractor (src/extraction/languages/hcl.ts) — HCL's primary construct is the block node, where named blocks follow the pattern:
- resource "aws_instance" "web" { ... } — block type + labels
- variable "name" { ... }
- module "name" { ... }
- data "type" "name" { ... }
The block name can be derived from concatenating the identifier and string_lit children of the block (e.g., resource.aws_instance.web).
Use cases
- Navigate Terraform modules and their dependencies
- Find all references to a specific resource across a large monorepo
- Trace variable/output chains between modules
- Search for resource types (aws_instance, azurerm_kubernetes_cluster, etc.)
Environment
- CodeGraph v0.9.2
- macOS (arm64)
What would be involved
Looking at the existing language extractors in src/extraction/languages/, it seems like adding HCL would need:
(https://github.com/Mitchell-Sandrock/tree-sitter-hcl) project
- resource "aws_instance" "web" { ... } — block type + labels
- variable "name" { ... }
- module "name" { ... }
- data "type" "name" { ... }
The block name can be derived from concatenating the identifier and string_lit children of the block (e.g., resource.aws_instance.web).
Use cases
Environment