代理格点:用 Markdown 编写的代码库知识图谱
Lat.md: Agent Lattice: a knowledge graph for your codebase, written in Markdown

原始链接: https://github.com/1st1/lat.md

## Lat:代码库的知识图谱 随着代码库的增长,维护单一的知识共享文档(如 `AGENTS.md`)变得不可持续。**Lat** 通过将项目的知识转化为可扩展的、互连的图谱来解决这个问题,该图谱由 `lat.md/` 目录中的 markdown 文件构建而成。 Lat 使用 **[[wiki 链接]]** 连接 markdown *内部* 的概念,并使用代码中的 **`// @lat:` 注释** 链接 *到* 这些概念。`lat check` 命令确保代码和文档之间的一致性。 **主要特性:** * **可扩展性:** 将知识分解为易于管理的文件。 * **交叉引用:** 轻松导航相关概念。 * **同步:** 自动验证链接和代码引用。 * **可搜索性:** 通过嵌入向量实现精确、模糊和语义搜索(需要 OpenAI 或 Vercel AI 密钥)。 * **Agent 友好:** 易于人类阅读,并可被 AI agent 查询。 使用 `lat init` 开始,搭建目录结构,然后用 markdown 文件填充。Lat 需要 Node.js 22+ 和 pnpm。

## 代码库知识图谱:Agent Lattice Agent Lattice (lat.md) 是一种新工具,旨在改进 AI 代理与代码的交互方式。它使用 Markdown 文件为项目创建知识图谱,为代理提供了一种结构化的方式来理解和导航代码库,超越简单的文本搜索。 核心思想是摆脱大型 `agents.md` 文件,而是为代理提供工具来搜索、遍历和*维护*更有组织的知识库。这可以更快地理解复杂的逻辑,特别是跨多个文件编码的细节。 主要功能包括将 Markdown 部分链接到特定的代码元素,通过反向链接强制执行测试覆盖率,并可能通过 CI/CD 钩子自动更新。创建者正在进行基准测试以证明性能改进,初步测试表明编码会话更快,代码审查也得到改善。 虽然类似于文档或 RAG 方法,但 lat.md 侧重于公共和私有实现细节,并旨在由代理*自身*主动管理,而不仅仅是人类。它旨在解决基于代理的开发工作流中的上下文管理和知识压缩挑战。
相关文章

原文

lat.md

CI npm

A knowledge graph for your codebase, written in markdown.

AGENTS.md doesn't scale. A single flat file can describe a small project, but as a codebase grows, maintaining one monolithic document becomes impractical. Key design decisions get buried, business logic goes undocumented, and agents hallucinate context they should be able to look up.

Compress the knowledge about your program domain into a graph — a set of interconnected markdown files that live in a lat.md/ directory at the root of your project. Sections link to each other with [[wiki links]], source files link back with // @lat: comments, and lat check ensures nothing drifts out of sync.

The result is a structured knowledge base that:

  • 📈 Scales — split knowledge across as many files and sections as you need
  • 🔗 Cross-references — wiki links ([[cli#search#Indexing]]) connect concepts into a navigable graph
  • Stays in synclat check validates that all links resolve and that required code references exist
  • 🔍 Is searchable — exact, fuzzy, and semantic (vector) search across all sections
  • 🤝 Works for humans and machines — readable in any editor (or Obsidian), queryable by agents via the lat CLI

Then run lat init in the repo you want to use lat in.

Run lat init to scaffold a lat.md/ directory, then write markdown files describing your architecture, business logic, test specs — whatever matters. Link between sections using [[file#Section#Subsection]] syntax. Link to source code symbols with [[src/auth.ts#validateToken]]. Annotate source code with // @lat: [[section-id]] (or # @lat: [[section-id]] in Python) comments to tie implementation back to concepts.

my-project/
├── lat.md/
│   ├── architecture.md    # system design, key decisions
│   ├── auth.md            # authentication & authorization logic
│   └── tests.md           # test specs (require-code-mention: true)
├── src/
│   ├── auth.ts            # // @lat: [[auth#OAuth Flow]]
│   └── server.ts          # // @lat: [[architecture#Request Pipeline]]
└── ...
lat init                        # scaffold a lat.md/ directory
lat check                       # validate all wiki links and code refs
lat locate "OAuth Flow"         # find sections by name (exact, fuzzy)
lat section "auth#OAuth Flow"   # show a section with its links and refs
lat refs "auth#OAuth Flow"      # find what references a section
lat search "how do we auth?"    # semantic search via embeddings
lat expand "fix [[OAuth Flow]]" # expand [[refs]] in a prompt for agents
lat mcp                         # start MCP server for editor integration

Semantic search (lat search) requires an OpenAI (sk-...) or Vercel AI Gateway (vck_...) API key. The key is resolved in order:

  1. LAT_LLM_KEY env var — direct value
  2. LAT_LLM_KEY_FILE env var — path to a file containing the key
  3. LAT_LLM_KEY_HELPER env var — shell command that prints the key (10s timeout)
  4. Config file — saved by lat init. Run lat config to see its location.

Requires Node.js 22+ and pnpm.

pnpm install
pnpm build
pnpm test
联系我们 contact @ memedata.com