feat(ai): Built-in Claude AI Assistant (mokogitea-claude[bot]) #359

Open
opened 2026-05-31 16:11:52 +00:00 by jmiller · 3 comments
Owner

Summary

Build Claude AI directly into MokoGitea as a first-class platform feature — not a plugin, not an external service, not a workflow hack. It ships with the fork the same way mokogitea-actions[bot] ships with Actions support.

This Is a Built-In Feature

Like Gitea Actions is built into Gitea, Claude AI is built into MokoGitea:

  • System bot: mokogitea-claude[bot] (auto-provisioned at install)
  • Admin settings: Site Administration > AI Configuration
  • Org settings: Org Settings > AI Integration
  • Repo settings: Repo Settings > AI Assistant
  • UI elements: native buttons, comment styling, assignee integration
  • No external services to deploy separately

Feature Set

PR Smart Comments (automatic)

  • Auto-summary on PR open (what changed, risk areas)
  • Inline review comments (bugs, security, style)
  • Suggestion blocks with code fixes
  • Risk labels auto-applied (review: low-risk / review: needs-attention)
  • Responds to review feedback and pushes fix commits

Interactive Chat (@mention)

  • @mokogitea-claude in any issue/PR comment
  • Context-aware: reads issue, diff, linked files, repo conventions
  • Can answer questions, explain code, suggest approaches
  • Maintains conversation context within a thread

Coding Agent (assign/label)

  • Assign issue to mokogitea-claude[bot] or label ai:implement
  • Bot creates dev/ branch, implements changes, runs tests
  • Opens PR linking back to issue
  • Iterates on review feedback until approved

Code Search / Explain

  • "Explain this file" button in code view
  • AI-powered code search (semantic, not just text matching)
  • Inline documentation generation

Architecture (Internal to MokoGitea)

This runs inside the MokoGitea process — no sidecar, no separate container, no external webhook receiver. The AI service is just another internal service like notifications or actions.

Settings Hierarchy

Site Administration > AI

  • Default Anthropic API key (platform-wide fallback)
  • Default model
  • Global rate limits
  • Enable/disable AI features site-wide
  • Usage dashboard (all orgs)

Org Settings > AI Integration

  • Org API key (overrides site default)
  • Model selection per org
  • Rate limit per org (requests/hour, tokens/month)
  • Enable/disable per org
  • Add mokogitea-claude[bot] to teams
  • Usage/cost dashboard for org

Repo Settings > AI Assistant

  • Enable/disable for this repo
  • Review strictness: minimal / standard / thorough
  • Auto-review on PR open: yes/no
  • Files to ignore (.claude-review-ignore)
  • Custom instructions (uses CLAUDE.md in repo root)

