Skip to content

Add doctor diagnostics, install tooling, and ADF driver auto-resolution#46

Merged
reinauer merged 2 commits into
reinauer:mainfrom
tbdye:phase8/doctor-install-tooling
Jun 25, 2026
Merged

Add doctor diagnostics, install tooling, and ADF driver auto-resolution#46
reinauer merged 2 commits into
reinauer:mainfrom
tbdye:phase8/doctor-install-tooling

Conversation

@tbdye

@tbdye tbdye commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Summary

AmiFUSE currently requires users to manually install dependencies, diagnose missing components, and pass --driver flags for common ADF images. This PR adds a diagnostic/repair command (amifuse doctor) and platform-specific bootstrap scripts that get new users from zero to a working mount in one command. ADF floppy images now auto-resolve their filesystem handler without --driver.

What's New

amifuse doctor — standalone diagnostic command (extracted from fuse_fs.py into amifuse/doctor.py):

  • Detects FUSE backend across all platforms (macFUSE/FUSE-T/osxfuse, fusermount/libfuse, WinFSP with version check)
  • Tests machine68k in a subprocess so a segfault doesn't crash the doctor
  • Checks shell registration and PATH reachability on Windows
  • Color-coded human output by default, ASCII fallback on Windows cp1252 consoles
  • --json flag for CI/scripting — structured CheckResult output per check

amifuse doctor --fix — auto-repairs what it can:

  • Registers shell extensions, adds Scripts dir to user PATH (Windows, via HKCU registry)
  • Prints actionable instructions for issues that need manual intervention (FUSE install, machine68k-amifuse fork)
  • Never elevates privileges without user confirmation

Bootstrap scripts:

  • tools/install-windows.ps1 — detects Python/WinFSP via winget (manual URL fallback), creates venv at %LOCALAPPDATA%\amifuse\venv, installs machine68k-amifuse fork, hands off to amifuse doctor --fix
  • tools/install.sh — brew/apt/dnf detection, FUSE backend install, same venv strategy at ~/.local/share/amifuse/venv
  • Both scripts auto-detect repo checkouts (via pyproject.toml presence) and use pip install -e . instead of PyPI

Bundled FastFileSystem handler — ADF floppy images don't embed a filesystem driver (unlike HDF hard disk images). The Commodore FastFileSystem handler (~28KB, freely distributable) is bundled in amifuse/drivers/ and handles all standard ADF DOS types (DOS0–DOS7: OFS, FFS, and their international/dir-cache variants). This eliminates the need for users to source and specify --driver manually when mounting floppies. The .gitignore is updated to scope handler exclusion patterns to the repo root (where make download places them) so the bundled copy is tracked.

README — new "Quick install (recommended)" section with bootstrap scripts as the primary path, "From source" section for developers, and "Diagnosing Issues" section with doctor examples.

How It Works

Doctor architecture: Each check returns a CheckResult dataclass carrying status, message, optional fix_fn (callable), and optional fix_description (human-readable repair instruction). This separates execution from display — the same results render as color-coded text or JSON depending on the flag.

FUSE detection split: detect_fuse_backend() returns a dict of discovered backends for diagnostic display. The existing check_fuse_available() remains the mount-time guard (raises SystemExit). They query the same things but serve different callers.

Venv strategy: Bootstrap scripts use the active venv if one is detected, otherwise create a dedicated venv. They never pass --break-system-packages.

WinFSP version check: Uses GetFileVersionInfoW + VerQueryValueW on winfsp-x64.dll to enforce >= 2.0.

machine68k on Windows: The PyPI machine68k package segfaults; both the bootstrap script and doctor explicitly install/check for the machine68k-amifuse fork.

Files Changed

Status File Description
New amifuse/doctor.py Doctor command, CheckResult, --fix, --json
New amifuse/drivers/FastFileSystem Bundled handler for ADF auto-resolution
New tools/install-windows.ps1 Windows bootstrap script
New tools/install.sh macOS/Linux bootstrap script
New tests/unit/test_doctor.py 66 tests for doctor checks, fix mode, JSON output
Modified amifuse/fuse_fs.py Doctor extraction, ADF auto-resolution, dynamic __version__
Modified amifuse/platform.py detect_fuse_backend(), driver resolution functions
Modified pyproject.toml package-data for bundled amifuse/drivers/*
Modified README.md Quick install, from-source, and diagnosing-issues sections
Modified .gitignore Scope handler patterns to repo root
Modified tests/unit/test_cli_help.py Doctor JSON schema assertions
Modified tests/unit/test_fuse_fs.py Updated for doctor extraction and ADF auto-resolution

Test Plan

Automated (all passing):

  • 66 unit tests in test_doctor.py — all check types, --fix mode, JSON output serialization, edge cases (missing deps, partial installs, segfaulting machine68k)
  • test_cli_help.py updated with doctor subcommand and JSON schema assertions
  • test_fuse_fs.py updated for doctor delegation and ADF auto-resolution
  • Full existing test suite remains green

Manual validation performed:

  • Clean Windows slate -> install-windows.ps1 -> all doctor checks green
  • WinFSP installed via winget with elevation prompt, venv created, editable install, machine68k-amifuse fork, doctor --fix registered shell extensions
  • Partial install recovery: removed WinFSP, re-ran script, only WinFSP step executed
  • doctor --json output validated with Python json.loads()
  • ASCII fallback verified on Windows cp1252 console (Unicode symbols -> ASCII +/X)
  • ADF mount without --driver flag using bundled FastFileSystem handler

@tbdye tbdye marked this pull request as ready for review April 27, 2026 04:48
Replace the proprietary Hyperion binary with a 0-byte placeholder.
Add size checks in driver auto-resolution and doctor so ADF mounts
gracefully report "driver not found" rather than crashing on load.
@reinauer reinauer merged commit e086091 into reinauer:main Jun 25, 2026
18 checks passed
@tbdye tbdye deleted the phase8/doctor-install-tooling branch June 29, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants