-
Notifications
You must be signed in to change notification settings - Fork 4
Feat/refactor memory with pinecone #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… quality and organization - Added `import-x` plugin and TypeScript resolver to ESLint configuration. - Updated dependencies in `package.json` and `bun.lock` for ESLint and Prettier plugins. - Refactored imports in `discord.ts` and `stream.ts` for better organization and clarity.
…ty and consistency - Adjusted import statements in `deploy-commands.ts`, `index.ts`, and various command files to enhance readability. - Ensured consistent ordering of imports in `message-create` event handlers and utility files. - Removed redundant imports and streamlined code structure in several modules.
…ell checking - Corrected spelling for "ASSEMBLYAI" to "assemblyai" and "ELEVENLABS" to "ElevenLabs". - Added new entries "HackClub" and "OpenRouter" to the cSpell dictionary.
…ence - Commented out the `hackclub`, `openrouter`, and `google` provider configurations in `providers.ts` to prevent unused code while maintaining the option to re-enable them later.
…ders.ts - Removed unused import statements for `env`, `createGoogleGenerativeAI`, `createOpenAICompatible`, and `createOpenRouter` to clean up the code and improve maintainability.
…ment configuration
…nse prompts for better user interaction
…language model references
…e in Discord tool
WalkthroughThis change removes all handling and usage of the "memories" parameter from chat context building, response generation, relevance assessment, and AI prompt construction. Function signatures and internal logic are updated to exclude "memories," simplifying the AI interaction flow. Additional changes include provider model updates and various formatting and stylistic adjustments across the codebase. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant DiscordBot
participant AIProvider
User->>DiscordBot: Send message or chat command
DiscordBot->>DiscordBot: Build chat context (no memories)
DiscordBot->>AIProvider: Generate response (no memories)
AIProvider-->>DiscordBot: Return AI response
DiscordBot-->>User: Send reply
Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate Unit Tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 31
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (56)
.cspell.json
(1 hunks).editorconfig
(1 hunks).eslintrc.json
(1 hunks).github/FUNDING.yml
(1 hunks).github/actions/setup/action.yml
(1 hunks).github/pull-request-template.md
(1 hunks).github/workflows/ci.yml
(1 hunks).prettierrc.json
(0 hunks)README.md
(1 hunks)TODO.md
(1 hunks)commitlint.config.ts
(1 hunks)package.json
(1 hunks)src/commands/channels.ts
(1 hunks)src/commands/chat.ts
(1 hunks)src/commands/index.ts
(1 hunks)src/commands/ping.ts
(1 hunks)src/commands/voice-channel/index.ts
(1 hunks)src/commands/voice-channel/join.ts
(1 hunks)src/commands/voice-channel/leave.ts
(1 hunks)src/config.ts
(1 hunks)src/deploy-commands.ts
(1 hunks)src/env.ts
(1 hunks)src/events/index.ts
(1 hunks)src/events/message-create/index.ts
(1 hunks)src/events/message-create/utils/relevance.ts
(1 hunks)src/events/message-create/utils/respond.ts
(1 hunks)src/index.ts
(1 hunks)src/lib/ai/prompts.ts
(1 hunks)src/lib/ai/providers.ts
(1 hunks)src/lib/ai/tools/discord.ts
(1 hunks)src/lib/ai/tools/get-weather.ts
(1 hunks)src/lib/ai/tools/report.ts
(1 hunks)src/lib/ai/tools/search-web.ts
(1 hunks)src/lib/kv.ts
(1 hunks)src/lib/logger.ts
(1 hunks)src/lib/queries.ts
(1 hunks)src/lib/search.ts
(1 hunks)src/lib/validators/index.ts
(1 hunks)src/lib/validators/probability.ts
(1 hunks)src/utils/context.ts
(1 hunks)src/utils/delay.ts
(1 hunks)src/utils/discord.ts
(1 hunks)src/utils/log.ts
(1 hunks)src/utils/message-rate-limiter.ts
(1 hunks)src/utils/messages.ts
(1 hunks)src/utils/sandbox.ts
(1 hunks)src/utils/status.ts
(1 hunks)src/utils/time.ts
(1 hunks)src/utils/tokenize-messages.ts
(1 hunks)src/utils/triggers.ts
(1 hunks)src/utils/voice/helpers/ai.ts
(1 hunks)src/utils/voice/helpers/audio.ts
(1 hunks)src/utils/voice/helpers/deepgram.ts
(1 hunks)src/utils/voice/helpers/index.ts
(1 hunks)src/utils/voice/stream.ts
(1 hunks)tsconfig.json
(1 hunks)
💤 Files with no reviewable changes (1)
- .prettierrc.json
🧰 Additional context used
🧬 Code Graph Analysis (18)
src/lib/kv.ts (1)
src/env.ts (1)
env
(4-58)
src/lib/ai/tools/report.ts (1)
src/utils/messages.ts (1)
MinimalContext
(10-13)
src/utils/status.ts (2)
src/config.ts (2)
activities
(16-21)statuses
(15-15)src/index.ts (1)
client
(9-23)
src/lib/search.ts (1)
src/env.ts (1)
env
(4-58)
src/utils/time.ts (1)
src/config.ts (1)
timezone
(6-6)
src/lib/logger.ts (1)
src/env.ts (1)
env
(4-58)
src/commands/voice-channel/join.ts (1)
src/utils/voice/stream.ts (1)
createListeningStream
(13-83)
src/utils/voice/helpers/deepgram.ts (1)
src/env.ts (1)
env
(4-58)
src/lib/ai/tools/search-web.ts (1)
src/lib/search.ts (1)
exa
(10-10)
src/utils/triggers.ts (1)
src/config.ts (1)
keywords
(3-3)
src/deploy-commands.ts (2)
src/commands/index.ts (1)
commands
(6-11)src/env.ts (1)
env
(4-58)
src/utils/message-rate-limiter.ts (2)
src/lib/kv.ts (2)
redisKeys
(19-24)redis
(7-10)src/config.ts (1)
messageThreshold
(23-23)
src/commands/channels.ts (1)
src/lib/kv.ts (2)
redisKeys
(19-24)redis
(7-10)
src/utils/log.ts (1)
src/utils/triggers.ts (1)
TriggerType
(3-3)
src/utils/context.ts (5)
src/utils/messages.ts (2)
MinimalContext
(10-13)convertToModelMessages
(15-33)src/lib/ai/prompts.ts (1)
RequestHints
(3-12)src/lib/queries.ts (2)
getMessagesByChannel
(11-28)getChannelName
(30-42)src/config.ts (2)
initialMessages
(24-35)timezone
(6-6)src/utils/time.ts (1)
getTimeInCity
(4-11)
src/utils/delay.ts (1)
src/utils/tokenize-messages.ts (2)
normalize
(10-17)sentences
(3-8)
src/events/message-create/index.ts (8)
src/lib/kv.ts (3)
ratelimit
(12-17)redisKeys
(19-24)redis
(7-10)src/utils/log.ts (3)
logIncoming
(16-18)logTrigger
(4-14)logReply
(20-39)src/utils/triggers.ts (1)
getTrigger
(5-27)src/config.ts (1)
keywords
(3-3)src/utils/message-rate-limiter.ts (3)
clearUnprompted
(11-13)getUnprompted
(4-9)hasUnpromptedQuota
(15-19)src/utils/context.ts (1)
buildChatContext
(8-40)src/events/message-create/utils/respond.ts (1)
generateResponse
(12-63)src/events/message-create/utils/relevance.ts (1)
assessRelevance
(7-30)
src/lib/ai/providers.ts (1)
src/env.ts (1)
env
(4-58)
🪛 LanguageTool
.github/pull-request-template.md
[style] ~9-~9: Consider using a different verb for a more formal wording.
Context: ... [ ] Bug fix (non-breaking change which fixes an issue)
- New feature (non-break...
(FIX_RESOLVE)
README.md
[locale-violation] ~29-~29: In American English, ‘afterward’ is the preferred variant. ‘Afterwards’ is more commonly used in British English and other dialects.
Context: ...idpolice.com/how-to-make-discord-bot/). Afterwards, you will need [Git][git] and [Bun][bun...
(AFTERWARDS_US)
TODO.md
[uncategorized] ~9-~9: Did you mean “its” (the possessive pronoun)?
Context: ...alistic.
Separate Deepgram code into it's files
Implement Conversation history f...
(ITS_PREMIUM)
[style] ~13-~13: The phrasing ‘more easy’ can sound awkward and informal. Consider using a comparative adjective or other alternative.
Context: ...).
Refactor the channels command to be more easy to use, with deny and allow lists.
D...
(MORE_EASY_N_CLEAR)
[typographical] ~15-~15: If specifying a range, consider using an en dash instead of a hyphen.
Context: ...he response before replying fully, wait 1-2 seconds (for one user). This adds dedup...
(HYPHEN_TO_EN)
[uncategorized] ~23-~23: Possible missing comma found.
Context: ...ram things are kept
When the user is typing increase the response speed by 0.5x. Al...
(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~23-~23: Possible missing comma found.
Context: ... 0.5x. Also, use a different method for responding like a set WPM.
Add CI/CD testing so...
(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~25-~25: This verb does not appear to agree with the subject. Consider using a different form.
Context: ...testing so pushing things to production don't break stuff.
Add context to when ...
(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)
[typographical] ~33-~33: Consider adding a comma here.
Context: ...the bot always remembers the same person no matter where they interact with it.
(NO_MATTER_COMMA)
🪛 markdownlint-cli2 (0.17.2)
.github/pull-request-template.md
1-1: First line in a file should be a top-level heading
null
(MD041, first-line-heading, first-line-h1)
README.md
1-1: Inline HTML
Element: h1
(MD033, no-inline-html)
10-10: Inline HTML
Element: a
(MD033, no-inline-html)
14-14: Inline HTML
Element: a
(MD033, no-inline-html)
27-27: Inline HTML
Element: a
(MD033, no-inline-html)
49-49: Inline HTML
Element: a
(MD033, no-inline-html)
55-55: Link and image reference definitions should be needed
Unused link or image reference definition: "pr"
(MD053, link-image-reference-definitions)
57-57: Link and image reference definitions should be needed
Unused link or image reference definition: "node"
(MD053, link-image-reference-definitions)
🪛 ESLint
src/lib/kv.ts
[error] 2-2: Unable to resolve path to module '@upstash/ratelimit'.
(import-x/no-unresolved)
[error] 3-3: Unable to resolve path to module '@upstash/redis'.
(import-x/no-unresolved)
src/lib/ai/tools/report.ts
[error] 3-3: Unable to resolve path to module 'ai'.
(import-x/no-unresolved)
[error] 4-4: Unable to resolve path to module 'zod/v4'.
(import-x/no-unresolved)
src/lib/validators/probability.ts
[error] 1-1: Unable to resolve path to module 'zod/v4'.
(import-x/no-unresolved)
src/lib/ai/tools/get-weather.ts
[error] 1-1: Unable to resolve path to module 'ai'.
(import-x/no-unresolved)
[error] 2-2: Unable to resolve path to module 'zod/v4'.
(import-x/no-unresolved)
src/utils/status.ts
[error] 4-4: Unable to resolve path to module 'discord.js'.
(import-x/no-unresolved)
src/lib/search.ts
[error] 2-2: Unable to resolve path to module 'exa-js'.
(import-x/no-unresolved)
src/utils/time.ts
[error] 1-1: Unable to resolve path to module '@date-fns/tz'.
(import-x/no-unresolved)
[error] 2-2: Unable to resolve path to module 'date-fns'.
(import-x/no-unresolved)
src/commands/ping.ts
[error] 1-1: Unable to resolve path to module 'discord.js'.
(import-x/no-unresolved)
src/lib/queries.ts
[error] 9-9: Unable to resolve path to module 'discord.js'.
(import-x/no-unresolved)
src/lib/logger.ts
[error] 5-5: Unable to resolve path to module 'pino'.
(import-x/no-unresolved)
src/env.ts
[error] 1-1: Unable to resolve path to module '@t3-oss/env-core'.
(import-x/no-unresolved)
[error] 2-2: Unable to resolve path to module 'zod/v4'.
(import-x/no-unresolved)
src/commands/voice-channel/join.ts
[error] 8-8: Unable to resolve path to module '@discordjs/voice'.
(import-x/no-unresolved)
src/commands/chat.ts
[error] 8-8: Unable to resolve path to module 'discord.js'.
(import-x/no-unresolved)
src/utils/voice/helpers/ai.ts
[error] 3-3: Unable to resolve path to module 'ai'.
(import-x/no-unresolved)
src/index.ts
[error] 7-7: Unable to resolve path to module 'discord.js'.
(import-x/no-unresolved)
src/utils/voice/helpers/deepgram.ts
[error] 2-2: Unable to resolve path to module '@deepgram/sdk'.
(import-x/no-unresolved)
src/lib/ai/tools/search-web.ts
[error] 3-3: Unable to resolve path to module 'ai'.
(import-x/no-unresolved)
[error] 4-4: Unable to resolve path to module 'zod/v4'.
(import-x/no-unresolved)
src/utils/voice/helpers/audio.ts
[error] 6-6: Unable to resolve path to module '@discordjs/voice'.
(import-x/no-unresolved)
src/utils/voice/stream.ts
[error] 3-3: Unable to resolve path to module '@deepgram/sdk'.
(import-x/no-unresolved)
[error] 8-8: Unable to resolve path to module '@discordjs/voice'.
(import-x/no-unresolved)
[error] 10-10: Unable to resolve path to module 'prism-media'.
(import-x/no-unresolved)
src/utils/triggers.ts
[error] 1-1: Unable to resolve path to module 'discord.js'.
(import-x/no-unresolved)
src/deploy-commands.ts
[error] 2-2: Unable to resolve path to module 'discord.js'.
(import-x/no-unresolved)
src/utils/discord.ts
[error] 1-1: Unable to resolve path to module 'discord.js'.
(import-x/no-unresolved)
src/commands/channels.ts
[error] 9-9: Unable to resolve path to module 'discord.js'.
(import-x/no-unresolved)
src/config.ts
[error] 1-1: Unable to resolve path to module 'discord.js'.
(import-x/no-unresolved)
src/commands/voice-channel/leave.ts
[error] 1-1: Unable to resolve path to module '@discordjs/voice'.
(import-x/no-unresolved)
src/utils/tokenize-messages.ts
[error] 1-1: Unable to resolve path to module 'compromise'.
(import-x/no-unresolved)
src/utils/delay.ts
[error] 3-3: Unable to resolve path to module 'discord.js'.
(import-x/no-unresolved)
src/events/message-create/utils/relevance.ts
[error] 4-4: Unable to resolve path to module 'ai'.
(import-x/no-unresolved)
src/events/message-create/index.ts
[error] 10-10: Unable to resolve path to module 'discord.js'.
(import-x/no-unresolved)
src/commands/voice-channel/index.ts
[error] 1-1: Unable to resolve path to module 'discord.js'.
(import-x/no-unresolved)
src/lib/ai/tools/discord.ts
[error] 6-6: Unable to resolve path to module 'ai'.
(import-x/no-unresolved)
[error] 8-8: Unable to resolve path to module 'zod/v4'.
(import-x/no-unresolved)
src/events/message-create/utils/respond.ts
[error] 10-10: Unable to resolve path to module 'ai'.
(import-x/no-unresolved)
src/utils/messages.ts
[error] 8-8: Unable to resolve path to module 'discord.js'.
(import-x/no-unresolved)
src/lib/ai/providers.ts
[error] 1-1: Unable to resolve path to module 'ai'.
(import-x/no-unresolved)
[error] 4-4: Unable to resolve path to module '@ai-sdk/google'.
(import-x/no-unresolved)
[error] 5-5: Unable to resolve path to module '@ai-sdk/openai'.
(import-x/no-unresolved)
[error] 6-6: Unable to resolve path to module '@ai-sdk/openai-compatible'.
(import-x/no-unresolved)
🪛 YAMLlint (1.37.1)
.github/actions/setup/action.yml
[error] 1-1: wrong new line character: expected \n
(new-lines)
.github/FUNDING.yml
[error] 1-1: wrong new line character: expected \n
(new-lines)
.github/workflows/ci.yml
[error] 1-1: wrong new line character: expected \n
(new-lines)
[warning] 3-3: truthy value should be one of [false, true]
(truthy)
🪛 Biome (1.9.4)
src/commands/chat.ts
[error] 36-36: Forbidden non-null assertion.
(lint/style/noNonNullAssertion)
src/utils/voice/helpers/ai.ts
[error] 11-12: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
src/utils/discord.ts
[error] 35-35: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
src/lib/ai/providers.ts
[error] 19-19: Forbidden non-null assertion.
(lint/style/noNonNullAssertion)
🪛 GitHub Actions: CI
src/events/message-create/utils/relevance.ts
[warning] 1-1: Prettier formatting check failed. Run 'prettier --write' to fix code style issues in this file.
src/events/message-create/utils/respond.ts
[warning] 2-2: ESLint: 'replyPrompt' is defined but never used. (no-unused-vars, @typescript-eslint/no-unused-vars)
[warning] 16-16: ESLint: 'options' is defined but never used. (no-unused-vars, @typescript-eslint/no-unused-vars)
src/lib/ai/providers.ts
[warning] 8-8: ESLint: 'hackclub' is assigned a value but never used. (no-unused-vars, @typescript-eslint/no-unused-vars)
[warning] 19-19: ESLint: Forbidden non-null assertion. (@typescript-eslint/no-non-null-assertion)
🔇 Additional comments (46)
.github/FUNDING.yml (1)
1-2
: ```shell
#!/bin/bashCheck for CRLF line endings in .github/FUNDING.yml
if grep -q $'\r' .github/FUNDING.yml; then
echo "✔ CRLF line endings detected in .github/FUNDING.yml"
else
echo "✖ No CRLF line endings found (LF only)"
fi</details> <details> <summary>README.md (1)</summary> `49-51`: **License reference changed → ensure repository metadata is updated** README now states MIT. Please verify: 1. A corresponding `LICENSE` file with MIT text exists/was updated. 2. `package.json` / `bunfig.toml` (or equivalent) `license` field matches. 3. All copyright headers (if any) reflect the new license. Failure to sync these sources creates legal ambiguity. </details> <details> <summary>src/commands/ping.ts (1)</summary> `1-9`: **ESLint reports module not resolved – double-check path mapping** `import { ... } from 'discord.js'` triggers `import-x/no-unresolved`. If you rely on path aliases (e.g., Bun/TS `moduleResolution`), ensure: - `types` for `discord.js` are installed (`pnpm add -D @types/discord.js` not needed for ESM build ≥ v14). - ESLint resolver settings (`settings.import/resolver`) include `node` + `typescript` so CRLF-only change doesn’t introduce new lint noise. </details> <details> <summary>src/lib/validators/index.ts (1)</summary> `1-1`: **No functional change – looks good** Whitespace-only; export barrel still compiles. </details> <details> <summary>src/utils/voice/helpers/index.ts (1)</summary> `1-3`: **Export barrel unchanged – OK** Only line-ending normalization; nothing else to flag. </details> <details> <summary>commitlint.config.ts (1)</summary> `1-1`: **No functional change – looks good.** Only whitespace was altered. Configuration remains valid. </details> <details> <summary>src/events/index.ts (1)</summary> `1-5`: **Line-ending normalization only – fine to merge.** Nothing beyond CRLF conversion; runtime behaviour unchanged. </details> <details> <summary>src/lib/queries.ts (1)</summary> `11-22`: **`channel` type is too wide – can lead to runtime failures** `DiscordMessage['channel']` allows Voice/Stage channels that do **not** expose `.messages.fetch()`. At runtime calling `fetch` on those will throw. Recommend restricting the parameter to `TextBasedChannel` (or similar union) and letting TS enforce the guard: ```diff - channel: DiscordMessage['channel']; + channel: import('discord.js').TextBasedChannel;
If you truly need to support non-text channels, add an explicit type-guard before the fetch.
.github/actions/setup/action.yml (1)
26-43
: Secrets placeholder file may leak in forksCreating
.env.local
with dummy keys is handy, but GH Action logs will echo the entire file, which might mislead contributors into committing real tokens.Add
actions/upload-artifact
exclusion or write the file to./.tmp
and git-ignore that path.src/lib/ai/tools/report.ts (1)
22-22
: LGTM: Formatting improvementThe trailing comma removal improves code style consistency across the codebase.
tsconfig.json (1)
1-33
: LGTM: Configuration formatting cleanupThe formatting improvements enhance readability and consistency without affecting any compiler options or build behavior.
src/utils/voice/helpers/deepgram.ts (1)
12-19
: LGTM: Consistent formattingThe formatting changes align with the codebase style cleanup while preserving all functionality.
src/config.ts (1)
12-12
: Verify the significant speedFactor increaseThe
speedFactor
has been increased from180
to32400
(180 * 180), representing a 180x multiplier. This substantial change could significantly impact timing/pacing logic throughout the application.Please confirm this change is intentional and has been properly tested, as it may affect message processing delays or other time-sensitive operations.
src/utils/log.ts (1)
4-39
: LGTM: Formatting consistencyThe trailing comma removals improve code style consistency across the logging utilities without affecting functionality.
src/utils/sandbox.ts (1)
37-42
: Trailing-comma tweak looks goodPurely stylistic; runtime behaviour of
Promise.race
is unchanged.src/utils/voice/helpers/audio.ts (1)
1-7
: Verify ESLint “module not resolved” warning
@discordjs/voice
is listed inpackage.json
, so the import should resolve.
If the linter still complains, ensure:
- The package really exists in
node_modules
afterbun install
.eslint-import-resolver-typescript
is configured to look at Bun’s resolution paths.No source alteration required.
src/utils/message-rate-limiter.ts (1)
15-18
: Off-by-one risk in quota check
hasUnpromptedQuota
returnstrue
whilen < messageThreshold
.
If the intended quota is “exactly 10 messages per hour”, the 10-th message will be rejected because the inequality becomes10 < 10
.- return n < messageThreshold; + return n <= messageThreshold;Please verify the desired behaviour and adjust the comparison accordingly.
src/utils/delay.ts (1)
1-4
: ESLint “import-x/no-unresolved” warningIf you’re already using
@
path aliases intsconfig.json
, add the corresponding resolver config (eslint-import-resolver-typescript
) so ESLint can resolve@/config
,discord.js
, etc.src/lib/ai/tools/get-weather.ts (1)
1-2
: Unresolved module pathsESLint flags
ai
andzod/v4
as unresolved.
If these come from path aliases / sub-path exports, wire upeslint-import-resolver-typescript
or add the correctexports
field so tooling concurs with the compiler.src/commands/index.ts (1)
1-11
: LGTM – pure formatting changeNo behavioural impact; the
commands
aggregate remains intact.src/lib/search.ts (1)
1-3
: Verify dependency availability
exa-js
is flagged as unresolved by ESLint. Ensure it is:
- Added to
package.json
dependencies.- Compatible with your runtime (ESM/CommonJS).
- Covered by type definitions (or
@types/exa-js
) to preserve TS safety.Otherwise, runtime imports will fail even though compilation passes.
src/lib/validators/probability.ts (1)
1-15
: Schema looks goodOnly stylistic tweaks were made; validation logic and inferred types remain accurate.
src/commands/voice-channel/index.ts (1)
12-12
: LGTM: Consistent formatting improvementsThe removal of trailing commas improves code consistency across the project without affecting functionality.
Also applies to: 15-15, 19-19
src/lib/ai/tools/search-web.ts (1)
1-35
: LGTM: Formatting adjustments maintain functionalityThe formatting changes improve consistency while preserving the search web tool's functionality and logic.
src/commands/chat.ts (1)
51-55
: LGTM: Memory handling removal aligns with refactor objectivesThe removal of the
memories
parameter from bothbuildChatContext
andgenerateResponse
calls is consistent with the broader refactor to simplify the AI interaction pipeline. The chat command functionality remains intact.src/commands/voice-channel/join.ts (1)
52-54
: LGTM: Consistent formatting improvementThe formatting adjustment maintains functionality while improving code consistency across the project.
src/commands/voice-channel/leave.ts (1)
8-10
: LGTM! Clean formatting improvement.The removal of the trailing comma in the function parameter improves code consistency.
src/utils/triggers.ts (1)
1-27
: LGTM! Formatting changes maintain correct trigger detection logic.The trigger detection logic properly handles ping, keyword, and DM triggers in the correct priority order.
src/utils/discord.ts (1)
1-76
: LGTM! Consider using optional chaining for cleaner code.The formatting changes look good and the embed creation logic is solid.
src/utils/voice/stream.ts (1)
1-83
: LGTM! Formatting changes preserve complex voice streaming logic.The voice streaming implementation with Deepgram integration remains intact and correctly handles the audio processing pipeline.
src/deploy-commands.ts (1)
1-43
: LGTM! Formatting changes maintain proper command deployment logic.The command deployment functionality correctly handles both guild-specific and global command registration with appropriate error handling.
src/commands/channels.ts (1)
1-125
: LGTM: Formatting changes onlyThe changes in this file are purely formatting-related (trailing comma removal and whitespace adjustments) without any functional modifications. The command logic, Redis operations, and permission checks remain intact.
src/events/message-create/index.ts (2)
67-68
: LGTM: Memory parameter removal for explicit triggersThe destructuring of
buildChatContext
result and the call togenerateResponse
have been correctly updated to exclude thememories
parameter, aligning with the broader refactoring.
84-89
: LGTM: Memory parameter removal for relevance assessmentThe destructuring and function calls for
buildChatContext
,assessRelevance
, andgenerateResponse
have been consistently updated to remove thememories
parameter throughout the relevance-based response path.src/lib/ai/tools/discord.ts (3)
147-147
: Good addition: State serialization for observabilityAdding JSON serialization of the shared state enhances debugging and observability of the Discord agent's behavior.
149-149
: LGTM: State included in completion loggingIncluding the serialized state in the completion log provides valuable debugging information about the agent's final state.
165-165
: LGTM: State included in return valueAdding the state to the return object allows callers to access the agent's final state, which is useful for debugging and monitoring.
src/events/message-create/utils/relevance.ts (3)
7-11
: LGTM: Memory parameter removed from function signatureThe function signature has been correctly updated to remove the
memories
parameter, aligning with the broader refactoring.
17-20
: LGTM: Memory parameter removed from systemPrompt callThe
systemPrompt
call has been properly updated to exclude thememories
parameter.
1-30
: ```shell
#!/bin/bashCheck if prettier is listed as a dependency or devDependency
echo "=== prettier entries in package.json ==="
grep -R '"prettier"' package.json -n || echo "No prettier entry found in package.json"Check for an npm script that runs formatting
echo "=== format scripts in package.json ==="
grep -R '"format"' package.json -n || echo "No format script found in package.json"Check if a local prettier binary exists
echo "=== prettier binary check ==="
if [ -f node_modules/.bin/prettier ]; then
echo "prettier binary found at node_modules/.bin/prettier"
else
echo "prettier binary not found"
fi</details> <details> <summary>src/utils/tokenize-messages.ts (1)</summary> `13-13`: **LGTM: Improved regex precision with start anchor** Adding the `^` anchor to the regular expression improves precision by ensuring label-like prefixes are only removed from the start of strings, preventing unwanted matches in the middle of text. </details> <details> <summary>src/utils/context.ts (1)</summary> `8-40`: **LGTM! Clean refactor removing memories parameter.** The function is well-structured with proper error handling and type safety. The removal of the `memories` parameter simplifies the API and aligns with the broader refactoring effort across the codebase. </details> <details> <summary>src/events/message-create/utils/respond.ts (1)</summary> `25-63`: **LGTM! Function logic is sound.** The response generation logic is well-structured with proper error handling and tool integration. </details> <details> <summary>src/lib/ai/providers.ts (1)</summary> `22-34`: **LGTM! Provider configuration looks correct.** The multi-provider setup with Google Gemini and OpenAI models is well-structured and aligns with the refactoring objectives. </details> <details> <summary>src/lib/ai/prompts.ts (1)</summary> `168-182`: **LGTM! Clean refactor simplifying prompt construction.** The removal of the `memories` parameter simplifies the function signature and prompt construction. The remaining prompts are well-structured and maintain the bot's personality effectively. </details> <details> <summary>.cspell.json (1)</summary> `6-6`: ```shell #!/bin/bash rg -n "apiKey" -C2 .
|
||
## <a name="getting-started">📚 Getting Started</a> | ||
|
||
To clone and run this application, first you need to create a [Discord Bot](https://www.androidpolice.com/how-to-make-discord-bot/). Afterwards, you will need [Git][git] and [Bun][bun] installed on your computer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Minor wording nit – American vs British English
Afterwards
→ Afterward
for consistency with en-US style used elsewhere.
-...bot/). Afterwards, you will need...
+...bot/). Afterward, you will need...
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
To clone and run this application, first you need to create a [Discord Bot](https://www.androidpolice.com/how-to-make-discord-bot/). Afterwards, you will need [Git][git] and [Bun][bun] installed on your computer. | |
To clone and run this application, first you need to create a [Discord Bot](https://www.androidpolice.com/how-to-make-discord-bot/). Afterward, you will need [Git][git] and [Bun][bun] installed on your computer. |
🧰 Tools
🪛 LanguageTool
[locale-violation] ~29-~29: In American English, ‘afterward’ is the preferred variant. ‘Afterwards’ is more commonly used in British English and other dialects.
Context: ...idpolice.com/how-to-make-discord-bot/). Afterwards, you will need [Git][git] and [Bun][bun...
(AFTERWARDS_US)
🤖 Prompt for AI Agents
In README.md at line 29, change the word "Afterwards" to "Afterward" to maintain
consistency with the American English style used throughout the document.
const status = getRandomItem(statuses) as PresenceStatusData; | ||
const activity = getRandomItem(activities) as Activity; | ||
|
||
client.user.setPresence({ | ||
status, | ||
activities: [{ name: activity.name, type: activity.type }], | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
offline
is not a settable Discord presence status – will throw at runtime.
ClientUser#setPresence
accepts 'online' | 'idle' | 'dnd' | 'invisible'
.
'offline'
(present in statuses
) triggers DiscordAPIError[50035]: Invalid Form Body
.
Map it to 'invisible'
or drop it.
- const status = getRandomItem(statuses) as PresenceStatusData;
+ let status = getRandomItem(statuses) as PresenceStatusData;
+ if (status === 'offline') {
+ // Discord.js does not allow setting 'offline'; use 'invisible' instead
+ status = 'invisible';
+ }
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const status = getRandomItem(statuses) as PresenceStatusData; | |
const activity = getRandomItem(activities) as Activity; | |
client.user.setPresence({ | |
status, | |
activities: [{ name: activity.name, type: activity.type }], | |
}); | |
// Map any randomly picked 'offline' status to 'invisible' | |
let status = getRandomItem(statuses) as PresenceStatusData; | |
if (status === 'offline') { | |
// Discord.js does not allow setting 'offline'; use 'invisible' instead | |
status = 'invisible'; | |
} | |
const activity = getRandomItem(activities) as Activity; | |
client.user.setPresence({ | |
status, | |
activities: [{ name: activity.name, type: activity.type }], | |
}); |
🤖 Prompt for AI Agents
In src/utils/status.ts around lines 19 to 25, the presence status 'offline' is
invalid for Discord and causes a runtime error. Update the code to map any
'offline' status selected from statuses to 'invisible' before passing it to
client.user.setPresence. This ensures only valid statuses ('online', 'idle',
'dnd', 'invisible') are used and prevents the DiscordAPIError.
import { TZDate } from '@date-fns/tz'; | ||
import { format } from 'date-fns'; | ||
|
||
export function getTimeInCity( | ||
timezone: string, | ||
formatStr = 'yyyy-MM-dd HH:mm:ssXXX' | ||
): string { | ||
const now = new Date(); | ||
const zonedDate = new TZDate(now, timezone); | ||
return format(zonedDate, formatStr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TZDate
is not exported by @date-fns/tz
– runtime import error.
date-fns-tz
provides helpers like utcToZonedTime
, not a TZDate
class.
Current code will throw Cannot find module '@date-fns/tz'
/ “export ‘TZDate’ was not found”.
-import { TZDate } from '@date-fns/tz';
-import { format } from 'date-fns';
+import { format } from 'date-fns';
+import { utcToZonedTime } from 'date-fns-tz';
@@
- const now = new Date();
- const zonedDate = new TZDate(now, timezone);
- return format(zonedDate, formatStr);
+ const now = new Date();
+ const zonedDate = utcToZonedTime(now, timezone);
+ return format(zonedDate, formatStr);
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
import { TZDate } from '@date-fns/tz'; | |
import { format } from 'date-fns'; | |
export function getTimeInCity( | |
timezone: string, | |
formatStr = 'yyyy-MM-dd HH:mm:ssXXX' | |
): string { | |
const now = new Date(); | |
const zonedDate = new TZDate(now, timezone); | |
return format(zonedDate, formatStr); | |
import { format } from 'date-fns'; | |
import { utcToZonedTime } from 'date-fns-tz'; | |
export function getTimeInCity( | |
timezone: string, | |
formatStr = 'yyyy-MM-dd HH:mm:ssXXX' | |
): string { | |
const now = new Date(); | |
const zonedDate = utcToZonedTime(now, timezone); | |
return format(zonedDate, formatStr); | |
} |
🧰 Tools
🪛 ESLint
[error] 1-1: Unable to resolve path to module '@date-fns/tz'.
(import-x/no-unresolved)
[error] 2-2: Unable to resolve path to module 'date-fns'.
(import-x/no-unresolved)
🤖 Prompt for AI Agents
In src/utils/time.ts lines 1 to 10, the code incorrectly imports TZDate from
'@date-fns/tz', which does not export TZDate and causes a runtime error. Replace
the import of TZDate with the correct import of utcToZonedTime from
'@date-fns-tz', then update the function to use utcToZonedTime to convert the
current date to the specified timezone before formatting it.
### Description | ||
|
||
<!-- Describe your changes in detail. What problem does this PR solve? --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Optional: add a top-level heading to satisfy markdownlint (MD041).
+# # Pull Request
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
### Description | |
<!-- Describe your changes in detail. What problem does this PR solve? --> | |
# # Pull Request | |
### Description | |
<!-- Describe your changes in detail. What problem does this PR solve? --> |
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
1-1: First line in a file should be a top-level heading
null
(MD041, first-line-heading, first-line-h1)
🤖 Prompt for AI Agents
In .github/pull-request-template.md at lines 1 to 3, add a top-level heading
(e.g., starting with #) at the very beginning of the file to satisfy
markdownlint rule MD041, which requires a top-level heading in markdown
documents.
} catch (error) { | ||
console.error('Failed to get messages by chat id from database', error); | ||
throw error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Prefer structured logging over console.error
Elsewhere the project uses Pino (src/lib/logger.ts
). Using console.*
here bypasses log formatting and rotation.
-import { logger } from '@/lib/logger'; // at top
-
- console.error('Failed to get messages by chat id from database', error);
+ logger.error({ err: error }, 'Failed to fetch messages for channel');
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In src/lib/queries.ts around lines 24 to 26, replace the use of console.error
with the project's Pino logger imported from src/lib/logger.ts. Import the
logger if not already done, then use logger.error to log the error with a
descriptive message and the error object to maintain consistent structured
logging and enable proper log formatting and rotation.
options?: { | ||
tools?: { | ||
getWeather?: boolean; | ||
report?: boolean; | ||
discord?: boolean; | ||
[key: string]: boolean | undefined; | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Remove unused parameter.
The options
parameter is defined but never used in the function body.
Consider removing the unused parameter or implementing the intended functionality:
- options?: {
- tools?: {
- getWeather?: boolean;
- report?: boolean;
- discord?: boolean;
- [key: string]: boolean | undefined;
- };
- }
Committable suggestion skipped: line range outside the PR's diff.
🧰 Tools
🪛 GitHub Actions: CI
[warning] 16-16: ESLint: 'options' is defined but never used. (no-unused-vars, @typescript-eslint/no-unused-vars)
🤖 Prompt for AI Agents
In src/events/message-create/utils/respond.ts between lines 16 and 23, the
options parameter is declared but not used anywhere in the function body. To fix
this, either remove the options parameter entirely if it is unnecessary, or
implement the intended functionality that utilizes the options object within the
function. This will eliminate the unused parameter warning and clarify the
function's purpose.
const hackclub = createOpenAICompatible({ | ||
name: 'hackclub', | ||
apiKey: env.HACKCLUB_API_KEY, | ||
baseURL: 'https://ai.hackclub.com', | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Remove unused provider definition.
The hackclub
provider is defined but never used in the myProvider
configuration.
Apply this fix:
-const hackclub = createOpenAICompatible({
- name: 'hackclub',
- apiKey: env.HACKCLUB_API_KEY,
- baseURL: 'https://ai.hackclub.com',
-});
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const hackclub = createOpenAICompatible({ | |
name: 'hackclub', | |
apiKey: env.HACKCLUB_API_KEY, | |
baseURL: 'https://ai.hackclub.com', | |
}); |
🧰 Tools
🪛 GitHub Actions: CI
[warning] 8-8: ESLint: 'hackclub' is assigned a value but never used. (no-unused-vars, @typescript-eslint/no-unused-vars)
🤖 Prompt for AI Agents
In src/lib/ai/providers.ts around lines 8 to 12, the hackclub provider is
defined but not used anywhere in the myProvider configuration. Remove the entire
hackclub provider definition to clean up unused code and avoid confusion.
apiKey: env.GOOGLE_GENERATIVE_AI_API_KEY!, | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Replace non-null assertion with proper error handling.
The non-null assertion on the Google API key could cause runtime errors if the environment variable is undefined.
Apply this fix:
-const google = createGoogleGenerativeAI({
- apiKey: env.GOOGLE_GENERATIVE_AI_API_KEY!,
-});
+const google = createGoogleGenerativeAI({
+ apiKey: env.GOOGLE_GENERATIVE_AI_API_KEY ?? '',
+});
Or add proper validation:
-const google = createGoogleGenerativeAI({
- apiKey: env.GOOGLE_GENERATIVE_AI_API_KEY!,
-});
+if (!env.GOOGLE_GENERATIVE_AI_API_KEY) {
+ throw new Error('GOOGLE_GENERATIVE_AI_API_KEY is required');
+}
+
+const google = createGoogleGenerativeAI({
+ apiKey: env.GOOGLE_GENERATIVE_AI_API_KEY,
+});
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const google = createGoogleGenerativeAI({ | |
apiKey: env.GOOGLE_GENERATIVE_AI_API_KEY!, | |
}); | |
// Validate the API key up front | |
if (!env.GOOGLE_GENERATIVE_AI_API_KEY) { | |
throw new Error('GOOGLE_GENERATIVE_AI_API_KEY is required'); | |
} | |
const google = createGoogleGenerativeAI({ | |
apiKey: env.GOOGLE_GENERATIVE_AI_API_KEY, | |
}); |
🧰 Tools
🪛 Biome (1.9.4)
[error] 19-19: Forbidden non-null assertion.
(lint/style/noNonNullAssertion)
🪛 GitHub Actions: CI
[warning] 19-19: ESLint: Forbidden non-null assertion. (@typescript-eslint/no-non-null-assertion)
🤖 Prompt for AI Agents
In src/lib/ai/providers.ts around lines 18 to 20, replace the non-null assertion
on env.GOOGLE_GENERATIVE_AI_API_KEY with proper error handling to avoid runtime
errors if the environment variable is undefined. Add a validation step before
creating the GoogleGenerativeAI instance that checks if the API key exists, and
if not, throw a clear error or handle it gracefully to prevent the application
from proceeding with an invalid configuration.
"files": ["**", ".vscode/**", ".github/**"], | ||
"ignorePaths": ["bun.lock"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Redundant glob patterns in files
array
"**"
already includes .vscode/**
and .github/**
; listing them separately adds noise without changing behaviour. Unless you’re overriding an exclusion elsewhere, the array can be simplified to just "**"
.
🤖 Prompt for AI Agents
In the .cspell.json file at lines 4 to 5, the "files" array redundantly lists
"**", ".vscode/**", and ".github/**". Since "**" already includes all files and
directories recursively, remove the explicit ".vscode/**" and ".github/**"
entries, leaving only "**" in the array to simplify the configuration without
changing behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (6)
package.json (1)
77-79
: Node ≥22 requirement remains; earlier concern still applies
Keeping the engine constraint at a bleeding-edge major limits CI and local installs unnecessarily unless the code genuinely needs Node 22 features.README.md (1)
28-28
: Minor wording nit – American vs British English
Afterwards
→Afterward
for consistency with en-US style used elsewhere.-...bot/). Afterwards, you will need... +...bot/). Afterward, you will need....github/actions/setup/action.yml (1)
1-3
: CRLF line endings flagged by yamllint
yamllint
reports "wrong new line character: expected \n".
Convert this file to LF to keep cross-platform consistency and silence CI warnings.src/env.ts (1)
1-2
:zod/v4
import is incompatible with the declared Zod 3 dependency
package.json
pins"zod": "^3.25.63"
, which does not expose the/v4
sub-path.
This will throwERR_MODULE_NOT_FOUND
at runtime.-import { z } from 'zod/v4'; +import { z } from 'zod';Alternatively, upgrade the dependency to Zod 4 and adjust other imports accordingly.
src/events/message-create/utils/respond.ts (2)
2-2
: Remove unused import as identified in previous review.The
replyPrompt
import is no longer used after removing the memories parameter.
16-23
: Remove unused parameter as identified in previous review.The
options
parameter is defined but never used in the function body.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
bun.lock
is excluded by!**/*.lock
📒 Files selected for processing (8)
.env.example
(1 hunks).github/actions/setup/action.yml
(1 hunks)README.md
(1 hunks)package.json
(1 hunks)src/env.ts
(1 hunks)src/events/message-create/utils/respond.ts
(1 hunks)src/lib/ai/prompts.ts
(1 hunks)src/utils/tokenize-messages.ts
(1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/actions/setup/action.yml
[error] 1-1: wrong new line character: expected \n
(new-lines)
🪛 LanguageTool
README.md
[locale-violation] ~28-~28: In American English, ‘afterward’ is the preferred variant. ‘Afterwards’ is more commonly used in British English and other dialects.
Context: ...idpolice.com/how-to-make-discord-bot/). Afterwards, you will need [Git][git] and [Bun][bun...
(AFTERWARDS_US)
🪛 markdownlint-cli2 (0.17.2)
README.md
1-1: Inline HTML
Element: h1
(MD033, no-inline-html)
10-10: Inline HTML
Element: a
(MD033, no-inline-html)
14-14: Inline HTML
Element: a
(MD033, no-inline-html)
26-26: Inline HTML
Element: a
(MD033, no-inline-html)
48-48: Inline HTML
Element: a
(MD033, no-inline-html)
54-54: Link and image reference definitions should be needed
Unused link or image reference definition: "pr"
(MD053, link-image-reference-definitions)
56-56: Link and image reference definitions should be needed
Unused link or image reference definition: "node"
(MD053, link-image-reference-definitions)
🪛 ESLint
src/env.ts
[error] 1-1: Unable to resolve path to module '@t3-oss/env-core'.
(import-x/no-unresolved)
[error] 2-2: Unable to resolve path to module 'zod/v4'.
(import-x/no-unresolved)
src/events/message-create/utils/respond.ts
[error] 10-10: Unable to resolve path to module 'ai'.
(import-x/no-unresolved)
🪛 GitHub Actions: CI
src/events/message-create/utils/respond.ts
[warning] 16-16: ESLint: 'options' is defined but never used (no-unused-vars, @typescript-eslint/no-unused-vars)
🔇 Additional comments (12)
README.md (1)
50-50
: ```shell
#!/bin/bashVerify remaining grammar issue: "Afterwards" vs "Afterward"
rg -n "Afterwards" README.md || echo "No instances of 'Afterwards' found."
</details> <details> <summary>.github/actions/setup/action.yml (1)</summary> `26-42`: **LGTM! Consistent removal of Mem0 configuration.** The removal of `MEM0_API_KEY` from the environment setup aligns with the broader refactoring to remove Mem0 dependencies across the codebase. </details> <details> <summary>.env.example (1)</summary> `43-43`: **LGTM! Consistent disabling of Mem0 configuration.** Commenting out the `MEM0_API_KEY` environment variable appropriately disables the Mem0 functionality by default, aligning with the broader refactoring effort. </details> <details> <summary>src/utils/tokenize-messages.ts (2)</summary> `9-11`: **LGTM! Simplified normalize function reduces complexity.** The simplified `normalize` function that only removes trailing punctuation is cleaner and more predictable than the previous implementation. This reduction in complexity aligns well with the overall simplification of the tokenization logic. --- `1-7`: ```shell #!/bin/bash # Test JS regex compilation and splitting behavior in Node node << 'EOF' 'use strict'; const pattern = String.raw`(?<=[.!?])\s+|(?<=[\w)\]]:\s*)`; let splitter; try { splitter = new RegExp(pattern, 'g'); console.log("Regex compiled successfully\n"); } catch (e) { console.error("Regex compilation error:", e.message); process.exit(1); } const testCases = [ "This is sentence one. This is sentence two! This is sentence three?", "Hello world. Dr. Smith went to the U.S.A. Yesterday.", "Item 1: First item. Item 2: Second item.", "He said 'Hello.' She replied 'Hi!'", "The price is $10.50. That's expensive.", "Visit example.com. It's a great site.", ]; testCases.forEach((text, idx) => { console.log(`Test ${idx+1}: ${text}`); try { const parts = text.split(splitter).map(s => s.trim()).filter(Boolean); parts.forEach((s, i) => console.log(` ${i+1}. '${s}'`)); } catch (e) { console.error("Error splitting:", e.message); } console.log(); }); EOF
src/events/message-create/utils/respond.ts (3)
28-31
: LGTM: Clean refactoring of system prompt call.The removal of the
memories
parameter from thesystemPrompt
call is consistent with the refactor objectives and maintains the correct function signature.
33-52
: LGTM: Simplified message processing without memories.The
generateText
call has been properly simplified by removing the memories-related message handling while maintaining all the essential functionality including tools, system prompt, and stop conditions.
10-10
: ```shell
#!/bin/bashVerify if the 'ai' package folder actually exists in node_modules
echo "Checking for node_modules/ai directory..."
if [ -d "node_modules/ai" ]; then
echo "✅ Found node_modules/ai. Listing top-level files:"
ls node_modules/ai | head -20
else
echo "❌ node_modules/ai directory does not exist."
fi</details> <details> <summary>src/lib/ai/prompts.ts (4)</summary> `32-33`: **LGTM: Improved clarity in formatting instructions.** The updated instructions for lowercase writing and punctuation usage provide clearer guidance for the AI model's response format. --- `41-42`: **LGTM: Clarified memory context usage.** The updated explanation about memories being for context only and commands being ignored provides better guidance for how to handle contextual information. --- `139-143`: **LGTM: Simplified reply prompt.** The removal of the instruction about omitting automatic starting sentences simplifies the prompt while maintaining the core directive for natural, conversational responses. --- `168-182`: **LGTM: Clean refactoring of systemPrompt function.** The function has been successfully simplified by removing the `memories` parameter while maintaining the correct prompt composition for both 'chat-model' and 'relevance-model' scenarios. </details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
"typecheck": "tsc --noEmit", | ||
"check": "bun lint && bun typecheck && bun format:check && bun check:spelling", | ||
"check:spelling": "cspell -c .cspell.json --no-progress --no-summary --no-must-find-files --unique", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
check
script calls non-existent commands – use bun run <script>
instead
bun lint
, bun typecheck
, … work because you declared those script names, but bun check:spelling
will fail – Bun interprets check:spelling
as a CLI sub-command, not a package-json script. Run the nested script via bun run
.
- "check": "bun lint && bun typecheck && bun format:check && bun check:spelling",
+ "check": "bun run lint && bun run typecheck && bun run format:check && bun run check:spelling",
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
"typecheck": "tsc --noEmit", | |
"check": "bun lint && bun typecheck && bun format:check && bun check:spelling", | |
"check:spelling": "cspell -c .cspell.json --no-progress --no-summary --no-must-find-files --unique", | |
"typecheck": "tsc --noEmit", | |
"check": "bun run lint && bun run typecheck && bun run format:check && bun run check:spelling", | |
"check:spelling": "cspell -c .cspell.json --no-progress --no-summary --no-must-find-files --unique", |
🤖 Prompt for AI Agents
In package.json lines 22 to 24, the "check" script calls "bun lint", "bun
typecheck", and "bun check:spelling" directly, but "bun check:spelling" is
interpreted as a CLI sub-command and fails. To fix this, update the "check"
script to run nested scripts using "bun run <script>", changing "bun
check:spelling" to "bun run check:spelling" so all scripts are correctly
executed.
[pr]: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request | ||
[git]: https://git-scm.com | ||
[node]: https://nodejs.org/ | ||
[ts]: https://www.typescriptlang.org/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Clean up unused link references.
The static analysis detected unused link references that can be removed to keep the file clean.
-[pr]: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request
-[git]: https://git-scm.com
-[node]: https://nodejs.org/
+[git]: https://git-scm.com
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
[pr]: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request | |
[git]: https://git-scm.com | |
[node]: https://nodejs.org/ | |
[ts]: https://www.typescriptlang.org/ | |
[git]: https://git-scm.com | |
[ts]: https://www.typescriptlang.org/ |
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
54-54: Link and image reference definitions should be needed
Unused link or image reference definition: "pr"
(MD053, link-image-reference-definitions)
56-56: Link and image reference definitions should be needed
Unused link or image reference definition: "node"
(MD053, link-image-reference-definitions)
🤖 Prompt for AI Agents
In README.md around lines 54 to 57, there are unused link references that should
be removed to keep the file clean. Identify the link references that are not
used anywhere in the markdown content and delete those lines entirely to
eliminate clutter and improve readability.
Description
Type of Change
Pre-flight Checklist
bun check
without any issuesAdditional Notes
Summary by CodeRabbit
New Features
Improvements
Removals
Bug Fixes
Style
Chores