diff --git a/.mq/context/active-contract.md b/.mq/context/active-contract.md new file mode 100644 index 0000000..38f1d99 --- /dev/null +++ b/.mq/context/active-contract.md @@ -0,0 +1,23 @@ +# Active Contract: macos-scripts + +## Owns + +* `mqlaunch` interactive and direct CLI entrypoints +* macOS workflow menus and launchers +* release-check and repo workflow shortcuts +* HAL, review, and repo-status bridges +* shell-script surface validation + +## Does Not Own + +* MQ-stack orchestration internals +* repo scoring logic +* durable Obsidian memory +* MCP runtime behavior +* source-repo feature implementation + +## Rules + +* Treat this file as routing context, not runtime truth. +* Verify current code, tests, CLI behavior, and contracts in the target repo. +* Do not duplicate behavior owned by another MQ repo. diff --git a/.mq/context/current-blockers.md b/.mq/context/current-blockers.md new file mode 100644 index 0000000..d432e72 --- /dev/null +++ b/.mq/context/current-blockers.md @@ -0,0 +1,12 @@ +# Current Blockers: macos-scripts + +## Known Blockers + +* No repo-specific blocker exported in this Phase 4 seed. + +## Check Before Acting + +* Read `.mq/context/repo-card.md`. +* Read `.mq/context/active-contract.md`. +* Read `.mq/context/integration-map.md`. +* Verify live repo state before making runtime or release claims. diff --git a/.mq/context/integration-map.md b/.mq/context/integration-map.md new file mode 100644 index 0000000..dc883c4 --- /dev/null +++ b/.mq/context/integration-map.md @@ -0,0 +1,29 @@ +# Integration Map: macos-scripts + +## Reads From + +* local MQ repos under the user workspace +* mq-agent and mq-hal command outputs +* repo-signal readiness outputs +* terminal menu and launcher scripts + +## Writes To + +* terminal UI output +* local workflow snapshots +* shell launcher state +* no durable memory unless routed through MQ tools + +## Use When + +* task involves `mqlaunch` +* task involves macOS terminal menus +* task touches release-check shortcuts +* task needs launcher-to-repo path boundaries + +## Avoid Reading First + +* unrelated app docs +* old menu screenshots +* full repo READMEs +* generated dependency logs diff --git a/.mq/context/repo-card.md b/.mq/context/repo-card.md new file mode 100644 index 0000000..e9f4415 --- /dev/null +++ b/.mq/context/repo-card.md @@ -0,0 +1,56 @@ +--- +schema: context-card.v1 +repo: macos-scripts +role: macOS workflow launcher and mqlaunch operator entrypoint +updated_at: 2026-06-19T00:00:00Z +--- + +# Context Card: macos-scripts + +## Role + +macOS workflow launcher and mqlaunch operator entrypoint. + +## Owns + +* `mqlaunch` interactive and direct CLI entrypoints +* macOS workflow menus and launchers +* release-check and repo workflow shortcuts +* HAL, review, and repo-status bridges +* shell-script surface validation + +## Does not own + +* MQ-stack orchestration internals +* repo scoring logic +* durable Obsidian memory +* MCP runtime behavior +* source-repo feature implementation + +## Reads from + +* local MQ repos under the user workspace +* mq-agent and mq-hal command outputs +* repo-signal readiness outputs +* terminal menu and launcher scripts + +## Writes to + +* terminal UI output +* local workflow snapshots +* shell launcher state +* no durable memory unless routed through MQ tools + +## Use this card when + +* task involves `mqlaunch` +* task involves macOS terminal menus +* task touches release-check shortcuts +* task needs launcher-to-repo path boundaries + +## Avoid reading unless needed + +* unrelated app docs +* old menu screenshots +* full repo READMEs +* generated dependency logs diff --git a/.mq/context/token-budget.md b/.mq/context/token-budget.md new file mode 100644 index 0000000..90fd6ce --- /dev/null +++ b/.mq/context/token-budget.md @@ -0,0 +1,16 @@ +# Token Budget: macos-scripts + +## Generated Context Budgets + +| File | Budget | +| --- | ---: | +| `repo-card.md` | 60 lines | +| `active-contract.md` | 80 lines | +| `current-blockers.md` | 80 lines | +| `integration-map.md` | 120 lines | +| `task-pack.md` | 200 lines | + +## Rule + +If a generated context file exceeds its budget, tighten the export instead of +copying broad README, changelog, release-note, or vault history into it. diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..3ac1459 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,60 @@ +# Agent Instructions For macos-scripts + +This repo is part of the MQ stack. + +These instructions add MQ memory read-order rules. They do not replace +repo-specific build, test, safety, or release instructions. + +## mqobsidian Location + +Default local vault path: + +`/Users/mansys/mqobsidian` + +If `MQ_OBSIDIAN_DIR` is set, prefer that value. + +## Read Order + +For work related to `macos-scripts`: + +0. Read `.mq/context/task-pack.md` if it exists and matches the task. +1. Read `/Users/mansys/mqobsidian/memory/learn/agent/macos-scripts.md` if it exists. +2. Read `/Users/mansys/mqobsidian/systems/macos-scripts/hot.md` if it exists. +3. Read `/Users/mansys/mqobsidian/systems/macos-scripts/index.md` if it exists. +4. Read `/Users/mansys/mqobsidian/memory/learn/repos/macos-scripts.md` if it exists. +5. Read individual pattern notes only if the compressed notes are insufficient. + +Stop reading as soon as the task is grounded. + +## Low-Token Rules + +* Prefer task packs and agent views over full notes. +* Prefer hot/index over pattern notes. +* Do not scan the whole vault by default. +* Do not open multiple pattern notes unless clearly needed. +* Summarize instead of replaying long note bodies. + +## Source-Of-Truth Rule + +`mqobsidian` is durable memory, not live runtime truth. + +If the task depends on current code behavior, tests, contracts, CLI behavior, +or runtime state, verify in this repo before making claims. + +## Writing Rules + +When creating notes, summaries, or exports: + +* separate facts, interpretation, and recommendation +* keep outputs compact +* preserve timestamps and provenance when relevant +* prefer links over duplicated prose +* avoid raw dumps + +Do not store or copy secrets, tokens, internal hostnames, raw enterprise logs, +or machine-specific private paths. + +## Fallback Rule + +If `mqobsidian` is missing, stale, or too weak for the task, say so and verify +in the repo. Do not invent continuity. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..449834e --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,60 @@ +# Claude Instructions For macos-scripts + +This repo is part of the MQ stack. + +These instructions add MQ memory read-order rules. They do not replace +repo-specific build, test, safety, or release instructions. + +## mqobsidian Location + +Default local vault path: + +`/Users/mansys/mqobsidian` + +If `MQ_OBSIDIAN_DIR` is set, prefer that value. + +## Read Order + +For work related to `macos-scripts`: + +0. Read `.mq/context/task-pack.md` if it exists and matches the task. +1. Read `/Users/mansys/mqobsidian/memory/learn/agent/macos-scripts.md` if it exists. +2. Read `/Users/mansys/mqobsidian/systems/macos-scripts/hot.md` if it exists. +3. Read `/Users/mansys/mqobsidian/systems/macos-scripts/index.md` if it exists. +4. Read `/Users/mansys/mqobsidian/memory/learn/repos/macos-scripts.md` if it exists. +5. Read individual pattern notes only if the compressed notes are insufficient. + +Stop reading as soon as the task is grounded. + +## Low-Token Rules + +* Prefer task packs and agent views over full notes. +* Prefer hot/index over pattern notes. +* Do not scan the whole vault by default. +* Do not open multiple pattern notes unless clearly needed. +* Summarize instead of replaying long note bodies. + +## Source-Of-Truth Rule + +`mqobsidian` is durable memory, not live runtime truth. + +If the task depends on current code behavior, tests, contracts, CLI behavior, +or runtime state, verify in this repo before making claims. + +## Writing Rules + +When creating notes, summaries, or exports: + +* separate facts, interpretation, and recommendation +* keep outputs compact +* preserve timestamps and provenance when relevant +* prefer links over duplicated prose +* avoid raw dumps + +Do not store or copy secrets, tokens, internal hostnames, raw enterprise logs, +or machine-specific private paths. + +## Fallback Rule + +If `mqobsidian` is missing, stale, or too weak for the task, say so and verify +in the repo. Do not invent continuity. diff --git a/docs/python-guide-SE-v2.2.html b/docs/python-guide-SE-v2.2.html new file mode 100644 index 0000000..5e9897b --- /dev/null +++ b/docs/python-guide-SE-v2.2.html @@ -0,0 +1,833 @@ + + + + + +Python Kommandoguide v2.2 + + + + +
+
+
+ Python Kommandoguide + v2.2 +
+
+ Get Started + Docs + Downloads + Standard Library + Automation +
+
+ +
+
+
python.org-inspirerat tema • svensk referens • ren Python
+

