doctor

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package doctor provides workspace health checks and diagnostics for bc.

Run a full health check:

report := doctor.RunAll(ctx, ws)
for _, cat := range report.Categories {
    fmt.Println(cat.Name)
    for _, item := range cat.Items {
        fmt.Printf("  %s %s\n", item.Status, item.Message)
    }
}

Run a single category:

cat := doctor.CheckWorkspace(ws)
cat := doctor.CheckDatabase(ws)
cat := doctor.CheckAgents(ctx, ws)
cat := doctor.CheckTools(ctx)
cat := doctor.CheckGit(ctx, ws)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidCategories

func ValidCategories() []string

ValidCategories returns the list of valid category names.

Types

type CategoryReport

type CategoryReport struct {
	Name  string `json:"name"`
	Items []Item `json:"items"`
}

CategoryReport is the result of checking one category.

func CategoryByName

func CategoryByName(ctx context.Context, ws *workspace.Workspace, name string) *CategoryReport

CategoryByName runs a single named category check. Returns nil if the category name is unknown.

func CheckAgents

func CheckAgents(ctx context.Context, ws *workspace.Workspace) CategoryReport

CheckAgents checks for orphaned sessions and stale agents.

func CheckDatabase

func CheckDatabase(ws *workspace.Workspace) CategoryReport

CheckDatabase checks SQLite integrity and table existence.

func CheckGit

CheckGit checks git worktree health for the workspace.

func CheckTools

func CheckTools(ctx context.Context) CategoryReport

CheckTools checks binary installations: tmux, git, registered providers, and env vars.

func CheckWorkspace

func CheckWorkspace(ws *workspace.Workspace) CategoryReport

CheckWorkspace checks the .bc/ directory structure, config validity, and roles.

func (*CategoryReport) Counts

func (c *CategoryReport) Counts() (ok, warn, fail int)

Counts tallies ok/warn/fail across Items.

type FixResult

type FixResult struct {
	Action  string
	Message string
	Success bool
}

FixResult describes one auto-fix action taken (or that would be taken).

func Fix

func Fix(ctx context.Context, ws *workspace.Workspace, report *Report, dryRun bool) []FixResult

Fix runs auto-fix actions for all fixable issues found in report. If dryRun is true no changes are made; actions are described instead.

func FixCategory

func FixCategory(ctx context.Context, ws *workspace.Workspace, cat *CategoryReport, dryRun bool) []FixResult

FixCategory runs auto-fix actions for issues in a single category.

type Item

type Item struct {
	Name     string   `json:"name"`
	Message  string   `json:"message"`
	Fix      string   `json:"fix,omitempty"`
	Severity Severity `json:"severity"`
}

Item is the result of a single health check. Field order optimized by fieldalignment.

type Report

type Report struct {
	Categories []CategoryReport `json:"categories"`
}

Report contains all category results from a full health check.

func RunAll

func RunAll(ctx context.Context, ws *workspace.Workspace) *Report

RunAll runs all health check categories and returns a combined report.

func (*Report) Summary

func (r *Report) Summary() (ok, warn, fail int)

Summary returns aggregate ok/warn/fail totals across all categories.

type Severity

type Severity int

Severity indicates the outcome of a single health check item.

const (
	// SeverityOK means the check passed.
	SeverityOK Severity = iota
	// SeverityWarn means a non-critical issue was found.
	SeverityWarn
	// SeverityFail means a critical issue was found.
	SeverityFail
)

func (Severity) MarshalJSON

func (s Severity) MarshalJSON() ([]byte, error)

MarshalJSON encodes a Severity as its string representation.

func (Severity) String

func (s Severity) String() string

String returns the string representation of a Severity.

func (*Severity) UnmarshalJSON

func (s *Severity) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a Severity from its string representation.

Jump to

Keyboard shortcuts

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