MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / detectPluginRoot

Function detectPluginRoot

packages/agent-core/src/plugin/archive.ts:121–133  ·  view source on GitHub ↗
(dir: string)

Source from the content-addressed store, hash-verified

119}
120
121async function detectPluginRoot(dir: string): Promise<string> {
122 if (await hasManifest(dir)) return dir;
123
124 const entries = await readdir(dir, { withFileTypes: true });
125 const childDirs = entries.filter((entry) => entry.isDirectory());
126 const childDir = childDirs.length === 1 ? childDirs[0] : undefined;
127 if (childDir !== undefined) {
128 const child = path.join(dir, childDir.name);
129 if (await hasManifest(child)) return child;
130 }
131
132 return dir;
133}
134
135async function hasManifest(dir: string): Promise<boolean> {
136 const rootManifest = path.join(dir, 'kimi.plugin.json');

Callers 1

extractZipFunction · 0.85

Calls 2

hasManifestFunction · 0.85
readdirFunction · 0.50

Tested by

no test coverage detected