Skip to main content

Add your description here

Project description

Script Magic 🪄

Script Magic is a CLI tool for creating, managing, and running Python scripts with GitHub Gists integration and AI-powered script generation.

Python 3.9+ License: MIT

Features

  • 🤖 AI-Powered Script Generation: Create Python scripts from natural language prompts using OpenAI's GPT models
  • ☁️ GitHub Gist Integration: Store and manage scripts in GitHub Gists for easy sharing and versioning
  • 🔄 Simple Script Management: Run, update, and manage your scripts with easy commands
  • 📦 Automatic Dependency Management: Script execution with uv handles dependencies automatically
  • 🚀 Interactive Mode: Refine generated scripts interactively before saving

Installation

Prerequisites

  • Python 3.9+
  • uv for Python package management and script execution
  • GitHub account with a Personal Access Token
  • OpenAI API key

Quick Install

# Clone the repository
git clone https://github.com/yourusername/script-magic.git
cd script-magic

# Install with uv
uv venv
uv pip install -e .

# Set up your environment variables
export OPENAI_API_KEY="your-openai-api-key"
export GITHUB_PAT="your-github-personal-access-token"

Usage

Creating Scripts

Generate a new script from a natural language prompt:

sm create hello-world "Create a script that prints 'Hello, World!' with timestamp"

Generate with interactive preview:

sm create fibonacci --preview "Generate a script to print the first 10 Fibonacci numbers"

Running Scripts

Run a script that has been previously created:

sm run hello-world

Pass parameters to the script:

sm run hello-world --name="John"

Force refresh from GitHub before running:

sm run hello-world --refresh

Listing Scripts

View all scripts in your inventory:

sm list

Show detailed information about your scripts:

sm list --verbose

Filter scripts by tag:

sm list --tag python --tag backup

Deleting Scripts

Remove a script from both local inventory and GitHub Gists:

sm delete script-name

Force deletion without confirmation:

sm delete script-name --force

Configuration

Script Magic stores configuration in the ~/.sm directory:

  • ~/.sm/config.json: Main configuration file
  • ~/.sm/logs/: Log files for debugging
  • ~/.sm/mapping.json: Maps script names to GitHub Gist IDs

Structure

script-magic/
├── src/
│   └── script_magic/
│       ├── __init__.py             # CLI entry point with command registration
│       ├── create.py               # Script creation command
│       ├── run.py                  # Script execution command
│       ├── list.py                 # Script listing command
│       ├── delete.py               # Script deletion command
│       ├── github_integration.py   # GitHub Gist API integration
│       ├── pydantic_ai_integration.py  # AI script generation
│       ├── mapping_manager.py      # Script mapping management
│       ├── logger.py               # Logging configuration
│       └── rich_output.py          # Terminal output formatting

Environment Variables

  • OPENAI_API_KEY: Your OpenAI API key
  • GITHUB_PAT: GitHub Personal Access Token with Gist permissions
  • SM_CONFIG_DIR: (Optional) Custom directory for Script Magic configuration

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

script_magic-0.1.0.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

script_magic-0.1.0-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file script_magic-0.1.0.tar.gz.

File metadata

  • Download URL: script_magic-0.1.0.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.14

File hashes

Hashes for script_magic-0.1.0.tar.gz
Algorithm Hash digest
SHA256 41f40f13445720ce258f679df859bb2b693b704517c8032caa59c5f9d7d764df
MD5 604fad2489f53ddf9e3c7834339e27cd
BLAKE2b-256 8116b59508fadf8df0f8c6e5810de77d13e165edf56b5710eac5530b02827e8e

See more details on using hashes here.

File details

Details for the file script_magic-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for script_magic-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5035587765900eb8b8fa66823f5074b40bca452f2aff5fea111d78970070f990
MD5 248bec3b4d6751a0b6c2de83a0785260
BLAKE2b-256 e9e52cc4137d64301ba8be45c93d0526f5313a90a59e1a596c60bae427fab398

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page