Skip to content

Latest commit

 

History

History
37 lines (27 loc) · 3.93 KB

AGENTS.md

File metadata and controls

37 lines (27 loc) · 3.93 KB

Repository Guidelines

Project Structure & Module Organization

  • core/src/ hosts the core traits (llm, embedding, audio, image, moderation) plus core/src/lib.rs for re-exports; root src/lib.rs is the aither facade crate.
  • derive/ is the aither-derive proc-macro crate—limit it to macro glue and avoid depending on provider code.
  • openai/ contains the integration crate that maps the traits onto OpenAI endpoints; keep it lean so other providers can re-use the core API.
  • examples/ (notably tool_macro.rs) provides runnable flows; extend it and validate via cargo run --example tool_macro.

Build, Test & Development Commands

  • cargo fmt --all — formats every crate exactly as CI expects.
  • cargo clippy --all-targets --all-features --workspace -- -D warnings — pedantic lint gate mirrored in .github/workflows/ci.yml.
  • cargo test --all-features --workspace — runs unit and doc tests, including async cases backed by tokio-test.
  • cargo doc --all-features --no-deps --workspace — ensures docs compile under the docsrs cfg.
  • cargo run --example tool_macro — smoke-tests the showcased example when changing macros or request builders.

Async trait & error conventions

  • Public trait methods return impl Future; never expose Pin<Box<dyn Future>> or boxed-future aliases in public signatures.
  • When a trait must be stored dynamically, define a private object-safe twin [Trait]Impl plus a public wrapper Any[Trait] (e.g. AnyChatActionSender, AnyHandler, AnyContainerExec; Tools plays that role for Tool). Boxing lives inside the wrapper — callers only see the concrete API.
  • anyhow is banned: every error is a thiserror enum so callers can match on failure kinds. Box<dyn Error> is acceptable only at a binary's outermost boundary.

Coding Style & Naming Conventions

Follow rustfmt defaults (4 spaces, trailing commas) and keep modules snake_case, traits/types UpperCamelCase, and feature flags kebab-case (serde, derive). Public APIs need /// docs because cargo doc --cfg docsrs runs in CI. Favor builders such as Request::new([...]), keep provider-only structs behind feature flags, and align with clippy::pedantic expectations before raising a PR.

Text the model reads — tool results, notices, alerts and reminders — is natural language rendered from a typed template; no serializer output (JSON, XML) reaches the model, except data a command or an external tool itself produced and the schema of output the model must emit.

Testing Guidelines

Co-locate unit tests inside each module using #[cfg(test)] mod tests so traits stay covered near their definitions. Async logic should use #[tokio::test] (multi-thread flavor when polling streams) and exercise futures_lite::StreamExt when verifying streaming traits. Every new capability needs at least one success path, one failure path, and—when user facing—a doc test or example that mirrors realistic prompts.

Commit & Pull Request Guidelines

History favors short, imperative subjects (see Add serde support, Rename ai-types to aither); follow that pattern and explain breaking changes in the body. Pull requests should provide a concise description, link to the motivating issue, paste the results of cargo fmt, clippy, and test, and call out any docs/examples touched. Attach logs or transcripts when altering provider behavior so reviewers can reproduce the call.

Branches & Releases

main is the only long-lived branch. Topic branches start from origin/main and land through the merge queue, whose required check is CI result. release-plz keeps a release PR against main; merging it publishes, and it is never set to merge automatically.

Security & Configuration Tips

Never commit provider secrets; inject them via environment variables such as OPENAI_API_KEY when hacking on aither-openai. Keep .env* files out of Git and strip identifiers from captured responses before committing examples.