locus-product-planning 1.2.5 → 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.js CHANGED
@@ -12434,12 +12434,12 @@ tool.schema = external_exports;
12434
12434
 
12435
12435
  // src/index.ts
12436
12436
  import { readFileSync as readFileSync2 } from "fs";
12437
- import { join as join2, dirname as dirname2 } from "path";
12437
+ import { join, dirname as dirname2 } from "path";
12438
12438
  import { homedir } from "os";
12439
12439
 
12440
12440
  // src/lib/skills-core.ts
12441
12441
  import { readFileSync, existsSync, readdirSync } from "fs";
12442
- import { join, basename, dirname, resolve } from "path";
12442
+ import { join as pathJoin, basename, dirname, resolve } from "path";
12443
12443
  import { fileURLToPath } from "url";
12444
12444
  var _cachedDirname = null;
12445
12445
  function safeString(value) {
@@ -12448,6 +12448,28 @@ function safeString(value) {
12448
12448
  }
12449
12449
  return null;
12450
12450
  }
12451
+ function safeJoin(...paths) {
12452
+ const stringPaths = [];
12453
+ for (const p of paths) {
12454
+ if (typeof p === "string") {
12455
+ stringPaths.push(p);
12456
+ } else if (p != null) {
12457
+ const str = String(p);
12458
+ if (str && str !== "[object Object]" && str !== "undefined" && str !== "null") {
12459
+ stringPaths.push(str);
12460
+ }
12461
+ }
12462
+ }
12463
+ if (stringPaths.length === 0) {
12464
+ return ".";
12465
+ }
12466
+ try {
12467
+ return pathJoin(...stringPaths);
12468
+ } catch {
12469
+ const sep = stringPaths[0].includes("\\") ? "\\" : "/";
12470
+ return stringPaths.join(sep).replace(/[\/\\]+/g, sep);
12471
+ }
12472
+ }
12451
12473
  function getCurrentDirname() {
12452
12474
  if (typeof _cachedDirname === "string" && _cachedDirname.length > 0) {
12453
12475
  return _cachedDirname;
@@ -12475,7 +12497,7 @@ function getCurrentDirname() {
12475
12497
  try {
12476
12498
  const packageJsonPath = safeString(__require.resolve("locus-product-planning/package.json"));
12477
12499
  if (packageJsonPath) {
12478
- const result = safeString(join(dirname(packageJsonPath), "dist"));
12500
+ const result = safeString(safeJoin(dirname(packageJsonPath), "dist"));
12479
12501
  if (result) {
12480
12502
  _cachedDirname = result;
12481
12503
  return result;
@@ -12486,8 +12508,8 @@ function getCurrentDirname() {
12486
12508
  const homeDir = safeString(process.env.USERPROFILE) || safeString(process.env.HOME);
12487
12509
  if (homeDir) {
12488
12510
  const cacheLocations = [
12489
- join(homeDir, ".cache", "opencode", "node_modules", "locus-product-planning", "dist"),
12490
- join(homeDir, ".config", "opencode", "node_modules", "locus-product-planning", "dist")
12511
+ safeJoin(homeDir, ".cache", "opencode", "node_modules", "locus-product-planning", "dist"),
12512
+ safeJoin(homeDir, ".config", "opencode", "node_modules", "locus-product-planning", "dist")
12491
12513
  ];
12492
12514
  for (const loc of cacheLocations) {
12493
12515
  try {
@@ -12673,9 +12695,9 @@ function findSkillsInDir(dir, sourceType, maxDepth = 4) {
12673
12695
  }
12674
12696
  for (const entry of entries) {
12675
12697
  if (entry.name.startsWith(".")) continue;
12676
- const fullPath = join(currentDir, entry.name);
12698
+ const fullPath = safeJoin(currentDir, entry.name);
12677
12699
  if (entry.isDirectory()) {
12678
- const skillFile = join(fullPath, "SKILL.md");
12700
+ const skillFile = safeJoin(fullPath, "SKILL.md");
12679
12701
  if (existsSync(skillFile)) {
12680
12702
  const meta = extractFrontmatter(skillFile);
12681
12703
  skills.push({
@@ -12710,7 +12732,7 @@ function findAgentsInDir(dir, maxDepth = 3) {
12710
12732
  }
12711
12733
  for (const entry of entries) {
12712
12734
  if (entry.name.startsWith(".")) continue;
12713
- const fullPath = join(currentDir, entry.name);
12735
+ const fullPath = safeJoin(currentDir, entry.name);
12714
12736
  if (entry.isDirectory()) {
12715
12737
  recurse(fullPath, depth + 1, entry.name);
12716
12738
  } else if (entry.name.endsWith(".md")) {
@@ -12747,8 +12769,8 @@ function resolveSkillPath(skillName, locusSkillsDir, personalSkillsDir, projectS
12747
12769
  }
12748
12770
  function findSkillByName(baseDir, skillName, sourceType) {
12749
12771
  if (!existsSync(baseDir)) return null;
12750
- const directPath = join(baseDir, skillName);
12751
- const directSkillFile = join(directPath, "SKILL.md");
12772
+ const directPath = safeJoin(baseDir, skillName);
12773
+ const directSkillFile = safeJoin(directPath, "SKILL.md");
12752
12774
  if (existsSync(directSkillFile)) {
12753
12775
  return {
12754
12776
  skillFile: directSkillFile,
@@ -12769,8 +12791,8 @@ function findSkillByName(baseDir, skillName, sourceType) {
12769
12791
  return null;
12770
12792
  }
12771
12793
  function getBootstrapContent(locusSkillsDir, compact = false) {
12772
- const usingLocusPath = join(locusSkillsDir, "using-locus", "SKILL.md");
12773
- const legacyLocusPath = join(locusSkillsDir, "locus", "SKILL.md");
12794
+ const usingLocusPath = safeJoin(locusSkillsDir, "using-locus", "SKILL.md");
12795
+ const legacyLocusPath = safeJoin(locusSkillsDir, "locus", "SKILL.md");
12774
12796
  let skillFile = null;
12775
12797
  if (existsSync(usingLocusPath)) {
12776
12798
  skillFile = usingLocusPath;
@@ -12809,7 +12831,7 @@ function normalizePath(p, homeDir) {
12809
12831
  let normalized = p.trim();
12810
12832
  if (!normalized) return null;
12811
12833
  if (normalized.startsWith("~/")) {
12812
- normalized = join(homeDir, normalized.slice(2));
12834
+ normalized = safeJoin(homeDir, normalized.slice(2));
12813
12835
  } else if (normalized === "~") {
12814
12836
  normalized = homeDir;
12815
12837
  }
@@ -12819,13 +12841,13 @@ function normalizePath(p, homeDir) {
12819
12841
  // src/index.ts
12820
12842
  var LocusPlugin = async ({ client, directory }) => {
12821
12843
  const homeDir = homedir();
12822
- const projectSkillsDir = join2(directory, ".opencode/skills");
12844
+ const projectSkillsDir = join(directory, ".opencode/skills");
12823
12845
  const locusSkillsDir = getLocusSkillsDir();
12824
12846
  const locusAgentsDir = getLocusAgentsDir();
12825
- const projectAgentsDir = join2(directory, "agents");
12847
+ const projectAgentsDir = join(directory, "agents");
12826
12848
  const envConfigDir = normalizePath(process.env.OPENCODE_CONFIG_DIR, homeDir);
12827
- const configDir = envConfigDir || join2(homeDir, ".config/opencode");
12828
- const personalSkillsDir = join2(configDir, "skills");
12849
+ const configDir = envConfigDir || join(homeDir, ".config/opencode");
12850
+ const personalSkillsDir = join(configDir, "skills");
12829
12851
  const generateBootstrap = (compact = false) => {
12830
12852
  return getBootstrapContent(locusSkillsDir, compact);
12831
12853
  };