core

package
v0.8.0 Latest Latest
Warning

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

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

Documentation

Overview

Package core provides types, check functions, and output formatting for the doctor command. Subcommand cmd/root imports core for all doctor orchestration and display logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddResourceResults

func AddResourceResults(report *Report, snap sysinfo.Snapshot)

AddResourceResults appends per-metric resource results to the report. Extracted for testability with constructed Snapshot values.

Parameters:

  • report: Report to append the results to
  • snap: System resource snapshot to evaluate

func CheckContextInitialized

func CheckContextInitialized(report *Report)

CheckContextInitialized verifies that a .context/ directory exists.

Parameters:

  • report: Report to append the result to

func CheckContextTokenSize

func CheckContextTokenSize(report *Report)

CheckContextTokenSize estimates context token usage and reports per-file breakdown.

Parameters:

  • report: Report to append the result to

func CheckCtxrcValidation

func CheckCtxrcValidation(report *Report)

CheckCtxrcValidation validates the .ctxrc file for unknown fields or parse errors.

Parameters:

  • report: Report to append the result to

func CheckDrift

func CheckDrift(report *Report)

CheckDrift detects stale paths or missing files referenced in context.

Parameters:

  • report: Report to append the result to

func CheckEventLogging

func CheckEventLogging(report *Report)

CheckEventLogging checks whether event logging is enabled.

Parameters:

  • report: Report to append the result to

func CheckPluginEnablement

func CheckPluginEnablement(report *Report)

CheckPluginEnablement checks whether the ctx plugin is installed and enabled.

Parameters:

  • report: Report to append the result to

func CheckRecentEventActivity

func CheckRecentEventActivity(report *Report)

CheckRecentEventActivity reports the most recent event log entry.

Parameters:

  • report: Report to append the result to

func CheckReminders

func CheckReminders(report *Report)

CheckReminders checks for pending reminders in the context directory.

Parameters:

  • report: Report to append the result to

func CheckRequiredFiles

func CheckRequiredFiles(report *Report)

CheckRequiredFiles verifies that all required context files are present.

Parameters:

  • report: Report to append the result to

func CheckSystemResources

func CheckSystemResources(report *Report)

CheckSystemResources collects and evaluates system resource metrics.

Parameters:

  • report: Report to append the result to

func CheckTaskCompletion

func CheckTaskCompletion(report *Report)

CheckTaskCompletion analyzes the task completion ratio and suggests archiving.

Parameters:

  • report: Report to append the result to

func CheckWebhook

func CheckWebhook(report *Report)

CheckWebhook checks whether a webhook notification endpoint is configured.

Parameters:

  • report: Report to append the result to

func OutputHuman

func OutputHuman(cmd *cobra.Command, report *Report) error

OutputHuman writes the report in a human-readable format grouped by category.

Parameters:

  • cmd: Cobra command providing the output writer
  • report: Doctor report to display

Returns:

  • error: Always nil (satisfies interface)

func OutputJSON

func OutputJSON(cmd *cobra.Command, report *Report) error

OutputJSON writes the report as indented JSON to the command's output stream.

Parameters:

  • cmd: Cobra command providing the output writer
  • report: Doctor report to serialize

Returns:

  • error: Non-nil if JSON marshaling fails

func ResourcePct

func ResourcePct(used, total uint64) int

ResourcePct calculates the percentage of used versus total.

Parameters:

  • used: Used amount
  • total: Total capacity

Returns:

  • int: Percentage (0 if the total is 0)

func SeverityToStatus

func SeverityToStatus(sev sysinfo.Severity) string

SeverityToStatus converts a sysinfo.Severity to a doctor status string.

Parameters:

  • sev: Severity level from system resource evaluation

Returns:

  • string: Corresponding status constant (stats.StatusOK, stats.StatusWarning, stats.StatusError)

Types

type Report

type Report struct {
	Results  []Result `json:"results"`
	Warnings int      `json:"warnings"`
	Errors   int      `json:"errors"`
}

Report is the complete doctor output.

Fields:

  • Results: All individual check results
  • Warnings: Count of results with StatusWarning
  • Errors: Count of results with StatusError

type Result

type Result struct {
	Name     string `json:"name"`
	Category string `json:"category"`
	Status   string `json:"status"` // "ok", "warning", "error", "info"
	Message  string `json:"message"`
}

Result represents a single check outcome.

Fields:

  • Name: Machine-readable identifier for the check
  • Category: Grouping label (Structure, Quality, Plugin, etc.)
  • Status: One of stats.StatusOK, stats.StatusWarning, stats.StatusError, stats.StatusInfo
  • Message: Human-readable description of the outcome

Jump to

Keyboard shortcuts

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