summaryrefslogtreecommitdiffhomepage
path: root/README.md
diff options
context:
space:
mode:
authorKujtim Hoxha <[email protected]>2025-04-21 19:59:35 +0200
committerGitHub <[email protected]>2025-04-21 19:59:35 +0200
commitf33dff87725764af0b675b5e5b2e011b21c14c90 (patch)
tree4fe2c022305f13775f2cab3cdd80cd808259765b /README.md
parent6b1c64bcc75b89c530294b6a2d4404682b435d56 (diff)
parent3a6a26981a8074b6ab0eaadb520db986e04799ff (diff)
downloadopencode-f33dff87725764af0b675b5e5b2e011b21c14c90.tar.gz
opencode-f33dff87725764af0b675b5e5b2e011b21c14c90.zip
Merge pull request #27 from kujtimiihoxha/opencode
OpenCode - Initial Implementation
Diffstat (limited to 'README.md')
-rw-r--r--README.md357
1 files changed, 305 insertions, 52 deletions
diff --git a/README.md b/README.md
index 3c8df7345..145a881f5 100644
--- a/README.md
+++ b/README.md
@@ -1,83 +1,244 @@
-# TermAI
+# 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.
-[![TermAI Demo](https://asciinema.org/a/dtc4nJyGSZX79HRUmFLY3gmoy.svg)](https://asciinema.org/a/dtc4nJyGSZX79HRUmFLY3gmoy)
-
## Overview
-TermAI 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.
+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
+- **Multiple AI Providers**: Support for OpenAI, Anthropic Claude, Google Gemini, AWS Bedrock, and Groq
- **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
+- **Vim-like Editor**: Integrated editor with text input capabilities
- **Persistent Storage**: SQLite database for storing conversations and sessions
+- **LSP Integration**: Language Server Protocol support for code intelligence
+- **File Change Tracking**: Track and visualize file changes during sessions
+- **External Editor Support**: Open your preferred editor for composing messages
## Installation
```bash
# Coming soon
-go install github.com/kujtimiihoxha/termai@latest
+go install github.com/kujtimiihoxha/opencode@latest
```
## Configuration
-TermAI looks for configuration in the following locations:
+OpenCode looks for configuration in the following locations:
+
+- `$HOME/.opencode.json`
+- `$XDG_CONFIG_HOME/opencode/.opencode.json`
+- `./.opencode.json` (local directory)
+
+### Environment Variables
+
+You can configure OpenCode using environment variables:
+
+| Environment Variable | Purpose |
+| ----------------------- | ------------------------ |
+| `ANTHROPIC_API_KEY` | For Claude models |
+| `OPENAI_API_KEY` | For OpenAI models |
+| `GEMINI_API_KEY` | For Google Gemini models |
+| `GROQ_API_KEY` | For Groq models |
+| `AWS_ACCESS_KEY_ID` | For AWS Bedrock (Claude) |
+| `AWS_SECRET_ACCESS_KEY` | For AWS Bedrock (Claude) |
+| `AWS_REGION` | For AWS Bedrock (Claude) |
+
+### Configuration File Structure
+
+```json
+{
+ "data": {
+ "directory": ".opencode"
+ },
+ "providers": {
+ "openai": {
+ "apiKey": "your-api-key",
+ "disabled": false
+ },
+ "anthropic": {
+ "apiKey": "your-api-key",
+ "disabled": false
+ }
+ },
+ "agents": {
+ "coder": {
+ "model": "claude-3.7-sonnet",
+ "maxTokens": 5000
+ },
+ "task": {
+ "model": "claude-3.7-sonnet",
+ "maxTokens": 5000
+ },
+ "title": {
+ "model": "claude-3.7-sonnet",
+ "maxTokens": 80
+ }
+ },
+ "mcpServers": {
+ "example": {
+ "type": "stdio",
+ "command": "path/to/mcp-server",
+ "env": [],
+ "args": []
+ }
+ },
+ "lsp": {
+ "go": {
+ "disabled": false,
+ "command": "gopls"
+ }
+ },
+ "debug": false,
+ "debugLSP": false
+}
+```
-- `$HOME/.termai.json`
-- `$XDG_CONFIG_HOME/termai/.termai.json`
-- `./.termai.json` (local directory)
+## Supported AI Models
-You can also use environment variables:
+OpenCode supports a variety of AI models from different providers:
-- `ANTHROPIC_API_KEY`: For Claude models
-- `OPENAI_API_KEY`: For OpenAI models
-- `GEMINI_API_KEY`: For Google Gemini models
+### OpenAI
-## Usage
+- GPT-4.1 family (gpt-4.1, gpt-4.1-mini, gpt-4.1-nano)
+- GPT-4.5 Preview
+- GPT-4o family (gpt-4o, gpt-4o-mini)
+- O1 family (o1, o1-pro, o1-mini)
+- O3 family (o3, o3-mini)
+- O4 Mini
-```bash
-# Start TermAI
-termai
+### Anthropic
-# Start with debug logging
-termai -d
-```
+- Claude 3.5 Sonnet
+- Claude 3.5 Haiku
+- Claude 3.7 Sonnet
+- Claude 3 Haiku
+- Claude 3 Opus
+
+### Google
+
+- Gemini 2.5
+- Gemini 2.5 Flash
+- Gemini 2.0 Flash
+- Gemini 2.0 Flash Lite
-### Keyboard Shortcuts
+### AWS Bedrock
-#### 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
+- Claude 3.7 Sonnet
-#### Session Management
-- `N`: Create new session
-- `Enter` or `Space`: Select session (in sessions list)
+## Usage
+
+```bash
+# Start OpenCode
+opencode
+
+# Start with debug logging
+opencode -d
-#### 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)
+# Start with a specific working directory
+opencode -c /path/to/project
+```
-#### Navigation
-- Arrow keys: Navigate through lists and content
-- Page Up/Down: Scroll through content
+## Command-line Flags
+
+| Flag | Short | Description |
+| --------- | ----- | ----------------------------- |
+| `--help` | `-h` | Display help information |
+| `--debug` | `-d` | Enable debug mode |
+| `--cwd` | `-c` | Set current working directory |
+
+## Keyboard Shortcuts
+
+### Global Shortcuts
+
+| Shortcut | Action |
+| -------- | ------------------------------------------------------- |
+| `Ctrl+C` | Quit application |
+| `Ctrl+?` | Toggle help dialog |
+| `?` | Toggle help dialog (when not in editing mode) |
+| `Ctrl+L` | View logs |
+| `Ctrl+A` | Switch session |
+| `Ctrl+K` | Command dialog |
+| `Esc` | Close current overlay/dialog or return to previous mode |
+
+### Chat Page Shortcuts
+
+| Shortcut | Action |
+| -------- | --------------------------------------- |
+| `Ctrl+N` | Create new session |
+| `Ctrl+X` | Cancel current operation/generation |
+| `i` | Focus editor (when not in writing mode) |
+| `Esc` | Exit writing mode and focus messages |
+
+### Editor Shortcuts
+
+| Shortcut | Action |
+| ------------------- | ----------------------------------------- |
+| `Ctrl+S` | Send message (when editor is focused) |
+| `Enter` or `Ctrl+S` | Send message (when editor is not focused) |
+| `Ctrl+E` | Open external editor |
+| `Esc` | Blur editor and focus messages |
+
+### Session Dialog Shortcuts
+
+| Shortcut | Action |
+| ---------- | ---------------- |
+| `↑` or `k` | Previous session |
+| `↓` or `j` | Next session |
+| `Enter` | Select session |
+| `Esc` | Close dialog |
+
+### Permission Dialog Shortcuts
+
+| Shortcut | Action |
+| ----------------------- | ---------------------------- |
+| `←` or `left` | Switch options left |
+| `→` or `right` or `tab` | Switch options right |
+| `Enter` or `space` | Confirm selection |
+| `a` | Allow permission |
+| `A` | Allow permission for session |
+| `d` | Deny permission |
+
+### Logs Page Shortcuts
+
+| Shortcut | Action |
+| ------------------ | ------------------- |
+| `Backspace` or `q` | Return to chat page |
+
+## AI Assistant Tools
+
+OpenCode's AI assistant has access to various tools to help with coding tasks:
+
+### File and Code Tools
+
+| Tool | Description | Parameters |
+| ------------- | --------------------------- | ---------------------------------------------------------------------------------------- |
+| `glob` | Find files by pattern | `pattern` (required), `path` (optional) |
+| `grep` | Search file contents | `pattern` (required), `path` (optional), `include` (optional), `literal_text` (optional) |
+| `ls` | List directory contents | `path` (optional), `ignore` (optional array of patterns) |
+| `view` | View file contents | `file_path` (required), `offset` (optional), `limit` (optional) |
+| `write` | Write to files | `file_path` (required), `content` (required) |
+| `edit` | Edit files | Various parameters for file editing |
+| `patch` | Apply patches to files | `file_path` (required), `diff` (required) |
+| `diagnostics` | Get diagnostics information | `file_path` (optional) |
+
+### Other Tools
+
+| Tool | Description | Parameters |
+| ------------- | -------------------------------------- | ----------------------------------------------------------------------------------------- |
+| `bash` | Execute shell commands | `command` (required), `timeout` (optional) |
+| `fetch` | Fetch data from URLs | `url` (required), `format` (required), `timeout` (optional) |
+| `sourcegraph` | Search code across public repositories | `query` (required), `count` (optional), `context_window` (optional), `timeout` (optional) |
+| `agent` | Run sub-tasks with the AI agent | `prompt` (required) |
## Architecture
-TermAI is built with a modular architecture:
+OpenCode is built with a modular architecture:
- **cmd**: Command-line interface using Cobra
- **internal/app**: Core application services
@@ -88,37 +249,129 @@ TermAI is built with a modular architecture:
- **internal/logging**: Logging infrastructure
- **internal/message**: Message handling
- **internal/session**: Session management
+- **internal/lsp**: Language Server Protocol integration
+
+## MCP (Model Context Protocol)
+
+OpenCode implements the Model Context Protocol (MCP) to extend its capabilities through external tools. MCP provides a standardized way for the AI assistant to interact with external services and tools.
+
+### MCP Features
+
+- **External Tool Integration**: Connect to external tools and services via a standardized protocol
+- **Tool Discovery**: Automatically discover available tools from MCP servers
+- **Multiple Connection Types**:
+ - **Stdio**: Communicate with tools via standard input/output
+ - **SSE**: Communicate with tools via Server-Sent Events
+- **Security**: Permission system for controlling access to MCP tools
+
+### Configuring MCP Servers
+
+MCP servers are defined in the configuration file under the `mcpServers` section:
+
+```json
+{
+ "mcpServers": {
+ "example": {
+ "type": "stdio",
+ "command": "path/to/mcp-server",
+ "env": [],
+ "args": []
+ },
+ "web-example": {
+ "type": "sse",
+ "url": "https://example.com/mcp",
+ "headers": {
+ "Authorization": "Bearer token"
+ }
+ }
+ }
+}
+```
+
+### MCP Tool Usage
+
+Once configured, MCP tools are automatically available to the AI assistant alongside built-in tools. They follow the same permission model as other tools, requiring user approval before execution.
+
+## LSP (Language Server Protocol)
+
+OpenCode integrates with Language Server Protocol to provide code intelligence features across multiple programming languages.
+
+### LSP Features
+
+- **Multi-language Support**: Connect to language servers for different programming languages
+- **Diagnostics**: Receive error checking and linting information
+- **File Watching**: Automatically notify language servers of file changes
+
+### Configuring LSP
+
+Language servers are configured in the configuration file under the `lsp` section:
+
+```json
+{
+ "lsp": {
+ "go": {
+ "disabled": false,
+ "command": "gopls"
+ },
+ "typescript": {
+ "disabled": false,
+ "command": "typescript-language-server",
+ "args": ["--stdio"]
+ }
+ }
+}
+```
+
+### LSP Integration with AI
+
+The AI assistant can access LSP features through the `diagnostics` tool, allowing it to:
+
+- Check for errors in your code
+- Suggest fixes based on diagnostics
+
+While the LSP client implementation supports the full LSP protocol (including completions, hover, definition, etc.), currently only diagnostics are exposed to the AI assistant.
## Development
### Prerequisites
-- Go 1.23.5 or higher
+- Go 1.24.0 or higher
### Building from Source
```bash
# Clone the repository
-git clone https://github.com/kujtimiihoxha/termai.git
-cd termai
+git clone https://github.com/kujtimiihoxha/opencode.git
+cd opencode
# Build
-go build -o termai
+go build -o opencode
# Run
-./termai
+./opencode
```
## Acknowledgments
-TermAI builds upon the work of several open source projects and developers:
+OpenCode gratefully acknowledges the contributions and support from these key individuals:
+
+- [@isaacphi](https://github.com/isaacphi) - For the [mcp-language-server](https://github.com/isaacphi/mcp-language-server) project which provided the foundation for our LSP client implementation
+- [@adamdottv](https://github.com/adamdottv) - For the design direction and UI/UX architecture
-- [@isaacphi](https://github.com/isaacphi) - LSP client implementation
+Special thanks to the broader open source community whose tools and libraries have made this project possible.
## License
-[License information coming soon]
+OpenCode is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## Contributing
-[Contribution guidelines coming soon]
+Contributions are welcome! Here's how you can contribute:
+
+1. Fork the repository
+2. Create a feature branch (`git checkout -b feature/amazing-feature`)
+3. Commit your changes (`git commit -m 'Add some amazing feature'`)
+4. Push to the branch (`git push origin feature/amazing-feature`)
+5. Open a Pull Request
+
+Please make sure to update tests as appropriate and follow the existing code style.