Skip to content

karsonto/Athlon-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Athlon Code Java

Java Maven License

Java implementation of Athlon Code CLI tool for AI-powered software engineering tasks, adapted from advanced AI coding assistant projects.

Features

  • Code Understanding & Editing - Query and edit codebases with AI assistance
  • File System Operations - Read, write, and manage files through AI commands
  • Shell Command Execution - Run system commands safely with user confirmation
  • Long-term Memory Management - Save and retrieve context across sessions via ATHLON.md files
  • Interactive CLI - Chat-based interface for natural language programming tasks
  • Non-Interactive Mode - Batch processing support for automation
  • AI Model Integration - Supports various AI models through OpenAI-compatible API

Quick Start

Prerequisites

  • Java 8 or higher
  • Maven 3.6 or higher
  • AI model API key (supports OpenAI-compatible APIs)

Installation

  1. Clone and build the project:
git clone <repository-url>
cd athlon-code-java
mvn clean install
  1. Set up your API key:
# For users in mainland China
export OPENAI_API_KEY="your_api_key_here"
export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"

# For international users  
export OPENAI_API_KEY="your_api_key_here"
export OPENAI_BASE_URL="https://dashscope-intl.aliyuncs.com/compatible-mode/v1"

# Optional: specify model
export OPENAI_MODEL="qwen3-coder-max"
  1. Run the CLI:
# Interactive mode
java -jar athlon-cli/target/athlon-code.jar

# Non-interactive mode
java -jar athlon-cli/target/athlon-code.jar --non-interactive "Explain this code file" src/main/java/Main.java

Usage Examples

Interactive Mode

$ java -jar athlon-cli/target/athlon-code.jar
Athlon Code Java - Interactive Mode
Type 'exit' or 'quit' to end the session

> Read the README.md file and summarize the project structure
> Create a new Java class for handling HTTP requests
> Run tests and show me any failures

Non-Interactive Mode

# Code analysis
java -jar athlon-cli/target/athlon-code.jar --non-interactive "Analyze the main method in src/main/java/App.java"

# File operations
java -jar athlon-cli/target/athlon-code.jar --non-interactive "Create a new utility class for string operations"

# Project tasks
java -jar athlon-cli/target/athlon-code.jar --non-interactive "Run mvn test and fix any compilation errors"

Architecture

The project follows a modular architecture with three main components:

Core Module (athlon-core)

  • AthlonApiClient: HTTP client for AI API communication
  • Model Classes: Request/response models for OpenAI-compatible API
  • Configuration: API settings and model configuration

Tools Module (athlon-tools)

  • Tool Registry: Manages available AI tools
  • File Tools: Read and write file operations
  • Shell Tool: Execute system commands with safety checks
  • Memory Tools: Long-term memory management via ATHLON.md files
  • Extensible Framework: Easy to add new tool implementations

CLI Module (athlon-cli)

  • Command-Line Interface: Interactive and batch processing modes
  • Conversation Manager: Handles AI conversations and tool execution
  • User Confirmation: Safety prompts for destructive operations

Available Tools

Tool Description Requires Confirmation
read_file Read file contents with line numbers No
write_file Create or overwrite files Yes
shell Execute shell commands Yes
save_memory Save facts to long-term memory (ATHLON.md) No
load_memory Load and display memory content from ATHLON.md files No

Memory Management

Athlon Code Java includes a powerful long-term memory system that allows the AI to remember important information across sessions and projects.

How It Works

  • ATHLON.md Files: Memory is stored in ATHLON.md files
  • Hierarchical Loading: System automatically loads memory from:
    1. Project root: ./ATHLON.md (project-specific context)
    2. User home: ~/.athlon/ATHLON.md (global context)
  • Automatic Context: Memory content is automatically included in AI conversations
  • Persistent Storage: Information persists across sessions and restarts

Using Memory

The AI can automatically save important facts using the save_memory tool:

# The AI will automatically save important information like:
# - Project structure and conventions
# - API endpoints and configurations
# - Development guidelines and preferences
# - Frequently used commands or patterns

Manual Memory Management

You can also manually create or edit ATHLON.md files:

# Project Context

## Project Overview
This is a Spring Boot application for user management.

## Development Guidelines
- Use Java 11 features
- Follow REST API conventions
- Use JUnit 5 for testing

## Athlon Added Memories
- The project uses PostgreSQL as the database
- API endpoints follow the pattern /api/v1/*
- Authentication is handled via JWT tokens

Configuration

Environment Variables

  • OPENAI_API_KEY: Your AI API key (required)
  • OPENAI_BASE_URL: API endpoint URL (optional, auto-detected by region)
  • OPENAI_MODEL: Model name (optional, default: qwen3-coder-max)

Command Line Options

java -jar athlon-code.jar [OPTIONS] [COMMAND]

Options:
  -c, --config FILE         Configuration file path
  -m, --model MODEL         Model to use (default: qwen3-coder-max)  
  -t, --temperature TEMP    Temperature for generation (default: 0.7)
      --non-interactive     Run in non-interactive mode
  -h, --help               Show help message
  -V, --version            Print version information

Development

Building from Source

# Compile all modules
mvn clean compile

# Run tests
mvn test

# Build JAR files
mvn clean package

# Install to local repository
mvn clean install

Project Structure

athlon-code-java/
├── athlon-core/           # Core API client and models
│   ├── src/main/java/
│   │   └── com/athlon/code/core/
│   │       ├── client/  # HTTP client
│   │       ├── config/  # Configuration
│   │       └── model/   # Data models
│   └── pom.xml
├── athlon-tools/          # Tool implementations  
│   ├── src/main/java/
│   │   └── com/athlon/code/tools/
│   │       ├── impl/    # Tool implementations
│   │       └── *.java   # Tool framework
│   └── pom.xml
├── athlon-cli/           # Command-line interface
│   ├── src/main/java/
│   │   └── com/athlon/code/cli/
│   └── pom.xml
└── pom.xml             # Parent POM

Adding New Tools

  1. Extend the Tool abstract class:
public class MyCustomTool extends Tool {
    public MyCustomTool() {
        super("my_tool", "Description of what this tool does");
    }
    
    @Override
    public ToolResult execute(String arguments) throws ToolExecutionException {
        // Implementation here
        return ToolResult.success("Tool completed successfully");
    }
    
    @Override
    public Map<String, Object> getParametersSchema() {
        // Return JSON schema for parameters
    }
}
  1. Register in ToolRegistry:
toolRegistry.register(new MyCustomTool());

API Documentation

Get your AI API key:

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-tool)
  3. Make your changes
  4. Add tests for new functionality
  5. Commit your changes (git commit -am 'Add new tool')
  6. Push to the branch (git push origin feature/new-tool)
  7. Create a Pull Request

License

This project is licensed under the Apache License 2.0 - 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