npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

switch-acc-agy

v0.1.0

Published

Local account switcher for Antigravity CLI auth on macOS

Readme

switch-agy

switch-agy là tool switch account local cho Antigravity CLI (agy) trên macOS.

Mục tiêu: sau khi bạn login thủ công mỗi account một lần, bạn có thể switch account ngay từ terminal mà không cần mở browser hay nhập code lại:

switch-acc-agy-to acc1
agy --prompt "hello"

Tool hoạt động bằng cách lưu và khôi phục 2 nơi chứa credential mà agy đang dùng trên máy này:

  • ~/.gemini/oauth_creds.json
  • macOS Keychain generic password service=gemini, account=antigravity

Tool không tự động login Google. Nó chỉ snapshot credential đã có sẵn trên máy và restore lại khi cần switch.

Yêu Cầu

  • macOS
  • Node.js và npm
  • agy đã cài và chạy được
  • Ít nhất một account Antigravity/Gemini đã login sẵn

Kiểm tra:

node --version
npm --version
command -v agy

Cài Đặt

Cách gọn nhất trên máy mới là cài global qua npm. Không cần cd vào repo để tạo symlink tay nữa.

Nếu máy có quyền pull repo qua GitHub SSH:

npm install -g git+ssh://[email protected]/XuanMaiHieu/switch-acc-agy.git

Nếu đã clone repo sẵn trên máy:

npm install -g /path/to/switch-agy

Verify:

command -v switch-acc-agy
switch-acc-agy paths

npm sẽ tự tạo các command global:

  • switch-acc-agy
  • switch-acc-agy-save
  • switch-acc-agy-to

Nếu shell chưa nhận ra command ngay, mở terminal mới hoặc reload shell config.

Path kỳ vọng trên máy này:

store: /Users/abc-dev/.switch-agy
profiles: /Users/abc-dev/.switch-agy/profiles
backups: /Users/abc-dev/.switch-agy/backups
oauth_creds: /Users/abc-dev/.gemini/oauth_creds.json
keychain_service: gemini
keychain_account: antigravity

Setup Lần Đầu Cho Nhiều Account

Bạn cần login thủ công từng account một lần. Sau mỗi lần login, lưu trạng thái credential hiện tại thành một profile.

Lưu Account 1

Login account 1 bằng flow bình thường của Antigravity/Gemini. Kiểm tra account đang chạy được:

agy --prompt "say account one works"

Lưu lại:

switch-acc-agy-save acc1

Lưu Account 2

Logout hoặc đổi login thủ công sang account 2 bằng flow bình thường của Antigravity/Gemini. Kiểm tra account đang chạy được:

agy --prompt "say account two works"

Lưu lại:

switch-acc-agy-save acc2

Xem danh sách profile đã lưu:

switch-acc-agy list

Ví dụ output:

acc1
acc2 *

Dấu * là profile mà tool lưu hoặc switch gần nhất.

Sử Dụng Hàng Ngày

Switch sang account 1:

switch-acc-agy-to acc1
agy --prompt "hello from acc1"

Switch sang account 2:

switch-acc-agy-to acc2
agy --prompt "hello from acc2"

Lưu ý quan trọng: sau khi switch, hãy chạy một process agy mới. Những session agy đang mở từ trước có thể vẫn cache token cũ trong memory.

Lệnh Có Sẵn

Lưu auth hiện tại thành profile:

switch-acc-agy save <profile>
switch-acc-agy-save <profile>

Switch sang một profile đã lưu:

switch-acc-agy to <profile>
switch-acc-agy-to <profile>

Liệt kê profile:

switch-acc-agy list

Xem profile được chọn gần nhất:

switch-acc-agy current

Xem path và Keychain identifier mà tool đang dùng:

switch-acc-agy paths

Xem help:

switch-acc-agy --help

Quy Tắc Đặt Tên Profile

