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

### Changed

* Monolith de-layering (Step 11a): four concerns moved verbatim out of
* Monolith de-layering (Step 11a): five 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`), diagnostics (version reporting, self-check,
debug bundle, release notes, plus the system check, 6 functions →
`mqlaunch/lib/diagnostics.sh`), and the git & release menu launchers
(2 functions → `mqlaunch/lib/git-menus.sh`). No behavior change; the launcher
drops ~600 lines and each concern now has a named owner. Guarded by
`mqlaunch/lib/diagnostics.sh`), the git & release menu launchers
(2 functions → `mqlaunch/lib/git-menus.sh`), and the GitHub repo picker
(1 function → `mqlaunch/lib/repo-picker.sh`). No behavior change; the launcher
drops ~720 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 @@ -74,6 +74,7 @@ Reached through other live paths:
| `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/system-check de-layered out of the monolith (Step 11a) |
| `mqlaunch/lib/git-menus.sh` | `terminal/launchers/mqlaunch.sh` (sourced) — git & release menu launchers de-layered out of the monolith (Step 11a) |
| `mqlaunch/lib/repo-picker.sh` | `terminal/launchers/mqlaunch.sh` (sourced) — GitHub repo picker de-layered out of the monolith (Step 11a) |

## Bridges

Expand Down
131 changes: 131 additions & 0 deletions mqlaunch/lib/repo-picker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#!/usr/bin/env bash
# mqlaunch GitHub repo picker — fzf over `gh repo list`, then an action menu to
# open in the browser, cd into the repo, or clone to ~/repos (optionally opening
# in VS Code or Finder).
#
# 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/row_bold/empty_row/
# print_footer/pause_enter) and on $HOME/$SHELL. Requires gh and fzf at runtime
# (both checked, with an install hint when missing). No behavior change — the
# function body is a verbatim move (the launcher's mislabeled "# Opens repo
# browser." comment is corrected here). Pure bash, covered by shellcheck.

# Picks a GitHub repo via fzf and runs an open/clone action on it.
run_github_repo_picker() {
local fzf_bin gh_bin selected action clone_dir

fzf_bin="$(command -v fzf 2>/dev/null || true)"
gh_bin="$(command -v gh 2>/dev/null || true)"

print_header

if [[ -z "$gh_bin" ]]; then
row_bold "GITHUB REPO PICKER"
empty_row
row "gh (GitHub CLI) is not installed."
row "Install: brew install gh"
print_footer
pause_enter
return 1
fi

if [[ -z "$fzf_bin" ]]; then
row_bold "GITHUB REPO PICKER"
empty_row
row "fzf is not installed."
row "Install: brew install fzf"
print_footer
pause_enter
return 1
fi

row_bold "GITHUB REPO PICKER"
empty_row
row "Hämtar dina repos från GitHub..."
print_footer

selected="$(
"$gh_bin" repo list --limit 1000 --json nameWithOwner --jq '.[].nameWithOwner' 2>/dev/null \
| "$fzf_bin" \
--reverse \
--border \
--header='Välj ett GitHub-repo (ESC = avbryt)' \
--prompt='repo > ' \
--height=70%
)"

[[ -z "$selected" ]] && return 0

action="$(printf '%s\n' \
"Öppna i webbläsaren" \
"Gå till repo i terminalen" \
"Klona och hoppa in i terminalen" \
"Klona till ~/repos" \
"Klona till ~/repos och öppna i VS Code" \
"Klona till ~/repos och öppna i Finder" \
| "$fzf_bin" \
--reverse \
--border \
--header="$selected" \
--prompt='åtgärd > ' \
--height=40%
)"

[[ -z "$action" ]] && return 0

clone_dir="$HOME/repos"
mkdir -p "$clone_dir"
local repo_name repo_dir home_repo_dir
repo_name="$(basename "$selected")"
repo_dir="$clone_dir/$repo_name"
home_repo_dir="$HOME/$repo_name"

case "$action" in
"Öppna i webbläsaren")
"$gh_bin" repo view "$selected" --web
print_footer
pause_enter
;;
"Gå till repo i terminalen")
if [[ -d "$home_repo_dir" ]]; then
repo_dir="$home_repo_dir"
elif [[ ! -d "$repo_dir" ]]; then
printf "Repo saknas lokalt: %s\nKlona först med 'Klona och hoppa in i terminalen'.\n" "$home_repo_dir"
pause_enter
return 0
fi
cd "$repo_dir" || return 1
clear
printf "📁 %s\n" "$repo_dir"
exec "$SHELL" -l
;;
"Klona och hoppa in i terminalen")
if [[ ! -d "$repo_dir" ]]; then
"$gh_bin" repo clone "$selected" "$repo_dir" 2>&1 | tail -3
fi
cd "$repo_dir" || return 1
clear
printf "📁 %s\n" "$repo_dir"
exec "$SHELL" -l
;;
"Klona till ~/repos")
"$gh_bin" repo clone "$selected" "$repo_dir" 2>&1 | tail -3
row "Klonat till $repo_dir"
print_footer
pause_enter
;;
"Klona till ~/repos och öppna i VS Code")
"$gh_bin" repo clone "$selected" "$repo_dir" 2>&1 | tail -3
code "$repo_dir" 2>/dev/null || open -a "Visual Studio Code" "$repo_dir" 2>/dev/null
print_footer
pause_enter
;;
"Klona till ~/repos och öppna i Finder")
"$gh_bin" repo clone "$selected" "$repo_dir" 2>&1 | tail -3
open "$repo_dir"
print_footer
pause_enter
;;
esac
}
127 changes: 9 additions & 118 deletions terminal/launchers/mqlaunch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -379,124 +379,15 @@ show_date_time() {
pause_enter
}

