layermap 0.1.54 → 0.1.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,7 +17,7 @@
17
17
  <p align="center"><sub>A real Claude Code session on <a href="https://github.com/miniflux/v2">Miniflux</a>, replayed: one map call finds every endpoint, then the agent confirms them in source.</sub></p>
18
18
 
19
19
  A layered map of your codebase for coding agents. LayerMap gives Claude Code, Codex, CodeBuddy
20
- Code, Pi, DeepSeek Harness and other MCP clients read-only tools that answer, in one call, what an agent otherwise works out
20
+ Code, Pi, DeepSeek Harness, Antigravity and other MCP clients read-only tools that answer, in one call, what an agent otherwise works out
21
21
  with dozens of searches:
22
22
 
23
23
  - **What calls this, and what does changing it affect?** Callers traced up to 8 levels, to the
@@ -150,6 +150,18 @@ npx layermap setup dsh
150
150
  This adds LayerMap to every dsh profile. Each session maps the project dsh was started in, and
151
151
  `npx layermap remove dsh` undoes it.
152
152
 
153
+ **Antigravity**
154
+
155
+ ```
156
+ npx layermap setup antigravity
157
+ ```
158
+
159
+ Antigravity has no command that installs a plugin, so this writes LayerMap's plugin into
160
+ `~/.gemini/config/plugins/layermap`, which Antigravity loads by itself; `npx layermap remove
161
+ antigravity` deletes it. Antigravity asks before each map tool's first use; choose to always allow
162
+ it. It starts the server outside the project, so the plugin's rule tells the agent to give absolute
163
+ paths.
164
+
153
165
  In every agent, start a new session in a Git repository and ask as usual. LayerMap tells the agent
154
166
  when the map helps. A session started in a folder holding several repositories, or one that moves
155
167
  to another repository, works too: each map tool call maps the repository its path names. The first
@@ -180,7 +192,7 @@ CodeBuddy Code the plugin asks the agent once, before it finishes, to run this c
180
192
  and has not checked since, whether through its edit tools or shell commands, which count for the code files they name
181
193
  (changes another session makes in the same work tree do not count); the Pi extension does the same after the agent's own
182
194
  edits. Set `LAYERMAP_STOP_CHECK=0` to turn that
183
- off. Codex and DeepSeek Harness are told to run it.
195
+ off. Codex, DeepSeek Harness and Antigravity are told to run it.
184
196
 
185
197
  **Without plugins:** run `npx layermap setup claude` or `npx layermap setup codex`. Setup does three
186
198
  things:
@@ -210,6 +222,11 @@ Maps stay in your user cache (`~/Library/Caches/layermap`, `~/.cache/layermap` o
210
222
  nothing anywhere ([privacy](https://github.com/coffeecoproject/layermap/blob/main/PRIVACY.md),
211
223
  [security](https://github.com/coffeecoproject/layermap/blob/main/SECURITY.md)).
212
224
 
225
+ The versions of LayerMap your agents start are installed in the same user cache directory.
226
+ `LAYERMAP_CACHE` moves the maps and nothing else: a program that keeps the maps of its own tests in
227
+ a directory apart still runs the versions already installed. `LAYERMAP_HOME` names another
228
+ directory for the versions.
229
+
213
230
  The MCP server tells a client that asks for progress which step a long check is on, and keeps a
214
231
  line for each tool call in `logs/calls.jsonl` in the cache: the tool, its arguments, the
215
232
  repository, how long each step took and the first line of the answer, to review how the tools are
@@ -238,7 +255,7 @@ npx layermap imports --json # every import of the project as it is
238
255
  Codex's commands, a terminal and Git hooks have none, so a program run there that calls `layermap`,
239
256
  such as one choosing tests from `layermap check --json`, does not find it. Run `npx layermap setup
240
257
  command` once: it writes a `layermap` command into `~/.local/bin`, which runs the newest version
241
- installed in LayerMap's cache, where each agent's plugin installs the version it starts. It follows
258
+ installed on your machine, where each agent's plugin installs the version it starts. It follows
242
259
  the plugins as they update and uses no network; where `~/.local/bin` comes before the plugin's
243
260
  directory on PATH, Claude's shell commands run it too. A file of that name that is not LayerMap's
244
261
  is left as it is. `npx layermap remove command` deletes it. macOS and Linux only.
package/dist/cli.mjs CHANGED
@@ -26634,8 +26634,7 @@ var packageRoot = (() => {
26634
26634
  }
26635
26635
  })();
26636
26636
  var packageVersion = async () => JSON.parse(await readFile5(path16.join(packageRoot, "package.json"), "utf8")).version;
26637
- var cacheDirectory = (env = process.env) => {
26638
- if (env.LAYERMAP_CACHE) return path16.resolve(env.LAYERMAP_CACHE);
26637
+ var userCache = (env) => {
26639
26638
  if (process.platform === "darwin") return path16.join(homedir(), "Library", "Caches", "layermap");
26640
26639
  if (process.platform === "win32")
26641
26640
  return path16.join(
@@ -26645,6 +26644,8 @@ var cacheDirectory = (env = process.env) => {
26645
26644
  );
26646
26645
  return path16.join(env.XDG_CACHE_HOME || path16.join(homedir(), ".cache"), "layermap");
26647
26646
  };
26647
+ var cacheDirectory = (env = process.env) => env.LAYERMAP_CACHE ? path16.resolve(env.LAYERMAP_CACHE) : userCache(env);
26648
+ var installDirectory = (env = process.env) => env.LAYERMAP_HOME ? path16.resolve(env.LAYERMAP_HOME) : userCache(env);
26648
26649
  var projectDirectory = async (directory) => {
26649
26650
  try {
26650
26651
  const { stdout } = await new GitRunner().run(["rev-parse", "--show-toplevel"], {
@@ -26759,7 +26760,7 @@ async function pruneCache(cache, project, now = Date.now(), installed = packageR
26759
26760
  await rm(path16.join(builds, name), { recursive: true, force: true });
26760
26761
  }
26761
26762
  const own = path16.dirname(path16.dirname(installed));
26762
- const versions = path16.join(cache, "versions");
26763
+ const versions = path16.join(installDirectory(env), "versions");
26763
26764
  const launched = path16.dirname(own) === versions;
26764
26765
  if (launched) await pruneVersions(versions, own, now);
26765
26766
  const npx = launched ? path16.join(
@@ -26812,9 +26813,9 @@ async function pruneNpxInstalls(npx, installed, now) {
26812
26813
 
26813
26814
  // src/agent/command.ts
26814
26815
  var MARK = "// LayerMap's command, written by `layermap setup command`.";
26815
- var commandScript = (cache) => `#!/usr/bin/env node
26816
+ var commandScript = (directory) => `#!/usr/bin/env node
26816
26817
  ${MARK}
26817
- // It runs the newest LayerMap version installed in LayerMap's cache, where each agent's LayerMap
26818
+ // It runs the newest LayerMap version installed in the directory below, where each agent's LayerMap
26818
26819
  // plugin installs the version it starts. \`layermap remove command\` deletes this file.
26819
26820
  if (typeof process.getBuiltinModule !== "function") {
26820
26821
  process.stderr.write("layermap: LayerMap needs Node.js 22.22 or later; this is " + process.version + "\\n");
@@ -26823,8 +26824,7 @@ if (typeof process.getBuiltinModule !== "function") {
26823
26824
  const fs = process.getBuiltinModule("node:fs");
26824
26825
  const path = process.getBuiltinModule("node:path");
26825
26826
  const { pathToFileURL } = process.getBuiltinModule("node:url");
26826
- const cache = process.env.LAYERMAP_CACHE ? path.resolve(process.env.LAYERMAP_CACHE) : ${JSON.stringify(cache)};
26827
- const versions = path.join(cache, "versions");
26827
+ const versions = path.join(${JSON.stringify(directory)}, "versions");
26828
26828
  const installed = (version) => path.join(versions, version, "node_modules", "layermap");
26829
26829
  // A version being installed is a directory named .<version>-\u2026, and has no manifest in place yet.
26830
26830
  const numbers = (version) => version.split(".").map(Number);
@@ -26878,13 +26878,13 @@ async function setupCommand(options) {
26878
26878
  log2(`write LayerMap's command to ${file2}`);
26879
26879
  if (options.dryRun) return true;
26880
26880
  await mkdir3(path17.dirname(file2), { recursive: true });
26881
- await writeFile2(`${file2}.${process.pid}`, commandScript(cacheDirectory(env)));
26881
+ await writeFile2(`${file2}.${process.pid}`, commandScript(installDirectory(env)));
26882
26882
  await chmod(`${file2}.${process.pid}`, 493);
26883
26883
  await rename3(`${file2}.${process.pid}`, file2);
26884
26884
  if (!(env.PATH ?? "").split(path17.delimiter).includes(path17.dirname(file2)))
26885
26885
  log2(`${path17.dirname(file2)} is not on this shell's PATH: add it for the command to be found.`);
26886
26886
  log2(
26887
- `Done. \`layermap\` runs the newest LayerMap version installed in ${path17.join(cacheDirectory(env), "versions")}, where each agent's LayerMap plugin installs the version it starts.`
26887
+ `Done. \`layermap\` runs the newest LayerMap version installed in ${path17.join(installDirectory(env), "versions")}, where each agent's LayerMap plugin installs the version it starts.`
26888
26888
  );
26889
26889
  return true;
26890
26890
  }
@@ -27002,6 +27002,7 @@ var mapToolDescriptions = (host) => {
27002
27002
 
27003
27003
  // src/agent/notes.ts
27004
27004
  var AGENT_MAP_NOTE = "The layermap MCP server is available here. When a task needs to know what calls a function, what a change could affect beyond the code you are editing, or where code is used, use its project_explore_map tool (direction INCOMING, depth up to 8) instead of grep, then confirm in source; a change confined to code you have read does not need it. When the edits are done, call its project_check_changes tool once before reporting the work done.";
27005
+ var antigravityMapNote = (server) => `${AGENT_MAP_NOTE} In Antigravity, call its tools through call_mcp_tool with ServerName ${server}. The server does not start in the project, so give every call an absolute path, and give project_check_changes the project's root as its path.`;
27005
27006
  var projectHeading = (project) => `Project ${project} (paths are relative to it)`;
27006
27007
 
27007
27008
  // src/agent/projects.ts
@@ -27434,6 +27435,9 @@ import { existsSync as existsSync8 } from "node:fs";
27434
27435
  import { mkdir as mkdir4, readFile as readFile7, rename as rename4, rm as rm3, writeFile as writeFile3 } from "node:fs/promises";
27435
27436
  import { homedir as homedir3 } from "node:os";
27436
27437
  import path19 from "node:path";
27438
+ var SETUP_AGENTS = ["claude", "codex", "dsh", "antigravity"];
27439
+ var REPOSITORY = "https://github.com/coffeecoproject/layermap";
27440
+ var PLUGIN_DESCRIPTION = "A layered map of your codebase for coding agents: what calls a function, what a change affects up to the HTTP routes, handlers and jobs, and what each module contains, for TypeScript, JavaScript, Go, Python and Java. Built and kept locally; read-only.";
27437
27441
  var SERVER = "layermap";
27438
27442
  var SETUP_RULE = `mcp__${SERVER}`;
27439
27443
  var PLUGIN_RULE = `mcp__plugin_${SERVER}_${SERVER}`;
@@ -27442,7 +27446,7 @@ var END = "<!-- layermap:end -->";
27442
27446
  var launcherScript = (template, version2, args = '["mcp"]') => `// Generated from scripts/launcher.mjs.
27443
27447
  ${template.replace("__VERSION__", JSON.stringify(version2)).replace("__ARGUMENTS__", args)}`;
27444
27448
  var PUBLISHED_LAUNCHER = path19.join(packageRoot, "dist", "launcher.mjs");
27445
- var launcherFile = (env = process.env) => path19.join(cacheDirectory(env), "server.mjs");
27449
+ var launcherFile = (env = process.env) => path19.join(installDirectory(env), "server.mjs");
27446
27450
  var mcpLaunchCommand = (env = process.env, published = existsSync8(PUBLISHED_LAUNCHER)) => {
27447
27451
  if (published) return ["node", launcherFile(env)];
27448
27452
  const script = path19.resolve(process.argv[1] ?? "");
@@ -27599,8 +27603,34 @@ async function removeDshPatch(file2) {
27599
27603
  await writeFile3(file2, content ? rest : `${rest}${rest.endsWith("\n") ? "" : "\n"}[]
27600
27604
  `);
27601
27605
  }
27606
+ var antigravityPlugin = (env = process.env) => path19.join(env.HOME || homedir3(), ".gemini", "config", "plugins", SERVER);
27607
+ var antigravityPluginFiles = (command, version2, note = true) => {
27608
+ const [program = "", ...args] = command;
27609
+ const json2 = (value) => `${JSON.stringify(value, null, 2)}
27610
+ `;
27611
+ return {
27612
+ "plugin.json": json2({
27613
+ name: SERVER,
27614
+ displayName: "LayerMap",
27615
+ version: version2,
27616
+ description: PLUGIN_DESCRIPTION,
27617
+ homepage: REPOSITORY,
27618
+ repository: REPOSITORY
27619
+ }),
27620
+ "mcp_config.json": json2({ mcpServers: { [SERVER]: { command: program, args } } }),
27621
+ ...note ? { [path19.join("rules", "AGENTS.md")]: `${antigravityMapNote(`${SERVER}_${SERVER}`)}
27622
+ ` } : {}
27623
+ };
27624
+ };
27602
27625
  var agentFiles = (options) => {
27603
27626
  const env = options.env ?? process.env;
27627
+ if (options.agent === "antigravity") {
27628
+ const plugin = antigravityPlugin(env);
27629
+ return {
27630
+ settings: path19.join(plugin, "mcp_config.json"),
27631
+ instructions: path19.join(plugin, "rules", "AGENTS.md")
27632
+ };
27633
+ }
27604
27634
  if (options.agent === "dsh") {
27605
27635
  const home = env.DSH_HOME || path19.join(homedir3(), ".dsh");
27606
27636
  return {
@@ -27654,6 +27684,28 @@ async function setupAgent(options) {
27654
27684
  await rename4(`${file2}.${process.pid}`, file2);
27655
27685
  };
27656
27686
  if (published) log2(`write the launcher of LayerMap ${options.version} to ${launcherFile(env)}`);
27687
+ if (options.agent === "antigravity") {
27688
+ if (options.scope !== "user") {
27689
+ log2("Antigravity loads LayerMap's plugin in every project; --scope does not apply.");
27690
+ return false;
27691
+ }
27692
+ const plugin = antigravityPlugin(env);
27693
+ log2(`write LayerMap's plugin for Antigravity to ${plugin}`);
27694
+ if (note) log2(`with a rule naming the map tools, ${instructions}`);
27695
+ if (options.dryRun) return true;
27696
+ await writeLauncher();
27697
+ await rm3(plugin, { recursive: true, force: true });
27698
+ for (const [name, content] of Object.entries(
27699
+ antigravityPluginFiles(command, options.version, note)
27700
+ )) {
27701
+ await mkdir4(path19.dirname(path19.join(plugin, name)), { recursive: true });
27702
+ await writeFile3(path19.join(plugin, name), content);
27703
+ }
27704
+ log2(
27705
+ `Done. Start a new Antigravity conversation; its map tools come from the ${SERVER}_${SERVER} server, and Antigravity asks before each one's first use.`
27706
+ );
27707
+ return true;
27708
+ }
27657
27709
  if (options.agent === "dsh") {
27658
27710
  if (options.scope !== "user") {
27659
27711
  log2("DeepSeek Harness is set up for all its profiles at once; --scope does not apply.");
@@ -27704,7 +27756,11 @@ async function setupAgent(options) {
27704
27756
  async function allowAgent(options) {
27705
27757
  if (options.agent !== "claude") {
27706
27758
  options.log(
27707
- options.agent === "codex" ? "The Codex plugin already runs LayerMap's read-only tools without a prompt." : "DeepSeek Harness runs MCP tools without a prompt."
27759
+ {
27760
+ codex: "The Codex plugin already runs LayerMap's read-only tools without a prompt.",
27761
+ dsh: "DeepSeek Harness runs MCP tools without a prompt.",
27762
+ antigravity: "Antigravity asks before each map tool's first use; choose to always allow it there."
27763
+ }[options.agent]
27708
27764
  );
27709
27765
  return true;
27710
27766
  }
@@ -27718,6 +27774,14 @@ async function allowAgent(options) {
27718
27774
  async function removeAgent(options) {
27719
27775
  const env = options.env ?? process.env;
27720
27776
  const { settings, instructions } = agentFiles(options);
27777
+ if (options.agent === "antigravity") {
27778
+ const plugin = antigravityPlugin(env);
27779
+ options.log(`remove LayerMap's plugin for Antigravity, ${plugin}`);
27780
+ if (options.dryRun) return true;
27781
+ await rm3(plugin, { recursive: true, force: true });
27782
+ options.log("Removed.");
27783
+ return true;
27784
+ }
27721
27785
  if (options.agent === "dsh") {
27722
27786
  options.log(
27723
27787
  `remove the ${SERVER} MCP server from ${settings} and its note from ${instructions}`
@@ -27743,10 +27807,10 @@ async function removeAgent(options) {
27743
27807
  var USAGE = `LayerMap \u2014 a layered map of a codebase for coding agents.
27744
27808
 
27745
27809
  Usage:
27746
- layermap setup claude|codex|dsh [--scope user|local] [--no-instructions] [--dry-run]
27810
+ layermap setup ${SETUP_AGENTS.join("|")} [--scope user|local] [--no-instructions] [--dry-run]
27747
27811
  layermap allow claude [--scope user|project|local] [--dry-run]
27748
27812
  let the plugin's read-only tools run without a prompt
27749
- layermap remove claude|codex|dsh [--scope user|project|local] [--dry-run]
27813
+ layermap remove ${SETUP_AGENTS.join("|")} [--scope user|project|local] [--dry-run]
27750
27814
  layermap setup command [--dry-run] put a layermap command in ~/.local/bin, for shells with no
27751
27815
  plugin's on their PATH (Codex's commands, a terminal): it
27752
27816
  runs the newest version the agents' plugins have installed
@@ -27841,7 +27905,7 @@ async function main(argv) {
27841
27905
  dryRun: values["dry-run"],
27842
27906
  log
27843
27907
  }) ? 0 : 1;
27844
- if (agent !== "claude" && agent !== "codex" && agent !== "dsh") return usage(1);
27908
+ if (!SETUP_AGENTS.includes(agent)) return usage(1);
27845
27909
  if (!["user", "project", "local"].includes(values.scope)) return usage(1);
27846
27910
  const done = await { setup: setupAgent, allow: allowAgent, remove: removeAgent }[command]({
27847
27911
  agent,
package/dist/launcher.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // Runs one LayerMap version in this process: its MCP server, or, for the layermap command of the
2
- // Claude Code plugin, its command line with the arguments given. The version is installed once into
3
- // LayerMap's cache, from where every later start runs without npm or a network. The agent starts
4
- // this in the project, which stays the working directory the server maps; npm runs in the cache,
2
+ // Claude Code plugin, its command line with the arguments given. The version is installed once on
3
+ // this machine, from where every later start runs without npm or a network. The agent starts this
4
+ // in the project, which stays the working directory the server maps; npm runs where it installs,
5
5
  // so the project's own npm settings and packages play no part in what gets installed.
6
6
  import { spawn } from "node:child_process";
7
7
  import {
@@ -20,16 +20,17 @@ import { pathToFileURL } from "node:url";
20
20
  const VERSION = __VERSION__;
21
21
  const ARGUMENTS = __ARGUMENTS__;
22
22
 
23
- // The same directory as cacheDirectory in src/agent/environment.ts.
23
+ // The same directory as installDirectory in src/agent/environment.ts: the user's cache, unless
24
+ // LAYERMAP_HOME names another. LAYERMAP_CACHE, which names where maps are kept, does not move it.
24
25
  const env = process.env;
25
- const cache = env.LAYERMAP_CACHE
26
- ? path.resolve(env.LAYERMAP_CACHE)
26
+ const directory = env.LAYERMAP_HOME
27
+ ? path.resolve(env.LAYERMAP_HOME)
27
28
  : process.platform === "darwin"
28
29
  ? path.join(homedir(), "Library", "Caches", "layermap")
29
30
  : process.platform === "win32"
30
31
  ? path.join(env.LOCALAPPDATA || path.join(homedir(), "AppData", "Local"), "layermap", "Cache")
31
32
  : path.join(env.XDG_CACHE_HOME || path.join(homedir(), ".cache"), "layermap");
32
- const versions = path.join(cache, "versions");
33
+ const versions = path.join(directory, "versions");
33
34
  const home = path.join(versions, VERSION);
34
35
  const installed = path.join(home, "node_modules", "layermap");
35
36
  const manifest = path.join(installed, "package.json");
@@ -94,7 +95,7 @@ async function install() {
94
95
 
95
96
  try {
96
97
  if (!existsSync(manifest)) await install();
97
- // LayerMap removes a version from its cache once nothing has started it for a week.
98
+ // LayerMap removes a version once nothing has started it for a week.
98
99
  writeFileSync(path.join(home, "last-used"), "");
99
100
  const entry = path.join(installed, JSON.parse(readFileSync(manifest, "utf8")).bin.layermap);
100
101
  process.argv = [process.argv[0], entry, ...ARGUMENTS];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "layermap",
3
- "version": "0.1.54",
3
+ "version": "0.1.56",
4
4
  "mcpName": "io.github.coffeecoproject/layermap",
5
5
  "description": "A layered map of a codebase for coding agents: directories, modules and call chains across TypeScript, JavaScript, Go, Python and Java.",
6
6
  "license": "Apache-2.0",
package/pi/layermap.mjs CHANGED
@@ -293,7 +293,7 @@ function layermap(pi) {
293
293
  if (server && !server.dead) return server;
294
294
  starting ??= (async () => {
295
295
  const next = new MapServer(cwd);
296
- const tools = await next.start("0.1.54");
296
+ const tools = await next.start("0.1.56");
297
297
  for (const tool of tools) {
298
298
  if (registered.has(tool.name)) continue;
299
299
  registered.add(tool.name);