Skip to content
PRN-6Public

About

Autonomous terminal AI coding agent (Cloud Intelligence + Local Execution). Powered by Qwen2.5-Coder on free dual Kaggle GPUs or Ollama, with surgical diff editing, AST search, test-driven fixing, and a 5-tier security sandbox.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Code68 πŸš€

Autonomous AI Coding Agent | Cloud Intelligence + Local Execution

Website License: MIT Python 3.11+ Tests

Code68 Terminal Demo

Code68 is an independent, modular open-source terminal AI coding agent inspired by Claude Code.

The Core Concept:

Cloud Intelligence + Local Execution = Code68

The heavy LLM (e.g., Qwen/Qwen2.5-Coder-7B-Instruct, 4-bit quantized) runs remotely on a GPU server (such as a free Kaggle instance with 2x NVIDIA Tesla T4 GPUs), while Code68 runs locally on the developer's computer. The local agent interacts with your real project files, terminal, Git repository, and tests with full security sandboxing and granular permissions. The local computer never needs to load the model into memory.


πŸ—οΈ Architecture

                                      CLOUD (Remote GPU / Kaggle / vLLM)
                             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                             β”‚   Qwen2.5-Coder-7B-Instruct (4-bit BitsAndBytes) β”‚
                             β”‚        OpenAI-Compatible FastAPI Server          β”‚
                             β”‚          Token Auth + SSE Streaming              β”‚
                             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                      β–²  Encrypted Tunnel
                                                      β”‚  (Cloudflare / ngrok)
                                                      β–Ό
LOCAL DEVELOPER MACHINE      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                             β”‚                  Code68 CLI                      β”‚
                             β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
                             β”‚  β”‚            Autonomous Agent Loop            β”‚ β”‚
                             β”‚  β”‚      (Tool Calling, Loop Detector, Context) β”‚ β”‚
                             β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
                             β”‚                 β”‚                                β”‚
                             β”‚                 β–Ό                                β”‚
                             β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
                             β”‚  β”‚           Security & Sandbox Gate           β”‚ β”‚
                             β”‚  β”‚  (Permission Levels, Traversal Guard, Audit)β”‚ β”‚
                             β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
                             β”‚                 β”‚ Approved Actions               β”‚
                             β”‚                 β–Ό                                β”‚
                             β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
                             β”‚  β”‚               Local Tools                   β”‚ β”‚
                             β”‚  β”‚  β€’ Filesystem (read, write, edit with diff) β”‚ β”‚
                             β”‚  β”‚  β€’ Search (ripgrep / python fallback)       β”‚ β”‚
                             β”‚  β”‚  β€’ Terminal (sandboxed commands & timeouts) β”‚ β”‚
                             β”‚  β”‚  β€’ Git (status, diff, branch, safe commit)  β”‚ β”‚
                             β”‚  β”‚  β€’ Testing (pytest, linters, type checkers) β”‚ β”‚
                             β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
                             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

⚑ Key Features

  • Real Tool-Calling Agent Loop: Autonomous multi-step problem solving, loop detection, and structured tool recovery.
  • Surgical Code Editing: Uses unified diffs and snippet replacement rather than blindly rewriting entire files.
  • Deep Codebase Intelligence: AST symbol extraction, language discovery, .gitignore filtering, and smart token budgeting.
  • Strict Security & Boundaries:
    • Traversal prevention (resolve_safe_path confines access to project root).
    • 5 Granular permission levels: read-only, edit-approved, auto-edit, command-approved, and full-auto.
    • Destructive command interceptor (rm -rf, disk wipes, fork bombs blocked).
    • Secret & API key redaction in logs and tool results.
    • Full audit logging in .code68/audit.log.
  • Provider Agnostic: Seamlessly swap between Kaggle, vLLM, Ollama, OpenRouter, or OpenAI without changing any client code.
  • Beautiful Rich Terminal UI: Markdown formatting, syntax highlighting, diff visualizer, and streaming token output.

πŸ“¦ Installation

Method 1: Install Directly via pip (Quickest for Users ⚑)

Any developer with Python 3.11+ can install Code68 as a system-wide or user tool:

# Using pip
pip install git+https://github.com/PRN-6/code68.git

# Or isolated using pipx (recommended for CLI apps)
pipx install git+https://github.com/PRN-6/code68.git

Now code68 is available everywhere in your terminal:

code68 --version

Method 2: Clone for Local Development / Contributing

