diagnostics

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 26 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasFixableIssues

func HasFixableIssues(r *Report) bool

HasFixableIssues reports whether the report contains any failing checks that the auto-fix harness knows how to handle. Drives the `--fix` hint in the doctor CLI — there's no point suggesting --fix when nothing in the report is fixable.

pi and piolium are treated as optional when claude (Path A) is available — the audit mode already has a working driver, so a missing Path B alone should not trigger the "re-run with --fix" hint. A missing bun is also ignored when npm is present, since the JS installs fall back to npm.

func NucleiTemplatesDir

func NucleiTemplatesDir(settings *config.Settings) string

NucleiTemplatesDir resolves the nuclei templates directory from settings or the ~/nuclei-templates default. Exported so the `update` command resolves the same path as the doctor checks and fixes.

func ResolveFixKey

func ResolveFixKey(name string) string

ResolveFixKey is the exported form of resolveAlias: it maps a user-supplied --only token (e.g. "chrome", "nuclei") to its canonical fix key (e.g. "chromium", "nuclei-templates"). The doctor CLI uses it to render a focused view of just the components named in --only.

Types

type AgentCheck

type AgentCheck struct {
	Status       Status   `json:"status"`
	Name         string   `json:"name"`
	Binary       string   `json:"binary,omitempty"`
	Protocol     string   `json:"protocol,omitempty"`
	PingResponse string   `json:"ping_response,omitempty"`
	Message      string   `json:"message,omitempty"`
	Details      []string `json:"details,omitempty"`
	Tip          string   `json:"tip,omitempty"`
}

AgentCheck holds the outcome of the agent backend check.

type AuditPathStatus

type AuditPathStatus struct {
	OK      bool     // true when every component this path needs is healthy
	Reasons []string // one line per failing component (e.g. "claude: not found in PATH")
}

AuditPathStatus describes one of the two driver paths under "Audit mode" in the doctor renderer. Paths are independent — either one being OK is enough to consider the audit mode usable.

func AuditPathA

func AuditPathA(r *Report) AuditPathStatus

AuditPathA reports the status of the claude/audit driver path used by `vigolium agent audit --driver=audit`. Both the `claude` CLI and the embedded vigolium-audit binary are required; when `agent.audit.enabled=false` the path is treated as unavailable (the user has explicitly opted out).

func AuditPathB

func AuditPathB(r *Report) AuditPathStatus

AuditPathB reports the status of the piolium driver path used by `vigolium agent audit --driver=piolium`. Needs pi (the runtime) and the piolium Pi extension loaded. pi is installed via bun or npm, but once present it's a standalone binary — neither bun nor npm is required at audit time, so they are not part of this path's required set.

type CheckResult

type CheckResult struct {
	Status  Status   `json:"status"`
	Message string   `json:"message,omitempty"`
	Details []string `json:"details,omitempty"` // verbose-only diagnostic details
	Tip     string   `json:"tip,omitempty"`     // remediation hint shown at all verbosity levels
}

CheckResult holds the outcome of a single diagnostic check.

type Deps

type Deps struct {
	DB *database.DB
	// DBErr carries the error from opening the database when DB is nil. The
	// CLI populates this so checkDatabase can surface real connect failures
	// (refused, auth failed, unknown host) instead of "not configured".
	DBErr error
	// ConfigErr carries the error from loading the configuration file when
	// Settings fell back to defaults. doctor exists to REPORT broken state, so a
	// config it could not read must be a failed check here rather than a log line
	// nobody sees next to a report that says everything is fine.
	ConfigErr error
	// ConfigPath is the file the CLI actually resolved, so a report run with
	// --config names the file it read rather than the default location. Empty
	// falls back to the default path.
	ConfigPath string
	Queue      queue.Queue
	Settings   *config.Settings
	// ProbeBrowserLaunch, when set, makes the chromium check actually launch the
	// resolved browser headless (catching a binary that passes --version but
	// crashes on real startup). It spawns a browser process (~1-2s), so only the
	// one-shot CLI paths (doctor, first-run init) enable it; the server
	// /diagnostics endpoint leaves it off to stay a cheap, poll-safe readout.
	ProbeBrowserLaunch bool
	// ProbeNetwork, when set, lets the OAST check resolve the interactsh server
	// and open one TLS connection to it (3s budget, no registration). Like
	// ProbeBrowserLaunch it is set by the CLI doctor only; the server
	// /diagnostics endpoint leaves it off so a poll never touches the network.
	ProbeNetwork bool
}

Deps provides the dependencies needed to run diagnostics. All fields are optional — nil values are handled gracefully.

type FixResult

type FixResult struct {
	Key     string `json:"key"`
	Label   string `json:"label"`
	Success bool   `json:"success"`
	Message string `json:"message"`
}

FixResult holds the outcome of a single fix attempt.

func RunFixes

func RunFixes(ctx context.Context, report *Report, settings *config.Settings, only []string) []FixResult

RunFixes attempts to fix failing checks. If only is non-empty, only those items (and their required dependencies) are fixed.

pi and piolium are skipped by default when claude (Path A) is available — audit mode already has a working driver, so we don't want a bare `--fix` to pull in the Path B stack as well. Users who want both drivers can still opt in with `--fix --only piolium` (or `--only pi`).

The standalone bun install is skipped by default when npm is present — npm-equipped hosts use npm for the global installs. `--only bun` force- installs bun regardless.

type Report

type Report struct {
	Status           Status                  `json:"status"` // "ready", "degraded", "not_ready"
	Timestamp        string                  `json:"timestamp"`
	Config           *CheckResult            `json:"config"`
	Scope            *CheckResult            `json:"scope"`
	OAST             *CheckResult            `json:"oast"`
	Database         *CheckResult            `json:"database"`
	Initialized      *CheckResult            `json:"initialized"`
	Queue            *CheckResult            `json:"queue,omitempty"`
	Agent            *AgentCheck             `json:"agent"`
	Browser          *CheckResult            `json:"browser"`
	SessionsDir      *CheckResult            `json:"sessions_dir"`
	EmbeddedBinaries map[string]*CheckResult `json:"embedded_binaries,omitempty"`
	Audit            *CheckResult            `json:"audit,omitempty"`   // omitted when audit integration is disabled
	Piolium          *CheckResult            `json:"piolium,omitempty"` // soft check — feature-gates audit --driver=piolium
	Tools            map[string]*ToolCheck   `json:"tools"`
	TemplatesDir     *CheckResult            `json:"templates_dir"`
	NucleiTemplates  *CheckResult            `json:"nuclei_templates"`
	// Skill is the coding-agent skill install check. The CLI fills it in after
	// Run (it needs the binary's version and embedded bundle), so the server's
	// /diagnostics leaves it nil. It never moves Status: a stale skill does
	// not stop a scan.
	Skill *CheckResult `json:"skill,omitempty"`
}

Report is the complete diagnostic report.

func Run

func Run(deps Deps) *Report

Run performs all diagnostic checks and returns a report.

type Status

type Status string

Status represents the state of a diagnostic check.

const (
	StatusOK      Status = "ok"
	StatusWarning Status = "warning"
	StatusError   Status = "error"
)

type ToolCheck

type ToolCheck struct {
	Status  Status   `json:"status"`
	Path    string   `json:"path,omitempty"`
	Message string   `json:"message,omitempty"`
	Details []string `json:"details,omitempty"`
	Tip     string   `json:"tip,omitempty"`
}

ToolCheck holds the outcome of a third-party tool check.

Jump to

Keyboard shortcuts

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