c_josie_overlay

# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DESCRIPTION="The open source AI coding agent"
HOMEPAGE="https://opencode.ai https://github.com/anomalyco/opencode"

# OpenCode 2 is not published as GitHub release assets. It ships as
# per-platform npm packages; the tarball unpacks to package/bin/opencode.
SRC_URI="
	amd64? (
		https://registry.npmjs.org/@opencode/cli-linux-x64/-/cli-linux-x64-${PV}.tgz -> ${P}-amd64.tgz
	)
	arm64? (
		https://registry.npmjs.org/@opencode/cli-linux-arm64/-/cli-linux-arm64-${PV}.tgz -> ${P}-arm64.tgz
	)
"

S="${WORKDIR}/package"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~arm64"
RESTRICT="mirror strip"

QA_PREBUILT="usr/bin/opencode"

# opencode shells out to a system `rg` when one is on PATH, and only downloads
# its own copy at runtime when none is found.
RDEPEND="sys-apps/ripgrep"

src_install() {
	dobin bin/opencode
}