Documentation
¶
Index ¶
- Constants
- func BuildSystemPrompt(cwd string, ctx ContextFiles, tools []ToolInfo, skills []Skill) string
- func CoderSubAgentPrompt(cwd string) string
- func DefaultModelName(prov string) string
- func EnvCredentials(prov string) (apiKey, baseURL string)
- func ExploreSubAgentPrompt(cwd string) string
- func FormatModelID(provider, model string) string
- func FormatSkillsForPrompt(skills []Skill) string
- func ParseModelID(id string) (provider, model string)
- func PlanSubAgentPrompt(cwd string) string
- func PlansDir(cwd string) string
- func PromptsDir(cwd string) string
- func ProviderEnvKey(prov string) string
- func RunSetup(cwd string, settings Resolved, listModels ModelLister) error
- func SaveSettings(cwd string, s Settings) error
- func SessionsDir(cwd string) string
- func SettingsPath(cwd string) string
- func SkillsDir(cwd string) string
- func StripFrontmatter(content string) string
- func TasksDir(cwd string) string
- func UserConfigDir() string
- type ContextFiles
- type ModelLister
- type ModelOption
- type PromptTemplate
- type ProviderConfig
- type Resolved
- type Settings
- type Skill
- type ToolInfo
Constants ¶
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 ¶
CoderSubAgentPrompt returns the system prompt for the coder sub-agent.
func DefaultModelName ¶
DefaultModelName returns the default model name for a given provider.
func EnvCredentials ¶
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 ¶
ExploreSubAgentPrompt returns the system prompt for the explore sub-agent.
func FormatModelID ¶
FormatModelID combines provider and model into "provider/model". If model already contains "/", it is returned as-is.
func FormatSkillsForPrompt ¶
FormatSkillsForPrompt generates the XML block injected into the system prompt. Skills with DisableModelInvocation=true are excluded.
func ParseModelID ¶
ParseModelID splits "provider/model" into (provider, model). If no "/" is present, returns ("", id).
func PlanSubAgentPrompt ¶
PlanSubAgentPrompt returns the system prompt for the plan sub-agent.
func ProviderEnvKey ¶
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 ¶
SaveSettings writes settings to <cwd>/.codebot/settings.json.
func SessionsDir ¶
SessionsDir returns <cwd>/.codebot/sessions/.
func SettingsPath ¶
SettingsPath returns <cwd>/.codebot/settings.json.
func StripFrontmatter ¶
StripFrontmatter removes a leading YAML frontmatter block (--- delimited) from content.
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 ¶
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 ¶
LoadSettings loads and merges settings from global (~/.codebot/settings.json) and project (<cwd>/.codebot/settings.json). Project-level values override global.
func ResolveAll ¶
ResolveAll merges global and project settings, applies defaults, and returns a fully resolved configuration.
func (Resolved) ProviderCredentials ¶
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.
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 ¶
LoadSkills discovers and loads skills from user and project directories. Project skills override user skills with the same name.