mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-16 23:43:12 +00:00
Bare-name @import("pkg") calls in Zig refer to dependencies declared in
build.zig.zon. Previously these returned null and fell through to the
generic suffix matcher, which could only resolve them by accident.
This adds:
- A `loadZigBuildZon` config loader that parses build.zig.zon at the
repo root and extracts `.path = "..."` dependency mappings into a
per-run ZigBuildZonConfig.
- A regex-based parser (`parseZigBuildZon`) over the .zon source — a
small anonymous-struct literal — rather than pulling in tree-sitter
for one file. Limitations are documented inline; the parser handles
the two common shapes (`.path` and `.url + .hash`) and bails to null
on anything weirder.
- Resolver wiring in `resolveZigImportInternal` that, given a parsed
ZigBuildZonConfig, tries the conventional Zig package layout
(`<dep_root>/src/<name>.zig`, then `<dep_root>/src/main.zig`).
`.url`-based deps unpack into a build cache outside the repo
(.zig-cache/p/<hash>/) and so can't be resolved against repo-local
files; those bare names continue to return null cleanly. `.path` deps
that escape the repo root (`..`) are also rejected to avoid pointing
at files outside `allFilePaths`.
Tests:
- Unit coverage for `resolveZigImportInternal` (10 cases — relative
paths, parent traversal, bare-name dep resolution with both
`<name>.zig` and `main.zig` layouts, escape-the-repo rejection).
- Unit coverage for `parseZigBuildZon` (3 cases — mixed `.path`/`.url`
block, missing deps block, deps with no `.path` entries).
- The pre-existing `csharpConfigs: []` test contexts gain a
`zigBuildZon: null` field to match the widened `ImportConfigs`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| cli | ||
| config | ||
| core | ||
| lib | ||
| mcp | ||
| server | ||
| storage | ||
| types | ||