feat(tray): replace executable stub bin (MacOS/Prospector) with featureful dispatcher
The previous dumb stub just execd the applescript. Now the bin (still used as the bundle executable and for double-click) supports CLI features/subcommands while preserving default tray UI behavior: - no arg / tray / menu: launch tray UI (status item + menu) - launch / open / app: start services (delegates to launch.sh, matches menu "Open Prospector") - stop: stop services (matches menu "Stop services") - help: list features Updated post-build messaging, tray.applescript header comment, scripts/README.md table, and ./run usage. Tested via TRAY_DEST=/tmp/... build + direct bin help invocation (and full make-tray success).
This commit is contained in:
parent
75cb79281c
commit
aa3e6eacda
4 changed files with 60 additions and 7 deletions
4
run
4
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}"
|
||||
|
|
|
|||
|
|
@ -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. |
|
||||
|
|
|
|||
|
|
@ -63,11 +63,55 @@ cat > "$DEST/Contents/Info.plist" <<'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 <<EOF
|
||||
Prospector tray (MacOS/Prospector bin with features)
|
||||
|
||||
Usage: $(basename "$0") [feature]
|
||||
|
||||
Features (CLI subcommands):
|
||||
(no arg) Start tray UI / menu bar (default for bundle)
|
||||
tray Same as default
|
||||
launch Start services (API + panel) — same as menu "Open Prospector"
|
||||
open Alias for launch
|
||||
stop Stop services — same as menu "Stop services"
|
||||
help This message
|
||||
|
||||
The tray process (when running) provides the persistent ❖ menu.
|
||||
You can also invoke this bin directly for the above features.
|
||||
EOF
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown feature: $cmd" >&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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue