cognis-macros 0.3.0

Procedural macros for Cognis: #[tool] attribute for tool definitions and #[derive(GraphState)] for graph state with per-field reducers.
Documentation

Proc macros for the Cognis framework.

Macros

  • [tool] — #[cognis::tool] attribute that generates a cognis_core::tools::BaseTool implementation from an async fn (or from an impl block containing one). Uses [schemars] under the hood for parameter schema generation.
  • [GraphState] — derive macro for graph state schemas with per-field reducers (see attributes #[reducer(append|last_value|add|merge)]).

JSON Schema generation

For #[derive(JsonSchema)] on your own structs/enums, use the re-export at cognis_core::JsonSchema (which is schemars::JsonSchema). The legacy hand-rolled JsonSchema / ToolSchema derives in this crate were removed in favor of the upstream schemars crate, which supports recursive types, $ref/definitions, doc-comment → description, and richer attribute syntax.

use cognis_core::JsonSchema;
use serde::{Deserialize, Serialize};

#[derive(JsonSchema, Serialize, Deserialize)]
struct SearchFilter {
    /// Minimum relevance score
    min_score: f64,
    /// Categories to include
    categories: Vec<String>,
}

let schema = serde_json::to_value(schemars::schema_for!(SearchFilter)).unwrap();