locus-product-planning 1.2.4 → 1.2.7

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.cjs CHANGED
@@ -12484,6 +12484,28 @@ function safeString(value) {
12484
12484
  }
12485
12485
  return null;
12486
12486
  }
12487
+ function safeJoin(...paths) {
12488
+ const stringPaths = [];
12489
+ for (const p of paths) {
12490
+ if (typeof p === "string") {
12491
+ stringPaths.push(p);
12492
+ } else if (p != null) {
12493
+ const str = String(p);
12494
+ if (str && str !== "[object Object]" && str !== "undefined" && str !== "null") {
12495
+ stringPaths.push(str);
12496
+ }
12497
+ }
12498
+ }
12499
+ if (stringPaths.length === 0) {
12500
+ return ".";
12501
+ }
12502
+ try {
12503
+ return (0, import_path.join)(...stringPaths);
12504
+ } catch {
12505
+ const sep = stringPaths[0].includes("\\") ? "\\" : "/";
12506
+ return stringPaths.join(sep).replace(/[\/\\]+/g, sep);
12507
+ }
12508
+ }
12487
12509
  function getCurrentDirname() {
12488
12510
  if (typeof _cachedDirname === "string" && _cachedDirname.length > 0) {
12489
12511
  return _cachedDirname;
@@ -12511,7 +12533,7 @@ function getCurrentDirname() {
12511
12533
  try {
12512
12534
  const packageJsonPath = safeString(require.resolve("locus-product-planning/package.json"));
12513
12535
  if (packageJsonPath) {
12514
- const result = safeString((0, import_path.join)((0, import_path.dirname)(packageJsonPath), "dist"));
12536
+ const result = safeString(safeJoin((0, import_path.dirname)(packageJsonPath), "dist"));
12515
12537
  if (result) {
12516
12538
  _cachedDirname = result;
12517
12539
  return result;
@@ -12522,8 +12544,8 @@ function getCurrentDirname() {
12522
12544
  const homeDir = safeString(process.env.USERPROFILE) || safeString(process.env.HOME);
12523
12545
  if (homeDir) {
12524
12546
  const cacheLocations = [
12525
- (0, import_path.join)(homeDir, ".cache", "opencode", "node_modules", "locus-product-planning", "dist"),
12526
- (0, import_path.join)(homeDir, ".config", "opencode", "node_modules", "locus-product-planning", "dist")
12547
+ safeJoin(homeDir, ".cache", "opencode", "node_modules", "locus-product-planning", "dist"),
12548
+ safeJoin(homeDir, ".config", "opencode", "node_modules", "locus-product-planning", "dist")
12527
12549
  ];
12528
12550
  for (const loc of cacheLocations) {
12529
12551
  try {
@@ -12564,15 +12586,33 @@ function getCurrentDirname() {
12564
12586
  _cachedDirname = absoluteFallback;
12565
12587
  return absoluteFallback;
12566
12588
  }
12567
- var currentDirname = getCurrentDirname();
12589
+ var _currentDirname = null;
12590
+ function ensureCurrentDirname() {
12591
+ if (_currentDirname === null) {
12592
+ _currentDirname = getCurrentDirname();
12593
+ }
12594
+ return _currentDirname;
12595
+ }
12568
12596
  function getPackageRoot() {
12569
- return (0, import_path.join)(currentDirname, "..");
12597
+ const dir = ensureCurrentDirname();
12598
+ if (dir.endsWith("/") || dir.endsWith("\\")) {
12599
+ return dir + "..";
12600
+ }
12601
+ const lastSlash = Math.max(dir.lastIndexOf("/"), dir.lastIndexOf("\\"));
12602
+ if (lastSlash > 0) {
12603
+ return dir.substring(0, lastSlash);
12604
+ }
12605
+ return dir;
12570
12606
  }
12571
12607
  function getLocusSkillsDir() {
12572
- return (0, import_path.join)(getPackageRoot(), "skills");
12608
+ const root = getPackageRoot();
12609
+ const sep = root.includes("\\") ? "\\" : "/";
12610
+ return root + sep + "skills";
12573
12611
  }
12574
12612
  function getLocusAgentsDir() {
12575
- return (0, import_path.join)(getPackageRoot(), "agents");
12613
+ const root = getPackageRoot();
12614
+ const sep = root.includes("\\") ? "\\" : "/";
12615
+ return root + sep + "agents";
12576
12616
  }
12577
12617
  function extractFrontmatter(filePath) {
12578
12618
  try {
@@ -12691,9 +12731,9 @@ function findSkillsInDir(dir, sourceType, maxDepth = 4) {
12691
12731
  }
12692
12732
  for (const entry of entries) {
12693
12733
  if (entry.name.startsWith(".")) continue;
12694
- const fullPath = (0, import_path.join)(currentDir, entry.name);
12734
+ const fullPath = safeJoin(currentDir, entry.name);
12695
12735
  if (entry.isDirectory()) {
12696
- const skillFile = (0, import_path.join)(fullPath, "SKILL.md");
12736
+ const skillFile = safeJoin(fullPath, "SKILL.md");
12697
12737
  if ((0, import_fs.existsSync)(skillFile)) {
12698
12738
  const meta = extractFrontmatter(skillFile);
12699
12739
  skills.push({
@@ -12728,7 +12768,7 @@ function findAgentsInDir(dir, maxDepth = 3) {
12728
12768
  }
12729
12769
  for (const entry of entries) {
12730
12770
  if (entry.name.startsWith(".")) continue;
12731
- const fullPath = (0, import_path.join)(currentDir, entry.name);
12771
+ const fullPath = safeJoin(currentDir, entry.name);
12732
12772
  if (entry.isDirectory()) {
12733
12773
  recurse(fullPath, depth + 1, entry.name);
12734
12774
  } else if (entry.name.endsWith(".md")) {
@@ -12765,8 +12805,8 @@ function resolveSkillPath(skillName, locusSkillsDir, personalSkillsDir, projectS
12765
12805
  }
12766
12806
  function findSkillByName(baseDir, skillName, sourceType) {
12767
12807
  if (!(0, import_fs.existsSync)(baseDir)) return null;
12768
- const directPath = (0, import_path.join)(baseDir, skillName);
12769
- const directSkillFile = (0, import_path.join)(directPath, "SKILL.md");
12808
+ const directPath = safeJoin(baseDir, skillName);
12809
+ const directSkillFile = safeJoin(directPath, "SKILL.md");
12770
12810
  if ((0, import_fs.existsSync)(directSkillFile)) {
12771
12811
  return {
12772
12812
  skillFile: directSkillFile,
@@ -12787,8 +12827,8 @@ function findSkillByName(baseDir, skillName, sourceType) {
12787
12827
  return null;
12788
12828
  }
12789
12829
  function getBootstrapContent(locusSkillsDir, compact = false) {
12790
- const usingLocusPath = (0, import_path.join)(locusSkillsDir, "using-locus", "SKILL.md");
12791
- const legacyLocusPath = (0, import_path.join)(locusSkillsDir, "locus", "SKILL.md");
12830
+ const usingLocusPath = safeJoin(locusSkillsDir, "using-locus", "SKILL.md");
12831
+ const legacyLocusPath = safeJoin(locusSkillsDir, "locus", "SKILL.md");
12792
12832
  let skillFile = null;
12793
12833
  if ((0, import_fs.existsSync)(usingLocusPath)) {
12794
12834
  skillFile = usingLocusPath;
@@ -12827,7 +12867,7 @@ function normalizePath(p, homeDir) {
12827
12867
  let normalized = p.trim();
12828
12868
  if (!normalized) return null;
12829
12869
  if (normalized.startsWith("~/")) {
12830
- normalized = (0, import_path.join)(homeDir, normalized.slice(2));
12870
+ normalized = safeJoin(homeDir, normalized.slice(2));
12831
12871
  } else if (normalized === "~") {
12832
12872
  normalized = homeDir;
12833
12873
  }