goals

package
v0.4.39-alpha Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package goals contains persisted thread-goal state and prompt rendering.

Index

Constants

View Source
const (
	// MetadataKey stores the active thread goal in conversation metadata.
	MetadataKey = "thread_goal"
	// SlashCommandName is the built-in slash command used to set a thread goal.
	SlashCommandName = "goal"
	// ContextStartMarker starts a hidden goal-context block.
	ContextStartMarker = "<goal_context>"
	// ContextEndMarker ends a hidden goal-context block.
	ContextEndMarker = "</goal_context>"
)

Variables

This section is empty.

Functions

func ContextFromMetadata

func ContextFromMetadata(metadata map[string]any) (string, bool)

ContextFromMetadata renders hidden goal context for an active goal.

func DisplayText

func DisplayText(objective string) string

DisplayText is the user-facing display text for a goal command.

func IsContextText

func IsContextText(text string) bool

IsContextText reports whether text is a goal-context block.

func IsTerminalStatus

func IsTerminalStatus(status Status) bool

IsTerminalStatus reports whether status ends automatic goal continuation.

func IsUpdateStatus

func IsUpdateStatus(status Status) bool

IsUpdateStatus reports whether status can be set by update_goal.

func IsValidStatus

func IsValidStatus(status Status) bool

IsValidStatus reports whether status is a known goal status.

func ModelPrompt

func ModelPrompt(objective string) string

ModelPrompt is the model-facing user message for a goal command.

func RenderContext

func RenderContext(goal Goal) string

RenderContext wraps the goal prompt in hidden goal-context markers.

func RenderContinuationPrompt

func RenderContinuationPrompt(goal Goal) string

RenderContinuationPrompt renders the model-facing steering prompt for an active goal.

Types

type CommandUpdate

type CommandUpdate struct {
	Objective   string
	ModelPrompt string
	Display     string
	Goal        Goal
}

CommandUpdate is the normalized result of handling `/goal <objective>`.

func ParseSlashCommand

func ParseSlashCommand(command, args string, now time.Time) (CommandUpdate, bool, error)

ParseSlashCommand normalizes a built-in goal slash command.

type Goal

type Goal struct {
	Version   int       `json:"version"`
	Objective string    `json:"objective"`
	Status    Status    `json:"status"`
	Reason    string    `json:"reason,omitempty"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

Goal is persisted in conversation metadata.

func AutoContinuationGoal

func AutoContinuationGoal(metadata map[string]any) (Goal, bool)

AutoContinuationGoal returns the active goal when another automatic continuation exchange may start.

func FromMetadata

func FromMetadata(metadata map[string]any) (Goal, bool)

FromMetadata reads and validates a goal from conversation metadata.

func New

func New(objective string, now time.Time) Goal

New creates a new active goal.

func UpdateStatus

func UpdateStatus(metadata map[string]any, status Status, reason string, now time.Time) (Goal, map[string]any, error)

UpdateStatus returns metadata with the goal status updated.

type Status

type Status string

Status is the lifecycle state of a thread goal.

const (
	StatusActive   Status = "active"
	StatusComplete Status = "complete"
	StatusBlocked  Status = "blocked"
	StatusPaused   Status = "paused"
	StatusCleared  Status = "cleared"
)

Jump to

Keyboard shortcuts

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