Orchardcore crestapps recipes

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore crestapps recipes is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for the CrestApps Recipes module in Orchard Core, which publishes JSON Schema for recipe steps. Covers RecipeSchemaService, RecipeExecutionService, the schema-aware JSON Import editor, custom IRecipeStep providers, Settings step contributions, content definition and content item schemas, the c

How to use this skill

Skill file

CrestApps Recipes

Generate accurate Orchard Core recipe schemas

You are an Orchard Core expert. The CrestApps Recipes module publishes JSON Schema for Orchard Core and CrestApps recipe steps, one schema per step, composed into a single recipe schema with a steps array. It does not replace Orchard Core's recipe handlers; it describes the payloads they accept so that recipes generated by people or AI agents can be validated before they run.

Guidelines

Feature overview

| Feature ID | Purpose |

|---|---|

| CrestApps.OrchardCore.Recipes | JSON Schema services, feature-gated step schemas, schema-aware JSON import editor |

| OrchardCore.Recipes.Core | Orchard Core recipe infrastructure (dependency) |

{
  "steps": [
    {
      "name": "Feature",
      "enable": [
        "CrestApps.OrchardCore.Recipes"
      ],
      "disable": []
    }
  ]
}

What the module provides

Schema-aware JSON import

With the feature enabled, the Orchard Core Deployment > JSON Import screen is replaced (through a view location expander) by a Monaco editor fed with RecipeSchemaService.GetRecipeSchemaAsync(), so administrators get autocomplete and validation for every registered step.

Retrieve schemas in application code

RecipeSchemaService (namespace CrestApps.OrchardCore.Recipes.Core.Services) is scoped.

| Member | Returns |

|---|---|

| GetRecipeSchemaAsync(cancellationToken) | The full recipe schema with every registered step |

| GetRecipeSchemaAsync(requestedStep, cancellationToken) | The recipe schema narrowed to one step, or null when no registered step has that name |

| GetStepSchemaAsync(stepName, cancellationToken) | The schema of one step, or null |

| GetStepNames() | Names of the steps with a registered IRecipeStep |

using CrestApps.OrchardCore.Recipes.Core.Services;
using Json.Schema;

namespace MyModule;

public sealed class RecipeSchemaLookup
{
    private readonly RecipeSchemaService _recipeSchemaService;

    public RecipeSchemaLookup(RecipeSchemaService recipeSchemaService)
    {
        _recipeSchemaService = recipeSchemaService;
    }

    public ValueTask<JsonSchema> GetContentDefinitionRecipeSchemaAsync(CancellationToken cancellationToken)
        => _recipeSchemaService.GetRecipeSchemaAsync("ContentDefinition", cancellationToken);
}

How the composed schema behaves:

Define a custom recipe step schema

Implement IRecipeStep (namespace CrestApps.OrchardCore.Recipes.Core), or derive from RecipeStepSchemaBase (namespace ...Schemas.Steps), which caches the result of CreateSchema().

using CrestApps.OrchardCore.Recipes.Core.Schemas.Steps;
using Json.Schema;

namespace MyModule.Recipes;

public sealed class ProductSettingsRecipeStep : RecipeStepSchemaBase
{
    public override string Name => "ProductSettings";

    protected override JsonSchema CreateSchema()
        => new JsonSchemaBuilder()
            .Type(SchemaValueType.Object)
            .Properties(
                ("name", new JsonSchemaBuilder()
                    .Type(SchemaValueType.String)
                    .Const("ProductSettings")),
                ("AllowBackorders", new JsonSchemaBuilder()
                    .Type(SchemaValueType.Boolean)
                    .Description("Whether out-of-stock products can still be ordered.")))
            .Required("name")
            .AdditionalProperties(false)
            .Build();
}
using CrestApps.OrchardCore.Recipes.Core;
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Modules;

namespace MyModule;

[RequireFeatures("CrestApps.OrchardCore.Recipes")]
public sealed class RecipesSchemaStartup : StartupBase
{
    public override void ConfigureServices(IServiceCollection services)
    {
        services.AddScoped<IRecipeStep, ProductSettingsRecipeStep>();
    }
}

Put the registration in a startup gated on both your feature and CrestApps.OrchardCore.Recipes so your module does not require the Recipes feature at runtime. Pair the schema with an Orchard Core recipe handler (see the framework orchardcore-recipes skill) when the step is executable.

