Class: RailsAiContext::Install::AiTool

Inherits:
Struct
  • Object
show all
Defined in:
lib/rails_ai_context/install/ai_tool.rb,
lib/rails_ai_context/install/ai_tool.rb

Overview

What each AI tool means to this gem, in one table: what to call it, what context files it gets, where its MCP config lives and in what shape, and what it left behind in older releases. The generator, the rake task and the standalone CLI all asked these questions separately and answered them from copies that drifted.

Vocabulary per CONTEXT.md: "AI tool" for the assistant, "context files" for what the gem generates for it.

Constant Summary collapse

ALL =
[
  new(
    number: "1", key: :claude, name: "Claude Code",
    files: "CLAUDE.md + .claude/rules/",
    context_paths: %w[CLAUDE.md .claude/rules],
    mcp_config: { path: ".mcp.json", root_key: "mcpServers", format: :mcp_json },
    legacy_paths: [ ".claude/rules/rails-ui-patterns.md", ".claude/rules/rails-accessibility.md" ]
  ),
  new(
    number: "2", key: :cursor, name: "Cursor",
    files: ".cursor/rules/ + .cursorrules (legacy fallback)",
    context_paths: %w[.cursor/rules .cursorrules],
    mcp_config: { path: ".cursor/mcp.json", root_key: "mcpServers", format: :mcp_json },
    legacy_paths: [ ".cursor/rules/rails-ui-patterns.mdc" ]
  ),
  new(
    number: "3", key: :copilot, name: "GitHub Copilot",
    files: ".github/copilot-instructions.md + .github/instructions/",
    context_paths: %w[.github/copilot-instructions.md .github/instructions],
    mcp_config: { path: ".vscode/mcp.json", root_key: "servers", format: :vscode_json },
    legacy_paths: [ ".github/instructions/rails-ui-patterns.instructions.md" ]
  ),
  new(
    number: "4", key: :opencode, name: "OpenCode",
    files: "AGENTS.md",
    context_paths: %w[AGENTS.md app/models/AGENTS.md app/controllers/AGENTS.md],
    mcp_config: { path: "opencode.json", root_key: "mcp", format: :opencode_json },
    legacy_paths: []
  ),
  new(
    number: "5", key: :codex, name: "Codex CLI",
    files: "AGENTS.md + .codex/config.toml",
    context_paths: %w[AGENTS.md app/models/AGENTS.md app/controllers/AGENTS.md],
    mcp_config: { path: ".codex/config.toml", root_key: nil, format: :codex_toml },
    legacy_paths: []
  )
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#context_pathsObject

Returns the value of attribute context_paths

Returns:

  • (Object)

    the current value of context_paths



13
14
15
# File 'lib/rails_ai_context/install/ai_tool.rb', line 13

def context_paths
  @context_paths
end

#filesObject

Returns the value of attribute files

Returns:

  • (Object)

    the current value of files



13
14
15
# File 'lib/rails_ai_context/install/ai_tool.rb', line 13

def files
  @files
end

#keyObject

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



13
14
15
# File 'lib/rails_ai_context/install/ai_tool.rb', line 13

def key
  @key
end

#legacy_pathsObject

Returns the value of attribute legacy_paths

Returns:

  • (Object)

    the current value of legacy_paths



13
14
15
# File 'lib/rails_ai_context/install/ai_tool.rb', line 13

def legacy_paths
  @legacy_paths
end

#mcp_configObject

Returns the value of attribute mcp_config

Returns:

  • (Object)

    the current value of mcp_config



13
14
15
# File 'lib/rails_ai_context/install/ai_tool.rb', line 13

def mcp_config
  @mcp_config
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



13
14
15
# File 'lib/rails_ai_context/install/ai_tool.rb', line 13

def name
  @name
end

#numberObject

Returns the value of attribute number

Returns:

  • (Object)

    the current value of number



13
14
15
# File 'lib/rails_ai_context/install/ai_tool.rb', line 13

def number
  @number
end

Class Method Details

.allObject



56
57
58
# File 'lib/rails_ai_context/install/ai_tool.rb', line 56

def all
  ALL
end

.find(key) ⇒ Object



60
61
62
63
# File 'lib/rails_ai_context/install/ai_tool.rb', line 60

def find(key)
  key = key.to_sym if key.respond_to?(:to_sym)
  ALL.find { |tool| tool.key == key }
end

.legacy_filesObject



69
70
71
# File 'lib/rails_ai_context/install/ai_tool.rb', line 69

def legacy_files
  ALL.flat_map { |tool| tool.legacy_paths.map { |path| { path: path, ai_tool: tool.key } } }
end

.mcp_configs_by_keyObject



65
66
67
# File 'lib/rails_ai_context/install/ai_tool.rb', line 65

def mcp_configs_by_key
  ALL.to_h { |tool| [ tool.key, tool.mcp_config ] }
end