@maverickcer/env-cap
    Preparing search index...

    Function linkFiles

    • Parses every discovered file, then resolves and links createEnv/ documentEnv calls into the merged, docs-enriched contract shape the rest of the generator (compatibility.ts, exclusive-group.ts, manifest.ts, docs.ts, env-example.ts) consumes.

      Parameters

      • discoveredFiles: readonly string[]
      • readFile: (filePath: string) => Promise<string>
      • context: ImportResolutionContext

        See ImportResolutionContext; drives how a resolved import specifier maps back to a file on disk.

      • packageOrigins: ReadonlyMap<string, PackageOrigin> = ...

      Returns Promise<LinkResult>

      Cross-file linking is deliberately narrow (see resolveImportSpecifier): a documentEnv() call's schema reference resolves either to a const in its own file, to a directly-imported named export of another file's const, or (since ADR 0014) to an allow-listed package's declared schema entry point. Anything else -- a re-export barrel, a namespace import, an unlisted bare package specifier -- becomes an unresolvedLinks entry rather than a throw or a guess, exactly like every other static-analysis boundary in this codebase.

      packageOrigins (from resolveAllowlistedPackages()) tags any discovered contract whose file matches a package-resolved path with that package's origin -- purely a lookup; discoveredFiles must already include those files (merged in by the caller via mergeLocalAndPackageFiles()).