CMDC.Tool.Shell (cmdc v0.5.0)

Copy Markdown View Source

在 shell 中执行命令,支持超时和大输出自动存文件。

大输出处理

输出超过 @max_bytes(50KB)或 @max_lines(2000 行)时:

  • 将完整输出写入 working_dir/.cmdc/output/{timestamp}.txt
  • 返回截断版本 + 文件路径提示,LLM 可用 read_file 继续查阅

Shell 类型

根据平台自动选择:POSIX(sh/bash/zsh)或 Windows(cmd/powershell)。 通过 ctx.config.shell 可覆盖。

Summary

Functions

返回当前平台的默认 shell。

返回指定 shell 类型的工具名称。

返回指定 shell 类型的基础描述。

返回所有 shell 工具名称的 MapSet。

Types

shell()

@type shell() :: :sh | :bash | :zsh | :cmd | :powershell

Functions

default_shell()

@spec default_shell() :: shell()

返回当前平台的默认 shell。

name(shell_type)

@spec name(shell()) :: String.t()

返回指定 shell 类型的工具名称。

shell_description(shell_type)

@spec shell_description(shell()) :: String.t()

返回指定 shell 类型的基础描述。

shell_names()

@spec shell_names() :: MapSet.t(String.t())

返回所有 shell 工具名称的 MapSet。