{"id":28795957,"url":"https://github.com/wronai/shapi","last_synced_at":"2026-05-08T04:36:58.592Z","repository":{"id":297930247,"uuid":"998316433","full_name":"wronai/shapi","owner":"wronai","description":"from shell to api","archived":false,"fork":false,"pushed_at":"2025-06-08T19:26:43.000Z","size":693,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-15T08:19:43.592Z","etag":null,"topics":["api","bash","cline","cursor","generator","llm","mistral","ollama","rest","script","shell","windsurf"],"latest_commit_sha":null,"homepage":"https://wronai.github.io/shapi/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wronai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-08T10:56:52.000Z","updated_at":"2025-06-08T19:26:47.000Z","dependencies_parsed_at":"2025-06-08T12:39:34.501Z","dependency_job_id":null,"html_url":"https://github.com/wronai/shapi","commit_stats":null,"previous_names":["wronai/shapi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wronai/shapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wronai%2Fshapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wronai%2Fshapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wronai%2Fshapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wronai%2Fshapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wronai","download_url":"https://codeload.github.com/wronai/shapi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wronai%2Fshapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32767412,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T02:36:36.067Z","status":"ssl_error","status_checked_at":"2026-05-08T02:36:07.210Z","response_time":54,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","bash","cline","cursor","generator","llm","mistral","ollama","rest","script","shell","windsurf"],"created_at":"2025-06-18T03:10:47.960Z","updated_at":"2026-05-08T04:36:58.588Z","avatar_url":"https://github.com/wronai.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003e✨ shapi\u003c/h1\u003e\n  \u003cp\u003eTransform shell scripts into production-ready APIs with REST, WebRTC, and gRPC support\u003c/p\u003e\n  \n  [![PyPI Version](https://img.shields.io/pypi/v/shapi?color=blue)](https://pypi.org/project/shapi/)\n  [![Python Versions](https://img.shields.io/pypi/pyversions/shapi)](https://pypi.org/project/shapi/)\n  [![License](https://img.shields.io/github/license/wronai/shapi)](https://github.com/wronai/shapi/blob/main/LICENSE)\n  [![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n  [![Documentation](https://img.shields.io/badge/docs-latest-blue.svg)](https://wronai.github.io/shapi/)\n  [![Tests](https://github.com/wronai/shapi/actions/workflows/tests.yml/badge.svg)](https://github.com/wronai/shapi/actions)\n  [![Codecov](https://codecov.io/gh/wronai/shapi/branch/main/graph/badge.svg)](https://codecov.io/gh/wronai/shapi)\n\n  [🚀 Quick Start](#-quick-start) |\n  [📖 Documentation](https://wronai.github.io/shapi/) |\n  [💡 Examples](#-examples) |\n  [🤝 Contributing](#-contributing) |\n  [📄 License](#-license)\n\u003c/div\u003e\n\n## ✨ Features\n\n- 🚀 **Instant API Generation**: Convert any shell script into a REST API with a single command\n- 🤖 **AI-Powered**: Leverage local LLM (Mistral:7b) for intelligent API generation\n- 🐳 **Container Ready**: Automatic Dockerfile and docker-compose.yml generation\n- 🌐 **Multi-Protocol**: Support for REST, WebRTC, and gRPC APIs\n- 🧪 **Testing Included**: Generated test suites and Ansible playbooks\n- 📊 **Monitoring**: Built-in health checks and status endpoints\n- 🔧 **Service Management**: Start, stop, and manage multiple services\n- 🚦 **Port Management**: Automatic port conflict resolution\n- 🎯 **Daemon Mode**: Run services in the background\n- 🔄 **Service Discovery**: List and manage running services\n\n## 📦 Installation\n\n```bash\n# Install using pip\npip install shapi\n\n# Or install from source\ngit clone https://github.com/wronai/shapi.git\ncd shapi\npip install -e .\n```\n\n## 🚀 Quick Start\n\n### Serve a Script\n\n```bash\n# Serve a script directly\nshapi serve ./examples/echo.sh --port 8000\n\n# Or run it as a daemon\nshapi serve ./examples/echo.sh --name echo-service --port 8000 --daemon\n\n# List running services\nshapi service list\n```\n\n### Manage Services\n\n```bash\n# List all running services\nshapi service list\n\n# Stop a service\nshapi service stop service-name\n\n# Restart a service\nshapi service restart service-name\n\n# Force stop if port is in use\nshapi serve ./script.sh --port 8000 --force\n```\n\n### Generate Service Structure\n\n```bash\n# Generate complete service structure with Docker and tests\nshapi generate /path/to/your/script.sh --name my-service\n\n# Navigate to the generated service\ncd my-service\n\n# Install dependencies and run\npip install -r requirements.txt\npython main.py\n```\n\n## 📚 Documentation\n\n- [Examples](./examples/README.md) - Detailed documentation of example scripts\n- [API Reference](https://wronai.github.io/shapi/) - Complete API documentation\n- [Development Guide](./CONTRIBUTING.md) - How to contribute to ShAPI\n\n## 🔍 Examples\n\nShAPI comes with several example scripts that demonstrate its capabilities:\n\n1. `ls.sh` - List directory contents\n2. `ps.sh` - Show running processes\n3. `df.sh` - Display disk usage\n4. `free.sh` - Show memory usage\n5. `whoami.sh` - Display current user information\n6. `date.sh` - Show current date/time with formatting\n7. `echo.sh` - Echo back input text\n\nSee the [examples documentation](./examples/README.md) for detailed usage and API examples.\n\n## 🛠️ Project Structure\n\n```\nmy-service/\n├── main.py              # FastAPI service\n├── Dockerfile           # Container configuration\n├── docker-compose.yml   # Multi-service setup\n├── Makefile            # Build and deployment commands\n├── requirements.txt    # Python dependencies\n├── test_service.py     # Test suite\n├── ansible/           # Infrastructure tests\n│   └── test.yml\n└── script.sh          # Your original script\n```\n\n## Usage Examples\n\n### Basic Script Conversion\n\n```bash\n#!/bin/bash\n# hello.sh\necho \"Hello, $1!\"\n```\n\nGenerate the service:\n```bash\nshapi generate hello.sh --name greeting-service\ncd greeting-service\npython main.py\n```\n\nAccess your API:\n- **Health Check**: `GET http://localhost:8000/health`\n- **Documentation**: `GET http://localhost:8000/docs`\n- **Execute Script**: `POST http://localhost:8000/run`\n\n### API Endpoints\n\nEvery generated service includes:\n\n- `GET /health` - Service health check\n- `GET /info` - Script information\n- `POST /run` - Execute script (sync/async)\n- `GET /status/{task_id}` - Check async task status\n- `GET /docs` - Interactive API documentation\n\n## Service Management\n\n### Managing Multiple Services\n\n```bash\n# Start multiple services on different ports\nshapi serve ./service1.sh --name service1 --port 8000 --daemon\nshapi serve ./service2.sh --name service2 --port 8001 --daemon\n\n# List all running services\nshapi service list\n\n# Output:\n# ┏━━━━━━━━━━━┳━━━━━━━━┳━━━━━━┳━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n# ┃ Name      ┃ PID    ┃ Port ┃ Status  ┃ Uptime   ┃ Script                          ┃\n# ┡━━━━━━━━━━━╇━━━━━━━━╇━━━━━━╇━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩\n# │ service1  │ 12345  │ 8000 │ running │ 00:05:32 │ /path/to/service1.sh            │\n# │ service2  │ 12346  │ 8001 │ running │ 00:02:15 │ /path/to/service2.sh            │\n# └───────────┴────────┴──────┴─────────┴──────────┴─────────────────────────────────┘\n\n# Stop a service\nshapi service stop service1\n\n# Force stop a service if it's not responding\nshapi service stop service2 --force\n\n# Restart a service\nshapi service restart service1\n```\n\n### Port Management\n\n```bash\n# Start a service with automatic port conflict resolution\nshapi serve ./service.sh --port 8000 --force\n\n# The --force flag will automatically stop any service using port 8000\n```\n\n### Example API Request\n\n```json\nPOST /run\n{\n  \"parameters\": {\n    \"name\": \"World\",\n    \"verbose\": true\n  },\n  \"async_execution\": false\n}\n```\n\n### Docker Deployment\n\n```bash\n# Build and run with Docker\nmake docker-build\nmake docker-run\n\n# Or use docker-compose\ndocker-compose up -d\n```\n\n### Testing\n\n```bash\n# Run tests\nmake test\n\n# Or directly\npython -m pytest test_service.py -v\n```\n\n## Configuration\n\nCreate a `config.yaml` file for advanced configuration:\n\n```yaml\nservice:\n  name: \"my-advanced-service\"\n  description: \"Advanced shell script API\"\n  version: \"1.0.0\"\n  \nprotocols:\n  rest: true\n  grpc: true\n  webrtc: true\n  \nsecurity:\n  auth_required: false\n  cors_enabled: true\n  \nmonitoring:\n  health_check_interval: 30\n  metrics_enabled: true\n```\n\n## CLI Commands\n\n```bash\n# Generate service structure\nshapi generate hello.sh --name service-name --output ./output\n\n# Serve script directly\nshapi serve hello.sh --host 0.0.0.0 --port 8008\n\n# Test generated service\nshapi test ./generated/service-name\n\n# Build Docker image\nshapi build ./generated/service-name\n```\n\n## Advanced Features\n\n### Async Execution\n\n```python\n# Enable async execution for long-running scripts\nresponse = requests.post(\"/run\", json={\n    \"parameters\": {\"input\": \"data\"},\n    \"async_execution\": True\n})\n\ntask_id = response.json()[\"task_id\"]\n\n# Check status\nstatus = requests.get(f\"/status/{task_id}\")\n```\n\n### Multiple Protocols\n\nThe generated service supports multiple communication protocols:\n\n- **REST API**: Standard HTTP endpoints\n- **WebRTC**: Real-time data streaming\n- **gRPC**: High-performance RPC calls\n\n### Production Deployment\n\n```bash\n# Using Makefile\nmake deploy\n\n# Manual deployment\ndocker-compose up -d\n```\n\n## Requirements\n\n- Python 3.8+\n- Docker (optional, for containerization)\n- Bash (for shell script execution)\n\n## Contributing\n\nContributions are welcome! Please see our [Contributing Guidelines](CONTRIBUTING.md).\n\n## License\n\nApache License 2.0 - see [LICENSE](LICENSE) file for details.\n\n## Support\n\n- 📖 [Documentation](https://wronai.github.io/shapi)\n- 🐛 [Issue Tracker](https://github.com/wronai/shapi/issues)\n- 💬 [Discussions](https://github.com/wronai/shapi/discussions)\n\n---\n\n**shapi** - From shell to service in seconds! 🚀\n\n\n\n\n\n\n\n# Contributing Guidelines\n# CONTRIBUTING.md\n\"\"\"\n# Contributing to shapi\n\nWe welcome contributions to shapi! This document provides guidelines for contributing.\n\n## Development Setup\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/wronai/shapi.git\ncd shapi\n```\n\n2. Create virtual environment:\n```bash\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n```\n\n3. Install in development mode:\n```bash\npip install -e .[dev]\n```\n\n## Running Tests\n\n```bash\n# Run all tests\npytest\n\n# Run with coverage\npytest --cov=shapi\n\n# Run specific test file\npytest tests/test_core.py -v\n```\n\n## Code Style\n\nWe use black for code formatting and flake8 for linting:\n\n```bash\n# Format code\nblack shapi/\n\n# Check linting\nflake8 shapi/\n```\n\n## Submitting Changes\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests for new functionality\n5. Ensure all tests pass\n6. Submit a pull request\n\n## Reporting Issues\n\nPlease use the GitHub issue tracker to report bugs or request features.\n\"\"\"","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwronai%2Fshapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwronai%2Fshapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwronai%2Fshapi/lists"}