LayerMap

io.github.coffeecoprojectv0.1.4更新于 Oct 5, 2026

Call graph for coding agents: callers up to HTTP routes, callees and usages for TS, Go, Python, Java

已验证STDIO仅桌面Developer ToolsKnowledge & Memory

概览

AI 生成的概览

LayerMap 为编码代理提供代码仓库的只读调用图,可沿调用链向上追溯到 HTTP 路由,并分析 TypeScript、JavaScript、Go、Python 和 Java 的调用方与被调用方。

功能
LayerMap 在本地为代码库建立映射,并提供三个只读工具:project_explore_map 用于查看目录、文件或声明的调用方与被调用方(direction 为 INCOMING 或 OUTGOING,depth 最多 8 层),project_search_map 按名称、路径或文档中的词查找声明,project_find_references 查找某个声明的所有使用位置。调用关系由各语言自身的编译器或类型检查器解析,因此接口、基类、模板和装饰器调用都能按编译器的解析结果呈现。映射在每次调用时增量更新,并缓存在仓库之外。
适用场景
当代理需要在代码仓库中回答影响范围问题(例如某处改动会影响哪些 HTTP 路由或处理函数)而不想进行大量分散搜索时,适合使用。适用于重视编译器级调用方与被调用方准确性的 TypeScript、JavaScript、Go、Python 和 Java 项目。
运行要求
通过 npx(npm 包 layermap)以 stdio 在本地运行。需要 Node.js 22.22 或更高版本、macOS 或 Linux(x64 或 arm64)以及一个 Git 仓库;Java 项目还需要 JDK 21 或更高版本。未声明账号、API 密钥或环境变量;可选环境变量 LAYERMAP_CACHE 用于指定缓存位置。
安装前请注意
这些工具是只读的,README 说明 LayerMap 完全在本机运行且不向任何地方发送数据。安装命令可能会注册该服务器、允许其只读工具无需确认即可运行,并向代理的指令文件添加一句话;团队使用可用 --scope project,撤销可用 remove 命令。大型仓库首次建立映射可能需要数分钟。

安装

在 SourceWeft 中

  1. 打开 控制台中的 LayerMap,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

[LayerMap]

LayerMap

English · 中文

[npm] [License]

[Claude Code asks which HTTP endpoints changing Storage.MarkFeedAsRead affects; one LayerMap call returns all four callers with their routes]

A real Claude Code session on Miniflux, replayed: one map call finds every endpoint, then the agent confirms them in source.

A layered map of your codebase for coding agents. LayerMap gives Claude Code, Codex, DeepSeek Harness and other MCP clients three read-only tools that answer, in one call, what an agent otherwise works out with dozens of searches:

  • What calls this, and what does changing it affect? Callers traced up to 8 levels, to the HTTP routes, handlers, jobs and commands they start from.
  • What does it call? Callees down to 8 levels.
  • What is here? Modules, each file's declarations, and every usage of a symbol.

It maps TypeScript, JavaScript, Go, Python and Java with each language's own compiler, so calls through interfaces, base classes, templates and decorators resolve as the compiler resolves them, including the ones text search misses.

Example

In Miniflux, one call on Storage.MarkFeedAsRead finds all four ways a request reaches it, each with its route:

DECLARATION internal/storage/entry.go: Storage.MarkFeedAsRead m656-680 exported  ← called by internal/api/feed.go: handler.markFeedAsRead m140-155 @149  ← called by internal/fever/handler.go: handler.handleWriteFeeds m492-519 @508  ← called by internal/googlereader/handler.go: handler.markAllAsReadHandler m1261-1338 @1311  ← called by internal/ui/feed_mark_as_read.go: handler.markFeedAsRead m14-30 @24[1] internal/api/feed.go: handler.markFeedAsRead m140-155  ← used as value by internal/api/api.go: Serve f25-84 @61 "/feeds/{feedID}/mark-all-as-read"[1] internal/googlereader/handler.go: handler.markAllAsReadHandler m1261-1338  ← used as value by internal/googlereader/handler.go: Serve f44-64 @62 "/mark-all-as-read"[1] internal/ui/feed_mark_as_read.go: handler.markFeedAsRead m14-30  ← used as value by internal/ui/ui.go: Serve f18-180 @77 "/feed/{feedID}/mark-all-as-read"… (the Fever API, then on down to main.go: main)

m and f mark methods and functions with their lines; @ is the line of the call, and the quoted path is the route it is registered under.

Results

Impact questions ("which HTTP endpoints does changing this affect?") on public Go, Python and Java projects, graded blind against truth sets cross-checked with each language's own toolchain:

With LayerMapWithout
Endpoints found, at most 15 requests (gpt-5.5, 6 tasks × 3 runs)97.9%58.8%
Used unprompted by Claude Code / Codex (plugin installed)6 of 6 / 6 of 6—
Endpoints found, no request limit (Claude Code / Codex)99.3% / 98.0%99.0% / 98.6%
Cost, no request limit (Claude Code in USD / Codex in input tokens)−32% / −55%
Time, no request limit+24% / +17%

