← 返回 Skills 市场
ouhaitao

Session History Share

作者 ouhaitao · GitHub ↗ · v1.0.2 · MIT-0
cross-platform ⚠ suspicious
8
总下载
0
收藏
0
当前安装
3
版本数
在 OpenClaw 中安装
/install session-history-share
功能描述
Automatically injects compressed summaries of previous session histories into new sessions after daily reset for context continuity.
使用说明 (SKILL.md)

Session History Share

跨 Session 对话历史自动共享方案。在每日重置后,自动将旧 Session 的压缩摘要注入新 Session 上下文。

原理

每天 3:30 AM
  → Cron isolated session 获取所有活跃 session
  → 读取 JSONL 尾部,向前查找 compaction 事件
  → 有 compaction → 提取 summary
  → 无 compaction → 提取最近 200 条消息生成简要摘要
  → 写入 .session_history/\x3CsafeKey>/\x3CsafeKey>-YYYY-MM-DD.md

每天 4:00 AM
  → OpenClaw 定时重置 Session

新 Session 每轮
  → agent:bootstrap hook 读取最新存档(带 10 分钟缓存)
  → push BOOTSTRAP.md 到 bootstrapFiles
  → 摘要注入 prompt

安装

# 自动安装(创建 hook + 配置 cron)
node skills/session-history-share/scripts/install.sh

# 或手动安装
# 1. 复制 hook 目录到 ~/.openclaw/hooks/session-history-share/
# 2. 在 openclaw.json 注册 hook
# 3. 创建 cron 定时任务

配置

Hook 注册(openclaw.json)

{
  "hooks": {
    "internal": {
      "enabled": true,
      "entries": {
        "session-history-share": {
          "enabled": true
        }
      }
    }
  }
}

定时任务

openclaw cron add \
  --name "定时压缩活跃会话" \
  --cron "30 3 * * *" \
  --tz "Asia/Shanghai" \
  --session isolated \
  --message "执行以下步骤压缩所有活跃会话:\
\
1. 使用 sessions_list 获取所有活跃 session(排除 cron 和 subagent)\
2. 对每个 session 的 transcriptPath(JSONL 文件),执行以下步骤:\
   a. 使用 read 读取 JSONL 文件尾部(用 limit 从 offset 读取,不要读完整文件)\
   b. 从最后一条消息向前查找,找到最近的 compaction 事件(type=compaction)\
   c. 如果找到 compaction:提取 compaction.summary 字段的纯文本值\
   d. 如果没找到 compaction:提取最近 200 条 user/assistant 消息,生成简要摘要\
   e. 将摘要内容写入 .session_history/\x3CsafeSessionKey>/\x3CsafeSessionKey>-\x3CYYYY-MM-DD>.md\
      - safeSessionKey 是把 sessionKey 中的冒号替换为下划线\
   f. 生成的摘要在**不丢失关键内容**的情况下尽可能的**简短**\
1. **文件内容只包含摘要正文纯文本,不要写任何 metadata header(不要 Session Key、Date、分隔线、标题等)**\
2. 每个 sessionKey 只保留最近 3 个存档文件,删除旧的\
3. 完成后回复 NO_REPLY"

技术特点

  • 自动压缩:提取 compaction summary 或生成简要摘要
  • 每轮注入:通过 agent:bootstrap hook 每轮注入
  • 内存缓存:同 Session 内 10 分钟缓存过期,之后重新读取
  • 存档轮转:每个 Session 保留最近 3 个存档

查看日志

openclaw logs | grep "session-history"

卸载

node skills/session-history-share/scripts/uninstall.sh

文件结构

session-history-share/
├── SKILL.md
├── README.md
├── scripts/
│   ├── install.sh
│   └── uninstall.sh
└── hook/
    ├── HOOK.md
    └── handler.js

版本

  • v1.0 - 轻量注入(自动压缩 + bootstrap 注入)
  • v1.0.1 - 更新定时任务描述 + README 链接
  • v1.0.2 - 添加缓存过期机制(10 分钟 TTL)
安全使用建议
Install only if you intentionally want prior OpenClaw conversations summarized, stored on disk, and automatically injected into later sessions. Review the cron job and ~/.openclaw/openclaw.json changes, avoid using it with sessions containing secrets or client data unless you accept that carryover, and know how to remove the hook, cron task, and .session_history archives.
能力评估
Purpose & Capability
The core purpose is coherent: preserve prior OpenClaw session context and inject it into future sessions. The concern is that this purpose inherently handles sensitive conversation data and can carry prior instructions or secrets into later prompts.
Instruction Scope
The artifacts disclose automatic extraction, storage, and bootstrap injection, but they do not provide clear opt-in boundaries, per-session exclusion, redaction, review, or consent before prior history is reintroduced.
Install Mechanism
The installer copies a hook, modifies ~/.openclaw/openclaw.json, and creates an OpenClaw cron task by default. These changes are purpose-aligned but persistent and high-trust, with no interactive confirmation or backup flow in the script.
Credentials
Reading active session transcript tails and storing summaries is proportionate to a history-sharing tool, but broad automatic collection of session content is sensitive and under-scoped for users who expect session isolation.
Persistence & Privilege
The skill creates ongoing scheduled processing, stores summaries under ~/.openclaw/workspace/.session_history, keeps recent archives, and injects them into BOOTSTRAP.md on agent bootstrap. An uninstall script exists, which reduces but does not remove the persistence concern.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install session-history-share
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /session-history-share 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.2
添加缓存过期机制(10分钟TTL);更新 SKILL.md/README.md 文档
v1.0.1
更新定时任务描述为完整版本;添加 README.md 含 GitHub 和 ClawHub 链接
v1.0.0
初始版本:跨 Session 历史自动注入(轻量注入)。包含 agent:bootstrap hook + Cron 定时压缩 + 安装/卸载脚本
元数据
Slug session-history-share
版本 1.0.2
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 3
常见问题

Session History Share 是什么?

Automatically injects compressed summaries of previous session histories into new sessions after daily reset for context continuity. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 8 次。

如何安装 Session History Share?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install session-history-share」即可一键安装,无需额外配置。

Session History Share 是免费的吗?

是的,Session History Share 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Session History Share 支持哪些平台?

Session History Share 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Session History Share?

由 ouhaitao(@ouhaitao)开发并维护,当前版本 v1.0.2。

💬 留言讨论