Thanks to visit codestin.com
Credit goes to github.com

Skip to content

kentaro/argent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Argent

Hex.pm Hex.pm Hex.pm

Argent is an AI-powered coding assistant and code generation tool for the command line, leveraging OpenAI's language models through LangChain.

Features

  • 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

Installation

Via Hex

def deps do
  [
    {:argent, "~> 0.1.0"}
  ]
end

As CLI Tool

You 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/argent

Configuration

Argent requires an OpenAI API key to function. Set it as an environment variable:

export OPENAI_API_KEY=your_api_key

Alternatively, you can configure it in your application:

# In config/config.exs
config :langchain,
  openai_api_key: "your_api_key"

Usage

Command Line Interface

# Show help and available commands
argent --help

# Show version
argent --version

Code Generation

Generate 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.ex

Test Generation

Create 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.js

Project Analysis

Analyze your project structure:

# Get insights about your project
argent analyze project ./my_project

Git Operations

Execute 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 main

Dependency Management

Add 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"

Error Handling

Argent provides clear error messages for common issues:

  • Missing or invalid API key ({:error, :api_key})
  • File system errors ({:error, :enoent})
  • Command execution failures

Library Usage

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

Documentation is available at https://hexdocs.pm/argent.

You can also generate documentation locally:

mix docs

Contributing

Contributions are welcome!

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages