fix(agents): replace 'in' with Object.hasOwn() for prototype-safe property checks

Addresses cubic-dev-ai review: using 'in' on plain objects can skip valid
agent names that match inherited properties (toString, constructor, etc.).
Switched both occurrences in opencode-config-agents-reader.ts to
Object.hasOwn() for safe own-property checks.
This commit is contained in:
Brandon Webb
2026-04-14 20:45:22 -04:00
committed by YeonGyu-Kim
parent 42445f5130
commit cf4b231553
@@ -96,7 +96,7 @@ export function readOpencodeConfigAgents(directory: string): Record<string, Clau
if (agentsToLoad && typeof agentsToLoad === "object") {
for (const [agentName, agentData] of Object.entries(agentsToLoad)) {
if (agentName in result) continue
if (Object.hasOwn(result, agentName)) continue
const converted = convertInlineAgent(agentData)
if (converted) {
result[agentName] = converted
@@ -113,7 +113,7 @@ export function readOpencodeConfigAgents(directory: string): Record<string, Clau
const definitionAgents = loadAgentDefinitions(resolvedPaths, "opencode-config")
for (const [name, config] of Object.entries(definitionAgents)) {
if (!(name in result)) {
if (!Object.hasOwn(result, name)) {
result[name] = config
}
}