@@ -43,19 +43,12 @@ LOCK_DIR="$DEVKIT_HOME/.registry.lock"
4343STAMP_FILE=" $DEVKIT_HOME /.caddy.fingerprint"
4444BREW_CADDYFILE=" ${DEVKIT_BREW_CADDYFILE:-/ opt/ homebrew/ etc/ Caddyfile} "
4545
46- # ── Supervisor (opt-in crash recovery) ──────────────────────────────────────
47- # wants/ records desired state (set on start, cleared on stop) so the supervisor only
48- # revives apps you actually want up — it never fights a manual `devkit stop` .
49- # state/ holds per-app backoff counters so a crash-looping app can't be hammered .
46+ # Desired-state markers. `wants/` records which apps were last started vs stopped. These
47+ # are advisory only today (written on start/stop, read by nothing) — kept as the seam for
48+ # a future reliability layer, which will be process-compose, not a hand-rolled supervisor .
49+ # TODO: fully remove these + the inert `restart` policy in a focused pass .
5050WANTS_DIR=" $DEVKIT_HOME /supervisor/wants"
5151SUPERVISOR_STATE_DIR=" $DEVKIT_HOME /supervisor/state"
52- SUPERVISOR_LOCK=" $DEVKIT_HOME /supervisor/.tick.lock"
53- SUPERVISOR_LOG=" $LOGS_DIR /_supervisor.log"
54- SUPERVISOR_LABEL=" com.devkit.supervisor"
55- SUPERVISOR_PLIST=" $HOME /Library/LaunchAgents/$SUPERVISOR_LABEL .plist"
56- SUPERVISOR_INTERVAL=" ${DEVKIT_SUPERVISE_INTERVAL:- 10} "
57- SUPERVISOR_BACKOFF_BASE=" ${DEVKIT_SUPERVISE_BACKOFF_BASE:- 5} "
58- SUPERVISOR_BACKOFF_CAP=" ${DEVKIT_SUPERVISE_BACKOFF_CAP:- 300} "
5952DEVKIT_BIN_SELF=" $SCRIPT_DIR /$( basename -- " ${BASH_SOURCE[0]} " ) "
6053
6154die () { echo " devkit: $* " >&2 ; exit 1; }
@@ -382,7 +375,6 @@ is_running() {
382375# stopped — managed, down, no recorded failure (identical to never-started)
383376app_state () {
384377 local name=" $1 " managed=" $2 "
385- [[ " $managed " == " pm2" ]] && managed=" devkit"
386378 case " $managed " in
387379 external) echo " external" ; return 0 ;;
388380 devkit)
@@ -1512,45 +1504,50 @@ OUT
15121504# Wire the devkit MCP server into an AI agent so it can register/manage apps as
15131505# structured tool calls (instead of relying on a CLAUDE.md text instruction).
15141506cmd_setup_mcp () {
1507+ # Prefer a local checkout (handy during development); otherwise run the published
1508+ # package with `npx -y devkit-mcp`, so a standalone CLI install needs nothing extra.
1509+ # Either way the agent gets the same stdio MCP server.
15151510 local candidates=(
15161511 " $REPO_HOME /../devkit-mcp/index.js"
15171512 " $REPO_HOME /devkit-mcp/index.js"
1518- " $REPO_HOME /mcp-server/index.js"
15191513 " $DEVKIT_HOME /devkit-mcp/index.js"
1520- " $DEVKIT_HOME /mcp-server/index.js"
15211514 )
15221515 local server=" " c
15231516 for c in " ${candidates[@]} " ; do
1524- if [[ -f " $c " ]]; then
1525- server=" $( cd " $( dirname " $c " ) " && pwd) /index.js"
1526- break
1527- fi
1517+ if [[ -f " $c " ]]; then server=" $( cd " $( dirname " $c " ) " && pwd) /index.js" ; break ; fi
15281518 done
1529- [[ -n " $server " ]] || die " could not find the devkit MCP server (index.js) — expected near $REPO_HOME /../devkit-mcp/"
1530-
1531- need node
15321519
1533- # Install the MCP's dependencies if missing, otherwise the server crashes on first
1534- # call with "Cannot find module @modelcontextprotocol/sdk".
1535- local server_dir; server_dir=$( dirname " $server " )
1536- if [[ ! -d " $server_dir /node_modules/@modelcontextprotocol" ]]; then
1537- need npm
1538- echo " installing devkit MCP dependencies..."
1539- (cd " $server_dir " && npm install --silent) || die " npm install failed in $server_dir "
1520+ local -a runcmd
1521+ if [[ -n " $server " ]]; then
1522+ need node
1523+ # Install deps if missing, else the server crashes with "Cannot find module
1524+ # @modelcontextprotocol/sdk" on first call.
1525+ local server_dir; server_dir=$( dirname " $server " )
1526+ if [[ ! -d " $server_dir /node_modules/@modelcontextprotocol" ]]; then
1527+ need npm
1528+ echo " installing devkit MCP dependencies..."
1529+ (cd " $server_dir " && npm install --silent) || die " npm install failed in $server_dir "
1530+ fi
1531+ runcmd=(node " $server " )
1532+ else
1533+ # Unscoped "devkit-mcp" is taken by an unrelated package on npm, so we publish under
1534+ # the @djadmin scope. npx fetches it on first use (then caches).
1535+ need npx
1536+ runcmd=(npx -y @djadmin/devkit-mcp)
15401537 fi
15411538
15421539 if command -v claude > /dev/null 2>&1 ; then
1543- if claude mcp add devkit -- node " $server " ; then
1544- echo " devkit MCP registered with Claude Code. Restart Claude Code to load it."
1540+ if claude mcp add devkit -- " ${runcmd[@]} " ; then
1541+ echo " devkit MCP registered with Claude Code ( ${runcmd[*]} ) . Restart Claude Code to load it."
15451542 else
1546- die " failed to register the MCP with Claude Code (try: claude mcp add devkit -- node \" $server \" )"
1543+ die " failed to register the MCP with Claude Code (try: claude mcp add devkit -- ${runcmd[*]} )"
15471544 fi
15481545 else
15491546 echo " Claude Code CLI not found. Add the devkit MCP to your agent manually:"
1550- echo " command: node "
1551- echo " args: $server "
1547+ echo " command: ${runcmd[0]} "
1548+ echo " args: ${runcmd[*] : 1} "
15521549 echo
1553- echo " Claude Code: claude mcp add devkit -- node \" $server \" "
1550+ echo " Claude Code: claude mcp add devkit -- ${runcmd[*]} "
15541551 echo " Cursor / Windsurf / other: see your agent's MCP config docs."
15551552 fi
15561553}
0 commit comments