← 返回 Skills 市场
liuxiaolong1988

Lingxi-MindVault - Auto Memory Extraction for OpenClaw

作者 Lingxi(灵曦) · GitHub ↗ · v1.1.15 · MIT-0
cross-platform ✓ 安全检测通过
228
总下载
3
收藏
0
当前安装
14
版本数
在 OpenClaw 中安装
/install lingxi-memory
功能描述
自动记忆提炼 & 写入飞书知识库。定时扫描 OpenClaw 会话文件,自动提炼有价值的记忆,写入飞书多维表格/云文档知识库。
使用说明 (SKILL.md)

Lingxi-MindVault - 灵曦记忆系统:自动记忆提炼 & 写入飞书知识库

⚠️ 风险提示

本技能的正常工作需要:

  1. 读取本地 OpenClaw 会话文件(包含你的聊天记录)→ 这是功能必需,因为要提炼记忆内容
  2. 将会话内容传给 AI agent 进行提炼 → AI 需要分析内容才能提炼
  3. 将提炼结果写入你 自己配置的 飞书知识库 → 结果存储在你自己的飞书空间

如果你不希望会话内容被 AI 处理,或者不希望数据存储到飞书,请不要安装。

描述

灵曦自动记忆系统,定时扫描 OpenClaw 会话文件,自动提炼有价值的记忆,写入飞书多维表格/云文档知识库。

v5 新架构:一次完成,省去队列,bash 调用 agent,agent 直接提炼 + 写入 + 通知,更简洁更实时!

功能特点

  • ✅ 稳定排除 heartbeat 会话(当前 + 历史自动标记)
  • ✅ 支持 .jsonl / .jsonl.reset.* / .jsonl.deleted.* 所有会话格式
  • ✅ 自动过滤空会话/小会话(用户消息数 \x3C 1 或内容长度 \x3C 20)
  • ✅ 完整的异常处理和通知,每个阶段都有错误通知
  • ✅ 超时支持 300 秒(5分钟),适应大会话
  • ✅ 开源友好,所有配置通过环境变量指定,无硬编码敏感信息
  • ✅ 启动检查,如果缺少必需环境变量会立即报错,不会静默使用错误配置
  • ✅ 原子进程锁,防止重复运行
  • ✅ 过期锁自动清理,不会死锁

架构流程图

【阶段 1:定时触发】
    │
    ├─▶ crontab
    │     ├─ 白天(8:00-22:00):每 1 分钟
    │     └─ 夜间(22:00-次日8:00):每 5 分钟
    │
【阶段 2:会话检查】
    │
    ├─▶ session_check.sh
    │     │
    │     ├─ 1. 获取进程锁(/tmp/session_check.lock)
    │     │
    │     ├─ 2. 读取 sessions.json
    │     │
    │     ├─ 3. 获取活跃会话
    │     │     ├─ 只保留最近 24 小时内更新的
    │     │     └─ 排除 key 为 "agent:main:main" 的 heartbeat 会话(活跃列表层面排除)
    │     │
    │     ├─ 4. 遍历所有会话文件
    │     │     ├─ .jsonl
    │     │     ├─ .jsonl.reset.*
    │     │     └─ .jsonl.deleted.*
    │     │
    │     ├─ 5. 对每个会话:
    │     │     │
    │     │     ├─ a. 文件存在?
    │     │     │   └─ 否 → 下一个
    │     │     │
    │     │     ├─ b. 已处理过?(/tmp/processed_sessions.tmp)
    │     │     │   └─ 是 → 下一个
    │     │     │
    │     │     ├─ c. 是 heartbeat 会话?
    │     │     │     ├─ 判断逻辑:
    │     │     │     │   1. 从 sessions.json 读取 agent:main:main 的 sessionFile
    │     │     │     │   2. 从 sessionFile 中提取 session_id
    │     │     │     │   3. 如果当前文件的 session_id == heartbeat 会话的 session_id → 跳过
    │     │     │     └─ 是 → 跳过,下一个
    │     │     │     └─ 否 → 继续
    │     │     │
    │     │     ├─ d. 是活跃会话?
    │     │     │   └─ 是 → 下一个
    │     │     │
    │     │     ├─ e. 已提炼过?(memory/.extracted_sessions)
    │     │     │   └─ 是 → 下一个
    │     │     │
    │     │     └─ f. 发现未提炼会话!
    │     │                 │
    │     │                 ├─ 发送通知:"发现未提炼会话: \x3Csession_id>,正在处理..."
    │     │                 │
    │     │                 ├─ 调用 do_extract_and_write.sh \x3C会话文件路径>
    │     │                 │
    │     │                 └─ 检查结果:
    │     │                     ├─ 成功(退出码 0)→ 标记为已提炼
    │     │                     └─ 失败(退出码非 0)→ 不标记,下次重试
    │     │
    │     └─ 6. 释放进程锁
    │
