mapx

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EstimateTokens

func EstimateTokens(size int64) int

EstimateTokens: ~4 chars/token.

func ExtractSymbols

func ExtractSymbols(ext, content string) []string

ExtractSymbols returns symbol names found in the first maxLines of content.

Types

type File

type File struct {
	Path    string   `json:"path"`
	Size    int64    `json:"-"`
	Refs    int      `json:"refs"`
	Symbols []string `json:"symbols,omitempty"`
	Score   float64  `json:"score"`
	Tokens  int      `json:"tokens"`
}

File is one mapped file.

type Gitignore

type Gitignore struct {
	// contains filtered or unexported fields
}

Gitignore matches paths against .gitignore-style patterns. Stdlib-only: no go-gitignore dep. Implements the 90% case — glob (*, **), negation (!), leading slash anchoring, dir suffix (/). ponytail: gitignore subset, full gitignore (git::check-ignore semantics) if real-world repos expose misses.

func BaselineIgnore

func BaselineIgnore() *Gitignore

BaselineIgnore returns always-ignored paths (VCS, node_modules, caches).

func LoadGitignore

func LoadGitignore(root string) (*Gitignore, error)

func (*Gitignore) Match

func (gi *Gitignore) Match(rel string) bool

Match reports whether a repo-relative slash path (e.g. "src/app.go" or "vendor/x") is ignored. Last matching rule wins (git semantics).

type Result

type Result struct {
	Files       []File `json:"files"`
	TotalTokens int    `json:"total_tokens"`
	Truncated   int    `json:"truncated"`
}

Result is the full map.

func Build

func Build(ctx context.Context, root string, gitignore *Gitignore, full bool) (*Result, error)

Build walks root, extracts symbols, counts refs, ranks, applies name gate.

func (*Result) Budget

func (r *Result) Budget(budget int)

Budget truncates a ranked result to fit within a token budget. Files arrive pre-sorted by score (Build). Keeps top-N by score until budget exhausted, then marks the rest truncated.

func (*Result) RenderIndex

func (r *Result) RenderIndex(title string) string

RenderIndex emits a self-contained HTML page with the map embedded as JSON plus SEO/meta/robots — indexable, searchable, no server needed.

func (*Result) RenderJSON

func (r *Result) RenderJSON() (string, error)

RenderJSON marshals the result.

func (*Result) RenderTree

func (r *Result) RenderTree() string

RenderTree returns a token-budgeted tree. Files already ranked by Build.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL