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
16 changes: 9 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ All notable changes to this project will be documented in this file.

### Changed

* Monolith de-layering (Step 11a): the network concern (status, diagnostics,
and connectivity actions — 17 functions) and the fzf interactive pickers
(git log/branch, kill process/port, run snippet, recent files — 6 functions)
moved verbatim out of `terminal/launchers/mqlaunch.sh` into
`mqlaunch/lib/network.sh` and `mqlaunch/lib/fzf-pickers.sh`, sourced back into
the launcher's scope. No behavior change; the launcher drops ~310 lines and
each concern now has a named owner. Guarded by
* Monolith de-layering (Step 11a): three concerns moved verbatim out of
`terminal/launchers/mqlaunch.sh` into dedicated libraries sourced back into
the launcher's scope — the network concern (status/diagnostics/connectivity,
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
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.
* `semantic-memory-maintainer` renamed to `vector-store-maintainer` to avoid
Expand Down
1 change: 1 addition & 0 deletions docs/AUTHORITY_MAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +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) |

## Bridges

Expand Down
137 changes: 137 additions & 0 deletions mqlaunch/lib/diagnostics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#!/usr/bin/env bash
# mqlaunch diagnostics — version reporting, self-check, debug bundle, and
# release notes.
#
# 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
# launcher's ambient UI helpers (print_header/row/empty_row/print_footer/
# pause_enter) and $BASE_DIR. It defines no state of its own and changes no
# behavior — the functions are verbatim moves. Pure bash (no zsh builtins), so
# it carries a bash shebang and is covered by shellcheck.

# Gets repo version.
get_repo_version() {
local version_file="$BASE_DIR/VERSION"

if [[ -f "$version_file" ]]; then
head -n 1 "$version_file"
else
echo "unknown"
fi
}

# Shows version info.
show_version_info() {
print_header
row_bold "VERSION INFO"
empty_row

local version
version="$(get_repo_version)"
local launcher="$BASE_DIR/terminal/launchers/mqlaunch.sh"
local main_menu="$BASE_DIR/terminal/menus/mq-main-menu.sh"
local help_menu="$BASE_DIR/terminal/menus/mq-help-menu.sh"

row "Project: macos-scripts"
row "Version: $version"
row "Release stage: baseline"
row "Shell: zsh"
row "Project root: $BASE_DIR"
row "Launcher: $launcher"
row "Main menu: $main_menu"
row "Help module: $help_menu"

print_footer
pause_enter
}

# Runs self check.
run_self_check() {
print_header
row_bold "SELF-CHECK"
empty_row

local check_script="$BASE_DIR/tools/scripts/test-all.sh"

row "Running smoke checks..."
empty_row

if [[ ! -x "$check_script" ]]; then
echo "${C_ERR}Missing or non-executable:${C_RESET} $check_script"
print_footer
pause_enter
return 1
fi

"$check_script"
local rc=$?

echo
if [[ $rc -eq 0 ]]; then
echo "${C_OK}All smoke checks passed.${C_RESET}"
else
echo "${C_ERR}Smoke checks failed.${C_RESET}"
fi

print_footer
pause_enter
return $rc
}

# Runs debug bundle.
run_debug_bundle() {
print_header
row_bold "DEBUG BUNDLE"
empty_row

local bundle_script="$BASE_DIR/tools/scripts/create-debug-bundle.sh"

if [[ ! -x "$bundle_script" ]]; then
echo "${C_ERR}Missing or non-executable:${C_RESET} $bundle_script"
print_footer
pause_enter
return 1
fi

local outfile
outfile="$("$bundle_script")"
local rc=$?

echo
if [[ $rc -eq 0 ]]; then
echo "${C_OK}Debug bundle created:${C_RESET}"
echo " $outfile"
[[ -f "$outfile" ]] && open -R "$outfile" 2>/dev/null || true
else
echo "${C_ERR}Debug bundle failed.${C_RESET}"
fi

print_footer
pause_enter
return $rc
}