【阶段 3:AI 提炼 + 写入(一次完成)】
    │
    ├─▶ do_extract_and_write.sh
    │     │
    │     ├─ 1. 完整读取会话文件(无行数限制)
    │     │
    │     ├─ 2. 统计用户消息数和内容长度
    │     │     ├─ 支持 .message.role
    │     │     └─ 支持 .message.content[0].text(数组和字符串两种格式)
    │     │
    │     ├─ 3. 过滤条件检查
    │     │     ├─ 用户消息数 ≥ 1
    │     │     └─ 内容长度 ≥ 20
    │     │
    │     ├─ 4. 过滤通过?
    │     │   ├─ 否 → 发送通知(CLI)→ 标记为已提炼 → 返回 0
    │     │   └─ 是 → 继续
    │     │
    │     ├─ 5. 准备 AI 提炼 prompt(占位符替换,解决多行引号问题)
    │     │
    │     ├─ 6. 调用 openclaw agent 进行 AI 提炼(后台运行,最多等待 300 秒 = 5 分钟)
    │     │
    │     ├─ 7. 检查 AI 调用结果:
    │     │   ├─ a. 超时?(> 300 秒)
    │     │   │   └─ 是 → 发送通知(CLI)→ "❌ 会话 \x3CSESSION_ID> 提炼失败:AI调用超时(300秒)" → 退出 1
    │     │   ├─ b. 退出码非 0?
    │     │   │   └─ 是 → 发送通知(CLI)→ "❌ 会话 \x3CSESSION_ID> 提炼失败:AI调用失败(退出码:\x3Ccode>)" → 退出 1
    │     │   ├─ c. 输出为空?
    │     │   │   └─ 是 → 发送通知(CLI)→ "❌ 会话 \x3CSESSION_ID> 提炼失败:AI返回为空" → 退出 2
    │     │   ├─ d. 输出包含 "DONE" → AI 已完成所有写入 → 标记为已提炼 → 退出 0
    │     │   ├─ 不包含 "DONE" 但包含错误 → 发送通知(CLI)→ "❌ 会话 \x3CSESSION_ID> 提炼失败:AI返回错误信息" → 退出 1
    │     │   └─ 不包含 "DONE" 也不包含错误 → 发送通知(CLI)→ "❌ 会话 \x3CSESSION_ID> 提炼失败:AI 没有完成写入" → 退出 3
    │     │
    │     └─ 完成,返回 0
    │
【阶段 4:完成】
    │
    └─▶ 结束,agent 已经完成所有提炼 + 写入 + 通知

文件结构

skill/lingxi-memory/
├── SKILL.md                         # 这个文件
├── session_check.sh                  # 会话检查脚本
└── do_extract_and_write.sh           # AI 提炼 + 写入脚本

环境变量配置(必填)

你必须在 workspace/.env 文件中配置以下环境变量,否则脚本无法运行:

