Skip to content

t1018: Fix agent name collisions in OpenCode plugin#1319

Closed
marcusquinn wants to merge 1 commit intomainfrom
feature/t1018
Closed

t1018: Fix agent name collisions in OpenCode plugin#1319
marcusquinn wants to merge 1 commit intomainfrom
feature/t1018

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Feb 12, 2026

Summary

Fixed agent name collisions in the OpenCode plugin that caused 204 agents to be silently dropped.

Problem

The loadAgentDefinitions() function used basename(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 as github-cli
  • services/git/github-cli.md → also registered as github-cli (second one dropped)

Solution

  1. Use relative paths as agent names for subagents (e.g., tools/git/github-cli)
  2. Keep simple names for root agents (backward compatibility)
  3. Added scripts/ and templates/ subdirs to the scanned directories list

Results

  • Before: ~341 agents loaded, 204 silently dropped due to collisions
  • After: 545 agents loaded, 0 collisions
  • New agents: 51 from scripts/, 8 from templates/

Testing

  • ✅ JavaScript syntax validation passed
  • ✅ Verified all 545 agents load without name collisions
  • ✅ No new ShellCheck violations introduced

Breakdown by Directory

  • tools: 309
  • scripts: 51 (newly added)
  • services: 42
  • content: 32
  • seo: 32
  • workflows: 32
  • aidevops: 26
  • root: 13
  • templates: 8 (newly added)

Ref #1308

Summary by CodeRabbit

  • Chores
    • Expanded agent discovery to include scripts and templates directories.
    • Updated agent naming convention to ensure uniqueness across nested directory structures.

- 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
@gemini-code-assist
Copy link

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

Walkthrough

Agent 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

Cohort / File(s) Summary
Agent Discovery Configuration
.agents/plugins/opencode-aidevops/index.mjs
Extended agent discovery to include scripts/ and templates/ subdirectories; shifted subagent naming from basename-only to full relative-path-based names to eliminate collision risks in hierarchical agent structures; root-level agent entries preserved with commentary additions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Possibly related PRs

Poem

🔍 Paths collide no more, dear agents find their way,
Through scripts and templates, in nested array,
From basename shadows to full-path clarity,
Agent discovery blooms with rare rarity! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ⚠️ Unable to check for merge conflicts: Failed to fetch base branch: From https://github.com/marcusquinn/aidevops
! [rejected] main -> main (non-fast-forward)
+ 186cd2e...d79265e main -> origin/main (forced update)
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing agent name collisions in the OpenCode plugin by implementing relative path-based naming for subagents.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/t1018
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch feature/t1018
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 0 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Thu Feb 12 22:42:35 UTC 2026: Code review monitoring started
Thu Feb 12 22:42:35 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 0

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 0
  • VULNERABILITIES: 0

Generated on: Thu Feb 12 22:42:38 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

@marcusquinn marcusquinn marked this pull request as ready for review February 12, 2026 22:45
@gemini-code-assist
Copy link

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟠 Major

Note: AGENT_MCP_TOOLS keys 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, and applyAgentMcpTools will 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.join produces OS-specific separators in agent names.

On Windows, join(relBase, entry.name) would yield tools\git\github-cli instead of tools/git/github-cli, making agent names platform-dependent. If cross-platform consistency matters, consider normalizing with .replace(/\\/g, '/') or using posix.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$/, "");

Comment on lines +384 to 393
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,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 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.mjs

Repository: 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 -80

Repository: 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.mjs

Repository: 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
done

Repository: 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.

@marcusquinn
Copy link
Owner Author

Closing: t1018 is a duplicate of t1015 (same description — agent name collisions). t1015 PR #1311 is the canonical one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant