diff --git a/run b/run index a3ecebd..17871c1 100755 --- a/run +++ b/run @@ -31,7 +31,9 @@ usage() { echo " app Launch API + panel, open as Chrome app window." echo " app --build Rebuild first, then launch." echo " stop Stop the detached app (API + panel)." - echo " tray Build the menu-bar tray app (~/Applications)." + echo " tray Build the menu-bar tray app (~/Applications). The bundle's" + echo " MacOS/Prospector bin now has built-in features (launch/stop/help)" + echo " in addition to starting the ❖ tray UI on double-click/open." echo " db:migrate Apply pending SQL migrations (ledger-tracked)." echo "" echo -e "${YELLOW}MCP (agent / Claude Desktop + global claude)${NC}" diff --git a/scripts/README.md b/scripts/README.md index 2e3e4ae..1580d94 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -8,7 +8,7 @@ All are reachable through `./run` (preferred) or by direct execution. | `install.sh` | `./run install` | Deps → env files → DB + migrations → build API + web → tray app → MCP. Idempotent. `--launch` opens the app after. Skip steps with `SKIP_DB`/`SKIP_TRAY`/`SKIP_MCP`. | | `app.sh` | `./run app` | Start API + the vite-preview front door, health-check, open Chrome as an app window. `--build` rebuilds first; `--detach` runs in the background (used by the tray). Reuses an already-running instance. | | `stop.sh` | `./run stop` | Stop the detached app — kills only the PIDs in `.run/app.pids`, never a blanket node kill. | -| `make-tray.sh` | `./run tray` | Build the `Prospector.app` menu-bar tray (~/Applications): ❖ status icon with Open / Stop / Quit. AppleScript-ObjC + built-in icon tooling, no Swift/deps. | +| `make-tray.sh` | `./run tray` | Build the `Prospector.app` menu-bar tray (~/Applications): ❖ status icon with Open / Stop / Quit. The `MacOS/Prospector` bin (formerly a dumb stub) now supports CLI features directly (default=tray UI; `launch`/`open`, `stop`, `help`). AppleScript-ObjC + built-in icon tooling, no Swift/deps. | | `migrate.sh` | `./run db:migrate` | Apply pending `migrations/*.sql`, tracked in a `_prospector_migrations` ledger (each file runs once). | | `lib.sh` | — | Shared helpers (logging, `.env.local` loading, psql locating). Sourced, not run. | | `mcp/install-mcp.sh` | `./run install:mcp` | Register the agent/coworker MCP ("prospector") into Claude Desktop + global `~/.claude/mcp-config.json` (for Claude Code / desktop coworker). Builds the mcp package, handles secrets from .env or vault, safe edits. | diff --git a/scripts/make-tray.sh b/scripts/make-tray.sh index 0393394..f428d2f 100755 --- a/scripts/make-tray.sh +++ b/scripts/make-tray.sh @@ -63,11 +63,55 @@ cat > "$DEST/Contents/Info.plist" <<'PLIST' PLIST -# 5. Executable stub — runs the tray AppleScript, passing it its Resources dir. +# 5. Executable (with features) — default launches tray UI; subcommands provide +# CLI features for the services (matching menu actions). Replaces the prior +# dumb stub with a small dispatcher so the bin itself has features. cat > "$DEST/Contents/MacOS/Prospector" <<'STUB' #!/bin/bash +set -euo pipefail RES="$(cd "$(dirname "$0")/../Resources" && pwd)" -exec /usr/bin/osascript "$RES/tray.applescript" "$RES" + +cmd="${1:-}" + +case "$cmd" in + ""|tray|menu|default) + # Launch the tray UI (AppleScript-ObjC status item + menu). This is the + # default when the .app bundle is opened/double-clicked. + exec /usr/bin/osascript "$RES/tray.applescript" "$RES" + ;; + open|launch|app|open-prospector) + # Feature: start the services (web + API) detached, like the "Open Prospector" menu item. + exec "$RES/launch.sh" + ;; + stop|stop-services) + # Feature: stop the running services, like the "Stop services" menu item. + exec "$RES/stop.sh" + ;; + help|--help|-h) + cat <&2 + echo "Try: $(basename "$0") help" >&2 + exit 1 + ;; +esac STUB chmod +x "$DEST/Contents/MacOS/Prospector" @@ -93,3 +137,8 @@ osacompile -o "$WORK/syntax-check.scpt" "$RES/tray.applescript" >/dev/null || di ok "tray app built → $DEST" echo " Open it once (double-click in ~/Applications or 'open \"$DEST\"') to put the" echo " ❖ icon in your menu bar. It survives logout via Login Items if you add it." +echo " The bin now supports features directly:" +echo " $DEST/Contents/MacOS/Prospector # start tray UI (default)" +echo " $DEST/Contents/MacOS/Prospector launch # start services (like menu Open)" +echo " $DEST/Contents/MacOS/Prospector stop # stop services (like menu Stop)" +echo " $DEST/Contents/MacOS/Prospector help # list features" diff --git a/scripts/tray.applescript b/scripts/tray.applescript index 62022ef..0210c09 100644 --- a/scripts/tray.applescript +++ b/scripts/tray.applescript @@ -1,6 +1,8 @@ --- Prospector menu-bar (tray) app. Run via osascript by the app bundle's stub, --- which passes the bundle Resources dir as the first argument. Creates a status --- item with a small menu (Open / Stop / Quit) and keeps the run loop alive. +-- Prospector menu-bar (tray) app. Run via osascript by the app bundle's bin +-- (MacOS/Prospector, a small featureful dispatcher; default = tray UI). +-- The bin passes the bundle Resources dir as the first argument to the script. +-- Creates a status item with a small menu (Open / Stop / Quit) and keeps the +-- run loop alive. The bin also supports CLI features: launch/stop/help. use framework "Foundation" use framework "AppKit" use scripting additions