context-restore

0
0
Source

Skill that restores conversation context when users want to "continue where we left off". Reads compressed context files, extracts key information (recent operations, projects, tasks), and provides structured output to help users quickly resume their work.

Install

mkdir -p .claude/skills/context-restore && curl -L -o skill.zip "https://mcp.directory/api/skills/download/5611" && unzip -o skill.zip -d .claude/skills/context-restore && rm skill.zip

Installs to .claude/skills/context-restore

About this skill

Context Restore Skill

快速开始

# 基础使用 - 恢复上下文
/context-restore

# 指定恢复级别
/context-restore --level detailed
/context-restore -l minimal

# 命令行工具
python scripts/restore_context.py --level normal

# 获取结构化摘要(供其他技能使用)
python scripts/restore_context.py --summary

# 用户确认流程
python scripts/restore_context.py --confirm

# Telegram 消息分块发送
python scripts/restore_context.py --telegram

# ========== Phase 3: 自动触发集成 ==========

# 自动检测并恢复上下文(检测到变化时自动恢复)
python scripts/restore_context.py --auto

# 自动模式,静默输出(适合 cron)
python scripts/restore_context.py --auto --quiet

# 仅检查变化(返回退出码 0/1)
python scripts/restore_context.py --check-only

# 安装 cron 自动监控任务
python scripts/restore_context.py --install-cron

功能说明

核心价值

让用户在 /new(开启新会话)后快速恢复工作状态:

  • 无需重复解释背景
  • 秒级恢复到之前的工作状态
  • 自然语言触发,无感恢复
  • 支持用户确认流程
  • Telegram 消息自动分块

目标用户场景

场景用户需求恢复内容
跨天继续工作昨天做到哪了?项目进度、待办任务
任务切换后回来之前在做什么?当前任务状态、关键文件
中断后继续接着刚才的聊对话历史节点
周期性回顾这周做了哪些事?时间线摘要、成果列表

触发条件

中文关键词

核心词: 恢复上下文、继续之前的工作
扩展词: 恢复、接着、继续、之前聊到哪了、继续之前的工作、
        继续之前的任务、接着做、回到之前的工作、恢复工作状态

英文关键词

核心词: restore context、continue previous work
扩展词: continue、resume、what was I doing、where did we leave off、
        get back to work、resume session

命令格式

/context-restore [选项]
/restore [选项]
恢复上下文 [级别]
restore context [level]

级别参数

参数效果
minimal / min / 简短极简模式(核心状态一句话)
normal / default / 正常标准模式(默认,项目+任务)
detailed / full / 详细完整模式(完整上下文+时间线)

执行流程

1. 检测意图 → 关键词/命令识别
2. 加载上下文 → 读取 compressed_context/latest_compressed.json
3. 解析内容 → JSON 或纯文本格式
4. 提取信息 → 项目、任务、操作、时间线
5. 格式化输出 → 根据级别生成报告
6. 发送确认 → 用户确认后继续工作

恢复级别

Minimal(极简)

输出内容

  • 核心状态一句话
  • 1个活跃任务

示例输出

✅ 上下文已恢复

状态:Hermes Plan 进行中(数据管道完成,待测试)

Normal(标准,默认)

输出内容

  • 项目状态列表
  • 待办任务列表
  • 最近操作记录
  • MEMORY.md 高亮

示例输出

✅ 上下文已恢复

当前活跃项目:
1. 🏛️ Hermes Plan - 数据分析助手(进度:80%)
2. 🌐 Akasha Plan - 自主新闻系统(进度:45%)

待办任务:
- [高] 编写数据管道测试用例
- [中] 设计 Akasha UI 组件
- [低] 更新 README 文档

最近操作(今天):
- 完成数据清洗模块
- 添加 3 个新 cron 任务
- 修改配置文件

Detailed(完整)

输出内容

  • 完整会话概览
  • 所有项目详情
  • 完整任务队列(按优先级分类)
  • 7天时间线
  • 原始内容预览