With a tight budget, the map finds far more of the affected code, at about 24% more tokens. With no limit, both agents get there either way. The map makes the run cheaper, and the agents explore more widely, which takes longer. These are small samples on tasks written by LayerMap's authors. The report has the setup, the published tasks and the limitations.

How LayerMap differs

Other tools give agents part of this. LayerMap combines compiler accuracy with whole-chain traces in one local map:

Tree-sitter code graphs (codegraph, GitNexus, …)Language servers and IDEs (Claude Code's LSP tool, Serena, JetBrains)Embedding search (Claude Context, Augment)LayerMap
How calls are linkedMatched by names, imports and framework rules, often with confidence scoresThe compiler's own resolutionNot linked; similar code is retrievedResolved by each language's compiler or type checker
Callers traced to routes and handlersIn several tools, at varying depthOne level per request (JetBrains: 5 by default)—Up to 8 levels in one call
Kept as a mapYes, with file watchingNo, answered live by a running serverAn index of code chunksYes, brought up to date on every call
Runs on your machineYes; some send anonymous telemetryYesUsually with cloud embeddingsYes, and sends nothing

Another tool fits better if you need:

  • more languages, since tree-sitter graphs cover 30 or more;
  • Windows;
  • renaming and refactoring, from language servers;
  • search by meaning, from embedding search;
  • search across many repositories, with Sourcegraph.

Install

Claude Code

/plugin marketplace add coffeecoproject/layermap/plugin install layermap@layermap

Codex

codex plugin marketplace add coffeecoproject/layermapcodex plugin add layermap@layermap

DeepSeek Harness

npx layermap setup dsh

This adds LayerMap to every dsh profile. Each session maps the project dsh was started in, and npx layermap remove dsh undoes it.

In every agent, start a new session in a Git repository and ask as usual. LayerMap tells the agent when the map helps. On first launch, npx downloads the pinned layermap package from npm.

Claude Code asks once before each map tool runs in a project. Choose "don't ask again", or run npx layermap allow claude to allow the plugin's read-only tools everywhere.

Without plugins: run npx layermap setup claude or npx layermap setup codex. Setup does three things:

  • registers the server;
  • lets its read-only tools run without a prompt;
  • adds one marked sentence to the agent's instructions file.

Use --scope project to set it up for a whole team, and npx layermap remove … to undo it. For any other MCP client, run npx -y layermap mcp as a stdio server in the repository.

Requirements:

  • Node.js 22.22 or later.
  • macOS or Linux (x64 or arm64).
  • A Git repository.
  • For Java projects, a JDK 21 or later.

How it works

The first call in a repository builds its map: seconds for a small project, a few minutes for a large one. Later calls re-analyze only what changed, so the map always matches the working tree.

Maps stay in your user cache (~/Library/Caches/layermap, ~/.cache/layermap or LAYERMAP_CACHE), never in the repository. LayerMap runs entirely on your machine and sends nothing anywhere (privacy, security).

ToolUse
project_explore_mapA directory, a file, or a declaration's callers and callees (direction INCOMING or OUTGOING, depth up to 8).
project_search_mapFind declarations by words in their names, paths or documentation.
project_find_referencesEvery usage of a declaration, compiled from current source.

The same from the command line:

npx layermap explore src/api/users.ts --name createUser --direction INCOMING --depth 8npx layermap search "invoice total"npx layermap refs src/billing/tax.ts calculateTax

FAQ

How long does the first map take? On a recent Mac:

  • Miniflux (400 Go files): about 3 s.
  • Polar's server (1,900 Python files): about a minute.
  • Conductor (1,500 Java and 1,300 TypeScript files): under two minutes.

What can't it see? Calls the compiler cannot resolve statically: dependency injection, unknown framework routing, reflection and computed names. The tools say where a trace stops, and a missing relationship does not prove absence.

Windows? Not yet.

How do I remove it?

  • Claude Code: /plugin uninstall layermap@layermap.
  • Codex: codex plugin remove layermap@layermap.
  • Then delete the cache directory.

Development

You need pnpm, Go 1.24 and a JDK 21+. A missing toolchain leaves its language unanalyzed.

Run pnpm install. On the first install pnpm asks which dependencies may run build scripts; allow esbuild only, since the SQLite package ships prebuilt binaries:

pnpm approve-builds esbuild '!@photostructure/sqlite'

Then run pnpm test, pnpm typecheck or pnpm lint.

pnpm package builds the npm package.

License

Apache-2.0. See LICENSE and NOTICE.

来源:README.md,提交 82b8dcf

工具

0
工具元数据尚未被收录。

版本历史

1
  1. v0.1.4最新Oct 5, 2026