Summary
codedb currently detects .tf, .tfvars, and .hcl files as unknown, so outline, symbol, and deps return nothing for Terraform/HCL codebases. Additionally, .terraform/ provider cache directories are not in skip_dirs, causing the index to balloon with thousands of cached module files.
Problem
On a real Terraform monorepo:
- 19,487 files indexed (17,000+ from
.terraform/ caches)
- 18s snapshot time, 8.3MB snapshot
- 0 symbols extracted from
.tf files (detected as unknown)
- Search results polluted by cached provider/module files
Proposed Solution
- Add
.terraform and .terragrunt-cache to skip_dirs in watcher.zig
- Add
hcl to the Language enum with detection for .tf, .tfvars, .hcl extensions
- Implement
parseHclLine() recognising top-level HCL block types:
resource "type" "name" → struct_def with symbol type.name
data "type" "name" → struct_def with symbol data.type.name
module "name" → import
variable "name" → variable
output "name" → constant
provider "name" → import
locals / terraform / moved → keyword blocks
- Record
source = "..." inside module blocks as imports for the dep graph
- Add HCL comment support (
#, //, /* */) to isCommentOrBlank
Results after fix
On the same Terraform monorepo:
- 1,836 files indexed (down from 19,487)
- 93ms snapshot time (down from 18s)
- Full symbol extraction across all HCL block types
- Clean search results with no
.terraform/ noise
Files touched
src/watcher.zig — 2 lines (add to skip_dirs)
src/explore.zig — ~240 lines (language enum, detection, parser, helpers)
src/tests.zig — ~250 lines (11 test cases)
Total: 493 inserted lines.
Tests
All existing tests pass (zig build test exit 0). 11 new tests cover:
- Each HCL block type (resource, data, variable, output, module, provider, locals, terraform)
- Full multi-block file parsing
- Comment skipping
findSymbol integration
.tfvars language detection
isCommentOrBlank for HCL
Summary
codedb currently detects
.tf,.tfvars, and.hclfiles asunknown, sooutline,symbol, anddepsreturn nothing for Terraform/HCL codebases. Additionally,.terraform/provider cache directories are not inskip_dirs, causing the index to balloon with thousands of cached module files.Problem
On a real Terraform monorepo:
.terraform/caches).tffiles (detected asunknown)Proposed Solution
.terraformand.terragrunt-cachetoskip_dirsinwatcher.zighclto theLanguageenum with detection for.tf,.tfvars,.hclextensionsparseHclLine()recognising top-level HCL block types:resource "type" "name"→struct_defwith symboltype.namedata "type" "name"→struct_defwith symboldata.type.namemodule "name"→importvariable "name"→variableoutput "name"→constantprovider "name"→importlocals/terraform/moved→ keyword blockssource = "..."inside module blocks as imports for the dep graph#,//,/* */) toisCommentOrBlankResults after fix
On the same Terraform monorepo:
.terraform/noiseFiles touched
src/watcher.zig— 2 lines (add toskip_dirs)src/explore.zig— ~240 lines (language enum, detection, parser, helpers)src/tests.zig— ~250 lines (11 test cases)Total: 493 inserted lines.
Tests
All existing tests pass (
zig build testexit 0). 11 new tests cover:findSymbolintegration.tfvarslanguage detectionisCommentOrBlankfor HCL