Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions main.js

Large diffs are not rendered by default.

19 changes: 12 additions & 7 deletions src/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ function scanDirectoryWithSkillMd(
const items: SkillItem[] = [];

for (const entry of readdirSync(baseDir, { withFileTypes: true })) {
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
const skillFile = join(baseDir, entry.name, "SKILL.md");
const fullPath = join(baseDir, entry.name);
const isDir = entry.isDirectory() || (entry.isSymbolicLink() && statSync(fullPath, { throwIfNoEntry: false })?.isDirectory());
if (!isDir) continue;
const skillFile = join(fullPath, "SKILL.md");
if (!existsSync(skillFile)) continue;

const item = parseSkillFile(skillFile, type, toolId);
Expand All @@ -89,14 +91,17 @@ function scanFlatMd(
const items: SkillItem[] = [];

for (const entry of readdirSync(baseDir, { withFileTypes: true })) {
if (entry.isDirectory() || entry.isSymbolicLink()) {
const skillFile = join(baseDir, entry.name, "SKILL.md");
const fullPath = join(baseDir, entry.name);
const isDir = entry.isDirectory() || (entry.isSymbolicLink() && statSync(fullPath, { throwIfNoEntry: false })?.isDirectory());

if (isDir) {
const skillFile = join(fullPath, "SKILL.md");
if (existsSync(skillFile)) {
const item = parseSkillFile(skillFile, type, toolId);
if (item) items.push(item);
continue;
}
const mdFiles = readdirSync(join(baseDir, entry.name)).filter(
const mdFiles = readdirSync(fullPath).filter(
(f) => f.endsWith(".md") && !IGNORED_FILES.has(f.toLowerCase())
);
const preferred =
Expand All @@ -105,7 +110,7 @@ function scanFlatMd(
) || mdFiles[0];
if (preferred) {
const item = parseSkillFile(
join(baseDir, entry.name, preferred),
join(fullPath, preferred),
type,
toolId
);
Expand All @@ -116,7 +121,7 @@ function scanFlatMd(

const fname = entry.name.toLowerCase();
if (!fname.endsWith(".md") || IGNORED_FILES.has(fname)) continue;
const item = parseSkillFile(join(baseDir, entry.name), type, toolId, "flat-md");
const item = parseSkillFile(fullPath, type, toolId, "flat-md");
if (item) items.push(item);
}
return items;
Expand Down
2 changes: 1 addition & 1 deletion src/tool-configs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { homedir } from "os";
import { existsSync } from "fs";
import { existsSync, readdirSync } from "fs";
import { join } from "path";
import type { ToolConfig } from "./types";

Expand Down