lensmcp 1.5.0 → 1.7.0

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.
Files changed (2) hide show
  1. package/lib/cli.js +22 -8
  2. package/package.json +1 -1
package/lib/cli.js CHANGED
@@ -399,10 +399,26 @@ function walkProjectFiles(root, match, maxDepth = 6, cap = 6000) {
399
399
  return found;
400
400
  }
401
401
  // ---------- helpers ----------
402
+ /** The lensmcp package root. `prepare-dist` flattens `dist/` → the package root, so this compiled
403
+ * file ships at `<root>/lib/cli.js` with `bundled/` + `package.json` as siblings of `lib/`. Walk up
404
+ * to the nearest `package.json` rather than hardcoding a depth: a fixed `../..` assumed the
405
+ * un-flattened `dist/lib` layout and overshot to `node_modules/`, which broke the bundle lookups
406
+ * (`lensmcp mcp`/`dashboard`/`bridge`) and the version read in every published consumer. */
407
+ function cliPackageRoot() {
408
+ let dir = dirname(fileURLToPath(import.meta.url));
409
+ for (let i = 0; i < 4; i++) {
410
+ if (existsSync(join(dir, 'package.json')))
411
+ return dir;
412
+ const parent = dirname(dir);
413
+ if (parent === dir)
414
+ break;
415
+ dir = parent;
416
+ }
417
+ return dir;
418
+ }
402
419
  function readCliVersion() {
403
420
  try {
404
- const pkgPath = join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'package.json');
405
- const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
421
+ const pkg = JSON.parse(readFileSync(join(cliPackageRoot(), 'package.json'), 'utf8'));
406
422
  return pkg.version;
407
423
  }
408
424
  catch {
@@ -447,9 +463,8 @@ function findMcpBinary(cwd) {
447
463
  /** Resolve a built server bundle (`main.js` | `dashboard.js`): the published
448
464
  * `bundled/<file>` first, then the workspace dev build (walking up from cwd). */
449
465
  function findServerBundle(cwd, file) {
450
- // 1. Bundled inside the published lensmcp (ship step).
451
- const here = dirname(fileURLToPath(import.meta.url));
452
- const bundled = resolve(here, '..', '..', 'bundled', file);
466
+ // 1. Bundled inside the published lensmcp (ship step) — `bundled/` sits at the package root.
467
+ const bundled = join(cliPackageRoot(), 'bundled', file);
453
468
  if (existsSync(bundled))
454
469
  return bundled;
455
470
  // 2. Dev build in the workspace (four-bucket layout: servers/).
@@ -472,9 +487,8 @@ function findServerBundle(cwd, file) {
472
487
  /** Resolve the standalone bridge runner: the published `bundled/bridge.js`
473
488
  * first, then the workspace dev build (`libs/bridge/dist/main.js`, walking up). */
474
489
  function findBridgeBundle(cwd) {
475
- // 1. Bundled inside the published lensmcp (ship step).
476
- const here = dirname(fileURLToPath(import.meta.url));
477
- const bundled = resolve(here, '..', '..', 'bundled', 'bridge.js');
490
+ // 1. Bundled inside the published lensmcp (ship step) — `bundled/` sits at the package root.
491
+ const bundled = join(cliPackageRoot(), 'bundled', 'bridge.js');
478
492
  if (existsSync(bundled))
479
493
  return bundled;
480
494
  // 2. Dev build in the workspace (walk up from cwd).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lensmcp",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",