Normalizes map keys from hyphens to underscores at the tool boundary.
PTC-Lisp uses Clojure conventions where LLMs naturally write hyphenated keywords
(e.g., :was-improved). Elixir/JSON conventions use underscores. This module
provides key normalization at the boundary between the two.
Summary
Functions
Normalize a single key from hyphen to underscore format.
Recursively normalize map keys from hyphens to underscores.
Functions
Normalize a single key from hyphen to underscore format.
Examples
iex> PtcRunner.SubAgent.KeyNormalizer.normalize_key(:"was-improved")
"was_improved"
iex> PtcRunner.SubAgent.KeyNormalizer.normalize_key("foo-bar")
"foo_bar"
iex> PtcRunner.SubAgent.KeyNormalizer.normalize_key(:no_hyphens)
"no_hyphens"
Recursively normalize map keys from hyphens to underscores.
Converts Clojure-style :was-improved to Elixir-style "was_improved".
Works recursively on nested maps and lists.
Examples
iex> PtcRunner.SubAgent.KeyNormalizer.normalize_keys(%{"was-improved" => true})
%{"was_improved" => true}
iex> PtcRunner.SubAgent.KeyNormalizer.normalize_keys(%{nested: %{"foo-bar" => 1}})
%{"nested" => %{"foo_bar" => 1}}
iex> PtcRunner.SubAgent.KeyNormalizer.normalize_keys([%{"list-item" => 1}])
[%{"list_item" => 1}]