Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: EUPL-1.2 Imports: 10 Imported by: 0

Documentation

Overview

Package config charge la configuration globale et projet (TOML).

La configuration projet est une frontière de sécurité : un dépôt malveillant ne doit pouvoir ni assouplir les permissions ni rediriger le trafic vers un autre fournisseur.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataDir

func DataDir(getenv func(string) string) string

DataDir : $XDG_DATA_HOME/tenon, sinon $HOME/.local/share/tenon.

func GlobalPath

func GlobalPath(getenv func(string) string) string

GlobalPath : $XDG_CONFIG_HOME/tenon/config.toml, sinon $HOME/.config/tenon/config.toml.

Types

type Audit

type Audit struct {
	Level string `toml:"level"`
}

type Config

type Config struct {
	Lang            string   `toml:"lang"`
	DefaultProvider string   `toml:"default_provider"`
	MaxIterations   int      `toml:"max_iterations"`
	ShellTimeout    Duration `toml:"shell_timeout"`
	OutputLimit     int      `toml:"output_limit"`
	// CompactionThreshold : part de la fenêtre de contexte au-delà de
	// laquelle l'historique est compacté. Clé globale uniquement.
	CompactionThreshold float64     `toml:"compaction_threshold"`
	Audit               Audit       `toml:"audit"`
	Providers           []Provider  `toml:"providers"`
	Permissions         Permissions `toml:"permissions"`
	Redaction           Redaction   `toml:"redaction"`
	// MCP : serveurs MCP. Clé globale uniquement (un serveur stdio est une
	// exécution de code arbitraire : un dépôt ne peut pas en déclarer).
	MCP MCP `toml:"mcp"`
	// Hooks : réglages des hooks. Clé globale uniquement (un hook est une
	// exécution de code arbitraire : un dépôt ne peut pas les activer).
	Hooks Hooks `toml:"hooks"`
}

func Defaults

func Defaults(getenv func(string) string) Config

Defaults renvoie la configuration par défaut, préréglages inclus.

func Load

func Load(globalPath, projectPath string, getenv func(string) string) (Config, error)

Load fusionne défauts, configuration globale puis configuration projet. Un fichier absent est ignoré.

func (Config) Provider

func (c Config) Provider(id string) (Provider, bool)

Provider renvoie le fournisseur d'identifiant id.

type Duration

type Duration struct{ time.Duration }

Duration encapsule time.Duration pour le décodage TOML ("2m").

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(b []byte) error

type Hooks added in v0.5.0

type Hooks struct {
	ClaudeSettings bool `toml:"claude_settings"` // lit aussi ~/.claude/settings.json
	Disabled       bool `toml:"disabled"`        // ne charge aucun hook
}

Hooks règle le chargement des hooks utilisateur.

type MCP

type MCP struct {
	Servers []MCPServer `toml:"servers"`
}

type MCPServer

type MCPServer struct {
	ID           string   `toml:"id"`           // [a-z0-9_-]{1,32}
	Transport    string   `toml:"transport"`    // "stdio" | "http"
	Command      []string `toml:"command"`      // stdio : argv, non vide
	EnvFrom      []string `toml:"env_from"`     // stdio : variables transmises au serveur
	URL          string   `toml:"url"`          // http : https://… (http:// seulement vers localhost/127.0.0.1/::1)
	BearerEnv    string   `toml:"bearer_env"`   // http : variable contenant le jeton
	Jurisdiction string   `toml:"jurisdiction"` // "eu" | "non-eu" | "local"
	Country      string   `toml:"country"`
	Risk         string   `toml:"risk"`  // "" | "read" | "write" | "exec" | "network"
	Tools        []string `toml:"tools"` // liste blanche optionnelle des outils exposés
	Disabled     bool     `toml:"disabled"`
}

MCPServer déclare un serveur MCP. Aucun secret : variables référencées par nom.

type Permissions

type Permissions struct {
	Rules []Rule `toml:"rules"`
}

type Provider

type Provider struct {
	ID            string `toml:"id"`
	Name          string `toml:"name"`
	BaseURL       string `toml:"base_url"`
	APIKeyEnv     string `toml:"api_key_env"`
	Model         string `toml:"model"`
	Country       string `toml:"country"`
	Jurisdiction  string `toml:"jurisdiction"`
	ContextWindow int    `toml:"context_window"`
	// Detect : "ollama" ou "vllm" pour interroger le serveur au démarrage
	// (modèle servi, fenêtre appliquée) quand model ou context_window est
	// vide ; "off" désactive la détection héritée d'un préréglage.
	Detect string `toml:"detect"`
}

func (Provider) Window

func (p Provider) Window() int

Window renvoie la fenêtre de contexte du fournisseur, ou 32000 si non renseignée.

type Redaction

type Redaction struct {
	Rules []RedactionRule `toml:"rules"`
}

type RedactionRule

type RedactionRule struct {
	Name    string `toml:"name"`
	Pattern string `toml:"pattern"`
}

type Rule

type Rule struct {
	Tool     string `toml:"tool"`
	Match    string `toml:"match"`
	Decision string `toml:"decision"`
	Project  bool   `toml:"-"`
}

Rule.Decision : "allow" | "ask" | "deny". Project est posé au chargement pour les règles de la config projet (jamais lu depuis le TOML).

Jump to

Keyboard shortcuts

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