Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .changeset/interactive-installer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
"@inbrace-tech/tokenline": minor
---

Rework `install.sh` into an interactive installer. It now copies `tokenline.sh`
into the Claude profile(s) you choose and patches each `settings.json` with the
same safety contract as the npm CLI (backup, merge-only `statusLine`, idempotent,
never clobbers invalid JSON). It discovers `~/.claude`, any `~/.claude-*`, and
`./.claude`, and lets you install into several profiles at once via an arrow-key
menu (↑/↓ move, space toggle, digits 1-9 quick-toggle, Enter confirm) with a
typed-number fallback for `TERM=dumb`. Adds `--dir`, `--yes`, `--dry-run`,
`--print`, and `--force`. A minimal stepped UI with a TTY-only spinner;
piped/non-interactive runs stay plain and default to `~/.claude`. Runs on stock
macOS bash 3.2 and checks the PATH `bash` (not the interpreter) for the 4+
requirement.

Adds themes to `tokenline.sh` via `--theme <name>` (or `TOKENLINE_THEME`):
`full` (default, unchanged), `minimal` (model · ctx% · cache), `compact`
(one line with tokens + saving%), `economics` (model/ctx/cache + per-turn
breakdown), and `limits` (model/ctx/cache + 5h/7d bars). The installer asks you
to pick a theme before the profile; an unknown value falls back to `full` so a
typo never blanks the statusline.
8 changes: 8 additions & 0 deletions .changeset/macos-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@inbrace-tech/tokenline": minor
---

Add macOS support. `tokenline.sh` now abstracts `date`/`stat` over GNU vs BSD by
probing behavior once (`epoch_from_iso`, `file_mtime`), pins `LC_ALL=C` so a
comma-decimal locale renders identically, and the installer accepts macOS
(`brew install bash jq`). Closes #2.
5 changes: 3 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ Strip ANSI to check structure: pipe the output through `sed 's/\x1b\[[0-9;]*m//g

## Platform

v1 targets Linux / WSL2. macOS and Windows are tracked as roadmap issues — the
GNU-specific calls (`mapfile`, `date -d`, `stat -c`) are the things to abstract.
Runs on Linux / WSL2 and macOS. `date`/`stat` are abstracted over GNU vs BSD by
probing behavior once (`epoch_from_iso`, `file_mtime` in `tokenline.sh`); `mapfile`
still needs bash 4+, so macOS users `brew install bash`. Windows is a roadmap issue.

## The npm installer

Expand Down
57 changes: 41 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
> See your AI coding costs in real time. Tokenline adds context usage, prompt-cache savings, TTL countdown and rate-limit pacing to Claude Code and Gemini CLI.

![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)
![Platform](https://img.shields.io/badge/platform-Linux%20%7C%20WSL2-blue)
![Platform](https://img.shields.io/badge/platform-Linux%20%7C%20WSL2%20%7C%20macOS-blue)
![Shell](https://img.shields.io/badge/shell-bash%204%2B-lightgrey)

## Quickstart
Expand Down Expand Up @@ -78,39 +78,64 @@ If `tokenline` reveals you are getting 1-hour cache writes, keep in mind they bu

## Requirements

v1 targets **Linux / WSL2**:
Runs on **Linux / WSL2** and **macOS**:

- `bash` 4 or newer
- `bash` 4 or newer — macOS ships 3.2, so `brew install bash`
- [`jq`](https://jqlang.github.io/jq/)
- GNU coreutils (`date -d`, `stat -c`)
- `date` and `stat` — GNU (`-d` / `-c`) or BSD (`-j` / `-f`); both are handled

> macOS and Windows support are on the [roadmap](#roadmap). `install.sh` checks all of
> the above and tells you exactly what's missing.
On macOS: `brew install bash jq`. BSD `date`/`stat` work as-is; no `coreutils` needed.

> Windows support is on the [roadmap](#roadmap). `install.sh` checks all of the
> above and tells you exactly what's missing.

## Advanced Installation

### Without Node (clone + install.sh)

No Node? Clone the repo and run the dependency checker, which prints a ready-to-paste snippet:
No Node? Clone the repo and run the installer. It checks dependencies, then
copies `tokenline.sh` into the profile(s) you pick and patches each
`settings.json` with the same safety contract as the npm CLI (backup,
merge-only, idempotent, never clobbers invalid JSON):

```bash
git clone https://github.com/inbrace-tech/tokenline.git
cd tokenline
./install.sh
```

Add the printed block to your project's `.claude/settings.json` (or `~/.claude/settings.json` for global), inside the top-level object:
It first asks you to pick a [theme](#themes), then discovers your Claude profile
directories (`~/.claude`, any `~/.claude-*`, and `./.claude`) and lets you
install into one or several at once — handy if you run multiple profiles. Use
↑/↓ and space to choose; `~/.claude` is the default.

```json
"statusLine": {
"type": "command",
"command": "bash /absolute/path/to/tokenline/tokenline.sh",
"refreshInterval": 1
}
```bash
./install.sh --theme minimal # skip the theme prompt
./install.sh --dir ~/.claude-work # install into a specific directory
./install.sh --yes # non-interactive, install into ~/.claude
./install.sh --dry-run # show what would happen, write nothing
./install.sh --print # just print the snippet to paste manually
./install.sh --force # replace a different existing statusLine
```

Then restart Claude Code.

### Themes

The statusline ships five layouts, selected with `--theme <name>` in the
`statusLine` command (or the `TOKENLINE_THEME` env var). `full` is the default
and needs no flag.

| Theme | Lines | Shows |
| --- | --- | --- |
| `full` | 3 | model · ctx · cache + per-turn economics + 5h/7d limit bars |
| `minimal` | 1 | model · ctx% · cache state |
| `compact` | 1 | model · ctx (tokens + %) · cache TTL · saving% |
| `economics` | 2 | `full`'s first line + the per-turn economics breakdown |
| `limits` | 2 | `full`'s first line + the 5h/7d rate-limit bars |

An unknown theme name falls back to `full`, so a typo never blanks the line.

### What the installer does

`npx @inbrace-tech/tokenline init` is deliberately transparent about touching your config:
Expand Down Expand Up @@ -139,11 +164,11 @@ On every refresh the host CLI pipes a JSON snapshot of the session to the script
| Blank statusline, or `[tokenline] jq not found` | Install `jq` (`apt install jq` / `brew install jq`), then re-run `./install.sh`. |
| Cache shows `COLD` immediately | Normal right after a long idle gap — the cache window has elapsed. It goes `HOT` again on your next turn. |
| Colors look wrong / show escape codes | Your terminal must support 256-color ANSI. Most modern terminals do; check your `$TERM`. |
| Nothing renders on macOS | Expected on v1 — macOS uses BSD `date`/`stat`. See the [roadmap](#roadmap). |
| Nothing renders on macOS | Install `bash` 4+ and `jq`: `brew install bash jq`. Stock bash 3.2 lacks `mapfile`. |

## Roadmap

- [ ] macOS support (BSD `date`/`stat`, bash 3.2 fallback)
- [x] macOS support (BSD `date`/`stat`, Homebrew bash)
- [ ] Windows support (Git Bash / PowerShell)
- [ ] Configurable colors and thresholds via `TOKENLINE_*` env vars

Expand Down
Loading