drafted 1.12.2 → 1.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/install-mcp.sh +54 -4
  2. package/package.json +1 -1
package/install-mcp.sh CHANGED
@@ -207,9 +207,50 @@ fi
207
207
 
208
208
  init_telemetry
209
209
 
210
- mkdir -p "$HOME/.drafted/npm-global"
211
- npm config set prefix "$HOME/.drafted/npm-global" >/dev/null
212
- export PATH="$HOME/.drafted/npm-global/bin:$PATH"
210
+ NPM_GLOBAL_PREFIX="$HOME/.drafted/npm-global"
211
+ mkdir -p "$NPM_GLOBAL_PREFIX"
212
+
213
+ # A `drafted` resolved elsewhere on PATH (a leftover install from before this
214
+ # fixed-prefix scheme, or a manual `npm i -g` under the default prefix) would
215
+ # permanently shadow the fixed-prefix copy: the updater keeps this prefix
216
+ # current, but the shell keeps running the stale one. Remove it at its source.
217
+ STALE_DRAFTED_BIN="$(command -v drafted 2>/dev/null || true)"
218
+ if [ -n "$STALE_DRAFTED_BIN" ]; then
219
+ # Derived from where the resolved binary actually sits (bin's grandparent),
220
+ # not `npm config get prefix` — that reflects our own target prefix once
221
+ # it's already been set on a prior run, which would make this a no-op on
222
+ # every machine that's already installed once (i.e. every real machine).
223
+ CANDIDATE_PREFIX="$(dirname "$(dirname "$STALE_DRAFTED_BIN")")"
224
+ if [ "$CANDIDATE_PREFIX" != "$NPM_GLOBAL_PREFIX" ] && [ -d "$CANDIDATE_PREFIX/lib/node_modules/drafted" ]; then
225
+ echo -e " ${YELLOW}Found a stale Drafted install at $CANDIDATE_PREFIX — removing it so it can't shadow the current one.${RESET}"
226
+ npm uninstall -g drafted --prefix "$CANDIDATE_PREFIX" >/dev/null 2>&1 || true
227
+ fi
228
+ fi
229
+
230
+ npm config set prefix "$NPM_GLOBAL_PREFIX" >/dev/null
231
+ export PATH="$NPM_GLOBAL_PREFIX/bin:$PATH"
232
+
233
+ # Persist the prefix's bin dir at the FRONT of PATH for future shells — without
234
+ # this, npm's prefix config makes `npm install -g` land in the right place, but
235
+ # a bare `drafted` in a new terminal keeps resolving through whatever was
236
+ # already on PATH (see the installedVersion() comment on the login-shell PATH
237
+ # gap below). Idempotent guarded block, same pattern as the agent-instructions
238
+ # markers further down.
239
+ persist_npm_global_path() {
240
+ local marker_begin="# BEGIN drafted-path"
241
+ local marker_end="# END drafted-path"
242
+ local line="export PATH=\"$NPM_GLOBAL_PREFIX/bin:\$PATH\""
243
+ local rc
244
+ case "$(basename "${SHELL:-}")" in
245
+ zsh) rc="$HOME/.zshrc" ;;
246
+ bash) rc="$HOME/.bash_profile" ;;
247
+ *) rc="$HOME/.profile" ;;
248
+ esac
249
+ [ -f "$rc" ] || : > "$rc"
250
+ grep -qF "$marker_begin" "$rc" 2>/dev/null && return 0
251
+ { echo ""; echo "$marker_begin"; echo "$line"; echo "$marker_end"; } >> "$rc"
252
+ }
253
+ persist_npm_global_path
213
254
 
214
255
  # ── Install ───────────────────────────────────────────────────────
215
256
 
@@ -651,6 +692,13 @@ install_desktop_app() {
651
692
  # Clear quarantine so Gatekeeper doesn't block a freshly downloaded bundle.
652
693
  xattr -dr com.apple.quarantine "$app_bundle" >/dev/null 2>&1 || true
653
694
 
695
+ # Kill any already-running instance first — including a stray one that isn't
696
+ # launchd-managed (e.g. left over from a prior run of this same installer,
697
+ # before this pkill existed: `open` below used to spawn a second, untracked
698
+ # process alongside the launchd-supervised one, and `launchctl bootout` only
699
+ # ever stops the launchd-managed process, not that rogue one).
700
+ pkill -x "$exe_name" >/dev/null 2>&1 || true
701
+
654
702
  # Register run-at-login for the new app (mirrors the legacy launch agent).
655
703
  uid="$(id -u)"
656
704
  plist="$HOME/Library/LaunchAgents/live.drafted.desktop.plist"
@@ -673,9 +721,11 @@ install_desktop_app() {
673
721
  </dict>
674
722
  </plist>
675
723
  PLIST
724
+ # launchctl bootstrap + RunAtLoad is the sole launch path — it already starts
725
+ # the app, so a trailing `open "$app_bundle"` here would start a second,
726
+ # launchd-unaware process every time this function runs (that was the bug).
676
727
  launchctl bootout "gui/$uid" "$plist" >/dev/null 2>&1 || true
677
728
  launchctl bootstrap "gui/$uid" "$plist" >/dev/null 2>&1 || true
678
- open "$app_bundle" >/dev/null 2>&1 || true
679
729
  return 0
680
730
  }
681
731
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drafted",
3
- "version": "1.12.2",
3
+ "version": "1.12.4",
4
4
  "description": "Drafted — visual thinking surface for humans and AI agents. Renders HTML, markdown, images, and code as frames on a zoomable canvas, with MCP tools for AI agents and real-time sync for humans.",
5
5
  "type": "module",
6
6
  "files": [