Part of [DEVEX-556](https://linear.app/codercom/issue/DEVEX-556).
## Summary
Replaces the Template Builder's regex-based extraction of information
from base-template Terraform with an `hclsyntax` parse of the rendered
output, and removes the single-`coder_agent` assumption from the compose
core.
## What changed
- `render.go`: parse rendered Terraform via `hclsyntax.ParseConfig`
instead of regex.
- Added `ExtractedAgent{Name, Reference}` and
`ExtractAgentResourceNames`, which enumerates every `coder_agent` in
declaration order and reads `count`/`for_each` from each block body.
This is robust to nested blocks (`env {}`, `metadata {}`), fixing a case
the old `[^}]*` regex missed.
- Kept singular `ExtractAgentResourceName` as a compatibility wrapper
that still errors unless exactly one agent exists.
- `ExtractModuleNames` now walks parsed `module` blocks rather than
line-anchored regex.
- `compose.go`: `Compose` wires modules to the base's first/default
agent instead of erroring when a base declares multiple agents.
Single-agent output is byte-identical.
- `render_test.go`: added `TestExtractAgentResourceNames`
(multiple-in-order, `count` after a nested block, no agents).
## Scope
Parsing/compose layer only. Per-module agent **selection** (SDK/UI) is
intentionally out of scope and left as follow-up.
## Testing
- `go test ./coderd/templatebuilder/` passes (golden snapshots
unchanged).
- `golangci-lint run ./coderd/templatebuilder/` reports 0 issues.
- `go build ./coderd/...` succeeds. No new dependencies
(`hashicorp/hcl/v2` already vendored).
<details>
<summary>Design context</summary>
- The `.tf.tmpl` files are Go templates and only become valid HCL after
rendering, so parsing happens on rendered output (which the extractors
already operated on).
- `base.json` stays authoritative; no manifest fields are inferred or
removed here. A survey found `os` is mostly inferable from
`coder_agent.os` (except `scratch`, which uses a dynamic
`data.coder_provisioner.me.os`), and that `variables` cannot be safely
inferred because base variables are Go-template inputs, not Terraform
`variable` blocks. These were left out to keep the change minimal.
- Multiple agents are supported by wiring modules to the first agent in
document order; single-agent bases are unaffected because first == only.
</details>
---
🤖 Generated with Coder Agents on behalf of @jeremyruppel.
---------
Co-authored-by: Coder Agents <agents@coder.com>