@phren/cli 0.0.14 → 0.0.16

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.
@@ -3,6 +3,7 @@ import * as path from "path";
3
3
  import { getProjectDirs } from "./shared.js";
4
4
  import { parseSkillFrontmatter } from "./link-skills.js";
5
5
  import { isSkillEnabled } from "./skill-state.js";
6
+ import { safeProjectPath } from "./utils.js";
6
7
  function normalizeCommand(raw, fallbackName) {
7
8
  const value = typeof raw === "string" && raw.trim() ? raw.trim() : `/${fallbackName}`;
8
9
  return value.startsWith("/") ? value : `/${value}`;
@@ -28,13 +29,35 @@ function collectSkills(phrenPath, root, sourceLabel, scopeType, sourceKind, seen
28
29
  if (!fs.existsSync(root))
29
30
  return [];
30
31
  const results = [];
32
+ const realRoot = (() => {
33
+ try {
34
+ return fs.realpathSync(root);
35
+ }
36
+ catch {
37
+ return path.resolve(root);
38
+ }
39
+ })();
31
40
  for (const entry of fs.readdirSync(root, { withFileTypes: true })) {
32
41
  const isFolder = entry.isDirectory();
33
- const filePath = isFolder
42
+ const candidatePath = isFolder
34
43
  ? path.join(root, entry.name, "SKILL.md")
35
44
  : entry.name.endsWith(".md") ? path.join(root, entry.name) : null;
36
- if (!filePath || seen.has(filePath) || !fs.existsSync(filePath))
45
+ if (!candidatePath)
46
+ continue;
47
+ const safeCandidate = safeProjectPath(root, path.relative(root, candidatePath));
48
+ if (!safeCandidate || seen.has(safeCandidate) || !fs.existsSync(safeCandidate))
37
49
  continue;
50
+ try {
51
+ if (fs.lstatSync(safeCandidate).isSymbolicLink())
52
+ continue;
53
+ const realCandidate = fs.realpathSync(safeCandidate);
54
+ if (realCandidate !== realRoot && !realCandidate.startsWith(realRoot + path.sep))
55
+ continue;
56
+ }
57
+ catch {
58
+ continue;
59
+ }
60
+ const filePath = safeCandidate;
38
61
  seen.add(filePath);
39
62
  const name = isFolder ? entry.name : entry.name.replace(/\.md$/, "");
40
63
  const { frontmatter } = parseSkillFrontmatter(fs.readFileSync(filePath, "utf8"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phren/cli",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "Knowledge layer for AI agents. Phren learns and recalls.",
5
5
  "type": "module",
6
6
  "bin": {