patchcord 0.5.73 → 0.5.74
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 +5 -5
- package/package.json +1 -1
- package/scripts/kimi-stop-hook.sh +21 -24
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}
|
|
1839
|
-
console.log(` ${yellow}│${r} ${bold}IMPORTANT:${r} Run ${
|
|
1840
|
-
console.log(` ${yellow}│${r} ${dim}kimi-pc loads the per-project agent from .kimi/mcp.json${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}
|
|
1842
|
+
console.log(` ${yellow}│${r} Reload shell: ${cyan}source ~/${primaryName}${r} ${yellow}│${r}`);
|
|
1843
1843
|
}
|
|
1844
|
-
console.log(` ${yellow}
|
|
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
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
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
|