redmine_ai_helper
Copilot instructions106 starsChanged 10 months agoMITView on GitHub
This is a Redmine plugin that adds AI-powered chat functionality using a multi-agent architecture backed by RubyLLM for LLM interactions. The plugin extends Redmine's Rails application with specialized agents for different domains. Automatic Registration: - All agents inherit from BaseAgent (lib/redmine_ai_helper/base_agent.rb) - Agent classes auto-register via inherited hook when loaded — no manual registration needed - LeaderAgent coordinates multi-step tasks by routing to specialized agents Key Agents: - Domain-specific: IssueReadAgent, RepositoryAgent, WikiAgent, ProjectAgent, BoardAgent, SystemAgent, UserAgent, VersionAgent, DocumentationAgent - Issue…
In this repository46 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- commitSkill
- create-pull-requestSkill
- create-release-branchSkill
- create-release-notesSkill
- qlty-checkSkill
- recreate-test-dbSkill
- redmine-playwright-loginSkill
- regression-checkSkill
- rubocopSkill
- speckit-agent-context-updateSkill
- speckit-analyzeSkill
- speckit-branch-convention-configureSkill
- speckit-branch-convention-renameSkill
- speckit-branch-convention-validateSkill
- speckit-checklistSkill
- speckit-clarifySkill
- speckit-constitutionSkill
- speckit-convergeSkill
- speckit-git-commitSkill
- speckit-git-featureSkill
- speckit-git-initializeSkill
- speckit-git-remoteSkill
- speckit-git-validateSkill
- speckit-implementSkill
- speckit-planSkill
- speckit-review-codeSkill
- speckit-review-commentsSkill
- speckit-review-errorsSkill
- speckit-review-runSkill
- speckit-review-simplifySkill
- speckit-review-testsSkill
- speckit-review-typesSkill
- speckit-specifySkill
- speckit-tasksSkill
- speckit-taskstoissuesSkill
- speckit-token-budget-compactSkill
- speckit-token-budget-conciseSkill
- speckit-token-budget-scopeSkill
- speckit-token-budget-usageSkill
- speckit-wiki-ingestSkill
- speckit-wiki-initSkill
- speckit-wiki-lintSkill
- speckit-wiki-querySkill
- speckit-wiki-statusSkill
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
24 rules. About 0 are common, 13 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 22
All agents inherit from BaseAgent (lib/redmine_ai_helper/base_agent.rb)
- Distinctive: line 71
Write source code comments in English
- Very specific: line 72
All user-facing text must support i18n (use config/locales/*.yml)
- Distinctive: line 74
Do not include any information about Claude Code in commit messages
- Distinctive: line 79
Follow design documents exactly for architecture, file locations, method placement, APIs, and test locations
- Distinctive: line 80
If you believe the design has issues, ASK THE USER FIRST before implementing differently
- Distinctive: line 86
Red: Write a failing test first that describes the expected behavior
- Distinctive: line 87
Green: Write the minimum code necessary to make the test pass
- Distinctive: line 92
When fixing a bug, first write a test that reproduces the bug, then fix it
- Distinctive: line 93
When adding a feature, write tests for the feature first, then implement
- Distinctive: line 94
Run tests frequently during development to ensure nothing breaks
- Very specific: line 127
Use shoulda (context/should blocks), not rspec
- Very specific: line 128
Use mocha for mocking - but only when connecting to external servers
- Very specific: line 134
Use model_factory.rb for creating test fixtures
- Distinctive: line 137
Follow Ruby on Rails conventions
- Distinctive: line 138
Write comments in English
- Very specific: line 139
Use ai_helper_logger for logging, never Rails.logger
- Very specific: line 142
Use let and const, not var
- Distinctive: line 149
Use proper error logging, but never silently continue with fallback behavior
- Distinctive: line 154
No custom colors or fonts — use Redmine's class definitions and design system
- Very specific: line 155
Use Redmine's .box class for container elements
- Very specific: line 199
Create lib/redmine_ai_helper/agents/your_agent.rb inheriting from BaseAgent
- Very specific: line 201
Create corresponding tools class in lib/redmine_ai_helper/tools/
- Very specific: line 229
Use sprite_icon helper for icons, t() / l() for i18n text in templates
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Redmine AI Helper Plugin - AI Coding Instructions
Project Architecture
This is a Redmine plugin that adds AI-powered chat functionality using a multi-agent architecture backed by RubyLLM for LLM interactions. The plugin extends Redmine's Rails application with specialized agents for different domains.
Request Flow
Controller (AiHelperController)
→ RedmineAiHelper::Llm # Entry point from controllers, creates Langfuse trace
→ LeaderAgent#perform_user_request # Generates goal, steps, coordinates agents
→ BaseAgent#chat # Direct RubyLLM.chat (no tools)
→ BaseAgent#assistant # AssistantProvider → RubyLLM::Chat with tools
→ LlmProvider.get_llm_provider # Returns OpenAI/Anthropic/Gemini/Azure/Compatible
→ Provider#create_chat # Configures and returns RubyLLM::Chat instanceMulti-Agent System
Automatic Registration:
- All agents inherit from
BaseAgent(lib/redmine_ai_helper/base_agent.rb) - Agent classes auto-register via
inheritedhook when loaded — no manual registration needed LeaderAgentcoordinates multi-step tasks by routing to specialized agents
Key Agents:
- Domain-specific:
IssueReadAgent,RepositoryAgent,WikiAgent,ProjectAgent,BoardAgent,SystemAgent,UserAgent,VersionAgent,DocumentationAgent - Issue updates:
IssueWriteAgent - Coordination:
LeaderAgent - Dynamic MCP integration:
McpAgent(generatesSubMcpAgentclasses per MCP server)
Tool System
Tools are defined via a DSL in BaseTools subclasses that generates RubyLLM::Tool subclasses:
class MyTools < RedmineAiHelper::BaseTools
define_function :do_something, description: "Does something" do
property :input, type: "string", description: "The input", required: true
end
def do_something(input:)
# implementation
end
endAgents expose tools by overriding available_tool_providers to return an array of BaseTools subclasses (e.g. [MyTools]). The base available_tool_classes method then calls available_tool_providers and expands each provider via .tool_classes, returning a flat array of RubyLLM::Tool subclasses passed to RubyLLM::Chat#with_tools.
LLM Providers
lib/redmine_ai_helper/llm_client/ — each provider subclass implements configure_ruby_llm (sets API keys) and optionally overrides create_chat. Supported: OpenAI, Anthropic, Gemini, Azure OpenAI, OpenAI-compatible.
Langfuse Observability
LangfuseWrappermanages traces and spans at the orchestration level (Llmclass)BaseAgent#setup_langfuse_callbacksregisterson_end_messagecallbacks onRubyLLM::Chatinstances to create Langfuse generations with token usage- Configuration:
config/ai_helper/config.yml
Streaming
AiHelper::Streaming concern provides SSE streaming via stream_llm_response. Agents accept a stream_proc callback for incremental content delivery.
Custom Commands
Users define reusable commands (global/project/user scoped) stored in AiHelperCustomCommand. CustomCommandExpander expands /command_name input syntax with template variables ({input}, {user_name}, {project_name}, {datetime}).
Development Conventions
Code Comments & Messages:
- Write source code comments in English
- All user-facing text must support i18n (use
config/locales/*.yml) - Git commit messages in English
- Do not include any information about Claude Code in commit messages
Design Document Adherence:
CRITICAL: Design documents in specs/ directory are AUTHORITATIVE and MANDATORY.
- NEVER deviate from design documents without explicit user approval
- Follow design documents exactly for architecture, file locations, method placement, APIs, and test locations
- If you believe the design has issues, ASK THE USER FIRST before implementing differently
Test-Driven Development (TDD): This project follows Test-Driven Development. Always write tests BEFORE implementing features.
TDD Workflow:
- Red: Write a failing test first that describes the expected behavior
- Green: Write the minimum code necessary to make the test pass
- Refactor: Improve the code while keeping tests green
TDD Rules:
- Never write production code without a failing test first
- When fixing a bug, first write a test that reproduces the bug, then fix it
- When adding a feature, write tests for the feature first, then implement
- Run tests frequently during development to ensure nothing breaks
Testing with Shoulda:
class SomeTest < ActiveSupport::TestCase
context "method_name" do
should "describe expected behavior" do
# test implementation
end
end
endRunning Tests:
# Run all plugin tests
bundle exec rake redmine:plugins:test NAME=redmine_ai_helper
# Run a single test file
bundle exec ruby -I"lib:test" plugins/redmine_ai_helper/test/unit/base_agent_test.rb
# Run tests matching a pattern
bundle exec rake redmine:plugins:test NAME=redmine_ai_helper TESTOPTS="--name=/test_name_pattern/"
# Setup test environment (first time only)
bundle exec rake redmine:plugins:migrate RAILS_ENV=test
bundle exec rake redmine:plugins:ai_helper:setup_scm
# YARD documentation coverage
yard stats --list-undocTesting Guidelines:
- Use
shoulda(context/should blocks), not rspec - Use
mochafor mocking - but only when connecting to external servers - Aim for test coverage of 95% or higher (check
coverage/directory) - Test structure:
test/functional/- Controller teststest/unit/- Model, agent, and tool teststest/integration/- API and integration tests
- Use
model_factory.rbfor creating test fixtures
Code Style (Ruby):
- Follow Ruby on Rails conventions
- Write comments in English
- Use
ai_helper_loggerfor logging, neverRails.logger
Code Style (JavaScript):
- Use
letandconst, notvar - Vanilla JavaScript only, no jQuery
- Write comments in English
Error Handling:
- NEVER implement fallback error handling — fallbacks hide real problems
- Let errors surface immediately for proper diagnosis
- Use proper error logging, but never silently continue with fallback behavior
- Custom logger:
RedmineAiHelper::Loggermixin - Graceful degradation when AI services unavailable
CSS:
- No custom colors or fonts — use Redmine's class definitions and design system
- Use Redmine's
.boxclass for container elements
File Structure Patterns:
- Controllers:
app/controllers/ai_helper_*.rb - Models:
app/models/ai_helper_*.rb - Agents:
lib/redmine_ai_helper/agents/*_agent.rb - Tools:
lib/redmine_ai_helper/tools/*_tools.rb - Tests:
test/unit/andtest/functional/
Key Integration Points
Redmine Plugin Hooks:
init.rb- Plugin registration and permission setuplib/redmine_ai_helper/view_hook.rb- UI integration points- Patches:
*_patch.rbfiles extend Redmine core classes
Vector Search (Qdrant):
- Issue/wiki content embeddings in
AiHelperVectorDatamodel - Vector operations in
lib/redmine_ai_helper/vector/ - Setup via rake tasks:
redmine:plugins:ai_helper:*
MCP (Model Context Protocol):
- Dynamic agent generation per MCP server configuration
- Transport layer supports STDIO and HTTP+SSE
- Configuration in
config/ai_helper/mcp_servers/ - MCP servers configured in
config/ai_helper/config.json McpServerLoaderauto-generatesSubMcpAgentclasses per server
Development Workflows
Testing Setup:
# Setup test environment
bundle exec rake redmine:plugins:migrate RAILS_ENV=test
bundle exec rake redmine:plugins:ai_helper:setup_scm
# Run all plugin tests
bundle exec rake redmine:plugins:test NAME=redmine_ai_helper
# Run migrations
bundle exec rake redmine:plugins:migrate RAILS_ENV=productionAdding New Agents:
- Create
lib/redmine_ai_helper/agents/your_agent.rbinheriting fromBaseAgent - Implement required methods:
backstory,available_tool_providers - Create corresponding tools class in
lib/redmine_ai_helper/tools/ - Agent auto-registers via inheritance hook
- See
example/redmine_fortune/for a complete example
Configuration Management:
- Global settings:
AiHelperSettingmodel - Project settings:
AiHelperProjectSettingmodel - Model profiles:
AiHelperModelProfilefor different LLM configs - Plugin config:
config/config.yaml.example
Key Components
lib/redmine_ai_helper/llm.rb— Entry point from controllers, wraps all agent calls with Langfuse traceslib/redmine_ai_helper/base_agent.rb— Agent base class:chat,assistant,perform_task,setup_langfuse_callbackslib/redmine_ai_helper/base_tools.rb— Tool DSL:define_function/property/item→RubyLLM::Toolgenerationlib/redmine_ai_helper/assistant.rb— WrapsRubyLLM::Chatwith unified interface (add_message,run,messages)lib/redmine_ai_helper/assistant_provider.rb— Factory: creates Assistant from LLM provider + instructions + toolsapp/controllers/ai_helper_controller.rb— Main controller with streaming supportassets/prompt_templates/— Internationalized YAML prompt templates (EN/JP)config/ai_helper/config.json— MCP server configurationconfig/ai_helper/config.yml— Langfuse configuration
Critical Implementation Details
Frontend Security:
- Build HTML structures in ERB templates (
*.html.erb), not in JavaScript - This prevents XSS and JS injection vulnerabilities by leveraging Rails' automatic escaping
- JavaScript should only manipulate existing DOM elements rendered by ERB
- Use
sprite_iconhelper for icons,t()/l()for i18n text in templates
Langfuse Integration:
LangfuseWrappermanages traces and spans at the orchestration level (Llmclass)BaseAgent#setup_langfuse_callbacksregisterson_end_messagecallbacks onRubyLLM::Chatinstances to create Langfuse generations with token usage- LLM observability for all providers via
langfuse_util/ - Trace conversations and agent interactions
- Configuration:
config/ai_helper/config.yml
Memory Management:
- Conversations stored in
AiHelperConversation/AiHelperMessagemodels - Summary caching in
AiHelperSummaryCacheto avoid re-computation - Vector data cleanup via scheduled tasks
Error Handling:
- NEVER implement fallback error handling — fallbacks hide real problems
- Let errors surface immediately for proper diagnosis
- Use proper error logging, but never silently continue with fallback behavior
- Custom logger:
RedmineAiHelper::Loggermixin - Graceful degradation when AI services unavailable
<!-- SPECKIT START -->For additional context about technologies to be used, project structure, shell commands, and other important information, read the current plan
<!-- SPECKIT END -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

