Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/AUTHORITY_MAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
111 changes: 109 additions & 2 deletions mqlaunch/lib/diagnostics.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
}
112 changes: 3 additions & 109 deletions terminal/launchers/mqlaunch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/monolith-delayer-smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading