tf_code/packages/tfcode/README.md
2026-03-24 14:29:24 +11:00

146 lines
3.5 KiB
Markdown

# tfcode
**ToothFairyAI's official AI coding agent** - A terminal-based coding assistant with seamless integration to your ToothFairyAI workspace.
## Features
- 🤖 **AI-Powered Coding** - Intelligent code generation, refactoring, and debugging
- 🔌 **Tool Integration** - Sync and use tools from your ToothFairyAI workspace
- 💻 **Terminal-Based** - Fast, lightweight, runs in your terminal
- 🔐 **Secure** - Credentials stay in ToothFairyAI, route via TF Proxy
## Requirements
- **Python 3.10+** - Required for ToothFairyAI integration
- **Node.js 18+** - Required to run tfcode
## Installation
```bash
npm install -g @toothfairyai/tfcode@beta
```
The installer will:
- Check Python is installed
- Install the ToothFairyAI Python SDK automatically
## Quick Start
### Option A: Interactive Setup (Recommended)
```bash
# Run interactive setup
tfcode setup
```
This will guide you through entering your credentials step by step:
1. Enter your Workspace ID
2. Enter your API Key (hidden as you type)
3. Select your region
4. Validate and sync automatically
### Option B: Manual Setup
```bash
# 1. Set your ToothFairyAI credentials
export TF_WORKSPACE_ID="your-workspace-id"
export TF_API_KEY="your-api-key"
export TF_REGION="au"
# 2. Validate your credentials
tfcode validate
# 3. Sync tools from your workspace
tfcode sync
# 4. List your tools
tfcode tools list
```
## Commands
| Command | Description |
|---------|-------------|
| `tfcode setup` | **Interactive credential setup** |
| `tfcode quickstart` | Show quick start guide |
| `tfcode validate` | Test your credentials |
| `tfcode sync` | Sync tools from workspace |
| `tfcode tools list` | List synced tools |
| `tfcode tools list --type api_function` | Filter by type |
## Regions
| Region | URL | Use Case |
|--------|-----|----------|
| `dev` | api.toothfairylab.link | Development/Testing |
| `au` | api.toothfairyai.com | Australia (Default) |
| `eu` | api.eu.toothfairyai.com | Europe |
| `us` | api.us.toothfairyai.com | United States |
## Configuration
Credentials are stored in `~/.tfcode/config.json`:
```json
{
"workspace_id": "your-workspace-id",
"api_key": "your-api-key",
"region": "au"
}
```
You can also set credentials via environment variables (takes priority over config file):
```bash
export TF_WORKSPACE_ID="your-workspace-id"
export TF_API_KEY="your-api-key"
export TF_REGION="au"
```
## Getting Your Credentials
1. Log in to [ToothFairyAI](https://app.toothfairyai.com)
2. Go to **Settings****API Keys**
3. Copy your **Workspace ID** and **API Key**
## Troubleshooting
### "Python 3.10+ is required but not found"
Install Python:
- **macOS**: `brew install python@3.12`
- **Windows**: Download from https://python.org/downloads
- **Linux**: `sudo apt install python3.12`
### "Failed to validate: Invalid API key"
- Check your API key is correct
- Generate a new key in ToothFairyAI Settings → API Keys
- Run `tfcode setup` to re-enter credentials
### "Failed to validate: Connection test failed"
Try a different region:
- Run `tfcode setup` and select a different region
- Or set `TF_REGION="eu"` or `TF_REGION="us"`
### "No credentials found"
Run interactive setup:
```bash
tfcode setup
```
## Documentation
- **Full Guide**: https://toothfairyai.com/developers/tfcode
- **API Docs**: https://apidocs.toothfairyai.com
- **Issues**: https://github.com/ToothFairyAI/tfcode/issues
## Credits
tfcode is based on [opencode](https://github.com/anomalyco/opencode) by [anomalyco](https://github.com/anomalyco).
## License
MIT