layermap 0.1.54 → 0.1.55

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
@@ -210,6 +210,11 @@ Maps stay in your user cache (`~/Library/Caches/layermap`, `~/.cache/layermap` o
210
210
  nothing anywhere ([privacy](https://github.com/coffeecoproject/layermap/blob/main/PRIVACY.md),
211
211
  [security](https://github.com/coffeecoproject/layermap/blob/main/SECURITY.md)).
212
212
 
213
+ The versions of LayerMap your agents start are installed in the same user cache directory.
214
+ `LAYERMAP_CACHE` moves the maps and nothing else: a program that keeps the maps of its own tests in
215
+ a directory apart still runs the versions already installed. `LAYERMAP_HOME` names another
216
+ directory for the versions.
217
+
213
218
  The MCP server tells a client that asks for progress which step a long check is on, and keeps a
214
219
  line for each tool call in `logs/calls.jsonl` in the cache: the tool, its arguments, the
215
220
  repository, how long each step took and the first line of the answer, to review how the tools are
@@ -238,7 +243,7 @@ npx layermap imports --json # every import of the project as it is
238
243
  Codex's commands, a terminal and Git hooks have none, so a program run there that calls `layermap`,
239
244
  such as one choosing tests from `layermap check --json`, does not find it. Run `npx layermap setup
240
245
  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
246
+ installed on your machine, where each agent's plugin installs the version it starts. It follows
242
247
  the plugins as they update and uses no network; where `~/.local/bin` comes before the plugin's
243
248
  directory on PATH, Claude's shell commands run it too. A file of that name that is not LayerMap's
244
249
  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
  }
@@ -27442,7 +27442,7 @@ var END = "<!-- layermap:end -->";
27442
27442
  var launcherScript = (template, version2, args = '["mcp"]') => `// Generated from scripts/launcher.mjs.
27443
27443
  ${template.replace("__VERSION__", JSON.stringify(version2)).replace("__ARGUMENTS__", args)}`;
27444
27444
  var PUBLISHED_LAUNCHER = path19.join(packageRoot, "dist", "launcher.mjs");
27445
- var launcherFile = (env = process.env) => path19.join(cacheDirectory(env), "server.mjs");
27445
+ var launcherFile = (env = process.env) => path19.join(installDirectory(env), "server.mjs");
27446
27446
  var mcpLaunchCommand = (env = process.env, published = existsSync8(PUBLISHED_LAUNCHER)) => {
27447
27447
  if (published) return ["node", launcherFile(env)];
27448
27448
  const script = path19.resolve(process.argv[1] ?? "");
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.55",
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.55");
297
297
  for (const tool of tools) {
298
298
  if (registered.has(tool.name)) continue;
299
299
  registered.add(tool.name);