用途
memory 技能基于 basic-memory CLI,提供跨会话的持久化知识存储能力。它让 AI 助手可以保存笔记、以语义方式搜索记忆,并为主题构建上下文,从而在多次会话之间积累与延续知识。
主要能力
- 写入笔记:使用
basic-memory tool write-note保存笔记,支持标题、Markdown 内容、标签、指定文件夹和指定项目。 - 读取笔记:使用
basic-memory tool read-note按标识符/永久链接读取,也可指定项目。 - 语义搜索:使用
basic-memory tool search-notes进行语义搜索,支持限制结果数量、按永久链接搜索、按标题搜索、按日期过滤以及指定项目。 - 构建主题上下文:使用
basic-memory tool build-context获取某个 URL/主题的相关笔记,支持设置深度和时间范围。 - 查看最近活动:使用
basic-memory tool recent-activity查看近期活动,支持深度与时间范围参数。 - 继续对话:使用
basic-memory tool continue-conversation获取继续此前工作的提示。 - 同步与状态:使用
basic-memory sync同步数据库,使用basic-memory status检查状态。
使用方式
前提条件是安装 basic-memory:
pip install basic-memory
写入笔记示例:
# 基本笔记
basic-memory tool write-note --title "Note Title" --content "Note content in markdown"
# 带标签
basic-memory tool write-note --title "React Patterns" --content "# Content here" --tags "react,patterns,frontend"
# 指定文件夹
basic-memory tool write-note --title "Meeting Notes" --content "# Notes" --folder "meetings"
# 指定项目
basic-memory tool write-note --title "Project Notes" --content "# Notes" --project myproject
读取笔记示例:
# 按标识符/永久链接
basic-memory tool read-note "note-title"
# 从特定项目
basic-memory tool read-note "note-title" --project myproject
搜索记忆示例:
# 语义搜索(查询为位置参数)
basic-memory tool search-notes "your search query"
# 限制结果
basic-memory tool search-notes "react hooks" --page-size 10
# 按永久链接搜索
basic-memory tool search-notes "pattern" --permalink
# 按标题搜索
basic-memory tool search-notes "meeting" --title
# 按日期过滤
basic-memory tool search-notes "feature" --after_date "7d"
# 指定项目
basic-memory tool search-notes "authentication" --project myproject
构建上下文示例:
# 获取 URL/主题的相关笔记(URL 为位置参数)
basic-memory tool build-context "memory://topic/authentication"
# 设置深度和时间范围
basic-memory tool build-context "memory://note/my-note" --depth 2 --timeframe 30d
# 指定项目
basic-memory tool build-context "memory://topic/api" --project myproject
查看最近活动示例:
# 默认(深度 1,7 天)
basic-memory tool recent-activity
# 设置深度
basic-memory tool recent-activity --depth 3
# 设置时间范围
basic-memory tool recent-activity --timeframe 30d
# 组合
basic-memory tool recent-activity --depth 3 --timeframe 14d
继续对话示例:
basic-memory tool continue-conversation "previous topic or context"
同步与状态:
basic-memory sync
basic-memory status
笔记格式:笔记以包含 YAML frontmatter 的 Markdown 存储。
---
title: My Note
tags: [tag1, tag2]
created: 2024-01-15
---
# My Note
Content here in markdown format.
## Sections
More content...
适用场景
- 个人 Wiki:存储代码片段和模式、记录项目决策、保留参考资料。
- 学习日志:记录学到的东西,按主题打标签以便日后检索,随时间积累知识。
- 项目上下文:保存项目专属知识,在会话开始时检索相关上下文,跨会话共享知识。
工作流模式
- 保存学习:发现有用内容时写入笔记,例如:
basic-memory tool write-note \
--title "TypeScript Utility Types" \
--content "# Utility Types\n\n- Partial<T> - Makes all properties optional\n- Required<T> - Makes all properties required\n- Pick<T, K> - Picks specific properties" \
--tags "typescript,types,reference"
- 保存决策:做出架构决策时写入笔记,例如:
basic-memory tool write-note \
--title "Auth Strategy Decision" \
--content "# Decision: Use JWT for API auth\n\n## Context\n...\n\n## Decision\n...\n\n## Consequences\n..." \
--tags "architecture,auth,decision" \
--folder "decisions"
- 检索上下文:开始相关工作前进行搜索或构建上下文,例如:
basic-memory tool search-notes "authentication jwt tokens"
basic-memory tool build-context "memory://topic/api-authentication"
- 回顾近期工作:
basic-memory tool recent-activity --depth 5 --timeframe 7d
集成模式
- 会话开始:获取当天工作的上下文:
basic-memory tool build-context "memory://topic/feature-youre-building"
- 工作中:保存发现:
basic-memory tool write-note --title "Discovery Title" --content "What I learned"
- 会话结束:同步以确保持久化:
basic-memory sync
最佳实践
- 使用有意义的标题——它们会成为永久链接。
- 添加标签——改善搜索和组织。
- 使用 Markdown——内容完全支持 Markdown。
- 用文件夹组织——对相关笔记进行分组。
- 写之前先搜索——检查知识是否已存在。
- 保持笔记专注——每条笔记一个主题。
- 更新而非重复——修订现有笔记。
限制
资料中未提供关于平台支持范围、并发能力、笔记数量上限、basic-memory 版本要求等限制信息,相关内容暂未提供。