layermap 0.1.2 → 0.1.3
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 +16 -6
- package/analyzers/project-map-java/java-map.jar +0 -0
- package/dist/cli.mjs +106 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
[](https://www.npmjs.com/package/layermap)
|
|
8
8
|
[](https://github.com/coffeecoproject/layermap/blob/main/LICENSE)
|
|
9
9
|
|
|
10
|
-
A layered map of your codebase for coding agents. LayerMap gives Claude Code, Codex
|
|
11
|
-
clients three read-only tools that answer, in one call, what an agent otherwise works out with
|
|
10
|
+
A layered map of your codebase for coding agents. LayerMap gives Claude Code, Codex, DeepSeek
|
|
11
|
+
Harness and other MCP clients three read-only tools that answer, in one call, what an agent otherwise works out with
|
|
12
12
|
dozens of searches:
|
|
13
13
|
|
|
14
14
|
- **What calls this, and what does changing it affect?** Callers traced up to 8 levels, to the
|
|
@@ -98,10 +98,20 @@ codex plugin marketplace add coffeecoproject/layermap
|
|
|
98
98
|
codex plugin add layermap@layermap
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
**DeepSeek Harness**
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
npx layermap setup dsh
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
This adds LayerMap to every dsh profile. Each session maps the project dsh was started in, and
|
|
108
|
+
`npx layermap remove dsh` undoes it.
|
|
109
|
+
|
|
110
|
+
In every agent, start a new session in a Git repository and ask as usual. LayerMap tells the agent
|
|
111
|
+
when the map helps. On first launch, npx downloads the pinned `layermap` package from npm.
|
|
112
|
+
|
|
113
|
+
Claude Code asks once before each map tool runs in a project. Choose "don't ask again", or run
|
|
114
|
+
`npx layermap allow claude` to allow the plugin's read-only tools everywhere.
|
|
105
115
|
|
|
106
116
|
**Without plugins:** run `npx layermap setup claude` or `npx layermap setup codex`. Setup does three
|
|
107
117
|
things:
|
|
Binary file
|
package/dist/cli.mjs
CHANGED
|
@@ -22321,9 +22321,12 @@ function serveMcp(options) {
|
|
|
22321
22321
|
opened ??= options.open();
|
|
22322
22322
|
return opened;
|
|
22323
22323
|
};
|
|
22324
|
+
const session = new AbortController();
|
|
22324
22325
|
let warm;
|
|
22325
22326
|
const warmUp = () => {
|
|
22326
|
-
warm ??= map2().then((layermap) => layermap.refresh(
|
|
22327
|
+
warm ??= map2().then((layermap) => layermap.refresh(session.signal)).catch((error51) => {
|
|
22328
|
+
if (!session.signal.aborted) log2(`LayerMap could not build the map: ${String(error51)}`);
|
|
22329
|
+
});
|
|
22327
22330
|
return warm;
|
|
22328
22331
|
};
|
|
22329
22332
|
const call = async (id2, params) => {
|
|
@@ -22428,6 +22431,7 @@ function serveMcp(options) {
|
|
|
22428
22431
|
}
|
|
22429
22432
|
});
|
|
22430
22433
|
lines.on("close", async () => {
|
|
22434
|
+
session.abort();
|
|
22431
22435
|
for (const controller of calls.values()) controller.abort();
|
|
22432
22436
|
if (opened) await (await opened.catch(() => void 0))?.close().catch(() => void 0);
|
|
22433
22437
|
resolve();
|
|
@@ -22438,7 +22442,7 @@ function serveMcp(options) {
|
|
|
22438
22442
|
// src/agent/setup.ts
|
|
22439
22443
|
import { execFile as execFile2 } from "node:child_process";
|
|
22440
22444
|
import { existsSync as existsSync5 } from "node:fs";
|
|
22441
|
-
import { mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
|
|
22445
|
+
import { mkdir as mkdir2, readFile as readFile2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
22442
22446
|
import { homedir as homedir2 } from "node:os";
|
|
22443
22447
|
import path9 from "node:path";
|
|
22444
22448
|
var SERVER = "layermap";
|
|
@@ -22523,7 +22527,9 @@ async function removeInstructionNote(file2) {
|
|
|
22523
22527
|
const end = text.indexOf(END);
|
|
22524
22528
|
if (start < 0 || end < start) return;
|
|
22525
22529
|
const before = text.slice(0, start).replace(/\n\n$/u, "\n");
|
|
22526
|
-
|
|
22530
|
+
const rest = `${before}${text.slice(end + END.length).replace(/^\n/u, "")}`;
|
|
22531
|
+
if (!rest.trim()) await rm2(file2);
|
|
22532
|
+
else await writeFile2(file2, rest);
|
|
22527
22533
|
}
|
|
22528
22534
|
async function disallowInClaudeSettings(file2) {
|
|
22529
22535
|
if (!existsSync5(file2)) return;
|
|
@@ -22537,8 +22543,74 @@ async function disallowInClaudeSettings(file2) {
|
|
|
22537
22543
|
await writeFile2(file2, `${JSON.stringify(settings, null, 2)}
|
|
22538
22544
|
`);
|
|
22539
22545
|
}
|
|
22546
|
+
var YAML_BEGIN = "# layermap:begin";
|
|
22547
|
+
var YAML_END = "# layermap:end";
|
|
22548
|
+
var nodeDirectory = (env = process.env) => (env.PATH ?? "").split(path9.delimiter).find(
|
|
22549
|
+
(directory) => path9.isAbsolute(directory) && existsSync5(path9.join(directory, "node")) && existsSync5(path9.join(directory, "npx"))
|
|
22550
|
+
) ?? path9.dirname(process.execPath);
|
|
22551
|
+
var dshPatchBlock = (command, env) => {
|
|
22552
|
+
const node = nodeDirectory(env);
|
|
22553
|
+
const npx = path9.join(node, "npx");
|
|
22554
|
+
const [program = "", ...args] = command[0] === "npx" && existsSync5(npx) ? [npx, ...command.slice(1)] : command;
|
|
22555
|
+
const searchPath = `${JSON.stringify(`${node}${path9.delimiter}`)} + process.env.PATH`;
|
|
22556
|
+
return [
|
|
22557
|
+
`${YAML_BEGIN} (written by \`layermap setup dsh\`; \`layermap remove dsh\` deletes it)`,
|
|
22558
|
+
"- insert:",
|
|
22559
|
+
" - id: layermap",
|
|
22560
|
+
" name: '@deepseek-ai/dsh-mcp-client'",
|
|
22561
|
+
" config:",
|
|
22562
|
+
" serverName: layermap",
|
|
22563
|
+
" transport: stdio",
|
|
22564
|
+
` command: ${JSON.stringify(program)}`,
|
|
22565
|
+
` args: ${JSON.stringify(args)}`,
|
|
22566
|
+
" env:",
|
|
22567
|
+
` PATH: !!js ${JSON.stringify(searchPath)}`,
|
|
22568
|
+
" cwd: !!js process.cwd()",
|
|
22569
|
+
" toolCallTimeoutMs: 120000",
|
|
22570
|
+
YAML_END
|
|
22571
|
+
].join("\n");
|
|
22572
|
+
};
|
|
22573
|
+
async function writeDshPatch(file2, block) {
|
|
22574
|
+
const text = existsSync5(file2) ? await readFile2(file2, "utf8") : "";
|
|
22575
|
+
const start = text.indexOf(YAML_BEGIN);
|
|
22576
|
+
const end = text.indexOf(YAML_END);
|
|
22577
|
+
let next;
|
|
22578
|
+
if (start >= 0 && end > start)
|
|
22579
|
+
next = `${text.slice(0, start)}${block}${text.slice(end + YAML_END.length)}`;
|
|
22580
|
+
else {
|
|
22581
|
+
const content = text.split("\n").filter((line) => line.trim() && !line.trim().startsWith("#"));
|
|
22582
|
+
if (content.length === 1 && content[0]?.trim() === "[]")
|
|
22583
|
+
next = text.replace(/^[ \t]*\[\][ \t]*$/mu, block);
|
|
22584
|
+
else if (content.some((line) => line.trim().startsWith("[")))
|
|
22585
|
+
throw new Error(`${file2} is a flow-style YAML list; add LayerMap's entry to it by hand.`);
|
|
22586
|
+
else next = `${text}${text && !text.endsWith("\n") ? "\n" : ""}${block}
|
|
22587
|
+
`;
|
|
22588
|
+
}
|
|
22589
|
+
if (next === text) return;
|
|
22590
|
+
await mkdir2(path9.dirname(file2), { recursive: true });
|
|
22591
|
+
await writeFile2(file2, next);
|
|
22592
|
+
}
|
|
22593
|
+
async function removeDshPatch(file2) {
|
|
22594
|
+
if (!existsSync5(file2)) return;
|
|
22595
|
+
const text = await readFile2(file2, "utf8");
|
|
22596
|
+
const start = text.indexOf(YAML_BEGIN);
|
|
22597
|
+
const end = text.indexOf(YAML_END);
|
|
22598
|
+
if (start < 0 || end < start) return;
|
|
22599
|
+
const rest = `${text.slice(0, start)}${text.slice(end + YAML_END.length).replace(/^\n/u, "")}`;
|
|
22600
|
+
if (!rest.trim()) return rm2(file2);
|
|
22601
|
+
const content = rest.split("\n").some((line) => line.trim() && !line.trim().startsWith("#"));
|
|
22602
|
+
await writeFile2(file2, content ? rest : `${rest}${rest.endsWith("\n") ? "" : "\n"}[]
|
|
22603
|
+
`);
|
|
22604
|
+
}
|
|
22540
22605
|
var agentFiles = (options) => {
|
|
22541
22606
|
const env = options.env ?? process.env;
|
|
22607
|
+
if (options.agent === "dsh") {
|
|
22608
|
+
const home = env.DSH_HOME || path9.join(homedir2(), ".dsh");
|
|
22609
|
+
return {
|
|
22610
|
+
settings: path9.join(home, "cordis.patch.yml"),
|
|
22611
|
+
instructions: path9.join(home, "AGENTS.md")
|
|
22612
|
+
};
|
|
22613
|
+
}
|
|
22542
22614
|
if (options.agent === "codex") {
|
|
22543
22615
|
const home = env.CODEX_HOME ?? path9.join(homedir2(), ".codex");
|
|
22544
22616
|
return { settings: path9.join(home, "config.toml"), instructions: path9.join(home, "AGENTS.md") };
|
|
@@ -22567,6 +22639,21 @@ async function setupAgent(options) {
|
|
|
22567
22639
|
const quoted = command.map((part) => /^[\w./:@=-]+$/u.test(part) ? part : JSON.stringify(part));
|
|
22568
22640
|
const { settings, instructions } = agentFiles(options);
|
|
22569
22641
|
const note = options.instructions !== false;
|
|
22642
|
+
if (options.agent === "dsh") {
|
|
22643
|
+
if (options.scope !== "user") {
|
|
22644
|
+
log2("DeepSeek Harness is set up for all its profiles at once; --scope does not apply.");
|
|
22645
|
+
return false;
|
|
22646
|
+
}
|
|
22647
|
+
log2(`add the ${SERVER} MCP server to ${settings}`);
|
|
22648
|
+
if (note) log2(`add a note naming the map tools to ${instructions}`);
|
|
22649
|
+
if (options.dryRun) return true;
|
|
22650
|
+
await writeDshPatch(settings, dshPatchBlock(command, env));
|
|
22651
|
+
if (note) await writeInstructionNote(instructions);
|
|
22652
|
+
log2(
|
|
22653
|
+
"Done. DeepSeek Harness reloads its settings by itself; its sessions have the mcp__layermap__project_* tools for the project dsh was started in."
|
|
22654
|
+
);
|
|
22655
|
+
return true;
|
|
22656
|
+
}
|
|
22570
22657
|
if (options.agent === "claude") {
|
|
22571
22658
|
const scope2 = ["--scope", options.scope];
|
|
22572
22659
|
log2(`claude mcp add ${scope2.join(" ")} ${SERVER} -- ${quoted.join(" ")}`);
|
|
@@ -22597,7 +22684,9 @@ async function setupAgent(options) {
|
|
|
22597
22684
|
}
|
|
22598
22685
|
async function allowAgent(options) {
|
|
22599
22686
|
if (options.agent !== "claude") {
|
|
22600
|
-
options.log(
|
|
22687
|
+
options.log(
|
|
22688
|
+
options.agent === "codex" ? "The Codex plugin already runs LayerMap's read-only tools without a prompt." : "DeepSeek Harness runs MCP tools without a prompt."
|
|
22689
|
+
);
|
|
22601
22690
|
return true;
|
|
22602
22691
|
}
|
|
22603
22692
|
const { settings } = agentFiles(options);
|
|
@@ -22610,6 +22699,16 @@ async function allowAgent(options) {
|
|
|
22610
22699
|
async function removeAgent(options) {
|
|
22611
22700
|
const env = options.env ?? process.env;
|
|
22612
22701
|
const { settings, instructions } = agentFiles(options);
|
|
22702
|
+
if (options.agent === "dsh") {
|
|
22703
|
+
options.log(
|
|
22704
|
+
`remove the ${SERVER} MCP server from ${settings} and its note from ${instructions}`
|
|
22705
|
+
);
|
|
22706
|
+
if (options.dryRun) return true;
|
|
22707
|
+
await removeDshPatch(settings);
|
|
22708
|
+
await removeInstructionNote(instructions);
|
|
22709
|
+
options.log("Removed.");
|
|
22710
|
+
return true;
|
|
22711
|
+
}
|
|
22613
22712
|
const scope = options.agent === "claude" ? ["--scope", options.scope] : [];
|
|
22614
22713
|
options.log(`${options.agent} mcp remove ${SERVER} ${scope.join(" ")}`.trim());
|
|
22615
22714
|
options.log(`remove LayerMap's approval from ${settings} and its note from ${instructions}`);
|
|
@@ -22625,10 +22724,10 @@ async function removeAgent(options) {
|
|
|
22625
22724
|
var USAGE = `LayerMap \u2014 a layered map of a codebase for coding agents.
|
|
22626
22725
|
|
|
22627
22726
|
Usage:
|
|
22628
|
-
layermap setup claude|codex [--scope user|project|local] [--no-instructions] [--dry-run]
|
|
22727
|
+
layermap setup claude|codex|dsh [--scope user|project|local] [--no-instructions] [--dry-run]
|
|
22629
22728
|
layermap allow claude [--scope user|project|local] [--dry-run]
|
|
22630
22729
|
let the plugin's read-only tools run without a prompt
|
|
22631
|
-
layermap remove claude|codex [--scope user|project|local] [--dry-run]
|
|
22730
|
+
layermap remove claude|codex|dsh [--scope user|project|local] [--dry-run]
|
|
22632
22731
|
layermap mcp [--project DIR] serve the map tools over MCP (stdio)
|
|
22633
22732
|
layermap index [--project DIR] build or update the map now
|
|
22634
22733
|
layermap explore [PATH] [--name NAME] [--line N] [--direction INCOMING|OUTGOING|BOTH]
|
|
@@ -22693,7 +22792,7 @@ async function main(argv) {
|
|
|
22693
22792
|
};
|
|
22694
22793
|
if (command === "setup" || command === "allow" || command === "remove") {
|
|
22695
22794
|
const agent = rest[0];
|
|
22696
|
-
if (agent !== "claude" && agent !== "codex") return usage(1);
|
|
22795
|
+
if (agent !== "claude" && agent !== "codex" && agent !== "dsh") return usage(1);
|
|
22697
22796
|
if (!["user", "project", "local"].includes(values.scope)) return usage(1);
|
|
22698
22797
|
const done = await { setup: setupAgent, allow: allowAgent, remove: removeAgent }[command]({
|
|
22699
22798
|
agent,
|
package/package.json
CHANGED