# 你的飞书 open_id(必填,用于接收通知)
export FEISHU_USER_OPEN_ID="ou_xxxxxxxxxxxxxxxxxx"
# L2 任务看板:飞书多维表格 app_token(必填)
export L2_APP_TOKEN="your_l2_app_token"
# L2 任务看板:数据表 ID(必填)
export L2_TABLE_ID="your_l2_table_id"
# L3 项目日志:飞书云文档 doc_id(必填)
export L3_DOC_ID="your_l3_doc_id"
# L4 知识沉淀:飞书云文档 doc_id(必填)
export L4_DOC_ID="your_l4_doc_id"

# 可选配置:OpenClaw 会话目录(默认:/root/.openclaw/agents/main/sessions)
# export SESSIONS_DIR="/path/to/your/sessions"
# 可选配置:通知目标(默认:user:$FEISHU_USER_OPEN_ID)
# export NOTIFY_TARGET="user:ou_xxxxxxxxxxxxxxxxxx"

重要安全提示

  • 不要使用默认提供的示例 ID,那是作者的飞书资源
  • 必须替换为你自己的飞书多维表格和文档 ID
  • 如果不配置,脚本会启动失败并提示你缺少环境变量,这是正常的安全设计

通知格式

场景 通知内容 发起方
发现未提炼会话 发现未提炼会话: \x3Csession_id>,正在处理... session_check.sh (bash)
会话文件不存在 ❌ 会话 \x3CSESSION_ID> 提炼失败:文件不存在 do_extract_and_write.sh (bash)
过滤跳过 ℹ️ 会话 \x3CSESSION_ID> 过滤跳过:\x3C原因> do_extract_and_write.sh (bash)
AI 调用超时 ❌ 会话 \x3CSESSION_ID> 提炼失败:AI调用超时(300秒) do_extract_and_write.sh (bash)
AI 调用失败 ❌ 会话 \x3CSESSION_ID> 提炼失败:AI调用失败(退出码:\x3Ccode>) do_extract_and_write.sh (bash)
AI 返回为空 ❌ 会话 \x3CSESSION_ID> 提炼失败:AI返回为空 do_extract_and_write.sh (bash)
AI 返回错误 ❌ 会话 \x3CSESSION_ID> 提炼失败:AI返回错误信息 do_extract_and_write.sh (bash)
AI 没有完成写入 ❌ 会话 \x3CSESSION_ID> 提炼失败:AI 没有完成写入 do_extract_and_write.sh (bash)
提炼成功(有内容) `## 提炼结果\
\
  • L2 任务: X 条\
  • L3 项目: X 条\
  • L4 知识: X 条| agent (AI) | | **提炼成功(无内容)** |ℹ️ 会话 \x3CSESSION_ID> 提炼完成,无内容需要写入` | agent (AI) |

安装部署

# 1. 克隆/复制脚本到你的 workspace/scripts 目录
cp session_check.sh /root/.openclaw/workspace/scripts/
cp do_extract_and_write.sh /root/.openclaw/workspace/scripts/

# 2. 添加执行权限
chmod +x /root/.openclaw/workspace/scripts/*.sh

# 3. 创建已提炼记录文件
mkdir -p /root/.openclaw/workspace/memory
touch /root/.openclaw/workspace/memory/.extracted_sessions

# 4. 配置 crontab
# 编辑 crontab: crontab -e
# 添加以下内容:
# 白天(8:00-22:00)每 1 分钟运行一次
# */1 8-22 * * * /root/.openclaw/workspace/scripts/session_check.sh >> /tmp/session_check.log 2>&1
# 夜间(22:00-次日8:00)每 5 分钟运行一次
# */5 22-23 * * * /root/.openclaw/workspace/scripts/session_check.sh >> /tmp/session_check.log 2>&1
# */5 0-7 * * * /root/.openclaw/workspace/scripts/session_check.sh >> /tmp/session_check.log 2>&1