# Shows release notes.
show_release_notes() {
print_header
row_bold "RELEASE NOTES"
empty_row

local changelog="$BASE_DIR/CHANGELOG.md"

if [[ ! -f "$changelog" ]]; then
echo "${C_ERR}Missing:${C_RESET} $changelog"
print_footer
pause_enter
return 1
fi

if command -v bat >/dev/null 2>&1; then
bat --style=plain --paging=never "$changelog" | head -n 80
else
head -n 80 "$changelog"
fi

print_footer
pause_enter
}
135 changes: 9 additions & 126 deletions terminal/launchers/mqlaunch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1123,132 +1123,15 @@ open_tools_menu() {
fi
}

# Gets repo version.
get_repo_version() {
local version_file="$BASE_DIR/VERSION"

if [[ -f "$version_file" ]]; then
head -n 1 "$version_file"
else
echo "unknown"
fi
}

# Shows version info.
show_version_info() {
print_header
row_bold "VERSION INFO"
empty_row

local version
version="$(get_repo_version)"
local launcher="$BASE_DIR/terminal/launchers/mqlaunch.sh"
local main_menu="$BASE_DIR/terminal/menus/mq-main-menu.sh"
local help_menu="$BASE_DIR/terminal/menus/mq-help-menu.sh"

row "Project: macos-scripts"
row "Version: $version"
row "Release stage: baseline"
row "Shell: zsh"
row "Project root: $BASE_DIR"
row "Launcher: $launcher"
row "Main menu: $main_menu"
row "Help module: $help_menu"

print_footer
pause_enter
}

# Runs self check.
run_self_check() {
print_header
row_bold "SELF-CHECK"
empty_row

local check_script="$BASE_DIR/tools/scripts/test-all.sh"

row "Running smoke checks..."
empty_row

if [[ ! -x "$check_script" ]]; then
echo "${C_ERR}Missing or non-executable:${C_RESET} $check_script"
print_footer
pause_enter
return 1
fi

"$check_script"
local rc=$?

echo
if [[ $rc -eq 0 ]]; then
echo "${C_OK}All smoke checks passed.${C_RESET}"
else
echo "${C_ERR}Smoke checks failed.${C_RESET}"
fi

print_footer
pause_enter
return $rc
}

# Runs debug bundle.
run_debug_bundle() {
print_header
row_bold "DEBUG BUNDLE"
empty_row

local bundle_script="$BASE_DIR/tools/scripts/create-debug-bundle.sh"

if [[ ! -x "$bundle_script" ]]; then
echo "${C_ERR}Missing or non-executable:${C_RESET} $bundle_script"
print_footer
pause_enter
return 1
fi

local outfile
outfile="$("$bundle_script")"
local rc=$?

echo
if [[ $rc -eq 0 ]]; then
echo "${C_OK}Debug bundle created:${C_RESET}"
echo " $outfile"
[[ -f "$outfile" ]] && open -R "$outfile" 2>/dev/null || true
else
echo "${C_ERR}Debug bundle failed.${C_RESET}"
fi

print_footer
pause_enter
return $rc
}

# Shows release notes.
show_release_notes() {
print_header
row_bold "RELEASE NOTES"
empty_row

local changelog="$BASE_DIR/CHANGELOG.md"

if [[ ! -f "$changelog" ]]; then
echo "${C_ERR}Missing:${C_RESET} $changelog"
print_footer
pause_enter
return 1
fi

if command -v bat >/dev/null 2>&1; then
bat --style=plain --paging=never "$changelog" | head -n 80
else
head -n 80 "$changelog"
fi

print_footer
pause_enter
}
# Diagnostics — version reporting, self-check, debug bundle, and release notes
# — 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
source "$BASE_DIR/mqlaunch/lib/diagnostics.sh"
else
mq_debug "mqlaunch: diagnostics lib missing: mqlaunch/lib/diagnostics.sh"
fi

# Runs mqlogin.
run_mqlogin() {
Expand Down
1 change: 1 addition & 0 deletions tests/monolith-delayer-smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +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"
)

total=0
Expand Down
Loading