S

Session Memory

AI 智能体v2.0.0
作者:swaylq更新于 2026-11-05session-memory@clawhub_swaylq/session-memory
上下文管理记忆增强

据 AlphaMoat 统计,截至 2026-10,Session Memory 累计下载 8,724 次、获 1 个星标,按累计下载量在本次参与排名的 10,914 个 AI 技能中排名第 3,188 位,在「AI 智能体」分类(1,632 个)中排名第 422 位。

列表默认按累计下载量排序,也可按星标排序;详情页排名按累计下载量计算。

累计下载
8,724
星标
1
全站下载量排名
#3,188
全站前 30% · 「AI 智能体」前 26%
平台累计下载星标评论
SkillHub ↗8,7241—

各平台的计数口径不同,统计时间不一致。

这个技能是做什么的

Bash 与 Node 工具可按主题、标签和重要性保存记录,通过多关键词搜索,并按重要性与时间加载相关上下文。它还支持主题归纳、编辑、删除、导入导出和归档,记忆以本地 JSONL 记录保存。 本地文件可能包含个人或项目资料;限制工作目录访问,并在处理前核对所选文件。

资料发布于 2026-10-27

可以用来做什么

  • 为后续会话保留决策和有用背景

什么时候用

  • 智能体需要持久上下文、可搜索记录或会话开始摘要时

示例提示词

以下是根据技能文档生成的示例,不代表实际运行结果。

按主题和重要性保存这条非敏感项目决策,并说明之后如何检索。

月度数据趋势

累计下载8,724
3,8416,4649,0862026-03 · 累计下载 4,2032026-05 · 累计下载 5,3752026-06 · 累计下载 5,6272026-07 · 累计下载 5,9872026-08 · 累计下载 6,1822026-09 · 累计下载 6,5692026-10 · 累计下载 8,72426-0326-0926-10
星标1
0122026-03 · 星标 12026-05 · 星标 12026-06 · 星标 12026-07 · 星标 12026-08 · 星标 12026-09 · 星标 12026-10 · 星标 126-0326-0926-10

2026-09 起统计方法调整:同名技能按作者分别统计,并覆盖全部技能。图中虚线为调整前的月份,与之后的数据不直接比较,也不计算跨越调整的增长。

月份累计下载环比星标
2026-108,724—1
2026-096,569—1
2026-086,182+3.3%1
2026-075,987+6.4%1
2026-065,627+4.7%1
2026-055,375—1
2026-034,203—1

SKILL.md 原文

以下是作者发布的原始文件,按纯文本显示,本站未做修改或审核;其中的链接不可点击,命令请核实后再运行。抓取于 2026-10-23。

5.2 KB · SkillHub v2.0.0
---
name: session-memory
description: Persistent memory toolkit for AI agents. Save context, recall with relevance scoring, consolidate insights, track decisions across sessions. Features importance levels, multi-keyword search, session context loader, export/import, memory stats. Pure bash+node, no dependencies. v2.0.0
homepage: https://github.com/voidborne-d/session-memory-skill
metadata: {"openclaw":{"emoji":"🧠","requires":{"bins":["node"]}}}
---

# Session Memory 🧠 v2.0

Persistent memory for AI agents. Save what matters, recall what's relevant, consolidate what you've learned.
展开全部(共 213 行)

**v2.0:** relevance-scored search, importance levels, session context loader, consolidation, export/import, stats, edit/delete.

## Quick Start

```bash
# Save a memory (with optional importance)
MEMORY_IMPORTANCE=high ./scripts/save.sh "decision" "Chose Postgres over SQLite for scale"

# Recall with relevance scoring
./scripts/recall.sh "database" --limit 5

# Load session context (startup)
./scripts/context.sh --days 3

# Consolidate by topic
./scripts/consolidate.sh --since 2026-01-01

# Stats
./scripts/stats.sh
```

---

## Commands

### save.sh — Save a Memory

```bash
./scripts/save.sh "topic" "content" [tags...]
```

| Env | Default | Description |
|-----|---------|-------------|
| `AGENT_MEMORY_DIR` | `~/.agent-memory` | Storage directory |
| `MEMORY_IMPORTANCE` | `normal` | low / normal / high / critical |

```bash
# Basic save
./scripts/save.sh "insight" "Users prefer dark mode 3:1" ui design

# High importance
MEMORY_IMPORTANCE=high ./scripts/save.sh "decision" "Migrated to TypeScript" refactor

# Critical (always surfaces in context.sh)
MEMORY_IMPORTANCE=critical ./scripts/save.sh "credential" "API key rotated, new one in vault"
```

### recall.sh — Search Memories

```bash
./scripts/recall.sh "query" [--json] [--limit N] [--topic T] [--importance I] [--since YYYY-MM-DD]
```

Features:
- **Multi-keyword AND search** — all words must match
- **Relevance scoring** — based on word match ratio + importance + recency
- **Filters** — by topic, importance level, date range

```bash
./scripts/recall.sh "database migration"
./scripts/recall.sh "API" --topic decision --limit 20
./scripts/recall.sh "deploy" --since 2026-03-01 --json
./scripts/recall.sh "error" --importance high
```

### context.sh — Session Startup Loader

```bash
./scripts/context.sh [--days N] [--limit N] [--json]
```

Loads the most relevant memories for a new session:
- Recent memories (last N days, default 3)
- High/critical importance items regardless of age
- Sorted by importance then recency
- Grouped by date

```bash
# Quick context
./scripts/context.sh

# Wider window
./scripts/context.sh --days 7 --limit 30

# For programmatic use
./scripts/context.sh --json
```

### daily.sh — Day View

```bash
./scripts/daily.sh [YYYY-MM-DD] [--json]
```

### topics.sh — Topic Index

```bash
./scripts/topics.sh [--json]
```

### consolidate.sh — Topic Consolidation

```bash
./scripts/consolidate.sh [--since YYYY-MM-DD] [--topic T] [--json]
```

Groups all memories by topic, showing counts, date ranges, top tags, and latest entries. Useful for periodic review.

### stats.sh — Memory Statistics

```bash
./scripts/stats.sh [--json]
```

Shows: total entries, date range, entries/day average, storage size, topic breakdown, importance distribution.

### edit.sh — Edit or Delete

```bash
./scripts/edit.sh <timestamp_ms> --content "new content"
./scripts/edit.sh <timestamp_ms> --topic "new topic"
./scripts/edit.sh <timestamp_ms> --importance critical
./scripts/edit.sh <timestamp_ms> --delete
```

### export.sh — Export Memories

```bash
./scripts/export.sh [-o backup.json] [--since YYYY-MM-DD] [--topic T]
```

### import.sh — Import Memories

```bash
./scripts/import.sh backup.json [--dry-run]
```

Deduplicates by timestamp — safe to run multiple times.

### prune.sh — Archive Old Memories

```bash
./scripts/prune.sh [days]
```

Moves memories older than N days (default: 30) to `archive/`.

---

## Storage

```
~/.agent-memory/
├── 2026/
│   ├── 01/
│   │   ├── 15.jsonl
│   │   └── 16.jsonl
│   └── 02/
│       └── 01.jsonl
└── archive/          # Pruned memories
```

Each line is a JSON object:
```json
{"ts":1706793600000,"topic":"decision","content":"Chose X because Y","tags":["project"],"importance":"high"}
```

## Importance Levels

| Level | When to Use | Behavior |
|-------|-------------|----------|
| `low` | Background info, minor notes | Only found via search |
| `normal` | Standard memories | Shown in daily view |
| `high` | Key decisions, insights | Always in session context |
| `critical` | Credentials, blockers, urgent | Always in session context, top priority |

## Recommended Workflow

```bash
# Session start
./scripts/context.sh

# During work — save important things
./scripts/save.sh "decision" "..."
MEMORY_IMPORTANCE=high ./scripts/save.sh "insight" "..."

# End of session
./scripts/save.sh "summary" "Today: did X, decided Y, next step Z"

# Weekly review
./scripts/consolidate.sh --since $(date -u -d '7 days ago' +%Y-%m-%d)
./scripts/stats.sh

# Monthly maintenance
./scripts/prune.sh 60
./scripts/export.sh -o backup-$(date +%Y%m).json
```

---

*Created by [Voidborne](https://voidborne.org) 🔹*

「AI 智能体」分类下的热门技能

数据月份:2026-10 · 下载/星标数聚合自公开技能注册库(ClawHub、SkillHub),按月更新。口径说明见数据方法。