MCPcopy Create free account
hub / github.com/backnotprop/plannotator / resolveAgentConfigKey

Function resolveAgentConfigKey

apps/opencode-plugin/workflow.ts:208–227  ·  view source on GitHub ↗
(opencodeConfig: OpenCodeConfig, agentName: string)

Source from the content-addressed store, hash-verified

206}
207
208function resolveAgentConfigKey(opencodeConfig: OpenCodeConfig, agentName: string): string {
209 opencodeConfig.agent ??= {};
210
211 if (Object.prototype.hasOwnProperty.call(opencodeConfig.agent, agentName)) {
212 return agentName;
213 }
214
215 const normalizedTarget = normalizeAgentLookupKey(agentName);
216 for (const existingKey of Object.keys(opencodeConfig.agent)) {
217 const normalizedExisting = normalizeAgentLookupKey(existingKey);
218 if (normalizedExisting === normalizedTarget) {
219 return existingKey;
220 }
221 if (normalizedExisting.startsWith(`${normalizedTarget} -`) || normalizedExisting.startsWith(`${normalizedTarget} (`)) {
222 return existingKey;
223 }
224 }
225
226 return agentName;
227}
228
229function ensureAgentConfig(opencodeConfig: OpenCodeConfig, agentName: string): AgentConfig {
230 opencodeConfig.agent ??= {};

Callers 2

applyWorkflowConfigFunction · 0.85
ensureAgentConfigFunction · 0.85

Calls 1

normalizeAgentLookupKeyFunction · 0.85

Tested by

no test coverage detected