Skip to content

feat: support plugins option on cli - #198

Merged
kazupon merged 3 commits into
mainfrom
feat/accept-user-plugin
Jun 24, 2025
Merged

kazupon merged 3 commits into
mainfrom
feat/accept-user-plugin

Conversation

@kazupon

@kazupon kazupon commented Jun 24, 2025

Copy link
Copy Markdown
Owner

Description

Linked Issues

Additional context

Summary by CodeRabbit

  • New Features
    • Added support for user-defined plugins in the CLI, allowing enhanced customization and extensibility.
  • Tests
    • Introduced a new test case to verify correct integration and logging behavior of plugins within the CLI framework.
  • Chores
    • Updated type checking script to use a new tool for improved diagnostics.

@coderabbitai

coderabbitai Bot commented Jun 24, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

A plugin system was integrated into the CLI framework by updating the CLI options and core logic to accept and apply user-provided plugins in addition to built-in ones. Type definitions and constants were updated to support the new plugins property, and a test was added to verify plugin functionality within the CLI. The type-check script was also switched from tsc to tsgo.

Changes

Files/Paths Change Summary
packages/gunshi/src/cli.ts Modified to concatenate user-provided plugins with built-in plugins before applying them.
packages/gunshi/src/types.ts Added optional plugins?: Plugin[] property to the CliOptions interface.
packages/gunshi/src/constants.ts Added plugins property (default undefined) to COMMAND_OPTIONS_DEFAULT constant.
packages/gunshi/src/cli.test.ts Added a test case to verify the CLI's ability to use user-supplied plugins.
package.json Changed the type-check script from tsc to tsgo with the same flags.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant BuiltInPlugins
    participant UserPlugins
    participant PluginSystem
    participant Command

    User->>CLI: Invoke CLI with options (including plugins)
    CLI->>BuiltInPlugins: Collect built-in plugins
    CLI->>UserPlugins: Collect user-provided plugins
    CLI->>PluginSystem: Apply built-in + user plugins
    PluginSystem->>Command: Decorate/modify command execution
    User->>CLI: Run command
    CLI->>Command: Execute (with plugins applied)
    Command-->>CLI: Return result (possibly modified by plugins)
    CLI-->>User: Output result
Loading

Possibly related PRs

Poem

🐇
Plugins now hop into the CLI,
Bringing new tricks as commands fly.
With a decorator’s gentle touch,
They log and tweak and do so much!
Rabbits cheer with every run—
More features, more fun,
The plugin journey’s just begun!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 25b1c1d and 5d8c535.

📒 Files selected for processing (1)
  • packages/gunshi/src/cli.test.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/gunshi/src/cli.test.ts
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@kazupon kazupon added the feature Includes new features label Jun 24, 2025
@pkg-pr-new

pkg-pr-new Bot commented Jun 24, 2025

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/gunshi@198

commit: 5d8c535

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 24, 2025

Copy link
Copy Markdown

Deploying gunshi with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5d8c535
Status: ✅  Deploy successful!
Preview URL: https://0aad9338.gunshi.pages.dev
Branch Preview URL: https://feat-accept-user-plugin.gunshi.pages.dev

View logs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dba846f and 4f79486.

📒 Files selected for processing (4)
  • packages/gunshi/src/cli.test.ts (2 hunks)
  • packages/gunshi/src/cli.ts (1 hunks)
  • packages/gunshi/src/constants.ts (1 hunks)
  • packages/gunshi/src/types.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`packages/gunshi/src/**/*.ts`: All source code must be written in TypeScript with strict mode enabled. Use ES modules throughout the codebase. Follow the existing code style, which...

packages/gunshi/src/**/*.ts: All source code must be written in TypeScript with strict mode enabled.
Use ES modules throughout the codebase.
Follow the existing code style, which is enforced by ESLint and Prettier.

  • packages/gunshi/src/constants.ts
  • packages/gunshi/src/cli.ts
  • packages/gunshi/src/types.ts
  • packages/gunshi/src/cli.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (6)
packages/gunshi/src/types.ts (2)

7-9: LGTM! Clean import organization and type integration.

The Plugin import is properly placed and the reorganized import structure improves readability.


258-261: Well-defined plugins property in CliOptions interface.

The optional plugins property is correctly typed as Plugin[] and properly documented, maintaining consistency with the rest of the interface.

packages/gunshi/src/constants.ts (1)

69-70: Consistent default value for plugins option.

The plugins: undefined default value aligns perfectly with the optional nature of the plugins property in the CliOptions interface.

packages/gunshi/src/cli.ts (1)

57-57: Excellent plugin integration implementation.

The concatenation of built-in plugins with user plugins using the spread operator and safe fallback (options.plugins || []) correctly handles both defined and undefined plugin arrays.

packages/gunshi/src/cli.test.ts (2)

6-6: Good addition of plugin import.

The import is correctly added to support the new plugin functionality test.


1156-1192: Comprehensive test case for plugin functionality.

The test effectively demonstrates the plugin system by:

  • Creating a logger plugin that decorates command execution
  • Testing plugin integration with the CLI
  • Verifying expected logging behavior

This provides good coverage for the new plugin functionality.

Comment thread packages/gunshi/src/cli.test.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4f79486 and 25b1c1d.

📒 Files selected for processing (2)
  • package.json (1 hunks)
  • packages/gunshi/src/cli.test.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/gunshi/src/cli.test.ts

Comment thread package.json
@kazupon
kazupon merged commit 26a6016 into main Jun 24, 2025
@kazupon
kazupon deleted the feat/accept-user-plugin branch June 24, 2025 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Includes new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant