搜索

PythonReactSEOPDF
GitHub Skill

session-logs

Search and analyze your own Lemon session logs (older/parent conversations) using jq.

z80dev☆ 114 仓库 Stars15 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

session-logs

Search your complete conversation history stored in Lemon session JSONL files. Use this when a user references older/parent conversations or asks what was said before.

Trigger

Use this skill when the user asks about prior chats, parent conversations, or historical context that isn't in current memory files.

Location

Session logs live under ~/.lemon/agent/sessions/ and are organized by encoded working directory name:

  • <encoded-cwd>/*.jsonl - Full conversation transcript per session

For example: ~/.lemon/agent/sessions/--home-user-project--/2026...jsonl

The first line in each .jsonl is a session header with metadata.

Structure

Each .jsonl file contains messages with:

  • type: "session" (metadata header) or "message" (conversation entries)
  • timestamp: Epoch timestamp
  • message.role: "user", "assistant", etc.
  • message.content[]: Text, thinking, or tool calls (filter type=="text" for human-readable content)
  • message.usage.cost.total: Cost per response

Common Queries

List all sessions by date and size
for f in ~/.lemon/agent/sessions/*/*.jsonl; do
  ts=$(jq -r 'select(.type=="session") | .timestamp' "$f")
  size=$(wc -c <"$f")
  started="$(date -r "$((ts / 1000))" '+%F %T' 2>/dev/null || printf 'ts=%s' "$ts")"
  echo "$started $size $(basename "$f")"
done | sort -r
Find sessions from a specific day
for f in ~/.lemon/agent/sessions/*/*.jsonl; do
  ts=$(jq -r 'select(.type=="session") | .timestamp' "$f")
  day="$(date -r "$((ts / 1000))" '+%F' 2>/dev/null || true)"
  [[ "$day" == "2026-01-06" ]] && echo "$f"
done
Extract user messages from a session
jq -r 'select(.type=="message" and .message.role == "user") | .message.content[]? | select(.type == "text") | .text' <session>.jsonl
Search for keyword in assistant responses
jq -r 'select(.type=="message" and .message.role == "assistant") | .message.content[]? | select(.type == "text") | .text' <session>.jsonl | rg -i "keyword"
Get total cost for a session
jq -s '[.[] | select(.type=="message") | .message.usage.cost.total // 0] | add' <session>.jsonl
Daily cost summary
for f in ~/.lemon/agent/sessions/*/*.jsonl; do
  day="$(date -r "$(( $(jq -r 'select(.type=="session") | .timestamp' "$f") / 1000 ))" '+%F' 2>/dev/null || continue)"
  cost=$(jq -s '[.[] | select(.type=="message") | .message.usage.cost.total // 0] | add' "$f")
  echo "$day $cost"
done | awk '{a[$1]+=$2} END {for(d in a) print d, "$"a[d]}' | sort -r
Count messages and tokens in a session
jq -s '{
  messages: length,
  user: [.[] | select(.type=="message" and .message.role == "user")] | length,
  assistant: [.[] | select(.type=="message" and .message.role == "assistant")] | length,
  first: .[0].timestamp,
  last: .[-1].timestamp
}' <session>.jsonl
Tool usage breakdown
jq -r '.message.content[]? | select(.type == "toolCall") | .name' <session>.jsonl | sort | uniq -c | sort -rn
Search across ALL sessions for a phrase
rg -l "phrase" ~/.lemon/agent/sessions/*/*.jsonl

Tips

  • Sessions are append-only JSONL (one JSON object per line)
  • Large sessions can be several MB - use head/tail for sampling
  • ~/.lemon/agent/sessions is the session root in Lemon
  • No separate sessions.json index file exists for logs

Fast text-only hint (low noise)

jq -r 'select(.type=="message") | .message.content[]? | select(.type=="text") | .text' ~/.lemon/agent/sessions/*/*.jsonl | rg 'keyword'

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-03-11
索引更新时间
2026-03-11
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!