drafted 1.12.2 → 1.12.3

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 +44 -3
  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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drafted",
3
- "version": "1.12.2",
3
+ "version": "1.12.3",
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": [