summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: f3806f9ef34acf93792de161a0a899d5c458e2df (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# Maintainer: Youcef NAFA <youcef.nafa at gmail>
# Adapted from aider-chat AUR package by Auerhuhn (AlphaJack)

pkgbase=cecli
pkgname=(
  'cecli'
)
_gitpkgname=cecli
pkgver=0.99.12
pkgrel=1
pkgdesc='AI pair programming in your terminal - dwash96 fork of AIDER with TUI and MCP support'
arch=('any')
url='https://github.com/dwash96/cecli'
license=('Apache-2.0')
_depends=(
  'litellm'
  'python'
  'python-beautifulsoup4'
  'python-configargparse'
  'python-diff-match-patch'
  'python-diskcache'
  'python-dotenv'
  'python-flake8'
  'python-gitpython'
  'python-grep-ast'
  'python-httpx'
  'python-importlib_resources'
  'python-json5'
  'python-jsonschema'
  'python-mixpanel'
  'python-rustworkx'
  'python-numpy'
  'python-oslex'
  'python-packaging'
  'python-pathspec'
  'python-pexpect'
  'python-pillow'
  'python-posthog'
  'python-prompt_toolkit'
  'python-psutil'
  'python-pydub'
  'python-pygments'
  'python-pypandoc'
  'python-pyperclip'
  'python-requests'
  'python-rich'
  'python-shtab'
  'python-sounddevice'
  'python-soundfile'
  'python-tqdm'
  'python-tree-sitter'
  'python-watchfiles'
  'python-yaml'
  'python-pytokens'
  'python-truststore'
  'python-backoff'
  'python-socksio'
  'python-textual'
  'python-tomlkit'
  'python-xxhash'
)
makedepends=(
  'jekyll'
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-setuptools-scm'
  'python-wheel'
  'ruby-jekyll-feed'
  'ruby-jekyll-redirect-from'
  'ruby-jekyll-sitemap'
  'ruby-just-the-docs'
  'ruby-rake'
  'ruby-google-protobuf'
  # We need all runtime deps at build time to generate shell completions
  "${_depends[@]}"
)
checkdepends=(
  'chromium'
  'python-playwright'
  'python-pytest'
  'python-streamlit'
)

conflicts=()

source=(
  "${_gitpkgname}-${pkgver}.tar.gz::https://github.com/dwash96/cecli/archive/refs/tags/v${pkgver}.tar.gz"
  'archlinux_use_system_aur_notice.patch'
  'fix-build-from-tarball.patch'
)

sha512sums=('92b5c54a2e986df62b8485a0829af49c434327cb5b45aa40abc0c9f1dca229fd63a117bfe62d7c12128ed0dc8431caad79ef11d5b92e71bb6bb6828639b951bb'
            '81a4593740fe643bea577d011d427ad962b0f46a9b2121e0f757606af73a097343d31e356ab7d2ad4a9c83e8e713f5bafadba7284fd1a81b30aa75b231e86029'
            '523aed2029146d079de44db15152833a385ff331ca6bb19230cbc92d5abed1a33e4a132a34150ead213a19c7eb715c564b480c8943fd03216400aa6954770d8c')

prepare() {
  cd "${_gitpkgname}-${pkgver}"

  # Replace custom downloads with system packages
  # Replace auto-updater and optdepends installers with AUR notice
  patch -p1 < ../archlinux_use_system_aur_notice.patch

  # Fix issues with incomplete build from source tarball (needs upstreaming)
  patch -p1 < ../fix-build-from-tarball.patch

  # Update Gemfile to allow newer version of the dependencies,
  # add undeclared dependencies, and remove dependencies not
  # relevant to this package
  #
  # shellcheck disable=SC2016  # Not meant to expand
  sed -i \
    -e 's/"\([0-9]\)/">=\1/g' \
    -e '$agem "jekyll-feed"' \
    -e "s/\(^gem 'github-pages'.*\)/#\1/" \
    -e 's/\(^gem "html-proofer".*\)/#\1/' \
    cecli/website/Gemfile

  # Adjust base URL for documentation
  sed -i \
    -e 's|^\(url:\).*|\1 file:///usr/share/doc/'"${pkgbase}"'/html|' \
    cecli/website/_config.yml
  sed -i -E \
    -e 's|="(https://aider.chat)?/|="file:///usr/share/doc/'"${pkgbase}"'/html/|' \
    cecli/website/index.html
  find cecli/website -name '*.md' -exec sed -i -E \
    -e 's|]\((https://aider.chat)?/|](file:///usr/share/doc/'"${pkgbase}"'/html/|' \
    '{}' +

  # Include model-settings.yml in MANIFEST.in for wheel installation
  echo "include cecli/resources/model-settings.yml" >> MANIFEST.in
}

build() {
  cd "${_gitpkgname}-${pkgver}"
  echo >&2 'Building wheel'
  export SETUPTOOLS_SCM_PRETEND_VERSION="${pkgver}"
  python -m build --wheel --no-isolation

  echo >&2 'Generating shell completions'
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  mkdir -p completions/{bash,zsh}
  "test-env/bin/${_gitpkgname}" --shell-completions bash \
    > 'completions/bash/cecli'
  "test-env/bin/${_gitpkgname}" --shell-completions zsh \
    > 'completions/zsh/_cecli'

  #cd cecli/website

  #echo >&2 'Generating HTML documentation'
  #export JEKYLL_ENV=production
  #jekyll build --baseurl "file:///usr/share/doc/${pkgbase}/html/"
}

check() {
  cd "${_gitpkgname}-${pkgver}"

  # Use a clean environment (env -i) to avoid incurring unintended
  # LLM API usage costs.
  #
  # Additionally, skip the following tests:
  #
  # - tests for the `/help` feature, which require two system
  #   packages `python-llama-index-core` and `-embeddings-huggingface`
  #
  # - commit message tests, which require the current working dir
  #   to be part of a Git worktree
  #
  # - dependency tests for Bedrock and Vertex AI models:
  #   not applicable because dependencies have been replaced with
  #   optdepends
  #
  # - skip all failing tests for now, ObjectMock usage with await fails + dark mode + openai provider + llama_index + stream_Cache_Warning ..

  echo >&2 'Running unit tests'
  env -i PATH="${PATH}" python -m pytest \
    -k 'not test_get_commit_message and not TestHelp and not test_check_for_dependencies_ and not test_encodings_arg and not test_main_exit_calls_version_check and not test_mode_sets_code_theme and not test_env_file_variables and not test_verbose_mode_lists_env_vars and not test_list_models_includes_metadata_models and not test_list_models_includes_all_model_sources and not test_list_models_includes_openai_provider and not test_list_models_with_direct_resource_patch and not test_stream_cache_warning and not test_model_overrides_no_match_preserves_model_name and not test_scraper_print_error_not_called'

  echo >&2 'Testing the executable'
  test-env/bin/${_gitpkgname} --version > actual.txt
  if ! grep -qF "${_gitpkgname} ${pkgver}" actual.txt; then
    printf >&2 '%s\n' 'Unexpected test output:' '==='
    cat >&2 actual.txt
    printf >&2 '\n%s\n' '==='
    exit 1
  fi
}

# shellcheck disable=SC2128
package_cecli() {
  depends=("${_depends[@]}")
  optdepends=(
    'chromium: for web scraping'
    'python-babel: support for more locales'
    # Packages are yet to be written, see comment in `check()`
    # 'python-llama-index-embeddings-huggingface: to use the interactive `/help` feature'
    'python-playwright: for web scraping'
    'python-streamlit: for a graphical user interface'
  )

  cd "${_gitpkgname}-${pkgver}"

  echo >&2 'Packaging the wheel'
  python -I -m installer --destdir="${pkgdir}" dist/*.whl

  echo >&2 'Packaging the license'
  install -D -m 644 -t "${pkgdir}/usr/share/licenses/${pkgname}" \
    LICENSE.txt

  echo >&2 'Packaging shell completions'
  install -D -m 644 -t "${pkgdir}/usr/share/bash-completion/completions" \
    'completions/bash/cecli'
  install -D -m 644 -t "${pkgdir}/usr/share/zsh/site-functions" \
    'completions/zsh/_cecli'
}