Help us shape the future of Go! Take the 2026 Go Developer Survey

navigate

package
v0.10.21 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package navigate builds the map of a vault: what it holds, by folder, one line per note. An agent reads a file when it knows where the answer lives; with a knowledge base it can only know that if it can see what is there. Search answers a question already formed; the map lets the question form.

Index

Constants

View Source
const MaxLineRunes = 120

MaxLineRunes caps a note's one-line description so the map stays a map.

View Source
const MaxSummaryRunes = 256

MaxSummaryRunes caps a folder overview's summary: an L0 abstract, longer than a note's line. The 2026-10-03 probe measured whole overview lines.

View Source
const OverviewType = vault.OverviewType

OverviewType is the note type that describes the folder it sits in: its first sentence is the folder's summary in the map. Defined once, in vault.

View Source
const PathsField = "paths"

PathsField is the frontmatter field in which a note names the code it is about: globs relative to the repository root, `**` for any depth, a trailing `/` for everything under a folder, and `repo:` in front for another repo.

Variables

This section is empty.

Functions

func MarkCodeChanged added in v0.9.12

func MarkCodeChanged(notes []Note, vaultRoot string, f CodeFile)

MarkCodeChanged sets CodeChanged on each note whose file was last committed before f was. Commit times on both sides, never file times: a checkout rewrites every mtime and would make every note look current. Without history on either side — a note not yet committed, a file outside a repository — there is nothing to compare, and the note is left unmarked.

func OneLine

func OneLine(body string) string

OneLine is a note's description for the map: the first sentence of its excerpt (the Principle section when it has one, else its opening prose), on one line and capped at MaxLineRunes.

func Render

func Render(w io.Writer, root *Dir, o RenderOptions) error

Render prints the map: each folder with its note count, each note as "Title (id) — line", indented by depth.

Types

type CodeChange added in v0.9.12

type CodeChange struct {
	Commits int    `json:"commits"`
	Date    string `json:"date"`
	Latest  string `json:"latest"`
	// Summary is the sentence every surface shows — the text map and the
	// code-map hook — so they cannot word the warning differently.
	Summary string `json:"summary"`
}

CodeChange says the code a note covers was committed to after the note was. It is a prompt to check the note still holds, not a verdict: a broad glob changes for reasons that leave the note true.

type CodeFile

type CodeFile struct {
	Rel  string
	Repo string
	// Root is the repository's folder, empty outside a repository. It is where
	// the file's history is read.
	Root string
}

CodeFile is the file an agent is reading: its path relative to its repository root, and the repository's name (the root folder's name).

func ResolveCodeFile

func ResolveCodeFile(file string) CodeFile

ResolveCodeFile names a file the way `paths:` does: relative to the nearest enclosing repository root, and the repository by its origin remote (the root's folder name when it has none). Outside a repository the Rel is the file name alone and Repo is empty.

type Dir

type Dir struct {
	Path  string `json:"path"`
	Total int    `json:"total"`
	// Summary is what the folder covers: its overview note's first sentence,
	// else its most used tags. SummaryFrom says which ("overview", "tags").
	Summary     string `json:"summary,omitempty"`
	SummaryFrom string `json:"summary_from,omitempty"`
	// Overview is the folder's overview note, kept out of Notes and Total.
	Overview *Note  `json:"overview,omitempty"`
	Dirs     []*Dir `json:"dirs,omitempty"`
	Notes    []Note `json:"notes,omitempty"`
}

Dir is a folder in the map. Total counts every note beneath it.

func Build

func Build(notes []Note) *Dir

Build groups notes into folders. Folders and notes are sorted by path.

type Filter

type Filter struct {
	PathPrefix string
	Type       string
}

Filter narrows what Load returns. Empty fields do not filter.

type Note

type Note struct {
	ID     string `json:"id"`
	Path   string `json:"path"`
	Title  string `json:"title"`
	Type   string `json:"type"`
	Status string `json:"status,omitempty"`
	Line   string `json:"line,omitempty"`
	// CodeChanged is set by `tree --for` when the file was committed to after
	// the note was.
	CodeChanged *CodeChange `json:"code_changed,omitempty"`
	// Tags and Mtime feed a folder's summary and doctor's staleness check;
	// they are not part of the printed map.
	Tags  []string `json:"-"`
	Mtime int64    `json:"-"`
}

Note is one entry in the map.

func Covering

func Covering(q Querier, f CodeFile) ([]Note, error)

Covering returns the notes whose `paths:` cover f, each with its line. A status:draft note is omitted: the line is a slice of the body, and the code-map hook injects it as context. The full tree still lists the draft.

func CoveringIncludingDrafts added in v0.10.13

func CoveringIncludingDrafts(q Querier, f CodeFile) ([]Note, error)

CoveringIncludingDrafts is Covering with the retrieval opt-in.

func Load

func Load(q Querier, f Filter) ([]Note, error)

Load reads every indexed note matching f, with its one-line description.

type Querier

type Querier interface {
	Query(query string, args ...interface{}) (*sql.Rows, error)
}

Querier is the part of the index DB that Load needs.

type RenderOptions

type RenderOptions struct {
	// Depth limits how many folder levels are listed; deeper folders are folded
	// into their parent's count. Notes are listed only inside listed folders
	// above the limit. 0 lists everything.
	Depth int
	// Brief prints titles and ids without the one-line descriptions.
	Brief bool
}

RenderOptions shape the printed map.

Jump to

Keyboard shortcuts

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