MCPcopy Create free account
hub / github.com/codeaashu/claude-code / loadComponents

Function loadComponents

src/commands/plugin/ManagePlugins.tsx:211–328  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

209 const [error, setError] = useState<string | null>(null);
210 useEffect(() => {
211 async function loadComponents() {
212 try {
213 // Built-in plugins don't have a marketplace entry — read from the
214 // registered definition directly.
215 if (marketplace === 'builtin') {
216 const builtinDef = getBuiltinPluginDefinition(plugin.name);
217 if (builtinDef) {
218 const skillNames = builtinDef.skills?.map(s => s.name) ?? [];
219 const hookEvents = builtinDef.hooks ? Object.keys(builtinDef.hooks) : [];
220 const mcpServerNames = builtinDef.mcpServers ? Object.keys(builtinDef.mcpServers) : [];
221 setComponents({
222 commands: null,
223 agents: null,
224 skills: skillNames.length > 0 ? skillNames : null,
225 hooks: hookEvents.length > 0 ? hookEvents : null,
226 mcpServers: mcpServerNames.length > 0 ? mcpServerNames : null
227 });
228 } else {
229 setError(`Built-in plugin ${plugin.name} not found`);
230 }
231 setLoading(false);
232 return;
233 }
234 const marketplaceData = await getMarketplace(marketplace);
235 // Find the plugin entry in the array
236 const pluginEntry = marketplaceData.plugins.find(p => p.name === plugin.name);
237 if (pluginEntry) {
238 // Combine commands from both sources
239 const commandPathList = [];
240 if (plugin.commandsPath) {
241 commandPathList.push(plugin.commandsPath);
242 }
243 if (plugin.commandsPaths) {
244 commandPathList.push(...plugin.commandsPaths);
245 }
246
247 // Get base file names from all command paths
248 const commandList: string[] = [];
249 for (const commandPath of commandPathList) {
250 if (typeof commandPath === 'string') {
251 // commandPath is already a full path
252 const baseNames = await getBaseFileNames(commandPath);
253 commandList.push(...baseNames);
254 }
255 }
256
257 // Combine agents from both sources
258 const agentPathList = [];
259 if (plugin.agentsPath) {
260 agentPathList.push(plugin.agentsPath);
261 }
262 if (plugin.agentsPaths) {
263 agentPathList.push(...plugin.agentsPaths);
264 }
265
266 // Get base file names from all agent paths
267 const agentList: string[] = [];
268 for (const agentPath of agentPathList) {

Callers 1

PluginComponentsDisplayFunction · 0.85

Calls 5

getBaseFileNamesFunction · 0.85
getSkillDirNamesFunction · 0.85
keysMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected