Module: BundlerSkills::AgentRegistry
- Defined in:
- lib/bundler_skills/agent_registry.rb
Overview
Knows where each supported agent reads project-level skills and how to detect that the agent is in use. Dependency-free: a small internal table, the single place to edit when an agent’s convention changes.
Output dirs collapse to two in practice:
.claude/skills — Claude Code only (does not read .agents/skills yet)
.agents/skills — cross-tool standard, shared by Cursor / Codex / Copilot
Defined Under Namespace
Classes: Agent
Constant Summary collapse
- ALL =
[ Agent.new(key: "claude", skills_subdir: ".claude/skills", markers: [".claude"]), Agent.new(key: "cursor", skills_subdir: ".agents/skills", markers: [".cursor"]), Agent.new(key: "codex", skills_subdir: ".agents/skills", markers: [".codex", "AGENTS.md"]), Agent.new(key: "copilot", skills_subdir: ".agents/skills", markers: [".github"]) ].freeze
Class Method Summary collapse
- .all ⇒ Object
-
.detect(root) ⇒ Object
Agents whose marker exists under root.
- .find(key) ⇒ Object
-
.output_subdirs(agents) ⇒ Object
Distinct output subdirs for the given agents, preserving order.
- .present?(root, agent) ⇒ Boolean
-
.resolve(root, config) ⇒ Object
Resolve the agents to target: config.agents nil -> auto-detect by markers config.agents [“*”] -> all agents config.agents [keys..] -> those keys (unknown keys ignored).
Class Method Details
.all ⇒ Object
26 27 28 |
# File 'lib/bundler_skills/agent_registry.rb', line 26 def all ALL end |
.detect(root) ⇒ Object
Agents whose marker exists under root.
35 36 37 |
# File 'lib/bundler_skills/agent_registry.rb', line 35 def detect(root) ALL.select { |agent| present?(root, agent) } end |
.find(key) ⇒ Object
30 31 32 |
# File 'lib/bundler_skills/agent_registry.rb', line 30 def find(key) ALL.find { |a| a.key == key.to_s } end |
.output_subdirs(agents) ⇒ Object
Distinct output subdirs for the given agents, preserving order.
54 55 56 |
# File 'lib/bundler_skills/agent_registry.rb', line 54 def output_subdirs(agents) agents.map(&:skills_subdir).uniq end |
.present?(root, agent) ⇒ Boolean
58 59 60 |
# File 'lib/bundler_skills/agent_registry.rb', line 58 def present?(root, agent) agent.markers.any? { |m| File.exist?(File.join(root.to_s, m)) } end |
.resolve(root, config) ⇒ Object
Resolve the agents to target:
config.agents nil -> auto-detect by markers
config.agents ["*"] -> all agents
config.agents [keys..] -> those keys (unknown keys ignored)
43 44 45 46 47 48 49 50 51 |
# File 'lib/bundler_skills/agent_registry.rb', line 43 def resolve(root, config) requested = config.agents return detect(root) if requested.nil? || requested.empty? keys = Array(requested).map(&:to_s) return all if keys.include?("*") keys.filter_map { |key| find(key) } end |