Describe a site settings section for the Settings step

The Settings step composes one property per registered ISiteSettingsSchemaDefinition. Derive from SiteSettingsSchemaBase (namespace ...Schemas.SiteSettings); Name is the property name under the step, normally the settings class name.

using CrestApps.OrchardCore.Recipes.Core.Schemas.SiteSettings;
using Json.Schema;

namespace MyModule.Recipes;

public sealed class ProductSettingsSchema : SiteSettingsSchemaBase
{
    public override string Name => "ProductSettings";

    protected override JsonSchemaBuilder BuildSchemaCore()
        => new JsonSchemaBuilder()
            .Type(SchemaValueType.Object)
            .Properties(
                ("AllowBackorders", new JsonSchemaBuilder().Type(SchemaValueType.Boolean)))
            .AdditionalProperties(false);
}

Register it with services.AddScoped<ISiteSettingsSchemaDefinition, ProductSettingsSchema>(); behind the feature whose SiteDisplayDriver<TSettings> owns the settings.

Condition rules

A step or settings property that holds a "match all/any of these conditions" rule (CrestApps.OrchardCore.Conditions) describes it with ConditionRuleSchema.Build(description, sourceDescription) (namespace CrestApps.OrchardCore.Recipes.Core.Schemas). The schema is an object (or null) with Match (ConditionMatch: All or Any) and Conditions, each with Source, Operator (ConditionOperator names) and string Values in the invariant culture. Conditional fields (ShowWhen) and work order rules use it.

("ShowWhen", ConditionRuleSchema.Build(
    "When the field is shown. Empty shows it always.",
    "The technical name of the field whose value is tested."))

Extend content definition and content item schemas

IContentSchemaDefinition contributes the Settings envelope of a part or field to ContentDefinition and ReplaceContentDefinition. PartSchemaDefinitionBase and FieldSchemaDefinitionBase also contribute the payload used by the Content step. Contributions are grouped by Name, so several contributors to the same part or field merge instead of replacing each other.

using CrestApps.OrchardCore.Recipes.Core.Schemas.Fields;
using Json.Schema;

namespace MyModule.Schemas;

public sealed class RatingFieldSchemaDefinition : FieldSchemaDefinitionBase
{
    public override string Name => "RatingField";

    protected override JsonSchemaBuilder BuildSettingsCore()
        => new JsonSchemaBuilder()
            .Type(SchemaValueType.Object)
            .Properties(
                ("RatingFieldSettings", new JsonSchemaBuilder()
                    .Type(SchemaValueType.Object)
                    .Properties(
                        ("Maximum", new JsonSchemaBuilder().Type(SchemaValueType.Integer)))
                    .AdditionalProperties(false)))
            .AdditionalProperties(true);

    protected override JsonSchemaBuilder BuildFieldSchemaCore()
        => new JsonSchemaBuilder()
            .Type(SchemaValueType.Object)
            .Properties(
                ("Value", new JsonSchemaBuilder().Type(SchemaValueType.Integer)))
            .AdditionalProperties(true);
}
services.AddScoped<IContentSchemaDefinition, RatingFieldSchemaDefinition>();

Read references/content-schemas.md for part schemas, the two settings surfaces (ContentParts[].Settings and ContentTypePartDefinitionRecords[].Settings), container parts (IContainedContentPartSchemaDefinition), and complete ContentDefinition and Content examples.

Extend composed recipe step schemas

Each polymorphic step composes its schema from one contribution per condition, source, step, node, filter or activity. The base class adds the shared members; you describe only the type's own members. Register the contribution behind the feature that owns the type.

| Step | Base class | Registration | Keyed by | Recipes gate |

|---|---|---|---|---|

| Layers conditions | RuleConditionSchemaDefinitionBase, OperandConditionSchemaDefinitionBase, ConditionGroupSchemaDefinitionBase | AddRuleConditionSchema<T>() | Name + $type | OrchardCore.Layers |

| Layers operators | RuleConditionOperatorSchemaDefinitionBase, StringOperatorSchemaDefinitionBase | AddRuleConditionOperatorSchema<T>() | $type | OrchardCore.Layers |

