patchcord 0.5.73 → 0.5.75

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/bin/patchcord.mjs CHANGED
@@ -1835,13 +1835,13 @@ if (!cmd || cmd === "install" || cmd === "agent" || cmd?.startsWith("--")) {
1835
1835
  console.log(` ${cyan}${aliasLine}${r}`);
1836
1836
  }
1837
1837
  // Prominent kimi-pc reminder — users MUST run kimi-pc instead of kimi
1838
- console.log(`\n ${yellow}┌────────────────────────────────────────────────────────────┐${r}`);
1839
- console.log(` ${yellow}│${r} ${bold}IMPORTANT:${r} Run ${cyan}${bold}kimi-pc${r} instead of ${dim}kimi${r} in this project ${yellow}│${r}`);
1840
- console.log(` ${yellow}│${r} ${dim}kimi-pc loads the per-project agent from .kimi/mcp.json${r} ${yellow}│${r}`);
1838
+ console.log(`\n ${yellow}┌─────────────────────────────────────────────────────────────┐${r}`);
1839
+ console.log(` ${yellow}│${r} ${bold}IMPORTANT:${r} Run ${white}${bold}kimi-pc${r} instead of ${dim}kimi${r} in this project ${yellow}│${r}`);
1840
+ console.log(` ${yellow}│${r} ${dim}kimi-pc loads the per-project agent from .kimi/mcp.json${r} ${yellow}│${r}`);
1841
1841
  if (aliasInstalled) {
1842
- console.log(` ${yellow}│${r} Reload shell: ${cyan}source ~/${primaryName}${r} ${yellow}│${r}`);
1842
+ console.log(` ${yellow}│${r} Reload shell: ${cyan}source ~/${primaryName}${r} ${yellow}│${r}`);
1843
1843
  }