示例输出

✅ 上下文已恢复(完整模式)

═══════════════════════════════════════
📊 会话概览
═══════════════════════════════════════
当前会话:#2026-02-06-main
活跃 Isolated Sessions:3个
最后活动:2小时前

═══════════════════════════════════════
🎯 核心项目状态
═══════════════════════════════════════
1. Hermes Plan(进行中)- 进度:80%
2. Akasha Plan(待恢复)- 进度:45%

[...完整时间线和历史记录]

API / 命令行参数

Python API

from restore_context import (
    restore_context,
    get_context_summary,
    extract_timeline,
    compare_contexts,
    filter_context
)

# 基础恢复
report = restore_context(filepath, level="normal")

# 获取结构化摘要(供其他技能使用)
summary = get_context_summary(filepath)
# 返回格式:
# {
#   "success": True,
#   "metadata": {...},
#   "operations": [...],
#   "projects": [...],
#   "tasks": [...],
#   "timeline": {...},
#   "memory_highlights": [...]
# }

# 提取时间线
timeline = extract_timeline(content, period="weekly", days=30)
# 返回格式:
# {
#   "period": "weekly",
#   "total_days": 30,
#   "total_operations": 15,
#   "timeline": [
#     {
#       "period_label": "Week 6 (Feb 2-8)",
#       "date_range": "2026-02-02 to 2026-02-08",
#       "operations": [...],
#       "projects": [...],
#       "highlights": [...]
#     }
#   ]
# }

# 对比两个版本
diff = compare_contexts(old_file, new_file)
# 返回格式:
# {
#   "success": True,
#   "added_projects": [...],
#   "removed_projects": [...],
#   "modified_projects": [...],
#   "operations_added": [...],
#   "operations_removed": [...],
#   "time_diff_hours": 24.0,
#   ...
# }

# 过滤内容
filtered = filter_context(content, "Hermes Plan")

命令行参数

python restore_context.py [选项]

基础选项:
  --file, -f           上下文文件路径(默认:绝对路径 compressed_context/latest_compressed.json)
  --level, -l          恢复级别(minimal/normal/detailed,默认:normal)
  --output, -o         输出文件路径
  --summary, -s        输出结构化摘要(JSON 格式)
  --confirm            添加用户确认流程(询问用户是否继续)
  --telegram           Telegram 消息分块发送(自动分割长消息)
  --since              仅包含指定日期后的操作(YYYY-MM-DD 格式)
  --help, -h           显示帮助信息

Phase 2 - 时间线与过滤选项:
  --timeline           启用时间线视图
  --period             时间线聚合周期(daily/weekly/monthly,默认:daily)
  --filter             过滤关键词,只显示匹配内容
  --diff               对比两个版本(需要两个文件路径)

Phase 3 - 自动触发选项:
  --auto               自动模式:检测到变化时自动恢复,无需用户确认
  --quiet              静默模式:仅显示必要消息(与 --auto 配合使用)
  --check-only         仅检查变化,不恢复(返回退出码 0/1)
  --install-cron       生成并安装 cron 自动监控任务
  --cron-interval      Cron 间隔分钟数(默认:5,与 --install-cron 配合)

完整命令行示例

# 使用默认配置
python restore_context.py

# 详细模式输出到文件
python restore_context.py --level detailed --output report.txt

# 最小模式
python restore_context.py -l minimal

# 自定义文件路径
python restore_context.py -f /path/to/context.json

# 结构化 JSON 输出
python restore_context.py --summary

# 用户确认流程
python restore_context.py --confirm

# Telegram 消息分块发送
python restore_context.py --telegram

# ========== Phase 2: 时间线与过滤 ==========

# 按天显示时间线(默认)
python restore_context.py --timeline --period daily

# 按周显示时间线
python restore_context.py --timeline --period weekly

# 按月显示时间线
python restore_context.py --timeline --period monthly

