# AbysiusCodium

A custom, releasable VSCodium distribution built from Microsoft's open-source VS Code repository, bundled with the **Abysius AI** extension for intelligent inline code completions and an embedded AI chat interface.

## Features

- **Inline Code Completions**: Ghost-text suggestions powered by Abysius AI models as you type
- **AI Chat Panel**: Conversational assistant integrated directly into the editor sidebar
- **Privacy-First**: Built on VSCodium — no Microsoft telemetry, no proprietary licensing
- **Custom Branding**: Fully branded as Abysius Codium with its own identity
- **Cross-Platform**: Builds for Linux, macOS, and Windows (x64, ARM64, ARM HF)
- **OSS Extension Marketplace**: Uses [Open VSX](https://open-vsx.org/) by default

## Project Structure

```
AbysiusCodium/
|-- .github/workflows/       # CI/CD pipelines (GitHub Actions)
|-- build/
|   |-- build.sh             # Main build script for VSCodium binaries
|   |-- dev-setup.sh         # Local extension dev environment setup
|-- extensions/
|   |-- abysius-ai/          # The Abysius AI VS Code extension
|       |-- src/
|       |   |-- extension.ts         # Main activation entry point
|       |   |-- api.ts               # Abysius API client (inline + chat)
|       |   |-- inlineCompletion.ts  # Ghost-text completion provider
|       |   |-- chatPanel.ts         # Webview chat panel provider
|       |-- assets/
|       |   |-- chat.css             # Chat UI styles
|       |   |-- chat.js              # Chat UI logic (webview)
|       |-- package.json             # Extension manifest
|       |-- tsconfig.json            # TypeScript config
|-- patches/                 # Patches applied to vscode source
|-- product.json             # Abysius branding & built-in extensions config
|-- package.json             # Root project scripts
|-- README.md
```

## Quick Start

### Prerequisites

- Node.js 20+ (use [nvm](https://github.com/nvm-sh/nvm) or [fnm](https://github.com/Schniz/fnm))
- Git
- Platform-specific build tools (see below)

### Linux Build

```bash
# Install deps (Ubuntu/Debian)
sudo apt-get install libx11-dev libxkbfile-dev libsecret-1-dev fakeroot rpm

# Clone and build
git clone https://github.com/AbysiusAI/AbysiusCodium.git
cd AbysiusCodium
./build/build.sh --platform linux --arch x64
```

### macOS Build

```bash
# Xcode Command Line Tools required
xcode-select --install

# Build
git clone https://github.com/AbysiusAI/AbysiusCodium.git
cd AbysiusCodium
./build/build.sh --platform darwin --arch arm64
```

### Windows Build

```powershell
# From Git Bash or WSL
git clone https://github.com/AbysiusAI/AbysiusCodium.git
cd AbysiusCodium
bash build/build.sh --platform win32 --arch x64
```

### Extension-Only Development

To work on just the Abysius AI extension without building the full editor:

```bash
cd AbysiusCodium
./build/dev-setup.sh
```

This symlinks the extension into your local VS Code / VSCodium installation for live testing.

## Abysius AI Extension

### Inline Completions

- Triggered automatically as you type (debounced, configurable delay)
- Accept full completion with **Tab**
- Accept word-by-word with **Ctrl+Right** / **Cmd+Right**
- Reject with **Escape**
- Manual trigger with **Ctrl+Space** / **Cmd+Space**

### Chat Interface

- Open from the Activity Bar or via Command Palette (`Abysius: Open Chat`)
- Streaming responses in real-time
- Code blocks have **Copy** and **Insert** actions
- Context-aware: knows your current file language, selection, and cursor position

### Configuration

| Setting | Default | Description |
|---------|---------|-------------|
| `abysius.enableInlineCompletions` | `true` | Toggle ghost-text suggestions |
| `abysius.inlineCompletionDelay` | `300` | MS delay before requesting completion |
| `abysius.inlineCompletionMaxLength` | `200` | Max chars in a suggestion |
| `abysius.chatEndpoint` | `https://api.abysius.ai/v1/chat` | Chat API endpoint |
| `abysius.inlineEndpoint` | `https://api.abysius.ai/v1/inline` | Inline completion endpoint |
| `abysius.apiKey` | `""` | Your Abysius API key |
| `abysius.model` | `abysius-coder` | Model selection (coder/chat/fast) |
| `abysius.showInlineDiff` | `true` | Highlight diff in completions |
| `abysius.telemetry` | `false` | Anonymous usage telemetry |

## Architecture

### How It Works

1. **Build**: `build.sh` clones the VS Code upstream repo at the specified tag
2. **Patch**: De-branding patches are applied to remove Microsoft-specific code
3. **Inject**: `product.json` is copied in, defining Abysius branding and built-in extensions
4. **Bundle**: The `abysius-ai` extension is compiled and installed as a built-in extension
5. **Compile**: VS Code's standard build pipeline produces platform-specific binaries
6. **Package**: OS-specific packages (.tar.gz, .deb, .rpm, .dmg, .zip, .exe) are created

### Extension API Design

The extension uses four VS Code API surfaces:

- **`InlineCompletionItemProvider`**: Provides ghost-text suggestions via `provideInlineCompletionItems`
- **`WebviewViewProvider`**: Hosts the chat UI in a sidebar panel
- **Chat Participants**: Uses the `chatParticipant` API proposal for `@-mention` support
- **Language Model API**: Direct programmatic access to models for custom features

The API client (`src/api.ts`) supports both streaming (chat) and request/response (inline) patterns. Endpoints are configurable so you can point to self-hosted or third-party model backends.

## Releasing

1. Tag a release: `git tag -a v1.0.0 -m "Release v1.0.0"`
2. Push tags: `git push origin v1.0.0`
3. GitHub Actions builds for all platforms and creates a draft release
4. Review the draft release, add notes, publish

## Development Scripts

```bash
# Watch extension TypeScript for changes
npm run dev:ext

# Build extension once
npm run build:ext

# Package extension as .vsix
npm run package:ext

# Build full editor for current platform
npm run build:linux   # or build:darwin / build:win32

# Clean all build artifacts
npm run clean

# Lint extension
npm run lint:ext
```

## Customizing the AI Backend

By default, the extension points to `https://api.abysius.ai`. To use your own backend:

1. Update `abysius.chatEndpoint` and `abysius.inlineEndpoint` in settings
2. Your backend should accept OpenAI-compatible request/response formats:

   **Inline Endpoint** (`POST /v1/inline`):
   ```json
   {
     "prompt": "code before cursor",
     "suffix": "code after cursor",
     "language": "typescript",
     "filename": "test.ts",
     "model": "your-model",
     "max_tokens": 200
   }
   ```
   Response:
   ```json
   { "completion": "suggested code here", "finish_reason": "stop" }
   ```

   **Chat Endpoint** (`POST /v1/chat`):
   OpenAI-compatible chat completions with `stream: true/false` support.

## License

MIT — see [LICENSE](./LICENSE)

## Acknowledgments

- Built on [VSCodium](https://vscodium.com/) and Microsoft's [vscode](https://github.com/microsoft/vscode) open-source project
- Inline completions leverage VS Code's `InlineCompletionItemProvider` API
- Chat UI built with VS Code Webview API