1844
- console.log(` ${yellow}└────────────────────────────────────────────────────────────┘${r}`);
1844
+ console.log(` ${yellow}└─────────────────────────────────────────────────────────────┘${r}`);
1845
1845
  } else if (isVSCode) {
1846
1846
  // VS Code: write .vscode/mcp.json (per-project)
1847
1847
  const vscodeDir = join(cwd, ".vscode");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchcord",
3
- "version": "0.5.73",
3
+ "version": "0.5.75",
4
4
  "description": "Cross-machine agent messaging for Claude Code and Codex",
5
5
  "author": "ppravdin",
6
6
  "license": "MIT",
@@ -54,8 +54,11 @@ Kimi has **two** complementary ways to learn about incoming messages:
54
54
 
55
55
  ```
56
56
  Run: patchcord subscribe
57
+ timeout: 86400
57
58
  ```
58
59
 
60
+ The `timeout` parameter is required — background tasks default to 60 seconds, which is too short for polling. Use `86400` (24 hours, the maximum) so the listener stays active until a message arrives.
61
+
59
62
  This ensures the next incoming message will also wake you up. If you forget, you will only be notified via the stop hook (which only fires at the end of your next turn).
60
63
 
61
64
  ## Do the work, never just acknowledge
@@ -6,6 +6,9 @@ set -euo pipefail
6
6
  #
7
7
  # Supports per-project .kimi/mcp.json (walks up from cwd) and
8
8
  # falls back to global ~/.kimi/mcp.json.
9
+ #
10
+ # CRITICAL: Kimi v1.44.0 ONLY acts on Stop hooks when they BLOCK (exit code 2).
11
+ # stdout is silently discarded. stderr becomes the "reason" that triggers a new turn.
9
12
 
10
13
  command -v jq >/dev/null 2>&1 || exit 0
11
14
 
@@ -13,9 +16,7 @@ INPUT=$(cat)
13
16
 
14
17
  # Guard: stop_hook_active prevents infinite loops
15
18
  STOP_ACTIVE=$(echo "$INPUT" | jq -r '.stop_hook_active // false' 2>/dev/null || echo "false")
16
- if [ "$STOP_ACTIVE" = "true" ]; then
17
- exit 0
18
- fi
19
+ [ "$STOP_ACTIVE" = "true" ] && exit 0
19
20
 
20
21
  # Resolve MCP config: per-project first, then global
21
22
  KIMI_MCP=""
@@ -33,9 +34,7 @@ if [ -n "$CWD" ]; then
33
34
  fi
34
35
 
35
36
  # Fallback to global config
36
- if [ -z "$KIMI_MCP" ]; then
37
- KIMI_MCP="${HOME}/.kimi/mcp.json"
38
- fi
37
+ [ -z "$KIMI_MCP" ] && KIMI_MCP="${HOME}/.kimi/mcp.json"
39
38
 
40
39
  TOKEN=""
41
40
  URL=""
@@ -45,9 +44,7 @@ if [ -f "$KIMI_MCP" ]; then
45
44
  URL=$(jq -r '.mcpServers.patchcord.url // empty' "$KIMI_MCP" 2>/dev/null || true)
46
45
  fi
47
46
 
48
- if [ -z "$URL" ] || [ -z "$TOKEN" ]; then
49
- exit 0
50
- fi
47
+ [ -z "$URL" ] || [ -z "$TOKEN" ] && exit 0
51
48
 
52
49
  # Normalize URL to base
53
50
  BASE_URL=$(echo "$URL" | sed 's|/mcp$||; s|/mcp/bearer$||')
@@ -57,26 +54,26 @@ HTTP_CODE=$(curl -s -o /tmp/patchcord_kimi_inbox.json -w "%{http_code}" --max-ti
57
54
  -H "Authorization: Bearer ${TOKEN}" \
58
55
  "${BASE_URL}/api/inbox?status=pending&limit=5&count_only=1" 2>/dev/null || echo "000")
59
56
 
60
- if [ "$HTTP_CODE" != "200" ]; then
61
- rm -f /tmp/patchcord_kimi_inbox.json
62
- exit 0
63
- fi
57
+ [ "$HTTP_CODE" != "200" ] && { rm -f /tmp/patchcord_kimi_inbox.json; exit 0; }
64
58
 
65
59
  RESPONSE=$(cat /tmp/patchcord_kimi_inbox.json 2>/dev/null || echo '{"count":0}')
66
60
  rm -f /tmp/patchcord_kimi_inbox.json
67
61
 
68
62
  COUNT=$(echo "$RESPONSE" | jq -r '.count // .pending_count // 0' 2>/dev/null || echo "0")
69
63
 
70
- if [ "$COUNT" -gt 0 ]; then
71
- # Deduplicate: only notify once every 30 seconds
72
- NOTIFY_LOCK="/tmp/patchcord_kimi_notify_lock"
73
- if [ -f "$NOTIFY_LOCK" ]; then
74
- LOCK_MTIME=$(stat -c %Y "$NOTIFY_LOCK" 2>/dev/null || stat -f %m "$NOTIFY_LOCK" 2>/dev/null || echo "0")
75
- NOW=$(date +%s)
76
- [ $(( NOW - LOCK_MTIME )) -lt 30 ] && exit 0
77
- fi
78
- touch "$NOTIFY_LOCK"
79
- echo "📬 Patchcord: You have ${COUNT} pending message(s). Call inbox() to read and reply."
64
+ [ "$COUNT" -gt 0 ] || exit 0
65
+
66
+ # Deduplicate: only notify once every 30 seconds
67
+ NOTIFY_LOCK="/tmp/patchcord_kimi_notify_lock"
68
+ if [ -f "$NOTIFY_LOCK" ]; then
69
+ LOCK_MTIME=$(stat -c %Y "$NOTIFY_LOCK" 2>/dev/null || stat -f %m "$NOTIFY_LOCK" 2>/dev/null || echo "0")
70
+ NOW=$(date +%s)
71
+ [ $(( NOW - LOCK_MTIME )) -lt 30 ] && exit 0
80
72
  fi
81
73
 
82
- exit 0
74
+ touch "$NOTIFY_LOCK"
75
+
76
+ # Exit 2 + stderr = Kimi starts a new turn with this as the user message.
77
+ # stdout is silently discarded by Kimi for Stop hooks.
78
+ printf '%s\n' "📬 Patchcord: You have ${COUNT} pending message(s). Call inbox() to read and reply." >&2
79
+ exit 2