Project

General

Profile

Plugins Directory » Redmine AI Assistant

Author: Carol Jack
Website: https://github.com/carolcoral/
Code repository: https://github.com/carolcoral/redmine_ai_assistant
Registered on: 2026-07-29 (22 days ago)
Current version: 1.1.0
Compatible with: Redmine 7.1.x, 7.0.x, 6.1.x
User ratings:   (0)

  1. Redmine AI Assistant

AI-powered intelligent assistant plugin for Redmine, providing floating chat widget, automated work report generation, and multi-provider AI support.

  1. Features

- Floating Chat Widget: A draggable AI chat bubble in the bottom-right corner of every page, supporting natural language conversations
- Work Report Generation: One-click generation of daily/weekly/monthly reports based on user activity data (time entries, issue assignments, status changes, comments, wiki updates)
- Multi-Provider AI Support: Supports multiple AI service providers with a unified interface, compatible with OpenAI-style APIs
- Read-Only Guard Prompt: Automatically restricts AI to analysis-only mode when business data is involved, preventing accidental or malicious data modification suggestions
- Custom System Prompt: Administrators can define system-level prompt constraints via plugin settings
- Customizable Icon: Supports custom floating icon images (PNG/JPG/GIF/APNG/SVG), with auto-play for animated formats
- Conversation History: Persistent chat history with configurable context window size
- Smart Data Injection: Automatically detects task/report-related queries and injects real Redmine issue data as context
- Issue Hyperlinks: All issue references in reports and chat are rendered as clickable links that navigate directly to the issue detail page
- Version & Progress Tracking: Reports include version grouping analysis, progress percentages, due date alerts, and overdue issue detection
- Dynamic System Name: Uses the actual application name from `Setting.app_title` instead of hardcoded "Redmine"

  1. Requirements

- Redmine >= 6.1.0
- Ruby >= 3.2.0
- At least one AI service provider (OpenAI-compatible API)

Installation notes

  1. Installation

1. Copy the plugin directory into `plugins/redmine_ai_assistant`

2. Run database migrations:

```bash
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
```

3. Restart Redmine

4. Go to AdministrationPluginsRedmine AI AssistantConfigure to enable the plugin

  1. Configuration
  1. Plugin Settings

Go to AdministrationPluginsRedmine AI AssistantConfigure:

Setting Default Description
--- --- ---
Enable AI Assistant Off Enables the floating chat widget for logged-in users
Default AI Provider (None) The default AI service provider for chat and reports
Enable Read-Only Guard Prompt On Restricts AI to analysis-only mode when business data is involved
Custom System Prompt (Empty) Custom prompt injected before every AI call to control behavior
Max History Messages 20 Number of previous messages to include in conversation context (1-50)
Report Timezone (Empty) Timezone for report period calculation
Custom Pet Image URL (Empty) Custom floating icon image URL (supports PNG/JPG/GIF/APNG/WebP/SVG)
Icon Size 60 Floating button size in pixels (40-120)
  1. AI Service Providers

Go to AdministrationAI Service Providers to configure AI backends.

Provider Types:
- `tdp`: TDP platform integrated provider
- `custom`: Any OpenAI-compatible API (e.g., OpenAI, Ollama, vLLM, local LLM)

Required Fields:
- Name: Display name
- Slug: Unique identifier (lowercase letters, digits, hyphens, underscores)
- Provider Type: `tdp` or `custom`
- API URL: Full base URL (e.g., `https://api.openai.com/v1`)
- API Key: Authentication key (encrypted at rest)
- Default Model: Model name (e.g., `gpt-4o-mini`)

Optional Fields:
- Available Models: JSON array of model names — use the "Auto Fetch" button to retrieve from the API
- Extra Settings: JSON object for provider-specific parameters (e.g., top_p, frequency_penalty)

  1. Permissions

Three permissions control access:

Permission Access Description
--- --- ---
Manage AI Providers Admin only CRUD and enable/disable AI providers
Use AI Chat Logged-in users Access the floating chat widget
Generate AI Reports Logged-in users Generate work reports
  1. Usage
  1. AI Chat

1. Click the floating icon in the bottom-right corner to open the chat panel
2. Type questions about your projects, tasks, or time entries
3. The assistant will automatically pull relevant Redmine data when you ask task-related questions
4. Use the quick-action buttons for one-click task summary or recent activity

Trigger keywords (at least 2 needed to trigger data injection): task, issue, status, priority, progress, version, due date, overdue, report, summary, today, week, month, 任务, 项目, etc.

  1. Work Reports

