Crestapps core data storage

From CrestApps/CrestApps.AgentSkills · View interactive version

Crestapps core data storage is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for choosing and registering CrestApps.Core 2.0 persistence. Covers picking Entity Framework Core (CrestApps.Core.Data.EntityCore) or YesSql (CrestApps.Core.Data.YesSql), registering the backing data store on the root builder, per-feature AddEntityCoreStores and AddYesSqlStores calls on the AI

How to use this skill

Skill file

CrestApps.Core Data Storage

You are a CrestApps.Core expert. Help the host choose a backend and register exactly the stores each enabled feature needs.

Guidelines

Entity Framework Core

using CrestApps.Core;
using CrestApps.Core.AI;
using CrestApps.Core.AI.A2A;
using CrestApps.Core.AI.Chat;
using CrestApps.Core.AI.Documents;
using CrestApps.Core.AI.Documents.OpenXml;
using CrestApps.Core.AI.Documents.Pdf;
using CrestApps.Core.AI.Mcp;
using CrestApps.Core.AI.OpenAI;
using CrestApps.Core.Data.EntityCore;

Directory.CreateDirectory(Path.Combine(builder.Environment.ContentRootPath, "App_Data"));

builder.Services.AddCrestAppsCore(crestApps => crestApps
    .AddAISuite(ai => ai
        .AddEntityCoreStores()
        .AddOpenAI()
        .AddChatInteractions(chat => chat.AddEntityCoreStores())
        .AddDocumentProcessing(documents => documents
            .AddEntityCoreStores()
            .AddOpenXml()
            .AddPdf())
        .AddAIMemory(memory => memory.AddEntityCoreStores())
        .AddPersonas(personas => personas.AddEntityCoreStores())
        .AddToolInstances(tools => tools.AddEntityCoreStores())
        .AddA2AClient(a2a => a2a.AddEntityCoreStores())
        .AddMcpClient(mcp => mcp.AddEntityCoreStores())
        .AddMcpServer(mcp => mcp.AddEntityCoreStores()))
    .AddIndexingServices(indexing => indexing.AddEntityCoreStores())
    .AddEntityCoreSqliteDataStore(
        $"Data Source={Path.Combine(builder.Environment.ContentRootPath, "App_Data", "crestapps.db")}"));

// Features registered on IServiceCollection
builder.Services.AddCoreWebCrawlerStoresEntityCore();
builder.Services.AddCoreFileSourceStoresEntityCore();

var app = builder.Build();
await app.Services.InitializeEntityCoreSchemaAsync();

YesSql

using CrestApps.Core.Data.YesSql;
using YesSql.Provider.Sqlite;

builder.Services.AddCrestAppsCore(crestApps => crestApps
    .AddAISuite(ai => ai
        .AddYesSqlStores()
        .AddOpenAI()
        .AddChatInteractions(chat => chat.AddYesSqlStores())
        .AddDocumentProcessing(documents => documents.AddYesSqlStores())
        .AddAIMemory(memory => memory.AddYesSqlStores())
        .AddPersonas(personas => personas.AddYesSqlStores())
        .AddToolInstances(tools => tools.AddYesSqlStores())
        .AddA2AClient(a2a => a2a.AddYesSqlStores())
        .AddMcpClient(mcp => mcp.AddYesSqlStores())
        .AddMcpServer(mcp => mcp.AddYesSqlStores()))
    .AddIndexingServices(indexing => indexing.AddYesSqlStores())
    .AddYesSqlDataStore(configuration => configuration
        .UseSqLite("Data Source=App_Data/crestapps.db;Cache=Shared")));

builder.Services.AddCoreWebCrawlerStoresYesSql();
builder.Services.AddCoreFileSourceStoresYesSql();

YesSql hosts must also create every index table for the stores they registered; see crestapps-core-yessql-stores.

What Each Store Call Registers

| Feature | Call | Stores |

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

| AI suite | CrestAppsAISuiteBuilder.Add*Stores() | IAIProfileStore and the AIProfile catalogs, AIProfileTemplate catalog, writable AIProviderConnection and AIDeployment binding sources, IAIChatSessionManager, IAIChatSessionStore, IAIChatSessionPromptStore, IAIChatSessionEventStore, IAICompletionUsageStore, IAIChatSessionExtractedDataStore |

| Personas | CrestAppsAIPersonasBuilder.Add*Stores() | AIPersona named catalog |

| Profile versions | CrestAppsAIProfileVersionsBuilder.Add*Stores() (from AddProfileVersions(v => v.Add*Stores())) | IAIProfileVersionStore |

| Chat Interactions | CrestAppsChatInteractionsBuilder.Add*Stores() | ChatInteraction catalog, IChatInteractionPromptStore |

| Document processing | CrestAppsDocumentProcessingBuilder.Add*Stores() | IAIDocumentStore, IAIDocumentChunkStore, IAIDataSourceStore |

| AI memory | CrestAppsAIMemoryBuilder.Add*Stores() | IAIMemoryStore |

| Tool instances | CrestAppsAIToolInstancesBuilder.Add*Stores() | AIToolInstance named-source catalog |

| A2A client | CrestAppsA2AClientBuilder.Add*Stores() | A2AConnection catalog |

| MCP client | CrestAppsMcpClientBuilder.Add*Stores() | McpConnection source catalog |

| MCP server | CrestAppsMcpServerBuilder.Add*Stores() | McpPrompt named catalog, McpResource source catalog |

| Indexing | CrestAppsIndexingBuilder.Add*Stores() | ISearchIndexProfileStore |

| Web crawlers | AddCoreWebCrawlerStoresEntityCore() / AddCoreWebCrawlerStoresYesSql() | IWebCrawlerStore, IWebCrawlStateStore, plus ingestion item state and knowledge stores |

| File sources | AddCoreFileSourceStoresEntityCore() / AddCoreFileSourceStoresYesSql() | IFileSourceStore, plus ingestion item state and knowledge stores |

| Knowledge objects | AddCoreKnowledgeStoresEntityCore() / AddCoreKnowledgeStoresYesSql() | IKnowledgeObjectStore |

| Ingestion item state | AddCoreIngestionItemStateStoreEntityCore() / AddCoreIngestionItemStateStoreYesSql() | IIngestionItemStateStore |

Configuration and Database Records

IAIDeploymentStore and IAIProviderConnectionStore are merged views. The configuration binding sources (CrestApps:AI:Deployments, CrestApps:AI:Connections, Order = 100) are always present; the store packages add a writable database source at Order = 0. When both define the same name, the database record wins, and all writes go to the database. Resolve INamedSourceCatalog<AIDeployment> when you need only the database-backed records. Custom sources are covered in crestapps-core-foundations.

Custom Backend

Implement the catalog interfaces (ICatalog<T> and, where the model supports it, INamedCatalog<T>, ISourceCatalog<T>, INamedSourceCatalog<T>) and the store interfaces the features resolve (for example IAIChatSessionManager, IAIDocumentStore), register them as scoped, and register a scoped IStoreCommitter when writes are staged. Register AddCatalogManagers() so managers and handlers run over your catalogs.

A custom IAIChatSessionStore must implement ListByLastActivityAsync(profileId, afterUtc, beforeUtc, count, cancellationToken) (a profile's sessions with LastActivityUtc after the optional time and before the other, oldest first, up to count) and DeleteAsync(sessionId, cancellationToken) (delete the session and its prompts, leave its documents to the caller, return false when it does not exist). Conversation privacy and retention use them for sessions of any user, visitor or system channel. A custom IAIChatSessionManager.PageAsync should also honor AIChatSessionQueryContext.UserId, which past-conversation memory sets, and AIChatSessionQueryContext.ClientId (one anonymous visitor's sessions).

Upgrading Within 2.0 Previews

Upgrading from 1.x

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.