refrax

command module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2025 License: MIT Imports: 3 Imported by: 0

README

Refrax

codecov

Refrax is an AI-powered refactoring agent for Java code, implemented in Go. It communicates using the A2A protocol.

⚠️ Early prototype — subject to rapid change.

Installation

Releases

Download the latest stable version from the releases page. Pre-built binaries are available for macOS, Windows, and Linux.

Using Go

If you have Go 1.24.1 or later installed, you can run:

go install github.com/cqfn/refrax@latest

To install a specific version, use:

go install github.com/cqfn/refrax@v0.0.1

Releases page.

From Source

Ensure that Go 1.24.1 or later is installed on your system.

  1. Clone the repository:

    git clone https://github.com/cqfn/refrax.git
    cd refrax
    
  2. Build the binary:

    go build -o refrax
    
  3. (Optional) Install the binary to your $GOPATH/bin:

    go install
    

Usage

*asciicast

  • refrax refactor [path]: Refactor Java code in the specified directory (defaults to current directory).
  • refrax start [agent]: Start the server for agents like fixer, critic, or facilitator.
Example

You can try refactoring the testing project located in this repository. To do so, you will need to clone the repository:

git clone https://github.com/cqfn/refrax.git

Then, run the following command:

refrax refactor --output="./out" --ai=deepseek refrax/test/test_data/java/person

Or, if you are already in the refrax folder, simply run:

refrax refactor --output="./out" --ai=deepseek test/test_data/java/person

Configuration

  • --ai, -a: Specify the AI provider (e.g., deepseek, openai).
  • --token, -t: Token for the AI provider.
  • --debug, -d: Enable debug logging.

Authentication

Some operations in Refrax require AI authentication using an API token. You can provide the token using one of the following methods:

Command-Line Flag
refrax refactor . --token your-token-here
AI Providers

Supported AI providers are:

  • deepseek
  • openai
Environment Variable

✅ The DEEPSEEK_TOKEN variable is the recommended option for deepseep AI provider ✅ The OPENAI_TOKEN variable is the recommended option for openai AI provider ⚠️ The TOKEN variable is still supported for any AI provider but deprecated.

Set the environment variable:

export DEEPSEEK_TOKEN=your-token-here
refrax start facilitator
.env File

If a .env file is present in the working directory, Refrax will attempt to read the token from it:

# .env
DEEPSEEK_TOKEN=your-token-here
Priority Order

If multiple sources are provided, the following priority order is applied (highest priority first):

  1. --token command-line flag
  2. DEEPSEEK_TOKEN environment variable
  3. TOKEN environment variable (deprecated)
  4. .env file (DEEPSEEK_TOKEN > TOKEN)

License

Licensed under the MIT License.

Documentation

Overview

Refrax entry point.

Directories

Path Synopsis
Package cmd provides command-line interface functionality for the refrax tool.
Package cmd provides command-line interface functionality for the refrax tool.
internal
brain
Package brain provides an interface and implementations for asking questions programmatically.
Package brain provides an interface and implementations for asking questions programmatically.
client
Package client provides functionality for working with Java source files in a project structure.
Package client provides functionality for working with Java source files in a project structure.
critic
Package critic provides tools for identifying refactoring opportunities in code.
Package critic provides tools for identifying refactoring opportunities in code.
env
Package env provides utilities for environment variable management.
Package env provides utilities for environment variable management.
facilitator
Package facilitator provides functionality for facilitating interactions between critic and fixer agents in a code refactoring process.
Package facilitator provides functionality for facilitating interactions between critic and fixer agents in a code refactoring process.
fixer
Package fixer provides functionality for fixing Java code based on suggestions.
Package fixer provides functionality for fixing Java code based on suggestions.
log
Package log provides utilities for structured logging in applications.
Package log provides utilities for structured logging in applications.
protocol
Package protocol A2A Agent Card.
Package protocol A2A Agent Card.
stats
Package stats provides functionality to write statistics.
Package stats provides functionality to write statistics.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL