layermap 0.1.3 → 0.1.5

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/dist/cli.mjs CHANGED
@@ -15782,8 +15782,11 @@ var MapRelationSchema = external_exports.object({
15782
15782
  anchor: MapAnchorSchema,
15783
15783
  target: external_exports.string(),
15784
15784
  // A literal the relation carries: a decorator's first argument on the declaration itself, or
15785
- // the path a call or value is registered under; both are usually routes.
15785
+ // the route a call or value is registered under (its methods, if named, then its path).
15786
15786
  argument: external_exports.string().min(1).max(256).optional(),
15787
+ // The full route a decorator registers its declaration under, when it says more than the
15788
+ // argument: the HTTP methods, then the class's path joined with the member's.
15789
+ route: external_exports.string().min(1).max(256).optional(),
15787
15790
  basis: external_exports.enum(["TYPE_RESOLVED", "SYNTAX_DECLARED", "UNRESOLVED"]),
15788
15791
  unresolvedReason: external_exports.enum([
15789
15792
  "SYNTAX_ONLY",
@@ -16005,7 +16008,8 @@ var MapFactsSchema = external_exports.object({
16005
16008
  target: external_exports.string(),
16006
16009
  basis: MapRelationSchema.shape.basis,
16007
16010
  reason: MapRelationSchema.shape.unresolvedReason,
16008
- argument: MapRelationSchema.shape.argument
16011
+ argument: MapRelationSchema.shape.argument,
16012
+ route: MapRelationSchema.shape.route
16009
16013
  }).strict()
16010
16014
  ),
16011
16015
  notes: external_exports.array(
@@ -16183,7 +16187,8 @@ function mapFactsAnalysis(facts, input, context) {
16183
16187
  target: fact.target,
16184
16188
  basis: fact.basis,
16185
16189
  ...fact.reason ? { unresolvedReason: fact.reason } : {},
16186
- ...fact.argument ? { argument: fact.argument } : {}
16190
+ ...fact.argument ? { argument: fact.argument } : {},
16191
+ ...fact.route ? { route: fact.route } : {}
16187
16192
  });
16188
16193
  if (fact.kind === "WRITES")
16189
16194
  collect.note({
@@ -16645,7 +16650,7 @@ function runMapOperation(resources, input, schema, signal, observeTiming) {
16645
16650
  var goModule = /(?:^|\/)go\.mod$/u;
16646
16651
  var codeHosts = /* @__PURE__ */ new Set(["github.com", "gitlab.com", "bitbucket.org"]);
16647
16652
  var GO_MAP_LANGUAGE = Object.freeze({
16648
- id: "go-1.24-map-v6",
16653
+ id: "go-1.24-map-v7",
16649
16654
  claims: (path10) => path10.endsWith(".go"),
16650
16655
  reads: (path10) => goModule.test(path10),
16651
16656
  // A module path, or the standard library, whose first path element has no dot.
@@ -16798,7 +16803,7 @@ var nameOf = (path10) => path10.slice(path10.lastIndexOf("/") + 1);
16798
16803
  var DEFAULT_RELEASE = 21;
16799
16804
  var platformPackage = /^(?:java|jdk|sun|com\.sun|javax\.(?:annotation\.processing|crypto|imageio|lang\.model|management|naming|net|print|script|security|sound|sql|swing|tools|transaction\.xa|xml))(?:\.|$)/u;
16800
16805
  var JAVA_MAP_LANGUAGE = Object.freeze({
16801
- id: "javac-lombok-1.18.48-map-v5",
16806
+ id: "javac-lombok-1.18.48-map-v6",
16802
16807
  claims: (path10) => path10.endsWith(".java"),
16803
16808
  reads: (path10) => buildFile.test(path10),
16804
16809
  // A package of the Java platform, or a library named by its first two package segments.
@@ -17350,7 +17355,7 @@ var pythonConfig = /(?:^|\/)(?:pyrightconfig\.json|pyproject\.toml|setup\.cfg)$/
17350
17355
  var directoryOf2 = (path10) => path10.slice(0, path10.lastIndexOf("/") + 1);
17351
17356
  var DEFAULT_PYTHON = { major: 3, minor: 13 };
17352
17357
  var PYTHON_MAP_LANGUAGE = Object.freeze({
17353
- id: "pyright-1.1.414-map-v9",
17358
+ id: "pyright-1.1.414-map-v10",
17354
17359
  claims: (path10) => /\.pyi?$/u.test(path10),
17355
17360
  reads: (path10) => pythonConfig.test(path10),
17356
17361
  // An absolute import names the standard library or a distribution's top-level package.
@@ -17505,7 +17510,7 @@ var PythonMapAnalyzer = class {
17505
17510
 
17506
17511
  // src/project-map-language-typescript.ts
17507
17512
  var TYPESCRIPT_MAP_LANGUAGE = Object.freeze({
17508
- id: "typescript-7.0.2-map-v14",
17513
+ id: "typescript-7.0.2-map-v15",
17509
17514
  claims: (path10) => /\.[cm]?[jt]sx?$/u.test(path10),
17510
17515
  reads: (path10) => path10.endsWith(".json") || path10 === "pnpm-workspace.yaml",
17511
17516
  create: () => new TypeScriptMapAnalyzer()
@@ -18657,7 +18662,6 @@ function mapSearchView(store, version2, query, rows, offset, maxResults, budget)
18657
18662
  format: MAP_SEARCH_FORMAT,
18658
18663
  text: [
18659
18664
  `PROJECT MAP \xB7 SEARCH ${JSON.stringify(query.text)} ${query.matchMode}${filters.length ? ` \xB7 ${filters.join(" \xB7 ")}` : ""} \xB7 ${count ? `results ${offset + 1}-${offset + count}` : "no matching declarations or files"}${more2 ? ` \xB7 continue with offset ${offset + count}` : ""}`,
18660
- "Ranked by relevance; kinds f function, c class, m method, p property, v variable, t type, i interface, e enum, followed by 1-based source lines and the matched fields.",
18661
18665
  ...lines
18662
18666
  ].join("\n"),
18663
18667
  ...more2 ? { nextOffset: offset + count } : {},
@@ -18841,7 +18845,8 @@ var invalid2 = () => {
18841
18845
  var notFound = () => {
18842
18846
  throw new ProjectEvidenceError("PROJECT_MAP_OBJECT_NOT_FOUND", false);
18843
18847
  };
18844
- var LEGEND = "Kinds: f function, c class, m method, p property, v variable, t type, i interface, e enum; numbers are 1-based source lines.";
18848
+ var MAP_KINDS_LEGEND = "kinds f function, c class, m method, p property, v variable, t type, i interface, e enum; numbers are 1-based source lines";
18849
+ var MAP_DECLARATION_LEGEND = `@n marks where a relationship occurs and +n counts further sites, which project_find_references lists; a quoted path after the sites is the route the call or value is registered under there: its HTTP methods when the registration names them, then its path joined with the prefixes of the routers it is registered on, as far as the same function or file sets them (a prefix added where a router is mounted or passed in is not included); route "\u2026" after a decorator is the full route the decorator maps, its class's path joined with its own. Static relationships are grouped by the declaration that owns them. Callers are direct calls, uses as a value (stored, passed, returned or selected, then usually invoked through that value) and calls through an interface, type or base member that a declaration implements (dispatched from); dispatches to lists the members that implement an interface, type or base member, which a call through it may reach; trace stops names calls whose target is a function value, a member without a mapped implementation or a computed key, which only source reading can follow; possible callers by name are calls elsewhere, in the same language, of a member with a method's name on a receiver of unknown type (an untyped value, or one an unloaded package produced); they may or may not reach that method.`;
18845
18850
  var within = (path10, directory) => directory === "." || path10.startsWith(`${directory}/`);
18846
18851
  var parentDirectory = (path10) => {
18847
18852
  const slash = path10.lastIndexOf("/");
@@ -18850,7 +18855,7 @@ var parentDirectory = (path10) => {
18850
18855
  var compareText2 = (left, right) => left < right ? -1 : left > right ? 1 : 0;
18851
18856
  var byCount = ([leftName, left], [rightName, right]) => right - left || compareText2(leftName, rightName);
18852
18857
  var increment = (counts, key, count = 1) => counts.set(key, (counts.get(key) ?? 0) + count);
18853
- var decoratorTag = (name, argument) => `@${name}${argument === void 0 ? "" : `(${JSON.stringify(argument)})`}`;
18858
+ var decoratorTag = (name, argument, route) => `@${name}${argument === void 0 ? "" : `(${JSON.stringify(argument)})`}${route === void 0 ? "" : ` route ${JSON.stringify(route)}`}`;
18854
18859
  var targetText = (target) => {
18855
18860
  const limit = MAP_VIEW_LIMITS.targetText;
18856
18861
  if (target.length <= limit) return target;
@@ -18906,8 +18911,9 @@ function pageBlocks(view, head, whole, offset, budget) {
18906
18911
  return {
18907
18912
  format: MAP_VIEW_FORMAT,
18908
18913
  view,
18914
+ // Later pages continue a view the agent has already read, so only its title repeats.
18909
18915
  text: [
18910
- ...head,
18916
+ ...offset ? head.slice(0, 1) : head,
18911
18917
  ...blocks.slice(offset, end),
18912
18918
  ...more2 ? [`\u2026 ${blocks.length - end} more entries; continue with offset ${end}.`] : []
18913
18919
  ].join("\n"),
@@ -19000,7 +19006,8 @@ function loadDirectoryFacts(store, version2) {
19000
19006
  const classes = declarations.filter((item) => item.kind === "CLASS").map((item) => item.ref);
19001
19007
  const decoratorQuery = store.database.prepare(`SELECT from_ref,
19002
19008
  json_extract(relation_json, '$.target') AS target,
19003
- json_extract(relation_json, '$.argument') AS argument
19009
+ json_extract(relation_json, '$.argument') AS argument,
19010
+ json_extract(relation_json, '$.route') AS route
19004
19011
  FROM project_map_relations WHERE version_ref = ?
19005
19012
  AND from_ref IN (SELECT value FROM json_each(?))
19006
19013
  AND json_extract(relation_json, '$.kind') = 'DECORATED_BY'`);
@@ -19011,7 +19018,11 @@ function loadDirectoryFacts(store, version2) {
19011
19018
  ))
19012
19019
  decorators.set(String(row.from_ref), [
19013
19020
  ...decorators.get(String(row.from_ref)) ?? [],
19014
- decoratorTag(String(row.target), row.argument === null ? void 0 : String(row.argument))
19021
+ decoratorTag(
19022
+ String(row.target),
19023
+ row.argument === null ? void 0 : String(row.argument),
19024
+ row.route === null ? void 0 : String(row.route)
19025
+ )
19015
19026
  ]);
19016
19027
  const exported = /* @__PURE__ */ new Map();
19017
19028
  for (const item of declarations) {
@@ -19324,7 +19335,7 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
19324
19335
  });
19325
19336
  const head = [
19326
19337
  `PROJECT MAP \xB7 DIRECTORY ${directory} \xB7 ${code.length} code files \xB7 ${text - code.length} other text files${visible.length > text ? ` \xB7 ${visible.length - text} unreadable entries` : ""}${hiddenTests ? ` \xB7 ${hiddenTests} test files hidden (includeTests)` : ""}${prefixes.includes(".") ? "" : " \xB7 limited to authorized paths"}`,
19327
- tier === "DETAILED" ? `${LEGEND} Code files list line count and exported declarations; other files show size.` : tier === "COMPACT" ? "File lines give a directory, then its files with line counts; join them for a path. Declarations are omitted to keep this overview small: open a file, or a directory with fewer files, to see them." : "Files are omitted because this directory is large: open a module directory to list its files.",
19338
+ tier === "DETAILED" ? "Code files list line count and exported declarations; other files show size." : tier === "COMPACT" ? "File lines give a directory, then its files with line counts; join them for a path. Declarations are omitted to keep this overview small: open a file, or a directory with fewer files, to see them." : "Files are omitted because this directory is large: open a module directory to list its files.",
19328
19339
  ...rates.length ? [
19329
19340
  `Static calls linked to project declarations: ${rates.join(", ")}; the rest have a callee of unknown type, such as a value from a package whose types are not loaded. ${externalCalls} calls into the standard library or into packages that are not loaded are not counted.`
19330
19341
  ] : [],
@@ -19353,8 +19364,7 @@ var INCOMING = {
19353
19364
  DECORATED_BY: "decorates"
19354
19365
  };
19355
19366
  var IMPORT_KINDS = /* @__PURE__ */ new Set(["IMPORTS", "TEST_IMPORTS"]);
19356
- var callerCoverage = (textSearch) => `Callers are direct calls, uses as a value (stored, passed, returned or selected, then usually invoked through that value) and calls through an interface, type or base member that a declaration here implements (dispatched from). Calls through dependency injection, framework routing, reflection or computed names are not mapped, so a complete view is not a complete caller list; confirm impact with project_find_references or ${textSearch}. Possible callers by name are calls elsewhere, in the same language, of a member with a method's name on a receiver of unknown type (an untyped value, or one an unloaded package produced); they may or may not reach that method.`;
19357
- var DISPATCH_LEGEND = "dispatches to lists the members that implement an interface, type or base member, which a call through it may reach; trace stops names calls whose target is a function value, a member without a mapped implementation or a computed key, which only source reading can follow.";
19367
+ var callerCoverage = (textSearch) => `Calls through dependency injection, framework routing, reflection or computed names are not mapped, so a complete view is not a complete caller list; confirm impact with project_find_references or ${textSearch}.`;
19358
19368
  var SPECIAL_METHOD = /^__\w+__$/u;
19359
19369
  var DeclarationGroups = class {
19360
19370
  constructor(graph, input, prefixes, showTests, memberCalls) {
@@ -19437,6 +19447,11 @@ var DeclarationGroups = class {
19437
19447
  }
19438
19448
  continue;
19439
19449
  }
19450
+ if (!outgoing && relation.kind === "DECORATED_BY") {
19451
+ const name = relation.to === void 0 ? relation.target : graph.qualifiedName(graph.owner(relation.to));
19452
+ tags.push(decoratorTag(name, relation.argument, relation.route));
19453
+ continue;
19454
+ }
19440
19455
  if (!outgoing || relation.kind === "CONTAINS") continue;
19441
19456
  const reason = relation.kind === "CALLS" ? this.stop(relation) : void 0;
19442
19457
  if (reason) {
@@ -19450,7 +19465,7 @@ var DeclarationGroups = class {
19450
19465
  if (IMPORT_KINDS.has(relation.kind) && mapIsModule(graph.object(relation.from))) continue;
19451
19466
  if (relation.to === void 0) {
19452
19467
  if (relation.kind === "DECORATED_BY")
19453
- tags.push(decoratorTag(relation.target, relation.argument));
19468
+ tags.push(decoratorTag(relation.target, relation.argument, relation.route));
19454
19469
  else if (relation.kind === "EXTENDS" || relation.kind === "IMPLEMENTS")
19455
19470
  tags.push(`${relation.kind.toLowerCase()} ${relation.target}`);
19456
19471
  else {
@@ -19471,7 +19486,7 @@ var DeclarationGroups = class {
19471
19486
  continue;
19472
19487
  }
19473
19488
  if (relation.kind === "DECORATED_BY")
19474
- tags.push(decoratorTag(graph.qualifiedName(other.id), relation.argument));
19489
+ tags.push(decoratorTag(graph.qualifiedName(other.id), relation.argument, relation.route));
19475
19490
  else if (relation.kind === "EXTENDS" || relation.kind === "IMPLEMENTS")
19476
19491
  tags.push(`${relation.kind.toLowerCase()} ${graph.qualifiedName(other.id)}`);
19477
19492
  else
@@ -19613,8 +19628,7 @@ function fileView(store, coverage, graph, input, path10, prefixes) {
19613
19628
  const module = mapCodePath(path10) ? graph.objectsAt(path10).find((object2) => mapIsModule(object2)) : void 0;
19614
19629
  const gaps = coverage.files.get(path10) ?? [];
19615
19630
  const head = [
19616
- `PROJECT MAP \xB7 FILE ${path10} \xB7 ${entry.state !== "TEXT" ? entry.state : module ? module.parsing === "NOT_PARSED" ? `not parsed${gaps.length ? ` (${gaps.join("; ")})` : ""}; read it as text` : `${module.anchor.endLine} lines${gaps.length ? ` \xB7 ${gaps.join("; ")}` : ""}` : `${entry.byteLength} bytes, not analyzed; read it as text`}`,
19617
- LEGEND
19631
+ `PROJECT MAP \xB7 FILE ${path10} \xB7 ${entry.state !== "TEXT" ? entry.state : module ? module.parsing === "NOT_PARSED" ? `not parsed${gaps.length ? ` (${gaps.join("; ")})` : ""}; read it as text` : `${module.anchor.endLine} lines${gaps.length ? ` \xB7 ${gaps.join("; ")}` : ""}` : `${entry.byteLength} bytes, not analyzed; read it as text`}`
19618
19632
  ];
19619
19633
  if (!module || entry.state !== "TEXT")
19620
19634
  return pageBlocks("FILE", head, [], input.offset ?? 0, input.outputBudget);
@@ -19629,7 +19643,7 @@ function fileView(store, coverage, graph, input, path10, prefixes) {
19629
19643
  if (!["DECORATED_BY", "EXTENDS", "IMPLEMENTS"].includes(relation.kind)) continue;
19630
19644
  const list = tags.get(relation.from) ?? [];
19631
19645
  list.push(
19632
- relation.kind === "DECORATED_BY" ? decoratorTag(relation.target, relation.argument) : `${relation.kind.toLowerCase()} ${relation.target}`
19646
+ relation.kind === "DECORATED_BY" ? decoratorTag(relation.target, relation.argument, relation.route) : `${relation.kind.toLowerCase()} ${relation.target}`
19633
19647
  );
19634
19648
  tags.set(relation.from, list);
19635
19649
  }
@@ -19765,7 +19779,7 @@ function declarationView(graph, input, path10, prefixes, memberCalls) {
19765
19779
  }
19766
19780
  const head = [
19767
19781
  `PROJECT MAP \xB7 DECLARATION ${path10}${name === void 0 ? "" : ` ${name}`}${line === void 0 ? "" : ` line ${line}`} \xB7 direction ${input.direction ?? "BOTH"} \xB7 depth ${depth}${depth < requested ? ` (BOTH is limited to ${MAP_VIEW_LIMITS.bothDepth})` : ""}${prefixes.includes(".") ? "" : " \xB7 limited to authorized paths"}`,
19768
- `${LEGEND} @n marks where a relationship occurs and +n counts further sites, which project_find_references lists; a quoted path after the sites is what the call or value is registered under there, such as a route. Static relationships are grouped by the declaration that owns them; closures and locals belong to their container; ${DISPATCH_LEGEND}${truncated ? ` Expansion stopped at ${MAP_VIEW_LIMITS.declarations} declarations.` : ""}`,
19782
+ ...truncated ? [`Expansion stopped at ${MAP_VIEW_LIMITS.declarations} declarations.`] : [],
19769
19783
  ...(input.direction ?? "BOTH") === "OUTGOING" ? [] : [callerCoverage(input.textSearch ?? DEFAULT_TEXT_SEARCH)]
19770
19784
  ];
19771
19785
  return pageBlocks("DECLARATION", head, blocks, input.offset ?? 0, input.outputBudget);
@@ -22218,8 +22232,8 @@ var mapReferencesInputSchema = (host) => external_exports.object({
22218
22232
  var mapToolDescriptions = (host) => {
22219
22233
  const lead = (tool) => host.lead ? `${host.lead[tool]} ` : "";
22220
22234
  return Object.freeze({
22221
- search: `${lead("search")}Find declarations and files whose names, paths or source documentation match query terms. ANY (default) matches any term, ALL requires every term, LITERAL matches the exact text. Results are ranked by relevance and grouped by file with the declaration name, kind, 1-based line range and matched fields. Zoom into a result with project_explore_map({path,name}) or ${host.readResult}. This is not a full-text search and does not prove absence; ${host.textSearch}. Continue with offset and unchanged conditions.`,
22222
- explore: `${lead("explore")}Read the static project map, zooming from the whole project to one declaration. path "." or a directory lists modules, module imports, external packages and its files: with exported declarations when the listing is small, as file names and line counts by directory when larger, and as modules only when very large. Start here to see what exists before searching or reading. A file path lists its declarations and members, imports, importers and top-level statements. A file path with name (or Container.member), optionally narrowed by its start line, or with a line alone, shows that declaration's calls, callers (including uses as a value), writes, heritage, decorators and members, aggregated per related declaration with @line sites; closures and locals are folded into their named container. depth also expands the related declarations hop by hop: up to 8 in one direction, which traces callers up to entry points (INCOMING) or callees down (OUTGOING), and up to 3 for BOTH. To find what a change affects, select the declaration with direction INCOMING and a depth up to 8, continue from any NOT EXPANDED declarations the view names, then confirm the entry points in source. Test files and standard-library call targets are hidden and counted by default; includeTests and includeUnresolved show them. ${host.readSource} The map is static: calls through an interface, type or base member continue to the members it links as implementations (dispatches to, dispatched from), while trace stops, possible callers by name (calls of a same-named member on a receiver of unknown type), framework wiring and unresolved targets need source reading, and a missing relationship does not prove absence. When a page reports more entries, continue with offset and otherwise unchanged arguments.`,
22235
+ search: `${lead("search")}Find declarations and files whose names, paths or source documentation match query terms. ANY (default) matches any term, ALL requires every term, LITERAL matches the exact text. Results are ranked by relevance and grouped by file with the declaration name, kind, 1-based line range and matched fields (${MAP_KINDS_LEGEND}). Zoom into a result with project_explore_map({path,name}) or ${host.readResult}. This is not a full-text search and does not prove absence; ${host.textSearch}. Continue with offset and unchanged conditions.`,
22236
+ explore: `${lead("explore")}Read the static project map, zooming from the whole project to one declaration. path "." or a directory lists modules, module imports, external packages and its files: with exported declarations when the listing is small, as file names and line counts by directory when larger, and as modules only when very large. Start here to see what exists before searching or reading. A file path lists its declarations and members, imports, importers and top-level statements. A file path with name (or Container.member), optionally narrowed by its start line, or with a line alone, shows that declaration's calls, callers (including uses as a value), writes, heritage, decorators and members, aggregated per related declaration with @line sites; closures and locals are folded into their named container. depth also expands the related declarations hop by hop: up to 8 in one direction, which traces callers up to entry points (INCOMING) or callees down (OUTGOING), and up to 3 for BOTH. To find what a change affects, select the declaration with direction INCOMING and a depth up to 8, continue from any NOT EXPANDED declarations the view names, then confirm the entry points in source. Test files and standard-library call targets are hidden and counted by default; includeTests and includeUnresolved show them. Views use ${MAP_KINDS_LEGEND}. In a declaration view, ${MAP_DECLARATION_LEGEND} ${host.readSource} The map is static: trace stops, possible callers by name, framework wiring and unresolved targets need source reading, and a missing relationship does not prove absence. When a page reports more entries, continue with offset and otherwise unchanged arguments.`,
22223
22237
  references: `${lead("references")}Compute usages of a mapped declaration from current source, including aliases, re-exports and non-call references. Select it with symbol {path,name,line?} as printed by project_explore_map or project_search_map (line is its start line when names repeat), or with an entityRef or locator {path,start,kind}. Broader and more expensive than the cached callers in project_explore_map; file or unsupported declarations may lack a reference target. path and kinds filter usage locations before paging. ${host.grantRules}objects contains compact declarations; targetRef and reference ownerRef identify them. ${host.readReference} A file that several compiler contexts read (such as packages of one workspace) lists its references once per context, each with that context's configPath. Continue with nextCursor and unchanged conditions, including after an empty partial page. Filtered exhaustion and missing results do not prove absence.`
22224
22238
  });
22225
22239
  };
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "layermap",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
+ "mcpName": "io.github.coffeecoproject/layermap",
4
5
  "description": "A layered map of a codebase for coding agents: directories, modules and call chains across TypeScript, Go, Python and Java.",
5
6
  "license": "Apache-2.0",
6
7
  "type": "module",