skills-experimental/file-history/SKILL.md
Track file modification history with snapshots. Maintain up to 100 backups for diff comparison, change statistics, and version recovery. Use when checking file history, checkpointing changes, or rolling back edits.
npx skillsauth add bianhaifeng789-hue/openclaw-config file-historyInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
追踪文件修改历史,最多 100 个快照,支持 diff 对比和版本恢复。
场景:
Claude Code 方案:fileHistory.ts + MAX_SNAPSHOTS = 100 OpenClaw 飞书适配:文件编辑/写入时自动备份
每次文件编辑时创建快照:
interface FileHistorySnapshot {
messageId: UUID // 关联的消息 ID
trackedFileBackups: Record<string, FileHistoryBackup>
timestamp: Date
}
interface FileHistoryBackup {
backupFileName: string | null // null 表示文件不存在
version: number
backupTime: Date
}
最多保留 100 个快照:
使用 diffLines 计算变更:
interface DiffStats {
filesChanged?: string[]
insertions: number
deletions: number
}
function computeDiffStats(oldContent: string, newContent: string): DiffStats {
const diff = diffLines(oldContent, newContent)
let insertions = 0
let deletions = 0
for (const part of diff) {
if (part.added) insertions += part.count
if (part.removed) deletions += part.count
}
return { insertions, deletions }
}
{
"config": {"wide_screen_mode": true},
"elements": [
{
"tag": "div",
"text": {
"tag": "lark_md",
"content": "**📜 文件变更统计**\n\n**文件**:`MEMORY.md`\n\n**变更**:\n• +15 行插入\n• -3 行删除\n• 2 个文件修改\n\n**快照版本**:#47\n**时间**:2026-04-11 23:30"
}
},
{
"tag": "action",
"actions": [
{
"tag": "button",
"text": {"tag": "plain_text", "content": "查看 Diff"},
"type": "primary",
"value": {"action": "view_diff", "snapshotId": "47"}
},
{
"tag": "button",
"text": {"tag": "plain_text", "content": "恢复版本"},
"type": "default",
"value": {"action": "restore_version", "snapshotId": "47"}
}
]
}
]
}
{
"config": {"wide_screen_mode": true},
"elements": [
{
"tag": "div",
"text": {
"tag": "lark_md",
"content": "**📜 文件 Diff**\n\n**对比**:版本 #46 → #47\n**文件**:`MEMORY.md`\n\n```diff\n- <!-- AUTO_UPDATE: current_focus -->\n- _旧内容_\n+ <!-- AUTO_UPDATE: current_focus -->\n+ _新内容:已实现 13 个功能_\n```\n\n**统计**:+2 -2"
}
}
]
}
File Edit:
1. 读取文件当前内容
2. 创建备份文件(backupFileName)
3. 更新 trackedFiles Set
4. 创建 FileHistorySnapshot
5. 更新 fileHistoryState
6. 发送飞书卡片(可选)
Snapshot Management:
1. snapshotSequence++(单调递增)
2. 如果 snapshots.length > MAX_SNAPSHOTS:
→ 删除最旧的快照
→ 删除对应的备份文件
Diff Computation:
1. 用户请求查看变更
2. 读取两个快照的备份文件
3. 使用 diffLines 计算差异
4. 生成 DiffStats
5. 发送飞书卡片
// memory/file-history-state.json
{
"snapshots": [
{
"messageId": "msg-uuid-47",
"trackedFileBackups": {
"MEMORY.md": {
"backupFileName": "MEMORY.md.v47",
"version": 47,
"backupTime": "2026-04-11T23:30:00Z"
}
},
"timestamp": "2026-04-11T23:30:00Z"
}
],
"trackedFiles": ["MEMORY.md", "HEARTBEAT.md"],
"snapshotSequence": 47,
"stats": {
"snapshotsCreated": 47,
"filesTracked": 2,
"diffsComputed": 0
}
}
memory/backups/
├── MEMORY.md.v1
├── MEMORY.md.v2
├── ...
├── MEMORY.md.v47
├── HEARTBEAT.md.v1
├── ...
| Claude Code | OpenClaw 飞书场景 | |-------------|------------------| | FileHistoryState(内部) | file-history-state.json | | MAX_SNAPSHOTS = 100 | 同样 100 | | diffLines(diff package) | 同样可用 | | recordFileHistorySnapshot | 文件编辑 hook | | FileHistoryBackup(内存) | 备份文件存储 |
此 Skill 在文件编辑/写入时自动触发备份。
business
IAA 日报飞书输出能力。 支持把固定 CSV 模板一键转换成: - 中文运营结论 - 飞书卡片 JSON - 飞书发送载荷 Use when: - 需要把 IAA 日报直接发到飞书 - 需要从 CSV 一键生成运营日报
data-ai
IAA日报分析模型 功能: - 渠道日报自动分析 - 小时级+日级ROI联动判断 - 按地区输出加量/降量/停投建议 - 按产品类型输出阈值 - 自动识别利润区/观察区/止损区 Use when: - 分析每天投放数据 - 生成运营日报结论 - 判断是否加量/降量/停投 - 对比美加澳/日韩表现 Keywords: - 日报模型, 投放日报, 加量, 降量, 停投, ROI日报, 分地区分析
data-ai
IAA固定日报分析模板 功能: - 固定字段模板(可直接贴每天数据) - 自动输出总盘结论 - 自动输出美加澳/日韩结论 - 自动给出加量/降量/停投建议 - 适配文件修复/清理两类产品 Use when: - 需要固定日报格式 - 每天复盘渠道表现 - 给运营团队出统一结论 Keywords: - 固定模板, 日报模板, ROI模板, IAA日报, 运营模板
development
# HyperlinkPool Pattern Skill HyperlinkPool Pattern - HyperlinkPool class + strings array + stringMap + Index 0 no hyperlink + intern(hyperlink) + get(id) + undefined handling + 5-minute reset + OSC8 hyperlink interning。 ## 功能概述 从Claude Code的ink/screen.ts提取的HyperlinkPool模式,用于OpenClaw的OSC8超链接池管理。 ## 核心机制 ### HyperlinkPool Class ```typescript export class HyperlinkPool { private strings: string[] = [''] // Index 0 = no hyperlink private stringMap = new Map<string, number>() // strings