Session Recovery 标志

Session Recovery

社区
tamirdresher
session-recovery

Find and resume recently closed Copilot CLI sessions. Use when a session was accidentally closed, or to find past sessions by topic, working directory, or time range. Triggers on: recover session, find session, resume session, lost session, closed session, recent sessions.

概览

发布者tamirdresher
代码仓库squad-skills
技能名称session-recovery
星标数
44
复刻数
9
附带文件
2
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 2 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 tamirdresher 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Session Recovery AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/tamirdresher/squad-skills/tree/main/plugins/session-recovery
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/tamirdresher/squad-skills.git /tmp/squad-skills
mkdir -p .claude/skills
cp -r /tmp/squad-skills/plugins/session-recovery .claude/skills/session-recovery
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Session Recovery,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Session Recovery。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Session Recovery 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Session Recovery

When to Use

  • A Copilot CLI session was accidentally closed and needs to be resumed
  • You need to find a past session by topic (e.g., "monetization", "aspire", "podcast")
  • You want to see what sessions ran in a specific directory recently
  • You need to recover work from a session that was interrupted

When Not to Use

  • The session completed normally and work was committed
  • You're looking for git history (use git log instead)
  • The session is older than the retention period in session_store

How It Works

Copilot CLI stores session history in a SQLite database called session_store. This database is read-only and contains:

TableKey ColumnsPurpose
sessionsid, cwd, repository, branch, summary, created_at, updated_atSession metadata
turnssession_id, turn_index, user_message, assistant_response, timestampConversation history
checkpointssession_id, checkpoint_number, title, overviewProgress snapshots
session_filessession_id, file_path, tool_name, turn_indexFiles touched
session_refssession_id, ref_type, ref_valueLinked PRs/commits/issues
search_indexcontent, session_id, source_typeFTS5 full-text search

Core Queries

1. Find Recent Sessions (Last 24 Hours)

sql
SELECT
  s.id,
  s.summary,
  s.cwd,
  s.branch,
  s.updated_at,
  (SELECT title FROM checkpoints WHERE session_id = s.id ORDER BY checkpoint_number DESC LIMIT 1) AS last_checkpoint
FROM sessions s
WHERE s.updated_at >= datetime('now', '-24 hours')
ORDER BY s.updated_at DESC;

2. Filter Out Ralph Sessions

Ralph (the work monitor) creates many sessions. Exclude them:

sql
SELECT
  s.id,
  s.summary,
  s.cwd,
  s.updated_at,
  (SELECT title FROM checkpoints WHERE session_id = s.id ORDER BY checkpoint_number DESC LIMIT 1) AS last_checkpoint
FROM sessions s
WHERE s.updated_at >= datetime('now', '-24 hours')
  AND (s.summary IS NULL OR s.summary NOT LIKE '%ralph%')
  AND s.id NOT IN (
    SELECT DISTINCT t.session_id FROM turns t
    WHERE t.turn_index = 0
      AND (t.user_message LIKE '%ralph%' OR t.user_message LIKE '%keep-alive%')
  )
ORDER BY s.updated_at DESC;

3. Search by Topic (FTS5)

Use search_index for keyword search. FTS5 uses MATCH with OR for synonyms:

sql
SELECT DISTINCT s.id, s.summary, s.cwd, s.updated_at
FROM search_index si
JOIN sessions s ON si.session_id = s.id
WHERE search_index MATCH 'monetization OR monetize OR billing OR payment'
  AND s.updated_at >= datetime('now', '-48 hours')
ORDER BY s.updated_at DESC
LIMIT 10;

4. Find Sessions by Working Directory

sql
SELECT s.id, s.summary, s.updated_at,
  (SELECT title FROM checkpoints WHERE session_id = s.id ORDER BY checkpoint_number DESC LIMIT 1) AS last_checkpoint
FROM sessions s
WHERE s.cwd LIKE '%tamresearch1%'
  AND s.updated_at >= datetime('now', '-48 hours')
ORDER BY s.updated_at DESC;

5. Get Session Details Before Resuming

