amql-mutate 0.0.0-alpha.0

Pure source code mutation operations
Documentation

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 via wasm_bindgen
  • ts — TypeScript type generation via ts-rs
  • jsonschema — JSON Schema derivation via schemars

Types

  • NodeRef — self-contained reference to an AST node (file + byte range + kind)
  • InsertPosition — Before, After, Into
  • MutationResult — modified source + updated node refs
  • NodeKind — opaque newtype for tree-sitter node kinds
  • RelativePath — 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 via ts-rs

License

MIT