blob: f1c27027461ad131f0bc055854f7a439061f25f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# Maintainer: Xavier Francisco <echo moc.liamg@ocsicnarf.n.reivax | rev>
_pkgname=claude-code-api
pkgname=$_pkgname-git
pkgver=r30.b0cc14c
pkgrel=1
pkgdesc="OpenAI-compatible API gateway for Claude Code CLI"
arch=('any')
url="https://github.com/codingworkflow/$_pkgname"
license=('GPL-3.0-or-later')
depends=(
'python>=3.11'
'python-fastapi'
'uvicorn'
'python-pydantic'
'python-pydantic-settings'
'python-httpx'
'python-aiofiles'
'python-structlog'
'python-multipart'
'python-sqlalchemy'
'python-greenlet'
'python-aiosqlite'
'python-alembic'
'python-passlib'
'python-jose'
'python-dotenv'
'python-openai'
)
makedepends=('git' 'python-build' 'python-installer' 'python-setuptools' 'python-wheel')
provides=("$_pkgname")
conflicts=("$_pkgname")
source=("$_pkgname::git+https://github.com/codingworkflow/$_pkgname.git")
sha256sums=('SKIP')
pkgver() {
cd "$_pkgname"
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}
build() {
cd "$_pkgname"
python -m build --wheel --no-isolation
}
package() {
cd "$_pkgname"
python -m installer --destdir="$pkgdir" dist/*.whl
install -Dm644 LICENCE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
# Replace entry point with XDG-compliant wrapper
install -Dm755 /dev/stdin "$pkgdir/usr/bin/$_pkgname" <<'WRAPPER'
#!/bin/bash
# XDG-compliant wrapper for claude-code-api
: "${XDG_CONFIG_HOME:=$HOME/.config}"
: "${XDG_DATA_HOME:=$HOME/.local/share}"
: "${XDG_STATE_HOME:=$HOME/.local/state}"
_conf="$XDG_CONFIG_HOME/claude-code-api"
_data="$XDG_DATA_HOME/claude-code-api"
_state="$XDG_STATE_HOME/claude-code-api"
mkdir -p "$_data" "$_state/sessions" "$_state/logs"
: "${CLAUDE_CODE_API_ENV_FILE:=$_conf/env}"
: "${DATABASE_URL:=sqlite:///$_data/claude_api.db}"
: "${PROJECT_ROOT:=$_data/projects}"
: "${SESSION_MAP_PATH:=$_state/sessions/session_map.json}"
: "${LOG_FILE_PATH:=$_state/logs/claude-code-api.log}"
export CLAUDE_CODE_API_ENV_FILE DATABASE_URL PROJECT_ROOT SESSION_MAP_PATH LOG_FILE_PATH
exec python -m uvicorn claude_code_api.main:app \
--host "${HOST:-0.0.0.0}" \
--port "${PORT:-8000}" \
"$@"
WRAPPER
}
|