Search

PythonReactSEOPDF
OpenClaw

cross-session-memory

Cross-session memory continuity system. Automatically loads 24h rolling memory and daily memory files for context awareness.

24267580930 source installs☆ 0 Repository stars

Installation

Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.

SkillHub CLI

skillhub install 2426758093/cross-session-memory

Inspect the source and compatibility requirements, then follow its installation steps.

Give your agent the source link and ask it to inspect instructions and dependencies before explaining the installation steps.

View source ↗Guides

Skill instructions

跨会话记忆连续性

功能

  • 24 小时滚动记忆:自动加载最近 24 小时的记忆文件
  • 每日记忆加载:自动读取昨天和今天的 memory 文件
  • 上下文恢复:会话开始时自动恢复之前的对话上下文
  • 长期记忆整合:可选加载 MEMORY.md 长期记忆

使用场景

  • 跨天对话连续性
  • 多会话协作
  • 长期项目跟踪
  • 上下文不丢失

实现逻辑

# 伪代码
function Load-CrossSessionMemory {
    param(
        [int]$RollingHours = 24,
        [bool]$LoadLongTerm = $true
    )
    
    $now = Get-Date
    $memoryDir = "$workspace\memory"
    $context = @()
    
    # 1. 加载长期记忆(仅主会话)
    if ($LoadLongTerm -and $IsMainSession) {
        $longTerm = Get-Content "$workspace\MEMORY.md" -Raw
        $context += "## 长期记忆`n$longTerm"
    }
    
    # 2. 计算时间范围
    $startTime = $now.AddHours(-$RollingHours)
    
    # 3. 加载范围内的每日记忆文件
    $date = $startTime.Date
    while ($date -le $now.Date) {
        $file = "$memoryDir\$($date.ToString('yyyy-MM-dd')).md"
        if (Test-Path $file) {
            $content = Get-Content $file -Raw
            $context += "## 记忆:$($date.ToString('yyyy-MM-dd'))`n$content"
        }
        $date = $date.AddDays(1)
    }
    
    # 4. 返回整合的上下文
    return $context -join "`n`n"
}

文件结构

workspace/
├── MEMORY.md              # 长期记忆( curated )
└── memory/
    ├── 2026-03-02.md      # 每日记忆(raw logs)
    ├── 2026-03-03.md
    └── ...

使用示例

会话开始时自动加载

在 AGENTS.md 中已经定义:

## Every Session

Before doing anything else:

1. Read `SOUL.md` — this is who you are
2. Read `USER.md` — this is who you're helping
3. Read `memory/YYYY-MM-DD.md` (today + yesterday) for recent context
4. **If in MAIN SESSION**: Also read `MEMORY.md`
手动加载
# 加载最近 24 小时记忆
$context = Load-CrossSessionMemory -RollingHours 24

# 加载最近 7 天记忆(长期项目)
$context = Load-CrossSessionMemory -RollingHours 168 -LoadLongTerm $false

记忆文件内...

Source information

Source
github
Repository
openclaw/skills
Path
skills/2426758093/cross-session-memory
Version
—
Commit
81af75eff191010bbdf94ae120fab409f574b53e
Classification source
rules
Status
active
Visibility
public

These signals come from indexed source analysis and may lag behind changes. Check the current source files.

Extracted content

SKILL.md
# 跨会话记忆连续性

## 功能

- **24 小时滚动记忆**:自动加载最近 24 小时的记忆文件
- **每日记忆加载**:自动读取昨天和今天的 memory 文件
- **上下文恢复**:会话开始时自动恢复之前的对话上下文
- **长期记忆整合**:可选加载 MEMORY.md 长期记忆

## 使用场景

- 跨天对话连续性
- 多会话协作
- 长期项目跟踪
- 上下文不丢失

## 实现逻辑

```powershell
# 伪代码
function Load-CrossSessionMemory {
    param(
        [int]$RollingHours = 24,
        [bool]$LoadLongTerm = $true
    )
    
    $now = Get-Date
    $memoryDir = "$workspace\memory"
    $context = @()
    
    # 1. 加载长期记忆(仅主会话)
    if ($LoadLongTerm -and $IsMainSession) {
        $longTerm = Get-Content "$workspace\MEMORY.md" -Raw
        $context += "## 长期记忆`n$longTerm"
    }
    
    # 2. 计算时间范围
    $startTime = $now.AddHours(-$RollingHours)
    
    # 3. 加载范围内的每日记忆文件
    $date = $startTime.Date
    while ($date -le $now.Date) {
        $file = "$memoryDir\$($date.ToString('yyyy-MM-dd')).md"
        if (Test-Path $file) {
            $content = Get-Content $file -Raw
            $context += "## 记忆:$($date.ToString('yyyy-MM-dd'))`n$content"
        }
        $date = $date.AddDays(1)
    }
    
    # 4. 返回整合的上下文
    return $context -join "`n`n"
}
```

## 文件结构

```
workspace/
├── MEMORY.md              # 长期记忆( curated )
└── memory/
    ├── 2026-03-02.md      # 每日记忆(raw logs)
    ├── 2026-03-03.md
    └── ...
```

## 使用示例

### 会话开始时自动加载

在 AGENTS.md 中已经定义:

```markdown
## Every Session

Before doing anything else:

1. Read `SOUL.md` — this is who you are
2. Read `USER.md` — this is who you're helping
3. Read `memory/YYYY-MM-DD.md` (today + yesterday) for recent context
4. **If in MAIN SESSION**: Also read `MEMORY.md`
```

### 手动加载

```powershell
# 加载最近 24 小时记忆
$context = Load-CrossSessionMemory -RollingHours 24

# 加载最近 7 天记忆(长期项目)
$context = Load-CrossSessionMemory -RollingHours 168 -LoadLongTerm $false
```

## 记忆文件内...

Related skills

OpenClaw

13-Day Sprint Method

galizki

Productivity system based on Maya calendar with 13 natural tones for project management and personal development

OpenClaw

1password

daggerkun007

Set up and use 1Password CLI (op). Use when installing the CLI, enabling desktop app integration, signing in (single or multi-account), or reading/injecting/running secrets via op.