chat-recall 0.7.29 → 0.7.31
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/README.md +0 -2
- package/dist/board-hooks.d.ts +7 -0
- package/dist/board-hooks.d.ts.map +1 -1
- package/dist/board-hooks.js +9 -3
- package/dist/board-hooks.js.map +1 -1
- package/dist/cli.js +3231 -2928
- package/dist/cli.js.map +1 -1
- package/dist/install-hooks.d.ts +3 -3
- package/dist/install-hooks.d.ts.map +1 -1
- package/dist/install-hooks.js +40 -14
- package/dist/install-hooks.js.map +1 -1
- package/dist/mcp-relay.js +1 -1
- package/dist/mcp.js +430 -149
- package/dist/message-hook.js +1 -1
- package/dist/watch.js +5 -6
- package/package.json +1 -1
- package/hooks/chat_recall_save_hook.sh +0 -260
package/dist/message-hook.js
CHANGED
package/dist/watch.js
CHANGED
|
@@ -4674,7 +4674,6 @@ function legacyMappings() {
|
|
|
4674
4674
|
return [
|
|
4675
4675
|
{ legacyPath: join2(root, "chat-recall-cache.db"), newPath: join2(newRoot, "cache.db"), isDir: false },
|
|
4676
4676
|
{ legacyPath: join2(root, "chat-recall-index"), newPath: join2(newRoot, "index"), isDir: true },
|
|
4677
|
-
{ legacyPath: join2(root, "chat-recall-memory"), newPath: join2(newRoot, "memory"), isDir: true },
|
|
4678
4677
|
{ legacyPath: join2(root, "chat-recall-identity.txt"), newPath: join2(newRoot, "identity.txt"), isDir: false },
|
|
4679
4678
|
{ legacyPath: join2(root, "chat-recall-hooks"), newPath: join2(newRoot, "hooks"), isDir: true },
|
|
4680
4679
|
// The legacy settings directory was named just "chat-recall" (no
|
|
@@ -27654,7 +27653,7 @@ var init_http = __esm({
|
|
|
27654
27653
|
CLI_VERSION = JSON.parse(readFileSync35(new URL("../package.json", import.meta.url), "utf-8")).version || CLI_VERSION;
|
|
27655
27654
|
} catch {
|
|
27656
27655
|
try {
|
|
27657
|
-
if (true) CLI_VERSION = "0.7.
|
|
27656
|
+
if (true) CLI_VERSION = "0.7.31";
|
|
27658
27657
|
} catch {
|
|
27659
27658
|
}
|
|
27660
27659
|
}
|
|
@@ -28148,7 +28147,7 @@ var init_telemetry = __esm({
|
|
|
28148
28147
|
init_sync_client();
|
|
28149
28148
|
cliVersion = () => {
|
|
28150
28149
|
try {
|
|
28151
|
-
return true ? "0.7.
|
|
28150
|
+
return true ? "0.7.31" : "dev";
|
|
28152
28151
|
} catch {
|
|
28153
28152
|
return "dev";
|
|
28154
28153
|
}
|
|
@@ -30513,7 +30512,7 @@ var init_sync_client = __esm({
|
|
|
30513
30512
|
ownVersion = JSON.parse(readFileSync39(join46(dir, "../package.json"), "utf-8")).version || ownVersion;
|
|
30514
30513
|
} catch {
|
|
30515
30514
|
try {
|
|
30516
|
-
if (true) ownVersion = "0.7.
|
|
30515
|
+
if (true) ownVersion = "0.7.31";
|
|
30517
30516
|
} catch {
|
|
30518
30517
|
}
|
|
30519
30518
|
}
|
|
@@ -33877,7 +33876,7 @@ try {
|
|
|
33877
33876
|
ownVersion2 = JSON.parse(readFileSync43(join52(dir, "../package.json"), "utf-8")).version || ownVersion2;
|
|
33878
33877
|
} catch {
|
|
33879
33878
|
try {
|
|
33880
|
-
if (true) ownVersion2 = "0.7.
|
|
33879
|
+
if (true) ownVersion2 = "0.7.31";
|
|
33881
33880
|
} catch {
|
|
33882
33881
|
}
|
|
33883
33882
|
}
|
|
@@ -34262,7 +34261,7 @@ async function runCollectorMigration(opts) {
|
|
|
34262
34261
|
init_sync_ledger();
|
|
34263
34262
|
init_collector_health();
|
|
34264
34263
|
import { existsSync as existsSync52, readFileSync as readFileSync49, statSync as statSync49 } from "fs";
|
|
34265
|
-
var CLI_VERSION3 = true ? "0.7.
|
|
34264
|
+
var CLI_VERSION3 = true ? "0.7.31" : "0.0.0";
|
|
34266
34265
|
var DEBOUNCE_MS = 5e3;
|
|
34267
34266
|
var PLANS_DIR = claudeBackend.plansDir();
|
|
34268
34267
|
var TASKS_DIR = claudeBackend.tasksDir();
|
package/package.json
CHANGED
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# chat-recall save hook — auto-saves memory every 15 messages
|
|
3
|
-
# Installed as a Claude Code hook in ~/.claude/hooks.json
|
|
4
|
-
#
|
|
5
|
-
# This hook fires every 15 messages during a session.
|
|
6
|
-
# It extracts key facts (decisions, topics, tools) and saves them
|
|
7
|
-
# so they're preserved even if the session ends unexpectedly.
|
|
8
|
-
#
|
|
9
|
-
# Setup (one-time):
|
|
10
|
-
# 1. Copy this file to ~/.claude/chat-recall-hooks/
|
|
11
|
-
# 2. Add to ~/.claude/hooks.json:
|
|
12
|
-
# {
|
|
13
|
-
# "hooks": {
|
|
14
|
-
# "Stop": [{"matcher": "", "hooks": [{"type": "command", "command": "/home/YOU/.claude/chat-recall-hooks/chat_recall_save_hook.sh"}]}],
|
|
15
|
-
# "PreCompact": [{"matcher": "", "hooks": [{"type": "command", "command": "/home/YOU/.claude/chat-recall-hooks/chat_recall_save_hook.sh --precompact"}]}]
|
|
16
|
-
# }
|
|
17
|
-
# }
|
|
18
|
-
|
|
19
|
-
set -euo pipefail
|
|
20
|
-
|
|
21
|
-
HOOKS_DIR="${HOME}/.claude/chat-recall-hooks"
|
|
22
|
-
MEMORY_DIR="${HOME}/.claude/chat-recall-memory"
|
|
23
|
-
STATE_FILE="${MEMORY_DIR}/last_save.json"
|
|
24
|
-
SESSION_ID=""
|
|
25
|
-
|
|
26
|
-
log() {
|
|
27
|
-
echo "[chat-recall-save] $(date +%H:%M:%S) $*" >&2
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
init() {
|
|
31
|
-
mkdir -p "${MEMORY_DIR}"
|
|
32
|
-
mkdir -p "${HOOKS_DIR}"
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
# Detect current session from transcript
|
|
36
|
-
detect_session() {
|
|
37
|
-
local projects_dir="${HOME}/.claude/projects"
|
|
38
|
-
|
|
39
|
-
# Find the most recently modified session file
|
|
40
|
-
local latest_file=""
|
|
41
|
-
local latest_time=0
|
|
42
|
-
|
|
43
|
-
if [[ -d "$projects_dir" ]]; then
|
|
44
|
-
for dir in "$projects_dir"/*/; do
|
|
45
|
-
if [[ -d "$dir" ]]; then
|
|
46
|
-
for file in "$dir"/*.jsonl; do
|
|
47
|
-
if [[ -f "$file" ]]; then
|
|
48
|
-
local mtime
|
|
49
|
-
mtime=$(stat -c %Y "$file" 2>/dev/null || stat -f %m "$file" 2>/dev/null || echo 0)
|
|
50
|
-
if [[ "$mtime" -gt "$latest_time" ]]; then
|
|
51
|
-
latest_time="$mtime"
|
|
52
|
-
latest_file="$file"
|
|
53
|
-
fi
|
|
54
|
-
fi
|
|
55
|
-
done
|
|
56
|
-
fi
|
|
57
|
-
done
|
|
58
|
-
fi
|
|
59
|
-
|
|
60
|
-
if [[ -n "$latest_file" && -f "$latest_file" ]]; then
|
|
61
|
-
SESSION_ID=$(basename "$latest_file" .jsonl)
|
|
62
|
-
fi
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
# Extract key facts from a session file
|
|
66
|
-
extract_facts() {
|
|
67
|
-
local session_file="$1"
|
|
68
|
-
local session_id="$2"
|
|
69
|
-
|
|
70
|
-
if [[ ! -f "$session_file" ]]; then
|
|
71
|
-
echo "{}"
|
|
72
|
-
return
|
|
73
|
-
fi
|
|
74
|
-
|
|
75
|
-
# Count messages
|
|
76
|
-
local msg_count
|
|
77
|
-
msg_count=$(wc -l < "$session_file" 2>/dev/null || echo 0)
|
|
78
|
-
|
|
79
|
-
# Extract unique tools used
|
|
80
|
-
local tools
|
|
81
|
-
tools=$(grep -o '"type":"tool_use"' "$session_file" 2>/dev/null | wc -l | tr -d ' ')
|
|
82
|
-
|
|
83
|
-
# Extract topics from first user message
|
|
84
|
-
local first_topic
|
|
85
|
-
first_topic=$(grep -m1 '"type":"user"' "$session_file" 2>/dev/null | \
|
|
86
|
-
sed 's/.*"text":"//' | sed 's/".*//' | head -c 200 | tr -d '\n' | tr -d '"')
|
|
87
|
-
|
|
88
|
-
# Extract decisions (heuristic)
|
|
89
|
-
local decisions=""
|
|
90
|
-
decisions=$(grep -i "decided\|chose\|going with\|recommend\|prefer" "$session_file" 2>/dev/null | \
|
|
91
|
-
head -3 | sed 's/.*"text":"//' | sed 's/".*//' | head -c 300 | tr -d '\n')
|
|
92
|
-
|
|
93
|
-
# Get project path
|
|
94
|
-
local project_path=""
|
|
95
|
-
for dir in "${HOME}"/.claude/projects/*/; do
|
|
96
|
-
if [[ -d "$dir" && -f "${dir}${session_id}.jsonl" ]]; then
|
|
97
|
-
project_path=$(echo "$dir" | sed "s|${HOME}/.claude/projects/||" | sed 's|/||g' | sed 's|^|/|')
|
|
98
|
-
project_path=$(echo "$project_path" | sed "s|-|/|g")
|
|
99
|
-
break
|
|
100
|
-
fi
|
|
101
|
-
done
|
|
102
|
-
|
|
103
|
-
# Output JSON
|
|
104
|
-
cat <<EOF
|
|
105
|
-
{
|
|
106
|
-
"session_id": "$session_id",
|
|
107
|
-
"project_path": "$project_path",
|
|
108
|
-
"message_count": $msg_count,
|
|
109
|
-
"tool_uses": $tools,
|
|
110
|
-
"first_topic": "$(echo "$first_topic" | jq -Rs '.' 2>/dev/null || echo "\"$first_topic\"")",
|
|
111
|
-
"decisions": "$(echo "$decisions" | jq -Rs '.' 2>/dev/null || echo "\"\"")",
|
|
112
|
-
"saved_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
113
|
-
}
|
|
114
|
-
EOF
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
# Count messages in current session
|
|
118
|
-
count_messages() {
|
|
119
|
-
local session_file="$1"
|
|
120
|
-
if [[ ! -f "$session_file" ]]; then
|
|
121
|
-
echo 0
|
|
122
|
-
return
|
|
123
|
-
fi
|
|
124
|
-
grep -c '"type":"user"\|\|"type":"assistant"' "$session_file" 2>/dev/null || echo 0
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
# Main save logic
|
|
128
|
-
do_save() {
|
|
129
|
-
local precompact="${1:-false}"
|
|
130
|
-
|
|
131
|
-
detect_session
|
|
132
|
-
|
|
133
|
-
if [[ -z "$SESSION_ID" ]]; then
|
|
134
|
-
log "No active session found"
|
|
135
|
-
return
|
|
136
|
-
fi
|
|
137
|
-
|
|
138
|
-
# Find the session file
|
|
139
|
-
local session_file=""
|
|
140
|
-
for dir in "${HOME}"/.claude/projects/*/; do
|
|
141
|
-
if [[ -f "${dir}${SESSION_ID}.jsonl" ]]; then
|
|
142
|
-
session_file="${dir}${SESSION_ID}.jsonl"
|
|
143
|
-
break
|
|
144
|
-
fi
|
|
145
|
-
done
|
|
146
|
-
|
|
147
|
-
if [[ -z "$session_file" || ! -f "$session_file" ]]; then
|
|
148
|
-
log "Session file not found for $SESSION_ID"
|
|
149
|
-
return
|
|
150
|
-
fi
|
|
151
|
-
|
|
152
|
-
# Extract and save facts
|
|
153
|
-
local facts
|
|
154
|
-
facts=$(extract_facts "$session_file" "$SESSION_ID")
|
|
155
|
-
|
|
156
|
-
local output_file="${MEMORY_DIR}/sessions/${SESSION_ID}.json"
|
|
157
|
-
mkdir -p "$(dirname "$output_file")"
|
|
158
|
-
|
|
159
|
-
# Merge with existing data if present
|
|
160
|
-
if [[ -f "$output_file" ]]; then
|
|
161
|
-
# Simple merge: update fields but preserve accumulated data
|
|
162
|
-
local existing_msg_count
|
|
163
|
-
existing_msg_count=$(jq -r '.accumulated_messages // 0' "$output_file" 2>/dev/null || echo 0)
|
|
164
|
-
local new_msg_count
|
|
165
|
-
new_msg_count=$(echo "$facts" | jq -r '.message_count')
|
|
166
|
-
local total_msgs=$((existing_msg_count + new_msg_count))
|
|
167
|
-
|
|
168
|
-
# Update but preserve accumulated decisions
|
|
169
|
-
local existing_decisions
|
|
170
|
-
existing_decisions=$(jq -r '.accumulated_decisions // []' "$output_file" 2>/dev/null || echo '[]')
|
|
171
|
-
|
|
172
|
-
echo "$facts" | jq --argjson decisions "$existing_decisions" --argjson total "$total_msgs" \
|
|
173
|
-
'. + {accumulated_messages: $total, accumulated_decisions: $decisions}' > "$output_file"
|
|
174
|
-
else
|
|
175
|
-
echo "$facts" | jq '. + {accumulated_messages: .message_count, accumulated_decisions: []}' > "$output_file"
|
|
176
|
-
fi
|
|
177
|
-
|
|
178
|
-
# Track this save
|
|
179
|
-
# `date -Iseconds` is GNU-only: BSD date (macOS) rejects -I and prints an
|
|
180
|
-
# empty string, so this field was blank on every Mac. -u +format works on
|
|
181
|
-
# both. saved_at_epoch is written alongside it because reading the ISO value
|
|
182
|
-
# BACK needed `date -d`, which BSD also lacks — storing the number means
|
|
183
|
-
# nothing has to parse a date at all.
|
|
184
|
-
echo "{\"session_id\": \"$SESSION_ID\", \"saved_at\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\", \"saved_at_epoch\": $(date +%s), \"precompact\": $precompact}" > "${STATE_FILE}"
|
|
185
|
-
|
|
186
|
-
if [[ "$precompact" == "true" ]]; then
|
|
187
|
-
log "[PRECOMPACT] Emergency save for $SESSION_ID"
|
|
188
|
-
else
|
|
189
|
-
log "Saved facts for $SESSION_ID ($(echo "$facts" | jq -r '.message_count') messages)"
|
|
190
|
-
fi
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
# Check if we should save (throttle to avoid too frequent saves)
|
|
194
|
-
should_save() {
|
|
195
|
-
local session_file="$1"
|
|
196
|
-
|
|
197
|
-
if [[ ! -f "${STATE_FILE}" ]]; then
|
|
198
|
-
return 0
|
|
199
|
-
fi
|
|
200
|
-
|
|
201
|
-
# Read the epoch we stored. The old code kept only an ISO string and parsed
|
|
202
|
-
# it with `date -d`, which does not exist on BSD date — so on macOS this
|
|
203
|
-
# always resolved to 0, the throttle never engaged, and the hook re-scanned
|
|
204
|
-
# the entire transcript on EVERY Stop event.
|
|
205
|
-
local last_save_epoch
|
|
206
|
-
last_save_epoch=$(jq -r '.saved_at_epoch // empty' "${STATE_FILE}" 2>/dev/null || echo "")
|
|
207
|
-
|
|
208
|
-
if [[ -z "$last_save_epoch" ]]; then
|
|
209
|
-
# A state file written before saved_at_epoch existed. Treat it as due
|
|
210
|
-
# rather than trying to parse its timestamp portably.
|
|
211
|
-
return 0
|
|
212
|
-
fi
|
|
213
|
-
local now_epoch
|
|
214
|
-
now_epoch=$(date +%s)
|
|
215
|
-
|
|
216
|
-
if (( now_epoch - last_save_epoch < 30 )); then
|
|
217
|
-
return 1
|
|
218
|
-
fi
|
|
219
|
-
|
|
220
|
-
return 0
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
main() {
|
|
224
|
-
init
|
|
225
|
-
|
|
226
|
-
local precompact="false"
|
|
227
|
-
if [[ "${1:-}" == "--precompact" ]]; then
|
|
228
|
-
precompact="true"
|
|
229
|
-
fi
|
|
230
|
-
|
|
231
|
-
detect_session
|
|
232
|
-
|
|
233
|
-
if [[ -z "$SESSION_ID" ]]; then
|
|
234
|
-
log "No session detected, skipping"
|
|
235
|
-
exit 0
|
|
236
|
-
fi
|
|
237
|
-
|
|
238
|
-
# Find session file
|
|
239
|
-
local session_file=""
|
|
240
|
-
for dir in "${HOME}"/.claude/projects/*/; do
|
|
241
|
-
if [[ -f "${dir}${SESSION_ID}.jsonl" ]]; then
|
|
242
|
-
session_file="${dir}${SESSION_ID}.jsonl"
|
|
243
|
-
break
|
|
244
|
-
fi
|
|
245
|
-
done
|
|
246
|
-
|
|
247
|
-
if [[ -z "$session_file" ]]; then
|
|
248
|
-
log "Session file not found"
|
|
249
|
-
exit 1
|
|
250
|
-
fi
|
|
251
|
-
|
|
252
|
-
if ! should_save "$session_file"; then
|
|
253
|
-
log "Throttled (recent save)"
|
|
254
|
-
exit 0
|
|
255
|
-
fi
|
|
256
|
-
|
|
257
|
-
do_save "$precompact"
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
main "$@"
|