Class: Harnex::Doctor
- Inherits:
-
Object
- Object
- Harnex::Doctor
- Defined in:
- lib/harnex/commands/doctor.rb
Constant Summary collapse
- MIN_CODEX_VERSION =
Gem::Version.new("0.128.0")
- MIN_PI_VERSION =
Harnex::Adapters::Pi::MIN_RPC_VERSION
- SUPPORTED_ADAPTERS =
%w[codex pi].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv = []) ⇒ Doctor
constructor
A new instance of Doctor.
- #run ⇒ Object
Constructor Details
#initialize(argv = []) ⇒ Doctor
Returns a new instance of Doctor.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/harnex/commands/doctor.rb', line 43 def initialize(argv = []) @argv = argv.dup @options = { adapters: [], sweep: false, prune: false, dry_run: false, help: false } end |
Class Method Details
.usage ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/harnex/commands/doctor.rb', line 10 def self.usage <<~TEXT Usage: harnex doctor [--adapter codex|pi|all] [--sweep] [--prune [--dry-run]] Runs static preflight checks for harnex adapter dependencies. Codex is checked by default for backwards compatibility; select Pi explicitly after installing or upgrading it. Options: --adapter NAME Check codex, pi, or all (repeatable; default: codex) --sweep Include a read-only report of harnex/tmux session drift --prune Apply bounded harnex events/output/receipt retention pruning --dry-run Preview --prune candidates without deleting -h, --help Show this help Common patterns: harnex doctor harnex doctor --adapter pi harnex doctor --adapter all --sweep harnex doctor --prune --dry-run harnex doctor --prune harnex doctor --help Gotchas: doctor validates local adapter prerequisites; it does not start sessions. Pi RPC requires >= #{MIN_PI_VERSION} so `agent_settled` is available. --sweep is diagnostic only; it does not stop sessions or remove files. --dry-run must be paired with --prune. Run it after installing or upgrading a selected agent CLI. TEXT end |
Instance Method Details
#run ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/harnex/commands/doctor.rb', line 54 def run parser.parse!(@argv) if @options[:help] puts self.class.usage return 0 end checks = selected_adapters.map { |name| name == "pi" ? check_pi : check_codex } retention = retention_payload summary = { ok: checks.all? { |c| c[:ok] } && retention.fetch(:ok, true), checks: checks, retention: retention } summary[:sweep] = sweep_payload if @options[:sweep] puts JSON.generate(summary) summary[:ok] ? 0 : 1 end |