config

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const ConfigDir = ".codebot"

ConfigDir is the project-level config directory name.

Variables

This section is empty.

Functions

func BuildSystemPrompt

func BuildSystemPrompt(cwd string, ctx ContextFiles, tools []ToolInfo, skills []Skill) string

BuildSystemPrompt constructs the system prompt from the working directory, context files, available tools, and loaded skills. When tools is non-empty the tool section is generated dynamically; otherwise a static fallback is used.

func CoderSubAgentPrompt

func CoderSubAgentPrompt(cwd string) string

CoderSubAgentPrompt returns the system prompt for the coder sub-agent.

func DefaultModelName

func DefaultModelName(prov string) string

DefaultModelName returns the default model name for a given provider.

func EnvCredentials

func EnvCredentials(prov string) (apiKey, baseURL string)

EnvCredentials returns API key and base URL from standard environment variables for the given provider (e.g. ANTHROPIC_API_KEY, OPENAI_API_KEY).

func ExploreSubAgentPrompt

func ExploreSubAgentPrompt(cwd string) string

ExploreSubAgentPrompt returns the system prompt for the explore sub-agent.

func FormatModelID

func FormatModelID(provider, model string) string

FormatModelID combines provider and model into "provider/model". If model already contains "/", it is returned as-is.

func FormatSkillsForPrompt

func FormatSkillsForPrompt(skills []Skill) string

FormatSkillsForPrompt generates the XML block injected into the system prompt. Skills with DisableModelInvocation=true are excluded.

func ParseModelID

func ParseModelID(id string) (provider, model string)

ParseModelID splits "provider/model" into (provider, model). If no "/" is present, returns ("", id).

func PlanSubAgentPrompt

func PlanSubAgentPrompt(cwd string) string

PlanSubAgentPrompt returns the system prompt for the plan sub-agent.

func PlansDir

func PlansDir(cwd string) string

PlansDir returns <cwd>/.codebot/plans/.

func PromptsDir

func PromptsDir(cwd string) string

PromptsDir returns <cwd>/.codebot/prompts/.

func ProviderEnvKey

func ProviderEnvKey(prov string) string

ProviderEnvKey returns the standard environment variable name for a provider's API key.

func RunSetup

func RunSetup(cwd string, settings Resolved, listModels ModelLister) error

RunSetup runs an interactive first-time configuration wizard.

func SaveSettings

func SaveSettings(cwd string, s Settings) error

SaveSettings writes settings to <cwd>/.codebot/settings.json.

func SessionsDir

func SessionsDir(cwd string) string

SessionsDir returns <cwd>/.codebot/sessions/.

func SettingsPath

func SettingsPath(cwd string) string

SettingsPath returns <cwd>/.codebot/settings.json.

func SkillsDir

func SkillsDir(cwd string) string

SkillsDir returns <cwd>/.codebot/skills/.

func StripFrontmatter

func StripFrontmatter(content string) string

StripFrontmatter removes a leading YAML frontmatter block (--- delimited) from content.

func TasksDir

func TasksDir(cwd string) string

TasksDir returns <cwd>/.codebot/tasks/.

func UserConfigDir

func UserConfigDir() string

UserConfigDir returns ~/.codebot/.

Types

type ContextFiles

type ContextFiles struct {
	// Agents is the concatenated content of all AGENTS.md files found
	// from filesystem root down to cwd, separated by newlines.
	Agents string

	// SystemOverride is the content of SYSTEM.md if found in cwd.
	// When non-empty, it replaces the default system prompt entirely.
	SystemOverride string

	// SystemAppend is the content of APPEND_SYSTEM.md if found in cwd.
	// When non-empty, it is appended to the system prompt.
	SystemAppend string
}

ContextFiles holds the loaded context file contents.

func LoadContextFiles

func LoadContextFiles(cwd string) ContextFiles

LoadContextFiles searches for context files from cwd upward to the filesystem root.

AGENTS.md files are collected from each directory from root down to cwd. Closer to cwd = appended later (higher specificity).

