Skip to content

Latest commit

 

History

History
196 lines (149 loc) · 4.51 KB

File metadata and controls

196 lines (149 loc) · 4.51 KB
layout page
title Onboarding
nav_order 2
description Onboarding guide for Code-Forge
permalink /onboarding

Code-Forge: AI-Powered Code Assistant

Code-Forge is a sophisticated AI-powered coding assistant platform built in Rust, designed to provide intelligent code generation, manipulation, and analysis capabilities through a modular and extensible architecture.

System Architecture

Core Components

  1. Domain Layer (forge_domain)

    • Defines core domain models and interfaces
    • Handles chat requests/responses
    • Manages tool definitions and executions
    • Provides conversation management
  2. Provider Layer (forge_provider)

    • Implements AI model integration (OpenRouter)
    • Handles API communication
    • Manages model parameters and configurations
  3. Tool Layer (forge_tool)

    • Implements various coding tools:
      • File system operations (read, write, search, replace)
      • Shell command execution
      • Code outline generation
      • Thinking framework for complex problem-solving
  4. Server Layer (forge_services)

    • Provides HTTP API endpoints
    • Manages database operations
    • Handles conversation persistence
    • Implements system configurations

Key Features

  1. File System Operations

    • Read/Write capabilities
    • Directory listing
    • File search with regex support
    • Smart file replacement with diff blocks
    • Code validation for multiple languages
  2. Code Analysis

    • Language-aware code parsing
    • Function and class outline generation
    • Support for Rust, JavaScript, and Python
    • Syntax validation
  3. Conversation Management

    • Persistent conversations
    • Context management
    • Title generation
    • History tracking
  4. Tool Framework

    • Extensible tool system
    • JSON schema-based tool definitions
    • Asynchronous tool execution
    • Error handling and validation

Technical Details

Database Structure

The system uses SQLite with migrations for:

  • Conversation storage
  • Configuration management
  • System settings

AI Integration

  • Uses OpenRouter as the AI provider
  • Supports multiple AI models
  • Implements streaming responses
  • Handles tool-augmented conversations

Code Processing

  1. Language Support

    • Rust validation and parsing
    • JavaScript/TypeScript support
    • Python code analysis
    • Extensible language framework
  2. Tool Implementation

    • File system tools with safety checks
    • Shell command execution with security measures
    • Code outline generation using tree-sitter
    • Think framework for reasoning

Development Guidelines

Adding New Tools

  1. Define tool interface in forge_domain
  2. Implement tool in forge_tool
  3. Add tool registration in tool service
  4. Update tool definitions and schemas

Testing

  • Comprehensive test coverage
  • Snapshot testing for responses
  • Integration tests for tools
  • Mock providers for testing

Security Considerations

  1. File System Safety

    • Path validation
    • Permission checks
    • Content validation
  2. Shell Command Security

    • Command whitelisting
    • Working directory restrictions
    • Input sanitization

Configuration

Environment Variables

Required configurations:

  • Database URL
  • API Keys
  • Model configurations
  • System paths

System Requirements

  • Rust toolchain
  • SQLite
  • Tree-sitter (for code analysis)
  • Shell access (for command execution)

Getting Started

  1. Set up environment variables
  2. Run database migrations
  3. Build and start the server
  4. Initialize configurations

Architecture Best Practices

  1. Modularity

    • Clear separation of concerns
    • Domain-driven design
    • Interface-based communication
  2. Error Handling

    • Custom error types
    • Proper error propagation
    • Informative error messages
  3. Async Design

    • Asynchronous operations
    • Stream processing
    • Resource management
  4. Testing Strategy

    • Unit tests
    • Integration tests
    • Snapshot testing
    • Mock services

Extensibility

The system is designed for extension through:

  1. New tool implementations
  2. Additional language support
  3. Alternative AI providers
  4. Custom conversation handlers

Future Considerations

  1. Performance Optimization

    • Caching strategies
    • Response optimization
    • Resource pooling
  2. Feature Extensions

    • Additional language support
    • More sophisticated code analysis
    • Enhanced security measures
  3. Integration Capabilities

    • IDE plugins
    • CI/CD integration
    • Version control system integration