patchcord 0.5.83 → 0.5.84

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchcord",
3
- "version": "0.5.83",
3
+ "version": "0.5.84",
4
4
  "description": "Cross-machine agent messaging for Claude Code and Codex",
5
5
  "author": "ppravdin",
6
6
  "license": "MIT",
@@ -24,5 +24,9 @@ if command -v jq >/dev/null 2>&1; then
24
24
  fi
25
25
  fi
26
26
 
27
- nohup bash "$KIMI_SUB" 5 >/dev/null 2>&1 &
27
+ # --force tells kimi-subscribe.sh to kill any orphan listener (from a prior
28
+ # Kimi session for this same project) before claiming the pidfile. Subscribe
29
+ # resolves the project-specific pidfile name from .kimi/mcp.json itself, so
30
+ # concurrent sessions for OTHER projects are untouched.
31
+ nohup bash "$KIMI_SUB" --force 5 >/dev/null 2>&1 &
28
32
  exit 0
@@ -14,6 +14,19 @@ set -euo pipefail
14
14
 
15
15
  command -v jq >/dev/null 2>&1 || { echo "jq required" >&2; exit 1; }
16
16
 
17
+ # Parse --force flag (kills any existing listener for THIS project first).
18
+ # SessionStart hook passes --force so fresh sessions always get a fresh listener.
19
+ FORCE=0
20
+ ARGS=()
21
+ for arg in "$@"; do
22
+ if [ "$arg" = "--force" ]; then
23
+ FORCE=1
24
+ else
25
+ ARGS+=("$arg")
26
+ fi
27
+ done
28
+ set -- "${ARGS[@]+"${ARGS[@]}"}"
29
+
17
30
  # Resolve MCP config: per-project first, then global
18
31
  KIMI_MCP=""
19
32
  dir="$PWD"
@@ -60,14 +73,28 @@ fi
60
73
  PIDFILE="/tmp/patchcord_subscribe_${NAMESPACE_ID}_${AGENT_ID}.pid"
61
74
  NOTIFY_FILE="${HOME}/.kimi/patchcord-subscribe-notify.txt"
62
75
 
63
- # Pidfile guard: if another instance is already running, that's the desired
64
- # state (typically the SessionStart hook armed the listener). Exit 0 so flow
65
- # skill invocations don't surface as "background task failed".
76
+ # Pidfile guard.
77
+ # --force: kill the existing listener (if any) and take over. Used by SessionStart
78
+ # so a fresh Kimi session always gets a fresh listener for this project.
79
+ # default: if another instance is alive, exit 0 with a clear message so user-
80
+ # invoked flow skill calls are idempotent (no "background task failed").
66
81
  if [ -f "$PIDFILE" ]; then
67
82
  OLD_PID=$(cat "$PIDFILE" 2>/dev/null || echo "")
68
83
  if [ -n "$OLD_PID" ] && kill -0 "$OLD_PID" 2>/dev/null; then
69
- echo "Patchcord listener already running (pid $OLD_PID)"
70
- exit 0
84
+ if [ "$FORCE" = "1" ]; then
85
+ kill "$OLD_PID" 2>/dev/null || true
86
+ # Wait briefly for the old process to clean up its pidfile
87
+ for _ in 1 2 3 4 5; do
88
+ kill -0 "$OLD_PID" 2>/dev/null || break
89
+ sleep 0.2
90
+ done
91
+ rm -f "$PIDFILE" 2>/dev/null || true
92
+ else
93
+ echo "Patchcord listener already running (pid $OLD_PID)"
94
+ exit 0
95
+ fi
96
+ else
97
+ rm -f "$PIDFILE" 2>/dev/null || true
71
98
  fi
72
99
  fi
73
100
  echo $$ > "$PIDFILE"