mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-18 15:28:48 +03:00
docs: improve installation guide
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
---
|
||||
import CodeBlock from "./CodeBlock.astro"
|
||||
|
||||
interface Props {
|
||||
id: string
|
||||
label: string
|
||||
tabs: Array<{
|
||||
label: string
|
||||
code: string
|
||||
}>
|
||||
}
|
||||
---
|
||||
|
||||
<div class="docs-code-tabs" data-code-tabs>
|
||||
<div class="docs-code-tabs-list" role="tablist" aria-label={Astro.props.label}>
|
||||
{
|
||||
Astro.props.tabs.map((tab, index) => (
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
id={`${Astro.props.id}-tab-${index}`}
|
||||
aria-controls={`${Astro.props.id}-panel-${index}`}
|
||||
aria-selected={index === 0 ? "true" : "false"}
|
||||
tabindex={index === 0 ? 0 : -1}
|
||||
data-code-tab
|
||||
>
|
||||
{tab.label}
|
||||
</button>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
{
|
||||
Astro.props.tabs.map((tab, index) => (
|
||||
<div
|
||||
role="tabpanel"
|
||||
id={`${Astro.props.id}-panel-${index}`}
|
||||
aria-labelledby={`${Astro.props.id}-tab-${index}`}
|
||||
hidden={index !== 0}
|
||||
data-code-panel
|
||||
>
|
||||
<CodeBlock code={tab.code} />
|
||||
</div>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const selectTab = (button: HTMLButtonElement) => {
|
||||
const tabs = button.closest<HTMLElement>("[data-code-tabs]")
|
||||
if (!tabs) return
|
||||
const buttons = [...tabs.querySelectorAll<HTMLButtonElement>("[data-code-tab]")]
|
||||
const panels = [...tabs.querySelectorAll<HTMLElement>("[data-code-panel]")]
|
||||
const selected = buttons.indexOf(button)
|
||||
buttons.forEach((item, index) => {
|
||||
item.setAttribute("aria-selected", String(index === selected))
|
||||
item.tabIndex = index === selected ? 0 : -1
|
||||
})
|
||||
panels.forEach((panel, index) => (panel.hidden = index !== selected))
|
||||
}
|
||||
|
||||
document.addEventListener("click", (event) => {
|
||||
if (!(event.target instanceof Element)) return
|
||||
const button = event.target.closest<HTMLButtonElement>("[data-code-tab]")
|
||||
if (!button) return
|
||||
selectTab(button)
|
||||
})
|
||||
|
||||
document.addEventListener("keydown", (event) => {
|
||||
if (!(event.target instanceof HTMLButtonElement) || !event.target.matches("[data-code-tab]")) return
|
||||
const tabs = event.target.closest<HTMLElement>("[data-code-tabs]")
|
||||
if (!tabs) return
|
||||
const buttons = [...tabs.querySelectorAll<HTMLButtonElement>("[data-code-tab]")]
|
||||
const selected = buttons.indexOf(event.target)
|
||||
const next =
|
||||
event.key === "Home"
|
||||
? buttons[0]
|
||||
: event.key === "End"
|
||||
? buttons.at(-1)
|
||||
: event.key === "ArrowRight"
|
||||
? buttons[(selected + 1) % buttons.length]
|
||||
: event.key === "ArrowLeft"
|
||||
? buttons[(selected - 1 + buttons.length) % buttons.length]
|
||||
: undefined
|
||||
if (!next) return
|
||||
event.preventDefault()
|
||||
selectTab(next)
|
||||
next.focus()
|
||||
})
|
||||
</script>
|
||||
@@ -4,6 +4,7 @@ import Callout from "./Callout.astro"
|
||||
import Card from "./Card.astro"
|
||||
import CardGroup from "./CardGroup.astro"
|
||||
import CodeBlock from "./CodeBlock.astro"
|
||||
import CodeTabs from "./CodeTabs.astro"
|
||||
import DocsLayout from "../layouts/DocsLayout.astro"
|
||||
|
||||
interface Props {
|
||||
@@ -21,5 +22,5 @@ const rendered = await render(entry)
|
||||
headings={rendered.headings}
|
||||
showTableOfContents={entry.data.tableOfContents !== false}
|
||||
>
|
||||
<rendered.Content components={{ Callout, Card, CardGroup, CodeBlock }} />
|
||||
<rendered.Content components={{ Callout, Card, CardGroup, CodeBlock, CodeTabs }} />
|
||||
</DocsLayout>
|
||||
|
||||
@@ -2,28 +2,64 @@
|
||||
title: "Intro"
|
||||
---
|
||||
|
||||
These docs describe OpenCode and its APIs, configuration, and plugin system.
|
||||
OpenCode is an open source AI coding agent. It’s available as a terminal-based interface, desktop app, or web app.
|
||||
|
||||
OpenCode installs and runs as `opencode`.
|
||||
|
||||
## Install
|
||||
## CLI
|
||||
|
||||
<div data-install-code>
|
||||
<CodeBlock
|
||||
code={`$ npm install -g @opencode/cli
|
||||
$ bun install -g --trust @opencode/cli
|
||||
$ pnpm add -g --allow-build=@opencode/cli @opencode/cli
|
||||
$ yarn global add @opencode/cli
|
||||
$ curl -fsSL https://opencode.ai/v2/install | bash`}
|
||||
/>
|
||||
</div>
|
||||
<CodeTabs
|
||||
id="install"
|
||||
label="Install method"
|
||||
tabs={[
|
||||
{ label: "curl", code: "curl -fsSL https://opencode.ai/v2/install | bash" },
|
||||
{ label: "homebrew", code: "brew install anomalyco/tap/opencode-v2" },
|
||||
{ label: "npm", code: "npm install -g @opencode/cli" },
|
||||
{ label: "bun", code: "bun install -g --trust @opencode/cli" },
|
||||
{ label: "pnpm", code: "pnpm add -g --allow-build=@opencode/cli @opencode/cli" },
|
||||
{ label: "yarn", code: "yarn global add @opencode/cli" },
|
||||
{ label: "aur", code: "paru -S opencode-beta" },
|
||||
]}
|
||||
/>
|
||||
|
||||
The npm package uses a trusted postinstall script to select the native `opencode` binary for your platform. The Bun and pnpm
|
||||
commands above explicitly allow that script to run.
|
||||
|
||||
Docker images use versioned tags, for example `ghcr.io/anomalyco/opencode:2.0.0`.
|
||||
Windows package managers are not supported.
|
||||
|
||||
Homebrew, AUR, Windows package managers, and standalone binaries are not supported.
|
||||
|
||||
Download a standalone CLI binary for your platform.
|
||||
|
||||
- **macOS:** [Apple silicon](https://opencode.ai/files/bin/2.0.6/opencode-darwin-arm64.zip) · [Intel](https://opencode.ai/files/bin/2.0.6/opencode-darwin-x64.zip) · [Intel (baseline)](https://opencode.ai/files/bin/2.0.6/opencode-darwin-x64-baseline.zip)
|
||||
- **Windows:** [ARM64](https://opencode.ai/files/bin/2.0.6/opencode-windows-arm64.zip) · [x64](https://opencode.ai/files/bin/2.0.6/opencode-windows-x64.zip) · [x64 (baseline)](https://opencode.ai/files/bin/2.0.6/opencode-windows-x64-baseline.zip)
|
||||
- **Linux (glibc):** [ARM64](https://opencode.ai/files/bin/2.0.6/opencode-linux-arm64.tar.gz) · [x64](https://opencode.ai/files/bin/2.0.6/opencode-linux-x64.tar.gz) · [x64 (baseline)](https://opencode.ai/files/bin/2.0.6/opencode-linux-x64-baseline.tar.gz)
|
||||
- **Linux (musl):** [ARM64](https://opencode.ai/files/bin/2.0.6/opencode-linux-arm64-musl.tar.gz) · [x64](https://opencode.ai/files/bin/2.0.6/opencode-linux-x64-musl.tar.gz) · [x64 (baseline)](https://opencode.ai/files/bin/2.0.6/opencode-linux-x64-baseline-musl.tar.gz)
|
||||
|
||||
## Desktop
|
||||
|
||||
Download the latest OpenCode Desktop build for your platform.
|
||||
|
||||
- **macOS:** [Apple silicon](https://opencode.ai/files/bin/2.0.6/opencode-desktop-mac-arm64.dmg) · [Intel](https://opencode.ai/files/bin/2.0.6/opencode-desktop-mac-x64.dmg)
|
||||
- **Windows:** [x64](https://opencode.ai/files/bin/2.0.6/opencode-desktop-win-x64.exe) · [ARM64](https://opencode.ai/files/bin/2.0.6/opencode-desktop-win-arm64.exe)
|
||||
- **Linux (.deb):** [x64](https://opencode.ai/files/bin/2.0.6/opencode-desktop-linux-amd64.deb) · [ARM64](https://opencode.ai/files/bin/2.0.6/opencode-desktop-linux-arm64.deb)
|
||||
- **Linux (.rpm):** [x64](https://opencode.ai/files/bin/2.0.6/opencode-desktop-linux-x86_64.rpm) · [ARM64](https://opencode.ai/files/bin/2.0.6/opencode-desktop-linux-aarch64.rpm)
|
||||
- **Linux (AppImage):** [x64](https://opencode.ai/files/bin/2.0.6/opencode-desktop-linux-x86_64.AppImage) · [ARM64](https://opencode.ai/files/bin/2.0.6/opencode-desktop-linux-arm64.AppImage)
|
||||
|
||||
|
||||
## Web
|
||||
|
||||
Access the OpenCode web interface with the `opencode pair` command.
|
||||
|
||||
```bash
|
||||
$ opencode pair
|
||||
|
||||
URLs http://127.0.0.1:49374
|
||||
Username opencode
|
||||
Password ********
|
||||
```
|
||||
|
||||
## Docker
|
||||
|
||||
Docker images use versioned tags, for example `ghcr.io/anomalyco/opencode:2.0.0`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1002,6 +1002,48 @@ main {
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.docs-code-tabs {
|
||||
margin-bottom: 1.5rem;
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.docs-code-tabs-list {
|
||||
display: flex;
|
||||
border-bottom: 1px solid var(--border);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.docs-code-tabs-list button {
|
||||
margin-bottom: -1px;
|
||||
padding: 0.5rem 0.875rem;
|
||||
flex-shrink: 0;
|
||||
cursor: pointer;
|
||||
border: 0;
|
||||
border-bottom: 1px solid transparent;
|
||||
background: transparent;
|
||||
color: var(--muted);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.docs-code-tabs-list button:hover,
|
||||
.docs-code-tabs-list button[aria-selected="true"] {
|
||||
color: var(--foreground);
|
||||
}
|
||||
|
||||
.docs-code-tabs-list button[aria-selected="true"] {
|
||||
border-bottom-color: var(--foreground);
|
||||
}
|
||||
|
||||
.docs-code-tabs-list button:focus-visible {
|
||||
outline: 1px solid var(--foreground);
|
||||
outline-offset: -3px;
|
||||
}
|
||||
|
||||
.docs-code-tabs .docs-code-block pre {
|
||||
margin: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.prose h1 button {
|
||||
display: inline-flex;
|
||||
padding: 0;
|
||||
|
||||
Reference in New Issue
Block a user