t1018: Fix agent name collisions in OpenCode plugin#1319
t1018: Fix agent name collisions in OpenCode plugin#1319marcusquinn wants to merge 1 commit intomainfrom
Conversation
- Changed subagent name from basename to full relative path - Prevents collisions like tools/git/github-cli vs services/git/github-cli - Added scripts/ and templates/ to scanned subdirs (73 additional agents) - Root agents keep simple names for backward compatibility
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
WalkthroughAgent discovery logic updated to scan additional subdirectories (scripts, templates) and derive subagent names from full relative paths instead of basenames, preventing naming collisions across nested directory structures while preserving existing root-level agent behavior. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Thu Feb 12 22:42:38 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.agents/plugins/opencode-aidevops/index.mjs (1)
575-592:⚠️ Potential issue | 🟠 MajorNote:
AGENT_MCP_TOOLSkeys need reconciliation with the new naming scheme.This is the downstream impact of the naming change at line 384–389. If any of these agents (
outscraper,context7,playwriter, etc.) reside under subdirectories rather than at root level, their path-prefixed names will no longer match these keys, andapplyAgentMcpToolswill silently skip them — leaving those agents without their required MCP tool permissions.
🤖 Fix all issues with AI agents
In @.agents/plugins/opencode-aidevops/index.mjs:
- Around line 384-393: Agent registration uses OS-specific join and stores
agents under path-prefixed names (agentName from relPath via join) which won't
match AGENT_MCP_TOOLS simple basenames and breaks the config.agent lookup; to
fix, normalize agentName to use POSIX separators (e.g., replace backslashes with
'/') when building relPath/agentName and update the lookup logic where
config.agent[agentName] is checked to fall back to the basename (use
path.basename(agentName) or strip directory prefix) if the full-path key is
missing, or alternatively update AGENT_MCP_TOOLS keys to their path-prefixed
form to match agentName. Ensure changes touch the relPath/agentName construction
(join, relPath, agentName) and the config.agent lookup to handle both normalized
full paths and basenames.
🧹 Nitpick comments (1)
.agents/plugins/opencode-aidevops/index.mjs (1)
384-387:path.joinproduces OS-specific separators in agent names.On Windows,
join(relBase, entry.name)would yieldtools\git\github-cliinstead oftools/git/github-cli, making agent names platform-dependent. If cross-platform consistency matters, consider normalizing with.replace(/\\/g, '/')or usingposix.join.♻️ Suggested fix
- const relPath = join(relBase, entry.name); - // Use relative path without .md extension as agent name to prevent collisions - // e.g., "tools/git/github-cli.md" → "tools/git/github-cli" - const agentName = relPath.replace(/\.md$/, ""); + const relPath = join(relBase, entry.name).replace(/\\/g, "/"); + // Use relative path without .md extension as agent name to prevent collisions + // e.g., "tools/git/github-cli.md" → "tools/git/github-cli" + const agentName = relPath.replace(/\.md$/, "");
| const relPath = join(relBase, entry.name); | ||
| // Use relative path without .md extension as agent name to prevent collisions | ||
| // e.g., "tools/git/github-cli.md" → "tools/git/github-cli" | ||
| const agentName = relPath.replace(/\.md$/, ""); | ||
| agents.push({ | ||
| name: basename(entry.name, ".md"), | ||
| name: agentName, | ||
| description: data.description || "", | ||
| mode: data.mode || "subagent", | ||
| relPath: join(relBase, entry.name), | ||
| relPath: relPath, | ||
| }); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Step 1: Explore agents directory structure
echo "=== Repository structure in .agents ==="
fd -t f "\.md$" .agents --max-depth 4 | head -20
echo ""
echo "=== Directory layout ==="
tree -L 3 .agents 2>/dev/null || find .agents -type d -maxdepth 3 | sort
echo ""
echo "=== Check index.mjs file size and location ==="
ls -lh .agents/plugins/opencode-aidevops/index.mjsRepository: marcusquinn/aidevops
Length of output: 22515
🏁 Script executed:
#!/bin/bash
# Step 2: Examine the AGENT_MCP_TOOLS definition and surrounding code
echo "=== AGENT_MCP_TOOLS definition (lines 575-592) ==="
sed -n '575,592p' .agents/plugins/opencode-aidevops/index.mjs
echo ""
echo "=== applyAgentMcpTools function (around line 696-720) ==="
sed -n '696,720p' .agents/plugins/opencode-aidevops/index.mjs
echo ""
echo "=== relBase and agent discovery logic (lines 300-400) ==="
sed -n '300,400p' .agents/plugins/opencode-aidevops/index.mjs | head -80Repository: marcusquinn/aidevops
Length of output: 3361
🏁 Script executed:
#!/bin/bash
# Step 3: Check the join usage and relPath construction
echo "=== Checking import statements for path module ==="
head -30 .agents/plugins/opencode-aidevops/index.mjs | grep -E "import|require"
echo ""
echo "=== Searching for path.join or join usage around agent name construction ==="
sed -n '380,395p' .agents/plugins/opencode-aidevops/index.mjsRepository: marcusquinn/aidevops
Length of output: 909
🏁 Script executed:
#!/bin/bash
# Step 4: Search for actual agent markdown files and their locations
echo "=== Finding all .md files under .agents ==="
find .agents -name "*.md" -type f | sort
echo ""
echo "=== Checking if AGENT_MCP_TOOLS keys match existing agent files ==="
AGENT_KEYS="outscraper mainwp localwp quickfile google-search-console dataforseo claude-code playwriter shadcn macos-automator mac ios-simulator-mcp augment-context-engine context7 sentry socket"
for key in $AGENT_KEYS; do
if find .agents -name "${key}.md" -type f | grep -q .; then
echo "Found: $key"
find .agents -name "${key}.md" -type f
else
echo "NOT FOUND: $key"
fi
doneRepository: marcusquinn/aidevops
Length of output: 42690
AGENT_MCP_TOOLS keys will not match path-prefixed subagent names, silently breaking per-agent MCP tool permissions.
All agents in AGENT_MCP_TOOLS are located in subdirectories (e.g., .agents/tools/context/context7.md, .agents/tools/data-extraction/outscraper.md). With this change, they are registered with full relative paths (e.g., tools/context/context7, tools/data-extraction/outscraper), but AGENT_MCP_TOOLS keys remain simple basenames ("context7", "outscraper"). The lookup at line 702 (if (!config.agent[agentName]) continue;) will skip every agent because config.agent["context7"] won't exist—the agent is registered as config.agent["tools/context/context7"].
Additionally, path.join() uses OS-specific separators, creating cross-platform inconsistency (tools\context\context7 on Windows vs. tools/context/context7 on Unix).
Update AGENT_MCP_TOOLS keys to match the new path-based names, or add logic to resolve agents by basename when the full path lookup fails.
🧰 Tools
🪛 GitHub Check: Codacy Static Code Analysis
[failure] 384-384: .agents/plugins/opencode-aidevops/index.mjs#L384
Detected possible user input going into a path.join or path.resolve function.
🤖 Prompt for AI Agents
In @.agents/plugins/opencode-aidevops/index.mjs around lines 384 - 393, Agent
registration uses OS-specific join and stores agents under path-prefixed names
(agentName from relPath via join) which won't match AGENT_MCP_TOOLS simple
basenames and breaks the config.agent lookup; to fix, normalize agentName to use
POSIX separators (e.g., replace backslashes with '/') when building
relPath/agentName and update the lookup logic where config.agent[agentName] is
checked to fall back to the basename (use path.basename(agentName) or strip
directory prefix) if the full-path key is missing, or alternatively update
AGENT_MCP_TOOLS keys to their path-prefixed form to match agentName. Ensure
changes touch the relPath/agentName construction (join, relPath, agentName) and
the config.agent lookup to handle both normalized full paths and basenames.
|
Closing: t1018 is a duplicate of t1015 (same description — agent name collisions). t1015 PR #1311 is the canonical one. |



Summary
Fixed agent name collisions in the OpenCode plugin that caused 204 agents to be silently dropped.
Problem
The
loadAgentDefinitions()function usedbasename(file, ".md")as the agent name, causing collisions when multiple subdirectories contained files with the same name. For example:tools/git/github-cli.md→ registered asgithub-cliservices/git/github-cli.md→ also registered asgithub-cli(second one dropped)Solution
tools/git/github-cli)scripts/andtemplates/subdirs to the scanned directories listResults
Testing
Breakdown by Directory
Ref #1308
Summary by CodeRabbit