> ## Documentation Index
> Fetch the complete documentation index at: https://agentlogs.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenCode

> Set up AgentLogs with OpenCode for automatic transcript capture

# OpenCode Integration

OpenCode is an open-source AI coding assistant. AgentLogs provides integration with OpenCode for automatic transcript sync.

## Features

* **Automatic sync** - Transcripts are uploaded automatically when the session becomes idle
* **Git commit enhancement** - Automatically adds transcript links to git commit messages
* **Commit tracking** - Tracks which commits were made during each session

## Installation

### 1. Authentication

Run the following command in the terminal:

```bash theme={null}
npx agentlogs login agentlogs.ai
```

### 2. Configure OpenCode

Add the plugin to your `opencode.json` config file:

```json theme={null}
{
  "plugin": ["@agentlogs/opencode"]
}
```

The plugin will be automatically installed via npm on next OpenCode startup.

## How It Works

The plugin is lightweight and shells out to the AgentLogs CLI for all processing:

### Transcript Upload

When a session becomes idle, the plugin triggers the CLI to upload the transcript. Transcripts are automatically deduplicated server-side based on session ID.

### Git Commit Enhancement

When a git commit is detected:

1. The plugin intercepts the command before execution
2. Generates a stable transcript ID
3. Appends a transcript link to the commit message
4. Uploads a partial transcript so the link works immediately

**Example commit message:**

```
Fix authentication bug

🔮 View transcript: https://agentlogs.ai/s/abc123xyz
```

### Commit Tracking

After a git commit completes, the CLI extracts the commit SHA, branch, and title, then associates them with the transcript for easy navigation.

## Manual Upload

You can manually upload transcripts using the CLI:

```bash theme={null}
# Interactive picker to browse and upload any transcript
npx agentlogs upload

# Filter to only OpenCode transcripts
npx agentlogs upload --source opencode

# Upload a specific session by ID
npx agentlogs opencode upload <sessionId>
```

The interactive `upload` command discovers transcripts from all agents and lets you pick one to upload. Sessions are read from `~/.local/share/opencode/storage/`.