Tên profile hợp lệ:

  • Bắt đầu bằng chữ cái
  • Chỉ dùng chữ cái, số, dấu gạch ngang, dấu gạch dưới
  • Tối đa 32 ký tự

Ví dụ hợp lệ:

acc1
work
personal
gmail_main
team-pro

Không hợp lệ:

1acc
my.account
work/email

Dữ Liệu Được Lưu Ở Đâu

Profiles:

~/.switch-agy/profiles/<profile>/
  oauth_creds.json
  keychain_secret
  metadata.json

Backups:

~/.switch-agy/backups/<timestamp>/
  oauth_creds.json
  keychain_secret

Credential live sẽ bị thay khi switch:

~/.gemini/oauth_creds.json
macOS Keychain: service=gemini account=antigravity

Tool cố gắng set quyền file credential là 0600 và quyền thư mục profile là 0700.

Lưu Ý Bảo Mật

Profile đã lưu chứa OAuth credential thật. Hãy coi ~/.switch-agy là dữ liệu bí mật.

Không commit thư mục này:

echo ".switch-agy/" >> ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global

Không paste oauth_creds.json hoặc keychain_secret vào chat, log, issue, ticket.

Nếu một profile bị lộ, hãy revoke session Google đó, login thủ công lại, rồi lưu lại profile:

switch-acc-agy-save acc1

Rollback

Mỗi lần switch, tool tự tạo backup:

~/.switch-agy/backups/YYYYMMDD-HHMMSS

Ví dụ rollback thủ công:

backup="$HOME/.switch-agy/backups/20260520-223404"
cp "$backup/oauth_creds.json" "$HOME/.gemini/oauth_creds.json"
chmod 600 "$HOME/.gemini/oauth_creds.json"
security add-generic-password -U -a antigravity -s gemini -w "$(cat "$backup/keychain_secret")"

Sau đó chạy một process agy mới:

agy --prompt "hello"

Troubleshooting

switch-acc-agy-to: command not found

Khả năng cao là thư mục global prefix của npm chưa nằm trong PATH.

Xem prefix hiện tại:

npm prefix -g

Thêm dòng này vào shell config:

export PATH="$(npm prefix -g)/bin:$PATH"

Sau đó restart terminal hoặc chạy:

source ~/.zshrc

Keychain item not found

Account hiện tại chưa được Antigravity lưu vào Keychain item kỳ vọng.

Chạy:

agy --prompt "hello"

Nếu bị yêu cầu login thì login thủ công. Sau đó lưu profile:

switch-acc-agy-save acc1

agy vẫn dùng account cũ

Đóng các session agy cũ và chạy process mới:

switch-acc-agy-to acc1
agy --prompt "which account is active?"

Tool đã đổi credential local, nhưng process đang chạy có thể vẫn cache token cũ.

Browser vẫn mở sau khi switch

Profile đã lưu có thể thiếu credential, hết hạn, hoặc đã bị revoke.

Cách sửa: login thủ công lại account đó rồi ghi đè profile:

switch-acc-agy-save acc1

agy --prompt không in output

Kiểm tra log mới nhất của Antigravity CLI:

tail -120 ~/.gemini/antigravity-cli/cli.log

Silent auth thành công thường có các dòng:

ChainedAuth: authenticated via keyring (effective: keyring)
Print mode: silent auth succeeded

Tóm Tắt Cơ Chế

save:

  1. Đọc ~/.gemini/oauth_creds.json.
  2. Đọc Keychain item service=gemini, account=antigravity.
  3. Lưu cả hai vào ~/.switch-agy/profiles/<profile>.

to:

  1. Backup credential live hiện tại.
  2. Copy oauth_creds.json đã lưu vào ~/.gemini/oauth_creds.json.
  3. Thay Keychain item bằng secret đã lưu của profile.
  4. Cập nhật ~/.switch-agy/current_profile.

Sau đó agy sẽ silent auth qua Keychain và dùng account vừa restore.