# Opens repo browser.
run_github_repo_picker() {
local fzf_bin gh_bin selected action clone_dir

fzf_bin="$(command -v fzf 2>/dev/null || true)"
gh_bin="$(command -v gh 2>/dev/null || true)"

print_header

if [[ -z "$gh_bin" ]]; then
row_bold "GITHUB REPO PICKER"
empty_row
row "gh (GitHub CLI) is not installed."
row "Install: brew install gh"
print_footer
pause_enter
return 1
fi

if [[ -z "$fzf_bin" ]]; then
row_bold "GITHUB REPO PICKER"
empty_row
row "fzf is not installed."
row "Install: brew install fzf"
print_footer
pause_enter
return 1
fi

row_bold "GITHUB REPO PICKER"
empty_row
row "Hämtar dina repos från GitHub..."
print_footer

selected="$(
"$gh_bin" repo list --limit 1000 --json nameWithOwner --jq '.[].nameWithOwner' 2>/dev/null \
| "$fzf_bin" \
--reverse \
--border \
--header='Välj ett GitHub-repo (ESC = avbryt)' \
--prompt='repo > ' \
--height=70%
)"

[[ -z "$selected" ]] && return 0

action="$(printf '%s\n' \
"Öppna i webbläsaren" \
"Gå till repo i terminalen" \
"Klona och hoppa in i terminalen" \
"Klona till ~/repos" \
"Klona till ~/repos och öppna i VS Code" \
"Klona till ~/repos och öppna i Finder" \
| "$fzf_bin" \
--reverse \
--border \
--header="$selected" \
--prompt='åtgärd > ' \
--height=40%
)"

[[ -z "$action" ]] && return 0

clone_dir="$HOME/repos"
mkdir -p "$clone_dir"
local repo_name repo_dir home_repo_dir
repo_name="$(basename "$selected")"
repo_dir="$clone_dir/$repo_name"
home_repo_dir="$HOME/$repo_name"

case "$action" in
"Öppna i webbläsaren")
"$gh_bin" repo view "$selected" --web
print_footer
pause_enter
;;
"Gå till repo i terminalen")
if [[ -d "$home_repo_dir" ]]; then
repo_dir="$home_repo_dir"
elif [[ ! -d "$repo_dir" ]]; then
printf "Repo saknas lokalt: %s\nKlona först med 'Klona och hoppa in i terminalen'.\n" "$home_repo_dir"
pause_enter
return 0
fi
cd "$repo_dir" || return 1
clear
printf "📁 %s\n" "$repo_dir"
exec "$SHELL" -l
;;
"Klona och hoppa in i terminalen")
if [[ ! -d "$repo_dir" ]]; then
"$gh_bin" repo clone "$selected" "$repo_dir" 2>&1 | tail -3
fi
cd "$repo_dir" || return 1
clear
printf "📁 %s\n" "$repo_dir"
exec "$SHELL" -l
;;
"Klona till ~/repos")
"$gh_bin" repo clone "$selected" "$repo_dir" 2>&1 | tail -3
row "Klonat till $repo_dir"
print_footer
pause_enter
;;
"Klona till ~/repos och öppna i VS Code")
"$gh_bin" repo clone "$selected" "$repo_dir" 2>&1 | tail -3
code "$repo_dir" 2>/dev/null || open -a "Visual Studio Code" "$repo_dir" 2>/dev/null
print_footer
pause_enter
;;
"Klona till ~/repos och öppna i Finder")
"$gh_bin" repo clone "$selected" "$repo_dir" 2>&1 | tail -3
open "$repo_dir"
print_footer
pause_enter
;;
esac
}
# GitHub repo picker (fzf over `gh repo list` + open/clone actions) lives in a
# dedicated library (Step 11a monolith de-layering, audit P4). Sourced into this
# scope so it keeps using the ambient UI helpers and $HOME/$SHELL; no behavior
# change — a verbatim move.
if [[ -f "$BASE_DIR/mqlaunch/lib/repo-picker.sh" ]]; then
source "$BASE_DIR/mqlaunch/lib/repo-picker.sh"
else
mq_debug "mqlaunch: repo picker lib missing: mqlaunch/lib/repo-picker.sh"
fi

# fzf: bläddra och kopiera sparade AI-prompts från mqobsidian/_prompts/
prompts_pick() {
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 @@ -18,6 +18,7 @@ CONCERNS=(
"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 system_check"
"mqlaunch/lib/git-menus.sh : open_git_menu open_release_menu"
"mqlaunch/lib/repo-picker.sh : run_github_repo_picker"
)

total=0
Expand Down
Loading