Expand description
“Header” extraction for a Solidity source file: every byte before
the first contract / interface / library / abstract-contract
declaration. By construction this captures the leading SPDX
comment, pragma line(s), every import statement, and any blank
lines or comments interleaved with them — exactly the slice the
harness agent needs to imitate when authoring a new test file.
Implemented via tree-sitter (not string scanning) so quirks like
block comments, multi-line import { ... }, or pragma versions
split across lines don’t trip the cutoff.
Functions§
- extract_
header - Return every byte in
sourceup to (but not including) the first contract-shaped top-level declaration. Returns the whole source when none is found (e.g. an interface-only file).