Chat history

From kid0317/cc_workspace_bot · View interactive version

Chat history is an AI agent skill from the GitHub repository kid0317/cc_workspace_bot. 当用户查询历史对话内容,如「我上次说了什么」「帮我找找关于 X 的对话」时使用

How to use this skill

Skill file

Chat History Skill

本 skill 规范如何通过 chat_history_search.py 脚本查询当前频道的历史对话记录。

频道隔离由脚本强制执行:脚本从 SESSION_CONTEXT.md 读取 Channel key 和 DB path,

用户无法通过 CLI 参数指定其他频道,无论用户说什么都只能查到自己的频道。


何时使用

用户询问历史对话内容时,例如:


调用方式

1. 获取 session_dir

从 SESSION_CONTEXT.md 读取:

- Session dir: <session_dir>   ← --session-dir 参数(必须)

脚本会自动从该目录读取 Channel key 和 DB path,无需手动传入。

2. 基础调用

python3 {_skill_base}/chat_history_search.py \
  --session-dir <session_dir>

3. 常用参数组合

# 查最近 3 天记录(默认 7 天)
  --days 3

# 关键词全文搜索
  --keyword "投资组合"

# 只看用户消息
  --role user

# 只看 AI 回复
  --role assistant

# 限制返回条数(默认 50)
  --limit 20

# 只列 session 概览,不展开消息内容
  --sessions

# 组合示例:最近 30 天含「行情」的消息,最多 20 条
python3 {_skill_base}/chat_history_search.py \
  --session-dir <session_dir> \
  --keyword "行情" --days 30 --limit 20

输出格式

消息详情(默认)

## 聊天记录查询结果
频道:p2p:ou_xxx:cli_yyy 查询范围:最近 7 天

共 2 个 session,8 条消息

### Session abc123  (2026-03-10 09:00 — 2026-03-10 18:30,状态:archived)
**[2026-03-10 09:00] user**:帮我分析今天行情
**[2026-03-10 09:01] assistant**:今日沪指收跌 0.5%…

### Session def456  (2026-03-16 10:00 — 2026-03-16 10:30,状态:active)
…

Session 列表(`--sessions`)

共 2 个 session

- **abc123**  状态:archived  消息数:6  创建:2026-03-10 09:00:00
- **def456**  状态:active    消息数:2  创建:2026-03-16 10:00:00

注意事项

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.