Ldm Session Handoff logo

Ldm Session Handoff

Community
Holden323
ldm-session-handoff

导出会话原文、生成任务路由器和重启提示语,帮助长任务跨会话恢复。用户说“会话存档”“保存聊天记录”“导出对话全记录”“生成路由器”“准备退出重启”或“给我重启提示语”时使用;普通文件归档不使用。 Export raw conversation transcripts, generate task routers and restart prompts to help long-running tasks resume across sessions. Triggered when the user says "session archive," "save chat log," "export full transcript," "generate router," "prepare to exit and restart," or "give me a restart prompt"; not used for ordinary file archiving.

Overview

PublisherHolden323
Repositoryldm-skill
Skill nameldm-session-handoff
Stars
44
Forks
5
Bundled files
12
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 12 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by Holden323 on GitHub. Read the source before you install it.

Installation

Install the Ldm Session Handoff AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/Holden323/ldm-skill/tree/main/skills/ldm-session-handoff
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Holden323/ldm-skill.git /tmp/ldm-skill
mkdir -p .claude/skills
cp -r /tmp/ldm-skill/skills/ldm-session-handoff .claude/skills/ldm-session-handoff
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Ldm Session Handoff in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Ldm Session Handoff on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Ldm Session Handoff is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

会话交接

目标是让下一次会话能核对原始记录,并快速恢复决定、产出、进度和待办。

按用户请求选择产物

  • 完整交接:对话全记录、路由器、重启提示语。
  • 用户明确说“只导出原文”时:只生成对话全记录。
  • 用户明确说“只更新路由器”时:读取现有记录和产出后更新路由器。
  • 用户明确说“只要重启提示语”“不用导出”或“不要创建文件”时:只给提示语;若缺少可靠上下文,明确哪些信息待补。

用户说“加载交接 Skill”“使用交接 Skill”“会话存档”“保存对话”或“准备退出重启”时,默认做完整交接;即使同一句还提到“给我重启提示语”,也不能因此跳过对话全记录和路由器。只有用户用“只”“仅”“不用导出”“不要创建文件”等明确措辞缩小范围时,才改为单项产物。

完整交接流程

  1. 确认当前会话、主题和保存目录。优先使用用户已配置的存档根目录;否则使用当前工作区中的明确目录。
  2. 通过平台原生导出能力或本 Skill 的脚本读取 user/assistant 原文。不要凭记忆生成“全记录”。
  3. 生成路由器,只保留恢复任务需要的决定、产出、进度、待办和新教训。
  4. 核对文件存在、消息数量级合理、来源标记准确。
  5. 报告所有产物的绝对路径,最后直接给出可复制的重启提示语。

格式见 references/formats.md。只有需要选择或排查导出后端时才读 references/export-backends.md。

原文真实性

  • “对话全记录”必须来自可核查的会话数据源。
  • 默认保留 user/assistant 可见文本,过滤工具调用、工具输出、推理记录、环境注入和空占位。
  • 不把摘要、路由器或模型回忆标成原文。
  • 导出不完整时写明已获得的范围和“待补存”,不要声称数据必然永久存在。
  • 单条截断会损失原文;只有用户要求控制体积或平台限制无法避免时才截断,并在文件头记录阈值和数量。

路由器

路由器是恢复上下文的主力,重启提示语只是入口;原文负责回查,路由器负责恢复。它是导航,不复述整段对话。至少写清:

  • 关键决策及其理由。
  • 存档点:按时间顺序列出做完并确认过的关卡及其凭据,让新会话一眼看到做到哪了。
  • 已完成产物的绝对路径与状态。
  • 资源版本:只写恢复时用错版本就会做错的依赖及其版本(skill、素材库、模板、工具);还没定的状态、还没做的事,写进待办或下一步。
  • 正在进行的工作、下一步及其前置条件(动手之前必须先具备或确认什么)。
  • 尚未解决的问题和明确待办。
  • 只有本次新出现且可复用的经验教训。

外部链接只记录需要继续使用的最终入口。敏感凭证不写入路由器。

