Skip to content

Commit 402d543

Browse files
fricobenclaude
andcommitted
feat(cli): add npm publishing support for Bun CLI
- Update CLI package.json: remove src from files, add os field, change workspace dep to ^0.1.0 - Update core package.json: add optionalDependencies for platform packages - Add GitHub Actions workflow for cross-platform builds and npm publish - Add CLI README with installation and usage docs - Add missing table.ts utility 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1191e7d commit 402d543

5 files changed

Lines changed: 318 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
name: Release CLI
2+
3+
on:
4+
push:
5+
tags:
6+
- 'cli-v*'
7+
workflow_dispatch:
8+
inputs:
9+
dry_run:
10+
description: 'Dry run (skip npm publish)'
11+
required: false
12+
default: 'false'
13+
type: boolean
14+
15+
env:
16+
DEBUG: napi:*
17+
MACOSX_DEPLOYMENT_TARGET: '10.13'
18+
19+
permissions:
20+
contents: write
21+
id-token: write
22+
23+
jobs:
24+
build:
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
settings:
29+
- host: macos-latest
30+
target: x86_64-apple-darwin
31+
build: bun run build
32+
- host: macos-latest
33+
target: aarch64-apple-darwin
34+
build: bun run build --target aarch64-apple-darwin
35+
- host: ubuntu-latest
36+
target: x86_64-unknown-linux-gnu
37+
build: bun run build --target x86_64-unknown-linux-gnu
38+
- host: ubuntu-latest
39+
target: aarch64-unknown-linux-gnu
40+
build: |
41+
sudo apt-get update
42+
sudo apt-get install -y gcc-aarch64-linux-gnu
43+
bun run build --target aarch64-unknown-linux-gnu
44+
- host: ubuntu-latest
45+
target: x86_64-unknown-linux-musl
46+
build: bun run build --target x86_64-unknown-linux-musl
47+
- host: ubuntu-latest
48+
target: aarch64-unknown-linux-musl
49+
build: |
50+
sudo apt-get update
51+
sudo apt-get install -y gcc-aarch64-linux-gnu
52+
bun run build --target aarch64-unknown-linux-musl
53+
- host: windows-latest
54+
target: x86_64-pc-windows-msvc
55+
build: bun run build
56+
- host: windows-latest
57+
target: aarch64-pc-windows-msvc
58+
build: bun run build --target aarch64-pc-windows-msvc
59+
60+
name: Build - ${{ matrix.settings.target }}
61+
runs-on: ${{ matrix.settings.host }}
62+
63+
steps:
64+
- uses: actions/checkout@v4
65+
66+
- name: Setup Bun
67+
uses: oven-sh/setup-bun@v2
68+
with:
69+
bun-version: latest
70+
71+
- name: Setup Rust
72+
uses: dtolnay/rust-toolchain@stable
73+
with:
74+
targets: ${{ matrix.settings.target }}
75+
76+
- name: Install dependencies
77+
run: bun install
78+
working-directory: packages/core
79+
80+
- name: Build native module
81+
run: ${{ matrix.settings.build }}
82+
working-directory: packages/core
83+
shell: bash
84+
85+
- name: Upload artifact
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: bindings-${{ matrix.settings.target }}
89+
path: packages/core/*.node
90+
if-no-files-found: error
91+
92+
build-universal-macos:
93+
name: Build - universal-apple-darwin
94+
needs: build
95+
runs-on: macos-latest
96+
steps:
97+
- uses: actions/checkout@v4
98+
99+
- name: Setup Bun
100+
uses: oven-sh/setup-bun@v2
101+
with:
102+
bun-version: latest
103+
104+
- name: Install dependencies
105+
run: bun install
106+
working-directory: packages/core
107+
108+
- name: Download x64 artifact
109+
uses: actions/download-artifact@v4
110+
with:
111+
name: bindings-x86_64-apple-darwin
112+
path: packages/core
113+
114+
- name: Download arm64 artifact
115+
uses: actions/download-artifact@v4
116+
with:
117+
name: bindings-aarch64-apple-darwin
118+
path: packages/core
119+
120+
- name: Create universal binary
121+
run: |
122+
bun x @napi-rs/cli universal
123+
working-directory: packages/core
124+
125+
- name: Upload universal artifact
126+
uses: actions/upload-artifact@v4
127+
with:
128+
name: bindings-universal-apple-darwin
129+
path: packages/core/*.node
130+
if-no-files-found: error
131+
132+
publish:
133+
name: Publish to npm
134+
runs-on: ubuntu-latest
135+
needs:
136+
- build
137+
- build-universal-macos
138+
139+
steps:
140+
- uses: actions/checkout@v4
141+
142+
- name: Setup Bun
143+
uses: oven-sh/setup-bun@v2
144+
with:
145+
bun-version: latest
146+
147+
- name: Setup Node.js (for npm publish)
148+
uses: actions/setup-node@v4
149+
with:
150+
node-version: '20'
151+
registry-url: 'https://registry.npmjs.org'
152+
153+
- name: Install dependencies
154+
run: bun install
155+
156+
- name: Download all artifacts
157+
uses: actions/download-artifact@v4
158+
with:
159+
path: packages/core/artifacts
160+
161+
- name: Move artifacts
162+
run: bun x @napi-rs/cli artifacts
163+
working-directory: packages/core
164+
165+
- name: List packages
166+
run: ls -la npm/
167+
working-directory: packages/core
168+
169+
- name: Publish @vibetracking/core
170+
if: ${{ github.event.inputs.dry_run != 'true' }}
171+
run: |
172+
bun x @napi-rs/cli prepublish -t npm
173+
npm publish --access public --provenance
174+
working-directory: packages/core
175+
env:
176+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
177+
178+
- name: Publish platform packages
179+
if: ${{ github.event.inputs.dry_run != 'true' }}
180+
run: |
181+
for dir in npm/*/; do
182+
if [ -d "$dir" ]; then
183+
echo "Publishing $dir"
184+
cd "$dir"
185+
npm publish --access public --provenance
186+
cd ../..
187+
fi
188+
done
189+
working-directory: packages/core
190+
env:
191+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
192+
193+
- name: Build CLI
194+
run: bun run build
195+
working-directory: packages/cli
196+
197+
- name: Publish vibetracking CLI
198+
if: ${{ github.event.inputs.dry_run != 'true' }}
199+
run: npm publish --access public --provenance
200+
working-directory: packages/cli
201+
env:
202+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
203+
204+
- name: Dry run summary
205+
if: ${{ github.event.inputs.dry_run == 'true' }}
206+
run: |
207+
echo "## Dry Run Complete" >> $GITHUB_STEP_SUMMARY
208+
echo "Would have published:" >> $GITHUB_STEP_SUMMARY
209+
echo "- @vibetracking/core@0.1.0" >> $GITHUB_STEP_SUMMARY
210+
echo "- vibetracking@0.1.0" >> $GITHUB_STEP_SUMMARY
211+
echo "" >> $GITHUB_STEP_SUMMARY
212+
echo "Platform packages:" >> $GITHUB_STEP_SUMMARY
213+
ls -la packages/core/npm/ >> $GITHUB_STEP_SUMMARY

