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
8 changes: 8 additions & 0 deletions mqlaunch/lib/mqobsidian/doctor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
# Health check for the mqobsidian consumer chain. Read-only — NEVER opens
# anything. Depends on resolve.sh, manifest.sh, errors.sh.

# Coordinates doc ok behavior.
_doc_ok() { printf '\033[0;32m[OK]\033[0m %s\n' "$*"; }
# Coordinates doc missing behavior.
_doc_missing() { printf '\033[0;31m[MISSING]\033[0m %s\n' "$*"; }
# Coordinates doc invalid behavior.
_doc_invalid() { printf '\033[0;33m[INVALID]\033[0m %s\n' "$*"; }

# Coordinates doctor mqobsidian root behavior.
doctor_mqobsidian_root() {
local dir
dir="$(resolve_mqobsidian_dir)"
Expand All @@ -26,6 +30,7 @@ doctor_mqobsidian_root() {
fi
}

# Coordinates doctor mqobsidian manifest behavior.
doctor_mqobsidian_manifest() {
local mf
mf="$(get_mqobsidian_manifest_path)"
Expand All @@ -40,6 +45,7 @@ doctor_mqobsidian_manifest() {
_doc_ok "manifest found: $mf"
}

# Coordinates doctor mqobsidian views behavior.
doctor_mqobsidian_views() {
local root key rel type path status=0
root="$(resolve_mqobsidian_dir)"
Expand All @@ -57,6 +63,7 @@ doctor_mqobsidian_views() {
return $status
}

# Coordinates doctor mqobsidian open command behavior.
doctor_mqobsidian_open_command() {
if command -v "${MQOBS_OPENER:-open}" >/dev/null 2>&1; then
_doc_ok "opener available: ${MQOBS_OPENER:-open}"
Expand All @@ -66,6 +73,7 @@ doctor_mqobsidian_open_command() {
fi
}

# Runs mqobsidian doctor.
run_mqobsidian_doctor() {
local rc=0
doctor_mqobsidian_root || rc=1
Expand Down
3 changes: 3 additions & 0 deletions mqlaunch/lib/mqobsidian/errors.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env bash
# mqobsidian consumer — consistent messaging to stderr. Read-only.

# Coordinates mqobsidian error behavior.
mqobsidian_error() { printf '\033[0;31m[mqobsidian][error]\033[0m %s\n' "$*" >&2; }
# Coordinates mqobsidian warn behavior.
mqobsidian_warn() { printf '\033[0;33m[mqobsidian][warn]\033[0m %s\n' "$*" >&2; }
# Coordinates mqobsidian info behavior.
mqobsidian_info() { printf '\033[0;37m[mqobsidian]\033[0m %s\n' "$*" >&2; }
5 changes: 5 additions & 0 deletions mqlaunch/lib/mqobsidian/manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@
# read-only. The manifest is the single source for supported views. Depends on
# errors.sh.

# Gets mqobsidian manifest path.
get_mqobsidian_manifest_path() {
local dir
dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../config/mqobsidian" && pwd)"
printf '%s\n' "$dir/views.json"
}

# Coordinates list supported views behavior.
list_supported_views() {
local mf
mf="$(get_mqobsidian_manifest_path)"
jq -r '.[].key' "$mf"
}

# Resolves view relative path.
resolve_view_relative_path() {
local key="$1" mf out
mf="$(get_mqobsidian_manifest_path)"
Expand All @@ -26,6 +29,7 @@ resolve_view_relative_path() {
printf '%s\n' "$out"
}

# Resolves view type.
resolve_view_type() {
local key="$1" mf out
mf="$(get_mqobsidian_manifest_path)"
Expand All @@ -37,6 +41,7 @@ resolve_view_type() {
printf '%s\n' "$out"
}

# Resolves view label.
resolve_view_label() {
local key="$1" mf
mf="$(get_mqobsidian_manifest_path)"
Expand Down
3 changes: 3 additions & 0 deletions mqlaunch/lib/mqobsidian/open.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
# Open a manifest-defined target. Read-only navigation only. Depends on
# resolve.sh, manifest.sh, errors.sh.

# Builds view absolute path for later command execution.
build_view_absolute_path() {
local key="$1" root rel
root="$(assert_mqobsidian_dir)" || return 1
rel="$(resolve_view_relative_path "$key")" || return 1
printf '%s/%s\n' "$root" "$rel"
}

# Coordinates assert view target exists behavior.
assert_view_target_exists() {
local key="$1" path type
path="$(build_view_absolute_path "$key")" || return 1
Expand All @@ -31,6 +33,7 @@ open_mqobsidian_path() {
"${MQOBS_OPENER:-open}" "$path"
}

# Opens mqobsidian target.
open_mqobsidian_target() {
local key="$1" path
path="$(assert_view_target_exists "$key")" || return 1
Expand Down
3 changes: 3 additions & 0 deletions mqlaunch/lib/mqobsidian/resolve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Single source of truth for locating the mqobsidian vault. Read-only.
# The ONLY place that knows how mqobsidian is found. Depends on errors.sh.

# Resolves mqobsidian dir.
resolve_mqobsidian_dir() {
if [[ -n "${MQ_OBSIDIAN_DIR:-}" ]]; then
printf '%s\n' "$MQ_OBSIDIAN_DIR"
Expand All @@ -10,11 +11,13 @@ resolve_mqobsidian_dir() {
fi
}

# Checks whether valid mqobsidian root applies.
is_valid_mqobsidian_root() {
local dir="$1"
[[ -d "$dir/systems" && -d "$dir/memory" ]]
}

# Coordinates assert mqobsidian dir behavior.
assert_mqobsidian_dir() {
local dir
dir="$(resolve_mqobsidian_dir)"
Expand Down
1 change: 1 addition & 0 deletions mqlaunch/lib/recommendations/doctor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# invalid/wrong-schema source). Depends on: errors.sh, resolve.sh, parse.sh.
: "${REC_JQ:=jq}"

# Runs recommendations doctor.
run_recommendations_doctor() {
local path
if ! path="$(assert_recommended_json)"; then
Expand Down
4 changes: 4 additions & 0 deletions mqlaunch/lib/recommendations/errors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
# recommendations consumer — consistent messaging to stderr. Read-only.
# Mirrors lib/mqobsidian/errors.sh so the two consumers feel the same.

# Coordinates rec error behavior.
rec_error() { printf '\033[0;31m[recommend][error]\033[0m %s\n' "$*" >&2; }
# Coordinates rec warn behavior.
rec_warn() { printf '\033[0;33m[recommend][warn]\033[0m %s\n' "$*" >&2; }
# Coordinates rec info behavior.
rec_info() { printf '\033[0;37m[recommend]\033[0m %s\n' "$*" >&2; }
# Coordinates rec ok behavior.
rec_ok() { printf '\033[0;32m[recommend][ok]\033[0m %s\n' "$*" >&2; }
1 change: 1 addition & 0 deletions mqlaunch/lib/recommendations/resolve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ REC_SCHEMA="command-recommendations.v1"
# Defaults to the bare name so an un-bootstrapped call still works on a sane PATH.
: "${REC_JQ:=jq}"

# Resolves recommended json path.
resolve_recommended_json_path() {
if [[ -n "${MQ_RECOMMENDED_JSON:-}" ]]; then
printf '%s\n' "$MQ_RECOMMENDED_JSON"
Expand Down
4 changes: 4 additions & 0 deletions scripts/check-skills.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ BEGIN_MARK="<!-- BEGIN GENERATED SKILLS TABLE -->"
END_MARK="<!-- END GENERATED SKILLS TABLE -->"

FAIL=0
# Marks a failing check.
fail() { echo "FAIL: $1"; FAIL=1; }
# Coordinates ok behavior.
ok() { echo "PASS: $1"; }

# Coordinates frontmatter field behavior.
frontmatter_field() {
awk -v key="$2" -F': ' '$1 == key { sub("^" key ": ", ""); print; exit }' "$1"
}
Expand Down Expand Up @@ -84,6 +87,7 @@ done < <(grep -HoE '`[A-Za-z][A-Za-z0-9._/-]*/[A-Za-z0-9._/*<>-]*`' skills/*/SKI

# --- 5: SKILLS.md table generated from frontmatter ---------------------------

# Generates table for docs or release automation.
generate_table() {
echo "$BEGIN_MARK"
echo "| Skill | Description |"
Expand Down
6 changes: 6 additions & 0 deletions terminal/launchers/gitmerge-safe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@
set -euo pipefail
IFS=$'\n\t'

# Coordinates red behavior.
red() { printf '\033[31m%s\033[0m\n' "$*"; }
# Coordinates green behavior.
green() { printf '\033[32m%s\033[0m\n' "$*"; }
# Coordinates yellow behavior.
yellow() { printf '\033[33m%s\033[0m\n' "$*"; }
# Coordinates blue behavior.
blue() { printf '\033[34m%s\033[0m\n' "$*"; }

# Coordinates die behavior.
die() {
red "Error: $*"
exit 1
}

# Verifies the required cmd helper is available before continuing.
require_cmd() {
command -v "$1" >/dev/null 2>&1 || die "Missing command: $1"
}
Expand Down
1 change: 1 addition & 0 deletions terminal/menus/mq-agent-menu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ _agent_menu_cochange_review() {
done
}

# Runs agent command.
run_agent_command() {
local subcmd="${1:-menu}"
case "$subcmd" in
Expand Down
3 changes: 2 additions & 1 deletion terminal/menus/mq-dev-menu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ print_dev_menu() {
surface_row "" "$width" "$panel_color"
surface_row "MAINTENANCE" "$width" "$panel_color"
surface_split_row "${C_WARN}13. Repo Signal Folder Check${C_RESET}" "14. Env Snapshot" "$width" "$panel_color"
surface_split_row "15. Comment scripts" "" "$width" "$panel_color"
surface_split_row "15. Comment scripts" "16. Excalidraw" "$width" "$panel_color"
surface_row "" "$width" "$panel_color"
surface_split_row "b. Back" "" "$width" "$panel_color"
surface_row "" "$width" "$panel_color"
Expand Down Expand Up @@ -91,6 +91,7 @@ handle_dev_menu_choice() {
13) run_dev_script "REPO SIGNAL FOLDER CHECK" "$(dev_repo_path "terminal/dev/mq-repo-signal-folder-check.sh")" ;;
14) run_dev_script "ENV SNAPSHOT" "$(dev_repo_path "tools/scripts/env-snap.sh")" ;;
15) run_dev_script "COMMENT SCRIPTS" "$(dev_repo_path "terminal/menus/mq-tools-menu.sh")" docfunc ;;
16) run_dev_script "EXCALIDRAW" "$(dev_repo_path "tools/scripts/excalidraw.sh")" ;;
a|A) PYTHONPATH="${BASE_DIR}" python3 -m mqlaunch.b2_tui.main ;;
b|B|x|X|exit) return 1 ;;
*) echo "${C_ERR}Invalid dev selection:${C_RESET} $choice"; pause_enter ;;
Expand Down
1 change: 1 addition & 0 deletions terminal/menus/recommendations-menu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ render_recommendations_panel() {
# Prompts for a visible pattern and stores its id in REC_PICKED. Returns non-zero
# on cancel / invalid / empty visible set (the prompt itself reports why).
REC_PICKED=""
# Coordinates rec menu pick visible behavior.
_rec_menu_pick_visible() {
local path="$1" sel
REC_PICKED=""
Expand Down
3 changes: 3 additions & 0 deletions tests/dashboard-header-cache-smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
TMP="$(mktemp -d)"
trap 'rm -rf "$TMP"' EXIT

# Marks a failing check.
fail() { printf '[FAIL] %s\n' "$1" >&2; exit 1; }
# Marks a passing check.
pass() { printf '[PASS] %s\n' "$1"; }

# Stub dashboard: appends a line to a counter file every time it runs, and
Expand All @@ -21,6 +23,7 @@ STUBEOF
chmod +x "$STUB"
export COUNT_FILE

# Coordinates runs behavior.
runs() { wc -l < "$COUNT_FILE" | tr -d ' '; }

# shellcheck disable=SC1090
Expand Down
2 changes: 2 additions & 0 deletions tests/git-status-contract-smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
TMP_REPO="$(mktemp -d)"
trap 'rm -rf "$TMP_REPO"' EXIT

# Marks a failing check.
fail() {
printf '[FAIL] %s\n' "$1" >&2
exit 1
}

# Marks a passing check.
pass() {
printf '[PASS] %s\n' "$1"
}
Expand Down
8 changes: 8 additions & 0 deletions tools/scripts/excalidraw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,24 @@ LOG_DIR="${EXCALIDRAW_LOG_DIR:-$HOME/Library/Logs/mqlaunch}"

mkdir -p "$LOG_DIR"

# Coordinates die behavior.
die() {
printf 'excalidraw: %s\n' "$*" >&2
exit 1
}

# Coordinates need dir behavior.
need_dir() {
[[ -d "$1" ]] || die "missing directory: $1"
}

# Coordinates port listening behavior.
port_listening() {
local port="$1"
lsof -nP -iTCP:"$port" -sTCP:LISTEN >/dev/null 2>&1
}

# Coordinates wait for url behavior.
wait_for_url() {
local url="$1"
local label="$2"
Expand All @@ -39,6 +43,7 @@ wait_for_url() {
die "$label did not become ready at $url"
}

# Ensures yarn is ready.
ensure_yarn() {
if command -v yarn >/dev/null 2>&1; then
return 0
Expand All @@ -49,6 +54,7 @@ ensure_yarn() {
corepack prepare yarn@1.22.22 --activate >/dev/null
}

# Coordinates start proxy behavior.
start_proxy() {
need_dir "$PROXY_DIR"

Expand All @@ -69,6 +75,7 @@ start_proxy() {
)
}

# Coordinates start frontend behavior.
start_frontend() {
need_dir "$EXCALIDRAW_DIR"

Expand All @@ -86,6 +93,7 @@ start_frontend() {
)
}

# Runs the main entry point.
main() {
start_proxy
wait_for_url "$PROXY_URL/health" "proxy"
Expand Down
1 change: 1 addition & 0 deletions ui/terminal-ui/mq-ui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ print_dashboard_header() {
printf '%s\n' "$MQ_DASHBOARD_CACHE_OUTPUT"
}

# Prints header.
print_header() {
local dashboard nickname

Expand Down
Loading