导出工具

  • Hermes SQLite:scripts/export_transcript.py
  • Claude Code / Codex JSONL:scripts/export_jsonl_transcript.py
  • WorkBuddy JSONL:scripts/export_workbuddy_transcript.py
  • DSH(DeepSeek Harness)会话:两步。① node scripts/export_dsh_session.js <session.v4.jsonl.zstd> <原始.jsonl>;② python3 scripts/export_dsh_transcript.py <原始.jsonl> <对话全记录.md>。
    • ⚠️ DSH 的会话文件是多帧拼接的 zstd:zstdDecompressSync 只解得出第一帧(1.37MB 的文件只出 237 字节),必须逐帧循环解压,脚本已处理。
    • 会话位置:~/.dsh/sessions/<工作区目录名>/<session-id>/session.v4.jsonl.zstd。当前会话 id 直接读环境变量 DSH_SESSION_ID,不用猜。
    • 实测(2026-10-06):1.37MB → 914 帧 → 3.1MB / 1493 行 JSONL;过滤后 88 条 user/assistant 可见消息。
    • 事件类型:user/message(data.content[].text)、assistant/message(data.message.content[].text,另有 reasoning 与 tool-call 需过滤),其余 tool/result、request/* 、step/* 一律不出。

脚本只负责导出原文,不负责生成路由器。先用 --list 找到会话,再指定会话和输出路径;本机存在多个后端时不要猜测。

当前活跃会话:

  • WorkBuddy 后端会正常出现在 --list 里(2026-09-24 实测),直接取 sessionId 导出即可,不需要绕 session_search。
  • Hermes 后端的活跃会话不出现在 --list 中。导出步骤:session_search 搜当前对话关键词 → 从结果提取 session_id → export_transcript.py --session <id> --output <绝对路径>。此路径对活跃会话和已结束会话同样有效。

完成检查

  • 交付内容与用户请求的产物范围一致。
  • 全记录文件头写明数据源、会话标识、时间范围、消息数和导出方式。
  • 完整交接时,两个文件均已报告绝对路径,重启提示语已直接发给用户。
  • 失败和截断情况如实标注,没有用摘要冒充原文。

Pitfalls

1. 永远不要声称"导不出来"(2026-09-04/09-08 实战教训)

用户明确要求导出时,不得以"当前活跃session"为由放弃。导出路径:session_search 提取 session_id → export_transcript.py --session <id>。这招对活跃会话和已结束会话都有效。

此错误已导致用户暴怒两次。如果 --list 找不到,换 session_search;如果 session_search 也找不到,如实报告,但先试完两条路再说。

2. 重启提示语和路由器中必须使用绝对路径(2026-09-04/09-08 实战教训)

  • ❌ ~/Documents/Hermes_Workspace/...(~ 不是绝对路径,用户会暴怒)
  • ✅ /Users/likai/Documents/Hermes_Workspace/...

所有文件路径一律用 /Users/likai/ 开头。包括重启提示语、路由器产出清单、用户给的指引。用户已多次纠正此问题。

3. 导出全记录不要按 active = 1 过滤(2026-09-11 实战教训)

上下文压缩会把已压缩的老消息标成 active = 0,但那些仍是被压缩前的真实原文,全记录必须保留。按 active = 1 过滤会把长会话导成十分之一(实测某会话只导出 34 条,实际原文 162 条)——丢掉的正好是最早、最需要回查的那部分。

只排除 _compressed_summary = 1 的行:那是压缩生成给模型看的 AI 摘要,不是原文。export_transcript.py 已修(commit 5844ac6);确需只看当前活跃上下文时用 --active-only。 上下文重建还会把历史整块重复入库(同一消息以 [Note: ...] 前缀变体反复重插),脚本已内置去重:块重放(连续3条以上同序同文)整块剔除、助手重复长文只留首次,用户消息不做全局去重(连发「1」是真实对话)。文件头会写明两类剔除条数。

导出后必须核对条数:文件头写的消息数应与「用户条数 + 助手条数」一致,并与库里的实际条数量级相符。

4. 改真源后先看清安装形态,不要凭记忆假设(2026-09-11 / 09-24 实战教训)

真源永远在 ldm-skill 仓库:

/Users/likai/Documents/Hermes_Workspace/ldm-skill/skills/ldm-session-handoff/SKILL.md

要改就改真源,不要在安装副本上改,否则两边分叉。改完真源,第一件事是看清 WorkBuddy 那边的形态——同一台机器上可能混着两种,别凭记忆假设:

bash
ls -la /Users/likai/.workbuddy-ai/skills/ldm-session-handoff
  • 软链(输出以 lrwxr-xr-x 开头,末尾 -> /Users/likai/Documents/Hermes_Workspace/ldm-skill/skills/...):真源即生效,不用同步,直接读回验证。
  • 复制目录(drwxr-xr-x):必须 rsync 重新同步,否则 WorkBuddy 读到的还是旧版:
    bash
    rsync -a --exclude=__pycache__ --exclude='*.pyc' --exclude=.DS_Store \
      /Users/likai/Documents/Hermes_Workspace/ldm-skill/skills/ldm-session-handoff/ \
      /Users/likai/.workbuddy-ai/skills/ldm-session-handoff/

⚠️ 2026-09-24 已统一为软链:/Users/likai/.workbuddy-ai/skills/ 下全部是软链(ganhuo-skill + 6 个 ldm-*),改真源即刻生效。此前 ganhuo 是软链、其余 6 个是复制,曾出现静默丢失风险:Codex 端把 ganhuo-skill 从 82 行升到 84 行(2.1 版),WorkBuddy 端因软链才立刻读到新版——若它当时还是复制形态,这次更新就丢了。这就是要统一的原因。上面那套 rsync 流程只在遇到复制形态时才需要。

其他平台:

  • Hermes:软链安装。skill_manage 会报 not found in active profile。改真源后从软链路径 /Users/likai/.hermes/skills/ldm-session-handoff/SKILL.md 读回验证。
  • Grok:thin bridge,只指向真源,不维护正文。

跑 Python 脚本时加 -B(或设 PYTHONDONTWRITEBYTECODE=1),避免在仓库里生成 __pycache__,省掉清理动作。

5. WorkBuddy 会话数据的存放位置(2026-09-24 实测)

~/.workbuddy-ai/projects/<工作目录编码>/<sessionId>.jsonl

工作目录编码规则:绝对路径里的 / 和空格都换成 -。例:

/Users/likai/WorkBuddy AI/2026-09-23-23-17-40 → Users-likai-WorkBuddy AI-2026-09-23-23-17-40

行结构用 type 字段区分:message(唯一要导出的原文)、reasoning(推理,过滤)、function_call / function_call_result(工具调用与输出,过滤)、session-meta / file-history-snapshot / ai-title(元数据,过滤)。

user 消息里会塞一大段环境注入,真正的用户输入包在 <user_query>...</user_query> 里。export_workbuddy_transcript.py 优先取 user_query,取不到就剥掉 system-reminder。时间戳是毫秒,不是秒。

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Ldm Session Handoff AI skill do?

导出会话原文、生成任务路由器和重启提示语,帮助长任务跨会话恢复。用户说“会话存档”“保存聊天记录”“导出对话全记录”“生成路由器”“准备退出重启”或“给我重启提示语”时使用;普通文件归档不使用。 Export raw conversation transcripts, generate task routers and restart prompts to help long-running tasks resume across sessions. Triggered when the user says "session archive," "save chat log," "export full transcript," "generate router," "prepare to exit and restart," or "give me a restart prompt"; not used for ordinary file archiving.

Why use Ldm Session Handoff on TypingMind?

Because you install it once and use it with any model. Ldm Session Handoff is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Ldm Session Handoff in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Holden323/ldm-skill/tree/main/skills/ldm-session-handoff. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Ldm Session Handoff?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Ldm Session Handoff?

As many as you like. As long as a model supports skills, you can use Ldm Session Handoff with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Ldm Session Handoff AI skill free?

Yes. It is published on GitHub by Holden323 under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