Class: LcpRuby::Tasks::Doctor
- Inherits:
-
Object
- Object
- LcpRuby::Tasks::Doctor
- Defined in:
- lib/lcp_ruby/tasks/doctor.rb
Overview
Diagnostic checker for an LCP-installed host app. Four sections:
-
Install manifest replay — ‘tmp/lcp_ruby/install_manifest.json` from `lcp new`
-
Feature state — registry × ‘config/lcp_ruby/models/`
-
Environment — BUNDLE_GEMFILE leak, missing .envrc
-
Seed hygiene — ‘db/seeds.rb` + `LcpRuby::Current.user`
-
Agent affordances — CLAUDE.md/AGENTS.md managed block, lcp-* skills
Severity: :error (blocks install/runs), :warning (degraded), :info. Output formats: text (default), json, summary. Exit codes: 0 on no-error, 1 otherwise; ‘EXIT_ON=warning` upgrades warnings to errors.
JSON output schema (FORMAT=json) — stable for CI consumption:
{
"findings": [
{
"severity": "error" | "warning" | "info",
"section": "install_manifest" | "feature_state" |
"environment" | "seeds_hygiene" |
"agent_affordances",
"message": String, // human-readable description
"hint": String | null // optional remediation step
},
…
],
"summary": { "error": Integer, "warning": Integer, "info": Integer }
}
Stability contract: section names are stable, severity values are stable. New sections may be added; existing ones won’t be renamed without a manifest_version bump. Severity strings are JSON-friendly (the internal symbol form is converted at emit time).
Defined Under Namespace
Classes: Finding
Constant Summary collapse
- VALID_FORMATS =
%i[text json summary].freeze
- VALID_EXIT_ONS =
%i[error warning].freeze
Instance Method Summary collapse
- #exit_code ⇒ Object
-
#initialize(destination_root: Dir.pwd, format: :text, exit_on: :error, output: $stdout) ⇒ Doctor
constructor
A new instance of Doctor.
- #run ⇒ Object
Constructor Details
#initialize(destination_root: Dir.pwd, format: :text, exit_on: :error, output: $stdout) ⇒ Doctor
Returns a new instance of Doctor.
48 49 50 51 52 53 54 55 |
# File 'lib/lcp_ruby/tasks/doctor.rb', line 48 def initialize(destination_root: Dir.pwd, format: :text, exit_on: :error, output: $stdout) @destination_root = destination_root @format = format.to_sym @exit_on = exit_on.to_sym @output = output @findings = [] end |
Instance Method Details
#exit_code ⇒ Object
67 68 69 70 |
# File 'lib/lcp_ruby/tasks/doctor.rb', line 67 def exit_code threshold = @exit_on == :warning ? %i[error warning] : %i[error] @findings.any? { |f| threshold.include?(f.severity) } ? 1 : 0 end |
#run ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/lcp_ruby/tasks/doctor.rb', line 57 def run check_install_manifest check_feature_state check_environment check_seeds_hygiene check_agent_affordances emit exit_code end |