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

Function resolvePluginPathField

packages/agent-core/src/plugin/manifest.ts:202–231  ·  view source on GitHub ↗
(input: {
  readonly pluginRoot: string;
  readonly field: string;
  readonly value: string;
  readonly diagnostics: PluginDiagnostic[];
})

Source from the content-addressed store, hash-verified

200}
201
202async function resolvePluginPathField(input: {
203 readonly pluginRoot: string;
204 readonly field: string;
205 readonly value: string;
206 readonly diagnostics: PluginDiagnostic[];
207}): Promise<string | undefined> {
208 if (!input.value.startsWith('./')) {
209 input.diagnostics.push({
210 severity: 'warn',
211 message: `"${input.field}" path must start with "./" (got "${input.value}")`,
212 });
213 return undefined;
214 }
215 const absolute = path.resolve(input.pluginRoot, input.value);
216 let real: string;
217 try {
218 real = await realpath(absolute);
219 } catch {
220 real = absolute;
221 }
222 const rootReal = await realpath(input.pluginRoot).catch(() => input.pluginRoot);
223 if (!isWithin(real, rootReal)) {
224 input.diagnostics.push({
225 severity: 'warn',
226 message: `"${input.field}" path resolves outside the plugin (${input.value})`,
227 });
228 return undefined;
229 }
230 return real;
231}
232
233function readSessionStart(
234 raw: unknown,

Callers 2

readCommandsFunction · 0.85
normalizePluginMcpServerFunction · 0.85

Calls 4

isWithinFunction · 0.70
resolveMethod · 0.65
realpathFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected