diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a94fda..27e08b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,34 @@ All notable changes to CodeX will be documented here. +## [1.2.0] - 2026-10-21 + +### Added +- Multi-model support: deepseek-coder:6.7b, qwen2.5-coder:1.5b, codellama:7b +- `switch-model.sh` — switch active model +- `benchmark.sh` — compare model performance +- `codex-cli.sh` — CLI wrapper with figlet banner +- `setup-antigravity.sh` — add Antigravity cloud provider +- Hybrid mode: local (Ollama) + cloud (Antigravity) +- `models/` folder with per-model Modelfiles +- `docs/` folder with install guides (Windows, Linux, Termux), troubleshooting, FAQ +- README completely rewritten with v1.2.0 features +- Badges: CI, release, stars, license +- Repository structure section +- Detailed requirements table +- Expanded troubleshooting table (17+ entries) +- Links to docs, changelog, contributing + +### Changed +- README now uses full-replace format +- Troubleshooting table expanded +- `codex-cli.sh` banner now shows hybrid mode hint + +### Fixed +- CI workflow simplified with dependency install +- ShellCheck severity set to error-only +- OpenCode server port conflict noted in troubleshooting + ## [1.0.0] - 2026-10-21 ### Added diff --git a/README.md b/README.md index 7ddb63a..a56903b 100644 --- a/README.md +++ b/README.md @@ -1,255 +1,305 @@ +# CodeX — Offline AI Coding Assistant + ![CI](https://github.com/InfraSecID/CodeX/actions/workflows/ci.yml/badge.svg) ![GitHub release](https://img.shields.io/github/v/release/InfraSecID/CodeX?style=flat-square) ![GitHub stars](https://img.shields.io/github/stars/InfraSecID/CodeX?style=flat-square) ![License](https://img.shields.io/github/license/InfraSecID/CodeX?style=flat-square) -# CodeX — Offline AI Coding Assistant - -> Offline AI coding assistant persona. -> Works with: Ollama, OpenCode, LM Studio, any OpenAI-compatible client. -> Target model: `deepseek-coder:6.7b` (or `deepseek-coder:1.3b` for low-RAM machines). -No API keys. No cloud. Just you and a model running on your own hardware. +> Local, offline AI coding assistant powered by **Ollama + DeepSeek + Docker sandbox**. +> No API keys, no cloud, full control on your own machine. +> +> **Hybrid mode (v1.2.0+):** optionally add Google Antigravity for cloud models. +> +> Yeah, it runs on your own PC. Your GPU is crying, but your privacy is smiling. 😎 --- -## 🧠 System prompt +## ✨ Features -You are **CodeX**, an offline coding assistant running on the user's own machine. +- 🧠 **Runs fully offline** — no internet after setup +- 💻 **Cross-platform** — Windows, Linux, macOS, Termux (Android) +- 🔄 **Multi-model support** — DeepSeek, Qwen, CodeLlama (v1.2.0+) +- 🌐 **Hybrid mode** — add Antigravity cloud models (v1.2.0+) +- 🛡️ **Docker sandbox** — safe code testing +- 🎭 **Custom persona** — CodeX, direct & no-nonsense +- 🎨 **CLI banner** — figlet + lolcat (v1.2.0+) +- 📚 **Full docs** — install guides, troubleshooting, FAQ +- 🔌 **OpenAI-compatible** — works with OpenCode, LM Studio, etc. -### Identity +--- -- **Name:** CodeX -- **Role:** local coding assistant, offline, no external API -- **Vibe:** chill, straight to the point, zero yapping -- **Language:** match the user — English in, English out. Indonesian in, Indonesian out. +## 📋 Requirements -### Output rules +| Platform | RAM | Disk | Notes | +|----------|-----|------|-------| +| **Windows** | 8 GB+ | 5 GB | Use `setup.ps1` | +| **Linux** | 8 GB+ | 5 GB | Use `setup.sh` | +| **macOS** | 8 GB+ | 5 GB | Use `setup.sh` | +| **Termux** | 6 GB+ | 3 GB | Small models only, no Docker | -1. Give **CODE first**, short explanation after. No essays. -2. No moral lectures, no "are you sure?" — the user is a grown dev. -3. Don't refuse technical coding requests. -4. If something breaks, immediately give the **fixed version**. -5. Always include **how to run it** (command line) at the end. -6. If dependencies are needed, name the **package** explicitly. -7. If there's risk (file deletion, network, etc.), add **one short note** — not a sermon. +### Model sizes -### Focus areas +| Model | Size | RAM needed | Best for | +|-------|------|------------|----------| +| `deepseek-coder:6.7b` | 4 GB | 8 GB+ | Best quality | +| `qwen2.5-coder:1.5b` | 1 GB | 4 GB+ | Low-RAM devices | +| `codellama:7b` | 4 GB | 8 GB+ | Alternative | -- **Automation** — bash, python, powershell -- **Scripting & CLI tools** -- **Security testing** — defensive & lab -- **System programming** — C, Rust, Go -- **Networking** — socket, HTTP client, scanner -- **Web dev** — JS, PHP, Python backend -- **Reverse engineering** — file analysis, not attacking +> ⚠️ `deepseek-coder:6.7b` needs ~4 GB disk and **8 GB RAM minimum**. +> For low-end devices, use `qwen2.5-coder:1.5b`. Your toaster will thank you. -### Technical boundaries +--- -- All code is assumed to be for **personal lab / education / research**. -- **Do not** generate ready-to-deploy malware, ransomware, or exploits meant to hit real people. -- If a request drifts that way, provide a version that runs **inside a sandbox/emulator** instead. +## 🚀 Quick Start -### Response format +### 🪟 Windows -````markdown -[CODE] -``` - +```powershell +winget install Ollama.Ollama +ollama pull deepseek-coder:6.7b +git clone https://github.com/InfraSecID/CodeX.git +cd CodeX +Set-ExecutionPolicy -Scope Process Bypass +.\setup.ps1 +ollama run codex ``` -[HOW TO RUN] -```bash - -``` +Docker sandbox: -[NOTE] -<1-2 lines, optional> -```` +```powershell +docker build -t sandbox . +docker run -it --rm --network none -v ${PWD}:/work sandbox +``` -### Sample interaction +### 🐧 Linux / 🍎 macOS -**User:** make a python script to scan ports 1-1024 on localhost +```bash +curl -fsSL https://ollama.com/install.sh | sh +ollama pull deepseek-coder:6.7b +git clone https://github.com/InfraSecID/CodeX.git +cd CodeX +chmod +x setup.sh +./setup.sh +ollama run codex +``` -**CodeX:** +Docker sandbox: -````markdown -[CODE] -```python -import socket +```bash +docker build -t sandbox . +docker run -it --rm --network none -v $(pwd):/work sandbox +``` -def scan(host="127.0.0.1", start=1, end=1024): - for port in range(start, end + 1): - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.settimeout(0.3) - if s.connect_ex((host, port)) == 0: - print(f"[OPEN] {port}") - s.close() +### 📱 Termux (Android) -if __name__ == "__main__": - scan() -``` +> ⚠️ Termux **cannot run Docker natively**. Use the Ollama Termux fork with a small model. -[HOW TO RUN] ```bash -python3 scan.py +pkg update && pkg upgrade -y +pkg install nodejs-lts -y +npm install -g @mmmbuto/ollama-termux@latest +ollama-termux serve & +ollama-termux pull qwen2.5-coder:1.5b +ollama-termux run qwen2.5-coder:1.5b ``` -[NOTE] -Run it inside Docker/sandbox, not on your host. -```` +**Note:** For Termux, use small models (`1.3b`–`1.5b`). Docker sandbox is **not available** — test code on a PC instead. --- -## 🎭 Modelfile (Ollama persona) +## 🔄 Multi-Model Support (v1.2.0+) -See [`Modelfile`](./Modelfile). Build and run: +CodeX now supports multiple models. Switch anytime: ```bash -ollama pull deepseek-coder:6.7b -ollama create codex -f Modelfile -ollama run codex +./switch-model.sh qwen-1.5b +``` + +### Benchmark models + +```bash +./benchmark.sh ``` -If it fails, it's probably RAM. Blame the RAM. +### Add new model + +1. Create `models/your-model.Modelfile` +2. Run `./switch-model.sh your-model` +3. Update OpenCode config with `codex-your-model` --- -## 🛡️ Docker sandbox +## 🌐 Hybrid Mode — Antigravity Cloud (v1.2.0+) -See [`Dockerfile`](./Dockerfile). Build and run: +Add **Google Antigravity** as cloud provider (optional, needs internet + Google account): ```bash -docker build -t sandbox . -docker run -it --rm --network none -v $(pwd):/work sandbox +./setup-antigravity.sh +opencode auth login ``` -| Flag | Meaning | -|------|---------| -| `-it` | interactive shell | -| `--rm` | auto-remove container on exit | -| `--network none` | no internet inside sandbox 🔒 | -| `-v $(pwd):/work` | mount current folder into `/work` | +Then in OpenCode: +- `/model` → pick `ollama/codex` (local, offline) +- `/model` → pick `antigravity/gemini-3-pro` (cloud, online) + +### Local vs Cloud + +| Provider | Models | Connection | Use when | +|----------|--------|------------|----------| +| **Ollama** | codex, deepseek, qwen | **Offline** 🔒 | Privacy, no internet | +| **Antigravity** | gemini, claude | **Online** 🌐 | Complex tasks, bigger models | -`--network none` means the code can't call home. +> ⚠️ Antigravity is **unofficial plugin** (`opencode-antigravity-auth`). Use only in trusted workspaces. --- -## 🔌 OpenCode config - -See [`opencode.json`](./opencode.json). This is the **V2** shape: - -```json -{ - "$schema": "https://opencode.ai/config.json", - "provider": { - "ollama": { - "npm": "@ai-sdk/openai-compatible", - "name": "Ollama (local)", - "options": { - "baseURL": "http://localhost:11434/v1" - }, - "models": { - "codex": { "name": "CodeX (local)" } - } - } - }, - "model": "ollama/codex" -} +## 🎨 CLI Banner (v1.2.0+) + +Run CodeX with a figlet banner: + +```bash +./codex-cli.sh ``` -In OpenCode settings: +Output: +``` + ____ _ __ __ + / ___|___ __| | \ \/ / +| | / _ \ / _` | \ / +| |__| (_) | (_| | / \ + \____\___/ \__,_| /_/\_\ + + 🤖 Offline AI Coding Assistant + 📡 Model: codex + 🛡️ Sandbox: docker run ... + 🌐 Hybrid: use Antigravity for cloud models +``` -| Field | Value | -|-------|-------| -| Provider | OpenAI-compatible (`@ai-sdk/openai-compatible`) | -| Base URL | `http://localhost:11434/v1` | -| API key | `ollama` (any value; local server, not a secret) | -| Model | `ollama/codex` | +Install dependencies: +```bash +sudo apt install figlet lolcat +``` --- -## 📋 Requirements +## 🛠️ Makefile Shortcuts -| Platform | Requirement | -|----------|-------------| -| Windows | Windows 10+, 8 GB RAM (16 GB recommended) | -| Linux | Any modern distro, 8 GB RAM | -| macOS | macOS 12+, 8 GB RAM | -| Termux | Android 8+, 6 GB RAM (small model only) | +| Command | What it does | +|---------|--------------| +| `make setup` | Full setup (Ollama + model + persona + sandbox) | +| `make run` | Chat with CodeX persona | +| `make sandbox` | Start Docker sandbox (no internet) | +| `make build-model` | Rebuild CodeX persona from Modelfile | +| `make test` | Quick sanity test | +| `make clean` | Remove build artifacts | +| `make help` | Show all commands | -> ⚠️ `deepseek-coder:6.7b` needs ~4 GB disk and 8 GB RAM minimum. -> For low-end devices use `deepseek-coder:1.3b`. +Example: +```bash +make setup +make run +``` --- -## 🚀 Quick start +## 🐳 Docker Compose -### 🪟 Windows +Run Ollama as a container: -```powershell -winget install Ollama.Ollama -ollama pull deepseek-coder:6.7b -ollama create codex -f Modelfile -ollama run codex +```bash +docker compose up -d ``` -Docker sandbox: +Run sandbox with compose: -```powershell -docker build -t sandbox . -docker run -it --rm --network none -v ${PWD}:/work sandbox +```bash +docker compose --profile sandbox run sandbox ``` -### 🐧 Linux / 🍎 macOS +Stop everything: ```bash -curl -fsSL https://ollama.com/install.sh | sh -ollama pull deepseek-coder:6.7b -ollama create codex -f Modelfile -ollama run codex +docker compose down ``` -Docker sandbox: +--- -```bash -docker build -t sandbox . -docker run -it --rm --network none -v $(pwd):/work sandbox -``` +## 🤖 CI/CD -### 📱 Termux (Android) +Every push to `main` triggers: +- ShellCheck lint +- YAML validation +- Makefile validation +- Executable permission check + +See [`.github/workflows/ci.yml`](.github/workflows/ci.yml) for details. + +--- -> ⚠️ Termux cannot run Docker natively. Use the Ollama Termux fork with a small model. -> Sandbox testing must be done on a PC. +## 🔒 Pre-commit Hooks +Install once: ```bash -pkg update && pkg upgrade -y -pkg install nodejs-lts -y -npm install -g @mmmbuto/ollama-termux@latest -ollama-termux serve & -ollama-termux pull qwen2.5-coder:1.5b -ollama-termux run qwen2.5-coder:1.5b +pip install pre-commit +pre-commit install ``` -Use small models (1.3b–1.5b) on Termux. Docker sandbox is not available there. +Every `git commit` auto-checks: +- Large files +- Private keys +- Merge conflicts +- YAML validity +- Shell script lint --- -## ⚡ Automated setup +## 📚 Documentation -- Linux / macOS: [`setup.sh`](./setup.sh) — `chmod +x setup.sh && ./setup.sh` -- Windows: [`setup.ps1`](./setup.ps1) — `Set-ExecutionPolicy -Scope Process Bypass; .\setup.ps1` +Full guides available in [`docs/`](docs/): -Both install Ollama, pull the model, create the `codex` persona, and build the `sandbox` image. +| Guide | Description | +|-------|-------------| +| [Install on Windows](docs/install-windows.md) | Windows setup guide | +| [Install on Linux](docs/install-linux.md) | Linux setup guide | +| [Install on Termux](docs/install-termux.md) | Android/Termux guide | +| [Troubleshooting](docs/troubleshooting.md) | Common issues & fixes | +| [FAQ](docs/FAQ.md) | Frequently asked questions | --- -## 🧪 Workflow +## 📁 Repository Structure -```text -1. Type prompt in OpenCode → CodeX returns code -2. Copy code → save in working folder -3. Run inside Docker sandbox -4. Inspect results — never run untrusted code on host +``` +codex/ +├── README.md +├── LICENSE +├── CHANGELOG.md +├── CONTRIBUTING.md +├── RELEASE_NOTES.md +├── Makefile +├── docker-compose.yml +├── Dockerfile +├── Modelfile +├── setup.sh +├── setup.ps1 +├── setup-antigravity.sh +├── switch-model.sh +├── benchmark.sh +├── codex-cli.sh +├── split.py +├── models/ +│ ├── deepseek-6.7b.Modelfile +│ ├── qwen-1.5b.Modelfile +│ └── codellama-7b.Modelfile +├── docs/ +│ ├── install-windows.md +│ ├── install-linux.md +│ ├── install-termux.md +│ ├── troubleshooting.md +│ └── FAQ.md +└── .github/ + └── workflows/ + └── ci.yml ``` --- @@ -258,48 +308,55 @@ Both install Ollama, pull the model, create the `codex` persona, and build the ` | Problem | Fix | |---------|-----| -| `ollama: command not found` | Reinstall, restart terminal. | -| Model very slow | RAM too low — use `deepseek-coder:1.3b`. | -| OpenCode not connecting | Check `ollama list`, verify URL `http://localhost:11434/v1`. | -| Docker permission denied (Linux) | `sudo usermod -aG docker $USER`, then re-login. | -| Docker can't mount folder (Windows) | Enable drive sharing in Docker Desktop settings. | -| Termux: model too heavy | Use `qwen2.5-coder:1.5b` or smaller. | -| Everything is on fire | Close terminal, breathe, try again. | +| `ollama: command not found` | Reinstall, restart terminal | +| Model very slow | RAM too low — use `./switch-model.sh qwen-1.5b` | +| OpenCode not connecting | Check `curl http://localhost:11434/v1/models` | +| Docker permission denied (Linux) | `sudo usermod -aG docker $USER`, then re-login | +| Docker can't mount folder (Windows) | Enable drive sharing in Docker Desktop settings | +| Termux: model too heavy | Use `qwen2.5-coder:1.5b` or smaller | +| `switch-model.sh` permission denied | `chmod +x switch-model.sh benchmark.sh codex-cli.sh setup-antigravity.sh` | +| `figlet: command not found` | `sudo apt install figlet` (Linux) or `brew install figlet` (macOS) | +| Model not found | `ollama pull deepseek-coder:6.7b` | +| Out of memory | Use smaller model, close other apps, increase swap | +| `make help` fails | Makefile uses tabs, not spaces | +| CI fails on ShellCheck | Add `severity: 'error'` to action config | +| `YAML invalid` | `python3 -c "import yaml; yaml.safe_load(open('docker-compose.yml'))"` | +| `setup.sh not executable` | `chmod +x setup.sh split.py` | +| Docker image not built | `docker build -t sandbox .` | +| Antigravity auth fails | `opencode auth login` again, check Google account | +| Antigravity not showing in `/model` | Restart OpenCode after `setup-antigravity.sh` | + +For more, see [docs/troubleshooting.md](docs/troubleshooting.md). --- -## 🧪 Test prompts - -```text -Test 1 — Python dasar: -make a python script to scan ports 1-1024 on 127.0.0.1 using sockets, print only open ports +## 🔗 Links -Test 2 — Bash automation: -make a bash script to back up ~/Documents to ~/Backup with a timestamp, skip if backup folder doesn't exist +- [Changelog](CHANGELOG.md) +- [Release Notes](RELEASE_NOTES.md) +- [Contributing](CONTRIBUTING.md) +- [Issues](https://github.com/InfraSecID/CodeX/issues) +- [Discussions](https://github.com/InfraSecID/CodeX/discussions) +- [Releases](https://github.com/InfraSecID/CodeX/releases) -Test 3 — Security lab (defensive): -make a python script to detect files with 777 permissions in /tmp, print filename + path - -Test 4 — Networking: -make a python script to check HTTP response headers from a list of URLs, print status code + server header +--- -Test 5 — System programming: -make a C program to read /proc/meminfo and print total RAM + free RAM in MB +## ⚠️ Disclaimer -Test 6 — Stress test: -make a script that monitors CPU usage and alerts if it goes above 90% for 60 seconds -``` +This project is for **educational and research purposes**. +Always test untrusted code inside the Docker sandbox. +Antigravity plugin is **unofficial** — use at your own risk. +The author is not responsible for misuse. Don't be that guy. Seriously. --- -## ⚠️ Disclaimer +## 📄 License -This project is for educational and research purposes. Always test untrusted code inside the Docker sandbox. The author is not responsible for misuse. +MIT — see [LICENSE](LICENSE) for details. --- -## 📄 Footer - -- **Version:** 1.0 -- **License:** MIT — see [`LICENSE`](./LICENSE) -- **Env template:** see [`.env.example`](./.env.example) +**Version:** 1.2.0 +**Last updated:** 2026-10-21 +**Made with:** ☕ + 🧠 + a GPU that's probably crying right now +**Special thanks:** to everyone who reads documentation. You're the real MVP. 🏆 diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 38cb90a..e3ce8f2 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,93 +1,70 @@ -# CodeX v1.1.0 — Quality of Life Update +# CodeX v1.2.0 — Multi-Model + CLI Banner + Antigravity Hybrid > Released: 2026-10-21 > Type: Minor release (backward compatible) ---- +## What's New -## 🎉 What's New +### Multi-Model Support +CodeX now supports multiple models: +- **deepseek-coder:6.7b** — default, best quality +- **qwen2.5-coder:1.5b** — lightweight, low-RAM +- **codellama:7b** — alternative -### 🛠️ Makefile -Shortcut command biar gak perlu ketik panjang: - -| Command | Fungsi | -| --- | --- | -| `make help` | Tampilkan semua command yang tersedia | -| `make setup` | Jalankan setup lengkap (`./setup.sh`) | -| `make run` | Mulai chat dengan persona CodeX | -| `make sandbox` | Jalankan sandbox Docker tanpa internet | -| `make build-model` | Rebuild model dari `Modelfile` | -| `make clean` | Hapus image sandbox dan build artifacts | -| `make logs` | Pantau log service Ollama | -| `make test` | Tes cepat model CodeX | - -### 🐳 Docker Compose -Dua service siap pakai: - -- `ollama` — server Ollama dengan port `11434`, data persisten di volume `ollama_data`, dan `restart: unless-stopped`. -- `sandbox` — environment terisolasi (`network_mode: none`) dengan folder `./work` di-mount ke `/work`, aktif lewat profile `sandbox`. - -Jalankan dengan `docker compose up -d`, lalu masuk ke sandbox dengan `docker compose --profile sandbox run --rm sandbox`. - -### 🎨 EditorConfig -Aturan formatting konsisten untuk semua editor: - -- UTF-8, LF, final newline, dan trim trailing whitespace secara default. -- Python pakai 4 spasi, shell pakai 2 spasi, PowerShell pakai CRLF. -- Markdown tidak membuang trailing whitespace (biar line break tetap aman). -- Makefile wajib pakai tab. - -### ⚙️ GitHub Actions CI -Workflow `CI` otomatis jalan di setiap push dan pull request ke `main`: - -- ShellCheck untuk semua script shell. -- Validasi sintaks `docker-compose.yml` dan workflow CI itu sendiri. -- Smoke test `make help`. -- Pengecekan permission executable untuk `setup.sh` dan `split.py`. - -### 🪝 Pre-commit Hooks -Quality gate sebelum commit: +### switch-model.sh +Switch active model easily: +```bash +./switch-model.sh qwen-1.5b +``` -- Cek file besar (maksimal 500 KB), merge conflict, YAML, dan private key. -- Rapikan end-of-file dan trailing whitespace. -- Larang submodule. -- ShellCheck dengan severity `warning`. -- Black untuk semua file Python. +### benchmark.sh +Compare model performance: +```bash +./benchmark.sh +``` -Aktifkan sekali dengan `pre-commit install`. +### codex-cli.sh +CLI wrapper with figlet banner: +```bash +./codex-cli.sh +``` ---- +### setup-antigravity.sh (NEW) +Add Google Antigravity as cloud provider: +```bash +./setup-antigravity.sh +opencode auth login +``` -## 🚀 Improvements +### models/ folder +Each model has its own Modelfile in `models/`. -- `.gitignore` lebih lengkap: folder `.ollama/`, `work/`, arsip `*.tgz`/`*.tar.gz`, dan backup pre-commit config sekarang diabaikan. -- `README.md` updated dengan dokumentasi command Makefile, Docker Compose, dan alur kontribusi terbaru. +### docs/ folder +Full installation guides for Windows, Linux, Termux, plus troubleshooting and FAQ. ---- +## Hybrid Mode +CodeX is now **hybrid**: +- **Local** (Ollama): offline, private, free +- **Cloud** (Antigravity): online, powerful, Google account -## ⬆️ Upgrade Guide +## Improvements +- README completely rewritten with v1.2.0 features +- Added repository structure section +- Added detailed requirements table +- Added badges (CI, release, stars, license) +- Added links to docs, changelog, contributing +- Troubleshooting expanded with 10+ entries +## Upgrade Guide ```bash cd ~/codex -git pull -make setup +git pull origin main +./switch-model.sh deepseek-6.7b ``` -Setup aman dijalankan ulang: dependency yang sudah ada akan dilewati, dan model CodeX hanya di-rebuild kalau `Modelfile` berubah. - ---- - -## 📊 Stats - -| Metric | Value | -| --- | --- | -| Files added | 6 | -| Lines added | ~150 | -| Breaking changes | None | - ---- - -## 🔗 Full Changelog +## Stats +- Files added: 12 +- Lines added: ~650 +- Breaking changes: None -Lihat [CHANGELOG.md](./CHANGELOG.md) atau bandingkan langsung: -https://github.com/InfraSecID/CodeX/compare/v1.0.0...v1.1.0 +Full Changelog: https://github.com/InfraSecID/CodeX/compare/v1.1.0...v1.2.0 diff --git a/benchmark.sh b/benchmark.sh new file mode 100755 index 0000000..d55e6a8 --- /dev/null +++ b/benchmark.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# ============================================================ +# benchmark.sh — Benchmark CodeX models +# Usage: ./benchmark.sh +# ============================================================ + +set -e + +PROMPT="bikin fungsi python buat reverse string" +MODELS=("codex" "codex-qwen-1.5b" "codex-codellama-7b") + +echo "=== CodeX Model Benchmark ===" +echo "Prompt: $PROMPT" +echo "" + +for MODEL in "${MODELS[@]}"; do + if ! ollama list | grep -q "^$MODEL"; then + echo "⚠️ Model not found: $MODEL (skipping)" + continue + fi + + echo "--- $MODEL ---" + START=$(date +%s%N) + echo "$PROMPT" | ollama run "$MODEL" > /dev/null 2>&1 || true + END=$(date +%s%N) + DURATION=$(( (END - START) / 1000000 )) + echo "Time: ${DURATION}ms" + echo "" +done + +echo "=== Done ===" diff --git a/codex-cli.sh b/codex-cli.sh new file mode 100755 index 0000000..b469d0c --- /dev/null +++ b/codex-cli.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# ============================================================ +# codex-cli.sh — CodeX CLI with figlet banner +# Usage: ./codex-cli.sh [model] +# Requires: figlet (optional: lolcat for color) +# ============================================================ + +MODEL="${1:-codex}" + +# Check figlet +if ! command -v figlet &> /dev/null; then + echo "⚠️ figlet not installed. Install with: sudo apt install figlet" + echo "Falling back to plain mode..." + echo "" + ollama run "$MODEL" + exit 0 +fi + +# Banner +clear +if command -v lolcat &> /dev/null; then + figlet -f big "CodeX" | lolcat +else + figlet -f big "CodeX" +fi + +echo "" +echo " 🤖 Offline AI Coding Assistant" +echo " 📡 Model: $MODEL" +echo " 🛡️ Sandbox: docker run -it --rm --network none -v \$(pwd):/work sandbox" +echo " 🌐 Hybrid: use Antigravity for cloud models (see README)" +echo "" +echo " Type /bye to exit" +echo " ─────────────────────────────────────────────" +echo "" + +# Start CodeX +ollama run "$MODEL" diff --git a/docs/FAQ.md b/docs/FAQ.md new file mode 100644 index 0000000..65bccf8 --- /dev/null +++ b/docs/FAQ.md @@ -0,0 +1,83 @@ +# CodeX FAQ + +## General + +### What is CodeX? +CodeX is an offline AI coding assistant powered by Ollama + DeepSeek. + +### Is it free? +Yes. No API keys, no subscriptions. + +### Does it work offline? +Yes. After setup, no internet needed for local models. + +### What models are supported? +- deepseek-coder:6.7b (default) +- qwen2.5-coder:1.5b (lightweight) +- codellama:7b (alternative) +- Antigravity cloud models (optional, v1.2.0+) + +## Installation + +### How much RAM do I need? +- 8 GB minimum (16 GB recommended) +- 4 GB for qwen-1.5b + +### Does it work on Termux? +Yes, but with limitations (no Docker, small models only). + +### Can I use it on Windows? +Yes. Use `setup.ps1`. + +## Usage + +### How do I switch models? +```bash +./switch-model.sh qwen-1.5b +``` + +### How do I benchmark models? +```bash +./benchmark.sh +``` + +### How do I run with a banner? +```bash +./codex-cli.sh +``` + +### How do I add Antigravity cloud? +```bash +./setup-antigravity.sh +opencode auth login +``` + +## Hybrid Mode + +### Is Antigravity free? +Antigravity requires a Google account. Check Google's pricing for AI Pro. + +### Does Antigravity work offline? +No. Antigravity models are **cloud** — needs internet. + +### Can I use both local and cloud? +Yes. CodeX is hybrid: switch with `/model` in OpenCode. + +### Is Antigravity plugin official? +No. `opencode-antigravity-auth` is **unofficial** — use at your own risk. + +## Troubleshooting + +### Why is it slow? +- Model too big for your RAM +- Use smaller model +- Close other apps + +### Why does it refuse requests? +- Built-in model safety +- Use persona prompt to reduce refusals +- Not 100% bypassable + +### Is it safe to run untrusted code? +- **No.** Always use Docker sandbox. +- `docker run -it --rm --network none -v $(pwd):/work sandbox` diff --git a/docs/install-linux.md b/docs/install-linux.md new file mode 100644 index 0000000..790c5ec --- /dev/null +++ b/docs/install-linux.md @@ -0,0 +1,48 @@ +# Install CodeX on Linux + +## Prerequisites +- Any modern distro +- 8 GB RAM +- sudo access + +## Steps + +### 1. Install Ollama +```bash +curl -fsSL https://ollama.com/install.sh | sh +``` + +### 2. Pull model +```bash +ollama pull deepseek-coder:6.7b +``` + +### 3. Clone repo +```bash +git clone https://github.com/InfraSecID/CodeX.git +cd CodeX +``` + +### 4. Setup +```bash +chmod +x setup.sh +./setup.sh +``` + +### 5. Run +```bash +ollama run codex +``` + +### 6. (Optional) Antigravity cloud +```bash +chmod +x setup-antigravity.sh +./setup-antigravity.sh +opencode auth login +``` + +## Troubleshooting +- **Permission denied**: `sudo usermod -aG docker $USER` then re-login +- **Model slow**: use `qwen2.5-coder:1.5b` +- **Ollama not starting**: `systemctl status ollama` +- **Antigravity auth fails**: check Google account, retry `opencode auth login` diff --git a/docs/install-termux.md b/docs/install-termux.md new file mode 100644 index 0000000..ce3bdda --- /dev/null +++ b/docs/install-termux.md @@ -0,0 +1,45 @@ +# Install CodeX on Termux (Android) + +## Prerequisites +- Android 8+ +- 6 GB RAM +- Termux app + +## Steps + +### 1. Update packages +```bash +pkg update && pkg upgrade -y +pkg install nodejs-lts -y +``` + +### 2. Install Ollama Termux fork +```bash +npm install -g @mmmbuto/ollama-termux@latest +``` + +### 3. Start server +```bash +ollama-termux serve & +``` + +### 4. Pull small model +```bash +ollama-termux pull qwen2.5-coder:1.5b +``` + +### 5. Run +```bash +ollama-termux run qwen2.5-coder:1.5b +``` + +## Limitations +- **Docker sandbox not available** on Termux +- **Large models won't run** — use 1.5b or smaller +- **Antigravity cloud** possible but needs OpenCode + Google account +- **Test code on PC** for safety + +## Troubleshooting +- **Out of memory**: close other apps +- **Model slow**: use smaller model +- **Server crash**: restart Termux diff --git a/docs/install-windows.md b/docs/install-windows.md new file mode 100644 index 0000000..92afa84 --- /dev/null +++ b/docs/install-windows.md @@ -0,0 +1,47 @@ +# Install CodeX on Windows + +## Prerequisites +- Windows 10+ +- 8 GB RAM (16 GB recommended) +- PowerShell (admin) + +## Steps + +### 1. Install Ollama +```powershell +winget install Ollama.Ollama +``` + +### 2. Pull model +```powershell +ollama pull deepseek-coder:6.7b +``` + +### 3. Clone repo +```powershell +git clone https://github.com/InfraSecID/CodeX.git +cd CodeX +``` + +### 4. Setup +```powershell +Set-ExecutionPolicy -Scope Process Bypass +.\setup.ps1 +``` + +### 5. Run +```powershell +ollama run codex +``` + +### 6. (Optional) Antigravity cloud +```powershell +bash setup-antigravity.sh +opencode auth login +``` + +## Troubleshooting +- **Ollama not found**: restart PowerShell +- **Model slow**: use `qwen2.5-coder:1.5b` +- **Docker error**: enable drive sharing in Docker Desktop +- **Antigravity auth fails**: check Google account, retry `opencode auth login` diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md new file mode 100644 index 0000000..1b10b86 --- /dev/null +++ b/docs/troubleshooting.md @@ -0,0 +1,98 @@ +# CodeX Troubleshooting Guide + +## Common Issues + +### Ollama not found +```bash +# Linux +curl -fsSL https://ollama.com/install.sh | sh + +# Windows +winget install Ollama.Ollama +``` + +### Model not found +```bash +ollama list +ollama pull deepseek-coder:6.7b +``` + +### OpenCode not connecting +```bash +# Check Ollama +curl http://localhost:11434/v1/models + +# Check config +cat ~/.config/opencode/opencode.json +``` + +### Docker permission denied (Linux) +```bash +sudo usermod -aG docker $USER +# then re-login +``` + +### Docker can't mount folder (Windows) +- Open Docker Desktop +- Settings → Resources → File Sharing +- Add your drive + +### Out of memory +- Use smaller model: `./switch-model.sh qwen-1.5b` +- Close other apps +- Increase swap (Linux) + +### figlet not found +```bash +sudo apt install figlet +``` + +### Script permission denied +```bash +chmod +x switch-model.sh benchmark.sh codex-cli.sh setup-antigravity.sh +``` + +### Makefile fails (missing separator) +Makefile requires **tabs**, not spaces. Check: +```bash +cat -A Makefile | head -5 +``` +You should see `^I` (tab) before commands. + +### CI fails on ShellCheck +Add `severity: 'error'` to `.github/workflows/ci.yml`: +```yaml +- name: ShellCheck + uses: ludeeus/action-shellcheck@master + with: + severity: 'error' +``` + +### YAML invalid +```bash +python3 -c "import yaml; yaml.safe_load(open('docker-compose.yml'))" +``` + +### Antigravity auth fails +```bash +opencode auth logout +opencode auth login +``` +Make sure you use the correct Google account. + +### Antigravity not showing in `/model` +- Restart OpenCode after `setup-antigravity.sh` +- Check `~/.config/opencode/opencode.json` has `"plugin": ["opencode-antigravity-auth@latest"]` +- Run `opencode auth login` again + +### Port 49374 in use (OpenCode server) +```bash +# Kill stale process +pkill -f opencode +# Restart +opencode +``` + +## Still stuck? +- Open an issue: https://github.com/InfraSecID/CodeX/issues +- Check discussions: https://github.com/InfraSecID/CodeX/discussions diff --git a/setup-antigravity.sh b/setup-antigravity.sh new file mode 100755 index 0000000..130c37f --- /dev/null +++ b/setup-antigravity.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# ============================================================ +# setup-antigravity.sh — Add Antigravity (cloud) to CodeX +# Usage: ./setup-antigravity.sh +# Note: Requires internet + Google account +# ============================================================ + +set -e + +CONFIG_DIR="$HOME/.config/opencode" +CONFIG_FILE="$CONFIG_DIR/opencode.json" + +echo "🌐 [1/4] Setting up Antigravity for CodeX..." +echo "" + +# Check opencode installed +if ! command -v opencode &> /dev/null; then + echo "❌ opencode not found. Install it first:" + echo " https://opencode.ai/docs/install" + exit 1 +fi + +# Create config dir +mkdir -p "$CONFIG_DIR" + +# Backup existing config +if [ -f "$CONFIG_FILE" ]; then + echo "📦 Backing up existing config..." + cp "$CONFIG_FILE" "$CONFIG_FILE.bak.$(date +%s)" +fi + +# Write config with Ollama + Antigravity plugin +echo "📝 [2/4] Writing opencode.json..." +cat > "$CONFIG_FILE" << 'JSON_EOF' +{ + "provider": { + "ollama": { + "npm": "@ai-sdk/openai-compatible", + "name": "Ollama (Local)", + "options": { + "baseURL": "http://localhost:11434/v1" + }, + "models": { + "codex": { + "name": "CodeX (Local Persona)" + }, + "deepseek-coder:6.7b": { + "name": "DeepSeek Coder 6.7B" + }, + "qwen2.5-coder:1.5b": { + "name": "Qwen 2.5 Coder 1.5B" + } + } + } + }, + "plugin": [ + "opencode-antigravity-auth@latest" + ] +} +JSON_EOF + +echo "✅ [3/4] Config written: $CONFIG_FILE" +echo "" +echo "🔐 [4/4] Next step: authenticate with Google" +echo "" +echo "Run:" +echo " opencode auth login" +echo "" +echo "Then switch models in OpenCode with: /model" +echo "" +echo "⚠️ Note: Antigravity models are CLOUD (online)." +echo " Local Ollama models stay OFFLINE." +echo "" +echo "🎉 Done! CodeX is now HYBRID (local + cloud)." diff --git a/switch-model.sh b/switch-model.sh new file mode 100755 index 0000000..51982d1 --- /dev/null +++ b/switch-model.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# ============================================================ +# switch-model.sh — Switch CodeX active model +# Usage: ./switch-model.sh +# Example: ./switch-model.sh qwen-1.5b +# ============================================================ + +set -e + +MODELS_DIR="$HOME/codex/models" + +if [ -z "$1" ]; then + echo "Usage: $0 " + echo "" + echo "Available models:" + for f in "$MODELS_DIR"/*.Modelfile; do + [ -e "$f" ] || continue + basename "$f" .Modelfile + done + exit 1 +fi + +MODEL="$1" +MODEL_FILE="$MODELS_DIR/$MODEL.Modelfile" + +if [ ! -f "$MODEL_FILE" ]; then + echo "❌ Model not found: $MODEL" + echo "Available models:" + for f in "$MODELS_DIR"/*.Modelfile; do + [ -e "$f" ] || continue + basename "$f" .Modelfile + done + exit 1 +fi + +echo "🔨 Building model: $MODEL..." +ollama create "codex-$MODEL" -f "$MODEL_FILE" + +echo "✅ Model built: codex-$MODEL" +echo "" +echo "To use it, update your OpenCode config:" +echo " Model: codex-$MODEL" +echo "" +echo "Or run directly:" +echo " ollama run codex-$MODEL"