layermap 0.1.35 → 0.1.36
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/analyzers/project-map-java/java-map.jar +0 -0
- package/dist/cli.mjs +25 -27
- package/package.json +1 -1
- package/pi/layermap.mjs +35 -10
|
Binary file
|
package/dist/cli.mjs
CHANGED
|
@@ -12,7 +12,6 @@ import path16 from "node:path";
|
|
|
12
12
|
import { parseArgs } from "node:util";
|
|
13
13
|
|
|
14
14
|
// src/agent/environment.ts
|
|
15
|
-
import { execFile } from "node:child_process";
|
|
16
15
|
import { createHash as createHash6 } from "node:crypto";
|
|
17
16
|
import { existsSync as existsSync6, readFileSync as readFileSync5 } from "node:fs";
|
|
18
17
|
import { mkdir, readdir, readFile as readFile2, rename, rm, stat, utimes, writeFile } from "node:fs/promises";
|
|
@@ -21,20 +20,6 @@ import { homedir } from "node:os";
|
|
|
21
20
|
import path13 from "node:path";
|
|
22
21
|
import { fileURLToPath } from "node:url";
|
|
23
22
|
|
|
24
|
-
// src/layermap.ts
|
|
25
|
-
import { createHash as createHash5, randomUUID as randomUUID2 } from "node:crypto";
|
|
26
|
-
import { mkdirSync, statSync } from "node:fs";
|
|
27
|
-
import { lstat as lstat3, realpath as realpath2 } from "node:fs/promises";
|
|
28
|
-
import path12 from "node:path";
|
|
29
|
-
import { DatabaseSync } from "@photostructure/sqlite";
|
|
30
|
-
|
|
31
|
-
// src/capture-policy.ts
|
|
32
|
-
import path3 from "node:path";
|
|
33
|
-
|
|
34
|
-
// src/file-universe.ts
|
|
35
|
-
import { lstat } from "node:fs/promises";
|
|
36
|
-
import path2 from "node:path";
|
|
37
|
-
|
|
38
23
|
// src/git-runner.ts
|
|
39
24
|
import { spawn } from "node:child_process";
|
|
40
25
|
|
|
@@ -301,7 +286,19 @@ var GitRunner = class {
|
|
|
301
286
|
}
|
|
302
287
|
};
|
|
303
288
|
|
|
289
|
+
// src/layermap.ts
|
|
290
|
+
import { createHash as createHash5, randomUUID as randomUUID2 } from "node:crypto";
|
|
291
|
+
import { mkdirSync, statSync } from "node:fs";
|
|
292
|
+
import { lstat as lstat3, realpath as realpath2 } from "node:fs/promises";
|
|
293
|
+
import path12 from "node:path";
|
|
294
|
+
import { DatabaseSync } from "@photostructure/sqlite";
|
|
295
|
+
|
|
296
|
+
// src/capture-policy.ts
|
|
297
|
+
import path3 from "node:path";
|
|
298
|
+
|
|
304
299
|
// src/file-universe.ts
|
|
300
|
+
import { lstat } from "node:fs/promises";
|
|
301
|
+
import path2 from "node:path";
|
|
305
302
|
var FILE_UNIVERSE_ARGS = Object.freeze([
|
|
306
303
|
"ls-files",
|
|
307
304
|
"-z",
|
|
@@ -24943,16 +24940,17 @@ var cacheDirectory = (env = process.env) => {
|
|
|
24943
24940
|
);
|
|
24944
24941
|
return path13.join(env.XDG_CACHE_HOME || path13.join(homedir(), ".cache"), "layermap");
|
|
24945
24942
|
};
|
|
24946
|
-
var projectDirectory = (directory) =>
|
|
24947
|
-
|
|
24948
|
-
"
|
|
24949
|
-
|
|
24950
|
-
|
|
24951
|
-
|
|
24952
|
-
|
|
24953
|
-
|
|
24954
|
-
|
|
24955
|
-
|
|
24943
|
+
var projectDirectory = async (directory) => {
|
|
24944
|
+
try {
|
|
24945
|
+
const { stdout } = await new GitRunner().run(["rev-parse", "--show-toplevel"], {
|
|
24946
|
+
cwd: directory,
|
|
24947
|
+
timeoutMs: 1e4
|
|
24948
|
+
});
|
|
24949
|
+
return { directory: stdout.toString().trim(), git: true };
|
|
24950
|
+
} catch {
|
|
24951
|
+
return { directory: path13.resolve(directory), git: false };
|
|
24952
|
+
}
|
|
24953
|
+
};
|
|
24956
24954
|
var relativeTo = (directory, value) => Object.fromEntries(
|
|
24957
24955
|
Object.entries(value).map(([language, resources]) => [
|
|
24958
24956
|
language,
|
|
@@ -25553,7 +25551,7 @@ ${text}` : text
|
|
|
25553
25551
|
}
|
|
25554
25552
|
|
|
25555
25553
|
// src/agent/setup.ts
|
|
25556
|
-
import { execFile
|
|
25554
|
+
import { execFile } from "node:child_process";
|
|
25557
25555
|
import { existsSync as existsSync8 } from "node:fs";
|
|
25558
25556
|
import { mkdir as mkdir2, readFile as readFile3, rename as rename2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
25559
25557
|
import { homedir as homedir2 } from "node:os";
|
|
@@ -25583,7 +25581,7 @@ var mcpLaunchCommand = (env = process.env, published = existsSync8(PUBLISHED_LAU
|
|
|
25583
25581
|
};
|
|
25584
25582
|
var run = (command, args, env) => new Promise((resolve) => {
|
|
25585
25583
|
const invocation = commandInvocation(command, args, env);
|
|
25586
|
-
|
|
25584
|
+
execFile(
|
|
25587
25585
|
invocation.file,
|
|
25588
25586
|
invocation.args,
|
|
25589
25587
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "layermap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.36",
|
|
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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated by scripts/plugins.ts from scripts/pi-extension.mjs.
|
|
2
2
|
// scripts/pi-extension.mjs
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
|
-
import
|
|
4
|
+
import path3 from "node:path";
|
|
5
5
|
import { createInterface } from "node:readline";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { Type } from "typebox";
|
|
@@ -174,18 +174,35 @@ function checkedRepository(result, depth = 0) {
|
|
|
174
174
|
return void 0;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
// src/platform.ts
|
|
178
|
+
import { existsSync } from "node:fs";
|
|
179
|
+
import path2 from "node:path";
|
|
180
|
+
var executableName = (name, platform = process.platform) => platform === "win32" ? `${name}.exe` : name;
|
|
181
|
+
var searchPath = (env) => env.PATH ?? Object.entries(env).find(([name]) => name.toUpperCase() === "PATH")?.[1] ?? "";
|
|
182
|
+
function findOnPath(files, env, platform) {
|
|
183
|
+
const join = platform === "win32" ? path2.win32.join : path2.posix.join;
|
|
184
|
+
for (const directory of searchPath(env).split(platform === "win32" ? ";" : ":"))
|
|
185
|
+
for (const file of files)
|
|
186
|
+
if (directory && existsSync(join(directory, file))) return join(directory, file);
|
|
187
|
+
return void 0;
|
|
188
|
+
}
|
|
189
|
+
var findExecutable = (name, env = process.env, platform = process.platform) => findOnPath([executableName(name, platform)], env, platform);
|
|
190
|
+
|
|
177
191
|
// scripts/pi-extension.mjs
|
|
178
192
|
var CHECK_TOOL = "project_check_changes";
|
|
179
|
-
var CLI =
|
|
193
|
+
var CLI = path3.join(path3.dirname(fileURLToPath(import.meta.url)), "..", "dist", "cli.mjs");
|
|
180
194
|
var READS = /* @__PURE__ */ new Set(["read", "grep", "find", "ls"]);
|
|
181
195
|
var WRITES = /* @__PURE__ */ new Set(["edit", "write"]);
|
|
182
196
|
var PATCH = "apply_patch";
|
|
183
197
|
var PATCH_FILES = /^\*\*\* (?:(?:Add|Update|Delete) File|Move to): (.+)$/gm;
|
|
198
|
+
var NODE = process.versions.bun ? findExecutable("node") : process.execPath;
|
|
199
|
+
var START_TIMEOUT_MS = 3e4;
|
|
184
200
|
var MapServer = class {
|
|
185
201
|
constructor(cwd) {
|
|
202
|
+
if (!NODE) throw new Error("The server runs on Node, and none is on PATH.");
|
|
186
203
|
this.pending = /* @__PURE__ */ new Map();
|
|
187
204
|
this.next = 1;
|
|
188
|
-
this.child = spawn(
|
|
205
|
+
this.child = spawn(NODE, [CLI, "mcp"], {
|
|
189
206
|
cwd,
|
|
190
207
|
stdio: ["pipe", "pipe", "ignore"],
|
|
191
208
|
windowsHide: true
|
|
@@ -234,11 +251,19 @@ var MapServer = class {
|
|
|
234
251
|
});
|
|
235
252
|
}
|
|
236
253
|
async start(version) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
254
|
+
const timer = setTimeout(() => {
|
|
255
|
+
this.fail(new Error(`The server did not answer within ${START_TIMEOUT_MS / 1e3} seconds.`));
|
|
256
|
+
this.child.kill();
|
|
257
|
+
}, START_TIMEOUT_MS);
|
|
258
|
+
try {
|
|
259
|
+
await this.request("initialize", {
|
|
260
|
+
protocolVersion: "2025-06-18",
|
|
261
|
+
capabilities: {},
|
|
262
|
+
clientInfo: { name: "layermap-pi", version }
|
|
263
|
+
});
|
|
264
|
+
} finally {
|
|
265
|
+
clearTimeout(timer);
|
|
266
|
+
}
|
|
242
267
|
this.send({ method: "notifications/initialized" });
|
|
243
268
|
return (await this.request("tools/list", {})).tools;
|
|
244
269
|
}
|
|
@@ -268,7 +293,7 @@ function layermap(pi) {
|
|
|
268
293
|
if (server && !server.dead) return server;
|
|
269
294
|
starting ??= (async () => {
|
|
270
295
|
const next = new MapServer(cwd);
|
|
271
|
-
const tools = await next.start("0.1.
|
|
296
|
+
const tools = await next.start("0.1.36");
|
|
272
297
|
for (const tool of tools) {
|
|
273
298
|
if (registered.has(tool.name)) continue;
|
|
274
299
|
registered.add(tool.name);
|
|
@@ -322,7 +347,7 @@ function layermap(pi) {
|
|
|
322
347
|
if (!cwd) return;
|
|
323
348
|
const before = running.get(event.toolCallId);
|
|
324
349
|
running.delete(event.toolCallId);
|
|
325
|
-
const files = before ? changedFiles(before, await fileStates(Object.keys(before))) : event.isError ? [] : namedFiles(event).map((file) =>
|
|
350
|
+
const files = before ? changedFiles(before, await fileStates(Object.keys(before))) : event.isError ? [] : namedFiles(event).map((file) => path3.resolve(cwd, file));
|
|
326
351
|
changes.push(...await codeEdits(files));
|
|
327
352
|
});
|
|
328
353
|
pi.on("agent_before_settle", async (event) => {
|