Skip to main content

Module header

Module header 

Source
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 source up 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).