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 +55 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +61 -21
- 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 {
|
|
@@ -12528,15 +12550,33 @@ function getCurrentDirname() {
|
|
|
12528
12550
|
_cachedDirname = absoluteFallback;
|
|
12529
12551
|
return absoluteFallback;
|
|
12530
12552
|
}
|
|
12531
|
-
var
|
|
12553
|
+
var _currentDirname = null;
|
|
12554
|
+
function ensureCurrentDirname() {
|
|
12555
|
+
if (_currentDirname === null) {
|
|
12556
|
+
_currentDirname = getCurrentDirname();
|
|
12557
|
+
}
|
|
12558
|
+
return _currentDirname;
|
|
12559
|
+
}
|
|
12532
12560
|
function getPackageRoot() {
|
|
12533
|
-
|
|
12561
|
+
const dir = ensureCurrentDirname();
|
|
12562
|
+
if (dir.endsWith("/") || dir.endsWith("\\")) {
|
|
12563
|
+
return dir + "..";
|
|
12564
|
+
}
|
|
12565
|
+
const lastSlash = Math.max(dir.lastIndexOf("/"), dir.lastIndexOf("\\"));
|
|
12566
|
+
if (lastSlash > 0) {
|
|
12567
|
+
return dir.substring(0, lastSlash);
|
|
12568
|
+
}
|
|
12569
|
+
return dir;
|
|
12534
12570
|
}
|
|
12535
12571
|
function getLocusSkillsDir() {
|
|
12536
|
-
|
|
12572
|
+
const root = getPackageRoot();
|
|
12573
|
+
const sep = root.includes("\\") ? "\\" : "/";
|
|
12574
|
+
return root + sep + "skills";
|
|
12537
12575
|
}
|
|
12538
12576
|
function getLocusAgentsDir() {
|
|
12539
|
-
|
|
12577
|
+
const root = getPackageRoot();
|
|
12578
|
+
const sep = root.includes("\\") ? "\\" : "/";
|
|
12579
|
+
return root + sep + "agents";
|
|
12540
12580
|
}
|
|
12541
12581
|
function extractFrontmatter(filePath) {
|
|
12542
12582
|
try {
|
|
@@ -12655,9 +12695,9 @@ function findSkillsInDir(dir, sourceType, maxDepth = 4) {
|
|
|
12655
12695
|
}
|
|
12656
12696
|
for (const entry of entries) {
|
|
12657
12697
|
if (entry.name.startsWith(".")) continue;
|
|
12658
|
-
const fullPath =
|
|
12698
|
+
const fullPath = safeJoin(currentDir, entry.name);
|
|
12659
12699
|
if (entry.isDirectory()) {
|
|
12660
|
-
const skillFile =
|
|
12700
|
+
const skillFile = safeJoin(fullPath, "SKILL.md");
|
|
12661
12701
|
if (existsSync(skillFile)) {
|
|
12662
12702
|
const meta = extractFrontmatter(skillFile);
|
|
12663
12703
|
skills.push({
|
|
@@ -12692,7 +12732,7 @@ function findAgentsInDir(dir, maxDepth = 3) {
|
|
|
12692
12732
|
}
|
|
12693
12733
|
for (const entry of entries) {
|
|
12694
12734
|
if (entry.name.startsWith(".")) continue;
|
|
12695
|
-
const fullPath =
|
|
12735
|
+
const fullPath = safeJoin(currentDir, entry.name);
|
|
12696
12736
|
if (entry.isDirectory()) {
|
|
12697
12737
|
recurse(fullPath, depth + 1, entry.name);
|
|
12698
12738
|
} else if (entry.name.endsWith(".md")) {
|
|
@@ -12729,8 +12769,8 @@ function resolveSkillPath(skillName, locusSkillsDir, personalSkillsDir, projectS
|
|
|
12729
12769
|
}
|
|
12730
12770
|
function findSkillByName(baseDir, skillName, sourceType) {
|
|
12731
12771
|
if (!existsSync(baseDir)) return null;
|
|
12732
|
-
const directPath =
|
|
12733
|
-
const directSkillFile =
|
|
12772
|
+
const directPath = safeJoin(baseDir, skillName);
|
|
12773
|
+
const directSkillFile = safeJoin(directPath, "SKILL.md");
|
|
12734
12774
|
if (existsSync(directSkillFile)) {
|
|
12735
12775
|
return {
|
|
12736
12776
|
skillFile: directSkillFile,
|
|
@@ -12751,8 +12791,8 @@ function findSkillByName(baseDir, skillName, sourceType) {
|
|
|
12751
12791
|
return null;
|
|
12752
12792
|
}
|
|
12753
12793
|
function getBootstrapContent(locusSkillsDir, compact = false) {
|
|
12754
|
-
const usingLocusPath =
|
|
12755
|
-
const legacyLocusPath =
|
|
12794
|
+
const usingLocusPath = safeJoin(locusSkillsDir, "using-locus", "SKILL.md");
|
|
12795
|
+
const legacyLocusPath = safeJoin(locusSkillsDir, "locus", "SKILL.md");
|
|
12756
12796
|
let skillFile = null;
|
|
12757
12797
|
if (existsSync(usingLocusPath)) {
|
|
12758
12798
|
skillFile = usingLocusPath;
|
|
@@ -12791,7 +12831,7 @@ function normalizePath(p, homeDir) {
|
|
|
12791
12831
|
let normalized = p.trim();
|
|
12792
12832
|
if (!normalized) return null;
|
|
12793
12833
|
if (normalized.startsWith("~/")) {
|
|
12794
|
-
normalized =
|
|
12834
|
+
normalized = safeJoin(homeDir, normalized.slice(2));
|
|
12795
12835
|
} else if (normalized === "~") {
|
|
12796
12836
|
normalized = homeDir;
|
|
12797
12837
|
}
|
|
@@ -12801,13 +12841,13 @@ function normalizePath(p, homeDir) {
|
|
|
12801
12841
|
// src/index.ts
|
|
12802
12842
|
var LocusPlugin = async ({ client, directory }) => {
|
|
12803
12843
|
const homeDir = homedir();
|
|
12804
|
-
const projectSkillsDir =
|
|
12844
|
+
const projectSkillsDir = join(directory, ".opencode/skills");
|
|
12805
12845
|
const locusSkillsDir = getLocusSkillsDir();
|
|
12806
12846
|
const locusAgentsDir = getLocusAgentsDir();
|
|
12807
|
-
const projectAgentsDir =
|
|
12847
|
+
const projectAgentsDir = join(directory, "agents");
|
|
12808
12848
|
const envConfigDir = normalizePath(process.env.OPENCODE_CONFIG_DIR, homeDir);
|
|
12809
|
-
const configDir = envConfigDir ||
|
|
12810
|
-
const personalSkillsDir =
|
|
12849
|
+
const configDir = envConfigDir || join(homeDir, ".config/opencode");
|
|
12850
|
+
const personalSkillsDir = join(configDir, "skills");
|
|
12811
12851
|
const generateBootstrap = (compact = false) => {
|
|
12812
12852
|
return getBootstrapContent(locusSkillsDir, compact);
|
|
12813
12853
|
};
|