Skip to main content

Crate xtalforge_agent

Crate xtalforge_agent 

Source
Expand description

Agent layer for xtalforge: session, verbs, inspection, diagnostics, change tracking and pictures (Phase 8).

The layer is what an AI assistant drives. Every public operation is a named verb in verbs::catalogue, takes JSON arguments and returns a typed, printable answers::Answer. The CLI, the Python package, the WebAssembly package and the MCP server read the same catalogue, so there is one list of capabilities and no second list to drift.

Mutations never bypass xtalforge_commands::Document: the session applies them through commands with xtalforge_commands::Origin::Agent, so a user can review or undo the assistant’s work as a unit (changes).

§Example

use xtalforge_agent::{Session, answers::Answer};

let mut session = Session::new();
let answer = session.run("capabilities", &serde_json::json!({})).unwrap();
assert!(matches!(answer, Answer::Capabilities { .. }));

Ported from Crystal-Builder xtal/agent/ (MIT), split by verb group; the reference is recorded in docs/algorithms/agent.md.

Re-exports§

pub use answers::Answer;
pub use batch::run_verbs;
pub use capabilities::Capabilities;
pub use capabilities::capability_report;
pub use changes::ChangeBurst;
pub use changes::changes_for;
pub use diagnostics::Diagnostic;
pub use diagnostics::DiagnosticReport;
pub use diagnostics::Severity;
pub use diagnostics::diagnose;
pub use inspect::inspect_structure;
pub use mcp::McpServer;
pub use mcp::serve_stdio;
pub use render::RenderOptions;
pub use render::render_png;
pub use render::render_svg;
pub use session::Session;
pub use session::SessionOptions;
pub use skill::SkillDocument;
pub use skill::default_directory;
pub use verbs::ParameterKind;
pub use verbs::VerbInfo;
pub use verbs::catalogue;
pub use verbs::lookup;

Modules§

answers
Typed answers (Task 8.1.5).
batch
Stateless batch runner (Task 8.1.5).
capabilities
Runtime capabilities (Task 8.1.1).
changes
Change tracking (Task 8.1.4).
context
Context for chat clients (Task 8.2.2).
diagnostics
Inspection and diagnostics (Task 8.1.3).
inspect
Structure inspection (Task 8.1.3).
mcp
MCP server over stdio (Task 8.2.1).
png
Minimal PNG encoder (Task 8.1.6).
render
Pictures for the agent (Task 8.1.6).
session
Stateful session (Task 8.1.2).
skill
Skill documents shipped with the CLI (Task 8.2.3).
verbs
The verb catalogue (Task 8.1.1).

Enums§

Error
Errors returned by the agent layer.