Documentation
¶
Overview ¶
Package system provides system prompt construction for GenCode. It assembles prompts from modular components: base identity, provider-specific instructions, and dynamic environment information.
Index ¶
- func CompactPrompt() string
- func FindMemoryFile(paths []string) string
- func FormatFileSize(size int64) string
- func GetFileSize(path string) int64
- func GetMemoryPaths(cwd string) (userPaths, projectPaths []string)
- func ListRulesFiles(rulesDir string) []string
- func LoadMemory(cwd string) string
- func Prompt(cfg Config) string
- type Config
- type MemoryFile
- type MemoryPaths
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompactPrompt ¶ added in v1.3.0
func CompactPrompt() string
CompactPrompt returns the prompt for conversation compaction.
func FindMemoryFile ¶ added in v1.3.0
FindMemoryFile returns the first existing file path from the given list. Returns empty string if no file exists.
func FormatFileSize ¶ added in v1.3.0
FormatFileSize formats a file size for display.
func GetFileSize ¶ added in v1.3.0
GetFileSize returns the size of a file in bytes, or 0 if not found.
func GetMemoryPaths ¶ added in v1.3.0
GetMemoryPaths returns the search paths for memory files. Returns user-level paths and project-level paths separately (legacy compatibility).
func ListRulesFiles ¶ added in v1.3.0
ListRulesFiles returns all .md files in a rules directory.
func LoadMemory ¶ added in v1.1.1
LoadMemory loads memory content from standard locations. Priority: GEN.md files first, falling back to CLAUDE.md if not found.
User level (first found wins):
- ~/.gen/GEN.md (preferred)
- ~/.claude/CLAUDE.md (fallback)
User rules:
- ~/.gen/rules/*.md
Project level (first found wins):
- .gen/GEN.md or GEN.md (preferred)
- .claude/CLAUDE.md or CLAUDE.md (fallback)
Project local (not committed to git):
- .gen/GEN.local.md
Project rules:
- .gen/rules/*.md
All sources are concatenated with @import resolution.
Types ¶
type Config ¶
type Config struct {
Provider string // Provider name: anthropic, openai, google
Model string // Model identifier
Cwd string // Current working directory
IsGit bool // Whether cwd is a git repository
// Extension points (reserved for future use)
Memory string // CLAUDE.md or similar memory content
PlanMode bool // Whether in plan mode
Extra []string // Additional prompt sections
}
Config holds configuration for system prompt generation.
type MemoryFile ¶ added in v1.3.0
type MemoryFile struct {
Path string // Full path to the file
Size int64 // File size in bytes
Content string // File content
Level string // "global", "project", or "local"
Source string // "rules" for rules directory files, empty otherwise
}
MemoryFile represents a loaded memory file with metadata.
func LoadMemoryFiles ¶ added in v1.3.0
func LoadMemoryFiles(cwd string) []MemoryFile
LoadMemoryFiles loads all memory files with metadata. Returns files in order: global, global rules, project, project rules, local.
type MemoryPaths ¶ added in v1.3.0
type MemoryPaths struct {
Global []string // User-level memory files
GlobalRules string // User-level rules directory
Project []string // Project-level memory files
ProjectRules string // Project-level rules directory
Local []string // Local memory files (not committed)
}
MemoryPaths holds categorized memory file paths.
func GetAllMemoryPaths ¶ added in v1.3.0
func GetAllMemoryPaths(cwd string) MemoryPaths
GetAllMemoryPaths returns all memory paths organized by category.