Python-kommandon för vardag, automation och systemjobb

+

Version 2.2 fokuserar på snabbare användning: live-resultaträknare, tydligare filterstatus, kortnivå för att kopiera alla exempel och ett bättre tangentbordsflöde för sökning och navigering.

+ +
+ + +
+
+ +
+ + +
+
+
114
kommandokort
+
10
kategorier
+
live
resultaträknare och filterstatus
+
/ + Esc
snabbare sökflöde
+
+ +
Version 2.2 fokuserar på snabbare användning: live-resultaträknare, tydligare filterstatus, kortnivå för att kopiera alla exempel och ett bättre tangentbordsflöde för sökning och navigering.
+ +
+
+
träffar 0
+
kort totalt 114
+
kategorier 10
+
+
+ +
+ +
+ +
+ +

Kommandoguide

+
+ +
+
+ + + + diff --git a/terminal/themes/mq-zsh-theme-v3.zsh b/terminal/themes/mq-zsh-theme-v3.zsh index 965a281..382a395 100755 --- a/terminal/themes/mq-zsh-theme-v3.zsh +++ b/terminal/themes/mq-zsh-theme-v3.zsh @@ -349,7 +349,7 @@ mq_build_prompt() { git_part=" ${MQC_DIM}•%f ${MQC_GIT} ${git_info}%f" fi - PROMPT=$'\n'"${user_host} ${MQC_DIM}•%f ${path_part}${git_part}"$'\n'"${status_icon} " + PROMPT="$(starship prompt --status=$exit_code)" RPROMPT="" } diff --git a/tests/dashboard-header-cache-smoke.sh b/tests/dashboard-header-cache-smoke.sh new file mode 100755 index 0000000..7aa30bf --- /dev/null +++ b/tests/dashboard-header-cache-smoke.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +TMP="$(mktemp -d)" +trap 'rm -rf "$TMP"' EXIT + +fail() { printf '[FAIL] %s\n' "$1" >&2; exit 1; } +pass() { printf '[PASS] %s\n' "$1"; } + +# Stub dashboard: appends a line to a counter file every time it runs, and +# echoes a marker so callers can see the rendered output. +COUNT_FILE="$TMP/runs" +: > "$COUNT_FILE" +STUB="$TMP/dashboard.sh" +cat > "$STUB" <> "$COUNT_FILE" +printf 'DASHBOARD %s\n' "\$1" +STUBEOF +chmod +x "$STUB" +export COUNT_FILE + +runs() { wc -l < "$COUNT_FILE" | tr -d ' '; } + +# shellcheck disable=SC1090 +source "$ROOT/ui/terminal-ui/mq-ui.sh" +APP_TITLE="MQ"; APP_SUBTITLE="Launcher" + +# 1. Two renders within the TTL window fork the dashboard once. +# Use redirection (not command substitution) so the cache update stays in this +# shell — exactly how print_header is invoked inside the menu loop. +MQ_DASHBOARD_CACHE_TTL=5 +mq_dashboard_cache_invalidate +print_dashboard_header "$STUB" > "$TMP/out1" +print_dashboard_header "$STUB" > "$TMP/out2" +[[ "$(runs)" == "1" ]] || fail "expected 1 fork within TTL, got $(runs)" +diff -q "$TMP/out1" "$TMP/out2" >/dev/null || fail "cached render differs from first render" +[[ "$(cat "$TMP/out1")" == "DASHBOARD MQ" ]] || fail "unexpected render output: $(cat "$TMP/out1")" +pass "rapid renders within TTL reuse the cached dashboard" + +# 2. Explicit invalidation forces a fresh fork. +mq_dashboard_cache_invalidate +print_dashboard_header "$STUB" >/dev/null +[[ "$(runs)" == "2" ]] || fail "expected fork after invalidate, got $(runs)" +pass "cache invalidation forces a fresh render" + +# 3. A different working directory is a cache miss (git status is cwd-dependent). +( cd "$TMP" && print_dashboard_header "$STUB" >/dev/null ) +[[ "$(runs)" == "3" ]] || fail "expected fork on cwd change, got $(runs)" +pass "changing working directory misses the cache" + +# 4. TTL=0 disables caching entirely. +: > "$COUNT_FILE" +MQ_DASHBOARD_CACHE_TTL=0 +mq_dashboard_cache_invalidate +print_dashboard_header "$STUB" >/dev/null +print_dashboard_header "$STUB" >/dev/null +[[ "$(runs)" == "2" ]] || fail "expected 2 forks with TTL=0, got $(runs)" +pass "MQ_DASHBOARD_CACHE_TTL=0 disables caching" + +printf 'OK: dashboard header cache contract passed\n' diff --git a/tools/scripts/doctor.sh b/tools/scripts/doctor.sh index e644e63..027956f 100755 --- a/tools/scripts/doctor.sh +++ b/tools/scripts/doctor.sh @@ -33,7 +33,7 @@ run_json_mode() { local version version="$(cat "$BASE_DIR/VERSION" 2>/dev/null || printf 'unknown')" - for cmd in git eza fzf jq gitleaks pbcopy; do + for cmd in git gh uv python3 node eza fzf jq gitleaks pbcopy; do if command -v "$cmd" >/dev/null 2>&1; then _jc "$cmd" "ok" else @@ -66,7 +66,7 @@ run_normal_mode() { ok "Shell: $SHELL" section "TOOLS" - for cmd in git eza fzf jq gitleaks pbcopy; do + for cmd in git gh uv python3 node eza fzf jq gitleaks pbcopy; do if command -v "$cmd" >/dev/null 2>&1; then ok "$cmd" else diff --git a/tools/scripts/test-all.sh b/tools/scripts/test-all.sh index fe8971b..1b5eece 100755 --- a/tools/scripts/test-all.sh +++ b/tools/scripts/test-all.sh @@ -11,6 +11,7 @@ echo echo "== Running mqlaunch headless checks ==" "$PROJECT_ROOT/tests/headless-smoke.sh" "$PROJECT_ROOT/tests/git-status-contract-smoke.sh" +"$PROJECT_ROOT/tests/dashboard-header-cache-smoke.sh" echo echo "== Running HAL menu checks ==" diff --git a/ui/terminal-ui/mq-ui.sh b/ui/terminal-ui/mq-ui.sh index a722fda..e56f677 100644 --- a/ui/terminal-ui/mq-ui.sh +++ b/ui/terminal-ui/mq-ui.sh @@ -357,13 +357,54 @@ get_nickname() { } # Prints header. +# Cached dashboard header state. Rapid menu transitions — returning from a +# sub-menu (Back) or re-rendering after invalid input — would otherwise re-fork +# the dashboard subprocess (pmset + several git calls) on every loop tick. The +# cache reuses the last render within a short TTL so only genuinely fresh ticks +# pay the cost. +MQ_DASHBOARD_CACHE_OUTPUT="" +MQ_DASHBOARD_CACHE_KEY="" +MQ_DASHBOARD_CACHE_TS=0 + +# Invalidates the cached dashboard header. Call after an action that changes +# what the header reports (e.g. a commit) so the next render recomputes. +mq_dashboard_cache_invalidate() { + MQ_DASHBOARD_CACHE_OUTPUT="" + MQ_DASHBOARD_CACHE_KEY="" + MQ_DASHBOARD_CACHE_TS=0 +} + +# Renders the dashboard header, reusing a cached render within MQ_DASHBOARD_CACHE_TTL +# seconds (default 5; set to 0 to disable caching). The cache key includes the +# working directory because the dashboard's git status depends on it. +print_dashboard_header() { + local dashboard="$1" + local ttl now key + ttl="${MQ_DASHBOARD_CACHE_TTL:-5}" + now="$(date +%s)" + key="${APP_TITLE}|${APP_SUBTITLE}|${PWD}" + + if [[ "$ttl" != "0" \ + && -n "$MQ_DASHBOARD_CACHE_OUTPUT" \ + && "$MQ_DASHBOARD_CACHE_KEY" == "$key" \ + && $(( now - MQ_DASHBOARD_CACHE_TS )) -lt "$ttl" ]]; then + printf '%s\n' "$MQ_DASHBOARD_CACHE_OUTPUT" + return + fi + + MQ_DASHBOARD_CACHE_OUTPUT="$(bash "$dashboard" "$APP_TITLE" "$APP_SUBTITLE" "ONLINE")" + MQ_DASHBOARD_CACHE_KEY="$key" + MQ_DASHBOARD_CACHE_TS="$now" + printf '%s\n' "$MQ_DASHBOARD_CACHE_OUTPUT" +} + print_header() { local dashboard nickname if [[ "${MQ_USE_DASHBOARD_HEADER:-0}" == "1" ]]; then dashboard="${MACOS_SCRIPTS_HOME:-$HOME/macos-scripts}/ui/ascii/mqlaunch-dashboard-v7.1.sh" if [[ -f "$dashboard" ]]; then - bash "$dashboard" "$APP_TITLE" "$APP_SUBTITLE" "ONLINE" + print_dashboard_header "$dashboard" printf '\n' return fi