Security Model

  • Org isolation: bot only accesses repos where it has team membership
  • Branch protection: bot respects existing branch rules (can only push to dev/*)
  • Secrets: .env, credentials excluded from AI context
  • Rate limiting: per-org token budgets prevent runaway costs
  • Audit log: all AI actions logged (who triggered, what it did, tokens used)

Permission Tiers

  • PR Review (read-only): reads code, posts comments
  • Answer question (read-only): reads code, posts response
  • Fix issue (write): reads code, pushes commits to dev/ branches
  • Create feature (write): full implementation, opens PRs

Database Schema

New tables:

  • ai_org_settings (org_id, api_key_encrypted, model, enabled, rate_limit)
  • ai_repo_settings (repo_id, enabled, strictness, auto_review, ignore_patterns)
  • ai_usage_log (id, org_id, repo_id, action_type, tokens_in, tokens_out, model, created_at)
  • ai_conversations (id, issue_id, messages_json, created_at, updated_at)

Sub-Issues

  • #362 — mokogitea-claude[bot] system user (provisioning, permissions, badge)
  • TBD — AI settings UI (site/org/repo admin pages)
  • TBD — PR review service (services/ai/review.go)
  • TBD — Coding agent service (services/ai/agent.go)
  • TBD — @mention chat handler (services/ai/chat.go)
  • TBD — Usage tracking and cost dashboard
  • TBD — Repo settings and .claude-review-ignore support

Implementation Order

  1. mokogitea-claude[bot] system user (#362)
  2. Database schema + models
  3. Site/org/repo settings UI
  4. PR review service (highest user-visible value)
  5. @mention chat handler
  6. Coding agent
  7. Usage dashboard

References

  • mokogitea-actions[bot] implementation for bot user pattern
  • Anthropic Claude API: https://docs.anthropic.com/en/docs
  • Claude Code CLI for agent capabilities
  • GitHub Copilot feature set as UX reference
  • GitLab Duo for self-hosted AI forge reference
## Summary Build Claude AI directly into MokoGitea as a first-class platform feature — not a plugin, not an external service, not a workflow hack. It ships with the fork the same way mokogitea-actions[bot] ships with Actions support. ## This Is a Built-In Feature Like Gitea Actions is built into Gitea, Claude AI is built into MokoGitea: - System bot: mokogitea-claude[bot] (auto-provisioned at install) - Admin settings: Site Administration > AI Configuration - Org settings: Org Settings > AI Integration - Repo settings: Repo Settings > AI Assistant - UI elements: native buttons, comment styling, assignee integration - No external services to deploy separately ## Feature Set ### PR Smart Comments (automatic) - Auto-summary on PR open (what changed, risk areas) - Inline review comments (bugs, security, style) - Suggestion blocks with code fixes - Risk labels auto-applied (review: low-risk / review: needs-attention) - Responds to review feedback and pushes fix commits ### Interactive Chat (@mention) - @mokogitea-claude in any issue/PR comment - Context-aware: reads issue, diff, linked files, repo conventions - Can answer questions, explain code, suggest approaches - Maintains conversation context within a thread ### Coding Agent (assign/label) - Assign issue to mokogitea-claude[bot] or label ai:implement - Bot creates dev/ branch, implements changes, runs tests - Opens PR linking back to issue - Iterates on review feedback until approved ### Code Search / Explain - "Explain this file" button in code view - AI-powered code search (semantic, not just text matching) - Inline documentation generation ## Architecture (Internal to MokoGitea) This runs inside the MokoGitea process — no sidecar, no separate container, no external webhook receiver. The AI service is just another internal service like notifications or actions. ## Settings Hierarchy ### Site Administration > AI - Default Anthropic API key (platform-wide fallback) - Default model - Global rate limits - Enable/disable AI features site-wide - Usage dashboard (all orgs) ### Org Settings > AI Integration - Org API key (overrides site default) - Model selection per org - Rate limit per org (requests/hour, tokens/month) - Enable/disable per org - Add mokogitea-claude[bot] to teams - Usage/cost dashboard for org ### Repo Settings > AI Assistant - Enable/disable for this repo - Review strictness: minimal / standard / thorough - Auto-review on PR open: yes/no - Files to ignore (.claude-review-ignore) - Custom instructions (uses CLAUDE.md in repo root) ## Security Model - Org isolation: bot only accesses repos where it has team membership - Branch protection: bot respects existing branch rules (can only push to dev/*) - Secrets: .env, credentials excluded from AI context - Rate limiting: per-org token budgets prevent runaway costs - Audit log: all AI actions logged (who triggered, what it did, tokens used) ## Permission Tiers - PR Review (read-only): reads code, posts comments - Answer question (read-only): reads code, posts response - Fix issue (write): reads code, pushes commits to dev/ branches - Create feature (write): full implementation, opens PRs ## Database Schema New tables: - ai_org_settings (org_id, api_key_encrypted, model, enabled, rate_limit) - ai_repo_settings (repo_id, enabled, strictness, auto_review, ignore_patterns) - ai_usage_log (id, org_id, repo_id, action_type, tokens_in, tokens_out, model, created_at) - ai_conversations (id, issue_id, messages_json, created_at, updated_at) ## Sub-Issues - #362 — mokogitea-claude[bot] system user (provisioning, permissions, badge) - TBD — AI settings UI (site/org/repo admin pages) - TBD — PR review service (services/ai/review.go) - TBD — Coding agent service (services/ai/agent.go) - TBD — @mention chat handler (services/ai/chat.go) - TBD — Usage tracking and cost dashboard - TBD — Repo settings and .claude-review-ignore support ## Implementation Order 1. mokogitea-claude[bot] system user (#362) 2. Database schema + models 3. Site/org/repo settings UI 4. PR review service (highest user-visible value) 5. @mention chat handler 6. Coding agent 7. Usage dashboard ## References - mokogitea-actions[bot] implementation for bot user pattern - Anthropic Claude API: https://docs.anthropic.com/en/docs - Claude Code CLI for agent capabilities - GitHub Copilot feature set as UX reference - GitLab Duo for self-hosted AI forge reference
Author
Owner

Sub-task: Smart PR Comments

Requirements

  • Auto-generate PR summary comment on open
  • Inline code review comments (bugs, security, style)
  • Suggestion blocks with actual code fixes (Gitea suggestion format)
  • Complexity/risk assessment label
  • Configurable: org can set review strictness (minimal/standard/thorough)
  • Skip drafts unless explicitly requested
  • Respect .claude-review-ignore for files to skip

Comment Types

  1. PR Summary - Top-level comment summarizing what the PR does, files changed, risk areas
  2. Inline Reviews - Line-specific comments on potential issues
  3. Suggestions - Code blocks with fixes using Gitea suggestion syntax
  4. Risk Label - Auto-apply labels like review: low-risk / review: needs-attention

Prototype

Gitea Actions workflow in progress - see dev branch when ready.

## Sub-task: Smart PR Comments ### Requirements - [ ] Auto-generate PR summary comment on open - [ ] Inline code review comments (bugs, security, style) - [ ] Suggestion blocks with actual code fixes (Gitea suggestion format) - [ ] Complexity/risk assessment label - [ ] Configurable: org can set review strictness (minimal/standard/thorough) - [ ] Skip drafts unless explicitly requested - [ ] Respect .claude-review-ignore for files to skip ### Comment Types 1. **PR Summary** - Top-level comment summarizing what the PR does, files changed, risk areas 2. **Inline Reviews** - Line-specific comments on potential issues 3. **Suggestions** - Code blocks with fixes using Gitea suggestion syntax 4. **Risk Label** - Auto-apply labels like review: low-risk / review: needs-attention ### Prototype Gitea Actions workflow in progress - see dev branch when ready.
Author
Owner

Sub-issues

  • #362 — Built-in mokogitea[claude] bot user account (permissions, auto-provisioning, bot badge)
## Sub-issues - #362 — Built-in `mokogitea[claude]` bot user account (permissions, auto-provisioning, bot badge)
jmiller changed title from Feature: Embedded Claude AI Assistant (Copilot-style integration) to feat(ai): Built-in Claude AI Assistant (mokogitea-claude[bot]) 2026-05-31 16:24:32 +00:00
Author
Owner

Correction: Repo-Level AI Config

Repo-level AI instructions live in .mokogitea/CLAUDE.md — not a separate settings file. This is the same file Claude Code already reads, placed in the .mokogitea/ directory.

The built-in bot and developers running Claude Code locally both read the same file. Single source of truth for project conventions, review rules, and AI behavior.

UI settings (enable/disable, strictness, ignore patterns) still live in the DB via repo settings page — but the actual instructions to the AI come from .mokogitea/CLAUDE.md.

## Correction: Repo-Level AI Config Repo-level AI instructions live in `.mokogitea/CLAUDE.md` — not a separate settings file. This is the same file Claude Code already reads, placed in the `.mokogitea/` directory. The built-in bot and developers running Claude Code locally both read the same file. Single source of truth for project conventions, review rules, and AI behavior. UI settings (enable/disable, strictness, ignore patterns) still live in the DB via repo settings page — but the actual instructions to the AI come from `.mokogitea/CLAUDE.md`.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: MokoConsulting/MokoGitea#359