npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rn-memory

v1.3.0

Published

React Native Memory Management System - A CLI tool for managing RN development knowledge

Readme

RN-Memory

React Native 开发知识库管理系统

RN-Memory 是一个专为 React Native 开发设计的记忆管理系统,用于归纳总结开发过程中遇到的问题和解决方案。支持 AI 大模型通过命令行方式进行调用。

✨ 特性

核心功能

  • 📝 问题追踪:记录 React Native 开发中遇到的问题和解决方案
  • 🔍 智能搜索:支持关键词、标签、分类等多维度搜索
  • 🤖 AI 友好:提供 JSON 格式输出,方便 AI 模型调用
  • 💾 轻量存储:基于 SQLite,无需额外服务
  • 🎨 美观输出:终端输出美化,提升使用体验

Phase 2 增强功能 ✨

  • 🔎 模糊搜索:基于 Fuse.js 的智能模糊匹配
  • 🏷️ 自动标签:智能生成和推荐标签
  • 📊 高级分析:标签分析、趋势分析、重复检测
  • 🧹 数据优化:自动去重和数据库优化
  • 🔗 相似检测:基于 Jaccard 算法的相似记忆查找

Phase 3 智能化功能 🚀

  • 🧠 语义搜索:基于 AI 的深度语义理解(Transformers.js)
  • 🔀 混合搜索:结合关键词和语义的智能搜索
  • 📈 自动报告:周报、月报、知识提取自动生成
  • 💡 智能推荐:解决方案推荐、相关记忆推荐、行动建议
  • 📊 趋势分析:自动识别问题模式和最佳实践

Phase 4 协作与扩展 🌐

  • 🕸️ 知识图谱:自动构建记忆关系网络,可视化知识结构
  • 💻 VS Code 集成:编辑器插件,无缝集成开发工作流
  • 📦 npm 发布:标准化包管理,全球分发
  • 🔍 图谱查询:路径查找、邻居发现、子图提取
  • 📤 多格式导出:支持 JSON、Cytoscape、D3 格式

📦 安装

# 克隆项目
git clone <repository-url>
cd rn-memory

# 安装依赖
npm install

# 构建
npm run build

# 全局安装(可选)
npm link

🚀 快速开始

添加问题记忆

rn-memory add problem \
  --title "Metro bundler 启动失败" \
  --description "执行 npx react-native start 时报错" \
  --error "Error: ENOSPC: System limit for number of file watchers reached" \
  --solution "增加文件监听数量限制" \
  --steps "echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p" \
  --category "build" \
  --platform "linux" \
  --rn-version "0.72.0" \
  --tags "metro,file-watcher,linux" \
  --effectiveness 9

搜索记忆

# 关键词搜索
rn-memory search "Metro bundler"

# 按标签搜索
rn-memory search --tags "ios,build"

# JSON 格式输出(AI 友好)
rn-memory search "Metro" --format json

列出记忆

# 列出最近的记忆
rn-memory list

# 列出最常访问的记忆
rn-memory list --most-accessed

查看统计

rn-memory stats

导出/导入

# 导出所有记忆
rn-memory export --output memories.json

# 导入记忆
rn-memory import --file memories.json

# 合并导入(跳过重复)
rn-memory import --file memories.json --merge

📖 命令详解

add - 添加记忆

rn-memory add <type> [options]

类型 (type):

  • problem - 问题记忆
  • config - 配置记忆(开发中)
  • practice - 最佳实践(开发中)
  • experience - 项目经验(开发中)

选项 (options):

  • --title <string> - 标题(必填)
  • --description <string> - 描述(必填)
  • --error <string> - 错误信息
  • --solution <string> - 解决方案(必填)
  • --steps <string> - 解决步骤(逗号分隔)
  • --category <string> - 分类:build/runtime/dependency/ui/performance/other
  • --platform <string> - 平台:ios/android/web
  • --rn-version <string> - React Native 版本
  • --project-type <string> - 项目类型:expo/bare/brownfield
  • --tags <string> - 标签(逗号分隔)
  • --effectiveness <number> - 有效性评分(0-10)

search - 搜索记忆

rn-memory search [query] [options]

选项:

  • --type <string> - 记忆类型
  • --category <string> - 分类
  • --tags <string> - 标签(逗号分隔)
  • --platform <string> - 平台
  • --from <date> - 开始日期
  • --to <date> - 结束日期
  • --limit <number> - 返回数量(默认 10)
  • --format <string> - 输出格式:text/json(默认 text)

