locus-product-planning 1.2.5 → 1.2.8
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 +38 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
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(
|
|
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
|
-
|
|
12490
|
-
|
|
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 =
|
|
12698
|
+
const fullPath = safeJoin(currentDir, entry.name);
|
|
12677
12699
|
if (entry.isDirectory()) {
|
|
12678
|
-
const skillFile =
|
|
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 =
|
|
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")) {
|
|
@@ -12729,6 +12751,9 @@ function findAgentsInDir(dir, maxDepth = 3) {
|
|
|
12729
12751
|
return agents;
|
|
12730
12752
|
}
|
|
12731
12753
|
function resolveSkillPath(skillName, locusSkillsDir, personalSkillsDir, projectSkillsDir) {
|
|
12754
|
+
if (typeof skillName !== "string" || !skillName) {
|
|
12755
|
+
return null;
|
|
12756
|
+
}
|
|
12732
12757
|
const forceProject = skillName.startsWith("project:");
|
|
12733
12758
|
const forceLocus = skillName.startsWith("locus:");
|
|
12734
12759
|
const actualSkillName = skillName.replace(/^project:/, "").replace(/^locus:/, "");
|
|
@@ -12746,9 +12771,11 @@ function resolveSkillPath(skillName, locusSkillsDir, personalSkillsDir, projectS
|
|
|
12746
12771
|
return null;
|
|
12747
12772
|
}
|
|
12748
12773
|
function findSkillByName(baseDir, skillName, sourceType) {
|
|
12774
|
+
if (typeof baseDir !== "string" || !baseDir) return null;
|
|
12775
|
+
if (typeof skillName !== "string" || !skillName) return null;
|
|
12749
12776
|
if (!existsSync(baseDir)) return null;
|
|
12750
|
-
const directPath =
|
|
12751
|
-
const directSkillFile =
|
|
12777
|
+
const directPath = safeJoin(baseDir, skillName);
|
|
12778
|
+
const directSkillFile = safeJoin(directPath, "SKILL.md");
|
|
12752
12779
|
if (existsSync(directSkillFile)) {
|
|
12753
12780
|
return {
|
|
12754
12781
|
skillFile: directSkillFile,
|
|
@@ -12769,8 +12796,8 @@ function findSkillByName(baseDir, skillName, sourceType) {
|
|
|
12769
12796
|
return null;
|
|
12770
12797
|
}
|
|
12771
12798
|
function getBootstrapContent(locusSkillsDir, compact = false) {
|
|
12772
|
-
const usingLocusPath =
|
|
12773
|
-
const legacyLocusPath =
|
|
12799
|
+
const usingLocusPath = safeJoin(locusSkillsDir, "using-locus", "SKILL.md");
|
|
12800
|
+
const legacyLocusPath = safeJoin(locusSkillsDir, "locus", "SKILL.md");
|
|
12774
12801
|
let skillFile = null;
|
|
12775
12802
|
if (existsSync(usingLocusPath)) {
|
|
12776
12803
|
skillFile = usingLocusPath;
|
|
@@ -12809,7 +12836,7 @@ function normalizePath(p, homeDir) {
|
|
|
12809
12836
|
let normalized = p.trim();
|
|
12810
12837
|
if (!normalized) return null;
|
|
12811
12838
|
if (normalized.startsWith("~/")) {
|
|
12812
|
-
normalized =
|
|
12839
|
+
normalized = safeJoin(homeDir, normalized.slice(2));
|
|
12813
12840
|
} else if (normalized === "~") {
|
|
12814
12841
|
normalized = homeDir;
|
|
12815
12842
|
}
|
|
@@ -12819,13 +12846,13 @@ function normalizePath(p, homeDir) {
|
|
|
12819
12846
|
// src/index.ts
|
|
12820
12847
|
var LocusPlugin = async ({ client, directory }) => {
|
|
12821
12848
|
const homeDir = homedir();
|
|
12822
|
-
const projectSkillsDir =
|
|
12849
|
+
const projectSkillsDir = join(directory, ".opencode/skills");
|
|
12823
12850
|
const locusSkillsDir = getLocusSkillsDir();
|
|
12824
12851
|
const locusAgentsDir = getLocusAgentsDir();
|
|
12825
|
-
const projectAgentsDir =
|
|
12852
|
+
const projectAgentsDir = join(directory, "agents");
|
|
12826
12853
|
const envConfigDir = normalizePath(process.env.OPENCODE_CONFIG_DIR, homeDir);
|
|
12827
|
-
const configDir = envConfigDir ||
|
|
12828
|
-
const personalSkillsDir =
|
|
12854
|
+
const configDir = envConfigDir || join(homeDir, ".config/opencode");
|
|
12855
|
+
const personalSkillsDir = join(configDir, "skills");
|
|
12829
12856
|
const generateBootstrap = (compact = false) => {
|
|
12830
12857
|
return getBootstrapContent(locusSkillsDir, compact);
|
|
12831
12858
|
};
|