diff --git a/CHANGELOG.md b/CHANGELOG.md index d639484..6cc57c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,8 +26,8 @@ All notable changes to this project will be documented in this file. 17 functions → `mqlaunch/lib/network.sh`), the fzf interactive pickers (git log/branch, kill process/port, run snippet, recent files, 6 functions → `mqlaunch/lib/fzf-pickers.sh`), and diagnostics (version reporting, - self-check, debug bundle, release notes, 5 functions → - `mqlaunch/lib/diagnostics.sh`). No behavior change; the launcher drops ~430 + self-check, debug bundle, release notes, plus the system check, 6 functions → + `mqlaunch/lib/diagnostics.sh`). No behavior change; the launcher drops ~530 lines and each concern now has a named owner. Guarded by `tests/monolith-delayer-smoke.sh`, a table-driven check that fails if any extracted function is redefined in the monolith or a lib source is dropped. diff --git a/docs/AUTHORITY_MAP.md b/docs/AUTHORITY_MAP.md index e0afdc3..28343c9 100644 --- a/docs/AUTHORITY_MAP.md +++ b/docs/AUTHORITY_MAP.md @@ -72,7 +72,7 @@ Reached through other live paths: | `mqlaunch/lib/mqobsidian/*` | `terminal/menus/mq-obsidian-menu.sh` | | `mqlaunch/lib/network.sh` | `terminal/launchers/mqlaunch.sh` (sourced) — network concern de-layered out of the monolith (Step 11a) | | `mqlaunch/lib/fzf-pickers.sh` | `terminal/launchers/mqlaunch.sh` (sourced) — fzf interactive pickers de-layered out of the monolith (Step 11a) | -| `mqlaunch/lib/diagnostics.sh` | `terminal/launchers/mqlaunch.sh` (sourced) — version/self-check/debug-bundle/release-notes de-layered out of the monolith (Step 11a) | +| `mqlaunch/lib/diagnostics.sh` | `terminal/launchers/mqlaunch.sh` (sourced) — version/self-check/debug-bundle/release-notes/system-check de-layered out of the monolith (Step 11a) | ## Bridges diff --git a/mqlaunch/lib/diagnostics.sh b/mqlaunch/lib/diagnostics.sh index c25dd1f..1587ce0 100755 --- a/mqlaunch/lib/diagnostics.sh +++ b/mqlaunch/lib/diagnostics.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# mqlaunch diagnostics — version reporting, self-check, debug bundle, and -# release notes. +# mqlaunch diagnostics — version reporting, self-check, debug bundle, release +# notes, and the system check. # # Extracted from terminal/launchers/mqlaunch.sh as part of Step 11a (monolith # de-layering, audit P4). Sourced into the launcher's scope, so it relies on the @@ -135,3 +135,110 @@ show_release_notes() { print_footer pause_enter } + +# Coordinates system check behavior. +system_check() { + local prompt_count="0" + local resolved_prompt_dir="" + local ai_status="" + local link_target="" + local active_cmd="" + + resolved_prompt_dir="$(resolve_prompt_dir 2>/dev/null || true)" + ai_status="$(resolve_ai_status)" + + if [[ -n "$resolved_prompt_dir" ]]; then + prompt_count="$(find "$resolved_prompt_dir" -maxdepth 1 -type f 2>/dev/null | wc -l | tr -d ' ')" + fi + + if [[ -L "$BIN_LINK" ]]; then + link_target="$(readlink "$BIN_LINK" 2>/dev/null || true)" + fi + + active_cmd="$(command -v mqlaunch 2>/dev/null || true)" + + print_header + row "SYSTEM CHECK" + empty_row + + if [[ -d "$BASE_DIR" ]]; then + row "[OK] Base dir found" + else + row "[FAIL] Base dir missing" + fi + + if [[ -x "$MQ_SCRIPT" ]]; then + row "[OK] mqlaunch.sh executable" + elif [[ -e "$MQ_SCRIPT" ]]; then + row "[FAIL] mqlaunch.sh found but not executable" + else + row "[FAIL] mqlaunch.sh missing" + fi + + case "$ai_status" in + OK) + row "[OK] AI backend executable" + ;; + FOUND_NOT_EXECUTABLE) + row "[FAIL] AI backend found but not executable" + ;; + MISSING) + row "[FAIL] AI backend missing" + ;; + esac + + if [[ -n "$resolved_prompt_dir" ]]; then + row "[OK] Prompt dir found" + row " $resolved_prompt_dir" + else + row "[FAIL] Prompt dir missing" + fi + + if [[ -f "$TERMINAL_GUIDE_HTML" ]]; then + row "[OK] Terminal guide local file found" + else + row "[FAIL] Terminal guide local file missing" + fi + + if [[ -L "$BIN_LINK" ]]; then + if [[ "$link_target" == "$BASE_DIR/bin/mqlaunch" || "$link_target" == "$MQ_SCRIPT" ]]; then + row "[OK] ~/bin/mqlaunch symlink correct" + else + row "[FAIL] ~/bin/mqlaunch points elsewhere" + row " $link_target" + fi + elif [[ -e "$BIN_LINK" ]]; then + row "[FAIL] ~/bin/mqlaunch exists but is not a symlink" + else + row "[FAIL] ~/bin/mqlaunch missing" + fi + + if [[ -n "$active_cmd" ]]; then + row "[OK] mqlaunch command resolves" + row " $active_cmd" + else + row "[FAIL] mqlaunch command not found in PATH" + fi + + if command -v git >/dev/null 2>&1; then + row "[OK] git available" + else + row "[FAIL] git missing" + fi + + if command -v open >/dev/null 2>&1; then + row "[OK] open command available" + else + row "[FAIL] open command missing" + fi + + if command -v pbcopy >/dev/null 2>&1; then + row "[OK] pbcopy available" + else + row "[FAIL] pbcopy missing" + fi + + row "Prompt files: $prompt_count" + print_footer + pause_enter +} diff --git a/terminal/launchers/mqlaunch.sh b/terminal/launchers/mqlaunch.sh index 51d5076..487f211 100755 --- a/terminal/launchers/mqlaunch.sh +++ b/terminal/launchers/mqlaunch.sh @@ -604,113 +604,6 @@ open_terminal_guide() { fi } -# Coordinates system check behavior. -system_check() { - local prompt_count="0" - local resolved_prompt_dir="" - local ai_status="" - local link_target="" - local active_cmd="" - - resolved_prompt_dir="$(resolve_prompt_dir 2>/dev/null || true)" - ai_status="$(resolve_ai_status)" - - if [[ -n "$resolved_prompt_dir" ]]; then - prompt_count="$(find "$resolved_prompt_dir" -maxdepth 1 -type f 2>/dev/null | wc -l | tr -d ' ')" - fi - - if [[ -L "$BIN_LINK" ]]; then - link_target="$(readlink "$BIN_LINK" 2>/dev/null || true)" - fi - - active_cmd="$(command -v mqlaunch 2>/dev/null || true)" - - print_header - row "SYSTEM CHECK" - empty_row - - if [[ -d "$BASE_DIR" ]]; then - row "[OK] Base dir found" - else - row "[FAIL] Base dir missing" - fi - - if [[ -x "$MQ_SCRIPT" ]]; then - row "[OK] mqlaunch.sh executable" - elif [[ -e "$MQ_SCRIPT" ]]; then - row "[FAIL] mqlaunch.sh found but not executable" - else - row "[FAIL] mqlaunch.sh missing" - fi - - case "$ai_status" in - OK) - row "[OK] AI backend executable" - ;; - FOUND_NOT_EXECUTABLE) - row "[FAIL] AI backend found but not executable" - ;; - MISSING) - row "[FAIL] AI backend missing" - ;; - esac - - if [[ -n "$resolved_prompt_dir" ]]; then - row "[OK] Prompt dir found" - row " $resolved_prompt_dir" - else - row "[FAIL] Prompt dir missing" - fi - - if [[ -f "$TERMINAL_GUIDE_HTML" ]]; then - row "[OK] Terminal guide local file found" - else - row "[FAIL] Terminal guide local file missing" - fi - - if [[ -L "$BIN_LINK" ]]; then - if [[ "$link_target" == "$BASE_DIR/bin/mqlaunch" || "$link_target" == "$MQ_SCRIPT" ]]; then - row "[OK] ~/bin/mqlaunch symlink correct" - else - row "[FAIL] ~/bin/mqlaunch points elsewhere" - row " $link_target" - fi - elif [[ -e "$BIN_LINK" ]]; then - row "[FAIL] ~/bin/mqlaunch exists but is not a symlink" - else - row "[FAIL] ~/bin/mqlaunch missing" - fi - - if [[ -n "$active_cmd" ]]; then - row "[OK] mqlaunch command resolves" - row " $active_cmd" - else - row "[FAIL] mqlaunch command not found in PATH" - fi - - if command -v git >/dev/null 2>&1; then - row "[OK] git available" - else - row "[FAIL] git missing" - fi - - if command -v open >/dev/null 2>&1; then - row "[OK] open command available" - else - row "[FAIL] open command missing" - fi - - if command -v pbcopy >/dev/null 2>&1; then - row "[OK] pbcopy available" - else - row "[FAIL] pbcopy missing" - fi - - row "Prompt files: $prompt_count" - print_footer - pause_enter -} - # Opens downloads folder. open_downloads_folder() { open_folder_screen "OPEN DOWNLOADS FOLDER" "$HOME/Downloads" "Downloads folder missing:" @@ -1123,8 +1016,9 @@ open_tools_menu() { fi } -# Diagnostics — version reporting, self-check, debug bundle, and release notes -# — live in a dedicated library (Step 11a monolith de-layering, audit P4). +# Diagnostics — version reporting, self-check, debug bundle, release notes, and +# the system check — live in a dedicated library (Step 11a monolith de-layering, +# audit P4). # Sourced into this scope so they keep using the ambient UI helpers and # $BASE_DIR; no behavior change — the functions are verbatim moves. if [[ -f "$BASE_DIR/mqlaunch/lib/diagnostics.sh" ]]; then diff --git a/tests/monolith-delayer-smoke.sh b/tests/monolith-delayer-smoke.sh index d27802e..7caa5ff 100755 --- a/tests/monolith-delayer-smoke.sh +++ b/tests/monolith-delayer-smoke.sh @@ -16,7 +16,7 @@ fail() { printf '[FAIL] %s\n' "$1" >&2; exit 1; } CONCERNS=( "mqlaunch/lib/network.sh : network_default_interface network_service_name network_interface_ip network_dns_server network_gateway network_ssid network_ping_ms network_value network_report copy_network_info open_network_settings ping_test show_dns_gateway run_network_pulse run_network_ghost run_network_quality show_network_info" "mqlaunch/lib/fzf-pickers.sh : fzf_git_log fzf_git_branch fzf_kill_process fzf_kill_port fzf_run_snippet fzf_recent_files" - "mqlaunch/lib/diagnostics.sh : get_repo_version show_version_info run_self_check run_debug_bundle show_release_notes" + "mqlaunch/lib/diagnostics.sh : get_repo_version show_version_info run_self_check run_debug_bundle show_release_notes system_check" ) total=0