locus-product-planning 1.2.1 → 1.2.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/dist/index.js CHANGED
@@ -12441,31 +12441,69 @@ import { homedir } from "os";
12441
12441
  import { readFileSync, existsSync, readdirSync } from "fs";
12442
12442
  import { join, basename, dirname, resolve } from "path";
12443
12443
  import { fileURLToPath } from "url";
12444
+ var _cachedDirname = null;
12444
12445
  function getCurrentDirname() {
12446
+ if (_cachedDirname) return _cachedDirname;
12445
12447
  try {
12446
12448
  const meta = import.meta;
12447
- if (meta?.url) {
12448
- return dirname(fileURLToPath(meta.url));
12449
+ if (meta?.url && typeof meta.url === "string" && meta.url.startsWith("file:")) {
12450
+ const result = dirname(fileURLToPath(meta.url));
12451
+ if (typeof result === "string" && result.length > 0) {
12452
+ _cachedDirname = result;
12453
+ return result;
12454
+ }
12455
+ }
12456
+ } catch {
12457
+ }
12458
+ try {
12459
+ const globalDirname = globalThis.__dirname;
12460
+ if (typeof globalDirname === "string" && globalDirname.length > 0) {
12461
+ _cachedDirname = globalDirname;
12462
+ return globalDirname;
12449
12463
  }
12450
12464
  } catch {
12451
12465
  }
12452
12466
  try {
12453
12467
  const packageJsonPath = __require.resolve("locus-product-planning/package.json");
12454
- return join(dirname(packageJsonPath), "dist");
12468
+ if (typeof packageJsonPath === "string") {
12469
+ const result = join(dirname(packageJsonPath), "dist");
12470
+ _cachedDirname = result;
12471
+ return result;
12472
+ }
12455
12473
  } catch {
12456
12474
  }
12475
+ const homeDir = process.env.USERPROFILE || process.env.HOME || "";
12476
+ if (homeDir) {
12477
+ const cacheLocations = [
12478
+ join(homeDir, ".cache", "opencode", "node_modules", "locus-product-planning", "dist"),
12479
+ join(homeDir, ".config", "opencode", "node_modules", "locus-product-planning", "dist")
12480
+ ];
12481
+ for (const loc of cacheLocations) {
12482
+ try {
12483
+ if (existsSync(loc)) {
12484
+ _cachedDirname = loc;
12485
+ return loc;
12486
+ }
12487
+ } catch {
12488
+ }
12489
+ }
12490
+ }
12457
12491
  const cwd = process.cwd();
12458
12492
  try {
12459
12493
  const pkgPath = resolve(cwd, "package.json");
12460
12494
  if (existsSync(pkgPath)) {
12461
12495
  const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
12462
12496
  if (pkg.name === "locus-product-planning") {
12463
- return resolve(cwd, "dist");
12497
+ const result = resolve(cwd, "dist");
12498
+ _cachedDirname = result;
12499
+ return result;
12464
12500
  }
12465
12501
  }
12466
12502
  } catch {
12467
12503
  }
12468
- return resolve(cwd, "dist");
12504
+ const fallback = resolve(cwd, "dist");
12505
+ _cachedDirname = fallback;
12506
+ return fallback;
12469
12507
  }
12470
12508
  var currentDirname = getCurrentDirname();
12471
12509
  function getPackageRoot() {