Metadata-Version: 2.4
Name: kiro-switcher
Version: 2.0.1
Summary: Interactive TUI for hot-swapping between multiple Kiro IDE accounts
Author: Yeris Rifan
License: MIT
Project-URL: Homepage, https://github.com/yerisrifan/kiro-account-switcher
Project-URL: Repository, https://github.com/yerisrifan/kiro-account-switcher
Project-URL: Issues, https://github.com/yerisrifan/kiro-account-switcher/issues
Keywords: kiro,ide,aws,sso,account,switcher,tui
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development
Classifier: Topic :: Utilities
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: rich>=10.0.0
Dynamic: license-file

# Kiro IDE Account Switcher

Interactive terminal UI for hot-swapping between multiple Kiro IDE accounts without re-login.

![Version](https://img.shields.io/badge/version-2.0.0-blue)
![Python](https://img.shields.io/badge/python-3.6+-green)
![License](https://img.shields.io/badge/license-MIT-orange)

## Features

- ✅ **Visual Dashboard**: See all accounts at a glance with color-coded status
- ✅ **One-Key Switching**: Press number to switch instantly
- ✅ **Token Expiry Warnings**: Know which accounts need re-login
- ✅ **Custom Labels**: Friendly names like "Production AWS" instead of "prod"
- ✅ **Progress Spinners**: Visual feedback during token wait
- ✅ **Cross-Platform**: Works on macOS, Linux, Windows
- ✅ **Safe Operations**: Automatic backups on every switch
- ✅ **Modular Architecture**: Clean, maintainable codebase

## Quick Start

```bash
# Install
pip3 install kiro-switcher

# Run
kiro-switcher
```

## Installation

### From PyPI (Recommended)

```bash
pip3 install kiro-switcher
```

### From Source

```bash
git clone https://github.com/yerisrifan/kiro-account-switcher.git
cd kiro-account-switcher
pip3 install -e .
```

### Requirements

- Python 3.6+
- Kiro IDE installed
- `rich` library (auto-installed)

## Usage

### First Time Setup

1. **Run the tool**:
   ```bash
   kiro-switcher
   ```

2. **Press `n`** to setup new account

3. **Name the account** (e.g., "prod", "main", "personal")

4. **Add label** (optional, e.g., "Production AWS")

5. **Login in Kiro IDE** when it opens

### Switching Accounts

1. **Press number key** (1-9) for the account
2. **Restart Kiro IDE** to apply changes

### Other Actions

- **`n`** - Setup new account
- **`r`** - Rename account label
- **`d`** - Delete account (with confirmation)
- **`q`** - Quit

## Screenshot

```
╔══════════════════════════════════════════════════════════════════════════════╗
║                        KIRO IDE ACCOUNT SWITCHER                             ║
╚══════════════════════════════════════════════════════════════════════════════╝

╭─────────────────────────────────── Status ───────────────────────────────────╮
│ Active:  Production AWS  (3 accounts)                                        │
╰──────────────────────────────────────────────────────────────────────────────╯

                          Kiro IDE Accounts                          
╭──────┬──────────────────┬──────────┬──────────────────┬──────────╮
│ #    │ Account          │ Provider │ Expires          │  Status  │
├──────┼──────────────────┼──────────┼──────────────────┼──────────┤
│ 1    │ Production AWS   │ Github   │ 2026-05-12 19:52 │ ✓ ACTIVE │
│ 2    │ Development      │ Google   │ 2026-05-12 19:36 │          │
│ 3    │ Staging          │ Github   │ 2026-05-11 10:00 │ ⚠ EXPIRED│
╰──────┴──────────────────┴──────────┴──────────────────┴──────────╯

Actions:
  1-9     Switch to account
  n       Setup new account
  r       Rename account label
  d       Delete account
  q       Quit

Choice (q): 
```

## How It Works

### Architecture

```
kiro_switcher/
├── __init__.py       # Package metadata
├── config.py         # Configuration and paths
├── core.py           # Account and token management
├── ui.py             # Terminal UI rendering
└── app.py            # Main application logic
```

### File Structure

```
~/.aws/sso/cache/
├── kiro-auth-token.json              # Active token (regular file)
├── prod-kiro-auth-token.json         # Production account
├── dev-kiro-auth-token.json          # Development account
└── staging-kiro-auth-token.json      # Staging account

~/.local/share/kiro-ide-switcher/
├── accounts.json                     # Account metadata (labels, dates)
└── active                            # Currently active account name
```

### Security Note

**Why file copy instead of symlinks?**

Kiro IDE security policy rejects symbolic links:
```
Error: symbolic link detected at token storage path
```

This tool uses file copy strategy to comply with security requirements. Each switch:
1. Backs up current token (timestamped)
2. Copies target account token to `kiro-auth-token.json`
3. Updates active account tracking

## Development

### Project Structure

- **config.py**: Cross-platform path detection and IDE launch commands
- **core.py**: `TokenHandler` and `AccountManager` classes for business logic
- **ui.py**: `TUIRenderer` class for all Rich-based UI rendering
- **app.py**: `KiroSwitcher` main application orchestration

### Running from Source

```bash
# Install in development mode
pip3 install -e .

# Run
kiro-switcher

# Or run directly
./kiro-switcher
```

### Testing

```bash
# Install dev dependencies
pip3 install pytest

# Run tests (coming soon)
pytest
```

## Troubleshooting

### "No accounts found"
- Press `n` to setup your first account
- Make sure you've logged into Kiro IDE at least once

### "Token expired"
- Press `n` to re-login with expired account
- Or switch to an account with valid token

### Kiro IDE shows loading/error after switch
- **Restart Kiro IDE** (required after every switch)
- Check token expiry in the accounts table
- Verify token file: `ls ~/.aws/sso/cache/kiro-auth-token.json`

### "rich library not installed"
```bash
pip3 install rich
```

## Keyboard Shortcuts

| Key   | Action                    |
|-------|---------------------------|
| 1-9   | Switch to account         |
| n     | Setup new account         |
| r     | Rename account label      |
| d     | Delete account            |
| q     | Quit                      |

## Contributing

Issues and PRs welcome at [GitHub](https://github.com/yerisrifan/kiro-account-switcher).

## License

MIT

## Changelog

### v2.0.0 (2026-05-12)
- Complete refactor to modular architecture
- Cross-platform support (macOS, Linux, Windows)
- Progress spinners for better UX
- Class-based design for maintainability
- PyPI package support

### v1.0.0 (2026-05-12)
- Initial release with standalone TUI
- Basic account switching functionality
