Skip to content

Entity-level code map via sem (Rust-native, for templates + token savings) #315

@rs545837

Description

@rs545837

code2prompt's templating + source tree is a great base. A natural addition: an entity-level code map (functions, classes, methods per file) as a template variable, so prompts can include structure without dumping every full file, cutting tokens while improving navigation.

Since code2prompt is Rust, this is especially clean: sem is also Rust and exposes a sem-core crate (entity extraction across 26 languages via tree-sitter), so it can integrate as a library rather than a subprocess. There's also a CLI (sem entities <path> --json) if you'd prefer that path.

I maintain sem and would be glad to send a PR adding an optional entity-map variable. Would that fit the project?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions