Created the mosaic-bridge module to enable Discord integration for chat-based control of Mosaic Stack. This module provides the foundation for receiving commands via Discord and forwarding them to the stitcher for job orchestration. Key Features: - Discord bot connection and authentication - Command parsing (@mosaic fix, status, cancel, verbose, quiet, help) - Thread management for job updates - Chat provider interface for future platform extensibility - Noise management (low/medium/high verbosity levels) Implementation Details: - Created IChatProvider interface for platform abstraction - Implemented DiscordService with Discord.js - Basic command parsing (detailed parsing in #171) - Thread creation for job-specific updates - Configuration via environment variables Commands Supported: - @mosaic fix <issue> - Start job for issue - @mosaic status <job> - Get job status (placeholder) - @mosaic cancel <job> - Cancel running job (placeholder) - @mosaic verbose <job> - Stream full logs (placeholder) - @mosaic quiet - Reduce notifications (placeholder) - @mosaic help - Show available commands Testing: - 23/23 tests passing (TDD approach) - Unit tests for Discord service - Module integration tests - 100% coverage of critical paths Quality Gates: - Typecheck: PASSED - Lint: PASSED - Build: PASSED - Tests: PASSED (23/23) Environment Variables: - DISCORD_BOT_TOKEN - Bot authentication token - DISCORD_GUILD_ID - Server/Guild ID (optional) - DISCORD_CONTROL_CHANNEL_ID - Channel for commands Files Created: - apps/api/src/bridge/bridge.module.ts - apps/api/src/bridge/discord/discord.service.ts - apps/api/src/bridge/interfaces/chat-provider.interface.ts - apps/api/src/bridge/index.ts - Full test coverage Dependencies Added: - discord.js@latest Next Steps: - Issue #171: Implement detailed command parsing - Issue #172: Add Herald integration for job updates - Future: Add Slack, Matrix support via IChatProvider Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
84 lines
2.4 KiB
Markdown
84 lines
2.4 KiB
Markdown
# Issue #170: Implement mosaic-bridge module for Discord
|
|
|
|
## Objective
|
|
|
|
Create the mosaic-bridge module to enable Discord integration. This module will:
|
|
|
|
- Connect to Discord via bot token
|
|
- Listen for commands in designated channels
|
|
- Forward commands to stitcher
|
|
- Receive status updates from herald
|
|
- Post updates to threads with appropriate verbosity
|
|
|
|
## Prerequisites
|
|
|
|
- Issue #166 (Stitcher module) must be complete - StitcherService available
|
|
|
|
## Approach
|
|
|
|
1. Create bridge module structure
|
|
2. Define chat provider interface for extensibility
|
|
3. Implement Discord service using Discord.js
|
|
4. Add command parsing (basic implementation)
|
|
5. Implement thread management for job updates
|
|
6. Add configuration management
|
|
7. Follow TDD: Write tests before implementation
|
|
|
|
## Commands to Implement
|
|
|
|
- `@mosaic fix <issue>` - Start job for issue
|
|
- `@mosaic status <job>` - Get job status
|
|
- `@mosaic cancel <job>` - Cancel running job
|
|
- `@mosaic verbose <job>` - Stream full logs to thread
|
|
- `@mosaic quiet` - Reduce notifications
|
|
- `@mosaic help` - Show commands
|
|
|
|
## Noise Management Strategy
|
|
|
|
- **Main channel**: Low verbosity (milestones only)
|
|
- **Job threads**: Medium verbosity (step completions)
|
|
- **DMs**: Configurable per user
|
|
|
|
## Progress
|
|
|
|
- [x] Install discord.js dependency
|
|
- [x] Create bridge module structure
|
|
- [x] Define ChatProvider interface
|
|
- [x] Write tests for Discord service (RED phase)
|
|
- [x] Implement Discord service (GREEN phase)
|
|
- [x] Implement command parsing
|
|
- [x] Implement thread management
|
|
- [x] Add configuration
|
|
- [x] Refactor and optimize (REFACTOR phase)
|
|
- [x] Run quality gates (typecheck, lint, build, test)
|
|
- [x] Commit changes
|
|
|
|
## Results
|
|
|
|
- **Tests**: 23/23 passing (20 Discord service + 3 module tests)
|
|
- **Typecheck**: PASSED
|
|
- **Lint**: PASSED
|
|
- **Build**: PASSED
|
|
- **Coverage**: High (all critical paths tested)
|
|
|
|
## Testing Strategy
|
|
|
|
- Unit tests for command parsing
|
|
- Unit tests for thread management
|
|
- Mock Discord.js client for testing
|
|
- Test stitcher integration
|
|
- Verify configuration loading
|
|
|
|
## Environment Variables
|
|
|
|
- `DISCORD_BOT_TOKEN` - Bot authentication token
|
|
- `DISCORD_GUILD_ID` - Server/Guild ID
|
|
- `DISCORD_CONTROL_CHANNEL_ID` - Channel for commands
|
|
|
|
## Notes
|
|
|
|
- Keep Discord.js interactions isolated in discord.service.ts
|
|
- Use ChatProvider interface to allow future platform additions (Slack, Matrix, etc.)
|
|
- Basic command parsing in this issue; detailed parsing comes in #171
|
|
- DO NOT push to remote, just commit locally
|