# 过滤特定内容
python restore_context.py --filter "Hermes"

# 只显示项目相关信息
python restore_context.py --filter "project"

# ========== Phase 2: 上下文对比 ==========

# 对比两个版本
python restore_context.py --diff old.json new.json

# 对比并输出详细报告
python restore_context.py --diff old.json new.json --level detailed

# ========== Phase 3: 自动触发示例 ==========

# 自动检测并恢复(检测到变化时自动恢复)
python restore_context.py --auto

# 自动模式,静默输出(适合 cron)
python restore_context.py --auto --quiet

# 检查变化(外部监控使用)
python restore_context.py --check-only
echo $?  # 0=无变化, 1=有变化

# 安装 cron 任务
python restore_context.py --install-cron

# 安装 cron 任务(每10分钟)
python restore_context.py --install-cron --cron-interval 10

# 完整自动恢复(详细级别)
python restore_context.py --auto --level detailed

输出格式

标准消息格式

✅ **上下文已恢复** [级别标识]

[主要内容块]

---
💡 **操作建议**
• 建议操作 1
• 建议操作 2

Normal 级别统一输出格式

✅ **上下文已恢复**

📊 **压缩信息:**
- 原始消息: {original_count}
- 压缩后: {compressed_count}
- 压缩率: {compression_ratio}%

🔄 **最近操作:**
- 操作1
- 操作2

🚀 **项目:**
- **项目名称** - 描述

Telegram 消息分块

当消息超过 4000 字符时,自动分块发送:

# Telegram 模式下,输出会自动分割
python restore_context.py --telegram
# [1/3]
# 第一块内容...
# [2/3]
# 第二块内容...
# [3/3]
# 第三块内容...

平台适配

平台格式调整
Telegram使用 emoji 前缀,自动分块发送(--telegram)
Discord使用 embed 格式
WhatsApp无 markdown,简化格式
CLI纯文本,树形结构

错误处理

场景处理方式用户消息
文件不存在创建空上下文,记录警告"未找到历史上下文,将从新会话开始"
文件损坏尝试降级读取"上下文文件异常,已重置为初始状态"
解析失败返回 minimal 版本"部分上下文无法恢复,已获取核心信息"
权限错误记录日志,静默失败"无法访问上下文文件,请检查权限"

与其他技能的集成

集成关系

Context-Restore 依赖:
├── context-save (保存上下文)
├── memory_get (读取 MEMORY.md)
└── memory_search (搜索历史)

Context-Restore 提供给:
├── summarize (项目摘要)
├── task-manager (待办列表)
└── weekly-review (时间线回顾)

配合 context-save 使用

**context-save**:会话结束时自动保存上下文
**context-restore**:会话开始时恢复上下文

配合流程:
1. 用户结束会话 → context-save 自动保存
2. 用户 new session → context-restore 自动/手动触发
3. 用户确认 → 继续工作

供其他技能调用的结构化输出

from restore_context import get_context_summary

def my_skill():
    summary = get_context_summary()
    
    if summary['success']:
        # 使用项目信息
        for project in summary['projects']:
            process_project(project)
        
        # 使用任务信息
        for task in summary['tasks']:
            schedule_task(task)
        
        # 使用最近操作
        for operation in summary['operations']:
            log_operation(operation)

最佳实践

1. 推荐使用流程

1. 用户进入新会话
2. 说 "继续之前的工作"
3. 查看恢复报告
4. 选择继续的任务
5. 开始工作

2. 恢复级别选择

使用场景推荐级别
快速确认当前状态Minimal
日常继续工作Normal(默认)
深度回顾/汇报Detailed

3. 与其他技能配合

# 恢复上下文 + 获取详细信息
/context-restore --level normal
-> 然后调用 memory_get 获取 MEMORY.md 详情

# 恢复上下文 + 搜索特定话题
/context-restore --level normal
-> 然后调用 memory_search "某个关键词"

