feat: /tldr conversation summarizer (#25)#105
Conversation
Add a /tldr slash command that uses Claude Haiku to AI-summarize recent Discord channel messages into a rich embed. Features: - /tldr — summarize last 50 messages (default) - /tldr count:<n> — summarize last N messages (max 200) - /tldr hours:<n> — summarize last N hours of messages - Rich embed: Key Topics, Decisions Made, Action Items, Notable Links - Per-channel rate limiting (1 use per 5 minutes) - tldr.enabled config gate via getConfig() - Ephemeral responses via deferReply + safeEditReply Also adds: - @anthropic-ai/sdk as a direct dependency - tldr defaults to config.json (enabled: false) - 11 tests covering all core behaviors Closes #25
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Claude finished @BillChirico's task in 3m 18s —— View job Review: PR #105 — feat: /tldr conversation summarizer
8 issues found (1 critical, 5 warnings, 2 nitpicks) Note: The fix commit (
Prompt to fix all issues |
|
| Filename | Overview |
|---|---|
| src/commands/tldr.js | New AI conversation summarizer with proper error handling, cooldown management, Winston logging, ephemeral responses, and connection pooling via module-level Anthropic client |
| tests/commands/tldr.test.js | Comprehensive test suite with 11 tests covering default behavior, options, cooldowns, edge cases, and disabled config |
| config.json | Added tldr config section with sensible defaults, added permission entry, removed duplicate starboard section |
| package.json | Added @anthropic-ai/sdk dependency for direct API access in tldr command |
| src/commands/help.js | Minor formatting improvement to split a long line for better readability |
Sequence Diagram
sequenceDiagram
participant User
participant Discord
participant tldr.js
participant Config
participant Cooldown
participant Channel
participant Anthropic
User->>Discord: /tldr [count|hours]
Discord->>tldr.js: execute(interaction)
tldr.js->>Discord: deferReply (ephemeral)
tldr.js->>Config: getConfig(guildId)
Config-->>tldr.js: tldr config
alt Feature disabled
tldr.js->>Discord: Command not enabled
else Feature enabled
tldr.js->>Cooldown: checkCooldown(channelId)
Cooldown-->>tldr.js: cooldown status
alt On cooldown
tldr.js->>Discord: Wait X seconds
else Cooldown OK
tldr.js->>Channel: messages.fetch()
Channel-->>tldr.js: message collection
tldr.js->>tldr.js: Filter bots & format
alt No messages
tldr.js->>Discord: No messages found
else Messages exist
tldr.js->>Anthropic: summarize (Haiku 4.5)
Anthropic-->>tldr.js: AI summary
alt AI failed
tldr.js->>Discord: Failed to summarize
else AI success
tldr.js->>Cooldown: Set cooldown
tldr.js->>tldr.js: Parse & build embed
tldr.js->>Discord: Rich embed with sections
end
end
end
end
Last reviewed commit: bbad921
Additional Comments (1)
Prompt To Fix With AIThis is a comment left during a code review.
Path: config.json
Line: 128-148
Comment:
Missing `tldr` command in `allowedCommands`. Per `src/utils/permissions.js:98-100`, commands not in this list default to admin-only. Add entry to control access level:
```suggestion
"allowedCommands": {
"ping": "everyone",
"memory": "everyone",
"config": "admin",
"warn": "admin",
"kick": "admin",
"timeout": "admin",
"untimeout": "admin",
"ban": "admin",
"tempban": "admin",
"unban": "admin",
"softban": "admin",
"purge": "admin",
"case": "admin",
"history": "admin",
"lock": "admin",
"unlock": "admin",
"slowmode": "admin",
"modlog": "moderator",
"announce": "moderator",
"tldr": "everyone"
}
```
How can I resolve this? If you propose a fix, please make it concise. |
There was a problem hiding this comment.
Pull request overview
Adds a new /tldr slash command that summarizes recent channel conversation using Anthropic Claude Haiku, returning a structured embed (topics/decisions/actions/links) with ephemeral delivery, plus associated configuration defaults and tests.
Changes:
- Introduces
src/commands/tldr.jsimplementing/tldrwith count/hours options, cooldown, and Anthropic summarization. - Adds
tests/commands/tldr.test.jscovering option parsing, cooldown behavior, empty channels, and embed formatting. - Updates dependencies/configuration (adds
@anthropic-ai/sdk, addstldrdefaults inconfig.json) and a small help command formatting tweak.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
src/commands/tldr.js |
New TLDR command implementation (message fetch, rate limit, Anthropic call, embed formatting). |
tests/commands/tldr.test.js |
New unit tests for TLDR command behavior and output shaping. |
config.json |
Adds tldr default config; also includes starboard section cleanup/adjustments. |
package.json |
Adds @anthropic-ai/sdk dependency. |
src/commands/help.js |
Formatting-only change for option builder chaining. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…, cooldown timing, tldr permissions
Summary
Implements the
/tldrslash command — an AI-powered conversation summarizer using Claude Haiku.What's new
src/commands/tldr.js/tldr— summarize last 50 messages (default)/tldr count:<n>— summarize last N messages (max 200)/tldr hours:<n>— summarize last N hours of messagesdeferReply({ ephemeral: true })+safeEditReply)tldr.enabledconfig gate viagetConfig(guildId)@anthropic-ai/sdkwithclaude-haiku-4-5for cost-efficient summarizationconfig.jsonAdded
tldrdefaults:{ "tldr": { "enabled": false, "defaultMessages": 50, "maxMessages": 200, "cooldownSeconds": 300 } }tests/commands/tldr.test.js11 tests covering:
Test results
Full suite: 1657 tests pass, 0 failures, 0 biome errors.
Closes #25