From 543ded0a5f554d8b006554249730a0fc2dae2766 Mon Sep 17 00:00:00 2001 From: rob Date: Mon, 29 Dec 2025 17:33:23 -0400 Subject: [PATCH] Add interactive provider installer and fix documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add `smarttools providers install` interactive guide for installing AI CLIs - Fix OpenCode install URL (remove .sh suffix) - Auto-refresh PATH after provider installation - Fix incorrect npm package names in docs: - @anthropic-ai/claude-code (not claude-cli) - @openai/codex (not codex-cli) - @google/gemini-cli (not @anthropic-ai/gemini-cli) - Update all docs to reflect clone-first install workflow (not PyPI) - Add Docker provider installation section to README 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- README.md | 64 ++++++++++++++++++++++++++------- docs/EXAMPLES.md | 4 +-- docs/INSTALL.md | 82 ++++++++++++++++++++++--------------------- docs/PROVIDERS.md | 40 ++++++++++++++------- src/smarttools/cli.py | 44 +++++++++++++++++++++-- 5 files changed, 164 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index 9a05197..5c7c658 100644 --- a/README.md +++ b/README.md @@ -31,12 +31,17 @@ echo "Price $49.99, SKU ABC-123" | json-extract --fields "price, sku" ## Quick Start ```bash -# Install -pip install smarttools +# Clone and install +git clone https://gitea.brrd.tech/rob/SmartTools.git +cd SmartTools +pip install -e . # Ensure ~/.local/bin is in PATH export PATH="$HOME/.local/bin:$PATH" +# Install an AI provider (interactive guide) +smarttools providers install + # Launch the UI smarttools ui @@ -46,18 +51,20 @@ smarttools create summarize ## Installation -### From PyPI (Recommended) +### Native Install ```bash -pip install smarttools +git clone https://gitea.brrd.tech/rob/SmartTools.git +cd SmartTools +pip install -e . ``` -### From Source +### With Development Dependencies ```bash -git clone https://gitea.brrd.tech/rob/smarttools.git -cd smarttools -pip install -e . +git clone https://gitea.brrd.tech/rob/SmartTools.git +cd SmartTools +pip install -e ".[dev]" ``` ### Requirements @@ -229,10 +236,9 @@ SmartTools comes with 28 pre-built examples you can install: ### Install Example Tools ```bash -# Download and run the example installer -curl -sSL https://gitea.brrd.tech/rob/smarttools/raw/branch/main/examples/install.py | python3 - -# Or manually copy from examples/ +# Run the example installer (from the SmartTools directory) +python examples/install.py +smarttools refresh ``` ## Providers @@ -435,7 +441,7 @@ MIT - Use it, modify it, share it. ## Docker -Run SmartTools without installing anything locally: +Run SmartTools in a container: ```bash # Clone the repo @@ -455,6 +461,38 @@ docker-compose run --rm cli smarttools list docker-compose run --rm shell ``` +### Installing AI Providers in Docker + +AI providers require browser-based authentication. Use the `setup` service which has display access: + +```bash +# Allow Docker to access your display (Linux) +xhost +local:docker + +# Start the setup container +docker-compose run --rm setup + +# Inside the container, use the interactive installer: +smarttools providers install + +# Select a provider (1-5), it will: +# - Install the CLI tool +# - Open a browser for sign-in +# - Configure the provider + +# After signing in, test it: +smarttools providers test claude +``` + +**Available Providers:** +| # | Provider | Cost | Notes | +|---|----------|------|-------| +| 1 | Claude | Pay-per-use | Anthropic account | +| 2 | Codex | Pay-per-use | OpenAI account | +| 3 | Gemini | Free tier | Google account | +| 4 | OpenCode | Free tier | Multiple models | +| 5 | Ollama | FREE | Local, no internet | + ## Links - [Installation Guide](docs/INSTALL.md) diff --git a/docs/EXAMPLES.md b/docs/EXAMPLES.md index dcb1be5..b7a323e 100644 --- a/docs/EXAMPLES.md +++ b/docs/EXAMPLES.md @@ -5,8 +5,8 @@ This document contains all 28 pre-built SmartTools with their full configuration ## Quick Install ```bash -# Install all example tools -curl -sSL https://gitea.brrd.tech/rob/smarttools/raw/branch/main/examples/install.py | python3 +# Install all example tools (from the SmartTools directory) +python examples/install.py smarttools refresh ``` diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 4a16d5d..7230937 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -5,9 +5,11 @@ Complete installation instructions for SmartTools. ## Quick Install ```bash -pip install smarttools +git clone https://gitea.brrd.tech/rob/SmartTools.git +cd SmartTools +pip install -e . export PATH="$HOME/.local/bin:$PATH" -smarttools refresh +smarttools providers install ``` ## Detailed Installation @@ -32,21 +34,15 @@ python3 --version # Should be 3.10 or higher ### Step 2: Install SmartTools -**From PyPI (recommended):** ```bash -pip install smarttools -``` - -**From source (for development):** -```bash -git clone https://gitea.brrd.tech/rob/smarttools.git -cd smarttools +git clone https://gitea.brrd.tech/rob/SmartTools.git +cd SmartTools pip install -e . ``` -**With TUI support (recommended):** +**With TUI and development dependencies:** ```bash -pip install smarttools urwid +pip install -e ".[dev]" ``` ### Step 3: Configure PATH @@ -75,43 +71,46 @@ source ~/.bashrc # or restart terminal ### Step 4: Install an AI Provider -You need at least one AI CLI tool. Choose based on your needs: +You need at least one AI CLI tool. The easiest way is the interactive installer: -#### Free Options - -**OpenCode (recommended for free):** ```bash -# Install +smarttools providers install +``` + +This guides you through installing and authenticating providers. + +#### Manual Installation + +**OpenCode (free tier available):** +```bash curl -fsSL https://opencode.ai/install | bash - -# Authenticate (uses browser) -~/.opencode/bin/opencode auth +source ~/.bashrc # or start new shell +opencode # Opens browser for sign-in ``` -#### Paid Options - -**Claude CLI:** +**Claude CLI (pay-per-use):** ```bash -# Install -npm install -g @anthropic-ai/claude-cli - -# Authenticate -claude auth +npm install -g @anthropic-ai/claude-code +claude # Opens browser for sign-in ``` -**Gemini CLI:** +**Codex (pay-per-use):** ```bash -# Install -pip install google-generativeai - -# Or the CLI wrapper -npm install -g @anthropic-ai/gemini-cli +npm install -g @openai/codex +codex # Opens browser for sign-in ``` -**Codex (OpenAI):** +**Gemini (free tier available):** ```bash -npm install -g codex-cli -codex auth +npm install -g @google/gemini-cli +gemini # Opens browser for Google sign-in +``` + +**Ollama (free, runs locally):** +```bash +curl -fsSL https://ollama.ai/install.sh | bash +ollama pull llama3 +smarttools providers add ollama "ollama run llama3" -d "Local Llama 3" ``` See [PROVIDERS.md](PROVIDERS.md) for full provider setup instructions. @@ -122,8 +121,11 @@ See [PROVIDERS.md](PROVIDERS.md) for full provider setup instructions. # Check SmartTools is installed smarttools --version -# List available providers -smarttools providers +# List configured providers +smarttools providers list + +# Check which providers are available +smarttools providers check # Test with mock provider (no AI needed) echo "hello world" | smarttools run --provider mock @@ -144,7 +146,7 @@ This creates executable scripts in `~/.local/bin/` for all your tools. ### Quick Install (All 28 Tools) ```bash -curl -sSL https://raw.githubusercontent.com/yourusername/smarttools/main/examples/install.py | python3 +python examples/install.py smarttools refresh ``` diff --git a/docs/PROVIDERS.md b/docs/PROVIDERS.md index cdfdb14..ea3ff16 100644 --- a/docs/PROVIDERS.md +++ b/docs/PROVIDERS.md @@ -65,14 +65,12 @@ Anthropic's official CLI for Claude models. **Install:** ```bash -npm install -g @anthropic-ai/claude-cli -# or -brew install claude +npm install -g @anthropic-ai/claude-code ``` **Authenticate:** ```bash -claude auth +claude # Opens browser for sign-in (auto-saves auth tokens) ``` **Available Models:** @@ -94,12 +92,12 @@ OpenAI's Codex CLI with auto-routing. **Install:** ```bash -npm install -g codex-cli +npm install -g @openai/codex ``` **Authenticate:** ```bash -codex auth # Uses ChatGPT account +codex # Opens browser for sign-in (auto-saves auth tokens) ``` **Test:** @@ -113,14 +111,12 @@ Google's Gemini models. Best for large context (1M tokens). **Install:** ```bash -npm install -g @anthropic-ai/gemini-cli -# or -pip install google-generativeai +npm install -g @google/gemini-cli ``` **Authenticate:** ```bash -gemini auth # Uses Google account +gemini # Opens browser for Google sign-in ``` **Available Models:** @@ -138,16 +134,36 @@ echo "Hello" | gemini --model gemini-2.5-flash ## Managing Providers +### Interactive Installation (Recommended) + +The easiest way to install providers: + +```bash +smarttools providers install +``` + +This interactive guide: +- Shows available AI providers with costs +- Runs the installation command +- Updates PATH automatically +- Shows next steps for authentication + ### List Providers ```bash -smarttools providers +smarttools providers list +``` + +### Check Availability + +```bash +smarttools providers check ``` ### Add Custom Provider ```bash -smarttools providers add +smarttools providers add myname "my-command --args" -d "Description" ``` Or edit `~/.smarttools/providers.yaml`: diff --git a/src/smarttools/cli.py b/src/smarttools/cli.py index 49d9804..41d0086 100644 --- a/src/smarttools/cli.py +++ b/src/smarttools/cli.py @@ -365,10 +365,10 @@ PROVIDER_INSTALL_INFO = { }, "opencode": { "group": "OpenCode", - "install_cmd": "curl -fsSL https://opencode.ai/install.sh | bash", + "install_cmd": "curl -fsSL https://opencode.ai/install | bash", "requires": "curl, bash", - "setup": "Run 'opencode auth' - opens browser for sign-in", - "cost": "Free tier (pickle model), paid for premium models", + "setup": "Run 'opencode' - opens browser for sign-in", + "cost": "Free tier available, paid for premium models", "variants": ["opencode-deepseek", "opencode-pickle", "opencode-nano", "opencode-reasoner", "opencode-grok"], }, "ollama": { @@ -460,6 +460,44 @@ def cmd_providers(args): print("-" * 40) if result.returncode == 0: + # Refresh PATH to pick up newly installed tools + import os + new_paths = [] + + # Common install locations that might have been added + potential_paths = [ + Path.home() / ".opencode" / "bin", # OpenCode + Path.home() / ".local" / "bin", # pip/pipx installs + Path("/usr/local/bin"), # Ollama, system installs + ] + + # Also try to get npm global bin path + try: + npm_result = subprocess.run( + ["npm", "bin", "-g"], + capture_output=True, text=True, timeout=5 + ) + if npm_result.returncode == 0: + npm_bin = npm_result.stdout.strip() + if npm_bin: + potential_paths.append(Path(npm_bin)) + except (subprocess.TimeoutExpired, FileNotFoundError): + pass + + current_path = os.environ.get("PATH", "") + for p in potential_paths: + if p.exists() and str(p) not in current_path: + new_paths.append(str(p)) + + if new_paths: + os.environ["PATH"] = ":".join(new_paths) + ":" + current_path + print() + print(f"Added to PATH (for this session): {', '.join(new_paths)}") + print() + print("To use in your shell, run one of:") + print(" source ~/.bashrc") + print(" # or start a new shell") + print() print("Installation completed!") print()