Skip to content

Conversation

@Coder-soft
Copy link
Owner

No description provided.

Coder-soft and others added 9 commits December 6, 2025 16:33
Added docs and multiple event types to the application including threads and bulk messages and some more
…API key security documentation, and include wget in Dockerfile
Fixing major and critical bugs, adding more support to the plug-in system, and improving a lot of ways to introduce a much more centralized way of developing plugins
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 8, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch master

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Coder-soft
Copy link
Owner Author

@greptile review pls

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 8, 2025

Greptile Overview

Greptile Summary

This PR represents a major architectural upgrade to HoloBridge, transforming it from a basic Discord bridge into a comprehensive plugin platform with REST API capabilities. The changes introduce a comprehensive plugin SDK with REST route registration, typed event subscriptions through an event bus, and inter-plugin communication features. Core improvements include enhanced error handling across all Discord API routes with try-catch blocks, standardized error responses, and proper TypeScript type safety. The plugin system now supports mounting custom HTTP endpoints at /api/plugins/{name}, subscribing to Discord events and custom events through a structured event bus, and includes lifecycle management with proper cleanup. Additional security improvements include cryptographically secure API key generation, enhanced input validation with Zod schemas, and better configuration management. The changes maintain backward compatibility while providing a migration path to the new plugin architecture.

Important Files Changed

Filename Score Overview
.github/workflows/static.yml 1/5 Adds GitHub Actions workflow that exposes entire repository including source code and secrets to public GitHub Pages
src/plugins/manager.ts 2/5 Enhances plugin system with REST API support but contains critical bug referencing non-existent property
plugins/example-plugin.js 4/5 Transforms example plugin to demonstrate new comprehensive plugin system with REST routes and typed events
src/api/server.ts 4/5 Integrates plugin system with main API server to mount plugin routes at /api/plugins
src/index.ts 5/5 Passes Express app instance to plugin system enabling REST API route mounting
src/api/middleware/auth.ts 5/5 Preserves original API key creation timestamps instead of overwriting with current time
Dockerfile 5/5 Adds wget installation to support healthcheck functionality in Alpine container
src/api/routes/emojis.ts 5/5 Adds comprehensive error handling and TypeScript type safety to emoji management endpoints
src/api/routes/invites.ts 5/5 Wraps invite routes in try-catch blocks with standardized error responses and logging
plugins/example-api-plugin.js 5/5 New comprehensive CRUD REST API plugin demonstrating full plugin capabilities with validation and events
src/types/auth.types.ts 5/5 Adds security documentation and prepares interface for future hashed API key storage
src/api/routes/scheduled-events.ts 5/5 Enhances scheduled events routes with error handling and replaces unsafe type assertions
src/discord/services/scheduled-event.service.ts 5/5 Adds try-catch error handling to Discord API calls with fallback values and logging
src/api/routes/webhooks.ts 5/5 Implements comprehensive error handling for webhook routes with specific error codes
src/discord/services/emoji.service.ts 5/5 Adds error handling to emoji service Discord API calls with graceful fallback behavior
src/config/index.ts 5/5 Enhances API key configuration with Zod validation and optional createdAt field
src/api/middleware/rateLimit.ts 5/5 Fixes memory leak issues with proper cleanup mechanism and shutdown function
src/discord/services/webhook.service.ts 5/5 Fixes critical API mapping issue for webhook editing channelId parameter
bin/holo.js 5/5 Improves CLI with cryptographically secure API key generation and better error handling
src/api/routes/stickers.ts 5/5 Adds consistent try-catch error handling across all sticker management endpoints
src/discord/services/automod.service.ts 4/5 Adds error handling to AutoMod service but with inconsistent logging approach
src/api/routes/stage-instances.ts 5/5 Enhances stage instance routes with error handling and input validation for PATCH requests
src/plugins/event-bus.ts 5/5 New centralized event bus system for inter-plugin communication with subscription tracking
plugins/README.md 5/5 Comprehensive documentation update reflecting new plugin SDK architecture and capabilities
src/plugins/sdk.ts 5/5 New Plugin SDK providing type-safe wrappers, error handling, and standardized API responses
src/discord/services/stage-instance.service.ts 5/5 Improves error handling, type safety, and adds proper channel type validation
src/api/routes/automod.ts 5/5 Significantly enhances routes with comprehensive Zod validation and proper error handling
src/types/plugin.types.ts 5/5 Defines comprehensive TypeScript interfaces for enhanced plugin system with REST and event capabilities

