explain

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package explain builds compact, file-centred memory briefings for the CLI and MCP server.

Index

Constants

View Source
const (
	DefaultLimit = 10
	// MaxLimit bounds how many sessions one call returns, so an agent passing
	// limit=100000 can't turn a compact briefing into a transcript dump.
	MaxLimit = 50
)

Variables

This section is empty.

Functions

func NormalizePath

func NormalizePath(p string) string

NormalizePath puts a user-supplied path in the form file_touches stores: slash-separated, cleaned, no leading "./".

func ProjectPath

func ProjectPath(cwd, p string) string

ProjectPath is ResolvePath for callers whose relative paths are already project-relative (the MCP tool's documented contract): only an absolute path is rewritten, and a relative one is just normalised. Rebasing a relative path onto the server's cwd would turn a correct "internal/store/store.go" into a wrong one whenever the agent launched `ctx mcp` from a subdirectory.

func ResolvePath

func ResolvePath(cwd, p string) string

ResolvePath turns a path the caller typed (relative to cwd, or absolute) into the project-relative form file_touches uses. Running `ctx explain foo.go` from internal/store means internal/store/foo.go, not a file called foo.go at the project root. A path that lands outside the project root is returned normalised but otherwise untouched.

Types

type Result

type Result struct {
	Path     string    `json:"path"`
	Sessions []Session `json:"sessions"`
}

func File

func File(db *sql.DB, projectID int64, path string, limit int) (Result, error)

File explains path: the sessions that touched it in projectID, edits first. The result's slices are never nil, so it serialises as [] rather than null.

type Session

type Session struct {
	SessionID      string `json:"session_id"`
	Agent          string `json:"agent"`
	Title          string `json:"title,omitempty"`
	StartedAt      string `json:"started_at"`
	GitBranch      string `json:"git_branch,omitempty"`
	StartingCommit string `json:"starting_commit,omitempty"`
	EndingCommit   string `json:"ending_commit,omitempty"`
	// CommitSource is how the commits were obtained (store.Source*), empty
	// when unknown. CommitApproximate is true when they are a best guess:
	// resolved from HEAD rather than the session's branch, or unverifiable.
	CommitSource      string   `json:"commit_source,omitempty"`
	CommitApproximate bool     `json:"commit_approximate,omitempty"`
	Actions           []string `json:"actions"`
	Touches           int      `json:"touches"`
	Changes           int      `json:"changes"` // touches that were not plain reads
	LastTouchAt       string   `json:"last_touch_at,omitempty"`
	ChunkID           *int64   `json:"chunk_id,omitempty"`
	Preview           string   `json:"preview,omitempty"`
}

Jump to

Keyboard shortcuts

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