# Clone the repository
git clone https://github.com/PRN-6/code68.git
cd code68

# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .\.venv\Scripts\activate

# Install in editable mode with development dependencies
pip install -e ".[dev]"

☁️ Setting Up an LLM Brain

Code68 needs an LLM endpoint. Users can choose any of the following options:

Option A: Free Cloud GPU via Kaggle (Zero Local VRAM)

  1. Open a new Kaggle notebook: kaggle.com/code
  2. Settings (right panel): Accelerator = GPU T4 x 2, Internet = ON
  3. Paste and run this single cell:
    !git clone https://github.com/PRN-6/code68.git
    %cd /kaggle/working/code68
    !pip install -q -r server/requirements-server.txt
    !python server/kaggle_server.py
  4. Copy the printed tunnel URL into your .env file:
    CODE68_BASE_URL=https://random-name.trycloudflare.com/v1
    CODE68_API_KEY=code68-secret-key

Option B: Local Ollama (100% Offline)

If a user already has Ollama installed locally:

ollama run qwen2.5-coder:7b

Then configure Code68:

CODE68_BASE_URL=http://localhost:11434/v1
CODE68_MODEL=qwen2.5-coder:7b

Option C: Cloud API (OpenRouter, DeepSeek, Groq, OpenAI)

Code68 works with any OpenAI-compatible provider:

CODE68_BASE_URL=https://openrouter.ai/api/v1
CODE68_API_KEY=your-openrouter-key
CODE68_MODEL=qwen/qwen-2.5-coder-32b-instruct

βš™οΈ Configuration

Configure via environment variables or .env:

CODE68_BASE_URL=https://your-cloud-endpoint/v1
CODE68_API_KEY=code68-secret-key
CODE68_MODEL=Qwen/Qwen2.5-Coder-7B-Instruct
CODE68_PROVIDER=openai-compatible
CODE68_PERMISSION_LEVEL=edit-approved

Or configure via the CLI:

code68 config --set-url "https://your-endpoint/v1" --set-key "your-key"

Check system diagnostics:

code68 doctor

πŸ’» CLI Usage

Interactive REPL

code68

Inside the interactive session:

  • Type your instructions naturally: Find bugs in auth.py and fix them
  • Interactive slash commands:
    • /help - Show available commands
    • /clear - Clear conversation context
    • /compact - Compact message history to stay within token budget
    • /model [name] - View or switch model
    • /status - Check server connection & workspace state
    • /diff - View current uncommitted git diff
    • /undo - Revert changes
    • /exit - Exit Code68

One-shot Command Execution

code68 "Analyze the architecture of this project and summarize main entrypoints"

πŸ›‘οΈ Security & Permission Levels

Configure safety constraints with CODE68_PERMISSION_LEVEL:

Level Allowed Without Prompting Requires Confirmation
read-only File reads, directory listing, searching, git status File modifications, terminal commands, deletions
edit-approved (Default) Reads, searches, git status File edits, file deletions, commands
auto-edit File edits, reads, searches Terminal commands, deletions
command-approved Edits, reads, searches Terminal commands
full-auto All operations within workspace None (unattended automation)

Note: Destructive commands (e.g. rm -rf /, mkfs) and deletions are always flagged regardless of permission level.


πŸ§ͺ Testing

Run the full automated test suite (mocked provider, tools, security, indexing, and CLI):

pytest -v

πŸ“‚ Project Structure

