Argent is an AI-powered coding assistant and code generation tool for the command line, leveraging OpenAI's language models through LangChain.
- Code Generation: Generate code in various programming languages based on natural language descriptions
- Test Creation: Automatically create test cases for your functions and modules
- Project Analysis: Analyze your project structure and get insights about your codebase
- Git Integration: Execute Git commands directly through Argent interface
- Dependency Management: Add and manage dependencies across different package managers (Mix, npm, yarn)
- Error Handling: Provides meaningful error messages when operations fail
- Directory Management: Automatically creates output directories if they don't exist
def deps do
[
{:argent, "~> 0.1.0"}
]
endYou can install Argent as a command-line tool:
# Install from Hex
mix escript.install hex argent
# Or build from source
git clone https://github.com/kentaro/argent.git
cd argent
mix deps.get
mix escript.build
# Install the generated escript
mix escript.install --force _build/dev/argentArgent requires an OpenAI API key to function. Set it as an environment variable:
export OPENAI_API_KEY=your_api_keyAlternatively, you can configure it in your application:
# In config/config.exs
config :langchain,
openai_api_key: "your_api_key"# Show help and available commands
argent --help
# Show version
argent --versionGenerate code based on natural language descriptions:
# Generate a Python script
argent generate python "function that calculates fibonacci numbers" ./fib.py
# Generate a JavaScript module
argent generate javascript "class for managing user authentication" ./auth.js
# Generate an Elixir module
argent generate elixir "GenServer to cache API responses" ./lib/cache.exCreate test cases for your code:
# Generate a test for a Python function
argent generate test python "test for fibonacci function" ./test_fib.py
# Generate tests for a JavaScript class
argent generate test javascript "test suite for authentication class" ./auth.test.jsAnalyze your project structure:
# Get insights about your project
argent analyze project ./my_projectExecute Git commands:
# Check status
argent git status
# Add files
argent git add .
# Commit changes
argent git commit "Update documentation"
# Push to remote
argent git push origin mainAdd dependencies to your project:
# Add a dependency for Mix projects
argent deps add mix phoenix "~> 1.7.0"
# Add a dependency for npm projects
argent deps add npm react "^18.0.0"
# Add a dependency for yarn projects
argent deps add yarn vue "^3.2.0"Argent provides clear error messages for common issues:
- Missing or invalid API key (
{:error, :api_key}) - File system errors (
{:error, :enoent}) - Command execution failures
You can also use Argent as a library in your Elixir applications:
# Generate code
{:ok, content} = Argent.Tools.CodeOperations.generate_code("python", "function to calculate fibonacci", "./fib.py")
# Execute a command
{:ok, output} = Argent.Tools.CommandOperations.execute("ls", ["-la"])
# Execute a command string
{:ok, output} = Argent.Tools.CommandOperations.execute_string("git status")Documentation is available at https://hexdocs.pm/argent.
You can also generate documentation locally:
mix docsContributions are welcome!
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.