Confidence score: 2/5

  • This PR has significant architectural changes but contains critical security vulnerabilities and implementation bugs that must be addressed
  • Score reflects two major issues: GitHub Actions workflow exposing entire codebase publicly and critical bug in plugin manager referencing non-existent property
  • Pay close attention to .github/workflows/static.yml (major security vulnerability) and src/plugins/manager.ts (runtime error bug)

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as "CLI (holo.js)"
    participant Main as "Main (index.ts)"
    participant Discord as "Discord Client"
    participant Config as "Config Loader"
    participant PluginMgr as "Plugin Manager"
    participant APIServer as "API Server"
    participant Middleware as "Auth Middleware"
    participant Routes as "API Routes"
    participant Services as "Discord Services"
    
    User->>CLI: "holo start"
    CLI->>Main: "Execute main()"
    Main->>Config: "Load configuration"
    Config-->>Main: "Return config with Discord token, API keys"
    
    Main->>Discord: "loginDiscord()"
    Discord-->>Main: "Connection established"
    Main->>Discord: "waitForReady()"
    Discord-->>Main: "Ready state confirmed"
    
    Main->>APIServer: "createApiServer()"
    APIServer-->>Main: "Return server instance with Express app, Socket.IO"
    
    Main->>PluginMgr: "setContext(client, io, config, app)"
    PluginMgr-->>Main: "Context initialized"
    
    Main->>PluginMgr: "loadPlugins()"
    PluginMgr->>PluginMgr: "Read plugins directory"
    PluginMgr->>PluginMgr: "Load plugin files"
    PluginMgr-->>Main: "Plugins loaded"
    
    Main->>APIServer: "startApiServer()"
    APIServer-->>Main: "Server listening on port"
    
    Note over Main: "HoloBridge ready"
    
    User->>APIServer: "API Request with X-API-Key"
    APIServer->>Middleware: "authMiddleware()"
    Middleware->>Config: "Validate API key"
    Config-->>Middleware: "Key validation result"
    Middleware-->>APIServer: "Authenticated request"
    
    APIServer->>Routes: "Route handler"
    Routes->>Services: "Discord service call"
    Services->>Discord: "Discord API operation"
    Discord-->>Services: "Discord response"
    Services-->>Routes: "Serialized data"
    Routes-->>APIServer: "JSON response"
    APIServer-->>User: "API response"
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

28 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +142 to +150
const globalCleanupInterval = setInterval(() => {
const now = Date.now();
for (const [key, entry] of rateLimitStore) {
if (entry.resetAt < now) {
rateLimitStore.delete(key);
}
}
}, 60000);
cleanupIntervals.push(globalCleanupInterval);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: the global cleanup interval runs immediately at module load time (before any server is started), creating a timer that runs forever even if the server is never started or fails to start

