Version-Master 2.1.0
Purpose
Version-Master 2.1.0 is a single-file level version management skill. Unlike full-workspace snapshots, it maintains independent version history for each file, so users can clearly see what changes each document has gone through.
Core Features
- 1. Single-file versioning - Each file maintains its own version history independently
- Complete content saving - Saves actual file content (text and binary), supports full restoration
- Smart summaries - Automatically extracts descriptive summaries from file content (e.g., document titles)
- Content deduplication - Automatically skips unchanged files to avoid meaningless versions
- Safe restoration - Auto-backs up current file before restoring, supports rollback
- Version diff - Compare differences between versions of the same file
When to Use
Activate this skill when the user's request involves any of these scenarios:
- 1. Save file version / 保存文件版本 - User says "save this file's version", "save current changes"
- View version history / 查看版本历史 - User says "what versions does this file have", "show version history"
- Restore old version / 恢复旧版本 - User says "restore to v2", "go back to previous version"
- Diff versions / 对比版本差异 - User says "compare v1 and v2", "show me what changed"
- Clean versions / 清理版本 - User says "delete old versions"
How to Use
After loading this skill, the AI uses version management features by calling scripts/version_tool.py.
Core Features
1. Save Version
CODEBLOCK0
Key Parameters:
- -
file_path: File path (relative to workspace). Optional, but AI should auto-detect from context. - INLINECODE2 : Version description. AI should auto-generate meaningful descriptions based on user actions.
AI Auto-Detection Rules / AI 自动判断规则:
- - User explicitly specifies a filename → Save that file / 用户明确指定文件名 → 保存该文件
- User says "save it" and context shows a recently edited/generated file → AI auto-fills the file path / 用户说"保存一下"且上下文中有刚编辑/生成的文件 → AI 自动填入该文件路径
- Cannot determine → Ask the user which file to save / 无法判断 → 向用户询问要保存哪个文件
- NEVER call without filepath expecting batch save / 禁止不带 filepath 直接调用并期望批量保存
2. List Versions
CODEBLOCK1
Output Example:
CODEBLOCK2
3. Restore Version (requires user confirmation / 需要用户确认)
CODEBLOCK3
Restoration Features:
- - Auto-backs up current file to INLINECODE3
- Fully restores file content (text and binary)
4. Diff Versions
CODEBLOCK4
5. Clean Versions
CODEBLOCK5
Safety Rules / 安全规则
The following operations require explicit user confirmation:
- 1. Version restore / 版本恢复 - Will overwrite current file content
- Version delete / 版本删除 - Permanently deletes snapshot data
Before calling these operations, the AI must:
- 1. Show operation details and risks / 显示操作详情和风险
- Wait for explicit user confirmation / 等待用户明确确认
- Set
confirm=True parameter / 设置 confirm=True 参数
Path Security / 路径安全:
All file_path parameters are validated server-side to stay within the workspace boundary. Paths containing ../ or absolute paths outside the workspace are rejected with an error. The AI must never pass system-level paths (e.g., ../../etc/passwd, C:\Windows\...) as file_path.
Technical Implementation
Storage Architecture
CODEBLOCK6
Design Notes:
- - All workspaces share the same storage directory, version snapshots are accessible across workspaces
- Directory names are prefixed with workspace directory name (e.g.,
20260325084235) for readability and disambiguation - INLINECODE12 in filenames is replaced with
-, path separators replaced with _ to ensure unique keys - Text files: Content embedded directly in JSON
- Binary files: Copied to version directory (e.g.,
v1.png), JSON stores only a file reference (no base64) - INLINECODE16 can be auto-rebuilt from disk
v*.json files if corrupted or lost
Global Index Structure (index.json):
CODEBLOCK7
Version File Structure (v1.json)
CODEBLOCK8
File Structure
CODEBLOCK9
AI Usage Guide
Key Principles
- 1. Smart filepath detection / 智能判断 filepath - AI should auto-detect which file to save based on context. When user says "save it", save the file just edited/generated; when user specifies a filename, save that file; when uncertain, ask the user.
- Auto-generate message / 自动生成 message - AI should auto-generate meaningful version descriptions (e.g., "Added section 3", "Fixed typo").
- List before save / 先 list 后 save - Check existing version history before saving to avoid duplicating identical content.
- Clear version display / 清晰展示版本关系 - Display versions grouped by file with clear version numbers and change descriptions.
Example Workflow
CODEBLOCK10
Version-Master 2.1.0
目的
Version-Master 2.1.0 是一个单文件级别的版本管理技能。与完整工作区快照不同,它为每个文件维护独立的版本历史,让用户清晰了解每个文档经历了哪些变更。
核心功能
- 1. 单文件版本管理 - 每个文件独立维护自己的版本历史
- 完整内容保存 - 保存实际文件内容(文本和二进制),支持完整恢复
- 智能摘要 - 自动从文件内容中提取描述性摘要(如文档标题)
- 内容去重 - 自动跳过未变更的文件,避免产生无意义的版本
- 安全恢复 - 恢复前自动备份当前文件,支持回滚
- 版本差异对比 - 比较同一文件不同版本之间的差异
使用时机
当用户请求涉及以下任一场景时,激活此技能:
- 1. 保存文件版本 - 用户说保存这个文件的版本、保存当前更改
- 查看版本历史 - 用户说这个文件有哪些版本、显示版本历史
- 恢复旧版本 - 用户说恢复到v2、回到上一个版本
- 对比版本差异 - 用户说比较v1和v2、显示有什么变化
- 清理版本 - 用户说删除旧版本
使用方法
加载此技能后,AI 通过调用 scripts/version_tool.py 来使用版本管理功能。
核心功能
1. 保存版本
python
保存特定文件
save
version(filepath=ai
news20260324.md, message=新增第11条新闻)
关键参数:
- - file_path:文件路径(相对于工作区)。可选,但 AI 应从上下文中自动检测。
- message:版本描述。AI 应根据用户操作自动生成有意义的描述。
AI 自动判断规则:
- - 用户明确指定文件名 → 保存该文件
- 用户说保存一下且上下文中有刚编辑/生成的文件 → AI 自动填入该文件路径
- 无法判断 → 向用户询问要保存哪个文件
- 禁止不带 file_path 直接调用并期望批量保存
2. 列出版本
python
列出所有有版本历史的文件
list_versions()
列出特定文件的版本历史
list
versions(filepath=ai
news20260324.md)
输出示例:
ainews20260324.md (3个版本)
v3 - 新增第11条新闻 | 2026-03-25 08:08
v2 - 新增6条科技新闻 | 2026-03-25 08:05
v1 - 初始版本,10条AI新闻 | 2026-03-25 08:03
interesting_news.md (1个版本)
v1 - 科技、体育、军事亮点 | 2026-03-25 08:10
3. 恢复版本(需要用户确认)
python
恢复到特定版本
restore
version(filepath=ai
news20260324.md, version=2, confirm=True)
恢复到最新版本
restore
version(filepath=ai
news20260324.md, confirm=True)
恢复功能:
- - 自动将当前文件备份到 .version_backup/
- 完全恢复文件内容(文本和二进制)
4. 版本差异对比
python
比较同一文件的两个版本
diff
versions(filepath=ai
news20260324.md, version1=1, version2=3)
比较当前文件与历史版本
diff
versions(filepath=ai
news20260324.md, version2=2)
5. 清理版本
python
删除文件的所有版本
clean
versions(filepath=test.txt, confirm=True)
删除文件的特定版本
clean
versions(filepath=test.txt, version=1, confirm=True)
安全规则
以下操作需要用户明确确认:
- 1. 版本恢复 - 将覆盖当前文件内容
- 版本删除 - 永久删除快照数据
在执行这些操作之前,AI 必须:
- 1. 显示操作详情和风险
- 等待用户明确确认
- 设置 confirm=True 参数
路径安全:
所有 filepath 参数都会在服务端验证,确保不超出工作区边界。包含 ../ 或工作区之外的绝对路径将被拒绝并返回错误。AI 绝不能传递系统级路径(如 ../../etc/passwd、C:\Windows\...)作为 filepath。
技术实现
存储架构
~/.workbuddy/versions/version-master/
├── index.json # 全局索引(文件 → 版本映射)
├── 20260325084235ainews_20260324-md/ # 每个文件一个目录(以工作区ID为前缀)
│ ├── v1.json # 版本1(文本内容嵌入JSON中)
│ ├── v1.md # 版本1的二进制引用文件(如有)
│ ├── v2.json # 版本2
│ └── v3.json # 版本3
└── 20260325084235interestingnews-md/
└── v1.json
设计说明:
- - 所有工作区共享同一存储目录,版本快照可跨工作区访问
- 目录名称以工作区目录名(如 20260325084235)为前缀,便于阅读和区分
- 文件名中的 . 替换为 -,路径分隔符替换为 _,确保键的唯一性
- 文本文件:内容直接嵌入JSON中
- 二进制文件:复制到版本目录(如 v1.png),JSON仅存储文件引用(无base64)
- 如果 index.json 损坏或丢失,可从磁盘上的 v*.json 文件自动重建
全局索引结构(index.json):
json
{
files: {
20260325084235ainews_20260324-md: {
relpath: ainews_20260324.md,
next_version: 4,
versions: [
{
version: 1,
timestamp: 2026-03-25T08:03:00,
content_hash: abc123...,
file_size: 2928,
summary: 初始版本,10条AI新闻,
versionfile: 20260325084235ainews20260324-md/v1.json
}
]
}
}
}
版本文件结构(v1.json)
json
{
version: 1,
timestamp: 2026-03-25T08:03:00,
content_hash: abc123...,
file_size: 2928,
summary: 初始版本,10条AI新闻,
message: 初始版本,
content: {
type: text,
content: # AI新闻简报\n\n...
}
}
文件结构
version-master/
├── SKILL.md # 技能文档
├── requirements.txt # 依赖项
└── scripts/
├── init.py
└── version_tool.py # 核心实现
AI 使用指南
关键原则
- 1. 智能判断 file_path - AI 应根据上下文自动检测要保存哪个文件。当用户说保存一下时,保存刚编辑/生成的文件;当用户指定文件名时,保存该文件;不确定时,询问用户。
- 自动生成 message - AI 应自动生成有意义的版本描述(如新增第3节、修复拼写错误)。
- 先 list 后 save - 保存前先检查现有版本历史,避免重复保存相同内容。
- 清晰展示版本关系 - 按文件分组显示版本,附带清晰的版本号和变更描述。
示例工作流程
用户:帮我把 ai_news.md 保存一下
AI:
1. 调用 listversions(filepath=ai_news.md) 检查现有版本
2. 分析当前文件内容的变更
3. 调用 saveversion(filepath=ai_news.md, message=新增3条新闻)
4. 显示结果:ai_news.md 已保存为 v3
用户:恢复到上一个版本
AI:
1. 检查版本历史,确认当前为 v3,上一个为 v2
2. 提示用户:即将恢复 ai_news.md 到 v2(新增3条新闻 → 初始版本)。确认?
3. 用户确认后,调用 restoreversion(filepath=ai_news.md, version=2, confirm=True)