# Maintainer: ekhodzitsky <ekhodzitsky@gmail.com>
pkgname=omk
# pkgver is auto-synced on tag push by release.yml::update-packaging.
pkgver=0.4.0
pkgrel=1
pkgdesc="Multi-agent orchestration for Kimi CLI"
arch=('x86_64' 'aarch64')
url="https://github.com/ekhodzitsky/oh-my-kimi"
license=('MIT')
depends=()
makedepends=('cargo')
source=("$pkgname-$pkgver.tar.gz::https://github.com/ekhodzitsky/oh-my-kimi/archive/v$pkgver.tar.gz")
# `SKIP` here is a known gap: AUR consumes the GitHub *source* tarball, not
# the binary release assets, so release.yml cannot pre-populate this hash.
# Maintainers MUST run `updpkgsums` locally before submitting an AUR update
# so users get integrity-verified downloads.
sha256sums=('SKIP')

build() {
  cd "$pkgname-$pkgver"
  cargo build --release --locked
}

check() {
  cd "$pkgname-$pkgver"
  cargo test --locked
}

package() {
  cd "$pkgname-$pkgver"
  install -Dm755 "target/release/$pkgname" "$pkgdir/usr/bin/$pkgname"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
  
  # Shell completions
  install -Dm644 <(./target/release/$pkgname completions bash) "$pkgdir/usr/share/bash-completion/completions/$pkgname"
  install -Dm644 <(./target/release/$pkgname completions zsh) "$pkgdir/usr/share/zsh/site-functions/_$pkgname"
  install -Dm644 <(./target/release/$pkgname completions fish) "$pkgdir/usr/share/fish/vendor_completions.d/$pkgname.fish"
  
  # Man page
  install -Dm644 <(./target/release/$pkgname man) "$pkgdir/usr/share/man/man1/$pkgname.1"
}
