inmemoria

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

In Memoria: Persistent Codebase Intelligence

In Memoria: 持久化代码库智能

In Memoria is an MCP server that learns your codebase patterns once, then exposes that intelligence to AI agents persistently. Instead of re-analyzing code on every interaction, it maintains a semantic understanding of your architecture, conventions, and decisions.
In Memoria 是一款MCP服务器,只需学习一次你的代码库模式,就能持续为AI Agent提供这种智能能力。无需在每次交互时重新分析代码,它会持续维护对你的架构、约定和决策的语义理解。

Core Concept

核心概念

Setup → Learn → Verify → Serve. After that, AI agents query persistent intelligence without repeated parsing.
设置 → 学习 → 验证 → 提供服务。完成后,AI Agent即可查询持久化智能,无需重复解析代码。

Quick Start (5 minutes)

快速开始(5分钟)

bash
undefined
bash
undefined

1. Configure for your project

1. 为你的项目进行配置

npx in-memoria setup --interactive
npx in-memoria setup --interactive

2. Build intelligence database

2. 构建智能数据库

npx in-memoria learn ./src
npx in-memoria learn ./src

3. Verify it worked

3. 验证是否成功

npx in-memoria check ./src --verbose
npx in-memoria check ./src --verbose

4. Keep it fresh (optional but recommended)

4. 保持智能更新(可选但推荐)

npx in-memoria watch ./src
npx in-memoria watch ./src

5. Expose to agents via MCP

5. 通过MCP向Agent提供服务

npx in-memoria server
undefined
npx in-memoria server
undefined

When to Use

适用场景

Use In Memoria:
  • Building long-lived AI agent partnerships (Claude, Copilot, etc.)
  • Projects where consistency across sessions matters
  • Teams wanting shared codebase intelligence
Skip it:
  • One-off analysis (use
    npx in-memoria analyze [path]
    directly)
  • Simple projects agents can read directly
推荐使用In Memoria:
  • 构建长期运行的AI Agent协作(Claude、Copilot等)
  • 跨会话一致性至关重要的项目
  • 需要共享代码库智能的团队
不建议使用:
  • 一次性分析场景(直接使用
    npx in-memoria analyze [path]
  • Agent可直接读取的简单项目

The 5 Core Commands

5个核心命令

CommandPurposeWhen
setup --interactive
Configure exclusions, paths, preferencesFirst time only
learn [path]
Build/rebuild intelligence databaseAfter setup, major refactors
check [path]
Validate intelligence layerAfter learn, before server
watch [path]
Auto-update intelligence on code changesDuring development (optional)
server
Start MCP server for agent queriesAfter check passes
Key difference:
learn
builds persistent knowledge.
analyze
is one-time reporting only.
命令用途使用时机
setup --interactive
配置排除项、路径和偏好设置仅首次使用
learn [path]
构建/重建智能数据库完成设置后、重大重构后
check [path]
验证智能层执行learn后、启动server前
watch [path]
代码变更时自动更新智能开发期间(可选)
server
启动MCP服务器供Agent查询检查通过后
关键区别:
learn
用于构建持久化知识,
analyze
仅用于一次性报告。

What Agents See

Agent可查询内容

When connected, agents can query:
  • Project structure - Tech stack, entry points, architecture
  • Code patterns - Your naming conventions, error handling, patterns used
  • Smart routing - "Add password reset" → suggests
    src/auth/password-reset.ts
  • Semantic search - Find code by meaning, not keywords
  • Work context - Track decisions, tasks, approach consistency
连接后,Agent可查询以下信息:
  • 项目结构 - 技术栈、入口点、架构
  • 代码模式 - 命名约定、错误处理、所用模式
  • 智能路由 - 例如“添加密码重置功能”→ 推荐
    src/auth/password-reset.ts
  • 语义搜索 - 按含义而非关键词查找代码
  • 工作上下文 - 追踪决策、任务、方法一致性

Troubleshooting

故障排查

IssueFix
Learn failsVerify path is correct; check file permissions
Check reports missing intelligenceRun
learn [path]
again
Agent doesn't see new codeIs
watch
running? Start it:
npx in-memoria watch ./src
Server won't startRun
check --verbose
first; if issues, rebuild:
rm .in-memoria/*.db && npx in-memoria learn ./src
Multiple projects conflictUse
server --port 3001
(or different port per project)
问题解决方法
Learn执行失败验证路径是否正确;检查文件权限
Check报告缺少智能重新运行
learn [path]
Agent无法看到新代码是否运行了
watch
?启动它:
npx in-memoria watch ./src
Server无法启动先运行
check --verbose
;若仍有问题,重建数据库:
rm .in-memoria/*.db && npx in-memoria learn ./src
多项目冲突使用
server --port 3001
(或为每个项目使用不同端口)

Performance Notes

性能说明

  • Small projects (<1K files): 5-15s to learn
  • Medium (1K-10K files): 30-60s
  • Large (10K+ files): 2-5min
If learning stalls (>10min), verify you're not indexing
node_modules/
,
dist/
, or build artifacts—use setup's exclusion patterns.
  • 小型项目(<1000个文件):5-15秒完成学习
  • 中型项目(1000-10000个文件):30-60秒
  • 大型项目(10000+个文件):2-5分钟
如果学习过程停滞(超过10分钟),请确认未索引
node_modules/
dist/
或构建产物——可使用设置中的排除规则。

Key Principles

核心原则

  1. Local-first - Everything stays on your machine; no telemetry
  2. Persistent - One learning pass; intelligence updates incrementally with
    watch
  3. Agent-native - Designed for MCP; works with Claude, Copilot, and any MCP-compatible tool
  4. Pattern-based - Learns from your actual code, not rules you define
  1. 本地优先 - 所有数据均保存在你的设备上;无遥测数据
  2. 持久化 - 仅需一次学习;通过
    watch
    实现智能增量更新
  3. 原生支持Agent - 为MCP设计;可与Claude、Copilot及任何兼容MCP的工具配合使用
  4. 基于模式 - 从你的实际代码中学习,而非你定义的规则

Deployment Pattern (3 terminals)

部署模式(3个终端)

bash
undefined
bash
undefined

Terminal 1: One-time setup

终端1:一次性设置

npx in-memoria setup --interactive npx in-memoria learn ./src npx in-memoria check ./src --verbose
npx in-memoria setup --interactive npx in-memoria learn ./src npx in-memoria check ./src --verbose

Terminal 2: Keep intelligence fresh

终端2:保持智能更新

npx in-memoria watch ./src
npx in-memoria watch ./src

Terminal 3: Expose to agents

终端3:向Agent提供服务

npx in-memoria server
npx in-memoria server

Now agents (Claude, Copilot, etc.) have persistent codebase context

现在Agent(Claude、Copilot等)即可获取持久化代码库上下文


See [GitHub](https://github.com/pi22by7/In-Memoria) for full API docs and agent integration examples.

完整API文档及Agent集成示例请查看[GitHub](https://github.com/pi22by7/In-Memoria)。