code68/
β”‚
β”œβ”€β”€ pyproject.toml              # Package specifications & entry points
β”œβ”€β”€ requirements.txt            # Dependency specifications
β”œβ”€β”€ README.md                   # Complete documentation
β”œβ”€β”€ LICENSE                     # MIT License
β”œβ”€β”€ .env.example                # Sample environment configuration
β”‚
β”œβ”€β”€ server/                     # Cloud Inference Server
β”‚   β”œβ”€β”€ kaggle_server.py        # 4-bit Qwen2.5-Coder server with Cloudflare tunnel
β”‚   └── README.md               # Kaggle deployment guide
β”‚
β”œβ”€β”€ src/code68/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ main.py                 # Executable entrypoint
β”‚   β”œβ”€β”€ cli.py                  # Typer CLI & interactive REPL
β”‚   β”‚
β”‚   β”œβ”€β”€ core/                   # Agent Architecture
β”‚   β”‚   β”œβ”€β”€ agent.py            # High-level coordinator
β”‚   β”‚   β”œβ”€β”€ agent_loop.py       # Tool-calling agent loop with loop detection
β”‚   β”‚   β”œβ”€β”€ context.py          # Dynamic workspace context builder
β”‚   β”‚   β”œβ”€β”€ conversation.py     # Conversation thread & token manager
β”‚   β”‚   β”œβ”€β”€ planner.py          # Multi-step task planner
β”‚   β”‚   β”œβ”€β”€ state.py            # Agent state & repetitive loop detector
β”‚   β”‚   └── prompts.py          # System prompt & behavioral principles
β”‚   β”‚
β”‚   β”œβ”€β”€ llm/                    # Remote Inference Layer
β”‚   β”‚   β”œβ”€β”€ base.py             # Abstract base provider & exceptions
β”‚   β”‚   β”œβ”€β”€ client.py           # Provider factory
β”‚   β”‚   β”œβ”€β”€ models.py           # Message, ToolCall, FunctionCall models
β”‚   β”‚   β”œβ”€β”€ providers.py        # OpenAI-compatible & Mock providers
β”‚   β”‚   └── streaming.py        # SSE chunk accumulator
β”‚   β”‚
β”‚   β”œβ”€β”€ tools/                  # Local Execution Tools
β”‚   β”‚   β”œβ”€β”€ registry.py         # Tool registry, permission dispatcher & audit logger
β”‚   β”‚   β”œβ”€β”€ schemas.py          # OpenAI function schema generator
β”‚   β”‚   β”œβ”€β”€ filesystem.py       # Safe read, write, edit_file (diff), list, delete
β”‚   β”‚   β”œβ”€β”€ search.py           # ripgrep integration with Python regex fallback
β”‚   β”‚   β”œβ”€β”€ terminal.py         # Subprocess runner with timeouts & safety filters
β”‚   β”‚   β”œβ”€β”€ git.py              # Git status, diff, log, show, safe commit
β”‚   β”‚   └── testing.py          # Automated test, linter, & type checker runner
β”‚   β”‚
β”‚   β”œβ”€β”€ indexing/               # Codebase Intelligence
β”‚   β”‚   β”œβ”€β”€ ignore.py           # .gitignore filter
β”‚   β”‚   β”œβ”€β”€ scanner.py          # Project & language detection
β”‚   β”‚   β”œβ”€β”€ symbols.py          # Python AST symbol extractor
β”‚   β”‚   └── retrieval.py        # Visual ASCII tree & relevant file finder
β”‚   β”‚
β”‚   β”œβ”€β”€ security/               # Security & Sandboxing
β”‚   β”‚   β”œβ”€β”€ permissions.py      # Granular permission levels
β”‚   β”‚   β”œβ”€β”€ sandbox.py          # Workspace boundary & traversal guard
β”‚   β”‚   └── validation.py       # Destructive command detector & secret masking
β”‚   β”‚
β”‚   β”œβ”€β”€ storage/                # State & Persistence
β”‚   β”‚   β”œβ”€β”€ config.py           # Pydantic configuration loader
β”‚   β”‚   β”œβ”€β”€ history.py          # Conversation history & context compactor
β”‚   β”‚   └── sessions.py         # Session persistence to disk
β”‚   β”‚
β”‚   └── ui/                     # Terminal Interface
β”‚       β”œβ”€β”€ terminal.py         # Terminal UI coordinator
β”‚       β”œβ”€β”€ renderer.py         # Rich markdown, diffs, panels, & status
β”‚       └── components.py       # Approval dialogs & user prompts
β”‚
└── tests/                      # Automated Test Suite (27 tests)
    β”œβ”€β”€ conftest.py             # Fixtures (workspace & mock LLM)
    β”œβ”€β”€ test_agent.py           # End-to-end tool calling & agent loop tests
    β”œβ”€β”€ test_cli.py             # CLI commands tests
    β”œβ”€β”€ test_indexing.py        # Codebase scanner, symbols, & tree tests
    β”œβ”€β”€ test_llm.py             # LLM provider, streaming, & schema tests
    β”œβ”€β”€ test_security.py        # Sandbox traversal & permission tests
    └── test_tools.py           # Filesystem, search, terminal, & git tests

πŸ“œ License

MIT License. See LICENSE for details.

About

Autonomous terminal AI coding agent (Cloud Intelligence + Local Execution). Powered by Qwen2.5-Coder on free dual Kaggle GPUs or Ollama, with surgical diff editing, AST search, test-driven fixing, and a 5-tier security sandbox.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages