config

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config provides configuration management for Techne Code. It supports loading configuration from multiple sources with a clear priority order: defaults → global file → project file → environment variables.

Index

Constants

View Source
const (
	// EnvPrefix is the prefix for environment variables.
	EnvPrefix = "TECHNE_"

	// EnvDelimiter is the delimiter used to separate nested keys in env vars.
	// Example: TECHNE_PERMISSIONS_MODE maps to permissions.mode
	EnvDelimiter = "_"
)

Variables

This section is empty.

Functions

func Validate

func Validate(c *Config) error

Validate checks the configuration for errors and returns helpful messages. It validates required fields, provider types, and value constraints.

Types

type Config

type Config struct {
	// DefaultProvider is the name of the default AI provider to use.
	// Can reference a provider from the Providers map or be a built-in provider name.
	DefaultProvider string `koanf:"default_provider"`

	// DefaultModel is the default model to use for the provider.
	DefaultModel string `koanf:"default_model"`

	// Providers contains per-provider configuration.
	// Keys are provider names (e.g., "anthropic", "openai", "ollama").
	Providers map[string]ProviderConfig `koanf:"providers"`

	// Permissions contains the permission system configuration.
	Permissions PermissionsConfig `koanf:"permissions"`

	// Skills contains the skill system configuration.
	Skills SkillsConfig `koanf:"skills"`

	// Options contains general configuration options.
	Options OptionsConfig `koanf:"options"`
}

Config is the root configuration for Techne Code.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the built-in default configuration. These defaults are used when no configuration files or environment variables are present.

func Load

func Load(projectDir string) (*Config, error)

Load loads configuration from all sources with the following priority (lowest to highest): 1. Built-in defaults 2. Global config file (~/.config/techne/techne.json) 3. Project config file (.techne/techne.json) 4. Environment variables (TECHNE_*)

The projectDir parameter is used to locate the project config file. If projectDir is empty, the project config file is not loaded.

func LoadFromFile

func LoadFromFile(path string) (*Config, error)

LoadFromFile loads configuration from a specific file path. This is useful for testing or loading config from a custom location. Note: This does not apply defaults or load environment variables.

type OptionsConfig

type OptionsConfig struct {
	// ContextPaths is a list of file paths to include in the system prompt.
	// These files provide context about the project to the AI.
	// Example: ["AGENTS.md", ".cursorrules", "CLAUDE.md"]
	ContextPaths []string `koanf:"context_paths"`

	// MaxBashTimeout is the maximum allowed timeout for bash commands in milliseconds.
	// Default: 120000 (2 minutes)
	MaxBashTimeout int `koanf:"max_bash_timeout"`

	// MaxOutputChars is the maximum number of characters to display in output.
	// Output exceeding this will be truncated.
	// Default: 20000
	MaxOutputChars int `koanf:"max_output_chars"`

	// DataDirectory is the directory where Techne stores its data.
	// Default: ".techne/"
	DataDirectory string `koanf:"data_directory"`
}

OptionsConfig contains general configuration options.

type PermissionsConfig

type PermissionsConfig struct {
	// Mode determines how permissions are handled:
	// - "interactive": ask user for each permission (default)
	// - "auto_allow": automatically allow all tool executions
	// - "auto_deny": automatically deny all tool executions
	Mode string `koanf:"mode"`

	// AllowedTools is a list of tools that are automatically approved.
	// These tools bypass the permission check.
	AllowedTools []string `koanf:"allowed_tools"`
}

PermissionsConfig contains the permission system configuration.

type ProviderConfig

type ProviderConfig struct {
	// Type is the provider type: "anthropic", "openai", or "ollama".
	Type string `koanf:"type"`

	// APIKey is the API key for the provider.
	// Can reference environment variables using ${VAR} or $VAR syntax.
	APIKey string `koanf:"api_key"`

	// BaseURL is the base URL for the provider's API.
	// Useful for custom endpoints or Ollama.
	BaseURL string `koanf:"base_url"`

	// Models is a list of available models for this provider.
	Models []string `koanf:"models"`

	// ToolsEnabled determines whether tool use is enabled for this provider.
	// When false, the agent operates in chat-only mode without tool schemas.
	// Defaults: true for anthropic/openai, false for ollama.
	ToolsEnabled *bool `koanf:"tools_enabled"`
}

ProviderConfig contains per-provider configuration.

func (ProviderConfig) GetToolsEnabled

func (p ProviderConfig) GetToolsEnabled() bool

GetToolsEnabled returns the effective tools_enabled setting for this provider. If not explicitly set, it returns the default based on provider type: - anthropic, openai: true - ollama: false

type SkillsConfig

type SkillsConfig struct {
	// Enabled is a list of skill names to explicitly enable.
	// If empty, all skills are enabled by default.
	Enabled []string `koanf:"enabled"`

	// Disabled is a list of skill names to explicitly disable.
	// These skills will not be activated even if their triggers match.
	Disabled []string `koanf:"disabled"`

	// UserSkillsPath is the path to user-defined skills directory.
	// Default: ~/.config/techne/skills/
	UserSkillsPath string `koanf:"user_skills_path"`

	// ProjectSkillsPath is the path to project-specific skills directory.
	// Default: .techne/skills/
	ProjectSkillsPath string `koanf:"project_skills_path"`
}

SkillsConfig contains the skill system configuration.

Jump to

Keyboard shortcuts

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