LemonCliRunners.ToolActionHelpers (lemon_cli_runners v0.1.0)

View Source

Shared helpers for translating tool calls and tool results into action events.

This module provides a small abstraction for managing pending tool actions and normalizing tool output across CLI runners (e.g., Claude, Kimi).

Summary

Types

Kind of action for UI display

Functions

Make an absolute path relative to cwd when possible.

Convert atom keys to string keys in a map (shallow).

Find the first non-empty string value for any of the given keys.

Classify a tool call into a kind and human-readable title.

Types

action_kind()

@type action_kind() :: :command | :file_change | :tool | :web_search | :subagent

Kind of action for UI display

Functions

complete_action(factory, pending_actions, id, ok, detail, fallback_kind \\ :tool, fallback_title \\ "tool result")

maybe_relativize_path(path, cwd)

@spec maybe_relativize_path(String.t(), String.t() | nil) :: String.t()

Make an absolute path relative to cwd when possible.

normalize_tool_result(content)

@spec normalize_tool_result(any()) :: String.t()

start_action(factory, pending_actions, id, kind, title, detail)

stringify_keys(map)

@spec stringify_keys(map()) :: map()

Convert atom keys to string keys in a map (shallow).

tool_input_path(input, keys)

@spec tool_input_path(map(), [String.t()]) :: String.t() | nil

Find the first non-empty string value for any of the given keys.

tool_kind_and_title(name, input, opts)

@spec tool_kind_and_title(String.t(), map(), keyword()) :: {action_kind(), String.t()}

Classify a tool call into a kind and human-readable title.

Options

  • :path_keys - list of map keys to search for file paths (required)
  • :cwd - working directory for relativizing paths