依赖

  • OpenClaw >= 2026.3.13
  • python3 >= 3.8
  • bash >= 4.0
  • 需要配合 OpenClaw 飞书官方插件使用
  • 需要开通飞书相关用户身份读写权限,完成用户 OAuth 授权后才能正常使用

配置说明

使用前必须完成:

  1. 在 OpenClaw 中启用飞书插件,并完成用户 OAuth 授权(获得飞书 API 访问权限)
  2. workspace/.env 文件中配置以下环境变量:
# 你的飞书 open_id(必填,用于接收通知)
export FEISHU_USER_OPEN_ID="ou_xxxxxxxxxxxxxxxxxx"
# L2 任务看板:飞书多维表格 app_token
export L2_APP_TOKEN="your_l2_app_token"
# L2 任务看板:数据表 ID
export L2_TABLE_ID="your_l2_table_id"
# L3 项目日志:飞书云文档 doc_id
export L3_DOC_ID="your_l3_doc_id"
# L4 知识沉淀:飞书云文档 doc_id
export L4_DOC_ID="your_l4_doc_id"

如果不配置环境变量,会使用默认配置,但默认配置只能在灵曦的记忆空间使用,其他人使用需要修改为自己的飞书资源。

安全说明

安全扫描结果

检查项 状态 说明
命令注入 ✅ 安全 所有变量都正确使用引号包裹,文件名使用 basename 提取,不会导致命令注入
路径遍历 ✅ 安全 使用 basename 正确提取 session_id,不会路径遍历
硬编码密钥 ✅ 已修复 所有飞书资源 ID 都通过环境变量配置,无硬编码
必需环境变量 ✅ 已声明 skill.json 中完整声明了所有必需环境变量
进程锁 ✅ 安全 使用 mkdir 原子操作获取锁,支持过期锁(超过 10 分钟)自动清理,不会死锁
临时文件 ✅ 安全 使用 $$ PID 隔离临时文件,用完自动删除,不会冲突
错误处理 ✅ 安全 每个步骤都有错误检查和通知,不会静默失败

风险声明

本技能的核心功能是读取本地 OpenClaw 会话文件,将完整对话内容发送给 AI 代理进行提炼,然后写入你的飞书知识库。这是本技能的设计初衷,如果你使用本技能,即同意:

  • 本 skill 需要读取你的本地 OpenClaw $SESSIONS_DIR 目录下所有未提炼的会话文件(包含你的对话历史),这是自动化提炼的必要设计
  • 本 skill 会将完整对话内容发送给 OpenClaw agent(使用你配置的 AI 模型)进行内容提炼
  • 本 skill 需要访问飞书 API,必须完成飞书用户 OAuth 授权才能使用
  • 所有飞书资源 ID 都通过环境变量指定,你必须自行配置你自己的飞书多维表格和文档
  • 飞书 API 凭证由 OpenClaw 飞书插件通过 OAuth 授权管理,本技能不会接触或存储你的飞书凭证
  • 请确保你已经备份了重要数据,使用本技能产生的一切后果由使用者自行承担

权限范围说明

  • 本地读取:读取 $SESSIONS_DIR 目录下的所有未提炼会话文件(默认:/root/.openclaw/agents/main/sessions/),这是本技能的核心功能
  • AI 调用:调用 OpenClaw agent 进行内容提炼(由 OpenClaw 控制,使用你配置的 AI 模型)
  • 飞书配置传递:将你配置的飞书资源 ID(app_token、table_id、doc_id)传递给 AI agent,用于正确调用飞书 API
    • ⚠️ 重要说明:飞书 API 凭证(token/secret)由 OpenClaw 飞书插件通过 OAuth 授权管理,本技能不会接触或存储你的飞书凭证
    • 本技能只传递飞书资源 ID,不传递任何凭证信息
  • 飞书写入:通过 OpenClaw 飞书插件调用飞书 API,将提炼结果写入你自己配置的多维表格和云文档
  • 发送通知:通过 OpenClaw CLI 发送通知到你自己的飞书账号

请确认你理解这些权限范围后再安装使用。

