feat: macOS support (BSD date/stat, locale-safe rendering)#23
Conversation
Abstract date/stat over GNU vs BSD by probing behavior once (epoch_from_iso, file_mtime), so macOS works without coreutils. Pin LC_ALL=C so comma-decimal locales (e.g. pt_BR) render identically to the C-locale CI. install.sh accepts BSD date/stat; the npm CLI accepts darwin as a supported platform. Closes inbrace-tech#2
|
Suggested labels (couldn't self-apply from a fork): |
ropdias
left a comment
There was a problem hiding this comment.
Thanks for the really thorough work here, @xinnaider, excellent first contribution! 🙌
It cleanly implements #2: probing behavior instead of uname (so Homebrew
coreutils is picked up automatically), keeping the GNU branch verbatim so Linux
output is unchanged, and the LC_ALL=C pin is a great catch for comma-decimal
locales.
I reviewed and verified locally:
- ShellCheck
-s bashclean on bothtokenline.shandinstall.sh - Same fixture → identical rendered output vs
mainon Linux (the macOS
acceptance criterion)
One low-severity edge case I want to track separately: the BSD parse in
epoch_from_iso() uses a fixed %Y-%m-%dT%H:%M:%S mask, guaranteed for Claude
Code's .timestamp but unverified for Antigravity's .created_at. It degrades
gracefully (mtime fallback) and doesn't touch Linux, so I'm merging as-is and
opening a follow-up issue for it.
Approving, thank you again! 🚀
What
Adds macOS support, implementing the proposal in #2.
tokenline.shabstracts the GNU-only calls behind two helpers that branch on aone-time behavior probe (not
uname, so Homebrew coreutils is picked upautomatically):
epoch_from_iso()— GNUdate -dvs BSDdate -u -j -f "%Y-%m-%dT%H:%M:%S"(first 19 chars of the ISO string; transcript timestamps are UTC).
file_mtime()— GNUstat -c %Yvs BSDstat -f %m.On Linux the probe selects the GNU branch, which runs the original commands
verbatim — no behavior change.
It also pins
LC_ALL=C. A comma-decimal locale (e.g.pt_BR) otherwise makesawk/printfemit46,2kand reject dotted input, diverging from the C-localeCI.
LC_ALLis used (notLC_NUMERIC) because it wins when a user exportsLC_ALL. Output is ASCII/bytes, so this is safe.mapfilestill needs bash 4+, so macOS usersbrew install bash— documented inthe README and surfaced by
install.sh.Changes
tokenline.sh: GNU/BSD probe,epoch_from_iso,file_mtime,LC_ALL=C.install.sh:date/statchecks accept BSD (GNU-first); macOS hints.src/infra/system.ts:checkPlatform()acceptsdarwin.Testing
-s bashclean ontokenline.shandinstall.sh.pnpm lint,pnpm typecheck,pnpm buildpass.date/stat): same fixture → same lines asLinux, including under a hostile
LC_ALL=pt_BR.UTF-8.install.shpasses its dependency check on macOS with Homebrew bash + BSDcoreutils.
Closes #2