SYSTEM.md and APPEND_SYSTEM.md are only looked for in cwd.

type ModelLister

type ModelLister func(provider string) []ModelOption

ModelLister returns available models for a given provider.

type ModelOption

type ModelOption struct {
	ID   string
	Name string
}

ModelOption represents a selectable model for the setup wizard.

type PromptTemplate

type PromptTemplate struct {
	Name        string // filename without .md extension
	Description string // from frontmatter or first non-empty line (max 60 chars)
	Content     string // template body (after frontmatter)
	Source      string // "user" or "project"
	FilePath    string // absolute path to the template file
}

PromptTemplate is a user-defined prompt template loaded from a .md file.

func LoadPromptTemplates

func LoadPromptTemplates(cwd string) []PromptTemplate

LoadPromptTemplates discovers and loads .md templates from user and project directories. Project templates override user templates with the same name.

type ProviderConfig

type ProviderConfig struct {
	APIKey  string `json:"api_key,omitempty"`
	BaseURL string `json:"base_url,omitempty"`
}

ProviderConfig holds credentials for a single provider.

type Resolved

type Resolved struct {
	Provider   string                    // active provider name
	Model      string                    // model name sent to API as-is
	Providers  map[string]ProviderConfig // per-provider credentials
	SmallModel string                    // "provider/model" or ""

	ContextWindow  int
	AutoCompaction bool
	ThinkingLevel  string
	MaxTurns       int
	SearchProvider string
	SearchAPIKey   string
}

Resolved holds settings resolved to concrete values (no pointers).

func LoadSettings

func LoadSettings(cwd string) Resolved

LoadSettings loads and merges settings from global (~/.codebot/settings.json) and project (<cwd>/.codebot/settings.json). Project-level values override global.

func ResolveAll

func ResolveAll(cwd string) Resolved

ResolveAll merges global and project settings, applies defaults, and returns a fully resolved configuration.

func (Resolved) ProviderCredentials

func (r Resolved) ProviderCredentials(prov string) (apiKey, baseURL string)

ProviderCredentials returns API key and base URL for the given provider. It checks the providers map first, then falls back to standard environment variables.

type Settings

type Settings struct {
	Provider   *string                    `json:"provider,omitempty"`    // provider name (matches key in providers map)
	Model      *string                    `json:"model,omitempty"`       // model name sent to API as-is
	SmallModel *string                    `json:"small_model,omitempty"` // "provider/model" for explore sub-agent
	Providers  map[string]*ProviderConfig `json:"providers,omitempty"`

	ContextWindow  *int  `json:"context_window,omitempty"`
	AutoCompaction *bool `json:"auto_compaction,omitempty"`

	ThinkingLevel *string `json:"thinking_level,omitempty"`

	MaxTurns *int `json:"max_turns,omitempty"`

	SearchProvider *string `json:"search_provider,omitempty"`
	SearchAPIKey   *string `json:"search_api_key,omitempty"`
}

Settings holds application-level configuration. Fields use pointer types so unset fields fall back to defaults.

func (Settings) Resolve

func (s Settings) Resolve() Resolved

Resolve converts Settings to Resolved using defaults for unset fields.

type Skill

type Skill struct {
	Name                   string // validated skill name (stored lowercase)
	Description            string // from frontmatter or first line
	FilePath               string // absolute path to the .md file
	BaseDir                string // parent directory (for relative path resolution)
	Source                 string // "user" or "project"
	DisableModelInvocation bool   // when true, excluded from system prompt
}

Skill represents a loadable skill file.

func LoadSkills

func LoadSkills(cwd string) []Skill

LoadSkills discovers and loads skills from user and project directories. Project skills override user skills with the same name.

type ToolInfo

type ToolInfo struct {
	Name        string
	Description string
}

ToolInfo describes a tool for system prompt generation. Decoupled from agentcore.Tool to avoid package dependency.

Jump to

Keyboard shortcuts

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