Skip to content

HueByte/Jiro.Libs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jiro AI Assistant Banner

Build Status Latest Release Last Commit GitHub Stars GitHub Issues License .NET 9.0 Code Size NuGet Version NuGet Downloads

Jiro.Commands

A flexible command and plugin framework for Jiro

Jiro.Commands provides a robust, extensible system for building plugins and runtime commands for the Jiro platform. It enables modular development, dynamic feature loading, and a clean separation of concerns for your application.


Features

  • Plugin Management: Standardized loading/unloading of plugins at runtime.
  • Runtime Command Creation: Add new commands without rebuilding or redeploying your app.
  • Dependency Injection: Full support for DI in commands and plugins.
  • Custom Controllers: Easily extend your API surface with plugin controllers.
  • Strong Typing & Parsing: Type-safe command parameters and extensible parsing.
  • XML Documentation: All public APIs are fully documented for IntelliSense and doc generation.

Getting Started

Installation

Install via NuGet Package Manager:

dotnet add package Jiro.Commands

Or via Package Manager Console:

Install-Package Jiro.Commands

Plugin Development

Create a plugin by implementing the IPlugin interface:

public class PluginMain : IPlugin
{
    public string PluginName { get; } = "PluginMain";

    // Optional: Register configuration files
    public void RegisterAppConfigs(ConfigurationManager builder)
        => builder.AddJsonFile("example.config.json", optional: true, reloadOnChange: true);

    // Optional: Register middleware
    public void RegisterAppExtensions(IApplicationBuilder app)
        => app.UsePluginMiddleware();

    // Required: Register services
    public void RegisterServices(IServiceCollection services)
        => services.AddScoped<IPluginService, PluginService>();
}

Plugin requirements:

  • Implement IPlugin.
  • Provide a unique PluginName.
  • Register any services, configs, or middleware as needed.

Custom Controllers

Extend the API by inheriting from BaseController:

public class PluginController : BaseController
{
    [HttpGet("PluginTest")]
    public IActionResult PluginTest() => Ok("Plugin Controller Executed");
}

Custom Commands

Define commands by using attributes and implementing ICommandBase:

[CommandModule("PluginCommand")]
public class PluginCommand : ICommandBase
{
    private readonly IPluginService _pluginService;
    public PluginCommand(IPluginService pluginService) => _pluginService = pluginService;

    [Command("PluginTest", commandSyntax: "PluginTest", commandDescription: "Tests plugin command")]
    public async Task<ICommandResult> PluginTest()
    {
        _pluginService.ServiceTest();
        await Task.Delay(1000);
        return TextResult.Create("Plugin Command Executed");
    }
}

Command requirements:

  • Class must have [CommandModule] attribute.
  • Class must implement ICommandBase.
  • Command methods must have [Command] attribute (with at least a name).
  • Command methods must return Task<ICommandResult>.
  • Use TextResult.Create, ImageResult.Create, JsonResult.Create, or GraphResult.Create for results.

API Reference

  • All public APIs are documented with XML comments.
  • See the source code for detailed usage and extension points.

Contributing

Contributions, issues, and feature requests are welcome! Please open an issue or pull request on GitHub.

Development Setup

This project uses EditorConfig to maintain consistent coding styles. Make sure your editor supports EditorConfig or install the appropriate extension:

Code Formatting

  • Run dotnet format before committing to ensure code follows the project's style guidelines
  • The CI pipeline will verify that code formatting is consistent

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Commands base for Jiro

Resources

License

Stars

Watchers

Forks

Contributors