@amql/mutate
v0.0.0-alpha.0
Published
Pure source code mutation operations
Downloads
19
Readme
amql-mutate
Pure source code mutation operations for AQL
Role
- Insert, remove, replace, move nodes in source text
- All functions are pure: source text + node refs in, modified source + updated refs out
- No file I/O — callers handle reading/writing
- Defines shared newtypes:
NodeKind,RelativePath - Dependency of amql-engine
Features
wasm— WASM bindings viawasm_bindgents— TypeScript type generation viats-rsjsonschema— JSON Schema derivation viaschemars
Types
NodeRef— self-contained reference to an AST node (file + byte range + kind)InsertPosition— Before, After, IntoMutationResult— modified source + updated node refsNodeKind— opaque newtype for tree-sitter node kindsRelativePath— opaque newtype for project-relative file paths
Getting Started
use aql_mutate::{remove_node, NodeRef, RelativePath, NodeKind};
let node = NodeRef {
file: RelativePath::from("src/main.rs"),
start_byte: 100, end_byte: 200,
kind: NodeKind::from("function_item"),
line: 5, column: 0, end_line: 10, end_column: 1,
};
let (result, detached) = remove_node(source, &node)?;npm
- Package:
@aql/mutate - Build:
bun run build(wasm-pack + codegen) - Types: branded newtypes (
NodeKind,RelativePath), generated viats-rs
