doctor

package
v0.1.6 Latest Latest
Warning

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

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

Documentation

Overview

Package doctor runs diagnostic checks on Genie configuration and environment (config file, secrets, MCP, SCM, model provider) and returns a list of results (errors, warnings, info) with stable ErrCodes for troubleshooting.

It solves the problem of validating setup before or during runs: "genie doctor" and the setup wizard use it to report missing keys, invalid URLs, and connectivity issues so users can fix configuration without guessing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorCount

func ErrorCount(results []Result) int

ErrorCount returns the number of results with Level == SeverityError.

func HasErrors

func HasErrors(results []Result) bool

HasErrors returns true if any result has Level == SeverityError.

Types

type ErrCode

type ErrCode string

ErrCode is a stable identifier for each diagnostic so users can look up resolution steps in the documentation (e.g. docs/data/docs.yml error_codes). Every problem reported by genie doctor MUST have an ErrCode.

const (
	// Config
	ErrCodeConfigFileMissing    ErrCode = "GENIE_DOC_001"
	ErrCodeConfigFileRead       ErrCode = "GENIE_DOC_002"
	ErrCodeConfigParse          ErrCode = "GENIE_DOC_003"
	ErrCodeConfigUnsupportedExt ErrCode = "GENIE_DOC_004"

	// Secrets (external / [security.secrets])
	ErrCodeSecretUnavailable   ErrCode = "GENIE_DOC_010"
	ErrCodeSecretManagerInit   ErrCode = "GENIE_DOC_011"
	ErrCodeSecretResolveFailed ErrCode = "GENIE_DOC_012"

	// Model config
	ErrCodeModelNoProviders   ErrCode = "GENIE_DOC_020"
	ErrCodeModelMissingToken  ErrCode = "GENIE_DOC_021"
	ErrCodeModelValidateError ErrCode = "GENIE_DOC_022"

	// MCP
	ErrCodeMCPConfigInvalid    ErrCode = "GENIE_DOC_030"
	ErrCodeMCPConnectFailed    ErrCode = "GENIE_DOC_031"
	ErrCodeMCPInitializeFailed ErrCode = "GENIE_DOC_032"
	ErrCodeMCPListToolsFailed  ErrCode = "GENIE_DOC_033"

	// SCM
	ErrCodeSCMNotConfigured   ErrCode = "GENIE_DOC_040"
	ErrCodeSCMProviderInvalid ErrCode = "GENIE_DOC_041"
	ErrCodeSCMTokenMissing    ErrCode = "GENIE_DOC_042"
	ErrCodeSCMInitFailed      ErrCode = "GENIE_DOC_043"
	ErrCodeSCMValidateFailed  ErrCode = "GENIE_DOC_044"

	// Messenger (optional check)
	ErrCodeMessengerConfigInvalid ErrCode = "GENIE_DOC_050"
	ErrCodeMessengerSecretMissing ErrCode = "GENIE_DOC_051"

	// Web search (optional)
	ErrCodeWebSearchConfigInvalid ErrCode = "GENIE_DOC_060"
)

type Result

type Result struct {
	ErrCode ErrCode
	Level   Severity
	Section string // e.g. "config", "mcp", "scm", "secrets", "model_config"
	Message string
	Detail  string
}

Result is a single diagnostic from a doctor check. Every problem MUST have an ErrCode for troubleshooting docs.

type Results added in v0.1.6

type Results []Result

func Run

Run runs all doctor checks against the loaded config and secret provider. cfgPath is the config file path used for loading (may be empty). It returns a slice of results; callers should report errors for any Result with Level == SeverityError.

func (Results) GetSection added in v0.1.6

func (r Results) GetSection(section string) *Result

GetSection returns the first result with the given section, or nil if none.

type Severity

type Severity string

Severity indicates how severe a check result is.

const (
	SeverityError   Severity = "error"
	SeverityWarning Severity = "warning"
	SeverityInfo    Severity = "info"
)

Jump to

Keyboard shortcuts

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