{"id":50974385,"url":"https://github.com/coder11125/patchwork","last_synced_at":"2026-06-19T06:02:24.862Z","repository":{"id":358819937,"uuid":"1243216403","full_name":"coder11125/patchwork","owner":"coder11125","description":"Patchwork — The Autonomous Dependency Surgeon","archived":false,"fork":false,"pushed_at":"2026-05-19T07:06:54.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-19T09:04:58.875Z","etag":null,"topics":["agentic-workflow","ai","dependencies","persistent-memory","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coder11125.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-05-19T06:36:49.000Z","updated_at":"2026-05-19T07:06:58.000Z","dependencies_parsed_at":"2026-05-19T09:06:00.666Z","dependency_job_id":null,"html_url":"https://github.com/coder11125/patchwork","commit_stats":null,"previous_names":["coder11125/patchwork"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/coder11125/patchwork","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder11125%2Fpatchwork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder11125%2Fpatchwork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder11125%2Fpatchwork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder11125%2Fpatchwork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coder11125","download_url":"https://codeload.github.com/coder11125/patchwork/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder11125%2Fpatchwork/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34519052,"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-06-19T02:00:06.005Z","response_time":61,"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":["agentic-workflow","ai","dependencies","persistent-memory","python"],"created_at":"2026-06-19T06:02:24.069Z","updated_at":"2026-06-19T06:02:24.856Z","avatar_url":"https://github.com/coder11125.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Patchwork\n\n**BYOK (Bring Your Own Key) autonomous dependency upgrade framework.**\n\nPatchwork detects outdated packages, analyzes changelogs for breaking changes, plans migration strategies, applies codemods, runs tests in isolation, and opens pull requests. It learns from each attempt by writing reusable recipes to disk.\n\n## Features\n\n- **Multi-ecosystem detection** — Go modules, npm, pip (requirements.txt), Cargo (Cargo.toml), Ruby (Gemfile), Maven (pom.xml)\n- **Breaking change analysis** — GitHub releases, changelog parsing, semver risk assessment, LLM-powered analysis\n- **Recipe-driven learning** — Successful upgrades are saved as reusable recipes; future upgrades match against historical knowledge\n- **Safe codemod application** — Regex-based transformations, manifest updates (go.mod, package.json, requirements.txt, Cargo.toml, Gemfile, pom.xml)\n- **Isolated test execution** — Tests run in temp directories before changes touch your working tree\n- **PR automation** — Creates GitHub/GitLab pull requests for each upgrade\n- **Full pipeline** — `patchwork run` chains detect → analyze → plan → apply → pr\n- **OS keychain integration** — API keys and tokens stored in native OS keychain (macOS Keychain, Linux Secret Service, Windows Credential Manager)\n- **BYOK** — Bring your own LLM API key. Supports Anthropic Claude, Mistral, Groq, and local Ollama\n- **Local-first** — Works fully offline with Ollama as the default provider\n- **CLI-first** — Single binary, no server required\n\n## Architecture\n\n```\n┌─────────────────────────────────────────────────────────────────────┐\n│                         patchwork CLI                               │\n│  configure │ detect │ analyze │ plan │ apply │ pr │ run │ serve      │\n└────────────────────────┬────────────────────────────────────────────┘\n                         │\n┌────────────────────────▼────────────────────────────────────────────┐\n│                        Pipeline                                     │\n│  Detect → Analyze → Plan → Apply → PR                               │\n└────┬──────────┬─────────┬────────┬────────┬─────────────────────────┘\n     │          │         │        │        │\n┌────▼───┐ ┌───▼────┐ ┌──▼────┐ ┌─▼─────┐ ┌▼────────┐\n│Detector│ │Analyzer│ │Planner│ │Codemod│ │TestRunner│\n│Registry│ │Registry│ │       │ │Registry│ │Registry  │\n└────┬───┘ └───┬────┘ └──┬────┘ └─┬─────┘ └┬────────┘\n     │          │         │        │        │\n   ┌──▼────┐  ┌──▼──┐   ┌──▼──┐  ┌─▼──────┐ ┌─▼────────┐\n   │go.mod  │  │GitHub│  │Recipe│  │regex   │ │go test   │\n   │pkg.json│  │release│  │Store │  │go.mod  │ │npm test  │\n   │req.txt │  │semver │  │      │  │pkg.json│ │cargo test│\n   │Cargo   │  │LLM   │  │      │  │req.txt │ │bundle    │\n   │.toml   │  │      │  │      │  │Cargo   │ │exec      │\n   │Gemfile │  │      │  │      │  │.toml   │ │rspec     │\n   │pom.xml │  │      │  │      │  │Gemfile │ │mvn test  │\n   └────────┘  └──────┘  └──────┘  │pom.xml │ └──────────┘\n                                   └────────┘           │\n                                                  ┌─────▼─────┐\n                                                  │   PRCreator │\n                                                  │  GitHub API │\n                                                  │  GitLab API │\n                                                  └─────────────┘\n```\n\n### Package Layout\n\n| Package | Responsibility |\n|---|---|\n| `cmd/patchwork` | Single entry point, wires CLI |\n| `internal/cli` | Cobra commands: configure, detect, analyze, plan, apply, pr, run, serve |\n| `internal/config` | Koanf-based config loading (defaults → YAML → keychain → env → flags) |\n| `internal/detector` | Package detectors for Go, npm, pip, Cargo, Ruby, Maven ecosystems |\n| `internal/analyzer` | Changelog fetching, semver risk, LLM-powered breaking change analysis |\n| `internal/planner` | Upgrade plan generation with recipe matching and risk ordering |\n| `internal/codemod` | Code transformation engine (regex, go.mod, package.json, requirements.txt, Cargo.toml, Gemfile, pom.xml) |\n| `internal/testrunner` | Isolated test execution for Go, npm, Cargo, Ruby (Bundler), and Maven |\n| `internal/pr` | PR creation via GitHub/GitLab REST APIs |\n| `internal/recipe` | Disk-based recipe store and episode recording |\n| `internal/pipeline` | Full workflow orchestration |\n| `internal/llm` | LLM provider abstraction (Anthropic, Mistral, Groq, Ollama) |\n| `internal/keyring` | OS keychain integration for API keys and tokens |\n| `pkg/domain` | Core domain types (Package, Upgrade, Recipe, Episode, etc.) |\n| `pkg/git` | Git operations wrapper |\n| `pkg/semver` | Semantic version utilities |\n\n## Install\n\n### curl (recommended)\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/coder11125/patchwork/main/install.sh | bash\n```\n\nInstall to a custom directory:\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/coder11125/patchwork/main/install.sh | INSTALL_DIR=$HOME/.local/bin bash\n```\n\nInstall a specific version:\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/coder11125/patchwork/main/install.sh | bash -s -- v0.1.0\n```\n\n### From source\n\n```bash\ngit clone https://github.com/coder11125/patchwork.git\ncd patchwork\nmake build\n./bin/patchwork --help\n```\n\n### With Go install\n\n```bash\ngo install github.com/coder11125/patchwork/cmd/patchwork@latest\n```\n\n### Make targets\n\n```bash\nmake build        # Build binary to bin/patchwork\nmake test         # Run tests with coverage\nmake lint         # Run gofmt check and go vet\nmake install      # Build and install to /usr/local/bin\nmake clean        # Remove build artifacts\nmake help         # Show all targets\n```\n\n## Configuration\n\nPatchwork reads configuration in this precedence order: defaults → `~/.patchwork.yaml` → OS keychain → `PATCHWORK_*` env vars → CLI flags.\n\n### Quick setup via CLI\n\n```bash\n# Interactively store API keys in your OS keychain\npatchwork configure\n```\n\nThis stores your LLM API key and Git token in the native OS keychain (macOS Keychain, Linux Secret Service, Windows Credential Manager). These are never written to disk or exposed in plaintext.\n\n### Environment variables\n\n```bash\n# LLM provider (required)\nexport PATCHWORK_LLM_PROVIDER=ollama        # anthropic, mistral, groq, ollama\nexport PATCHWORK_LLM_MODEL=llama3.2         # model name\nexport PATCHWORK_LLM_API_KEY=sk-...         # required for cloud providers\nexport PATCHWORK_LLM_BASE_URL=http://localhost:11434  # for Ollama\n\n# Git/PR (optional, for pr command)\nexport PATCHWORK_GIT_PLATFORM=github        # github, gitlab\nexport PATCHWORK_GIT_TOKEN=ghp_...          # personal access token\nexport PATCHWORK_GIT_OWNER=coder11125\nexport PATCHWORK_GIT_REPO=myproject\nexport PATCHWORK_GIT_PR_BRANCH=main\nexport PATCHWORK_GIT_REMOTE=origin\n\n# Behavior\nexport PATCHWORK_DRY_RUN=false\nexport PATCHWORK_SKIP_TESTS=false\nexport PATCHWORK_VERBOSE=false\nexport PATCHWORK_MAX_RETRIES=3\n\n# Directories\nexport PATCHWORK_RECIPE_DIR=~/.patchwork/recipes\nexport PATCHWORK_EPISODE_DIR=~/.patchwork/episodes\nexport PATCHWORK_CACHE_DIR=~/.patchwork/cache\n```\n\n### Config file (`~/.patchwork.yaml`)\n\n```yaml\nllm_provider: anthropic\nllm_model: claude-sonnet-4-20250514\nllm_api_key: sk-ant-...\n\ngit_platform: github\ngit_token: ghp_...\ngit_owner: coder11125\ngit_repo: myproject\ngit_pr_branch: main\n\ndry_run: false\nskip_tests: false\nverbose: true\nmax_retries: 3\n```\n\nAPI keys and tokens can be omitted from the config file and env vars if stored via `patchwork configure` — Patchwork falls back to the OS keychain automatically.\n\n## Usage\n\n### Configure credentials\n\n```bash\n# Store LLM API key and Git token in OS keychain\npatchwork configure\n```\n\n### Detect outdated packages\n\n```bash\n# Scan current directory\npatchwork detect\n\n# Scan specific directory, output as JSON\npatchwork detect --dir /path/to/repo --format json\n\n# Filter by ecosystem\npatchwork detect --ecosystem cargo --output results.json\n```\n\n### Analyze packages for breaking changes\n\n```bash\n# Analyze all detected packages\npatchwork analyze\n\n# Analyze specific package\npatchwork analyze --package serde --ecosystem cargo\n```\n\n### Generate upgrade plan\n\n```bash\n# Generate plan from current directory\npatchwork plan\n\n# Output as JSON\npatchwork plan --format json\n```\n\n### Apply upgrades\n\n```bash\n# Apply upgrades (generates fresh plan)\npatchwork apply\n\n# Apply from a saved plan file\npatchwork apply --plan plan.json\n\n# Dry run (show what would be done)\npatchwork apply --dry-run\n```\n\n### Create pull requests\n\n```bash\n# Create PRs for all upgrades\npatchwork pr\n\n# Requires git_platform and git_token in config or keychain\n```\n\n### Run full pipeline\n\n```bash\n# Detect → analyze → plan → apply → PR\npatchwork run\n\n# Dry run (stops after plan)\npatchwork run --dry-run\n\n# Skip tests\npatchwork run --skip-tests\n```\n\n### API Server\n\nPatchwork can run as an HTTP API server for programmatic access. All CLI commands are available as REST endpoints.\n\n```bash\n# Start API server on default port 8080\npatchwork serve\n\n# Custom port and working directory\npatchwork serve --addr :3000 --dir /path/to/repo\n```\n\n#### Endpoints\n\n| Method | Path | Description |\n|---|---|---|\n| `GET` | `/health` | Health check |\n| `POST` | `/detect` | Scan directory for outdated packages |\n| `POST` | `/plan` | Generate upgrade plan |\n| `POST` | `/run` | Execute full pipeline |\n\n#### Examples\n\n```bash\n# Health check\ncurl http://localhost:8080/health\n\n# Detect outdated packages\ncurl -X POST http://localhost:8080/detect \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"dir\": \"/path/to/repo\"}'\n\n# Generate upgrade plan\ncurl -X POST http://localhost:8080/plan \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"dir\": \"/path/to/repo\"}'\n\n# Run full pipeline\ncurl -X POST http://localhost:8080/run \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"dir\": \"/path/to/repo\"}'\n```\n\n## LLM Providers\n\n| Provider | Env Var | Default Model | Notes |\n|---|---|---|---|\n| **Ollama** | `PATCHWORK_LLM_PROVIDER=ollama` | `llama3.2` | Local, no API key needed |\n| **Anthropic** | `PATCHWORK_LLM_PROVIDER=anthropic` | `claude-sonnet-4-20250514` | Requires `PATCHWORK_LLM_API_KEY` |\n| **Mistral** | `PATCHWORK_LLM_PROVIDER=mistral` | `mistral-large-latest` | Requires `PATCHWORK_LLM_API_KEY` |\n| **Groq** | `PATCHWORK_LLM_PROVIDER=groq` | `llama-3.3-70b-versatile` | Requires `PATCHWORK_LLM_API_KEY` |\n\n## Recipe System\n\nEvery upgrade attempt is recorded as an **Episode**. Successful episodes generate or update **Recipes** stored as JSON on disk. Future upgrades query the recipe store before falling back to LLM analysis.\n\nRecipes live in `~/.patchwork/recipes/` as `{recipeID}.json`. Episodes live in `~/.patchwork/episodes/` as `{episodeID}.json`.\n\n### Recipe format\n\n```json\n{\n  \"id\": \"rec-go-gin-v2\",\n  \"name\": \"Gin v1 to v2 migration\",\n  \"description\": \"Upgrade gin-gonic/gin from v1.x to v2.x\",\n  \"ecosystem\": \"go\",\n  \"package_name\": \"github.com/gin-gonic/gin\",\n  \"from_version\": \"\u003c2.0.0\",\n  \"to_version\": \"\u003e=2.0.0\",\n  \"steps\": [\n    {\n      \"order\": 1,\n      \"type\": \"codemod\",\n      \"description\": \"Update import path\",\n      \"pattern\": \"github.com/gin-gonic/gin\",\n      \"replacement\": \"github.com/gin-gonic/gin/v2\",\n      \"file_globs\": [\"**/*.go\"]\n    },\n    {\n      \"order\": 2,\n      \"type\": \"config_change\",\n      \"description\": \"Update go.mod\",\n      \"file_globs\": [\"go.mod\"]\n    }\n  ],\n  \"success_rate\": 0.95,\n  \"times_used\": 12\n}\n```\n\n## Design Principles\n\n- **No Python runtime** — Pure Go binary\n- **No OpenAI SDK** — Direct HTTP calls to each provider's REST API\n- **No external SDKs** — GitHub/GitLab via raw REST, git via CLI wrapper, crates.io via raw REST\n- **Explicit error handling** — No panics, no `must*` functions\n- **Interfaces for testability** — Every external dependency is behind an interface\n- **Local-first** — Ollama works fully offline; recipes bridge cloud and local modes\n- **CLI-first** — Single binary, no daemon, no web UI\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoder11125%2Fpatchwork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoder11125%2Fpatchwork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoder11125%2Fpatchwork/lists"}