版本历史

  • v1: 初始版本,cron → check → extract → queue → heartbeat → write,队列架构
  • v2-v4: 逐步修复 heartbeat 排除、参数解析等问题
  • v5: 简化架构,移除队列,bash → agent → write 一次完成,更简洁更实时

作者

灵曦 / Linxi-MindVault

安全使用建议
This skill is functionally consistent with its description, but it will read your full OpenClaw session files and send their contents to the OpenClaw agent, which will then write extracted results into Feishu — so only install if you are willing to have your chat contents processed and stored in your Feishu workspace. Before installing: (1) resolve the metadata inconsistency (the registry summary claimed no required env vars, but the package requires FEISHU_* and L2/L3/L4 IDs); (2) review and replace any example Feishu IDs in .env with your own credentials and keep .env out of version control; (3) run the scripts in an isolated/test environment first (or on non-sensitive sessions) to confirm behavior; (4) limit filesystem permissions for the workspace and .env so only the intended user can read them; (5) if you have high-security or sensitive conversations, do not enable this skill or ensure the target Feishu space is appropriately access-controlled. If you want greater assurance, ask the author to: publish a homepage/repo, sign or publish a canonical release, and clarify the registry metadata to list required env vars and external dependencies (inotify-tools/jq) clearly.
功能分析
Type: OpenClaw Skill Name: lingxi-memory Version: 1.1.15 The Lingxi-MindVault skill is a legitimate automation tool designed to extract 'memories' (tasks, project logs, and knowledge) from OpenClaw session files and save them to a user's Feishu (Lark) workspace. The scripts (session_check.sh and do_extract_and_write.sh) implement robust logic including file locking to prevent race conditions, automatic cleanup of temporary files, and detailed error handling. While the tool requires high-privilege access to read all local chat history, this behavior is the stated purpose of the skill and is accompanied by prominent safety warnings in both SKILL.md and README.md. The code follows security best practices by using environment variables for sensitive IDs and avoiding hardcoded credentials.
能力评估
Purpose & Capability
The skill claims to extract memories from local OpenClaw sessions and write to Feishu; the included scripts explicitly read session files, call the openclaw agent, and instruct the agent to write to Feishu L2/L3/L4—this is coherent with the stated purpose. NOTE: registry metadata at the top of the package (in the provided summary) said “Required env vars: none”, while skill.json and SKILL.md list required environment variables (FEISHU_USER_OPEN_ID, L2_APP_TOKEN, L2_TABLE_ID, L3_DOC_ID, L4_DOC_ID). That metadata mismatch is an inconsistency that should be resolved before trusting the registry entry.
Instruction Scope
The runtime instructions and scripts stay within the stated scope: they scan the OpenClaw sessions directory, filter sessions, invoke an OpenClaw agent to perform extraction, and rely on agent/tooling to write into Feishu. This behavior matches the description. Important privacy note: the scripts read entire session files and place session contents (via the prompt) into the agent call—so all conversation text can be processed and transmitted to the agent and then to Feishu. That is expected for the feature but is a sensitive operation and requires explicit user consent.
Install Mechanism
There is no automated install spec — the skill is instruction + shell scripts only. No external downloads or archives are used. The README suggests optional system packages (inotify-tools, jq) but those are not pulled automatically by the skill; this is low-risk compared to remote installs. Confirm those packages yourself if you use file-watching features.
Credentials
The environment variables required in SKILL.md and skill.json (FEISHU_USER_OPEN_ID, L2_APP_TOKEN, L2_TABLE_ID, L3_DOC_ID, L4_DOC_ID) are appropriate and proportionate for a skill that writes to a user's Feishu workspace. However, the registry metadata at the top of the supplied bundle incorrectly listed no required env vars, creating an inconsistency. Also note that L2_APP_TOKEN and app/doc IDs are sensitive and grant access to write to your Feishu resources — only supply credentials/IDs for accounts you control and trust.
Persistence & Privilege
The skill does not request 'always: true' or other elevated platform privileges. It writes state to its own workspace paths (/root/.openclaw/workspace and memory/.extracted_sessions), uses /tmp for temporary files and locks, and spawns background processes via cron/cron-like scheduling. Those are expected for a background extraction tool. Ensure workspace permissions are limited, as the skill will write extracted_session markers and temporary files to disk.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install lingxi-memory
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /lingxi-memory 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.15
v1.1.15: add explicit risk disclosure - this skill reads local OpenClaw session files and sends content to AI agent for extraction, then writes result to your own Feishu knowledge base. risk is stated clearly in SKILL.md
v1.1.14
v1.1.14 metadata fix: 确保required_env正确声明,解决元数据不一致问题
v1.1.13
v1.1.13 fix: 修复 skill.json 格式错误,确保元数据正确
v1.1.12
v1.1.12 搜索优化: 修改技能名称为英文,方便ClawHub搜索; 安全整改: 密钥改为脱敏占位存储,必须口令验证才能显示完整明文
v1.1.10
v1.1.10 彻底修复硬编码问题:所有飞书资源ID改为从环境变量读取,移除所有默认硬编码,增加必需环境变量检查,完全匹配skill.json声明,解决审核风险
v1.1.9
v1.1.9 安全修复:解决重复调用+凭证安全:1) 新增 processing_sessions 正在处理标记避免重复调用 2) trap 自动清理临时文件避免凭证残留 3) 移除tmp敏感日志留存
v1.1.8
v1.1.8 安全修复: 1) 新增 trap 确保临时文件 always 清理,避免凭证泄露 2) 移除 /tmp 敏感日志留存,日志由 cron 统一管理 3) 确认 skill.json 已正确声明所有需要的 FEISHU_* 环境变量
v1.1.7
- Improved process lock handling in session_check.sh to ensure better prevention of concurrent script execution. - Updated logic for cleaning up expired lock files, increasing script reliability and avoiding deadlocks. - Minor code cleanup for robustness.
v1.1.6
v1.1.6: 修复元数据声明 - 在SKILL.md头部yaml metadata中显式声明required_env,解决Registry metadata declares no required env vars 问题
v1.1.5
v1.1.5: 安全扫描最终修复 - 1) 完全清除所有硬编码飞书ID;2) skill.json添加dependencies依赖声明;3) 完善风险说明,明确凭证处理方式和数据采集范围
v1.1.4
v1.1.4: 同步最新脚本到GitHub仓库 - 确保发布的代码和本地版本完全一致
v1.1.3
v1.1.3: 安全扫描修复 - 在skill.json中声明requiredEnv环境变量,添加完整风险说明和权限范围声明
v1.1.2
v1.1.2: 安全扫描修复 - 移除所有硬编码飞书ID,强制要求环境变量配置,第三方用户必须自行配置才能使用
v1.1.1
v1.1.1: 添加创建时间必填要求,完善日志输出
元数据
Slug lingxi-memory
版本 1.1.15
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 14
常见问题

Lingxi-MindVault - Auto Memory Extraction for OpenClaw 是什么?

自动记忆提炼 & 写入飞书知识库。定时扫描 OpenClaw 会话文件,自动提炼有价值的记忆,写入飞书多维表格/云文档知识库。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 228 次。

如何安装 Lingxi-MindVault - Auto Memory Extraction for OpenClaw?

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

Lingxi-MindVault - Auto Memory Extraction for OpenClaw 是免费的吗?

是的,Lingxi-MindVault - Auto Memory Extraction for OpenClaw 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Lingxi-MindVault - Auto Memory Extraction for OpenClaw 支持哪些平台?

Lingxi-MindVault - Auto Memory Extraction for OpenClaw 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Lingxi-MindVault - Auto Memory Extraction for OpenClaw?

由 Lingxi(灵曦)(@liuxiaolong1988)开发并维护,当前版本 v1.1.15。

💬 留言讨论