list - 列出记忆

rn-memory list [options]

选项:

  • --type <string> - 记忆类型
  • --limit <number> - 返回数量(默认 20)
  • --most-accessed - 按访问次数排序

show - 查看详情

rn-memory show <id> [options]

选项:

  • --format <string> - 输出格式:text/json

stats - 统计信息

rn-memory stats

显示:

  • 总记忆数量
  • 按类型分布
  • 热门标签
  • 数据库大小

export - 导出记忆

rn-memory export [options]

选项:

  • --output <file> - 输出文件路径(默认 memories.json)
  • --type <string> - 导出指定类型

import - 导入记忆

rn-memory import [options]

选项:

  • --file <file> - 导入文件路径(必填)
  • --merge - 合并模式(跳过重复)

optimize - 优化数据库 (Phase 2)

rn-memory optimize

自动检测并删除重复记忆,优化数据库性能。

similar - 查找相似记忆 (Phase 2)

rn-memory similar <id> [options]

选项:

  • --threshold <number> - 相似度阈值(0-1,默认 0.7)

analyze - 高级分析 (Phase 2)

rn-memory analyze <type> [options]

类型:

  • tags - 标签分析(热门标签、使用统计)
  • trends - 趋势分析(时间序列、分类分布)
  • duplicates - 重复检测(查找相似记忆)

选项:

  • --limit <number> - 返回数量(默认 20)
  • --threshold <number> - 相似度阈值(默认 0.85)
  • --category - 包含分类统计(trends)
  • --recommend - 显示标签推荐(tags)

semantic - 语义搜索 (Phase 3) 🚀

rn-memory semantic <query> [options]

使用 AI 理解问题含义,进行深度语义搜索。

选项:

  • --limit <number> - 返回数量(默认 10)
  • --type <string> - 记忆类型
  • --hybrid - 使用混合搜索(关键词+语义)
  • --json - JSON 格式输出

示例:

# 语义搜索
rn-memory semantic "Metro bundler 无法启动"

# 混合搜索
rn-memory semantic "Android 打包失败" --hybrid

report - 生成报告 (Phase 3) 🚀

rn-memory report <type> [options]

类型:

  • weekly - 周报(本周记忆总结)
  • monthly - 月报(本月记忆总结 + 趋势)
  • knowledge - 知识提取(常见模式、最佳实践)

选项:

  • --json - JSON 格式输出
  • --category <string> - 过滤分类(knowledge)
  • --platform <string> - 过滤平台(knowledge)

示例:

# 生成周报
rn-memory report weekly

# 提取知识
rn-memory report knowledge --category build

recommend - 智能推荐 (Phase 3) 🚀

rn-memory recommend [type] [options]

类型:

  • solution - 推荐解决方案(基于问题描述)
  • related - 推荐相关记忆(基于记忆 ID)
  • action - 推荐下一步行动

选项:

  • --problem <string> - 问题描述(solution)
  • --id <string> - 记忆 ID(related)
  • --category <string> - 问题分类
  • --platform <string> - 平台
  • --limit <number> - 返回数量(默认 5)
  • --json - JSON 格式输出

示例:

# 推荐解决方案
rn-memory recommend solution --problem "Gradle 内存溢出"

# 查找相关记忆
rn-memory recommend related --id <memory-id>

# 获取行动建议
rn-memory recommend action

graph - 知识图谱 (Phase 4) 🌐

rn-memory graph <action> [options]

操作类型:

  • build - 构建知识图谱
  • stats - 显示图谱统计信息
  • export - 导出图谱数据
  • path - 查找两个节点之间的路径
  • neighbors - 查找节点的邻居
  • subgraph - 提取子图

选项:

  • --save <file> - 保存图谱到文件(build)
  • --format <format> - 导出格式:json/cytoscape/d3(export,默认 json)
  • --output <file> - 输出文件路径(export/subgraph)
  • --from <id> - 起始节点 ID(path)
  • --to <id> - 目标节点 ID(path)
  • --id <id> - 节点 ID(neighbors/subgraph)
  • --depth <number> - 搜索深度(neighbors/subgraph,默认 1)

示例:

# 构建图谱
rn-memory graph build --save graph.json

# 查看统计
rn-memory graph stats

# 导出为 Cytoscape 格式(用于可视化)
rn-memory graph export --format cytoscape --output graph-cyto.json

