{"id":51339660,"url":"https://github.com/semcod/pactfix","last_synced_at":"2026-07-02T06:04:47.441Z","repository":{"id":335112524,"uuid":"1144289949","full_name":"semcod/pactfix","owner":"semcod","description":"Real-time Bash script analyzer and auto-fixer with ShellCheck integration.","archived":false,"fork":false,"pushed_at":"2026-06-18T11:25:19.000Z","size":1070,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-27T07:04:44.812Z","etag":null,"topics":["bash","linting","python","semcod","shellcheck"],"latest_commit_sha":null,"homepage":"https://semcod.github.io/pactfix/","language":"Python","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/semcod.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-28T14:25:30.000Z","updated_at":"2026-06-18T15:54:29.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/semcod/pactfix","commit_stats":null,"previous_names":["wronai/pactown-debug","wronai/pactfix","semcod/pactfix"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/semcod/pactfix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semcod%2Fpactfix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semcod%2Fpactfix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semcod%2Fpactfix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semcod%2Fpactfix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/semcod","download_url":"https://codeload.github.com/semcod/pactfix/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semcod%2Fpactfix/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35035006,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-02T02:00:06.368Z","response_time":173,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["bash","linting","python","semcod","shellcheck"],"created_at":"2026-07-02T06:04:46.544Z","updated_at":"2026-07-02T06:04:47.420Z","avatar_url":"https://github.com/semcod.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pactown Live Debug 🚀\n\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![Docker](https://img.shields.io/badge/docker-ready-brightgreen.svg)](Dockerfile)\n[![ShellCheck](https://img.shields.io/badge/ShellCheck-integrated-orange.svg)](https://www.shellcheck.net/)\n[![Python](https://img.shields.io/badge/python-3.10+-blue.svg)](https://python.org)\n[![Tests](https://img.shields.io/badge/tests-202%20passing-green.svg)](#testing)\n[![E2E](https://img.shields.io/badge/e2e-41%20tests-yellow.svg)](#testing)\n\n\u003e Multi-language code analyzer and auto-fixer with real-time feedback and Docker sandbox testing support.\n\n---\n\n## 📋 Spis treści\n\n- [Features](#-features)\n- [Quick Start](#-quick-start)\n  - [Docker (recommended)](#docker-recommended)\n  - [Without Docker](#-without-docker)\n- [How to Use](#-how-to-use)\n- [Examples](#-examples)\n  - [Bash Script Analysis](#bash-script-analysis)\n  - [Python Code Analysis](#python-code-analysis)\n  - [Dockerfile Analysis](#dockerfile-analysis)\n  - [Multi-language Support](#multi-language-support)\n- [Detected Issues](#-detected-issues)\n- [API Reference](#-api-reference)\n- [Pactfix CLI](#-pactfix-cli-)\n- [Project Structure](#-project-structure)\n- [Development](#-development)\n- [Contributing](#contributing)\n- [License](#license)\n\n---\n\n## ⚡ Features\n\n- ⚡ **Real-time analysis** - Błędy widoczne podczas pisania\n- 🔧 **Auto-fix** - Automatyczne naprawianie typowych błędów\n- 📜 **History tracking** - Pełna historia wykrytych błędów i poprawek\n- 💾 **Export options** - Pobieranie poprawionego skryptu lub kopiowanie do schowka\n- 🐳 **Docker sandbox** - Testowanie poprawek w izolowanym środowisku\n- 🧪 **Multi-language** - Wsparcie dla 24+ języków i formatów\n- 🔄 **Live preview** - Podgląd poprawek w czasie rzeczywistym\n- 📊 **Statistics** - Liczba linii, znaków, błędów i ostrzeżeń\n- 🔗 **Share via URL** - Udostępnianie kodu przez link\n\n# Clone the repository\ngit clone https://github.com/wronai/pactown-debug.git\ncd pactown-debug\n\n# Build and run with Docker Compose\ndocker-compose up --build\n\n# Or directly with Docker\ndocker build -t pactown-debug .\ndocker run -p 8081:8081 pactown-debug\n```\n\nOpen http://localhost:8081 in your browser.\n\n# Requirements: Python 3.10+ and ShellCheck\nsudo apt-get install shellcheck  # Ubuntu/Debian\nbrew install shellcheck           # macOS\n\n# Clone and run\ngit clone https://github.com/wronai/pactown-debug.git\ncd pactown-debug\npip install -e pactfix-py\npython3 server.py\n```\n\n## 📖 How to Use\n\n1. **Paste your code** - Insert your script in the left panel\n2. **Automatic analysis** - Errors are detected in real-time\n3. **View fixes** - Right panel shows corrected code with explanations\n4. **Export** - Download or copy the fixed script\n\n### Bash Script Analysis\n\n**Input (with errors):**\n```bash\n#!/usr/bin/bash\nOUTPUT=/home/student/output-\n\nfor HOST in server{a,b}; do\n    echo \"$(ssh student@${HOST} hostname -f\") \u003e\u003e ${OUTPUT}${HOST}\n    if test -f $OUTPUT/$HOST; then\n        rm -v $OUTPUT/$HOST\n    fi\ndone\n```\n\n**Output (fixed):**\n```bash\n#!/usr/bin/bash\nOUTPUT=/home/student/output-\n\nfor HOST in server{a,b}; do\n    echo \"$(ssh student@${HOST} hostname -f)\" \u003e\u003e ${OUTPUT}${HOST}  # ✅ NAPRAWIONO: Poprawiono pozycję cudzysłowu zamykającego\n    if test -f ${OUTPUT}/${HOST}; then  # ✅ NAPRAWIONO: Dodano klamerki do zmiennych\n        rm -v ${OUTPUT}/${HOST}  # ✅ NAPRAWIONO: Dodano klamerki do zmiennych\n    fi || exit 1  # ✅ NAPRAWIONO: Dodano obsługę błędów dla rm\ndone || exit 1  # ✅ NAPRAWIONO: Dodano obsługę błędów dla for loop\n```\n\n### Python Code Analysis\n\n**Input (with issues):**\n```python\n#!/usr/bin/env python3\nimport os\nimport sys\n\ndef process_data(items=[]):\n    for item in items:\n        if item == None:\n            print \"Item is None\"\n            continue\n        try:\n            result = item * 2\n        except:\n            print \"Error processing item\"\n    return items\n\nif __name__ == \"__main__\":\n    data = [1, 2, None, 4]\n    process_data(data)\n```\n\n**Output (fixed):**\n```python\n#!/usr/bin/env python3\nimport os\nimport sys\n\ndef process_data(items=None):  # ✅ NAPRAWIONO: Unikaj mutable default arguments\n    if items is None:\n        items = []\n    for item in items:\n        if item is None:  # ✅ NAPRAWIONO: Użyj 'is None' zamiast '== None'\n            print(\"Item is None\")  # ✅ NAPRAWIONO: Użyj print() z nawiasami (Python 3)\n            continue\n        try:\n            result = item * 2\n        except Exception as e:  # ✅ NAPRAWIONO: Unikaj bare except, łap konkretny wyjątek\n            print(f\"Error processing item: {e}\")  # ✅ NAPRAWIONO: Użyj f-string i print()\n    return items\n\nif __name__ == \"__main__\":\n    data = [1, 2, None, 4]\n    process_data(data)  # ✅ NAPRAWIONO: Dodano docstring do funkcji\n```\n\n### Dockerfile Analysis\n\n**Input (with issues):**\n```dockerfile\nFROM ubuntu:latest\nRUN apt-get update\nRUN apt-get install -y python3\nCOPY . /app\nWORKDIR /app\nCMD python3 app.py\n```\n\n**Output (fixed):**\n```dockerfile\nFROM ubuntu:latest  # ✅ NAPRAWIONO: Użyj konkretnego tagu zamiast latest\nRUN apt-get update \u0026\u0026 apt-get install -y python3 \u0026\u0026 rm -rf /var/lib/apt/lists/*  # ✅ NAPRAWIONO: Połącz RUN i wyczyść cache\nCOPY . /app\nWORKDIR /app\nCMD [\"python3\", \"app.py\"]  # ✅ NAPRAWIONO: Użyj exec form\n```\n\n### Multi-language Support\n\nPactown Live Debug supports 24+ languages and formats:\n\n| Language | Status | Example |\n|----------|--------|---------|\n| **Bash/Shell** | ✅ Full | `#!/bin/bash` |\n| **Python** | ✅ Full | `def hello():` |\n| **JavaScript** | ✅ Full | `console.log()` |\n| **Dockerfile** | ✅ Full | `FROM node:18` |\n| **Docker Compose** | ✅ Full | `version: '3.8'` |\n| **Kubernetes YAML** | ✅ Full | `apiVersion: v1` |\n| **Terraform** | ✅ Full | `resource \"aws_instance\"` |\n| **SQL** | ✅ Full | `SELECT * FROM` |\n| **Nginx Config** | ✅ Full | `server { ... }` |\n| **GitHub Actions** | ✅ Full | `on: [push]` |\n| **GitLab CI** | ✅ New | `stages: ...` |\n| **Jenkinsfile** | ✅ New | `pipeline { ... }` |\n| **Ansible** | ✅ Full | `---\\n- hosts:` |\n| **Markdown** | ✅ Full | ``` fenced blocks |\n| **JSON** | ✅ Full | `{ \"key\": \"value\" }` |\n| **TOML** | ✅ Full | `[section]` |\n| **INI** | ✅ Full | `key=value` |\n| **And more...** | 🚧 In Progress | PHP, Go, Rust, Java |\n\n### Bash/Shell\n| Code | Description | Example |\n|------|-------------|---------|\n| SC1073 | Syntax errors - misplaced quotes, brackets | `echo \"$(cmd\")` |\n| SC2086 | Unquoted variables | `echo $VAR` |\n| SC2006 | Use backticks instead of $() | ``cmd`` |\n| SC2164 | cd without error handling | `cd /path` |\n| SC2162 | read without -r flag | `read var` |\n\n### Python\n| Code | Description | Example |\n|------|-------------|---------|\n| PY001 | Use print() without parentheses | `print \"text\"` |\n| PY002 | Mutable default arguments | `def func(items=[]):` |\n| PY003 | Use == None instead of is None | `if x == None:` |\n| PY004 | Bare except clause | `except:` |\n| PY005 | Missing docstring | `def func():` |\n\n### Dockerfile\n| Code | Description | Example |\n|------|-------------|---------|\n| DF001 | Use 'latest' tag | `FROM ubuntu:latest` |\n| DF002 | Multiple RUN instructions | `RUN apt-get update`\\n`RUN apt-get install` |\n| DF003 | Missing cache cleanup | `RUN apt-get update` |\n| DF004 | Use shell form of CMD | `CMD python app.py` |\n\n### POST /api/analyze\n\nAnalyzes code and returns fixes for detected issues.\n\n**Request:**\n```json\n{\n  \"code\": \"#!/bin/bash\\necho $VAR\",\n  \"language\": \"bash\"  // optional, auto-detected if not provided\n}\n```\n\n**Response:**\n```json\n{\n  \"originalCode\": \"#!/bin/bash\\necho $VAR\",\n  \"fixedCode\": \"#!/bin/bash\\necho \\\"$VAR\\\"\",\n  \"errors\": [],\n  \"warnings\": [\n    {\n      \"line\": 2,\n      \"column\": 6,\n      \"code\": \"SC2086\",\n      \"message\": \"Double quote to prevent globbing and word splitting\",\n      \"severity\": \"warning\"\n    }\n  ],\n  \"fixes\": [\n    {\n      \"line\": 2,\n      \"message\": \"Dodano cudzysłowy wokół zmiennej\",\n      \"before\": \"echo $VAR\",\n      \"after\": \"echo \\\"$VAR\\\"\"\n    }\n  ],\n  \"language\": \"bash\",\n  \"context\": {}\n}\n```\n\n### GET /api/health\n\nHealth check endpoint.\n\n**Response:**\n```json\n{\n  \"status\": \"healthy\",\n  \"version\": \"1.0.5\",\n  \"features\": {\n    \"shellcheck\": false,\n    \"bash_analysis\": true,\n    \"python_analysis\": true,\n    \"auto_fix\": true,\n    \"pactfix_api\": false,\n    \"pactfix_url\": \"http://pactfix-api:5000\"\n  }\n}\n```\n\n### POST /api/snippet\n\nSave or update a code snippet.\n\n**Request:**\n```json\n{\n  \"code\": \"#!/bin/bash\\necho hello\",\n  \"mode\": \"code\"\n}\n```\n\n**Response:**\n```json\n{\n  \"id\": \"abc123def456\",\n  \"url\": \"http://localhost:8081/#abc123def456\"\n}\n```\n\n## 🛠️ Pactfix CLI\n\nThe project includes the `pactfix` CLI tool for analyzing and auto-fixing code in multiple languages.\n\n### Key Features\n\n- **Project-wide scanning** (`--path`) - Analyze entire projects\n- **Docker sandbox** (`--sandbox`) - Test fixes in containers\n- **Automated testing** (`--test`) - Run tests in sandbox\n- **Multi-language support** - Bash, Python, Go, Node.js, Dockerfile, and more\n\n# Analyze and fix entire project\npactfix --path ./my-project\n\n# Run with Docker sandbox\npactfix --path ./my-project --sandbox\n\n# Sandbox with tests\npactfix --path ./my-project --sandbox --test\n\n# Insert comments above fixes\npactfix --path ./my-project --comment\n\n# Fix specific file\npactfix --file script.sh\n\n# List supported languages\npactfix --list-languages\n```\n\n### Testing with Sandboxes\n\nThe project includes test projects in `pactfix-py/test-projects/`:\n\n```bash\n# Run with in-container tests\nmake test-sandbox-tests\n```\n\nEach test project has `_fixtures/faulty/` with baseline code for deterministic testing.\n\n## 🏗️ Project Structure\n\n```\npactown-debug/\n├── app/                    # Frontend application\n│   ├── index.html         # Main UI\n│   └── assets/            # Static assets\n├── server.py              # Python backend server\n├── pactfix-py/            # Pactfix CLI tool\n│   ├── pactfix/           # Main package\n│   │   ├── analyzer.py    # Core analysis engine\n│   │   ├── analyzers/     # Language-specific analyzers\n│   │   └── cli.py         # CLI interface\n│   ├── test-projects/     # Test projects with fixtures\n│   │   ├── bash-project/\n│   │   ├── python-project/\n│   │   └── ...\n│   └── scripts/           # Test scripts\n├── tests/                 # Backend tests\n├── e2e/                   # E2E tests (Playwright)\n├── Dockerfile             # Container definition\n├── docker-compose.yml     # Docker Compose config\n├── Makefile              # Build and test targets\n├── playwright.config.ts  # Playwright configuration\n└── README.md             # This file\n```\n\n# Sandbox with in-container tests\nmake test-sandbox-tests\n```\n\n### Test Coverage\n\n- **Backend**: 8 tests covering API endpoints\n- **Pactfix CLI**: 202 tests covering all analyzers\n- **E2E**: 41 tests covering UI interactions\n- **Sandbox**: Multiple real-world project scenarios\n\n### Tech Stack\n\n- **Frontend**: Vanilla JavaScript, CSS Grid, CSS Variables\n- **Backend**: Python 3.10+, http.server\n- **Analysis**: ShellCheck (with fallback to built-in analysis)\n- **Testing**: Playwright (E2E), pytest (CLI), unittest (Backend)\n- **Container**: Docker, Alpine-based\n\n### Roadmap\n\n- [x] Support for Python/Node.js/Go/Dockerfile\n- [x] GitLab CI and Jenkinsfile support\n- [ ] AI-powered explanations (llama.cpp)\n- [ ] Collaborative debugging sessions\n- [ ] VSCode extension\n- [ ] More auto-fix rules\n- [ ] Real-time collaboration\n- [ ] Code snippet library\n- [ ] Integration with GitHub PRs\n\n### Contributing\n\nWe welcome contributions! Here's how to get started:\n\n1. **Fork the repository**\n   ```bash\n   git clone https://github.com/your-username/pactown-debug.git\n   ```\n\n2. **Create a feature branch**\n   ```bash\n   git checkout -b feature/amazing-feature\n   ```\n\n3. **Make your changes**\n   - Add tests for new features\n   - Follow the existing code style\n   - Update documentation\n\n4. **Run tests**\n   ```bash\n   make test\n   ```\n\n5. **Commit your changes**\n   ```bash\n   git commit -m 'Add amazing feature'\n   ```\n\n6. **Push to branch**\n   ```bash\n   git push origin feature/amazing-feature\n   ```\n\n7. **Open a Pull Request**\n   - Describe your changes clearly\n   - Link any relevant issues\n   - Ensure CI passes\n\n# Clone the repo\ngit clone https://github.com/wronai/pactown-debug.git\ncd pactown-debug\n\n# Install dependencies\npip install -e pactfix-py[dev]\n\n# Install playwright browsers\nnpx playwright install\n\n# Run tests in watch mode\nmake test-frontend  # E2E tests\nmake test-pactfix   # CLI tests\n```\n\n## 📄 License\n\nApache 2.0 License © 2026 Pactown Team\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**[⬆ Back to top](#pactown-live-debug-)**\n\nBuilt with ❤️ by the [Pactown](https://pactown.dev) team\n\n*Part of the [Pactown](https://pactown.dev) project - Educational platform for juniors*\n\n[![GitHub stars](https://img.shields.io/github/stars/wronai/pactown-debug.svg?style=social\u0026label=Star)](https://github.com/wronai/pactown-debug)\n[![GitHub forks](https://img.shields.io/github/forks/wronai/pactown-debug.svg?style=social\u0026label=Fork)](https://github.com/wronai/pactown-debug/fork)\n[![GitHub issues](https://img.shields.io/github/issues/wronai/pactown-debug.svg)](https://github.com/wronai/pactown-debug/issues)\n[![GitHub pull requests](https://img.shields.io/github/issues-pr/wronai/pactown-debug.svg)](https://github.com/wronai/pactown-debug/pulls)\n\n\u003c/div\u003e\n\n\u003c!-- taskill:status:start --\u003e\n\n## Status\n\n_Last updated by [taskill](https://github.com/oqlos/taskill) at 2026-04-25 13:41 UTC_\n\n| Metric | Value |\n|---|---|\n| HEAD | `5b97217` |\n| Coverage | — |\n| Failing tests | — |\n| Commits in last cycle | 50 |\n\n\u003e A series of release commits plus targeted refactors and docs updates. Notable changes include core architecture cleanup, a new DSL refactor, documentation updates for the changelog (v1.2.0), and addition of code-quality metrics split into six supporting modules.\n\n\u003c!-- taskill:status:end --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsemcod%2Fpactfix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsemcod%2Fpactfix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsemcod%2Fpactfix/lists"}