memory-defrag

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Memory Defrag

Memory Defrag

Reorganize memory files for clarity, efficiency, and relevance. Like filesystem defragmentation but for knowledge.
为提升清晰度、效率和相关性,重组内存文件。这就像是针对知识的文件系统碎片整理。

When to Run

运行时机

  • Periodic: Weekly or biweekly via cron (recommended)
  • On demand: User asks to clean up, reorganize, or defrag memory
  • Threshold: When MEMORY.md exceeds ~500 lines or daily notes accumulate without consolidation
  • 定期运行:通过cron每周或每两周运行(推荐)
  • 按需运行:用户要求清理、重组或整理内存时
  • 阈值触发:当MEMORY.md超过约500行,或每日笔记堆积未整合时

Process

操作流程

1. Audit Current State

1. 审核当前状态

Inventory all memory files:
MEMORY.md           — long-term memory
memory/             — daily notes, tasks, topical files
memory/tasks/       — active and completed tasks
For each file, note: line count, last modified, topic coverage, staleness.
盘点所有内存文件:
MEMORY.md           — 长期内存
memory/             — 每日笔记、任务、主题文件
memory/tasks/       — 活跃及已完成任务
针对每个文件,记录:行数、最后修改时间、主题覆盖范围、是否过时。

2. Identify Problems

2. 识别问题

Look for these common issues:
ProblemSignalFix
Bloated file>300 lines, covers many topicsSplit into focused files
Duplicate infoSame fact in multiple placesConsolidate to one location
Stale entriesReferences to completed work, old dates, resolved issuesRemove or archive
Orphan filesFiles in memory/ never referenced or updatedReview, merge, or remove
InconsistenciesContradictory information across filesResolve to ground truth
Poor organizationRelated info scattered across filesRestructure by topic
Recursive nesting
memory/memory/memory/...
directories
Delete nested dirs (indexer bug artifact)
排查以下常见问题:
问题信号修复方案
文件过大超过300行,涵盖多个主题拆分为聚焦主题的文件
信息重复同一事实出现在多个位置整合到单一位置
条目过时提及已完成的工作、旧日期、已解决的问题移除或归档
孤立文件memory/目录下的文件从未被引用或更新审核、合并或移除
信息不一致不同文件中的信息相互矛盾统一为基准事实
组织混乱相关信息分散在多个文件中按主题重组
递归嵌套
memory/memory/memory/...
目录结构
删除嵌套目录(索引器Bug产物)

3. Plan Changes

3. 制定变更计划

Before making edits, write a brief plan:
markdown
undefined
在编辑前,编写简要计划:
markdown
undefined

Defrag Plan

整理计划

  • Split MEMORY.md "Key People" section → memory/people.md
  • Remove completed tasks older than 30 days from memory/tasks/
  • Merge memory/bm-marketing-ideas.md into memory/competitive/
  • Update stale project status entries in MEMORY.md
undefined
  • 将MEMORY.md的「关键人员」章节拆分 → memory/people.md
  • 从memory/tasks/中移除30天以上的已完成任务
  • 将memory/bm-marketing-ideas.md合并到memory/competitive/
  • 更新MEMORY.md中过时的项目状态条目
undefined

4. Execute

4. 执行变更

Apply changes one at a time:
  • Split: Extract sections from large files into focused topical files
  • Merge: Combine related small files into coherent documents
  • Prune: Remove information that is no longer relevant or accurate
  • Restructure: Move files to appropriate directories, rename for clarity
  • Update: Fix outdated facts, dates, statuses
逐一应用变更:
  • 拆分:从大文件中提取章节,生成聚焦主题的文件
  • 合并:将相关的小文件合并为连贯的文档
  • 精简:移除不再相关或不准确的信息
  • 重组:将文件移动到合适的目录,重命名以提升可读性
  • 更新:修正过时的事实、日期和状态

5. Verify & Log

5. 验证与记录

After changes:
  • Verify no information was lost (compare before/after)
  • Update any cross-references between files
  • Log what was done in today's daily note:
markdown
undefined
变更完成后:
  • 验证无信息丢失(对比变更前后)
  • 更新文件间的所有交叉引用
  • 在今日的每日笔记中记录操作内容:
markdown
undefined

Memory Defrag (HH:MM)

内存碎片整理(HH:MM)

  • Files reviewed: N
  • Split: [list]
  • Merged: [list]
  • Pruned: [list]
  • Net result: X files, Y total lines (was Z lines)
undefined
  • 审核文件数:N
  • 拆分文件:[列表]
  • 合并文件:[列表]
  • 精简内容:[列表]
  • 最终结果:共X个文件,总Y行(原Z行)
undefined

Guidelines

操作准则

  • Preserve raw daily notes. Don't delete or modify
    memory/YYYY-MM-DD.md
    files — they're the audit trail.
  • Target 15-25 focused files. Too few means bloated files; too many means fragmentation. Aim for the sweet spot.
  • File names should be scannable. Use descriptive names:
    people.md
    ,
    project-status.md
    ,
    competitive-landscape.md
    — not
    notes-2.md
    .
  • Don't over-organize. One level of directories is usually enough.
    memory/tasks/
    and
    memory/competitive/
    are fine;
    memory/work/projects/active/basic-memory/notes/
    is not.
  • Completed tasks: Tasks with
    status: done
    older than 14 days can be removed. Their insights should already be in MEMORY.md via reflection.
  • Ask before destructive changes. If uncertain whether information is still relevant, keep it with a
    (review needed)
    tag rather than deleting.
  • 保留原始每日笔记:不要删除或修改
    memory/YYYY-MM-DD.md
    文件——它们是审计追踪记录。
  • 目标为15-25个聚焦文件:文件过少会导致体积过大;文件过多则会造成碎片化。需找到平衡点。
  • 文件名应便于扫描:使用描述性名称,如
    people.md
    project-status.md
    competitive-landscape.md
    ——而非
    notes-2.md
  • 避免过度组织:通常一层目录足够。
    memory/tasks/
    memory/competitive/
    是合理的,但
    memory/work/projects/active/basic-memory/notes/
    则不合适。
  • 已完成任务:状态为
    status: done
    且超过14天的任务可移除。其相关见解应已通过反思整合到MEMORY.md中。
  • 破坏性变更前需确认:若不确定信息是否仍有用,可添加
    (review needed)
    标签而非直接删除。