Reports are generated via API endpoints or triggered from the chat widget. The generator collects:

- Time Entries: Hours logged with project, issue, and activity details
- Issues Assigned: New tasks assigned during the report period
- Issue Change History: Full timeline of status/priority/assignee changes during the period
- Issues Closed: Tasks completed during the period
- Status Summary: Distribution of open issues by status
- Overdue Issues: Tasks past their due date but not yet closed
- Comments: Notes written on issues, wiki pages, documents
- Wiki Updates: Pages edited during the period

Reports are generated in Markdown format with structured sections, summarized via AI for readability.

  1. Architecture

```
redmine_ai_assistant/
├── init.rb # Plugin registration, permissions, settings
├── config/
│ ├── routes.rb # API routes
│ └── locales/ # i18n (zh.yml, en.yml)
├── app/
│ ├── controllers/ai_assistant/
│ │ ├── chat_controller.rb # Chat send/history/clear APIs
│ │ ├── reports_controller.rb # Report generation APIs
│ │ └── providers_controller.rb # Provider CRUD (admin)
│ ├── models/ai_assistant/
│ │ ├── ai_provider.rb # AI service provider model
│ │ └── ai_message.rb # Chat message persistence
│ └── views/ai_assistant/
│ ├── chat/_widget.html.erb # Floating widget HTML
│ ├── chat/_head_tags.html.erb # CSS/JS resource injection
│ └── providers/ # Provider management views
├── assets/
│ └── {javascripts,stylesheets}/ai_assistant/
│ ├── chat_widget_controller.js # ~770 lines, vanilla JS chat widget
│ └── chat_widget.css # ~725 lines, styled chat UI
├── lib/ai_assistant/
│ ├── ai_client.rb # Unified OpenAI-compatible API client
│ ├── guard_prompt.rb # Read-only guard prompt injection
│ ├── report_generator.rb # Work report data collection & AI generation (~580 lines)
│ └── hooks.rb # Redmine view hooks
└── db/migrate/ # Database schema migrations
```

  1. Key Components

`ai_client.rb` — Multi-provider HTTP client supporting all OpenAI-compatible APIs. Handles request building, timeout management, response parsing, error classification, and post-processing (including automatic issue ID linkification).

`guard_prompt.rb` — When business data keywords are detected in the conversation, injects a read-only constraint into the system prompt. Uses `Setting.app_title` for dynamic system name.

`report_generator.rb` — Core report engine:
- Computes report date range based on type (daily/weekly/monthly) and optional period offset
- Queries user's time entries, assigned issues, change history, closed issues, comments, wiki updates
- Status Summary: Groups open issues by status with counts and percentages
- Overdue Detection: Finds issues past `due_date` but not yet closed
- Version Grouping: Includes `fixed_version` name in issue data for version-level analysis
- Formats all data into structured Markdown for AI consumption
- All issue IDs are rendered as clickable Markdown links (`[#ID](url)`)

`chat_widget_controller.js` — Pure vanilla JavaScript chat widget:
- Draggable floating button with open/close toggle
- Markdown rendering with syntax highlighting, table support, and link handling
- Quick question templates for common queries
- Conversation history loading and new conversation controls
- Turbo/Turbolinks compatibility with proper event listener cleanup
- Debounce protection against duplicate initialization from multiple page load events

  1. API Reference

All API endpoints require authentication.

  1. Chat
Method Endpoint Description
--- --- ---
POST `/ai_assistant/chat/send_message` Send a message and get AI response
GET `/ai_assistant/chat/history` Get conversation history
GET `/ai_assistant/chat/clear` Clear a conversation

Send Message request body:
```json {
"message": "What are my tasks today?",
"conversation_id": "optional-conversation-uuid"
}
```

Send Message response:
```json {
"conversation_id": "uuid",
"message": {
"id": 42,
"role": "assistant",
"content": "Markdown formatted response...",
"tokens_used": 1234
}
}
```

  1. Reports
Method Endpoint Description
--- --- ---
GET `/ai_assistant/reports/daily` Generate today's daily report
GET `/ai_assistant/reports/weekly` Generate this week's weekly report
GET `/ai_assistant/reports/monthly` Generate this month's monthly report
POST `/ai_assistant/reports/generate` Generate a custom report

Generate Report request body:
```json {
"report_type": "weekly",
"period_offset": "-1",
"provider_id": "optional-provider-id"
}
```

`period_offset`: `0` = current period, `-1` = previous period (yesterday/last week/last month).

  1. Database Schema
  1. `ai_providers`
Column Type Description
--- --- ---
`name` string Provider display name
`slug` string Unique identifier
`provider_type` string `tdp` or `custom`
`api_url` string API base URL
`api_key` text Encrypted API key
`default_model` string Default model name
`available_models` text JSON array of model names
`settings` text JSON extra configuration
`is_enabled` boolean Enabled status (default true)
`is_builtin` boolean Whether built-in (default false)
`position` integer Sort order (default 0)
  1. `ai_messages`
Column Type Description
--- --- ---
`user_id` integer User reference
`ai_provider_id` integer AI provider reference
`conversation_id` string Conversation group ID
`role` string `user` or `assistant`
`content` text Message content
`model` string AI model used
`tokens_used` integer Token consumption
`report_type` string `daily`, `weekly`, or `monthly` (for reports)
`ai_provider` string Provider name snapshot
  1. Development
  1. Adding a New AI Provider

1. Go to AdministrationAI Service ProvidersNew Provider
2. Fill in the API URL and key for any OpenAI-compatible service
3. Set as default in Plugin Settings if desired

  1. Extending Report Data

The `ReportGenerator#collect_data` method returns a hash of all collected data. To add new data sources:

1. Add a new `fetch_*` method in `report_generator.rb`
2. Include the new key in `collect_data`
3. Add the corresponding section in `build_user_prompt`
4. Update `build_system_prompt` with guidelines for the new data

  1. Customizing the System Prompt

Use the Custom System Prompt setting in plugin configuration to inject custom rules. This prompt is prepended to every AI call (both chat and reports), allowing you to:
- Restrict AI to answer only within certain domains
- Define output format conventions
- Enforce company-specific policies

Changelog

1.1.0 (2026-07-30)

Compatible with Redmine 7.1.x, 7.0.x, 6.1.x.

  1. [1.1.0] — 2026-07-31
  1. Added (新增)
  1. AI 能力核心枢纽 (AI Capability Hub)

- 模块级公开 API (`AiAssistant`) — 一行调用即可完成 AI 对话,自动解析服务商、处理认证与错误。
- `AiAssistant.chat` / `AiAssistant.chat_stream` / `AiAssistant.chat_messages`
- `AiAssistant.enabled?` / `AiAssistant.ready?` / `AiAssistant.available_providers` / `AiAssistant.default_provider`
- Mixin 混入模块 (`AiAssistant::Mixins::AiCapable`) — 其他 Redmine 插件通过 `include` 即可零配置获得 AI 能力。
- 提供 `ai_chat` / `ai_chat_messages` / `ai_chat_stream` / `ai_ready?` 方法
- 流式响应支持 (SSE) — 基于 Server-Sent Events 的 `chat_stream` 回调接口
- 向后兼容 — 保留原始 `AiClient` 类作为薄封装

  1. 端点用户功能 (End-User Features)

- 悬浮聊天组件 — 右下角可拖拽的 AI 对话气泡
- Markdown 渲染、语法高亮、表格支持
- 对话历史持久化,可配置上下文窗口大小
- 快捷提问模板(一键发送常用查询)
- 工作报告生成 — 一键生成日报 / 周报 / 月报
- 基于真实活动数据:工时记录、任务变更、评论、Wiki 更新
- AI 总结为结构化 Markdown 文档
- 智能数据注入 — 自动检测任务/报告类查询,将真实 Redmine Issue 数据作为上下文注入
- 支持 `#123` 任务编号引用
- 关键词触发(任务、问题、状态、优先级等)

  1. 管理员功能 (Admin Features)

- 多服务商管理 — 配置多个 AI 后端
- 支持 `tdp`(TDP 平台集成)和 `custom`(任意 OpenAI 兼容接口)
- 兼容 OpenAI、DeepSeek、Ollama、vLLM 等
- 一键自动获取可用模型列表
- 只读守卫提示 (`GuardPrompt`) — 涉及业务数据时自动限制 AI 为只读分析模式
- 自定义系统提示词 — 定义组织级 AI 行为规范
- 用量统计仪表板 — 按用户统计 Token 消耗量和调用次数
- CSV / PDF 导出功能
- API 密钥加密 — 采用 AES-256-CBC 加密存储服务商凭证

1.0.0 (2026-07-17)

Compatible with Redmine 7.1.x, 7.0.x, 6.1.x.