Documentation
¶
Overview ¶
Package germ contains the core logic for the germ tool
Package germ contains the core logic for the germ tool
Index ¶
- Constants
- func DisableGlobIgnore() func(*RepoMap)
- func FindGitRoot(start string) (string, error)
- func Verbose(value bool) func(*RepoMap)
- func WithContentPrefix(value string) func(*RepoMap)
- func WithGlobIgnoreFilePath(value string) func(*RepoMap)
- func WithLastLineContext(value bool) func(*RepoMap)
- func WithLineNumber(value bool) func(*RepoMap)
- func WithLinesOfInterestMarked(value bool) func(*RepoMap)
- func WithLinesOfInterestPadding(value int) func(*RepoMap)
- func WithLogLevel(value int) func(*RepoMap)
- func WithMapMulNoFiles(value int) func(*RepoMap)
- func WithMaxContextWindow(value int) func(*RepoMap)
- func WithMaxTokens(value int) func(*RepoMap)
- func WithParentContext(value bool) func(*RepoMap)
- type DefRank
- type EdgeRank
- type ModelStub
- type RepoMap
- func (r *RepoMap) Generate(chatFiles, otherFiles []string, ...) string
- func (r *RepoMap) GetFileTags(fname, relFname string, filter TagFilter) ([]Tag, error)
- func (r *RepoMap) GetRankedTagsMap(chatFnames, otherFnames []string, maxMapTokens int, ...) string
- func (r *RepoMap) GetRelFname(fname string) string
- func (r *RepoMap) GetRepoFiles(path string) ([]string, string)
- func (r *RepoMap) GetTagsRaw(fname, relFname string, filter TagFilter) ([]Tag, error)
- func (r *RepoMap) LoadQuery(lang *sitter.Language, langID string) (*sitter.Query, error)
- func (r *RepoMap) TokenCount(text string) float64
- type Tag
- type TagFilter
Constants ¶
const ( // TagKindDef is the kind of tag that represents a definition TagKindDef = "def" // TagKindRef is the kind of tag that represents a reference TagKindRef = "ref" )
Variables ¶
This section is empty.
Functions ¶
func DisableGlobIgnore ¶ added in v0.3.0
func DisableGlobIgnore() func(*RepoMap)
DisableGlobIgnore disables the global ignore file
func FindGitRoot ¶ added in v0.3.0
FindGitRoot walks upward from the given path until it finds a directory containing a ".git" folder.
func WithContentPrefix ¶ added in v0.3.0
WithContentPrefix sets the repository content prefix.
func WithGlobIgnoreFilePath ¶ added in v0.3.0
WithGlobIgnoreFilePath sets the glob ignore file path. Ignored if DisableGlobIgnore is set
func WithLastLineContext ¶ added in v0.3.0
WithLastLineContext enables or disables the inclusion of the context delimited by the last line in the output.
func WithLineNumber ¶ added in v0.3.0
WithLineNumber enables or disables line numbers in the output.
func WithLinesOfInterestMarked ¶ added in v0.3.0
WithLinesOfInterestMarked enables or disables the marking of lines of interest in the output.
func WithLinesOfInterestPadding ¶ added in v0.3.0
WithLinesOfInterestPadding sets the number of lines of padding around lines of interest.
func WithLogLevel ¶ added in v0.3.0
WithLogLevel sets the log level for the RepoMap
func WithMapMulNoFiles ¶ added in v0.3.0
WithMapMulNoFiles sets the number of files to multiply the map by.
func WithMaxContextWindow ¶ added in v0.3.0
WithMaxContextWindow set the maximum context window.
func WithMaxTokens ¶ added in v0.3.0
WithMaxTokens sets the map's maximum number of tokens.
func WithParentContext ¶ added in v0.3.0
WithParentContext enables or disables the inclusion of parent context in the output.
Types ¶
type DefRank ¶
type DefRank struct {
// contains filtered or unexported fields
}
DefRank is a struct to hold the rank for a definition
type EdgeRank ¶
type EdgeRank struct {
// contains filtered or unexported fields
}
EdgeRank is a struct to hold the edge data for distributing rank
type ModelStub ¶
type ModelStub struct{}
ModelStub simulates the main_model used in Python code (for token_count, etc.).
func (*ModelStub) TokenCount ¶
TokenCount is a naive token estimator. Real code might call tiktoken or other logic.
type RepoMap ¶
type RepoMap struct {
// contains filtered or unexported fields
}
RepoMap is the Go equivalent of the Python class `RepoMap`.
func NewRepoMap ¶
NewRepoMap is the repo map constructor.
func (*RepoMap) Generate ¶ added in v0.3.0
func (r *RepoMap) Generate( chatFiles, otherFiles []string, mentionedFnames, mentionedIdents map[string]bool, ) string
Generate is the top-level function (mirroring the Python method) that produces the “repo content”.
func (*RepoMap) GetFileTags ¶
GetFileTags calls GetTagsRaw and filters out short names and common words.
func (*RepoMap) GetRankedTagsMap ¶
func (r *RepoMap) GetRankedTagsMap( chatFnames, otherFnames []string, maxMapTokens int, mentionedFnames, mentionedIdents map[string]bool, ) string
GetRankedTagsMap orchestrates calls to getRankedTags and toTree to produce the final “map” string.
func (*RepoMap) GetRelFname ¶
GetRelFname returns fname relative to r.Root. If that fails, returns fname as-is.
func (*RepoMap) GetRepoFiles ¶ added in v0.3.0
GetRepoFiles gathers all files in a directory (or a single file) and returns two values: the slice of file paths and a tree-like string representing the folder structure.
func (*RepoMap) GetTagsRaw ¶
GetTagsRaw parses the file with Tree-sitter and extracts "function definitions"
func (*RepoMap) TokenCount ¶
TokenCount tries to mimic how the Python code estimates tokens (split into short vs. large).
type Tag ¶
Tag represents a “tag” extracted from a source file.
func GetTagsFromQueryCapture ¶
func GetTagsFromQueryCapture(relFname, fname string, q *sitter.Query, tree *sitter.Tree, sourceCode []byte, filter TagFilter) []Tag
GetTagsFromQueryCapture extracts tags from the result of a Tree-sitter query on a given file. It iterates through the captures returned by the Tree-sitter query cursor and collects definitions (def) and references (ref). All other captures are ignored. filter is a function that accepts the name of a capture and returns bool false if it should be skipped.