| Sitemaps | SitemapSourceSchemaDefinitionBase | AddSitemapSourceSchema<T>() | $type | OrchardCore.Sitemaps |

| deployment | DeploymentStepSchemaDefinitionBase | AddDeploymentStepSchema<T>() | StepType (the Type value) | OrchardCore.Deployment |

| AdminMenu | AdminNodeSchemaDefinitionBase | AddAdminNodeSchema<T>() | $type | OrchardCore.AdminMenu |

| Queries | QuerySourceSchemaDefinitionBase | AddQuerySourceSchema<T>() | Name (the Source value) | OrchardCore.Queries |

| UrlRewriting | RewriteRuleSourceSchemaDefinitionBase | AddRewriteRuleSourceSchema<T>() | Name (the Source value) | OrchardCore.UrlRewriting |

| Placements | PlacementNodeFilterSchemaDefinitionBase | AddPlacementNodeFilterSchema<T>() | Key | OrchardCore.Placements |

| WorkflowType | WorkflowActivitySchemaDefinitionBase | AddWorkflowActivitySchema<T>() | activity Name | OrchardCore.Workflows |

Base classes live in CrestApps.OrchardCore.Recipes.Core.Schemas.<Family> (Rules, Rules.Conditions, Rules.Operators, Sitemaps, Deployment, AdminMenu, Queries, UrlRewriting, Placements, Workflows). The Add...Schema<T>() extensions live in Microsoft.Extensions.DependencyInjection. When two definitions share a name, the last registered wins, which lets you override a built-in description.

Example, a deployment step contribution:

using CrestApps.OrchardCore.Recipes.Core.Schemas.Deployment;
using Json.Schema;

namespace MyModule.Schemas;

public sealed class ProductCatalogDeploymentStepSchema : DeploymentStepSchemaDefinitionBase
{
    public override string StepType => "ProductCatalogDeploymentStep";

    protected override string DisplayText => "Product catalog";

    protected override string Description => "Exports the product catalog.";

    protected override IEnumerable<(string Name, JsonSchemaBuilder Schema)> GetPropertyDefinitions(DeploymentStepSchemaContext context)
    {
        yield return ("IncludeArchived", DeploymentSchemaBuilders.Boolean("When true, archived products are included."));
        yield return ("ContentTypes", DeploymentSchemaBuilders.StringArray("Content types to export.", context.Examples.ContentTypeNames));
    }
}
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Modules;

namespace MyModule;

[RequireFeatures("CrestApps.OrchardCore.Recipes", "OrchardCore.Deployment")]
public sealed class DeploymentSchemaStartup : StartupBase
{
    public override void ConfigureServices(IServiceCollection services)
    {
        services.AddDeploymentStepSchema<ProductCatalogDeploymentStepSchema>();
    }
}

Read these references for the full contract, built-in coverage and examples of each family:

Surface live tenant example values

IRecipeSchemaExampleService.GetExamplesAsync() returns a RecipeSchemaExamples snapshot with ContentTypeNames, ContentPartNames, CultureNames, RoleNames and IndexProfileNames. Family definitions receive it as context.Examples (admin menu, deployment, query, rule, sitemap and workflow contexts).

Never turn an example list into an enum. Examples are non-restrictive, so a recipe that references a type, role, culture or index added later still validates.

Execute a generated recipe

RecipeExecutionService.ExecuteRecipeAsync(JsonNode data) writes the JSON to a temporary Recipe.json under the tenant temp directory and imports it through every registered IDeploymentTargetHandler in sequence. It returns false and logs the exception when anything fails.

using System.Text.Json.Nodes;
using CrestApps.OrchardCore.Recipes.Core.Services;

namespace MyModule;

public sealed class GeneratedRecipeExecutor
{
    private readonly RecipeExecutionService _recipeExecutionService;

    public GeneratedRecipeExecutor(RecipeExecutionService recipeExecutionService)
    {
        _recipeExecutionService = recipeExecutionService;
    }

    public Task<bool> ExecuteAsync(JsonObject recipe)
        => _recipeExecutionService.ExecuteRecipeAsync(recipe);
}

Validate generated JSON against RecipeSchemaService first, authorize the caller for every operation the recipe performs, and never run untrusted Command or deployment payloads without review.

Upgrading from 2.x

Troubleshooting

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.