配置文件

# SKILL_CONFIG.md
context-restore:
  default_level: "normal"
  auto_trigger: true
  
  output:
    show_timeline: true
    max_projects: 5
    max_recent_actions: 10
    include_file_list: true
  
  limits:
    minimal_token: 50
    normal_token: 200
    detailed_token: 500

数据源

必需文件

./compressed_context/latest_compressed.json

可选文件

./memory/MEMORY.md          # 长期记忆
./memory/YYYY-MM-DD.md      # 每日记录
./projects/*/status.json    # 项目状态文件

上下文文件格式

{
  "version": "1.0",
  "lastUpdated": "2026-02-06T23:42:00Z",
  "sessions": {
    "main": {"id": "main-2026-02-06", "active": true},
    "isolated": [...]
  },
  "projects": {...},
  "recentActions": [...],
  "timeline": [...]
}

Phase 2: 时间线与对比功能 (Timeline & Comparison)

新增功能

1. --timeline 时间线视图

按不同周期聚合历史操作,提供更清晰的进度回顾:

# 按天显示(默认)
python restore_context.py --timeline --period daily

# 按周显示
python restore_context.py --timeline --period weekly

# 按月显示
python restore_context.py --timeline --period monthly

# 限制时间范围(最近30天)
python restore_context.py --timeline --period weekly --days 30

输出示例(weekly):

📅 Week 6 (Feb 2-8)
├── ✅ 完成数据管道测试
├── ✅ 部署新功能到生产环境
└── 🚀 项目: Hermes Plan, Akasha Plan

📅 Week 5 (Jan 26 - Feb 1)
├── ✅ 启动 Akasha UI 改进
└── 🚀 项目: Hermes Plan

2. --filter 内容过滤

只显示匹配特定条件的内容:

# 只显示与 Hermes 相关的内容
python restore_context.py --filter "Hermes"

# 只显示项目相关信息
python restore_context.py --filter "project"

# 组合使用
python restore_context.py --filter "Hermes" --level detailed

过滤逻辑:

  • 不区分大小写匹配
  • 保留匹配行的上下文(前后2行)
  • 如果没有匹配,返回提示信息

3. --diff 上下文对比

比较两个版本的上下文差异:

# 基本对比
python restore_context.py -

---

*Content truncated.*

seedream-image-gen

openclaw

Generate images via Seedream API (doubao-seedream models). Synchronous generation.

2259

ffmpeg-cli

openclaw

Comprehensive video/audio processing with FFmpeg. Use for: (1) Video transcoding and format conversion, (2) Cutting and merging clips, (3) Audio extraction and manipulation, (4) Thumbnail and GIF generation, (5) Resolution scaling and quality adjustment, (6) Adding subtitles or watermarks, (7) Speed adjustment (slow/fast motion), (8) Color correction and filters.

6623

context-optimizer

openclaw

Advanced context management with auto-compaction and dynamic context optimization for DeepSeek's 64k context window. Features intelligent compaction (merging, summarizing, extracting), query-aware relevance scoring, and hierarchical memory system with context archive. Logs optimization events to chat.

3622

a-stock-analysis

openclaw

A股实时行情与分时量能分析。获取沪深股票实时价格、涨跌、成交量,分析分时量能分布(早盘/尾盘放量)、主力动向(抢筹/出货信号)、涨停封单。支持持仓管理和盈亏分析。Use when: (1) 查询A股实时行情, (2) 分析主力资金动向, (3) 查看分时成交量分布, (4) 管理股票持仓, (5) 分析持仓盈亏。

9121

himalaya

openclaw

CLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).

7821

garmin-connect

openclaw

Syncs daily health and fitness data from Garmin Connect into markdown files. Provides sleep, activity, heart rate, stress, body battery, HRV, SpO2, and weight data.

7321

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

641968

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

590705

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

339397

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

318395

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

450339

fastapi-templates

wshobson

Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.

304231

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.