sql
-- See what the session was doing
SELECT turn_index, substr(user_message, 1, 200) AS ask, timestamp
FROM turns
WHERE session_id = 'SESSION_ID_HERE'
ORDER BY turn_index;

-- See checkpoint progress
SELECT checkpoint_number, title, overview
FROM checkpoints
WHERE session_id = 'SESSION_ID_HERE'
ORDER BY checkpoint_number;

-- See files touched
SELECT file_path, tool_name
FROM session_files
WHERE session_id = 'SESSION_ID_HERE';

How to Resume a Session

Once you have the session ID:

powershell
agency copilot --resume SESSION_ID

Ready-to-Use Prompt Template

Paste this into agency copilot --yolo -p "..." to find and list recent non-Ralph sessions:

Find my recent Copilot CLI sessions from the last 48 hours. Use the sql tool with database session_store.

Run these queries:

1. First, find all recent sessions excluding Ralph:
SELECT s.id, s.summary, s.cwd, s.branch, s.updated_at,
  (SELECT title FROM checkpoints WHERE session_id = s.id ORDER BY checkpoint_number DESC LIMIT 1) AS last_checkpoint
FROM sessions s
WHERE s.updated_at >= datetime('now', '-48 hours')
  AND (s.summary IS NULL OR LOWER(s.summary) NOT LIKE '%ralph%')
  AND s.id NOT IN (
    SELECT DISTINCT t.session_id FROM turns t
    WHERE t.turn_index = 0
      AND (LOWER(t.user_message) LIKE '%ralph%' OR LOWER(t.user_message) LIKE '%keep-alive%' OR LOWER(t.user_message) LIKE '%heartbeat%')
  )
ORDER BY s.updated_at DESC
LIMIT 30;

2. Then show the FULL session IDs grouped by working directory, with summary and last checkpoint, formatted as a clean table.

3. Highlight any sessions that mention: monetization, aspire, podcast, or pending issues.

Show the results so I can pick which session to resume with: agency copilot --resume SESSION_ID

Convenience Script

A PowerShell script is available at scripts/recover-sessions.ps1 that automates the full workflow:

powershell
# Find sessions from the last 24 hours (default), excluding Ralph
.\scripts\recover-sessions.ps1

# Look back 48 hours
.\scripts\recover-sessions.ps1 -Hours 48

# Filter by keyword
.\scripts\recover-sessions.ps1 -Filter "monetization"

# Include Ralph sessions too
.\scripts\recover-sessions.ps1 -ExcludeRalph:$false

Tips

  • FTS5 query expansion: The search_index table uses keyword matching, not semantic search. Search for synonyms: 'auth OR login OR token OR JWT'
  • Time windows: Start with -24 hours, expand to -48 hours or -7 days if needed
  • Session IDs are UUIDs: Always copy the full ID for --resume
  • Check checkpoints first: They show what stage the session was at when it closed
  • Multiple keywords: Use MATCH 'word1 OR word2' in FTS5, or LIKE '%word%' for substring matching
  • Working directory matters: Filter by cwd to find sessions for a specific project

Anti-Patterns

  • Don't search by partial session IDs — always use full UUIDs
  • Don't try to resume sessions that completed successfully — they have no pending work
  • Don't use MATCH with special characters without escaping — wrap in double quotes: MATCH '"C:\path"'
  • Don't skip the Ralph filter — Ralph sessions are high-volume and will flood results

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Session Recovery AI 技能有什么作用?

Find and resume recently closed Copilot CLI sessions. Use when a session was accidentally closed, or to find past sessions by topic, working directory, or time range. Triggers on: recover session, find session, resume session, lost session, closed session, recent sessions.

为什么在 TypingMind 中使用 Session Recovery?

因为您只需安装一次,就能搭配任何模型使用。Session Recovery 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Session Recovery?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/tamirdresher/squad-skills/tree/main/plugins/session-recovery。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Session Recovery?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Session Recovery 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Session Recovery 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Session Recovery AI 技能免费吗?

是的。tamirdresher 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