tuiml edit-algorithm: patch the source of a user-authored algorithm.
tuiml_edit_algorithm tool. It performs a single exact string replacement in a stored algorithm, re-validates the result, and re-registers the class in the component registry.Functions
Apply a targeted string replacement to a user-authored algorithm.
Replaces exactly one occurrence of --old-string with --new-string. The edit fails loudly when the text is missing or matches more than once, so add surrounding context until the snippet is unique. The patched source is AST-validated and the class is re-registered in the component registry, so every command and MCP tool sees the change right away.
The usual loop is tuiml read-algorithm to find the exact text, then this command to change it. Built-in algorithms are read-only; fork one with tuiml create-algorithm before editing it.
Requires TUIML_ALLOW_USER_ALGORITHMS=1 in the environment.
Change a default hyperparameter in the latest version:
$ tuiml edit-algorithm --name MyKNN \
--old-string "n_neighbors: int = 5" --new-string "n_neighbors: int = 7"
Keep the current version intact and save the edit as a new patch version:
$ tuiml edit-algorithm --name MyKNN --bump-version \
--old-string "metric = 'euclidean'" --new-string "metric = 'manhattan'"
Patch one specific version rather than the latest:
$ tuiml edit-algorithm --name MyKNN --version 1.0.0 \
--old-string "return preds" --new-string "return preds.astype(int)"
Options
--name
--old-string
--new-string
--version
--bump-version/--no-bump-version
--json-output