Files
pmg/internal/doctor/doctor.go
T
Sahilb315andCursor 1c9b16f1fa fix: harden system-install review findings
Require root-owned, non-group/other-writable pmg for --system install;
allow remove without that validation. Doctor checks npm resolution for
PATH precedence, uses ImpliesInterception instead of message matching,
and documents version-manager shadowing. Pass profile bin dir from the
shim manager and note that system config ignores per-user files.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-13 22:20:57 +05:30

55 lines
1.0 KiB
Go

package doctor
type CheckStatus int
const (
StatusPass CheckStatus = iota
StatusWarn
StatusFail
)
type CheckResult struct {
Name string
Category string
Status CheckStatus
Message string
ImpliesInterception bool
}
type Check struct {
Name string
Category string
Run func() CheckResult
}
func RunChecks(checks []Check) []CheckResult {
results := make([]CheckResult, 0, len(checks))
for _, c := range checks {
result := c.Run()
result.Name = c.Name
result.Category = c.Category
results = append(results, result)
}
return results
}
func HasFailures(results []CheckResult) bool {
for _, r := range results {
if r.Status == StatusFail {
return true
}
}
return false
}
func CategorySummary(results []CheckResult) map[string]CheckStatus {
summary := make(map[string]CheckStatus)
for _, r := range results {
current, exists := summary[r.Category]
if !exists || r.Status > current {
summary[r.Category] = r.Status
}
}
return summary
}