mirror of
https://github.com/github/awesome-copilot.git
synced 2026-04-30 12:15:56 +00:00
fix: agent files not loading from agents folder (#1473)
This commit is contained in:
@@ -492,6 +492,21 @@ function getSkillFiles(skillPath, relativePath) {
|
|||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all agent markdown files from a folder
|
||||||
|
*/
|
||||||
|
function getAgentFiles(agentDir, pluginRootPath) {
|
||||||
|
if (!fs.existsSync(agentDir)) return [];
|
||||||
|
|
||||||
|
return fs
|
||||||
|
.readdirSync(agentDir)
|
||||||
|
.filter((f) => f.endsWith(".md"))
|
||||||
|
.map((f) => ({
|
||||||
|
kind: "agent",
|
||||||
|
path: `${pluginRootPath}/agents/${f}`,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate plugins metadata
|
* Generate plugins metadata
|
||||||
*/
|
*/
|
||||||
@@ -517,9 +532,25 @@ function generatePluginsData(gitDates) {
|
|||||||
const relPath = `plugins/${dir.name}`;
|
const relPath = `plugins/${dir.name}`;
|
||||||
const dates = gitDates[relPath] || gitDates[`${relPath}/`] || {};
|
const dates = gitDates[relPath] || gitDates[`${relPath}/`] || {};
|
||||||
|
|
||||||
|
const agentItems = (data.agents || []).flatMap((agent) => {
|
||||||
|
const agentPath = agent.replace("./", "");
|
||||||
|
const fullPath = path.join(pluginDir, agentPath);
|
||||||
|
|
||||||
|
if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) {
|
||||||
|
return getAgentFiles(fullPath, relPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
kind: "agent",
|
||||||
|
path: `${relPath}/${agentPath}`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
// Build items list from spec fields (agents, commands, skills)
|
// Build items list from spec fields (agents, commands, skills)
|
||||||
const items = [
|
const items = [
|
||||||
...(data.agents || []).map((p) => ({ kind: "agent", path: p })),
|
...agentItems,
|
||||||
...(data.commands || []).map((p) => ({ kind: "prompt", path: p })),
|
...(data.commands || []).map((p) => ({ kind: "prompt", path: p })),
|
||||||
...(data.skills || []).map((p) => ({ kind: "skill", path: p })),
|
...(data.skills || []).map((p) => ({ kind: "skill", path: p })),
|
||||||
];
|
];
|
||||||
@@ -535,9 +566,8 @@ function generatePluginsData(gitDates) {
|
|||||||
itemCount: items.length,
|
itemCount: items.length,
|
||||||
items: items,
|
items: items,
|
||||||
lastUpdated: dates.lastModified || null,
|
lastUpdated: dates.lastModified || null,
|
||||||
searchText: `${data.name || dir.name} ${
|
searchText: `${data.name || dir.name} ${data.description || ""
|
||||||
data.description || ""
|
} ${tags.join(" ")}`.toLowerCase(),
|
||||||
} ${tags.join(" ")}`.toLowerCase(),
|
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn(`Failed to parse plugin: ${dir.name}`, e.message);
|
console.warn(`Failed to parse plugin: ${dir.name}`, e.message);
|
||||||
@@ -704,9 +734,8 @@ function generateSearchIndex(
|
|||||||
description: instruction.description,
|
description: instruction.description,
|
||||||
path: instruction.path,
|
path: instruction.path,
|
||||||
lastUpdated: instruction.lastUpdated,
|
lastUpdated: instruction.lastUpdated,
|
||||||
searchText: `${instruction.title} ${instruction.description} ${
|
searchText: `${instruction.title} ${instruction.description} ${instruction.applyTo || ""
|
||||||
instruction.applyTo || ""
|
}`.toLowerCase(),
|
||||||
}`.toLowerCase(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -732,9 +761,8 @@ function generateSearchIndex(
|
|||||||
description: workflow.description,
|
description: workflow.description,
|
||||||
path: workflow.path,
|
path: workflow.path,
|
||||||
lastUpdated: workflow.lastUpdated,
|
lastUpdated: workflow.lastUpdated,
|
||||||
searchText: `${workflow.title} ${
|
searchText: `${workflow.title} ${workflow.description
|
||||||
workflow.description
|
} ${workflow.triggers.join(" ")}`.toLowerCase(),
|
||||||
} ${workflow.triggers.join(" ")}`.toLowerCase(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1235,7 +1235,7 @@ function renderLocalPluginModal(
|
|||||||
|
|
||||||
switch (itemType) {
|
switch (itemType) {
|
||||||
case "agent":
|
case "agent":
|
||||||
path = path.replace(".md", ".agent.md");
|
// path = path.replace(".md", ".agent.md");
|
||||||
break;
|
break;
|
||||||
case "skill":
|
case "skill":
|
||||||
path = `${path}/SKILL.md`;
|
path = `${path}/SKILL.md`;
|
||||||
|
|||||||
Reference in New Issue
Block a user