packages/cli/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# vibetracking
2+
3+
Track AI coding assistant usage across Claude Code, Codex, Cursor, Gemini, Amp, and more.
4+
5+
## Requirements
6+
7+
- [Bun](https://bun.sh) >= 1.0
8+
9+
## Installation
10+
11+
```bash
12+
# One-off execution
13+
bunx vibetracking
14+
15+
# Global install
16+
bun add -g vibetracking
17+
```
18+
19+
## Usage
20+
21+
```bash
22+
# First run - scans local data and opens browser to import
23+
vibetracking
24+
25+
# Login to sync data automatically
26+
vibetracking login
27+
28+
# Sync data (after login)
29+
vibetracking sync
30+
31+
# Check current user
32+
vibetracking whoami
33+
34+
# Logout
35+
vibetracking logout
36+
```
37+
38+
### Cursor Integration
39+
40+
```bash
41+
# Login to Cursor to include usage data
42+
vibetracking cursor login
43+
44+
# Check Cursor status
45+
vibetracking cursor status
46+
47+
# Logout from Cursor
48+
vibetracking cursor logout
49+
```
50+
51+
## Supported Tools
52+
53+
| Tool | Data Location |
54+
|------|---------------|
55+
| Claude Code | `~/.claude/projects/` |
56+
| Codex | `~/.codex/` |
57+
| OpenCode | `~/.local/share/opencode/` |
58+
| Gemini | `~/.gemini/` |
59+
| Amp | `~/.ampcode/` |
60+
| Cursor | API sync (requires login) |
61+
62+
## How It Works
63+
64+
1. **Scan**: Vibetracking scans your local AI coding tool data
65+
2. **Parse**: Native Rust module parses session files in parallel
66+
3. **Calculate**: Estimates costs using real-time model pricing from LiteLLM
67+
4. **Import**: Opens browser to import data to vibetracking.dev
68+
5. **Share**: View your stats, compare on leaderboards, share your profile
69+
70+
## Links
71+
72+
- Website: https://vibetracking.dev
73+
- GitHub: https://github.com/lfglabs/vibetracking
74+
75+
## License
76+
77+
MIT

packages/cli/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
"vibetracking": "./dist/cli.js"
1010
},
1111
"files": [
12-
"dist/**/*",
13-
"src/**/*"
12+
"dist/**/*"
13+
],
14+
"os": [
15+
"darwin",
16+
"linux",
17+
"win32"
1418
],
1519
"publishConfig": {
1620
"registry": "https://registry.npmjs.org/",
@@ -28,7 +32,7 @@
2832
"prepublishOnly": "bun run build"
2933
},
3034
"dependencies": {
31-
"@vibetracking/core": "workspace:*",
35+
"@vibetracking/core": "^0.1.0",
3236
"clipboardy": "^5.0.2",
3337
"commander": "^14.0.2",
3438
"csv-parse": "^5.6.0",

packages/cli/src/table.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Table formatting utilities for CLI output
3+
*/
4+
5+
export function formatCurrency(amount: number): string {
6+
return `$${amount.toFixed(2)}`;
7+
}
8+
9+
export function formatNumber(num: number): string {
10+
return num.toLocaleString("en-US");
11+
}

packages/core/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@
5151
"index.d.ts",
5252
"*.node"
5353
],
54+
"optionalDependencies": {
55+
"@vibetracking/core-darwin-x64": "0.1.0",
56+
"@vibetracking/core-darwin-arm64": "0.1.0",
57+
"@vibetracking/core-linux-x64-gnu": "0.1.0",
58+
"@vibetracking/core-linux-arm64-gnu": "0.1.0",
59+
"@vibetracking/core-linux-x64-musl": "0.1.0",
60+
"@vibetracking/core-linux-arm64-musl": "0.1.0",
61+
"@vibetracking/core-win32-x64-msvc": "0.1.0",
62+
"@vibetracking/core-win32-arm64-msvc": "0.1.0"
63+
},
5464
"engines": {
5565
"node": ">= 16"
5666
},

0 commit comments

Comments
 (0)