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

# OpenCode

> Integrate Entire with OpenCode for AI coding session capture

OpenCode is an AI-powered terminal coding agent. Entire integrates with OpenCode via its plugin system, automatically capturing sessions and checkpoints. The OpenCode integration is in preview and may contain bugs.

## Prerequisites

* [Entire CLI installed](/cli/installation)
* [OpenCode](https://github.com/anomalyco/opencode) installed
* A Git repository with Entire enabled

## Enable

```bash theme={null}
entire agent add opencode
opencode
```

`entire agent add opencode` installs a TypeScript plugin that hooks into OpenCode's event system.

<AccordionGroup>
  <Accordion title="How it works">
    The plugin communicates with Entire via hooks:

    1. **Session Detection** — the plugin fires on `session.created` events.
    2. **Turn Tracking** — each user prompt triggers `turn-start`; when the agent goes idle, `turn-end` fires.
    3. **Transcript Export** — on `turn-end`, Entire calls `opencode export` to capture the full transcript.
    4. **Checkpoint Creation** — checkpoints are created based on your strategy.
    5. **Session Storage** — data saved to the `entire/checkpoints/v1` branch.
  </Accordion>

  <Accordion title="What gets captured">
    | Data         | Description                                     |
    | ------------ | ----------------------------------------------- |
    | Conversation | Full transcript of prompts and responses        |
    | File changes | Files modified via edit, write, and patch tools |
    | Tool calls   | Tool invocations with inputs and outputs        |
    | Token usage  | Input, output, reasoning, and cache tokens      |
    | Timestamps   | Session, message, and checkpoint timing         |
  </Accordion>

  <Accordion title="Features">
    **Rewind during sessions.** Use `entire checkpoint rewind` to restore to a previous checkpoint during or after an OpenCode session. When you rewind, Entire reimports the checkpoint-state transcript into OpenCode's database so you can continue seamlessly. See the [`rewind` command reference](/cli/commands#rewind) for full flag documentation.

    **Resume previous sessions.** Switch to a session's branch with `entire session resume <branch>`. The CLI restores the session log if needed and prints `opencode -s <session-id>`. See the [`resume` command reference](/cli/commands#resume) for full flag documentation.

    **Explain commits.** Inspect any commit or checkpoint with `entire checkpoint explain`. See the [`explain` command reference](/cli/commands#explain) for full flag documentation.

    **Mid-turn commits.** When OpenCode commits during a turn (before the turn ends), Entire captures a checkpoint for that commit. The transcript is fetched on-demand via `opencode export` so the checkpoint includes the latest agent activity.
  </Accordion>

  <Accordion title="Caveats and limitations">
    * The integration is in preview and may have rough edges.
    * Plugin requires Bun runtime (used by OpenCode's plugin system).
    * Session detection relies on OpenCode's event system.
    * Works best with the manual-commit strategy.
  </Accordion>

  <Accordion title="Best practices">
    **Use the manual-commit strategy.** For terminal AI tools like OpenCode:

    ```bash theme={null}
    entire agent add opencode
    ```

    **Commit when you've made meaningful progress:**

    ```bash theme={null}
    git add .
    git commit -m "Implement feature with OpenCode"
    ```
  </Accordion>

  <Accordion title="Example workflow">
    ```bash theme={null}
    # 1. Enable Entire with OpenCode
    cd my-project
    entire agent add opencode

    # 2. Start OpenCode
    opencode

    # 3. Work with OpenCode
    # Ask it to write code, make changes, etc.

    # 4. Rewind if needed
    entire checkpoint rewind

    # 5. Commit when ready
    git add .
    git commit -m "Add feature with OpenCode"

    # 6. Push to see on entire.io
    git push
    ```

    Your session is now visible on [entire.io](https://entire.io) with full context for code review.
  </Accordion>
</AccordionGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Session not detected">
    1. Ensure you're in an Entire-enabled repo: `entire status`
    2. Verify OpenCode is running from within the repository
    3. Check that the plugin is installed: look for the Entire plugin in your OpenCode config
    4. Check Git hooks are installed: `ls .git/hooks`
  </Accordion>

  <Accordion title="No checkpoints created">
    1. Checkpoints require file changes — ensure OpenCode is modifying files
    2. Check your strategy settings in `.entire/settings.json`
    3. Verify `opencode export` works: `opencode export <session-id>`
  </Accordion>

  <Accordion title="Transcript not captured">
    1. The plugin calls `opencode export` to fetch transcripts — ensure this command works
    2. Check that the `.opencode` directory exists in your repository
    3. Look for errors in the Entire hook output: run `entire hooks opencode turn-end` manually
  </Accordion>
</AccordionGroup>
