Skip to main content

Interactive coding agent CLI

Project description

pig-coding-agent

Interactive coding agent CLI with file operations and code generation.

Features

  • 💻 Code Generation: AI-powered code generation
  • 📁 File Operations: Read, write, edit files
  • 🔍 Code Analysis: Understand and analyze code
  • 🛠️ Refactoring: Automated code refactoring
  • 🐚 Shell Integration: Execute shell commands
  • 💬 Interactive Chat: Conversational interface

Installation

pip install pig-coding-agent

Quick Start

Start Interactive Session

# Start coding agent
pig-code

# With specific model
pig-code --model gpt-4

# In a specific directory
pig-code --path /path/to/project

Command Line Usage

# Generate code
pig-code gen "Create a FastAPI hello world app"

# Analyze file
pig-code analyze main.py

# Refactor code
pig-code refactor main.py "Add type hints"

# Chat mode
pig-code chat

Built-in Tools

The coding agent comes with these tools:

File Operations

  • read_file(path) - Read file contents
  • write_file(path, content) - Write to file
  • list_files(directory) - List directory contents
  • search_files(pattern) - Search for files

Code Operations

  • generate_code(description) - Generate code from description
  • explain_code(code) - Explain what code does
  • fix_code(code, error) - Fix code errors
  • add_tests(code) - Generate tests for code

Shell Operations

  • run_command(command) - Execute shell command
  • git_status() - Get git status
  • git_diff() - Get git diff

Usage Examples

Generate a Python Module

$ pig-code
> Create a Python module for handling JSON files with read/write functions

Agent will:
1. Generate the code
2. Write to file
3. Show you the result

Analyze Codebase

$ pig-code analyze
> Analyze this codebase and suggest improvements

Agent will:
1. Read relevant files
2. Analyze structure
3. Provide recommendations

Interactive Refactoring

$ pig-code
> Refactor main.py to use async/await

Agent will:
1. Read the file
2. Refactor the code
3. Show diff
4. Ask for confirmation
5. Write changes

Configuration

Create .pig-code-config.json:

{
  "provider": "openai",
  "model": "gpt-4",
  "temperature": 0.7,
  "max_iterations": 10,
  "auto_confirm": false,
  "workspace": "./",
  "ignore_patterns": [
    "node_modules",
    ".git",
    "__pycache__"
  ]
}

Chat Commands

Inside the agent:

/help       - Show help
/exit       - Exit agent
/clear      - Clear conversation
/files      - List files in workspace
/read PATH  - Read a file
/write PATH - Write to file
/run CMD    - Run shell command
/status     - Show agent status

Safety Features

  • File operation confirmations
  • Command execution warnings
  • Workspace boundaries
  • Backup before overwrite
  • Git integration for tracking changes

Architecture

CodingAgent
├── Agent Core (pig-agent-core)
├── LLM Client (pig-llm)
├── TUI (pig-tui)
└── Built-in Tools
    ├── FileTools
    ├── CodeTools
    └── ShellTools

Examples

See examples/coding-agent/:

  • generate_app.py - Generate full application
  • refactor_demo.py - Code refactoring
  • analysis_demo.py - Code analysis

License

MIT

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

pig_coding_agent-0.0.2.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

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

pig_coding_agent-0.0.2-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file pig_coding_agent-0.0.2.tar.gz.

File metadata

  • Download URL: pig_coding_agent-0.0.2.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for pig_coding_agent-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b22a458814eb2eb9f9aa1c3c84c832a72d1b559f0274398a3377c14edd626938
MD5 bd44319a7f5ffcb11ddd3f983359c80e
BLAKE2b-256 81fbdcd0aacbe8f036e46caaf2f6944d5370d0bd0fe5e49c964aadd57ccf3e26

See more details on using hashes here.

File details

Details for the file pig_coding_agent-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pig_coding_agent-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 178435cbef983dbb1182c4bc334de86831a4cace454ae2a31b9c8203504d7a51
MD5 c90069a3584bd1c1b5144a6a93d3b1e7
BLAKE2b-256 0522c3a8f3e4724d9d4874b0f8f1c92a477eac041b24d3314618c5c4a6d48988

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