Commit graph

56 commits

Author SHA1 Message Date
Sprite
780e2de9d3 Fix TTY detection and log output for non-interactive environments
- safe_read(): Test /dev/tty is functional before using it (exists
  but fails in containers/VMs)
- Log functions: Write to stderr so they don't pollute stdout in
  command substitutions like $(get_sprite_name)
- ensure_sprite_exists(): Fix grep regex (use -E for ERE)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 05:05:12 +00:00
Sprite
71246abc26 Fix source detection for process substitution (bash <(curl ...))
BASH_SOURCE[0] is /proc/self/fd/N with process substitution, not
"-" or "bash". Instead of guessing execution context, just check
if the local lib/common.sh file actually exists.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 05:03:02 +00:00
Sprite
10ada0e04d Fix non-interactive mode for curl | bash execution
The scripts were failing when run via curl | bash because they tried
to read from /dev/tty which doesn't exist in piped contexts.

## Changes

- Added safe_read() helper function that gracefully handles TTY absence
- Updated get_sprite_name() to support SPRITE_NAME env variable
- Updated all read commands to use safe_read()
- Added clear error messages for non-interactive usage
- Updated README with non-interactive mode documentation

## Usage

Interactive:
  curl URL | bash

Non-interactive:
  SPRITE_NAME=dev-mk1 curl URL | bash
  SPRITE_NAME=dev-mk1 OPENROUTER_API_KEY=sk-xxx curl URL | bash

## Fixes

- /dev/tty: No such device or address error
- Scripts now work in CI/CD and automated contexts
- OAuth fallback still works via OPENROUTER_API_KEY env var

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 04:48:48 +00:00
Sprite
640af6260c Refactor spawn scripts with shared library and OAuth fallback
Major refactoring to improve code maintainability and reliability:

## Shared Library Architecture
- Created sprite/lib/common.sh with reusable bash functions
- Reduced openclaw.sh from 258 to 93 lines (-64%)
- Reduced claude.sh from 272 to 101 lines (-63%)
- Eliminated ~330 lines of duplicate code

## OAuth Fallback Mechanism
- Added automatic fallback to manual API key entry
- Handles missing netcat (nc) gracefully
- Handles port conflicts and timeouts
- Validates API key format with override option
- Works in headless and minimal environments

## Dual Execution Support
- Local: bash sprite/openclaw.sh
- Remote: curl URL | bash
- Auto-detects context and sources library appropriately

## New Shared Functions
- Logging: log_info(), log_warn(), log_error()
- Sprite setup: ensure_sprite_installed/authenticated/exists()
- Environment: setup_shell_environment()
- OAuth: get_openrouter_api_key_oauth() with fallback
- Utilities: run_sprite(), verify_sprite_connectivity()

## Documentation
- REFACTORING.md - Architecture and benefits
- OAUTH_FALLBACK.md - Fallback mechanism guide
- CURL_BASH_SOLUTION.md - Execution mode details
- EXAMPLES.md - Usage scenarios
- CHANGELOG.md - Complete change history

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 04:06:11 +00:00
lab
57bf0ca2fc
Sprite setup scripts for Claude Code and OpenClaw
- OAuth authentication flow with OpenRouter to mint API keys
- Automatic sprite creation and environment configuration
- Claude Code setup with bypassed onboarding and dark theme
- OpenClaw setup with gateway and TUI launch
- Shell environment setup (bun PATH, zsh switch)
2026-02-05 13:25:30 -06:00
lab
3eaf6321a1
Initial commit: OpenClaw sprite setup script 2026-02-02 15:08:15 -06:00