From aef796dec1700a607ea27bb4db55e4f83ae88dde Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Tue, 2 Jun 2026 17:01:23 +0900 Subject: build(pkg): provision cs for native installs via a 'code-search' split package The Docker path (bin/up) already builds and bundles cs, but the native package path (bin/service install -> bin/build-pkg -> makepkg) did not, so search_code would have no cs binary under a systemd/s6 install and fall back to its 'cs not found' error. - packaging/PKGBUILD: add 'code-search' to the split pkgname array; add go+git to makedepends; build the patched, statically-linked cs (pinned v3.1.0 commit + docker/cs/luau-declarations.patch) in build(); install it to /usr/bin/cs via a dedicated package_code-search() (with the upstream MIT LICENSE). Pin kept in lockstep with the Dockerfiles. - bin/install-pkg: install code-search alongside dispatch + dispatch-systemd by default (and under --all). Verified: full run produces code-search-0.0.1-1-x86_64.pkg.tar.zst containing a working /usr/bin/cs (v3.1.0, static) with Luau declaration detection; the dispatch package no longer contains cs. Tests (598) + biome still pass. --- packaging/PKGBUILD | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'packaging') diff --git a/packaging/PKGBUILD b/packaging/PKGBUILD index a9a5b5c..4fd96d2 100644 --- a/packaging/PKGBUILD +++ b/packaging/PKGBUILD @@ -11,13 +11,17 @@ # bin/build-pkg # makepkg -fd in packaging/ pkgbase=dispatch -pkgname=('dispatch' 'dispatch-systemd' 'dispatch-s6') +pkgname=('dispatch' 'dispatch-systemd' 'dispatch-s6' 'code-search') pkgver=0.0.1 pkgrel=1 arch=('x86_64') url='https://github.com/anomalyco/dispatch' license=('MIT') -makedepends=('bun') +makedepends=('bun' 'go' 'git') + +# Pinned cs (code spelunker) commit (tag v3.1.0) built for the search_code tool. +# Kept in lockstep with the Docker build (see Dockerfile / Dockerfile.dev). +_cs_commit=697e0bf194bbc7a4a877e5170c70618989fc92e7 # All static files are read directly from ${_projectdir}/packaging/. We don't # use source=() because two of the s6 files share basenames (run, type), which # would collide inside ${srcdir}. @@ -56,6 +60,18 @@ build() { # Slim node_modules for runtime rm -rf node_modules bun install --frozen-lockfile --production + + # --- Build the patched `cs` code-search binary for the search_code tool --- + # Clone the pinned cs commit, apply the Luau declaration patch, and build a + # statically-linked binary. cs vendors its deps, so `go build -mod=vendor` + # needs no network beyond the clone. Mirrors the Docker cs-builder stage. + git clone https://github.com/boyter/cs.git "${srcdir}/cs-src" + cd "${srcdir}/cs-src" + git checkout "${_cs_commit}" + git apply "${_projectdir}/docker/cs/luau-declarations.patch" + CGO_ENABLED=0 GOFLAGS=-mod=vendor GOPATH="${srcdir}/gopath" GOCACHE="${srcdir}/gocache" \ + go build -ldflags="-s -w" -o "${srcdir}/cs" . + "${srcdir}/cs" --version } # ---------------------------------------------------------------------------- @@ -207,3 +223,26 @@ package_dispatch-s6() { install -Dm644 "${_packagingdir}/s6/dispatch-frontend-log/notification-fd" \ "${pkgdir}/etc/s6/sv/dispatch-frontend-log/notification-fd" } + + +# ---------------------------------------------------------------------------- +# code-search — patched `cs` (code spelunker) binary +# +# A standalone, relevance-ranked code search CLI (github.com/boyter/cs), built +# from a pinned commit with an added Luau declaration table (see +# docker/cs/luau-declarations.patch). Powers Dispatch's `search_code` agent +# tool, but is a self-contained binary usable on its own. Built once in build() +# and installed to /usr/bin/cs. +# ---------------------------------------------------------------------------- +package_code-search() { + pkgdesc='code spelunker (cs) — fast, relevance-ranked code search CLI (patched for Luau)' + depends=() + url='https://github.com/boyter/cs' + + install -Dm755 "${srcdir}/cs" "${pkgdir}/usr/bin/cs" + + if [ -f "${srcdir}/cs-src/LICENSE" ]; then + install -Dm644 "${srcdir}/cs-src/LICENSE" \ + "${pkgdir}/usr/share/licenses/code-search/LICENSE" + fi +} -- cgit v1.2.3