Skip to main content

llm による自立型 Cli コーディングエージェントライブラリ

Project description

llm-coder

日本語

llm-coder is an autonomous CLI coding agent library powered by LLMs.

It codes according to user instructions, runs its own linter, formatter, and test code in an evaluation phase, and keeps fixing until all checks pass. The LLM API interface uses the litellm library, allowing you to use any LLM such as Claude or OpenAI. Model and API key configuration follows the litellm provider settings.
See https://docs.litellm.ai/docs/providers for details.

Installation

  1. Clone the repository:

    git clone https://github.com/igtm/llm-coder.git
    cd llm-coder
    
  2. Install the package in development mode:

    pip install -e .
    

    This makes the llm-coder command available in your project directory.

Usage

After installation, you can run the CLI tool with:

llm-coder <prompt> [options...]

Available Options

positional arguments:
  prompt                Prompt to execute (if omitted, read from stdin or TOML file)

options:
  -h, --help            Show help message and exit
  --config CONFIG       Path to TOML config file (default: llm-coder-config.toml)
  --model MODEL, -m MODEL
                        LLM model to use (default: gpt-4.1-nano)
  --temperature TEMPERATURE, -t TEMPERATURE
                        LLM temperature parameter (default: 0.5)
  --max-iterations MAX_ITERATIONS, -i MAX_ITERATIONS
                        Maximum execution iterations (default: 10)
  --allowed-dirs ALLOWED_DIRS [ALLOWED_DIRS ...]
                        Directories allowed for file system operations (space separated, default: ['.', 'playground'])
  --repository-description-prompt REPOSITORY_DESCRIPTION_PROMPT
                        Repository description prompt for LLM (default: from TOML file or empty)
  --output OUTPUT, -o OUTPUT
                        Output file path (default: none, stdout only)
  --conversation-history CONVERSATION_HISTORY, -ch CONVERSATION_HISTORY
                        Output file path for agent conversation history (default: none)
  --request-timeout REQUEST_TIMEOUT
                        Timeout per LLM API request in seconds (default: 60)

Examples

# Basic usage
llm-coder "Create a python script that outputs 'hello world'"

# Specify model
llm-coder --model claude-3-opus-20240229 "Create a python script that outputs 'hello world'"

# Specify temperature and max iterations
llm-coder --temperature 0.7 --max-iterations 5 "Create a python script that outputs 'hello world'"

# Specify allowed directories
llm-coder --allowed-dirs . ./output ./src "Create a python script that outputs 'hello world'"

# Specify request timeout
llm-coder --request-timeout 120 "Create a python script that outputs 'hello world'"

# Output result to file
llm-coder --output result.txt "Create a python script that outputs 'hello world'"

# Output conversation history to file
llm-coder --conversation-history conversation.txt "Create a python script that outputs 'hello world'"

# Output both result and conversation history to files
llm-coder --output result.txt --conversation-history conversation.txt "Create a python script that outputs 'hello world'"

Configuration

You can configure llm-coder via command line arguments or a TOML file.

Priority: Command line arguments > TOML config file > hardcoded defaults

Example TOML Config File

By default, llm-coder-config.toml is loaded. You can specify a custom config file with --config.

# Global settings
model = "claude-3-opus-20240229"
prompt = "Create a python script that outputs 'hello world'"
temperature = 0.5
max_iterations = 10
request_timeout = 60
allowed_dirs = ["."]
repository_description_prompt = "This repository is a Python utility tool."
# output = "result.txt"
# conversation_history = "conversation.txt"

To use a config file:

# Use default config file (llm-coder-config.toml)
llm-coder

# Specify custom config file
llm-coder --config my_config.toml

Running Directly During Development

You can run cli.py directly during development without installing. A playground directory is provided for testing, but you must run scripts from the project root directory.

From the project root (llm-coder top directory), run:

# Make sure you are in the project root directory
uv run python -m llm-coder.cli <args...>

Example:

# Assuming you are in the project root directory
uv run python -m llm-coder.cli "Create a python script that outputs 'hello world'"

llm-coder-litellm Command

The llm-coder-litellm command is a simple wrapper for calling the LLM completion API directly using the LiteLLM library.

llm-coder-litellm --model <model> [options...] "prompt"

Available Options

usage: llm-coder-litellm [-h] --model MODEL [--temperature TEMPERATURE] [--max_tokens MAX_TOKENS] [--top_p TOP_P] [--n N] [--stream] [--stop [STOP ...]]
                         [--presence_penalty PRESENCE_PENALTY] [--frequency_penalty FREQUENCY_PENALTY] [--user USER] [--response_format RESPONSE_FORMAT]
                         [--seed SEED] [--timeout TIMEOUT] [--output OUTPUT] [--extra EXTRA]
                         [prompt]

litellm completion API wrapper

positional arguments:
  prompt                Prompt (if omitted, read from stdin)

options:
  -h, --help            show this help message and exit
  --model MODEL         Model name
  --temperature TEMPERATURE
                        Temperature parameter (default: 0.2)
  --max_tokens MAX_TOKENS
                        max_tokens
  --top_p TOP_P         top_p
  --n N                 n
  --stream              Stream output
  --stop [STOP ...]     Stop words
  --presence_penalty PRESENCE_PENALTY
                        presence_penalty
  --frequency_penalty FREQUENCY_PENALTY
                        frequency_penalty
  --user USER           user
  --response_format RESPONSE_FORMAT
                        response_format (e.g. json)
  --seed SEED           seed
  --timeout TIMEOUT     Request timeout in seconds (default: 60)
  --output OUTPUT, -o OUTPUT
                        Output file
  --extra EXTRA         Additional JSON parameters

Examples

# Basic usage
llm-coder-litellm --model gpt-4.1-nano "Generate a summary of the following text"

# Specify temperature
llm-coder-litellm --model gpt-4.1-nano --temperature 0.7 "Generate a summary of the following text"

# Save output to file
llm-coder-litellm --model gpt-4.1-nano --output summary.txt "Generate a summary of the following text"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_coder-0.0.1.tar.gz (30.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_coder-0.0.1-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file llm_coder-0.0.1.tar.gz.

File metadata

  • Download URL: llm_coder-0.0.1.tar.gz
  • Upload date:
  • Size: 30.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for llm_coder-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f32c6565b7e7452bc071d31c256689e5e6d8b001e50952b60db6f1ff9a85204e
MD5 ab8e890d4ab045f494c9e4846bd97aba
BLAKE2b-256 3f304ff191dfa9b4d294410fefaa704d0b7818ae3860365f70d38ed8814f6b6b

See more details on using hashes here.

File details

Details for the file llm_coder-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: llm_coder-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 25.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for llm_coder-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 201c2e129691843aa20ed8e54d51555b1082398674a1cb67606e63e7c9f69bf0
MD5 bcde73c9143671e0781aef6d9c3e0add
BLAKE2b-256 6110931d60f706093046a903f34300f7439d01237cc91ce9db41c40cd6ef2644

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page