@@ -156,18 +156,18 @@ release:
156156 tokenizer completion fish > ~/.config/fish/completions/tokenizer.fish
157157 ```
158158
159- # Homebrew tap configuration
160- brews :
159+ # Homebrew cask configuration (new approach for pre-built binaries)
160+ homebrew_casks :
161161 - repository :
162162 owner : agentstation
163163 name : homebrew-tap
164164 token : " {{ .Env.HOMEBREW_TAP_TOKEN }}"
165165
166- # Formula name
166+ # Cask name
167167 name : tokenizer
168168
169- # Directory inside the repository
170- directory : Formula
169+ # Directory inside the repository (default is Casks)
170+ directory : Casks
171171
172172 # Git commit information
173173 commit_author :
@@ -185,85 +185,37 @@ brews:
185185 # License
186186 license : " MIT"
187187
188- # Skip upload if version exists
189- skip_upload : false
190-
191- # Use pre-built binaries (bottles) instead of building from source
192- download_strategy : CurlDownloadStrategy
188+ # Binary name (extracted from archive)
189+ binary : tokenizer
193190
194- # Dependencies
195- dependencies :
196- - name : go
197- type : build
198- version : " 1.24"
191+ # Conflicts with old formula (for migration)
192+ conflicts :
193+ - formula : tokenizer
199194
200- # Custom install block
201- install : |
202- if build.bottle?
203- bin.install "tokenizer"
204- else
205- # Build from source with version information
206- # Note: buildDate is the actual build time (now), not the commit date
207- ldflags = %W[
208- -s -w
209- -X main.version=#{version}
210- -X main.commit={{ .ShortCommit }}
211- -X main.buildDate=#{Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ")}
212- -X main.goVersion=#{Formula["go"].version}
213- -X main.builtBy=homebrew
214- ]
215- system "go", "build", *std_go_args(ldflags: ldflags), "./cmd/tokenizer"
216- end
217-
218- # Install documentation
219- doc.install "README.md", "LICENSE", "CLAUDE.md"
220- doc.install "llama3/README.md" => "llama3-README.md"
221- doc.install "llama3/IMPLEMENTATION.md" => "llama3-IMPLEMENTATION.md"
222-
223- # Install examples if they exist
224- if Dir.exist?("examples")
225- pkgshare.install "examples"
226- end
195+ # Post-install hook for unsigned binaries (macOS)
196+ hooks :
197+ post :
198+ install : |
199+ if system_command("/usr/bin/xattr", args: ["-h"]).exit_status == 0
200+ system_command "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "#{staged_path}/tokenizer"], sudo: false
201+ end
227202
228- # Test block
229- test : |
230- # Test version command
231- output = shell_output("#{bin}/tokenizer version")
232- assert_match version.to_s, output
233- assert_match "commit:", output
234- assert_match "built:", output
235- assert_match "go version:", output
236-
237- # Test help output
238- assert_match "Usage:", shell_output("#{bin}/tokenizer --help")
239- assert_match "Available Commands:", shell_output("#{bin}/tokenizer --help")
240-
241- # Test llama3 subcommand
242- assert_match "llama3", shell_output("#{bin}/tokenizer --help")
243- assert_match "encode", shell_output("#{bin}/tokenizer llama3 --help")
244-
245- # Test encoding
246- output = shell_output("#{bin}/tokenizer llama3 encode 'Hello, world!'")
247- assert_match "128000", output # begin_of_text token
248- assert_match "9906", output # "Hello" token
249- assert_match "128001", output # end_of_text token
250-
251- # Test decoding
252- output = shell_output("#{bin}/tokenizer llama3 decode 128000 9906 11 1917 0 128001")
253- assert_match "Hello", output
254- assert_match "world", output
255-
256- # Test info command
257- output = shell_output("#{bin}/tokenizer llama3 info")
258- assert_match "Vocabulary Size: 128256", output
259- assert_match "Regular Tokens: 128000", output
260- assert_match "Special Tokens: 256", output
261-
262- # Test piping
263- output = pipe_output("#{bin}/tokenizer llama3 encode", "Test input")
264- assert_match "128000", output # begin_of_text token
203+ # Shell completions
204+ completions :
205+ bash :
206+ completion : |
207+ output = Utils.safe_popen_read("#{staged_path}/tokenizer", "completion", "bash")
208+ (bash_completion/"tokenizer").write output
209+ zsh :
210+ completion : |
211+ output = Utils.safe_popen_read("#{staged_path}/tokenizer", "completion", "zsh")
212+ (zsh_completion/"_tokenizer").write output
213+ fish :
214+ completion : |
215+ output = Utils.safe_popen_read("#{staged_path}/tokenizer", "completion", "fish")
216+ (fish_completion/"tokenizer.fish").write output
265217
266- # Custom caveats (simplified from the manual formula)
218+ # Custom caveats
267219 caveats : |
268220 Tokenizer has been installed! 🚀
269221
@@ -273,6 +225,11 @@ brews:
273225 tokenizer llama3 info # Show tokenizer info
274226 tokenizer --help # Show all commands
275227
228+ Shell completions have been installed to:
229+ Bash: #{HOMEBREW_PREFIX}/etc/bash_completion.d
230+ Zsh: #{HOMEBREW_PREFIX}/share/zsh/site-functions
231+ Fish: #{HOMEBREW_PREFIX}/share/fish/vendor_completions.d
232+
276233 Documentation: https://github.com/agentstation/tokenizer
277234
278235# Docker image configuration
0 commit comments