memory

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package memory loads project + user "agent memory" files (typically AGENTS.md) into the system prompt.

Per REQUIREMENTS FR-9.1, the project root is searched in this order (first match wins): AGENTS.md → CLAUDE.md → GEMINI.md. The fallback chain lets Cogo be dropped into a repo that already has memory authored for Claude Code or a Gemini-native tool.

The user-global root (typically ~/.cogo/) reads only AGENTS.md; no fallback chain (FR-9.2). Both files are concatenated, user first, project second, so a per-repo memory file can layer on top of a user's personal preferences.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loaded

type Loaded struct {
	Instruction string
	Sources     []Source
}

Loaded is the result of a Load call. Instruction is the assembled text suitable for prepending to the agent's system prompt; Sources describes what got included so the user can inspect via /memory.

func Load

func Load(projectRoot, userRoot string) (Loaded, error)

Load resolves the project + user memory files and returns the concatenated instruction text. Missing files are not errors — memory is optional. Other I/O errors (permission denied, etc.) are returned so the caller can surface them.

projectRoot may be empty (e.g., no .agents/ found and we're not using cwd as a fallback); in that case only user memory is loaded. userRoot may be empty in tests.

func (Loaded) Empty

func (l Loaded) Empty() bool

Empty reports whether nothing was loaded.

type Source

type Source struct {
	Scope     string // "user" | "project"
	Path      string // absolute path
	Bytes     int    // bytes after truncation
	Truncated bool   // true if the on-disk file exceeded maxFileBytes
}

Source records where one piece of loaded memory came from. Used by the /memory slash command to show provenance.

Jump to

Keyboard shortcuts

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