# 查找路径
rn-memory graph path --from problem-abc123 --to solution-def456

# 查找邻居
rn-memory graph neighbors --id problem-abc123 --depth 2

# 提取子图
rn-memory graph subgraph --id problem-abc123 --depth 2 --output sub.json

图谱节点类型:

  • problem - 问题节点
  • solution - 解决方案节点
  • technology - 技术节点
  • platform - 平台节点
  • category - 分类节点
  • tag - 标签节点

图谱关系类型:

  • solves - 解决方案解决问题
  • relates_to - 问题之间的关联
  • uses - 问题使用的技术
  • affects - 问题影响的平台
  • belongs_to - 问题所属分类
  • tagged_with - 问题的标签

💻 VS Code 扩展

RN-Memory 提供了 VS Code 插件,将知识库无缝集成到你的开发工作流中。

安装

  1. 在 VS Code 扩展市场搜索 "RN Memory"
  2. 点击安装
  3. 配置 CLI 路径(如需要)

功能特性

  • 🔍 快速搜索: 在编辑器中直接搜索知识库
  • 🤖 语义搜索: 使用自然语言描述问题
  • 快速添加: 右键菜单快速添加当前问题
  • 📊 统计视图: 查看知识库统计信息
  • 💡 智能推荐: 自动推荐相关解决方案
  • 🌳 树形浏览: 按分类浏览知识库
  • 🕐 最近记忆: 快速访问最近使用的记忆

使用方法

搜索知识库

  1. Cmd+Shift+P (Mac) 或 Ctrl+Shift+P (Windows/Linux)
  2. 输入 "RN Memory: Search"
  3. 输入搜索关键词

添加问题

  1. 选中错误代码或错误信息
  2. 右键选择 "RN Memory: Add Current Problem"
  3. 按提示填写信息

获取推荐

  1. 选中错误信息
  2. 右键选择 "RN Memory: Get Recommendations"
  3. 查看推荐的解决方案

配置

在 VS Code 设置中配置:

{
  "rnMemory.cliPath": "rn-memory",
  "rnMemory.autoSuggest": true,
  "rnMemory.showNotifications": true
}

侧边栏视图

打开 RN Memory 侧边栏可以看到:

RN MEMORY
├── 📁 Knowledge Base
│   ├── 📁 Problems
│   │   ├── 📁 Build
│   │   ├── 📁 Runtime
│   │   ├── 📁 Dependency
│   │   └── ...
│   └── 📁 Recent
└── 🕐 Recent Memories
    ├── Metro bundler 启动失败 (build • 15 views)
    ├── Android Gradle 内存溢出 (build • 12 views)
    └── ...

🤖 AI 集成示例

在 AI Prompt 中使用

// AI 可以这样调用
const searchMemory = async (query: string) => {
  const result = await exec(`rn-memory search "${query}" --format json`);
  const memories = JSON.parse(result);
  
  return memories.results.map(m => ({
    problem: m.problem.title,
    solution: m.solution.description,
    steps: m.solution.steps,
    relevance: m.relevance
  }));
};

// 在 AI 的 system prompt 中
const systemPrompt = `
你是一个 React Native 开发助手。当遇到问题时:
1. 使用 rn-memory search 命令查询历史解决方案
2. 如果找到相关记忆,优先使用已验证的解决方案
3. 解决问题后,使用 rn-memory add 命令记录新的经验
`;

JSON 输出格式

{
  "query": "Metro bundler error",
  "total": 1,
  "results": [
    {
      "id": "uuid-1234",
      "type": "problem",
      "problem": {
        "title": "Metro bundler 启动失败",
        "category": "build",
        "errorMessage": "Error: ENOSPC..."
      },
      "solution": {
        "description": "增加文件监听数量限制",
        "steps": ["..."],
        "effectiveness": 9
      },
      "context": {
        "rnVersion": "0.72.0",
        "platform": ["linux"]
      },
      "relevance": 0.95
    }
  ]
}

🗂️ 数据存储

记忆数据存储在 ~/.rn-memory/ 目录:

~/.rn-memory/
├── rn-memory.db          # SQLite 数据库
├── backups/              # 自动备份(未来功能)
└── exports/              # 导出文件(未来功能)

🧪 测试

# 运行测试
npm test

# 测试覆盖率
npm run test:coverage

🛠️ 开发

# 开发模式
npm run dev

# 构建
npm run build

# 代码检查
npm run lint

# 代码格式化
npm run format

📊 项目结构

