Expand description
AST Serializer - Convert AgentScript AST back to source text.
This module provides functionality to serialize an AgentFile AST back into
valid AgentScript source code. This enables:
- Visual editors that modify the AST and regenerate source
- Code transformation and refactoring tools
- AST-based code generators
§Example
use busbar_sf_agentscript::{parse, serialize};
let source = r#"
config:
agent_name: "Test"
topic main:
description: "Main topic"
"#;
let ast = parse(source).unwrap();
let regenerated = serialize(&ast);
println!("{}", regenerated);§Formatting
The serializer produces idiomatic AgentScript with:
- 3-space indentation (AgentScript standard)
- Consistent spacing and newlines
- Proper quoting of strings
- Correct reference formatting (
@namespace.path)
Functions§
- serialize
- Serialize an AgentFile AST to AgentScript source code.