repo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package repo implements BroCode's deterministic project intelligence layer: a repo map (entry points, structure, hot files) built without the LLM, and cross-session usage tracking ("the more BroCode is used, the smarter it gets"). Both persist under .brocode/ and are injected into the system prompt so every session starts warm without spending tokens on re-discovery.

  • RepoMap: tree (depth-2) + entry points, built deterministically from the filesystem, cached to .brocode/repo-map.json keyed by a content hash of the file list — rebuilt only when the project actually changes.
  • Usage: counts how often each file is read/edited per session, aggregated across sessions in .brocode/usage.json, so warm starts can prioritize the files the team actually works on (not just the ones the LLM guessed).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map struct {
	// Tree is a compact depth-2 directory listing (relative paths).
	Tree []string `json:"tree"`
	// EntryPoints are the files/commands a developer reaches for first
	// (main.go, package.json bin, cmd/, index.ts, ...).
	EntryPoints []string `json:"entry_points"`
	// HotFiles are the top-N files by usage frequency ("" when no usage yet).
	HotFiles []string `json:"hot_files"`
	// Hash is the content hash of the file list this map was built from.
	Hash string `json:"hash"`
}

Map is the deterministic project map: a depth-2 tree plus detected entry points and the most-used files (from cross-session usage).

func BuildMap

func BuildMap(workspaceDir string, usage *Usage) *Map

BuildMap walks the workspace and produces a deterministic Map, honoring the cache: when the file-list hash matches the cached map's hash it is returned as-is (no re-scan). Usage is merged in so hot files reflect the latest cross-session counts. Returns nil when the workspace is unusable.

func (*Map) String

func (m *Map) String() string

String renders the map as a compact system-prompt block ("" when nil).

type Usage

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

Usage counts how often each file was read or edited across sessions, so warm starts can prioritize what the team actually works on. Persisted to .brocode/usage.json; counts decay slowly so long-gone hotspots fade.

func NewUsage

func NewUsage(workspaceDir string) *Usage

NewUsage loads (or creates) the usage store for the workspace.

func (*Usage) Record

func (u *Usage) Record(paths []string)

Record bumps the count for each touched file. Paths are kept relative for portability; counts are capped so no single file dominates forever.

func (*Usage) Save

func (u *Usage) Save()

Save persists the counts (only when changed).

func (*Usage) Top

func (u *Usage) Top(n int) []string

Top returns the n most-used files ("" when no usage recorded).

Jump to

Keyboard shortcuts

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