Documentation
¶
Overview ¶
Package core provides error constructors, output formatters, sanitizers, fix logic, and types for the drift command. Subcommand cmd/run.go imports core for all drift analysis and reporting logic.
Index ¶
- func FixMissingFile(filename string) error
- func FixStaleness(cmd *cobra.Command, ctx *entity.Context) error
- func FormatCheckName(name drift.CheckName) string
- func OutputDriftJSON(cmd *cobra.Command, report *drift.Report) error
- func OutputDriftText(cmd *cobra.Command, report *drift.Report) error
- type FixResult
- type JSONOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FixMissingFile ¶
FixMissingFile creates a missing required context file from the template.
Parameters:
- filename: Name of the file to create (e.g., "CONSTITUTION.md")
Returns:
- error: Non-nil if the template is not found or file write fails
func FixStaleness ¶
FixStaleness archives completed tasks from TASKS.md.
Moves completed tasks to .context/archive/tasks-YYYY-MM-DD.md and removes them from the Completed section in TASKS.md.
Parameters:
- cmd: Cobra command for output messages
- ctx: Loaded context containing the files
Returns:
- error: Non-nil if file operations fail
func FormatCheckName ¶
FormatCheckName converts internal check identifiers to human-readable names.
Parameters:
- name: Internal check identifier (e.g., "path_references", "staleness_check")
Returns:
- string: Human-readable description of the check, or the original name if unknown
func OutputDriftJSON ¶
OutputDriftJSON writes the drift report as pretty-printed JSON.
Parameters:
- cmd: Cobra command for output stream
- report: Drift detection report to serialize
Returns:
- error: Non-nil if JSON encoding fails
func OutputDriftText ¶
OutputDriftText writes the drift report as formatted text with icons.
Output is grouped into violations, warnings (by type), and passed checks. Includes a summary status line at the end.
Parameters:
- cmd: Cobra command for output stream
- report: Drift detection report to display
Returns:
- error: Non-nil if violations were detected
Types ¶
type FixResult ¶
FixResult tracks fixes applied during drift fix.
Fields:
- Fixed: Number of issues successfully fixed
- Skipped: Number of issues skipped (not auto-fixable)
- Errors: Error messages from failed fix attempts
func ApplyFixes ¶
ApplyFixes attempts to auto-fix issues in the drift report.
Currently, supports fixing:
- staleness: Archives completed tasks from TASKS.md
- missing_file: Creates missing required files from templates
Parameters:
- cmd: Cobra command for output messages
- ctx: Loaded context
- report: Drift report containing issues to fix
Returns:
- *FixResult: Summary of fixes applied
type JSONOutput ¶
type JSONOutput struct {
Timestamp string `json:"timestamp"`
Status drift.StatusType `json:"status"`
Warnings []drift.Issue `json:"warnings"`
Violations []drift.Issue `json:"violations"`
Passed []drift.CheckName `json:"passed"`
}
JSONOutput represents the JSON structure for machine-readable drift output.
Fields:
- Timestamp: RFC3339-formatted UTC time when the report was generated
- Status: Overall drift status ("ok", "warning", or "violation")
- Warnings: Issues that should be addressed but don't block
- Violations: Constitution violations that must be fixed
- Passed: Names of checks that passed successfully