Documentation
¶
Overview ¶
Package memory stores searchable project and session memory entries.
Index ¶
- Constants
- Variables
- func Render(files []File) string
- func RenderAppendReport(w io.Writer, report AppendReport)
- func RenderFileReport(w io.Writer, report FileReport)
- func RenderReport(w io.Writer, report Report)
- func RenderResetReport(w io.Writer, report ResetReport)
- func RenderSearchReport(w io.Writer, report SearchReport)
- func RenderSelectionReport(w io.Writer, report SelectionReport)
- func RenderShowReport(w io.Writer, report ShowReport)
- func ResolvePath(workspace string, target string) (string, error)
- type AppendReport
- type File
- type FileReport
- type Metadata
- type Report
- type ResetFile
- type ResetOptions
- type ResetReport
- type RulesImportOptions
- type SearchMatch
- type SearchReport
- type SelectionOption
- type SelectionReport
- type ShowReport
- type Summary
Constants ¶
const MaxFileBytes = 64 * 1024
MaxFileBytes limits how much of each instruction file is loaded into memory.
Variables ¶
var CandidateNames = []string{ "AGENTS.md", "AGENTS.local.md", "CLAUDE.md", "CLAUDE.local.md", filepath.Join(".claude", "CLAUDE.md"), "CLAW.md", "CLAW.local.md", filepath.Join(".claw", "CLAUDE.md"), filepath.Join(".claw", "instructions.md"), filepath.Join(".codog", "instructions.md"), }
CandidateNames lists workspace-relative instruction file names Codog treats as project memory.
Functions ¶
func RenderAppendReport ¶
func RenderAppendReport(w io.Writer, report AppendReport)
RenderAppendReport writes a human-readable memory append report.
func RenderFileReport ¶
func RenderFileReport(w io.Writer, report FileReport)
RenderFileReport writes a human-readable memory file operation report.
func RenderReport ¶
RenderReport writes a human-readable memory discovery report.
func RenderResetReport ¶
func RenderResetReport(w io.Writer, report ResetReport)
RenderResetReport writes a human-readable memory reset report.
func RenderSearchReport ¶
func RenderSearchReport(w io.Writer, report SearchReport)
RenderSearchReport writes a human-readable memory search report.
func RenderSelectionReport ¶
func RenderSelectionReport(w io.Writer, report SelectionReport)
RenderSelectionReport writes a human-readable memory selector report.
func RenderShowReport ¶
func RenderShowReport(w io.Writer, report ShowReport)
RenderShowReport writes a human-readable memory file report.
Types ¶
type AppendReport ¶
type AppendReport struct {
Kind string `json:"kind"`
Action string `json:"action"`
Status string `json:"status"`
Path string `json:"path"`
Bytes int `json:"bytes"`
}
AppendReport describes a successful append to a memory file.
type File ¶
type File struct {
Path string `json:"path"`
Name string `json:"name"`
Scope string `json:"scope"`
Chars int `json:"chars"`
SizeBytes int64 `json:"size_bytes"`
ModifiedAt time.Time `json:"modified_at"`
Truncated bool `json:"truncated,omitempty"`
Body string `json:"-"`
}
File is a loaded project-memory instruction file.
func DiscoverWithRulesImport ¶
func DiscoverWithRulesImport(workspace string, rulesImport RulesImportOptions) ([]File, error)
DiscoverWithRulesImport loads project-memory files and optional external framework rule files between the workspace and its boundary.
type FileReport ¶
type FileReport struct {
Kind string `json:"kind"`
Action string `json:"action"`
Status string `json:"status"`
Path string `json:"path"`
Created bool `json:"created"`
Opened bool `json:"opened,omitempty"`
Editor string `json:"editor,omitempty"`
Message string `json:"message,omitempty"`
}
FileReport describes a memory file path, creation, or editor operation.
type Metadata ¶
type Metadata struct {
Path string `json:"path"`
Name string `json:"name"`
Source string `json:"source"`
Origin string `json:"origin"`
Scope string `json:"scope"`
ScopePath string `json:"scope_path"`
OutsideProject bool `json:"outside_project"`
Chars int `json:"chars"`
Lines int `json:"lines"`
Words int `json:"words"`
SizeBytes int64 `json:"size_bytes"`
ModifiedAt string `json:"modified_at,omitempty"`
AgeSeconds int64 `json:"age_seconds,omitempty"`
Empty bool `json:"empty"`
Contributes bool `json:"contributes"`
Truncated bool `json:"truncated,omitempty"`
}
Metadata is a JSON-safe description of one loaded project-memory file.
func MetadataFor ¶
MetadataFor returns JSON-safe metadata for loaded memory files.
type Report ¶
type Report struct {
Kind string `json:"kind"`
Action string `json:"action"`
Status string `json:"status"`
WorkingDirectory string `json:"working_directory"`
InstructionFiles int `json:"instruction_files"`
Files []Summary `json:"files"`
}
Report describes discovered project-memory files for a workspace.
func BuildReport ¶
BuildReport discovers and summarizes project-memory files for a workspace.
func BuildReportWithRulesImport ¶
func BuildReportWithRulesImport(workspace string, rulesImport RulesImportOptions) (Report, error)
BuildReportWithRulesImport discovers and summarizes project-memory files using the provided external rule import policy.
type ResetOptions ¶
type ResetReport ¶
type ResetReport struct {
Kind string `json:"kind"`
Action string `json:"action"`
Status string `json:"status"`
WorkingDirectory string `json:"working_directory"`
Target string `json:"target,omitempty"`
All bool `json:"all,omitempty"`
ResetCount int `json:"reset_count"`
Files []ResetFile `json:"files"`
}
func Reset ¶
func Reset(workspace string, opts ResetOptions) (ResetReport, error)
Reset clears one or more discovered project-memory files after confirmation.
type RulesImportOptions ¶
RulesImportOptions controls external AI coding rule imports.
func (RulesImportOptions) ShouldImport ¶
func (o RulesImportOptions) ShouldImport(framework string) bool
type SearchMatch ¶
type SearchMatch struct {
Path string `json:"path"`
Name string `json:"name"`
Scope string `json:"scope"`
LineNumber int `json:"line_number"`
Line string `json:"line"`
Score int `json:"score"`
MatchedTerms []string `json:"matched_terms,omitempty"`
}
SearchMatch records one relevant line found in project memory.
type SearchReport ¶
type SearchReport struct {
Kind string `json:"kind"`
Action string `json:"action"`
Status string `json:"status"`
WorkingDirectory string `json:"working_directory"`
Query string `json:"query"`
MatchCount int `json:"match_count"`
Matches []SearchMatch `json:"matches"`
}
SearchReport describes a project-memory search result.
func Search ¶
func Search(workspace string, query string, limit int) (SearchReport, error)
Search finds lines in project memory that match the query terms.
func SearchWithRulesImport ¶
func SearchWithRulesImport(workspace string, query string, limit int, rulesImport RulesImportOptions) (SearchReport, error)
SearchWithRulesImport finds lines in project memory using the provided external rule import policy.
type SelectionOption ¶
type SelectionOption struct {
Path string `json:"path"`
Name string `json:"name"`
Source string `json:"source"`
Origin string `json:"origin"`
Scope string `json:"scope"`
Exists bool `json:"exists"`
Selected bool `json:"selected,omitempty"`
}
SelectionOption describes a memory file candidate for selector UIs.
type SelectionReport ¶
type SelectionReport struct {
Kind string `json:"kind"`
Action string `json:"action"`
Status string `json:"status"`
WorkingDirectory string `json:"working_directory"`
Target string `json:"target,omitempty"`
Selected string `json:"selected"`
OptionCount int `json:"option_count"`
Options []SelectionOption `json:"options"`
}
SelectionReport previews the memory file that would be edited or created.
type ShowReport ¶
type ShowReport struct {
Kind string `json:"kind"`
Action string `json:"action"`
Status string `json:"status"`
File File `json:"file"`
Body string `json:"body,omitempty"`
}
ShowReport contains the selected memory file and its body.
func Show ¶
func Show(workspace string, target string) (ShowReport, error)
Show returns a selected memory file, requiring a target when multiple files are available.
func ShowWithRulesImport ¶
func ShowWithRulesImport(workspace string, target string, rulesImport RulesImportOptions) (ShowReport, error)
ShowWithRulesImport returns a selected memory file using the provided rule import policy.
type Summary ¶
type Summary struct {
Path string `json:"path"`
Name string `json:"name"`
Scope string `json:"scope"`
Lines int `json:"lines"`
Words int `json:"words"`
Chars int `json:"chars"`
SizeBytes int64 `json:"size_bytes"`
ModifiedAt string `json:"modified_at,omitempty"`
AgeSeconds int64 `json:"age_seconds,omitempty"`
Empty bool `json:"empty"`
Preview string `json:"preview"`
Truncated bool `json:"truncated,omitempty"`
}
Summary is the JSON-safe metadata view of a memory file.