Skip to content

ihasq/radius

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Radius

LLM-native code editing toolkit with LSP integration.

Radius is a daemon-based code editing system designed for AI coding agents. It provides semantic code operations via Language Server Protocol (LSP) integration with efficient in-memory text buffering using a Piece Tree data structure.

Features

  • LSP-powered semantic operations: Variable reading and renaming with full semantic understanding
  • Code actions and formatting: Apply LSP quick fixes, refactors, and document formatting
  • LLM-readable views: Outline, hover info, diagnostics, type hierarchy, and code lens
  • Code visualization: Generate Mermaid graphs for imports, references, and call hierarchies
  • Language tools: Comment toggling, snippet insertion, semantic tokens, and VS Code task runner
  • Undo/redo history: Per-project change tracking with full file restoration
  • Git integration: Conflict resolution and diff viewing
  • Import-aware file renaming: Automatically update import statements across the project
  • Diagnostic tracking: Persistent diagnostic IDs (D-NNN) with resolution detection and emoji indicators
  • Multi-agent support: Tag-chain based agent identification with conflict detection and resolution
  • Session management: Dog tag-based conversation tracking with automatic rewind detection
  • VSCode extension support: Install extensions from Open VSX registry for language support
  • External change detection: Automatically detect and handle external file modifications
  • Memory-efficient buffering: LRU cache with Piece Tree text buffer for large file handling
  • Configurable LSP servers: User-defined LSP server mappings via JSON configuration
  • Debug logging: Comprehensive logging via RADIUS_DEBUG environment variable
  • Automatic updates: Self-updating system with Ed25519 signature verification (12-hour check interval)

Installation

Quick Install

Linux / macOS:

curl -fsSL https://radius-ai.pages.dev/install.sh | bash

Windows (PowerShell):

irm https://radius-ai.pages.dev/install.ps1 | iex

The installer will:

  • Download the latest release for your platform
  • Extract binaries to ~/.radius/bin (customizable with $RADIUS_INSTALL_DIR)
  • Add to PATH automatically

Manual Installation

Download pre-built binaries from GitHub Releases:

# Linux x64
curl -LO https://github.com/ihasq/radius/releases/latest/download/radius-linux-x64.tar.gz
tar xzf radius-linux-x64.tar.gz
sudo mv radius-linux-x64 radiusd-linux-x64 /usr/local/bin/
sudo ln -s /usr/local/bin/radius-linux-x64 /usr/local/bin/radius
sudo ln -s /usr/local/bin/radiusd-linux-x64 /usr/local/bin/radiusd

Build from Source

Prerequisites:

  • Bun runtime (v1.0+)
  • Unix-like OS (Linux, macOS) or Windows
# Clone repository
git clone https://github.com/ihasq/radius.git
cd radius

# Install dependencies
bun install

# Build binaries
bun run build

# Install to system (optional)
sudo cp dist/radius dist/radiusd /usr/local/bin/

Usage

Starting the daemon

The daemon starts automatically on first command. To manually manage:

# Check daemon status
radius ping

# Stop daemon
radius daemon stop

Upgrading

Radius automatically checks for updates every 12 hours and installs them in the background. To manually upgrade:

# Force immediate update check and installation
radius upgrade

The update system uses Ed25519 signature verification to ensure binary integrity. Old versions are preserved in ~/.radius/bin/<hash>/ for rollback if needed.

Commands

File viewing

radius view <file>                    # View entire file
radius view <file> --range 10:20      # View lines 10-20

Variable operations (LSP-powered)

radius read-var <file> --var <name>              # Find variable definition and references
radius modify-var <file> --from <old> --to <new> # Rename variable across file

Text editing

radius str-replace <file> --old "text" --new "replacement"
radius insert <file> --line 10 --text "new line content"
radius create <file> --content "file content"

Git conflict resolution

radius solve-conflict <file>                    # Show conflicts
radius solve-conflict <file> --accept ours      # Accept our changes
radius solve-conflict <file> --accept theirs    # Accept their changes
radius solve-conflict <file> --id 1 --content "custom resolution"

File renaming with import updates

radius rename-file <old-path> --to <new-path>

Undo/Redo

radius undo    # Undo last change
radius redo    # Redo undone change

Code actions and formatting (Phase 17)

radius fix <file> --list                # List available code actions
radius fix <file> [--line N] [--id N]   # Apply code action
radius format <file>                    # Apply LSP formatting

Diagnostic Tracking

All write commands (str-replace, insert, create, etc.) automatically track diagnostics:

diagnostics: ❌ 2 errors, ⚠️ 1 warning
  ❌ D-001 [2322] (line 5): Type 'string' is not assignable to type 'number'
  ❌ D-002 [2322] (line 10): Property 'x' does not exist on type 'Foo'
  ⚠️ D-003 [6133] (line 3): 'unused' is declared but never used

resolved:
  ✅ D-004 [2322] (line 8): Type error was fixed
1 issue resolved by this change.

Features:

  • Persistent IDs: Each diagnostic gets a unique D-NNN ID that persists across edits
  • Emoji indicators: ❌ Error, ⚠️ Warning, ℹ️ Info/Hint, ✅ Resolved
  • Resolution detection: Tracks which diagnostics were fixed by each edit
  • Project-scoped: IDs are unique per project and survive daemon restarts