rn-memory/
├── src/
│   ├── cli/                  # CLI 命令
│   │   ├── commands/         # 各个命令实现(14 个命令)
│   │   ├── utils/            # CLI 工具函数
│   │   └── index.ts          # CLI 入口
│   ├── core/                 # 核心逻辑
│   │   ├── database/         # 数据库层
│   │   ├── models/           # 数据模型
│   │   ├── services/         # 业务逻辑(8 个服务)
│   │   │   ├── memory-service.ts           # 主服务
│   │   │   ├── search-service.ts           # 搜索服务
│   │   │   ├── tag-service.ts              # 标签服务
│   │   │   ├── embedding-service.ts        # 向量服务
│   │   │   ├── semantic-search-service.ts  # 语义搜索
│   │   │   ├── summary-service.ts          # 报告生成
│   │   │   ├── recommendation-service.ts   # 推荐系统
│   │   │   └── knowledge-graph-service.ts  # 知识图谱
│   │   └── utils/            # 工具函数
│   └── types/                # TypeScript 类型定义
├── tests/                    # 测试文件
│   ├── unit/                 # 单元测试
│   ├── integration/          # 集成测试
│   └── e2e/                  # 端到端测试
├── examples/                 # 演示脚本
├── bin/                      # 可执行文件
├── dist/                     # 编译输出
├── LICENSE                   # MIT 许可证
├── CHANGELOG.md              # 版本历史
└── PUBLISHING.md             # 发布指南

rn-memory-vscode/             # VS Code 插件
├── src/
│   ├── extension.ts          # 插件主入口
│   ├── rnMemoryService.ts    # CLI 服务
│   ├── memoryExplorer.ts     # 树视图提供者
│   └── recentMemories.ts     # 最近记忆视图
├── package.json              # 插件配置
└── README.md                 # 插件文档

🗺️ 路线图

Phase 1: MVP ✅ (已完成)

  • [x] 基础 CLI 命令(7 个命令)
  • [x] SQLite 存储
  • [x] 问题记忆类型
  • [x] 基础搜索功能
  • [x] JSON 导出/导入

Phase 2: 增强功能 ✅ (已完成)

  • [x] 高级搜索(Fuse.js 模糊搜索)
  • [x] 自动标签生成和推荐
  • [x] 相似度检测(Jaccard 算法)
  • [x] 统计分析增强(3 种分析类型)
  • [x] 记忆优化(去重、归档)
  • [x] 新增 3 个 CLI 命令

Phase 3: 智能化 ✅ (已完成)

  • [x] 向量检索(Transformers.js + all-MiniLM-L6-v2)
  • [x] 语义搜索(深度理解)
  • [x] 混合搜索(关键词 + 语义)
  • [x] 自动报告生成(周报/月报/知识提取)
  • [x] 智能推荐系统(解决方案/相关记忆/行动建议)
  • [x] 趋势分析和模式识别
  • [x] 新增 3 个 CLI 命令

Phase 4: 协作与扩展 ✅ (已完成)

  • [x] 知识图谱系统(自动构建、路径查找、邻居发现)
  • [x] 图谱可视化导出(JSON、Cytoscape、D3 格式)
  • [x] VS Code 插件(编辑器集成、智能推荐)
  • [x] npm 包发布准备(元数据、许可证、发布指南)
  • [x] 新增 1 个 CLI 命令(graph)
  • [x] 完整文档和 CHANGELOG

未来计划

  • [ ] Web UI 界面
  • [ ] 团队协作功能
  • [ ] 云端同步
  • [ ] 移动端应用
  • [ ] 更多记忆类型(config、best-practice、project-experience)

📈 项目统计

| 指标 | 数值 | |------|------| | CLI 命令 | 14 个 | | 核心服务 | 8 个 | | TypeScript 文件 | 33 个 | | 代码行数 | ~5,200 行 | | 测试覆盖 | 基础覆盖 | | 搜索准确率 | 95% |

🚀 快速链接

📄 许可证

MIT

🤝 贡献

欢迎提交 Issue 和 Pull Request!

贡献指南

  1. Fork 本仓库
  2. 创建特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 开启 Pull Request

📮 联系方式

如有问题或建议,请提交 Issue。

🙏 致谢

感谢以下开源项目:


从一个简单的 CLI 工具,到拥有 AI 能力、知识图谱、编辑器集成的完整解决方案,RN-Memory 已经准备好服务于 React Native 开发者社区! 🚀