Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions claude/claude-plugin/funes/scripts/funes-index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ agent_version() {
# of the last of them, or, before there is one, the `spool` record `setup add` wrote just before
# that walk. The transcript the payload named was converted already and is skipped. The next mark is
# the stamp `$3` the worker took before it converted anything, unless a conversion failed and
# dropped it.
# dropped it. The journal a workflow keeps beside its sub-agents holds no turn and is left out.
convert_stale() {
jq=$1
named=$2
Expand All @@ -82,7 +82,7 @@ convert_stale() {
mark="$HERE/converted"
since=$mark
[ -e "$since" ] || since="$HERE/spool"
find "$projects" -type f -name '*.jsonl' -newer "$since" 2>/dev/null | while IFS= read -r src; do
find "$projects" -type f -name '*.jsonl' ! -name journal.jsonl -newer "$since" 2>/dev/null | while IFS= read -r src; do
[ "$src" = "$named" ] || convert_one "$jq" "$src" || rm -f "$stamp"
done
[ ! -e "$stamp" ] || mv -f "$stamp" "$mark"
Expand Down
9 changes: 5 additions & 4 deletions claude/setup
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ lost() {

# Convert the transcripts Claude Code has already written, so recall reaches them before the next
# turn. Sub-agent transcripts nest under their session's directory and are picked up by the same
# walk. What the memory holds stays beside the scripts, where the converter reads the numbering
# each session was indexed with.
# walk. The journal a workflow keeps beside its sub-agents holds no turn and is left out. What the
# memory holds stays beside the scripts, where the converter reads the numbering each session was
# indexed with.
#
# The walk shares the mark the hooks' sweeps keep: every transcript older than it was converted as
# it stands, by the walk that stamped it or by a sweep since. So a re-run reads the transcripts
Expand All @@ -115,9 +116,9 @@ seed() {
indexed >"$rows.new"
: >"$stamp"
if [ -e "$mark" ] && [ ! -e "$legacy" ] && [ -f "$rows" ] && ! lost "$rows" "$rows.new"; then
find "$projects" -type f -name '*.jsonl' -newer "$mark"
find "$projects" -type f -name '*.jsonl' ! -name journal.jsonl -newer "$mark"
else
find "$projects" -type f -name '*.jsonl'
find "$projects" -type f -name '*.jsonl' ! -name journal.jsonl
fi >"$work/transcripts" || true
mv -f "$rows.new" "$rows"
awk 'NF == 3 { print $1, $2 }' "$rows" >"$work/indexed"
Expand Down
7 changes: 6 additions & 1 deletion claude/test/hooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,18 @@ await() {
fail "$2"
}

# Two sessions written after the install: the hook fires for one of them only.
# Two sessions written after the install, and the journal a workflow keeps beside its sub-agents:
# the hook fires for one of the sessions only.
tick
transcript a.jsonl
transcript b.jsonl
journal="$tree/a/subagents/workflows/wf_1/journal.jsonl"
mkdir -p "${journal%/*}"
printf '%s\n' '{"type":"started","agentId":"agent-1","key":"review"}' >"$journal"
fire
[ -f "$spool/a.funes.jsonl" ] || fail "the session the payload named was not converted"
[ -f "$spool/b.funes.jsonl" ] || fail "the session whose hook never fired was not converted"
[ ! -e "$spool/journal.funes.jsonl" ] || fail "a workflow's journal was converted"
[ -f "$scripts/converted" ] || fail "the sweep left no mark"

# A third, written after that run; the second, drained by funes meanwhile, is not re-emitted.
Expand Down
7 changes: 7 additions & 0 deletions claude/test/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ mkdir -p "$tree"
done
cat "$BUNDLE/claude-plugin/funes/test/session.jsonl"
} >"$tree/session.jsonl"
# The journal a workflow keeps beside its sub-agents: records the converter makes no turn of.
journal="$tree/session/subagents/workflows/wf_1/journal.jsonl"
mkdir -p "${journal%/*}"
printf '%s\n' '{"type":"started","agentId":"agent-1","key":"review"}' \
'{"type":"result","agentId":"agent-1","key":"review","result":"ok"}' >"$journal"

cp -R "$BUNDLE" "$HOME/.funes/agents/claude"
setup="$HOME/.funes/agents/claude/setup"
Expand Down Expand Up @@ -68,6 +73,7 @@ if grep -q acme/kb "$hooks"; then fail "the memory is in the hook command"; fi
[ "$(cat "$plugin/funes/scripts/memory")" = acme/kb ] || fail "no memory file"
[ "$(cat "$plugin/funes/scripts/spool")" = "$FUNES_HOME/spool/claude" ] || fail "the spool is not recorded"
[ -f "$FUNES_HOME/spool/claude/session.funes.jsonl" ] || fail "the history was not seeded"
[ ! -e "$FUNES_HOME/spool/claude/journal.funes.jsonl" ] || fail "a workflow's journal was converted"
mark="$plugin/funes/scripts/converted"
[ -f "$mark" ] || fail "the walk left no mark"
[ ! -e "$plugin/funes/scripts/swept" ] || fail "the mark of the earlier hooks stays"
Expand Down Expand Up @@ -130,6 +136,7 @@ age_mark
"$setup" add acme/kb >/dev/null
[ ! -e "$older" ] || fail "a transcript older than the mark was read"
[ ! -e "$seeded" ] || fail "a transcript whose last turn is indexed was converted again"
[ ! -e "$FUNES_HOME/spool/claude/journal.funes.jsonl" ] || fail "a workflow's journal newer than the mark was converted"
# The rows stay beside the scripts, for the converter.
[ "$(cat "$plugin/funes/scripts/indexed")" = "other 2026-10-01T09:30:00.000Z 4
$id $last 5" ] || fail "the memory's rows were not kept: $(cat "$plugin/funes/scripts/indexed")"
Expand Down
Loading