LLM-readable views (Phase 18)

radius outline <file>                        # Symbol tree
radius hover <file> --line N --col N         # Type and docs at position
radius problems [<file-or-dir>]              # Diagnostics (errors/warnings)
radius typehierarchy <file> --symbol <name>  # Class/interface hierarchy
radius diff <file> [--ref <git-ref>]         # Git diff
radius codelens <file>                       # Reference/implementation counts

Language tools (Phase 19)

radius comment <file> --line N [--uncomment]       # Toggle line comment
radius comment <file> --range S:E [--uncomment]    # Toggle block comment
radius snippet --list [--language <lang>]          # List snippets
radius snippet <file> --name <name> --line N       # Insert snippet
radius tokens <file> [--range S:E]                 # Semantic tokens
radius task list                                   # List VS Code tasks
radius task run <name>                             # Run task

Code visualization (Mermaid graphs)

radius graph imports <file> [--depth=N]      # Module dependency graph
radius graph refs <file> <symbol>            # Variable reference graph
radius graph calls <file> <function>         # Function call hierarchy

Extension management

radius ext install <publisher.name>   # Install from Open VSX
radius ext install ./local-extension  # Install local extension
radius ext list                       # List installed extensions
radius ext remove <publisher.name>    # Remove extension

LSP server management

radius lsp list    # Show registered LSP servers and their sources

Multi-Agent Support

Radius supports multiple AI agents working on the same project concurrently. Each command returns a tag that identifies the agent's chain of operations.

# Agent A starts working (no tag = new chain)
radius str-replace file.ts --old "foo" --new "bar"
# Returns: radius-tag: abc1-XXXXXXXX

# Agent A continues with returned tag
radius str-replace file.ts --old "baz" --new "qux" --tag abc1-XXXXXXXX

# Agent B starts working concurrently (no tag = new chain)
# If editing same lines as Agent A, will require --reason flag
radius str-replace file.ts --old "bar" --new "newbar" --reason "fixing typo"

Conflict Detection and Resolution

When agents edit overlapping regions, Radius detects conflicts and notifies affected chains:

# List pending notifications for your chain
radius list-notifications --tag <your-tag>

# Accept another agent's changes
radius accept-change --conflict <conflict-id> --tag <your-tag>

# Challenge another agent's changes
radius challenge-change --conflict <conflict-id> --reason "breaks tests" --tag <your-tag>

Debug Logging

Enable debug output via the RADIUS_DEBUG environment variable:

# Enable all debug output
RADIUS_DEBUG=1 radius ping

# Enable specific modules only
RADIUS_DEBUG=ipc,session radius view file.ts

# Available modules: ipc, cmd, session, lsp, buffer, history, conflict

Debug output goes to stderr. For daemon-side logs, check ~/.radius/daemon-debug.log.

Configuration

LSP servers

Create ~/.radius/lsp-servers.json to define custom LSP servers:

{
  "servers": {
    "python": {
      "command": "pylsp",
      "args": []
    },
    "go": {
      "command": "gopls",
      "args": ["serve"]
    }
  }
}

LSP resolution priority:

  1. Installed VSCode extensions (static extraction)
  2. User configuration (~/.radius/lsp-servers.json)
  3. Built-in fallback table

Architecture

radius (CLI) ─── Unix Socket IPC ───> radiusd (Daemon)
                                          │
                    ┌─────────────────────┼─────────────────────┐
                    │                     │                     │
              BufferManager          LspManager          HistoryTracker
              (Piece Tree)           (LSP clients)       (Undo/Redo)
                    │                     │
                    │              ExtensionLoader
                    │              (VSCode extensions)
                    │
              File System

Components

  • CLI (radius): Thin client that forwards commands to daemon via Unix socket
  • Daemon (radiusd): Long-running process managing buffers, LSP clients, and history
  • BufferManager: Piece Tree-based text buffer with mtime tracking and LRU eviction
  • LspManager: Per-project LSP client lifecycle management
  • ExtensionLoader: VSCode extension loading with static extraction + activate() fallback
  • HistoryTracker: Per-project changeset history for undo/redo operations
  • SessionManager: Tag-chain based session tracking with rewind detection
  • ChangeLedger: Records all changes with timestamps for conflict detection
  • ConflictManager: Detects overlapping edits and manages notifications between agents

Development

Project structure

src/
  cli/           # CLI entry point and command parsing
  daemon/        # Daemon entry point and handler registry
  core/
    buffer/      # Piece Tree buffer manager
    commands/    # Command handlers
    history/     # Undo/redo tracking
    imports/     # Import statement scanning and rewriting
    conflict/    # Git conflict parsing
    graph/       # Mermaid graph generation (imports, refs, calls)
    session/     # Tag-chain session management with rewind detection
    agent/       # Multi-agent support (ledger, conflict detection)
  lsp/           # LSP client and transport
  extension-host/# VSCode extension loading
  ipc/           # Unix socket IPC layer
  shared/        # Shared utilities, colors, debug logging

Build

bun run build    # Build both radius and radiusd binaries

Testing

bun run test       # Run all tests (CI mode)
bun run test:dev   # Run tests, stop on first failure (development mode)

Tests run in parallel with isolated RADIUS_HOME directories for each test file.

Type checking

bunx tsc --noEmit

License

MIT