system

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 11 Imported by: 0

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

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

func FindMemoryFile(paths []string) string

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

func FormatFileSize(size int64) string

FormatFileSize formats a file size for display.

func GetFileSize added in v1.3.0

func GetFileSize(path string) int64

GetFileSize returns the size of a file in bytes, or 0 if not found.

func GetMemoryPaths added in v1.3.0

func GetMemoryPaths(cwd string) (userPaths, projectPaths []string)

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

func ListRulesFiles(rulesDir string) []string

ListRulesFiles returns all .md files in a rules directory.

func LoadMemory added in v1.1.1

func LoadMemory(cwd string) string

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):

  1. ~/.gen/GEN.md (preferred)
  2. ~/.claude/CLAUDE.md (fallback)

User rules:

  • ~/.gen/rules/*.md

Project level (first found wins):

  1. .gen/GEN.md or GEN.md (preferred)
  2. .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.

func Prompt

func Prompt(cfg Config) string

Prompt builds the complete system prompt. Assembly order: base + tools + provider/generic + environment

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.

Jump to

Keyboard shortcuts

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