A · Interactive Architecture Topology Full System
Click presets on the left or nodes below to inspect components across CLI runtime, macOS Keychain, and Google OAuth endpoints.
B · Account Slot Inventory 3 Profiles Loaded
Interactive preview of registered profile slots. Run agyswap viz --open locally on macOS to view your real accounts.
| Slot | Account / Alias | Status | Token Expiry | Auth Method |
|---|
C · Profile Switching Sequence ~0.1s Fast Path
Detailed execution flow triggered during an account switch operation.
Concurrency Lock & Target Resolution
Acquires fcntl.flock on .agyswap.lock and resolves target slot by number, email, or alias.
Expired Token Guard
Compares token.expiry with system UTC clock. If expired without --force, switch is safely blocked with a renewal guide.
Native C API Keychain Injection
Directly modifies macOS Keychain using SecKeychainItemModifyAttributesAndData via ctypes without touching process argv.
Atomic Config Update & Session Notice
Atomically saves config.json and scans for running agy processes via lsof to emit session restart guidance.
D · Command Reference
-r: resume last session (agy -c). -n: launch fresh session. -y: pass --dangerously-skip-permissions to agy for fully automated no-prompt workflows.--all rotates every slot simultaneously — no browser interaction required.bench [--golden] [--json|-md]: measure compression, or run the 10-language oracle regression. map/state: compact context snapshots. clean: sync both before /clear.agy -c without human intervention.[agy:work 85%]). Zero network lag.E · Intelligent Context Optimization & Token Benchmarks
Reduces agentic token consumption by 94.2% using pure AST skeletons and lightweight state snapshots. Zero external dependencies.
| Workflow Phase | Naive Full-File Read | agyswap ctx (AST Map + Firewall) | Net Efficiency |
|---|---|---|---|
| Codebase Discovery | Full source read (~34.2k tokens) | REPO_MAP.md (~2.0k tokens) | 🔥 94.2% Saved |
| Session Reset Recovery | Re-read raw files (~34.2k tokens) | STATE.md (< 300 tokens) | ⚡ 99.6% Saved |
| 10 Agent Sessions | ~342,000 tokens ($1.03+) | ~20,000 tokens ($0.06) | 17x Cost / Rate-limit Savings |
🏆 Golden Quality Benchmark — Multi-Language Oracle Regression
A fixed fixture set (tests/fixtures/golden_repo/) with a known symbol checklist — every release must extract 100% of them, catching silent AST/regex regressions across languages before they ship.
Coverage: Python TypeScript TSX Go Rust Java C C++ Shell — native ast parsing for Python, hardened regex extractors (with control-flow keyword guards) for the rest.
F · 🎮 Interactive Context Playground & ROI Calculator
Simulate token savings on your own project scale and compare full source code with AST-extracted Repo Maps in real time.
🎛️ Real-Time Token Savings & Cost Calculator
🔍 Full Source Code vs. AST Repo-Map (Golden Fixtures)
G · 🛡️ Interactive Rate-Limit Guard Simulator
Live Auto-Recovery DemoExperience how agyswap guard catches 429 quota exhaustion in real-time, rotates credentials in ~0.1s, and resumes coding without human intervention.
────────────────────────────────────────────────────────────
[agy] Ready. Paired programming session active. Listening for instructions...
H · 🤖 2026 Stateless MCP Sandbox & Quick Config
Zero-Dependency JSON-RPCEnables AI agents to query their own quotas and rotate profiles autonomously via standard MCP over stdio or lightweight HTTP.
| MCP Tool Name | Input Schema | Autonomous Agent Action |
|---|---|---|
agyswap_list_accounts |
{} |
Queries all slots, active state, aliases, and token health info. |
agyswap_get_quota |
{ target?, refresh? } |
Inspects real-time remaining % and reset times for Gemini models. |
agyswap_switch_account |
{ target?, force?, compact_context? } |
Rotates active Keychain credential & compacts AST context automatically. |
agyswap_rotate_token |
{ target?, all? } |
Refreshes OAuth credentials in background without browser interaction. |
agyswap_compact_context |
{ budget?, goal? } |
Generates 96% compressed REPO_MAP.md and STATE.md into .agents/memory/. |
{
"jsonrpc": "2.0",
"result": {
"protocolVersion": "2026-07-28",
"capabilities": { "stateless": true }
}
}
I · Security Architecture & Threat Model
| Security Layer | Implementation Mechanism | Threat Mitigated |
|---|---|---|
| Keychain Binding | macOS Security.framework Native C API via ctypes | Process argument sniffing (ps aux / CWE-214) |
| Storage Isolation | Files 0600, Dirs 0700 (opener=secure_opener) | Cross-user access & Umask race conditions |
| Concurrency Lock | fcntl.flock on .agyswap.lock (config/slots) and a dedicated lock for quota_cache.json | Lost updates during concurrent terminal runs, incl. the TUI's background poller racing a CLI call |
| Template Escaping | safe_json_for_script Unicode character sanitization | Stored XSS inside HTML <script> blocks |
J · POSIX Storage Layout
Migrating from an older install? Data used to live at ~/.agy-swap/ (hyphenated — it collided with an unrelated third-party tool of a similar name). agyswap moves just its own files here automatically the first time you run any command after upgrading.