Files
kandev/Formula/kandev.rb
T
José Almeida d02441201f fix(homebrew): mirror upstream PR formula fixes (#972)
* fix(homebrew): mirror upstream PR fixes

Keep the in-repo reference formula in sync with what's actually
being submitted at Homebrew/homebrew-core#283241:

- Bump url + sha256 to v0.50.0 (the version the upstream PR pins)
- Strip *musl* paths from the web bundle before libexec.install
  (brew linkage --test flags musl-linked variants of sharp on
  glibc-only Linuxbrew)
- Set KANDEV_AGENT_STANDALONE_PORT to a free port in the test block
  so agentctl doesn't collide on the default 39429

* fix(homebrew): switch test poll to quiet_system + agentctl-only

Mirror fixes from upstream Homebrew/homebrew-core#283241:
- Switch the functional test to spawn libexec/bin/agentctl (pure-Go,
  no cgo+sqlite) instead of the full backend, sidestepping a Linux
  arm64 agentctl-launcher crash unique to brew test sandbox
- Use quiet_system instead of system for the curl poll. Formula#system
  raises BuildError on the first non-zero exit, which killed the
  retry loop before agentctl had time to bind the port

* fix(homebrew): swap functional test to agentctl CLI dispatch

Mirror upstream Homebrew/homebrew-core#283241 — Linux arm64 bottle CI
keeps timing out spawning agentctl as an HTTP server. The 'agentctl
kandev' subcommand exercises the same binary's boot + flag parser
+ CLI dispatcher path without binding any ports, which fits within
the sandbox constraints of brew test.

* fix(homebrew): build agentctl static (CGO_ENABLED=0)

Mirror upstream Homebrew/homebrew-core#283241 — agentctl was
segfaulting on Linuxbrew arm64 bottle CI. agentctl is pure-Go
(no cgo deps), so building it without cgo gives a static binary
that avoids whatever dynamic-linker issue is biting on that
platform. kandev still needs cgo for mattn/go-sqlite3.

* fix(homebrew): tighten musl-prune style + assertion

Mirror upstream Homebrew/homebrew-core#283241:
- Use bundle.glob(...) instead of Pathname.glob with string interp
- Drop the if p.directory? guard so bare musl .node files (if a
  future bundler version emits them) also get stripped — rm_r
  handles both shapes
- Spell out sharp / @swc/core / lightningcss in the comment
- Tighten the agentctl smoke check to an exact-string match

* fix(homebrew): guard musl prune against ENOENT race

bundle.glob returns parent dirs alongside the musl-named .node
files inside them. rm_r on the parent makes the child path vanish
before iteration reaches it, blowing up with Errno::ENOENT. Skip
paths that no longer exist.
2026-05-21 11:29:30 +01:00

83 lines
3.1 KiB
Ruby

class Kandev < Formula
desc "Manage tasks, orchestrate agents, review changes, and ship value"
homepage "https://github.com/kdlbs/kandev"
url "https://github.com/kdlbs/kandev/archive/refs/tags/v0.50.0.tar.gz"
sha256 "270d4c17f0cdd8b431e050f130dfee7d0f962149e3e0f50e149efec21a95954c"
license "AGPL-3.0-only"
livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
depends_on "go" => :build
depends_on "pnpm" => :build
depends_on "node"
uses_from_macos "rsync" => :build
uses_from_macos "sqlite"
def install
ENV["KANDEV_VERSION"] = version.to_s
system "pnpm", "-C", "apps", "install", "--frozen-lockfile"
system "pnpm", "-C", "apps", "--filter", "@kandev/web", "build"
system "./scripts/release/package-web.sh"
system "./scripts/release/package-cli.sh"
bundle = buildpath/"dist/kandev"
(bundle/"bin").mkpath
cd "apps/backend" do
# kandev backend needs cgo for mattn/go-sqlite3.
with_env(CGO_ENABLED: "1") do
system "go", "build",
*std_go_args(ldflags: "-s -w -X main.Version=#{version}",
output: bundle/"bin/kandev"),
"./cmd/kandev"
end
# agentctl is pure-Go; build it static to avoid a dynamic linker
# crash observed on Linuxbrew arm64 bottle CI.
with_env(CGO_ENABLED: "0") do
system "go", "build",
*std_go_args(ldflags: "-s -w", output: bundle/"bin/agentctl"),
"./cmd/agentctl"
end
end
system "./scripts/release/package-bundle.sh"
# The Next.js standalone tracer pulls platform-tagged native modules
# into the bundle, including musl-libc variants of sharp, @swc/core,
# and lightningcss that brew linkage --test flags on glibc-only
# Linuxbrew. Strip them — rm_r handles both directory trees (the
# current shape) and bare .node files (in case a future bundler
# version inlines them). The exist? guard handles the glob
# returning a parent dir and its musl-named children together —
# removing the parent makes the child paths vanish before we get
# to them.
bundle.glob("web/**/*musl*").each { |p| rm_r(p) if p.exist? }
libexec.install Dir[bundle/"*"]
(bin/"kandev").write_env_script libexec/"cli/bin/cli.js",
KANDEV_BUNDLE_DIR: libexec.to_s,
KANDEV_VERSION: version.to_s
end
test do
# Wrapper sanity: confirms write_env_script wired KANDEV_BUNDLE_DIR
# and the launcher reads the bundled package.json version.
assert_match version.to_s, shell_output("#{bin}/kandev --version")
# Functional test: exercise the agentctl sidecar's CLI subcommand
# dispatcher. Boots the Go binary, parses flags, dispatches to the
# kandev subcommand handler, and prints usage when called without
# arguments. Verifies the binary loads correctly across platforms
# without requiring HTTP listeners, port binds, or subprocesses —
# which can be problematic in sandboxed build environments.
output = shell_output("#{libexec}/bin/agentctl kandev 2>&1", 1)
assert_match "Usage: agentctl kandev", output
end
end