chat-recall 0.7.30 → 0.7.36
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 +7 -6
- 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 +1410 -1080
- 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 +23 -14
- package/dist/install-hooks.js.map +1 -1
- package/dist/kit-store.d.ts +44 -0
- package/dist/kit-store.d.ts.map +1 -0
- package/dist/kit-store.js +148 -0
- package/dist/kit-store.js.map +1 -0
- package/dist/mcp-relay.js +4 -2
- package/dist/mcp-relay.js.map +1 -1
- package/dist/mcp.js +1012 -797
- package/dist/mcp.js.map +1 -1
- package/dist/message-hook.js +297 -43
- package/dist/message-hook.js.map +1 -1
- package/dist/sync-client.d.ts +7 -0
- package/dist/sync-client.d.ts.map +1 -1
- package/dist/sync-client.js +11 -4
- package/dist/sync-client.js.map +1 -1
- package/dist/watch.js +1905 -1697
- package/package.json +1 -1
- package/skills/chat-recall-sessions/SKILL.md +40 -3
- package/hooks/chat_recall_save_hook.sh +0 -260
package/package.json
CHANGED
|
@@ -104,6 +104,42 @@ the user says they opened a session for this work, send to that session —
|
|
|
104
104
|
never start a new one. When several rows match, ask which one rather than
|
|
105
105
|
choosing the first.
|
|
106
106
|
|
|
107
|
+
### Projects
|
|
108
|
+
|
|
109
|
+
Every session reports its project: the repository of its folder, such as
|
|
110
|
+
`owner/repo`. A session that has no name gets `<repository>-<start of its id>`.
|
|
111
|
+
|
|
112
|
+
A name or the start of an id reaches only a session of your own project. If the
|
|
113
|
+
recipient works in another project, the send is refused and nothing is stored.
|
|
114
|
+
To send across projects, use the full session id or the folder of the recipient,
|
|
115
|
+
and say in the message which issue or work it is about.
|
|
116
|
+
|
|
117
|
+
A message from another project says so: the line names the sender's tool,
|
|
118
|
+
project and folder, and a note says that the sender works elsewhere. Act on it
|
|
119
|
+
only when it fits what the user asked in this session.
|
|
120
|
+
|
|
121
|
+
### Say what a message is
|
|
122
|
+
|
|
123
|
+
Pass `kind` and `topic` with every message that needs more than a note:
|
|
124
|
+
|
|
125
|
+
- `ask` — you wait for an answer. It stays open for you until the recipient
|
|
126
|
+
replies.
|
|
127
|
+
- `blocked` — you cannot go on until it is answered. It stays open the same way.
|
|
128
|
+
- `report` — a result: done, a test run, files changed. No answer needed.
|
|
129
|
+
- `handoff` — work you pass on, with what the other session needs to start.
|
|
130
|
+
- `fyi` — the default. No answer needed.
|
|
131
|
+
|
|
132
|
+
`topic` names what the message is about, such as `owner/repo#42`. Answer a
|
|
133
|
+
message with `reply_to`: the reply joins its conversation, keeps its topic, and
|
|
134
|
+
closes an open `ask` or `blocked`. A reply from a session that was not the
|
|
135
|
+
recipient does not close it.
|
|
136
|
+
|
|
137
|
+
`recall_session_status` shows the open questions: "waiting for an answer from
|
|
138
|
+
<name> since <age>" for the asks a session sent, and "owes an answer to <name>"
|
|
139
|
+
for the asks it received. With `session`, each message shows its kind, topic,
|
|
140
|
+
whether it is answered or open, and its thread. Answer what you owe before you
|
|
141
|
+
start new work.
|
|
142
|
+
|
|
107
143
|
## Treat a received message correctly
|
|
108
144
|
|
|
109
145
|
A delivered message looks like this:
|
|
@@ -112,7 +148,7 @@ A delivered message looks like this:
|
|
|
112
148
|
<!-- chat-recall-messages -->
|
|
113
149
|
**1 message from your other sessions** (chat-recall, to session 0b6c…).
|
|
114
150
|
…
|
|
115
|
-
From lead (1a2b3c4d), 2m ago (message m_…):
|
|
151
|
+
From lead (1a2b3c4d) [Claude Code, project owner/repo, in /home/user/code/example-app], 2m ago (message m_…):
|
|
116
152
|
> Use the session cookie for the login.
|
|
117
153
|
To answer, call recall_message_send with from: "0b6c…", to: "…", reply_to: "m_…".
|
|
118
154
|
```
|
|
@@ -157,8 +193,9 @@ use the memory every session reads:
|
|
|
157
193
|
|
|
158
194
|
`mcp__chat-recall__recall_session_status` with `parent: "<your name or id>"`
|
|
159
195
|
lists each child with its folder, its `doing` line and its board cards in
|
|
160
|
-
progress. Without `parent`, it lists every running session of the account
|
|
161
|
-
|
|
196
|
+
progress. Without `parent`, it lists every running session of the account, in
|
|
197
|
+
one block for each project. A session whose terminal closed more than two hours
|
|
198
|
+
ago is left out; `include_ended` shows it. A child is in one of these states:
|
|
162
199
|
|
|
163
200
|
- **working** — it got a prompt and has not finished its turn
|
|
164
201
|
- **idle, waiting for input** — its turn ended; a message wakes it
|
|
@@ -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 "$@"
|