prompts

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildEnvDiff added in v0.4.6

func BuildEnvDiff(storedEnvInfo string, platform, pwd, envLabel string, envInfo *utils.EnvInfo) string

BuildEnvDiff compares a stored environment snapshot (from session) with the current environment and returns a human-readable diff string. Returns "" if nothing changed.

func CollectReminders

func CollectReminders(rc *ReminderContext) []string

CollectReminders evaluates all built-in reminders and returns the messages for those whose condition is met. Returns nil if no reminders fire.

func FormatReminders

func FormatReminders(msgs []string) string

FormatReminders formats collected reminder strings into a single system message block, or returns empty string if none.

func GetPlanSystemPrompt

func GetPlanSystemPrompt(platform, pwd, envLabel string, envInfo *utils.EnvInfo) string

GetPlanSystemPrompt returns the system prompt for Plan mode (read-only exploration).

func GetSystemPrompt

func GetSystemPrompt(platform, pwd, envLabel string, envInfo *utils.EnvInfo, skillDescriptions string) string

func HasAgentsMd

func HasAgentsMd(pwd string) string

HasAgentsMd returns the path to agents.md (case-insensitive) in pwd, or "".

func LoadAgentsMdContent added in v0.9.2

func LoadAgentsMdContent(pwd string) string

LoadAgentsMdContent loads the merged agent-instruction content for pwd via the same MemoryLoader pipeline (char limits, @include resolution) that feeds the system prompt. Exported for the reminder middleware's AGENTS.md reload check, so both paths always see identical content.

func SerializeEnvInfo added in v0.4.6

func SerializeEnvInfo(platform, pwd, envLabel string, envInfo *utils.EnvInfo) string

SerializeEnvInfo produces a stable string representation of environment info for storage in session entries. The format is simple key=value lines.

Types

type MemoryConfig

type MemoryConfig struct {
	MaxTotalChars int
	MaxIncDepth   int
}

MemoryConfig controls how AGENTS.md files are loaded and merged.

type MemoryLoader

type MemoryLoader struct {
	// contains filtered or unexported fields
}

MemoryLoader loads and merges multi-level AGENTS.md files with @include support.

func NewMemoryLoader

func NewMemoryLoader(cfg MemoryConfig) *MemoryLoader

NewMemoryLoader creates a MemoryLoader with the given config.

func (*MemoryLoader) Load

func (m *MemoryLoader) Load(pwd string) (string, error)

Load loads and merges multi-level AGENTS.md files:

  1. ~/.jcode/AGENTS.md (global)
  2. {pwd}/AGENTS.md (project-level)
  3. {pwd}/AGENTS.local.md (local, expected gitignored)

Each file's @include directives are resolved recursively. The merged result is truncated to MaxTotalChars.

type ReminderContext

type ReminderContext struct {
	Iteration         int
	TokensUsed        int64
	ContextLimit      int
	HasIncompleteTodo bool
	IncompleteTodoN   int
	ConsecutiveErrors int
	EnvLabel          string
	IsRemote          bool
	PlanContent       string // non-empty when executing an approved plan

	// Goal context, set when an active session goal exists.
	GoalActive    bool
	GoalObjective string

	// Files the FileTracker sweep found modified (or deleted) outside the
	// session since the agent last read them.
	ExternalChangedFiles []string
	ExternalGoneFiles    []string

	// EnvDiff is the non-empty BuildEnvDiff output when the periodic env
	// refresh detected drift since the last snapshot (includes date changes).
	EnvDiff string

	// AGENTS.md reload: the new merged content when it changed on disk, or a
	// removal flag when the file disappeared. Mutually exclusive.
	AgentsMdUpdate  string
	AgentsMdRemoved bool
}

ReminderContext carries the runtime state needed to evaluate reminder conditions.

Jump to

Keyboard shortcuts

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