summaryrefslogtreecommitdiffhomepage
path: root/README.md
blob: 564284c7f138fdc54ebca74d64745730c496635e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# OpenCode

> **⚠️ Early Development Notice:** This project is in early development and is not yet ready for production use. Features may change, break, or be incomplete. Use at your own risk.

A powerful terminal-based AI assistant for developers, providing intelligent coding assistance directly in your terminal.

[![OpenCode Demo](https://asciinema.org/a/dtc4nJyGSZX79HRUmFLY3gmoy.svg)](https://asciinema.org/a/dtc4nJyGSZX79HRUmFLY3gmoy)

## Overview

OpenCode is a Go-based CLI application that brings AI assistance to your terminal. It provides a TUI (Terminal User Interface) for interacting with various AI models to help with coding tasks, debugging, and more.

## Features

- **Interactive TUI**: Built with [Bubble Tea](https://github.com/charmbracelet/bubbletea) for a smooth terminal experience
- **Multiple AI Providers**: Support for OpenAI, Anthropic Claude, and Google Gemini models
- **Session Management**: Save and manage multiple conversation sessions
- **Tool Integration**: AI can execute commands, search files, and modify code
- **Vim-like Editor**: Integrated editor with Vim keybindings for text input
- **Persistent Storage**: SQLite database for storing conversations and sessions

## Installation

```bash
# Coming soon
go install github.com/kujtimiihoxha/opencode@latest
```

## Configuration

OpenCode looks for configuration in the following locations:

- `$HOME/.opencode.json`
- `$XDG_CONFIG_HOME/opencode/.opencode.json`
- `./.opencode.json` (local directory)

You can also use environment variables:

- `ANTHROPIC_API_KEY`: For Claude models
- `OPENAI_API_KEY`: For OpenAI models
- `GEMINI_API_KEY`: For Google Gemini models

## Usage

```bash
# Start OpenCode
opencode

# Start with debug logging
opencode -d
```

### Keyboard Shortcuts

#### Global Shortcuts

- `?`: Toggle help panel
- `Ctrl+C` or `q`: Quit application
- `L`: View logs
- `Backspace`: Go back to previous page
- `Esc`: Close current view/dialog or return to normal mode

#### Session Management

- `N`: Create new session
- `Enter` or `Space`: Select session (in sessions list)

#### Editor Shortcuts (Vim-like)

- `i`: Enter insert mode
- `Esc`: Enter normal mode
- `v`: Enter visual mode
- `V`: Enter visual line mode
- `Enter`: Send message (in normal mode)
- `Ctrl+S`: Send message (in insert mode)

#### Navigation

- Arrow keys: Navigate through lists and content
- Page Up/Down: Scroll through content

## Architecture

OpenCode is built with a modular architecture:

- **cmd**: Command-line interface using Cobra
- **internal/app**: Core application services
- **internal/config**: Configuration management
- **internal/db**: Database operations and migrations
- **internal/llm**: LLM providers and tools integration
- **internal/tui**: Terminal UI components and layouts
- **internal/logging**: Logging infrastructure
- **internal/message**: Message handling
- **internal/session**: Session management

## Development

### Prerequisites

- Go 1.23.5 or higher

### Building from Source

```bash
# Clone the repository
git clone https://github.com/kujtimiihoxha/opencode.git
cd opencode

# Build the diff script first
go run cmd/diff/main.go

# Build
go build -o opencode

# Run
./opencode
```

## Acknowledgments

OpenCode builds upon the work of several open source projects and developers:

- [@isaacphi](https://github.com/isaacphi) - LSP client implementation

## License

[License information coming soon]

## Contributing

[Contribution guidelines coming soon]