360 Secure SkillHub
360 安全技能中心

MAMP

MAMP 通过本地 SQLite 数据库为 AI 代理提供跨会话记忆:可创建会话、记录 user/assistant 轮次、添加标签与优先级,并在全部会话中做关键词计数与检索。技能声明无需外部服务、API Key 或第三方依赖,默认写入当前目录的 mark_memory.db。

rokkiezeng
rokkiezeng
热度 20.56
最近更新 2026-04-17 13:41:47
分类:知识依赖:代码执行 / 读写文件应用场景:笔记整理 / 研究 / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add mamp
Metadata
name
mamp
description
Mark AI Memory Protocol — persistent, searchable session memory for AI agents. SQLite-only, zero external dependencies.
author
LeoTseng
version
1.1.5
license
MIT-0

MAMP — Mark AI Memory Protocol

Gives AI agents persistent, searchable memory using SQLite.

When to Use

  • User says "remember what I told you last time"
  • Agent needs to recall facts across conversations
  • User asks about past topics, preferences, or decisions
  • Context window is filling up and older info needs to be summarized

Core Concepts

  • Session — a conversation, has an ID, survives restarts
  • Turn — one message in a session (role: user/assistant)
  • Tag — labels for a turn, e.g. ["finance", "important"]
  • Priority — importance level: critical, normal, trivial

Key Methods

from importlib.util import spec_from_file_location, module_from_spec
spec = spec_from_file_location("mamp", "ai_memory_protocol_v1.1.5.py")
mod = module_from_spec(spec)
spec.loader.exec_module(mod)

# Default: writes to ./mark_memory.db in current directory
sm = mod.SessionManager()
# Or specify path explicitly:
sm = mod.SessionManager(db_path="./memory.db")
# Or via environment variable:
# export MARK_MEMORY_DB=/path/to/memory.db

# Start a conversation
sid = sm.start_conversation()

# Add a message
sm.add_turn("user", "I prefer dark mode")
sm.add_turn("assistant", "Noted")

# Search across all sessions
count = sm.search_count("dark mode")
results = sm.search("dark mode", limit=5)

# Get full session
sess = sm.get_session_extended(sid)
# → {'total_turns': 2, 'turns': [...], 'meta': {...}}

# Tag and filter
sm.add_turn("user", "finance topic", tags=["finance"])
c = sm.search_count("topic", tag_filter=["finance"])

What It Solves

AI forgets everything each conversation. MAMP makes memory persistent, searchable, and structured — without any external service, API key, or dependency beyond SQLite.