Back to Rig

Rig Core

.continue/rules/rig-core.md

latest1.7 KB
Original Source
<!-- This file is generated by scripts/sync_agent_instruction_files.sh. --> <!-- Do not edit this file directly; update AGENTS.md and re-run the sync script. -->

name: Rig Core Architecture globs: "**/*.rs" alwaysApply: false

Apply these Rig architectural constraints when editing Rust code.

rig-core-patterns

Rig is built on several core principles that all contributions must respect:

Trait-Based Abstractions

Rig uses traits to define provider-agnostic interfaces:

  • CompletionModel - For text completion/chat models
  • EmbeddingModel - For embedding generation
  • VectorStoreIndex - For vector similarity search
  • Tool - For defining callable tools

New implementations should implement these traits rather than creating parallel abstractions.

Builder Pattern

Nearly every configurable type uses the builder pattern:

rust
let agent = client
    .agent(openai::GPT_5_2)
    .preamble("System prompt")
    .tool(my_tool)
    .temperature(0.8)
    .build();

Follow this pattern for any new configurable types.

Generic Client Architecture

The client system uses a generic architecture with provider extensions:

rust
pub struct Client<Ext = Nothing, H = reqwest::Client> {
    // ...
}

Where Ext is a provider extension defining capabilities and H is the HTTP backend.

Capability-Based Providers

Providers declare their capabilities explicitly:

rust
impl<H> Capabilities<H> for MyProviderExt {
    type Completion = Capable<CompletionModel<H>>;  // Supported
    type Embeddings = Nothing;                       // Not supported
    // ...
}

Use Capable<T> for supported features and Nothing for unsupported ones.