34 lines
1.3 KiB
C#
Executable File
34 lines
1.3 KiB
C#
Executable File
using MarketAlly.AIPlugin;
|
|
using MarketAlly.AIPlugin.Refactoring.Plugins;
|
|
|
|
namespace MarketAlly.AIPlugin.Refactoring.Plugins;
|
|
|
|
[AIPlugin("github-validate", "Validate GitHub repository accessibility and get metadata")]
|
|
public class GitHubValidatePlugin : IAIPlugin
|
|
{
|
|
[AIParameter("GitHub repository URL to validate", required: true)]
|
|
public string RepositoryUrl { get; set; } = string.Empty;
|
|
|
|
public IReadOnlyDictionary<string, Type> SupportedParameters => new Dictionary<string, Type>
|
|
{
|
|
["repositoryUrl"] = typeof(string),
|
|
["repositoryurl"] = typeof(string)
|
|
};
|
|
|
|
public async Task<AIPluginResult> ExecuteAsync(IReadOnlyDictionary<string, object> parameters)
|
|
{
|
|
try
|
|
{
|
|
var repositoryUrl = (parameters.ContainsKey("repositoryUrl") ? parameters["repositoryUrl"] :
|
|
parameters.ContainsKey("repositoryurl") ? parameters["repositoryurl"] : null)?.ToString();
|
|
var cloneManager = new GitHubCloneManager();
|
|
var validation = await cloneManager.ValidateRepositoryAsync(repositoryUrl);
|
|
|
|
return new AIPluginResult(validation, validation.IsValid ? "Repository validation successful" : "Repository validation failed");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new AIPluginResult(ex, "Validation failed");
|
|
}
|
|
}
|
|
} |