Suggested change
const globalCleanupInterval = setInterval(() => {
const now = Date.now();
for (const [key, entry] of rateLimitStore) {
if (entry.resetAt < now) {
rateLimitStore.delete(key);
}
}
}, 60000);
cleanupIntervals.push(globalCleanupInterval);
// Track the global cleanup interval (initialized when server starts)
let globalCleanupInterval: NodeJS.Timeout | null = null;
/**
* Initialize the global rate limiter cleanup interval.
* Should be called when the server starts.
*/
export function initRateLimiter(): void {
if (!globalCleanupInterval) {
globalCleanupInterval = setInterval(() => {
const now = Date.now();
for (const [key, entry] of rateLimitStore) {
if (entry.resetAt < now) {
rateLimitStore.delete(key);
}
}
}, 60000);
cleanupIntervals.push(globalCleanupInterval);
}
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/api/middleware/rateLimit.ts
Line: 142:150

Comment:
**logic:** the global cleanup interval runs immediately at module load time (before any server is started), creating a timer that runs forever even if the server is never started or fails to start

```suggestion
// Track the global cleanup interval (initialized when server starts)
let globalCleanupInterval: NodeJS.Timeout | null = null;

/**
 * Initialize the global rate limiter cleanup interval.
 * Should be called when the server starts.
 */
export function initRateLimiter(): void {
    if (!globalCleanupInterval) {
        globalCleanupInterval = setInterval(() => {
            const now = Date.now();
            for (const [key, entry] of rateLimitStore) {
                if (entry.resetAt < now) {
                    rateLimitStore.delete(key);
                }
            }
        }, 60000);
        cleanupIntervals.push(globalCleanupInterval);
    }
}
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 77 to +78
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: the loadedPlugins getter doesn't exist in the class definition, causing a runtime error

Suggested change
};
listPlugins: () => Array.from(this.plugins.keys()),
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/plugins/manager.ts
Line: 77:78

Comment:
**logic:** the `loadedPlugins` getter doesn't exist in the class definition, causing a runtime error

```suggestion
            listPlugins: () => Array.from(this.plugins.keys()),
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Comments (2)

  1. src/discord/services/automod.service.ts, line 30-35 (link)

    style: inconsistent error handling - this method silently catches errors without logging, unlike other methods in this service. Should this method log errors like getAutoModRules and createAutoModRule do for consistency?

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

  2. src/discord/services/automod.service.ts, line 61-67 (link)

    style: inconsistent error handling - silently catches errors without logging, unlike getAutoModRules and createAutoModRule

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

28 files reviewed, 5 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +38 to +40
with:
# Upload entire repository
path: '.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: uploading entire repository exposes all source code, environment files, and potential secrets publicly on GitHub Pages

Suggested change
with:
# Upload entire repository
path: '.'
with:
# Upload only documentation directory
path: 'docs'
Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/static.yml
Line: 38:40

Comment:
**logic:** uploading entire repository exposes all source code, environment files, and potential secrets publicly on GitHub Pages

```suggestion
        with:
          # Upload only documentation directory
          path: 'docs'
```

How can I resolve this? If you propose a fix, please make it concise.

onLoad(ctx) {
ctx.logger.info('Example plugin v2.0.0 loaded!');
ctx.logger.info(`Connected to ${ctx.client.guilds.cache.size} guild(s)`);
ctx.logger.info(`Other plugins: ${ctx.listPlugins().join(', ') || 'none yet'}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: calls ctx.listPlugins() which references the non-existent loadedPlugins property in the plugin manager, causing a runtime error

Prompt To Fix With AI
This is a comment left during a code review.
Path: plugins/example-plugin.js
Line: 101:101

Comment:
**logic:** calls `ctx.listPlugins()` which references the non-existent `loadedPlugins` property in the plugin manager, causing a runtime error

How can I resolve this? If you propose a fix, please make it concise.

success: false,
error: 'Invalid request body',
code: 'VALIDATION_ERROR',
details: parseResult.error.issues,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: inconsistent error response structure - uses 'details' instead of 'issues' like the POST route

Suggested change
details: parseResult.error.issues,
issues: parseResult.error.issues.map(issue => ({
path: issue.path.join('.'),
message: issue.message,
})),
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/api/routes/automod.ts
Line: 157:157

Comment:
**style:** inconsistent error response structure - uses 'details' instead of 'issues' like the POST route

```suggestion
                issues: parseResult.error.issues.map(issue => ({
                    path: issue.path.join('.'),
                    message: issue.message,
                })),
```

How can I resolve this? If you propose a fix, please make it concise.

@Coder-soft Coder-soft closed this Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants