Rechercher

PythonReactSEOPDF
OpenClaw

cross-session-memory

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

24267580930 installations selon la source☆ 0 Étoiles du dépôt

Installation

Suivez les instructions du dépôt pour votre agent. Consultez les fichiers et dépendances avant l’installation.

SkillHub CLI

skillhub install 2426758093/cross-session-memory

Examinez la source et la compatibilité, puis suivez les étapes d’installation.

Donnez le lien à votre agent et demandez-lui d’examiner instructions et dépendances avant d’expliquer les étapes.

Voir la source ↗Guides

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

记忆文件内...

Informations sur la source

Source
github
Repository
openclaw/skills
Path
skills/2426758093/cross-session-memory
Version
—
Commit
81af75eff191010bbdf94ae120fab409f574b53e
Source de classification
rules
Statut
active
Visibilité
public

Ces informations proviennent de l’analyse indexée et peuvent être anciennes. Vérifiez les fichiers actuels.

Contenu extrait

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
```

## 记忆文件内...

Skills associés

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.