layermap 0.1.16 → 0.1.18

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
@@ -21059,14 +21059,18 @@ var CodeIndexStore = class {
21059
21059
  member.run(version2, path13, unit);
21060
21060
  }
21061
21061
  }
21062
- /** Earlier versions of a project's scope built by the same analyzer, most recent first. */
21063
- mapParentCandidates(version2, limit) {
21062
+ /**
21063
+ * Earlier versions of a project's scope built by the same analyzer, most recent first; with
21064
+ * another project, that project's versions of the same scope and analyzer as well.
21065
+ */
21066
+ mapParentCandidates(version2, limit, otherProjectRef) {
21064
21067
  return this.database.prepare(`SELECT version.version_ref FROM project_code_versions version
21065
21068
  JOIN project_code_index_state state ON state.version_ref = version.version_ref
21066
- WHERE version.project_ref = ? AND version.analyzer = ? AND version.scope_json = ?
21069
+ WHERE version.project_ref IN (?, ?) AND version.analyzer = ? AND version.scope_json = ?
21067
21070
  AND version.version_ref <> ?
21068
21071
  ORDER BY state.completed_at DESC LIMIT ?`).all(
21069
21072
  version2.projectRef,
21073
+ otherProjectRef ?? version2.projectRef,
21070
21074
  version2.analyzer,
21071
21075
  canonicalJson(version2.pathPrefixes),
21072
21076
  version2.version,
@@ -21732,7 +21736,7 @@ var CodeIndex = class {
21732
21736
  throw new ProjectEvidenceError("PROJECT_EVIDENCE_STORE_CONFLICT", false);
21733
21737
  return existing;
21734
21738
  }
21735
- await this.buildMap(result, source, combined);
21739
+ await this.buildMap(result, source, combined, options.startFromProjectRef);
21736
21740
  return this.store.requireVersion(result.version.version);
21737
21741
  }).catch((error51) => {
21738
21742
  if (error51 instanceof GitCommandStopUnconfirmedError || error51 instanceof ProjectMapStopUnconfirmedError)
@@ -21744,7 +21748,7 @@ var CodeIndex = class {
21744
21748
  this.captures.set(controller, completion);
21745
21749
  return completion;
21746
21750
  }
21747
- async buildMap(result, source, signal) {
21751
+ async buildMap(result, source, signal, startFromProjectRef) {
21748
21752
  this.assertAccepting(signal);
21749
21753
  const ref = result.version.version;
21750
21754
  const existing = this.mapBuilds.get(ref);
@@ -21755,7 +21759,7 @@ var CodeIndex = class {
21755
21759
  if (!(error51 instanceof ProjectEvidenceError) || error51.code !== "PROJECT_READ_CANCELLED")
21756
21760
  throw error51;
21757
21761
  }
21758
- return this.buildMap(result, source, signal);
21762
+ return this.buildMap(result, source, signal, startFromProjectRef);
21759
21763
  }
21760
21764
  if (existing) return this.awaitRebuild(existing, signal);
21761
21765
  if (this.store.getVersion(ref)) return;
@@ -21794,7 +21798,7 @@ var CodeIndex = class {
21794
21798
  this.store.discardMapStage(stage);
21795
21799
  }
21796
21800
  };
21797
- const completion = run2(this.mapParent(result)).finally(() => {
21801
+ const completion = run2(this.mapParent(result, startFromProjectRef)).finally(() => {
21798
21802
  if (this.mapBuilds.get(ref)?.completion === completion) this.mapBuilds.delete(ref);
21799
21803
  });
21800
21804
  const build = { controller, completion, waiters: /* @__PURE__ */ new Set() };
@@ -21802,13 +21806,18 @@ var CodeIndex = class {
21802
21806
  return this.awaitRebuild(build, signal);
21803
21807
  }
21804
21808
  /**
21805
- * The recent map of the same project scope and analyzer whose files differ least from the new
21806
- * revision's: its contexts whose inputs did not change are replayed rather than analyzed.
21809
+ * The recent map of the same project scope and analyzer, or of the project to start from, whose
21810
+ * files differ least from the new revision's: its contexts whose inputs did not change are
21811
+ * replayed rather than analyzed.
21807
21812
  */
21808
- mapParent(result) {
21813
+ mapParent(result, startFromProjectRef) {
21809
21814
  const digests = new Map(result.entries.map((entry) => [entry.path, entry.contentDigest]));
21810
21815
  let best;
21811
- for (const candidate of this.store.mapParentCandidates(result.version, 8)) {
21816
+ for (const candidate of this.store.mapParentCandidates(
21817
+ result.version,
21818
+ 8,
21819
+ startFromProjectRef
21820
+ )) {
21812
21821
  const entries2 = /* @__PURE__ */ new Map();
21813
21822
  for (const entry of this.store.listEntries(candidate))
21814
21823
  if (entry.contentDigest) entries2.set(entry.path, entry.contentDigest);
@@ -22606,11 +22615,10 @@ function mapChangeImpact(store, working, base, changes, project) {
22606
22615
  if (file2.status !== "DELETED") tracer.test(file2.path, void 0, "changed in this diff", 1);
22607
22616
  continue;
22608
22617
  }
22609
- if (!objects2.length) {
22610
- if (file2.status !== "DELETED" && kind)
22611
- unclear.push(`${file2.path} changed (${kind}): its effects are not mapped`);
22612
- continue;
22613
- }
22618
+ const analyzed = objects2.length > 0 && mapLanguageOf(file2.path) !== void 0;
22619
+ if (!analyzed && file2.status !== "DELETED" && kind)
22620
+ unclear.push(`${file2.path} changed (${kind}): its effects are not mapped`);
22621
+ if (!objects2.length) continue;
22614
22622
  const hits = /* @__PURE__ */ new Set();
22615
22623
  let topLevel = false;
22616
22624
  const inFile = declarations(graph, file2.path);
@@ -22641,7 +22649,7 @@ function mapChangeImpact(store, working, base, changes, project) {
22641
22649
  unclear.push(
22642
22650
  `the registration of ${JSON.stringify(relation.argument)} at ${relation.anchor.path}:${relation.anchor.startLine} changed; check that the route still reaches the right handler`
22643
22651
  );
22644
- if (topLevel && file2.status !== "ADDED")
22652
+ if (analyzed && topLevel && file2.status !== "ADDED")
22645
22653
  unclear.push(`top-level code of ${file2.path} changed (imports, constants or registrations)`);
22646
22654
  importerTests(graph, objects2, tracer);
22647
22655
  sameDirectoryTests(store, working, file2.path, tracer);
@@ -22887,6 +22895,22 @@ function routesIn(graph, path13) {
22887
22895
  return routes;
22888
22896
  }
22889
22897
  var routePath = (route) => route.slice(route.indexOf("/"));
22898
+ async function checkMapChanges(input, signal) {
22899
+ const { index, project, working } = input;
22900
+ const changes = await readMapChanges(project, input.base, signal);
22901
+ await index.ensureIndex(working, signal);
22902
+ const base = changes.files.some(
22903
+ (file2) => file2.basePath !== void 0 && (file2.baseLines.length || file2.baseText !== void 0)
22904
+ ) ? await input.baseVersion(changes.commit, signal) : void 0;
22905
+ const impact = mapChangeImpact(index.store, working, base, changes, project);
22906
+ return {
22907
+ text: mapChangesText(
22908
+ changes,
22909
+ impact,
22910
+ await mapRouteClients(project, index.store, working, impact, signal)
22911
+ )
22912
+ };
22913
+ }
22890
22914
  async function mapRouteClients(project, store, working, impact, signal) {
22891
22915
  const affected = impact.entries.filter(
22892
22916
  (entry) => entry.route && entry.certain && entry.chain.length <= 2
@@ -23176,19 +23200,16 @@ var LayerMap = class _LayerMap {
23176
23200
  * see. The base commit's map is built only when the diff removes or changes lines there.
23177
23201
  */
23178
23202
  async checkChanges(input, signal) {
23179
- const changes = await readMapChanges(this.project, input.base ?? "HEAD", signal);
23180
- const working = await this.refresh(signal);
23181
- const base = changes.files.some(
23182
- (file2) => file2.basePath !== void 0 && (file2.baseLines.length || file2.baseText !== void 0)
23183
- ) ? await this.versionAt(changes.commit, signal) : void 0;
23184
- const impact = mapChangeImpact(this.store, working, base, changes, this.project);
23185
- return {
23186
- text: mapChangesText(
23187
- changes,
23188
- impact,
23189
- await mapRouteClients(this.project, this.store, working, impact, signal)
23190
- )
23191
- };
23203
+ return checkMapChanges(
23204
+ {
23205
+ index: this.index,
23206
+ project: this.project,
23207
+ working: await this.refresh(signal),
23208
+ base: input.base ?? "HEAD",
23209
+ baseVersion: (commit, baseSignal) => this.versionAt(commit, baseSignal)
23210
+ },
23211
+ signal
23212
+ );
23192
23213
  }
23193
23214
  /**
23194
23215
  * Builds the map of a base commit (HEAD by default) ahead of a change check, so the check after an
@@ -23666,16 +23687,16 @@ var SETUP_RULE = `mcp__${SERVER}`;
23666
23687
  var PLUGIN_RULE = `mcp__plugin_${SERVER}_${SERVER}`;
23667
23688
  var BEGIN = "<!-- layermap:begin -->";
23668
23689
  var END = "<!-- layermap:end -->";
23690
+ var npxServerArgs = (version2) => [
23691
+ "--prefer-offline",
23692
+ "-y",
23693
+ `layermap@${version2}`,
23694
+ "mcp"
23695
+ ];
23669
23696
  var mcpLaunchCommand = (version2, platform = process.platform) => {
23670
23697
  const script = path12.resolve(process.argv[1] ?? "");
23671
23698
  if (script.includes(`${path12.sep}_npx${path12.sep}`))
23672
- return [
23673
- ...platform === "win32" ? ["cmd", "/c"] : [],
23674
- "npx",
23675
- "-y",
23676
- `layermap@${version2}`,
23677
- "mcp"
23678
- ];
23699
+ return [...platform === "win32" ? ["cmd", "/c"] : [], "npx", ...npxServerArgs(version2)];
23679
23700
  const execArgv = [];
23680
23701
  for (let index = 0; index < process.execArgv.length; index++) {
23681
23702
  const argument = process.execArgv[index];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "layermap",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
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
@@ -128,7 +128,7 @@ export default function layermap(pi) {
128
128
  if (server && !server.dead) return server;
129
129
  starting ??= (async () => {
130
130
  const next = new MapServer(cwd);
131
- const tools = await next.start("0.1.16");
131
+ const tools = await next.start("0.1.18");
132
132
  for (const tool of tools) {
133
133
  if (registered.has(tool.name)) continue;
134
134
  registered.add(tool.name);