sitedoctor

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package sitedoctor runs app-level health checks for a single site. It pairs a universal baseline every framework gets (env file present, .env drift, dependency install + lock, security audits, PHP version range) with the framework's own declarative checks from the store (config.FrameworkDoctor), so the web dashboard, TUI, and CLI all share one framework-agnostic engine.

Index

Constants

View Source
const (
	StatusOK      = "ok"
	StatusWarn    = "warn"
	StatusFail    = "fail"
	StatusUnknown = "unknown"
)

Check statuses, mirroring the MCP doctor's check shape so the diagnostics read consistently. "unknown" covers a check lerd couldn't run (e.g. the app is down), which is distinct from a genuine pass or failure.

View Source
const (
	FixComposerInstall = "composer_install"
	FixComposerUpdate  = "composer_update"
	FixNpmInstall      = "npm_install"
	FixNpmAuditFix     = "npm_audit_fix"
)

Universal doctor fix keys. A Check.Fix set to one of these names a package manager command the UI runs through the doctor fix endpoint, distinct from a framework command from the site's own command set.

Variables

View Source
var DoctorFixCommands = map[string]string{
	FixComposerInstall: "composer install",
	FixComposerUpdate:  "composer update",
	FixNpmInstall:      "npm install",
	FixNpmAuditFix:     "npm audit fix",
}

DoctorFixCommands maps each universal fix key to the shell command run in the site container. The fix endpoint only runs commands from this allowlist, so a client can never drive arbitrary shell through it.

Functions

func Applies added in v1.30.0

func Applies(path string, fw *config.Framework) bool

Applies reports whether Run would have anything to check, without touching the container. It mirrors Run's gating from the cheap, config-and-manifest signals so a site the report would leave empty (a host-proxy Python, Ruby, or Go dev server: no framework, no composer.json, no package.json) can hide the doctor button instead of opening a modal that finds nothing. A Node host-proxy keeps it, since its package.json still drives the node checks.

func AppliesForPath added in v1.30.0

func AppliesForPath(path, fwName string) bool

AppliesForPath reports whether the doctor has any check to run for the project at path, resolving the framework the same way RunForPath does so the dashboard, CLI, and MCP share one applicability answer.

Types

type Check

type Check struct {
	Name   string `json:"name"`
	Label  string `json:"label,omitempty"`
	Status string `json:"status"`
	Detail string `json:"detail,omitempty"`
	Fix    string `json:"fix,omitempty"`
}

Check is one app-level health finding for a site. Fix, when set, names a command from the site's command set that a UI can run to resolve the finding, so the doctor never grows its own mutation endpoints.

type EnvMergeProposal added in v1.28.0

type EnvMergeProposal struct {
	EnvFile        string
	ExampleContent string
	EnvContent     string
	Required       []string
	Optional       []string
}

EnvMergeProposal carries the raw example and env file contents plus the missing keys, classified the same way the env_drift check splits them: Required keys the app reads with no default, Optional keys code has a fallback for. A caller pairs this with envfile.MergeMissing to build the proposed .env.

func ProposeEnvMerge added in v1.28.0

func ProposeEnvMerge(path string, fw *config.Framework) (EnvMergeProposal, bool)

ProposeEnvMerge resolves the env and example files for the framework rooted at path and returns its classified missing keys. ok is false when the framework has no dotenv example to compare against (php-const frameworks, or no example file on disk), so the caller can skip offering an insert.

type Response

type Response struct {
	Checks   []Check `json:"checks"`
	Failures int     `json:"failures"`
	Warnings int     `json:"warnings"`
}

Response is the full doctor report for a site.

func Run

func Run(ctx context.Context, path string, fw *config.Framework) Response

func RunForPath added in v1.28.0

func RunForPath(ctx context.Context, path, fwName string) Response

Run builds the doctor report for the project at path using fw to drive both the universal baseline and the framework's declarative checks. fw may be nil (an unknown framework) — only the file/dependency baseline runs then. The cheap checks read files; command and audit checks touch the container. RunForPath resolves the framework definition for a project path and runs the doctor, so the CLI, MCP, and Web UI share one path -> framework -> Run chain instead of re-deriving it three ways. fwName is the site's recorded framework when known; pass "" to detect it from the path.

Jump to

Keyboard shortcuts

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