mcpField
M
memory-integration

memory-integration

github.com/troykellyAgent 工作流1257 次安装41 周前更新
代码仓库

关于 memory-integration

memory-integration 是帮助 Agent 跨会话延续项目上下文的技能,结合对话历史搜索与结构化知识图谱。它规定何时检索、记录哪些信息,以及如何基于既有决策和经验恢复工作。

主要功能

  1. 01按语义或概念搜索对话历史
  2. 02读取搜索结果中的完整对话
  3. 03存储实体、观察记录和关系
  4. 04遵循会话开始、进行与结束清单

适用场景

  1. 01开始问题处理前回忆过往工作
  2. 02规划修改时查看既有决策
  3. 03记录解决方案与结果供后续使用

MCP 相关

该技能说明如何使用 MCP 工具搜索和读取 episodic-memory,并通过 mcp__memory 知识图谱存取结构化上下文。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/troykelly/claude-skills --skill memory-integration

安装后在 Claude Code 中输入/memory-integration确认已加载。

详细介绍

记忆集成

概述

使用这两种记忆系统,在不同会话之间保持上下文。

核心原则: 会话之间不会保留记忆。使用这些工具来记住信息。

系统:

  • 情景记忆 - 搜索对话历史
  • 知识图谱(mcp__memory)- 结构化事实和关系

何时使用记忆

时机记忆操作
会话开始搜索相关上下文
开始处理问题之前搜索之前的工作
做出决定时检查过去的决定
完成工作时存储重要经验
会话结束存储关键结果

情景记忆

存储内容
  • 完整对话历史
  • 做出的决定
  • 已解决的问题
  • 尝试过的方法
  • 总结的经验
搜索情景记忆

使用情景记忆技能或 MCP 工具:

Search for:
- Issue number: "issue 123", "#123"
- Feature name: "authentication", "user login"
- Problem type: "TypeScript error", "build failure"
- Project name: repository name
语义搜索(单个查询)
// Search with natural language
mcp__plugin_episodic-memory_episodic-memory__search({
  query: "user authentication implementation decisions"
})
精确搜索(多个概念)
// Search for intersection of concepts
mcp__plugin_episodic-memory_episodic-memory__search({
  query: ["authentication", "session", "JWT"]
})
阅读完整对话

找到相关结果后:

// Read the full conversation
mcp__plugin_episodic-memory_episodic-memory__read({
  path: "/path/to/conversation.jsonl"
})
搜索内容
情况搜索词
开始处理问题 #123"issue 123"、"#123"
处理身份验证"authentication"、"login"、"session"
TypeScript 问题"TypeScript"、"type error"、具体错误消息
类似功能功能名称、相关概念

知识图谱(mcp__memory)

存储内容
  • 实体(项目、问题、决定、模式)
  • 实体之间的关系
  • 关于实体的观察
创建实体

存储重要事实:

// Create an entity for a project decision
mcp__memory__create_entities({
  entities: [{
    name: "Decision: Use JWT for Auth",
    entityType: "Decision",
    observations: [
      "Decided on 2024-12-01",
      "JWT chosen over sessions for API statelessness",
      "Related to issue #123",
      "Implementation in src/auth/jwt.ts"
    ]
  }]
})
创建关系

将实体关联起来:

// Create relationships
mcp__memory__create_relations({
  relations: [
    {
      from: "Project: MyApp",
      to: "Decision: Use JWT for Auth",
      relationType: "has_decision"
    },
    {
      from: "Issue #123",
      to: "Decision: Use JWT for Auth",
      relationType: "resulted_in"
    }
  ]
})
搜索图谱
// Search for relevant nodes
mcp__memory__search_nodes({
  query: "authentication"
})

// Open specific nodes
mcp__memory__open_nodes({
  names: ["Decision: Use JWT for Auth"]
})

// Read entire graph (for small graphs)
mcp__memory__read_graph({})

记忆协议

会话开始时
  1. 搜索情景记忆,查找:

    • 当前问题编号
    • 项目/代码库名称
    • 正在处理的活跃功能
  2. 搜索知识图谱,查找:

    • 项目实体
    • 相关决定
    • 已知模式
  3. 继续之前先综合上下文

工作期间

随时存储:

事件存储位置
重大决定知识图谱实体
已解决的问题向问题实体添加观察
发现的模式知识图谱实体
总结的经验添加观察
会话结束时
  1. 更新知识图谱,记录:

    • 新做出的决定
    • 已解决的问题
    • 发现的模式
  2. 向现有实体添加观察:

    • 问题进展
    • 经验总结
    • 后续步骤

实体类型

知识图谱建议使用的实体类型:

类型用途示例
项目代码库/代码基"Project: MyApp"
问题GitHub 问题"Issue #123: Auth"
决定架构决策"Decision: Use JWT"
模式代码模式"Pattern: Repository Layer"
问题已知问题"Problem: Race Condition in X"
人员协作者"Person: Alice (maintainer)"

示例:问题记忆流程

会话 1:开始处理问题
// Search for any previous context
const episodic = await search("issue 456 user profile");
const graph = await search_nodes("user profile");

// If nothing found, create fresh entity
await create_entities({
  entities: [{
    name: "Issue #456: User Profile Page",
    entityType: "Issue",
    observations: [
      "Started: 2024-12-01",
      "Scope: Profile display, edit, avatar upload"
    ]
  }]
});
会话 1:工作中做出决定
// Store a decision made
await add_observations({
  observations: [{
    entityName: "Issue #456: User Profile Page",
    contents: [
      "Decision: Using react-image-crop for avatar cropping",
      "Reason: Best mobile support, active maintenance"
    ]
  }]
});
会话 2:恢复工作
// Search for context
const results = await search("issue 456");
// Read: "Using react-image-crop for avatar cropping"

// Continue with context maintained

存储内容

始终存储
  • 附带理由的架构决策
  • 不显而易见的问题解决方案
  • 发现的重要约束
  • 组件之间的依赖关系
不要存储
  • 琐碎的实现细节
  • 代码中显而易见的内容
  • 临时调试笔记
  • 没有结论的猜测

检查清单

会话开始时:

  • 搜索情景记忆中的问题/项目
  • 搜索知识图谱中的上下文
  • 记录相关发现

工作期间:

  • 存储重大决定
  • 记录问题解决方案
  • 记录发现的模式

会话结束时:

  • 更新实体,记录进展
  • 添加新的经验总结
  • 记录后续步骤

集成

此技能由以下功能调用:

  • session-start - 初始上下文收集
  • issue-driven-development - 第 4 步

此技能支持:

  • 跨会话连续性
  • 决策记录
  • 模式发现

评论

支持 Markdown