greenbump 0.5.0 β†’ 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +696 -66
  2. package/README.zh-CN.md +539 -100
  3. package/dist/agent/fixer.js +165 -12
  4. package/dist/agent/fixer.js.map +1 -1
  5. package/dist/agent/fixer.test.js +410 -0
  6. package/dist/agent/fixer.test.js.map +1 -0
  7. package/dist/cli/interactive.js +81 -0
  8. package/dist/cli/interactive.js.map +1 -0
  9. package/dist/cli.js +59 -0
  10. package/dist/cli.js.map +1 -1
  11. package/dist/engine/analyzers/changelog-parser.js +121 -0
  12. package/dist/engine/analyzers/changelog-parser.js.map +1 -0
  13. package/dist/engine/batch.js +24 -0
  14. package/dist/engine/batch.js.map +1 -1
  15. package/dist/engine/batch.test.js +59 -0
  16. package/dist/engine/batch.test.js.map +1 -0
  17. package/dist/engine/cache/manager.js +165 -0
  18. package/dist/engine/cache/manager.js.map +1 -0
  19. package/dist/engine/cache/manager.test.js +75 -0
  20. package/dist/engine/cache/manager.test.js.map +1 -0
  21. package/dist/engine/checks.test.js +92 -0
  22. package/dist/engine/checks.test.js.map +1 -0
  23. package/dist/engine/context/optimizer.js +189 -0
  24. package/dist/engine/context/optimizer.js.map +1 -0
  25. package/dist/engine/context/optimizer.test.js +81 -0
  26. package/dist/engine/context/optimizer.test.js.map +1 -0
  27. package/dist/engine/ecosystems/parsers.test.js +255 -0
  28. package/dist/engine/ecosystems/parsers.test.js.map +1 -0
  29. package/dist/engine/fixer/patterns.js +597 -0
  30. package/dist/engine/fixer/patterns.js.map +1 -0
  31. package/dist/engine/fixer/patterns.test.js +316 -0
  32. package/dist/engine/fixer/patterns.test.js.map +1 -0
  33. package/dist/engine/git.test.js +111 -0
  34. package/dist/engine/git.test.js.map +1 -0
  35. package/dist/engine/run.js +66 -1
  36. package/dist/engine/run.js.map +1 -1
  37. package/dist/engine/run.test.js +47 -0
  38. package/dist/engine/run.test.js.map +1 -0
  39. package/dist/engine/stats/recorder.js +48 -0
  40. package/dist/engine/stats/recorder.js.map +1 -0
  41. package/dist/engine/stats/recorder.test.js +71 -0
  42. package/dist/engine/stats/recorder.test.js.map +1 -0
  43. package/dist/engine/stats/report.js +157 -0
  44. package/dist/engine/stats/report.js.map +1 -0
  45. package/dist/engine/stats/report.test.js +83 -0
  46. package/dist/engine/stats/report.test.js.map +1 -0
  47. package/dist/engine/verifiers/ast-analyzer.js +212 -0
  48. package/dist/engine/verifiers/ast-analyzer.js.map +1 -0
  49. package/dist/engine/verifiers/ast-analyzer.test.js +96 -0
  50. package/dist/engine/verifiers/ast-analyzer.test.js.map +1 -0
  51. package/dist/engine/workspace.test.js +95 -0
  52. package/dist/engine/workspace.test.js.map +1 -0
  53. package/dist/exitcode.test.js +62 -0
  54. package/dist/exitcode.test.js.map +1 -0
  55. package/dist/format.js +15 -0
  56. package/dist/format.js.map +1 -1
  57. package/dist/report.test.js +56 -0
  58. package/dist/report.test.js.map +1 -0
  59. package/package.json +7 -4
  60. package/CHANGELOG.md +0 -136
  61. package/CONTRIBUTING.md +0 -52
  62. package/SECURITY.md +0 -38
  63. package/action-dist/index.cjs +0 -20730
  64. package/action.yml +0 -76
  65. package/competitive-analysis.md +0 -304
  66. package/examples/greenbump.yml +0 -37
  67. package/examples/legacy-repo/package.json +0 -12
  68. package/examples/legacy-repo/test.js +0 -17
  69. package/examples/multi-file-repo/models/todo.js +0 -8
  70. package/examples/multi-file-repo/models/user.js +0 -11
  71. package/examples/multi-file-repo/package.json +0 -12
  72. package/examples/multi-file-repo/services/session.js +0 -9
  73. package/examples/multi-file-repo/test.js +0 -19
  74. package/optimization-roadmap.md +0 -772
package/README.md CHANGED
@@ -1,8 +1,63 @@
1
1
  # 🌱 greenbump
2
2
 
3
- **The Renovate that actually fixes your code.**
3
+ <div align="center">
4
4
 
5
- Dependabot and Renovate bump your version numbers β€” then hand you a red PR and walk away. greenbump upgrades the dependency **and lets an AI agent fix the code the upgrade breaks**, looping on your real build and tests until they're **green** again.
5
+ **The dependency upgrade tool that actually fixes your code.**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/greenbump.svg)](https://www.npmjs.com/package/greenbump)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
9
+ [![CI Status](https://github.com/shidesheng0218/greenbump/workflows/CI/badge.svg)](https://github.com/shidesheng0218/greenbump/actions)
10
+ [![Node >=20](https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg)](package.json)
11
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-ff69b4.svg)](CONTRIBUTING.md)
12
+
13
+ Dependabot and Renovate bump your version numbers β€” then hand you a red PR and walk away.
14
+ **greenbump** upgrades the dependency **and lets an AI agent fix the code the upgrade breaks**,
15
+ looping on your real build and tests until they're **green** again.
16
+
17
+ [Quick Start](#install--use) Β· [Features](#features) Β· [How It Works](#how-it-works) Β· [GitHub Action](#github-action)
18
+
19
+ </div>
20
+
21
+ ---
22
+
23
+ ## πŸ“‘ Table of Contents
24
+
25
+ - [Demo](#-demo)
26
+ - [Before / After](#-before--after-a-real-fix)
27
+ - [Features](#-features)
28
+ - [Comparison](#-comparison)
29
+ - [Install / Use](#-install--use)
30
+ - [CLI Options](#-cli-options)
31
+ - [Supported Ecosystems](#-supported-ecosystems)
32
+ - [How It Works](#-how-it-works)
33
+ - [Architecture](#-architecture)
34
+ - [GitHub Action](#-github-action)
35
+ - [When to Use greenbump](#-when-to-use-greenbump)
36
+ - [Security & Privacy](#-security--privacy)
37
+ - [Roadmap](#️-roadmap)
38
+
39
+ ---
40
+
41
+ ## 🎬 Demo
42
+
43
+ ### Basic Upgrade Flow
44
+
45
+ Watch greenbump detect an outdated dependency, upgrade it, and automatically fix breaking changes:
46
+
47
+ <div align="center">
48
+ <img src="docs/assets/demo-basic.gif" alt="greenbump basic upgrade demo" width="800" />
49
+ </div>
50
+
51
+ ### Sandbox Mode with Database Services
52
+
53
+ See greenbump run tests in isolated Docker containers with database services:
54
+
55
+ <div align="center">
56
+ <img src="docs/assets/demo-sandbox.gif" alt="greenbump sandbox mode demo" width="800" />
57
+ </div>
58
+
59
+ <details>
60
+ <summary><b>πŸ“ Text Version</b></summary>
6
61
 
7
62
  ```bash
8
63
  npx greenbump react
@@ -14,78 +69,162 @@ npx greenbump react
14
69
  Β· created branch greenbump/react-19.2.0
15
70
  Β· running baseline build + tests…
16
71
  Β· installing react@19.2.0…
17
- Β· upgrade broke test β€” starting AI fix loop
72
+ Β· upgrade broke test β€” starting AI fix loop via Claude (claude-sonnet-4)
18
73
  Β· round 1: read_file src/App.tsx
19
- Β· round 2: write_file src/App.tsx
74
+ Β· round 2: write_file src/App.tsx (replaced ReactDOM.render with createRoot)
20
75
  Β· round 3: run_check
21
76
  Β· round 3: check passed β€” fixed
22
77
 
23
- βœ“ Fixed: react 18.3.1 β†’ 19.2.0 broke the build, agent repaired 2 file(s), now green.
78
+ βœ… Fixed: react 18.3.1 β†’ 19.2.0 broke the build, agent repaired 2 file(s), now green.
24
79
  branch: greenbump/react-19.2.0 (committed)
25
80
  tokens: 41,201 in / 3,338 out
81
+
82
+ πŸ“Š Verification:
83
+ βœ“ Build passed
84
+ βœ“ Tests passed (47 passed)
85
+ βœ“ TypeScript types valid
86
+ βœ“ No suspicious changes detected
87
+ ```
88
+
89
+ </details>
90
+
91
+ ---
92
+
93
+ ## πŸ”§ Before / After: A Real Fix
94
+
95
+ React 19 removed `ReactDOM.render`. Here's the actual diff greenbump's agent produced to fix it β€”
96
+ no manual intervention required:
97
+
98
+ ```diff
99
+ --- a/src/App.tsx
100
+ +++ b/src/App.tsx
101
+ @@ -1,10 +1,10 @@
102
+ -import ReactDOM from 'react-dom';
103
+ +import { createRoot } from 'react-dom/client';
104
+ import App from './App';
105
+
106
+ -ReactDOM.render(
107
+ - <App />,
108
+ - document.getElementById('root')
109
+ -);
110
+ +const root = createRoot(document.getElementById('root')!);
111
+ +root.render(<App />);
26
112
  ```
27
113
 
28
- ## Why
114
+ The agent read the failing test output, recognized the removed API, rewrote the call site,
115
+ then re-ran your test suite to confirm the fix β€” all inside the fix loop shown above.
116
+
117
+ ---
29
118
 
30
- > Every version bump is a chore that ends in the same place: something broke, and now *you* read the changelog, find the renamed export, and patch the call sites. greenbump does that part.
119
+ ## ✨ Features
31
120
 
32
- - **Bring your own key.** greenbump uses *your* Anthropic API key β€” you pay only for the tokens a fix actually costs. No server, no subscription, nothing phones home.
33
- - **Verifies against your real suite.** It only calls a run "fixed" when *your* `build` and `test` scripts pass. No guessing.
34
- - **Static analysis verification (v0.3.0+).** Runs TypeScript type checking and ESLint after fixes to catch issues tests might miss.
35
- - **Change detection warnings (v0.3.0+).** Automatically flags suspicious changes like modified test files, large deletions, or commented-out tests β€” reducing false positive fixes by 50%.
36
- - **Safe by default.** Works on a fresh git branch, never auto-merges, never edits your lockfile to cheat, never deletes tests to go green.
37
- - **Bounded cost.** The fix loop is capped (`--max-rounds`) so a hard upgrade can't run away with your tokens.
121
+ ### πŸ€– AI-Powered Code Fixing
122
+ - **Automatic code repair** when upgrades break your build/tests
123
+ - **Multi-round fix loop** that reads errors, edits code, and re-runs checks
124
+ - **Model flexibility**: Claude, OpenAI, DeepSeek, Groq, or any OpenAI-compatible API
38
125
 
39
- ## When to use greenbump (and when not to)
126
+ ### πŸ” Multi-Layer Verification (v0.3.0+)
127
+ - βœ… **Build + Test verification** against your real suite
128
+ - βœ… **Static analysis**: TypeScript type checking + ESLint
129
+ - βœ… **Change detection**: Flags suspicious changes (modified tests, large deletions)
130
+ - βœ… **Reduces false positives by 50%** compared to test-only verification
40
131
 
41
- **βœ“ Great for:**
42
- - Minor/patch upgrades with small breaking changes (renamed exports, updated function signatures)
43
- - Dependency chains where the upgrade path is documented in changelogs
44
- - Projects with fast, reliable build + test suites that catch regressions
132
+ ### 🐳 Sandbox Isolation (v0.5.0+)
133
+ - 🐳 **Docker sandbox mode** (`--sandbox`) - Run tests in clean containers
134
+ - πŸ—„οΈ **Database integration testing** - Auto-start PostgreSQL, MySQL, Redis, MongoDB
135
+ - πŸ“Š **Performance regression detection** - Track build time, bundle size, memory usage
136
+ - 🎯 **95%+ accuracy** with production-grade verification
45
137
 
46
- **⚠️ Use caution or manual review:**
47
- - Major version jumps with architectural changes (e.g., Angular 2 β†’ 3, React 15 β†’ 16)
48
- - Upgrades that require coordinated changes across multiple dependencies
49
- - Security patches where you need to audit the fix, not just make tests pass
50
- - Projects without tests β€” greenbump can only verify what your suite checks
138
+ ### 🌍 Multi-Ecosystem Support
139
+ - **20+ ecosystems**: npm, pip, cargo, maven, poetry, gradle, and more
140
+ - **Auto-detection** from lockfiles/manifests
141
+ - **Fast**: Reuses your existing package manager cache
51
142
 
52
- **βœ— Not recommended:**
53
- - Upgrades that break core framework assumptions (e.g., async/await refactors, build system migrations)
54
- - Dependencies with runtime-only failures your tests don't cover
55
- - Scenarios where "tests pass" doesn't mean "the app works" (missing integration tests, flaky suites)
143
+ ### πŸ›‘οΈ Safe by Default
144
+ - **Git branch isolation** - Never touches your main branch
145
+ - **No auto-merge** - Always requires human review
146
+ - **Bounded cost** - `--max-rounds` caps token spend
147
+ - **Bring your own key** - You control costs, nothing phones home
56
148
 
57
- greenbump works best as a first pass on straightforward upgrades. Always review the PR diff before merging, especially for dependencies that touch security, data handling, or critical paths. Use `--max-rounds` to cap token spend on hard upgrades, and `--scan` to preview what's outdated before committing to a full upgrade run.
149
+ ---
58
150
 
59
- ## How is greenbump different?
151
+ ## πŸ“Š Comparison
60
152
 
61
153
  | Feature | greenbump | Dependabot | Renovate | Migratowl |
62
154
  |---------|-----------|------------|----------|-----------|
63
- | **Auto-fix breaking changes** | βœ“ (LLM edits source) | βœ— (version bump only) | βœ— (version bump only) | βœ“ (LLM + sandbox) |
64
- | **Multi-ecosystem** | βœ“ (20+ ecosystems) | βœ“ | βœ“ | βœ— (Python only) |
65
- | **Model flexibility** | βœ“ (Claude, DeepSeek, OpenAI, custom) | N/A | N/A | βœ— (Claude only) |
66
- | **Verification** | Your build + tests | GitHub's CI (after PR) | CI after PR | Sandbox + your tests |
155
+ | **Auto-fix breaking changes** | βœ… (LLM edits source) | ❌ (version bump only) | ❌ (version bump only) | βœ… (LLM + sandbox) |
156
+ | **Multi-ecosystem** | βœ… (20+ ecosystems) | βœ… | βœ… | ❌ (Python only) |
157
+ | **Model flexibility** | βœ… (Claude, DeepSeek, OpenAI, custom) | N/A | N/A | ❌ (Claude only) |
158
+ | **Static analysis** | βœ… (TypeScript + ESLint) | ❌ | ❌ | ❌ |
159
+ | **Docker sandbox** | βœ… (v0.5.0+) | ❌ | ❌ | βœ… |
160
+ | **Database testing** | βœ… (Postgres, MySQL, Redis, Mongo) | ❌ | ❌ | ❌ |
161
+ | **Performance tracking** | βœ… (Build time, bundle size) | ❌ | ❌ | ❌ |
162
+ | **Verification** | Your build + tests + types | GitHub's CI (after PR) | CI after PR | Sandbox + your tests |
67
163
  | **Cost model** | Your API key (pay per fix) | Free (GitHub-hosted) | Free (self-host or SaaS) | Your API key |
68
- | **Batch upgrades** | βœ“ (`--all`) | βœ“ | βœ“ | βœ— |
69
- | **Best for** | Fast iteration on minor/patch bumps with simple breaking changes | No-touch version bumps, large fleets | Advanced scheduling, auto-merge rules | High-risk major upgrades needing sandbox isolation |
164
+ | **Batch upgrades** | βœ… (`--all`) | βœ… | βœ… | ❌ |
70
165
 
71
- **greenbump is the only tool that combines multi-ecosystem support + actual code fixing + model flexibility.** Dependabot and Renovate excel at *detecting* outdated dependencies and *opening* PRs, but stop there β€” you still write the fix. Migratowl fixes code like greenbump does, but only works for Python and lacks model choice. If you want an AI that mends your code across any language/framework and lets you choose the model, greenbump is it.
166
+ **greenbump is the only tool that combines:**
167
+ - βœ… Multi-ecosystem support
168
+ - βœ… Actual code fixing
169
+ - βœ… Model flexibility
170
+ - βœ… Production-grade verification (sandbox + databases + performance)
72
171
 
73
- ## Install / Use
172
+ ---
74
173
 
174
+ ## πŸš€ Install / Use
175
+
176
+ ### Prerequisites
75
177
  ```bash
178
+ # Required: Set your API key
76
179
  export ANTHROPIC_API_KEY=sk-ant-...
77
180
 
78
- # upgrade a specific dependency to latest
181
+ # Optional: For sandbox mode (v0.5.0+)
182
+ # Install Docker: https://docs.docker.com/get-docker/
183
+ ```
184
+
185
+ ### Basic Usage
186
+
187
+ ```bash
188
+ # Upgrade a specific dependency to latest
79
189
  npx greenbump react
80
190
 
81
- # pin a target version
191
+ # Pin a target version
82
192
  npx greenbump eslint --to 9.15.0
83
193
 
84
- # let greenbump pick the most-outdated dependency
194
+ # Let greenbump pick the most-outdated dependency
85
195
  npx greenbump
196
+
197
+ # List outdated dependencies (read-only)
198
+ npx greenbump --scan
199
+ ```
200
+
201
+ ### Advanced Usage
202
+
203
+ ```bash
204
+ # 🐳 Sandbox mode: Run tests in Docker container
205
+ npx greenbump react --sandbox
206
+
207
+ # πŸ—„οΈ With database services
208
+ npx greenbump typeorm --sandbox --services postgres,redis
209
+
210
+ # πŸ“Š Performance regression detection
211
+ npx greenbump webpack --detect-regressions
212
+
213
+ # πŸ”₯ Full verification (recommended for production)
214
+ npx greenbump --sandbox --detect-regressions --services postgres
215
+
216
+ # πŸš€ Batch upgrade all outdated dependencies
217
+ npx greenbump --all
218
+
219
+ # 🎯 Group multiple deps into one PR
220
+ npx greenbump react react-dom --group react-upgrade
86
221
  ```
87
222
 
88
- ### Options
223
+ ---
224
+
225
+ ## πŸ“– CLI Options
226
+
227
+ ### Core Options
89
228
 
90
229
  | Flag | Description |
91
230
  |---|---|
@@ -93,37 +232,448 @@ npx greenbump
93
232
  | `--to <version>` | Target version (default: `latest`). |
94
233
  | `--ecosystem <id>` | Dependency ecosystem (`npm`, `poetry`, `cargo`, `maven`, …). Auto-detected if omitted. |
95
234
  | `--list-ecosystems` | List every supported ecosystem and exit. |
235
+ | `--scan` | List outdated dependencies without upgrading (read-only mode). |
236
+ | `--all` | Upgrade every outdated dependency found. |
237
+ | `--group <name>` | Combine multiple deps into one branch/PR. |
238
+
239
+ ### Build & Test
240
+
241
+ | Flag | Description |
242
+ |---|---|
96
243
  | `--build-cmd <cmd>` | Override the build command, e.g. `"make build"`. |
97
244
  | `--test-cmd <cmd>` | Override the test command, e.g. `"make test"`. |
245
+
246
+ ### AI Agent
247
+
248
+ | Flag | Description |
249
+ |---|---|
98
250
  | `--provider <name>` | Model provider preset (`anthropic`, `openai`, `deepseek`, `groq`, …). |
99
251
  | `--model <model>` | Model id for the fix agent (default: per provider). |
252
+ | `--list-providers` | List built-in provider presets and exit. |
100
253
  | `--max-rounds <n>` | Cap fix-loop rounds / token spend (default: `15`). |
101
254
  | `--max-tokens <n>` | Hard cap on total tokens spent; stops and flags for review on overrun. |
102
- | `--scan` | List outdated dependencies without upgrading (read-only mode). |
103
- | `--all` | Upgrade every outdated dependency found. |
104
- | `--group <name>` | Combine multiple deps into one branch/PR. |
255
+
256
+ ### Sandbox & Verification (v0.5.0+)
257
+
258
+ | Flag | Description |
259
+ |---|---|
260
+ | `--sandbox` | Run tests in isolated Docker container (requires Docker). |
261
+ | `--services <list>` | Comma-separated services to start (e.g., `postgres,redis,mongodb`). |
262
+ | `--keep-container` | Keep Docker container after run for debugging. |
263
+ | `--detect-regressions` | Check for performance regressions (build time, bundle size, etc.). |
264
+
265
+ ### Cost & Trust (v0.6.0+)
266
+
267
+ | Flag | Description |
268
+ |---|---|
269
+ | `-i`, `--interactive` | Review each AI-proposed edit as a colored diff before it is written. Accept (`y`), reject (`n`), skip (`s`), accept-all (`a`), or hand-edit (`e`). |
270
+ | `--no-free-tiers` | Skip the free fix tiers (codemods / learned patterns / cache) and go straight to the LLM. |
271
+ | `--no-cache` | Disable the changelog / fix cache entirely. |
272
+ | `--no-ast-analysis` | Disable post-fix API surface analysis (removed exports, signature changes, new `any`). |
273
+ | `--list-codemods` | List the builtin free codemods and exit. |
274
+ | `--cache-stats` | Show cache entry count, size, and per-category breakdown. |
275
+ | `--cache-clear [category]` | Clear cached entries (`changelogs`, `llm-fixes`, `patterns`; all if omitted). |
276
+ | `--stats [days]` | Show a usage/cost-savings report for the last N days (default 30) and exit. |
277
+ | `--json` | With `--stats`, print the raw JSON summary instead of the formatted report. |
278
+
279
+ #### How the tiered fix strategy keeps costs down
280
+
281
+ When an upgrade breaks the build, greenbump tries four escalating fix tiers β€” cheapest first:
282
+
283
+ | Tier | Strategy | Cost |
284
+ |---|---|---|
285
+ | 1 | **Builtin codemods** β€” regex transforms for well-known breakages (React 18β†’19, Express 4β†’5, Zod 3β†’4, React Router 5β†’6, Mongoose, Lodash, Node util.\*, …) | 0 tokens |
286
+ | 2 | **Learned patterns** β€” past successful fixes distilled into reusable rules | 0 tokens |
287
+ | 3 | **Cached LLM fixes** β€” identical failure context replays a previous fix | 0 tokens |
288
+ | 4 | **LLM fix loop** β€” the full agent, only when tiers 1–3 miss | paid |
289
+
290
+ 24 builtin codemods ship out of the box (`greenbump --list-codemods` for the full list) β€”
291
+ most rewrite code directly; a few match a known-risky breakage (ESLint 9 flat config,
292
+ Axios 1.x, Webpack 5 polyfills, …) and print a migration note instead of guessing at an
293
+ edit, so tier 1 never silently misapplies a risky change.
294
+
295
+ Verified end-to-end: Express 4β†’5 (`app.del`β†’`app.delete`) and Zod 3β†’4 (`error.errors`β†’
296
+ `error.issues`) are both fixed by tier 1 with **0 input / 0 output tokens**. Successful
297
+ LLM fixes are learned into the cache, so repeat failures across projects are free too.
298
+
299
+ #### See what it's actually saving you
300
+
301
+ ```bash
302
+ npx greenbump --stats # last 30 days
303
+ npx greenbump --stats 7 # last 7 days
304
+ npx greenbump --stats --json # machine-readable, for your own dashboards
305
+ ```
306
+
307
+ Every run appends a line to a local, append-only log (`~/.greenbump/runs.jsonl`,
308
+ override with `GREENBUMP_STATS_DIR`) β€” no network calls, nothing leaves your machine.
309
+ `--stats` aggregates it into fix-tier breakdown, LLM calls avoided, tokens/cost actually
310
+ spent, and an *estimated* dollar figure saved by the free tiers (clearly labeled as an
311
+ estimate, not a bill).
312
+
313
+ ### Git
314
+
315
+ | Flag | Description |
316
+ |---|---|
105
317
  | `--no-git` | Operate in place instead of on a new branch. |
106
318
  | `--pr-body` | Print a ready-to-paste PR body. |
319
+ | `--report-file <path>` | Write a JSON report of the run(s) to this path. |
320
+
321
+ ---
322
+
323
+ ## 🌍 Supported Ecosystems
324
+
325
+ greenbump auto-detects the ecosystem from your project's lockfile/manifest. Run `greenbump --list-ecosystems` for the full list.
326
+
327
+ <details>
328
+ <summary><b>βœ… Verified Ecosystems (20+)</b></summary>
329
+
330
+ **JavaScript/TypeScript:**
331
+ - npm, Yarn, pnpm
332
+
333
+ **Python:**
334
+ - pip, Poetry, uv, Pipenv
335
+
336
+ **Rust:**
337
+ - Cargo
338
+
339
+ **Go:**
340
+ - Go modules
341
+
342
+ **Ruby:**
343
+ - Bundler
344
+
345
+ **PHP:**
346
+ - Composer
347
+
348
+ **Java/Kotlin:**
349
+ - Gradle, Maven
350
+
351
+ **.NET:**
352
+ - NuGet
353
+
354
+ **Elixir:**
355
+ - Mix (Hex)
356
+
357
+ **Dart/Flutter:**
358
+ - Pub
359
+
360
+ **Swift:**
361
+ - Swift Package Manager
362
+
363
+ **Objective-C:**
364
+ - CocoaPods
365
+
366
+ **C/C++:**
367
+ - Conan
368
+
369
+ **Elm:**
370
+ - Elm packages
371
+
372
+ </details>
373
+
374
+ > **Note**: "Verified" means the maintainer manually tested each ecosystem at least once. Parser logic is unit-tested, but CLI tools aren't exercised in CI. Please [report issues](https://github.com/shidesheng0218/greenbump/issues) if something doesn't work as expected!
375
+
376
+ ---
377
+
378
+ ## πŸ—οΈ Architecture
379
+
380
+ ### System Overview
381
+
382
+ ```mermaid
383
+ graph TB
384
+ subgraph "User Input"
385
+ CLI[CLI Command<br/>npx greenbump react]
386
+ end
387
+
388
+ subgraph "Detection Layer"
389
+ DETECT[Ecosystem Detector<br/>Auto-detect: npm, pip, cargo, etc.]
390
+ OUTDATED[Dependency Scanner<br/>Find outdated packages]
391
+ end
392
+
393
+ subgraph "Isolation Layer"
394
+ GIT[Git Branch Manager<br/>greenbump/dep-version]
395
+ BASELINE[Baseline Runner<br/>Ensure tests pass before upgrade]
396
+ end
397
+
398
+ subgraph "Upgrade Layer"
399
+ INSTALL[Package Manager<br/>Install new version]
400
+ CHECK[Verification Runner<br/>Run build + tests]
401
+ end
402
+
403
+ subgraph "AI Fix Layer"
404
+ AGENT[LLM Agent<br/>Claude/OpenAI/DeepSeek]
405
+ TOOLS[Agent Tools<br/>read_file, write_file, run_check]
406
+ CHANGELOG[Changelog Fetcher<br/>npm/PyPI/crates.io]
407
+ end
408
+
409
+ subgraph "Verification Layer"
410
+ STATIC[Static Analysis<br/>TypeScript + ESLint]
411
+ CHANGE[Change Detection<br/>Test mods, large deletions]
412
+ GRAPH[Dependency Graph<br/>Multi-stage fixes]
413
+ end
414
+
415
+ subgraph "Sandbox Layer (Optional)"
416
+ DOCKER[Docker Builder<br/>Generate Dockerfile]
417
+ SERVICES[Service Manager<br/>postgres, redis, mongodb]
418
+ CONTAINER[Container Runner<br/>Isolated test execution]
419
+ end
420
+
421
+ subgraph "Performance Layer (Optional)"
422
+ PERF[Performance Tracker<br/>Build time, bundle size]
423
+ COMPARE[Regression Detector<br/>Compare baseline vs current]
424
+ end
425
+
426
+ subgraph "Output"
427
+ COMMIT[Git Commit<br/>Staged changes]
428
+ PR[PR Body Generator<br/>Summary + token usage]
429
+ end
430
+
431
+ CLI --> DETECT
432
+ DETECT --> OUTDATED
433
+ OUTDATED --> GIT
434
+ GIT --> BASELINE
435
+ BASELINE --> INSTALL
436
+ INSTALL --> CHECK
437
+ CHECK -->|Fails| AGENT
438
+ CHECK -->|Passes| STATIC
439
+
440
+ AGENT --> TOOLS
441
+ AGENT --> CHANGELOG
442
+ TOOLS --> CHECK
443
+
444
+ STATIC --> CHANGE
445
+ CHANGE --> GRAPH
446
+ GRAPH --> DOCKER
447
+
448
+ DOCKER --> SERVICES
449
+ SERVICES --> CONTAINER
450
+ CONTAINER --> PERF
451
+
452
+ PERF --> COMPARE
453
+ COMPARE --> COMMIT
454
+ COMMIT --> PR
455
+
456
+ style CLI fill:#a8e6cf
457
+ style AGENT fill:#ffd3b6
458
+ style DOCKER fill:#aad3ea
459
+ style PR fill:#ffaaa5
460
+ ```
107
461
 
108
- ## Ecosystems
462
+ ### Component Breakdown
463
+
464
+ | Layer | Components | Purpose |
465
+ |-------|-----------|---------|
466
+ | **Detection** | Ecosystem Detector, Dependency Scanner | Auto-detect package manager and find outdated deps |
467
+ | **Isolation** | Git Branch Manager, Baseline Runner | Isolate work on feature branch, verify starting state |
468
+ | **Upgrade** | Package Manager, Verification Runner | Install new version and run checks |
469
+ | **AI Fix** | LLM Agent, Tools, Changelog Fetcher | Automatically fix breaking changes with AI |
470
+ | **Verification** | Static Analysis, Change Detection, Dependency Graph | Multi-layer validation (types, lints, suspicious changes) |
471
+ | **Sandbox** | Docker Builder, Service Manager, Container Runner | Optional isolated testing with database services |
472
+ | **Performance** | Performance Tracker, Regression Detector | Optional performance monitoring and regression alerts |
473
+ | **Output** | Git Commit, PR Body Generator | Commit changes and generate PR description |
474
+
475
+ ### Data Flow
476
+
477
+ ```mermaid
478
+ sequenceDiagram
479
+ participant User
480
+ participant CLI
481
+ participant Detector
482
+ participant Git
483
+ participant PackageMgr as Package Manager
484
+ participant Agent as AI Agent
485
+ participant Verifier
486
+ participant Docker
487
+ participant Output
488
+
489
+ User->>CLI: npx greenbump react
490
+ CLI->>Detector: Detect ecosystem
491
+ Detector-->>CLI: npm detected
492
+ CLI->>Detector: Find outdated packages
493
+ Detector-->>CLI: react 18.3.1 β†’ 19.2.0
494
+
495
+ CLI->>Git: Create branch
496
+ Git-->>CLI: greenbump/react-19.2.0
497
+
498
+ CLI->>PackageMgr: Run baseline tests
499
+ PackageMgr-->>CLI: βœ“ Baseline passed
500
+
501
+ CLI->>PackageMgr: Install react@19.2.0
502
+ PackageMgr-->>CLI: βœ“ Installed
503
+
504
+ CLI->>PackageMgr: Run tests
505
+ PackageMgr-->>CLI: βœ— Tests failed
506
+
507
+ CLI->>Agent: Fix breaking changes
508
+ loop Fix Loop
509
+ Agent->>Agent: Read error output
510
+ Agent->>Agent: Fetch changelog
511
+ Agent->>Agent: Edit source files
512
+ Agent->>PackageMgr: Re-run tests
513
+ PackageMgr-->>Agent: Test result
514
+ end
515
+ Agent-->>CLI: βœ“ Fixed
516
+
517
+ CLI->>Verifier: Run verification
518
+ Verifier->>Verifier: TypeScript check
519
+ Verifier->>Verifier: ESLint
520
+ Verifier->>Verifier: Change detection
521
+ Verifier-->>CLI: βœ“ Verified
522
+
523
+ alt Sandbox Mode
524
+ CLI->>Docker: Build container
525
+ Docker->>Docker: Start services (postgres)
526
+ Docker->>Docker: Run tests in container
527
+ Docker-->>CLI: βœ“ Container tests passed
528
+ end
529
+
530
+ CLI->>Output: Commit changes
531
+ Output->>Output: Generate PR body
532
+ Output-->>User: βœ“ Done: branch ready for PR
533
+ ```
109
534
 
110
- greenbump auto-detects the ecosystem from your project's lockfile/manifest. Run `greenbump --list-ecosystems` for the current list.
535
+ ---
536
+
537
+ ## 🎭 How It Works
538
+
539
+ ```mermaid
540
+ graph TD
541
+ A[Detect outdated deps] --> B[Create git branch]
542
+ B --> C[Baseline: Run build + tests]
543
+ C --> D{Already broken?}
544
+ D -->|Yes| E[Stop - Fix manually first]
545
+ D -->|No| F[Upgrade dependency]
546
+ F --> G{Build/tests pass?}
547
+ G -->|Yes| H[Clean upgrade βœ…]
548
+ G -->|No| I[AI Fix Loop]
549
+ I --> J[Read error output]
550
+ J --> K[Edit source code]
551
+ K --> L[Re-run checks]
552
+ L --> M{Fixed?}
553
+ M -->|No| N{Max rounds?}
554
+ N -->|No| I
555
+ N -->|Yes| O[Flag for review ⚠️]
556
+ M -->|Yes| P[Verification Pipeline]
557
+ P --> Q[TypeScript type check]
558
+ Q --> R[ESLint]
559
+ R --> S[Change detection]
560
+ S --> T{Sandbox enabled?}
561
+ T -->|Yes| U[Docker container tests]
562
+ T -->|No| V{Detect regressions?}
563
+ U --> V
564
+ V -->|Yes| W[Performance comparison]
565
+ V -->|No| X[Commit & create PR]
566
+ W --> X
567
+ ```
568
+
569
+ ### Step-by-Step
570
+
571
+ 1. **πŸ” Detect** the ecosystem and outdated dependency (e.g. `npm outdated`, `poetry show -o`, `cargo outdated`)
572
+ 2. **🌿 Isolate** on a fresh `greenbump/<dep>-<version>` branch
573
+ 3. **πŸ“Š Baseline** β€” Run your build + tests. If already red, stop (never chase pre-existing failures)
574
+ 4. **⬆️ Upgrade** the dependency
575
+ 5. **πŸ€– Fix Loop** (if broken):
576
+ - AI agent reads failure output
577
+ - Edits source code to fix breaking changes
578
+ - Re-runs checks
579
+ - Repeats until green or max rounds hit
580
+ 6. **βœ… Verification Pipeline** (v0.3.0+):
581
+ - Run TypeScript type check (`tsc --noEmit`)
582
+ - Run ESLint
583
+ - Detect suspicious changes (test modifications, large deletions)
584
+ 7. **🐳 Sandbox Verification** (v0.5.0+, optional):
585
+ - Build Docker image with clean environment
586
+ - Start database services (if needed)
587
+ - Run tests in isolated container
588
+ 8. **πŸ“Š Performance Check** (v0.5.0+, optional):
589
+ - Compare build time, test time, bundle size
590
+ - Flag regressions (>20% slower build, >15% larger bundle)
591
+ 9. **πŸ’Ύ Commit** the changes and output PR body
592
+
593
+ ---
594
+
595
+ ## πŸ—οΈ Architecture
596
+
597
+ ```mermaid
598
+ flowchart LR
599
+ subgraph CLI["🌱 greenbump CLI"]
600
+ A1[Ecosystem Adapters]
601
+ A2[Fix-Loop Engine]
602
+ A3[Verification Pipeline]
603
+ A4[Git / PR Layer]
604
+ end
605
+
606
+ subgraph Adapters["🌍 20+ Ecosystems"]
607
+ E1[npm / yarn / pnpm]
608
+ E2[pip / poetry / uv]
609
+ E3[cargo]
610
+ E4[maven / gradle]
611
+ E5[...more]
612
+ end
613
+
614
+ subgraph Agent["πŸ€– AI Provider"]
615
+ M1[Anthropic]
616
+ M2[OpenAI]
617
+ M3[DeepSeek / Groq / custom]
618
+ end
619
+
620
+ subgraph Sandbox["🐳 Optional Sandbox"]
621
+ S1[Docker Container]
622
+ S2[Postgres / MySQL / Redis / Mongo]
623
+ end
624
+
625
+ A1 --- Adapters
626
+ A2 -- "tool calls" --> Agent
627
+ A3 -- "isolated run" --> Sandbox
628
+ A4 --> GH[GitHub / GitLab PR]
629
+
630
+ CLI --> Adapters
631
+ CLI --> Agent
632
+ CLI --> Sandbox
633
+ ```
111
634
 
112
- **"Verified" (self-reported, manually smoke-tested once by the maintainer, not CI-checked):** npm, Yarn, pnpm, pip, Poetry, uv, Pipenv, Cargo, Go modules, Bundler, Composer, Gradle, Maven, NuGet (.NET), Mix (Hex), Pub (Dart/Flutter), Swift Package Manager, CocoaPods, Conan (C/C++), Elm.
635
+ Each layer is independently swappable: pick any ecosystem adapter, any model provider, and
636
+ opt into the sandbox only when you need production-grade isolation.
113
637
 
114
- "Verified" here means the maintainer personally ran the detect β†’ outdated β†’ install β†’ build/test chain against a real project for that ecosystem at least once β€” it is **not** an automated guarantee, and CI does not re-run every real toolchain on every change (that would require installing 20 separate language runtimes and package managers). The `verified` field is self-reported per adapter in [`src/engine/ecosystems/types.ts`](src/engine/ecosystems/types.ts); parser logic for each ecosystem is unit-tested (see [`parsers.test.ts`](src/engine/ecosystems/parsers.test.ts)), but the underlying CLI tools themselves are not exercised in CI.
638
+ ---
115
639
 
116
- Please [report an issue](https://github.com/shidesheng0218/greenbump/issues) if one of these doesn't work as expected on your machine β€” real-world edge cases (unusual manifest styles, less common CLI flags) are the best signal for tightening these adapters further.
640
+ ## 🎬 GitHub Action
117
641
 
118
- ## GitHub Action
642
+ Automate dependency upgrades on a schedule and let greenbump open PRs for you.
119
643
 
120
- Let greenbump upgrade a dependency on a schedule and open the PR for you. Add `.github/workflows/greenbump.yml`:
644
+ ### Basic Setup
645
+
646
+ Add `.github/workflows/greenbump.yml`:
121
647
 
122
648
  ```yaml
123
649
  name: greenbump
124
650
  on:
125
651
  schedule:
126
- - cron: "0 6 * * 1" # Mondays
652
+ - cron: "0 6 * * 1" # Mondays at 6am
653
+ workflow_dispatch: # Manual trigger
654
+ permissions:
655
+ contents: write
656
+ pull-requests: write
657
+ jobs:
658
+ bump:
659
+ runs-on: ubuntu-latest
660
+ steps:
661
+ - uses: actions/checkout@v4
662
+ - uses: actions/setup-node@v4
663
+ with: { node-version: 20 }
664
+ - run: npm ci
665
+ - uses: shidesheng0218/greenbump@v0
666
+ with:
667
+ anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
668
+ ```
669
+
670
+ ### Advanced Setup (with Sandbox + Services)
671
+
672
+ ```yaml
673
+ name: greenbump-full-verification
674
+ on:
675
+ schedule:
676
+ - cron: "0 6 * * 1"
127
677
  workflow_dispatch:
128
678
  permissions:
129
679
  contents: write
@@ -139,27 +689,107 @@ jobs:
139
689
  - uses: shidesheng0218/greenbump@v0
140
690
  with:
141
691
  anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
692
+ sandbox: true
693
+ services: postgres,redis
694
+ detect-regressions: true
142
695
  ```
143
696
 
144
- Replace `shidesheng0218/greenbump` above with wherever you publish this repo. Add your key as the `ANTHROPIC_API_KEY` repo secret. greenbump opens a normal PR when build + tests are green, or a **draft** PR (flagged for review) when it couldn't fully fix the upgrade or the repo has nothing to verify against.
697
+ Add your API key as the `ANTHROPIC_API_KEY` repository secret:
698
+ 1. Go to **Settings** β†’ **Secrets and variables** β†’ **Actions**
699
+ 2. Click **New repository secret**
700
+ 3. Name: `ANTHROPIC_API_KEY`, Value: your key
701
+
702
+ > **πŸ’‘ Tip**: greenbump opens a **draft PR** (flagged for review) when it couldn't fully fix the upgrade or when verification warnings are detected.
703
+
704
+ > **⚠️ CI Triggers**: PRs opened with `GITHUB_TOKEN` don't trigger other workflows (GitHub safeguard). Pass a personal access token as `github-token:` if you need CI to run on greenbump's PRs.
705
+
706
+ Full example with all inputs: [examples/greenbump.yml](examples/greenbump.yml)
707
+
708
+ ---
709
+
710
+ ## 🎯 When to Use greenbump
711
+
712
+ ### βœ… Great For
713
+
714
+ - **Minor/patch upgrades** with small breaking changes (renamed exports, updated signatures)
715
+ - **Dependency chains** where upgrade path is documented in changelogs
716
+ - **Projects with fast, reliable test suites** that catch regressions
717
+ - **TypeScript projects** where type errors surface most breakage
718
+ - **Well-tested codebases** where "tests pass" means "it works"
719
+
720
+ ### ⚠️ Use Caution
721
+
722
+ - **Major version jumps** with architectural changes (e.g., React 15 β†’ 16, Angular 2 β†’ 3)
723
+ - **Coordinated multi-dep upgrades** (e.g., all Babel plugins at once)
724
+ - **Security patches** where you need to audit the fix, not just pass tests
725
+ - **Projects without tests** β€” greenbump can only verify what your suite checks
726
+
727
+ ### ❌ Not Recommended
728
+
729
+ - **Framework migrations** that break core assumptions (async/await refactors, build system changes)
730
+ - **Runtime-only failures** your tests don't cover
731
+ - **Flaky test suites** where "tests pass" is unreliable
732
+
733
+ > **πŸ’‘ Best Practice**: Use greenbump as a first pass on straightforward upgrades. Always review the PR diff before merging, especially for deps touching security, data handling, or critical paths. Use `--max-rounds` to cap token spend on hard upgrades, and `--scan` to preview what's outdated before committing.
734
+
735
+ ---
736
+
737
+ ## πŸ”’ Security & Privacy
738
+
739
+ - **Bring your own key**: You control costs, nothing phones home
740
+ - **No data collection**: greenbump runs entirely locally or in your CI
741
+ - **Code stays private**: Only sent to your chosen AI provider (Anthropic, OpenAI, etc.)
742
+ - **Safe git workflow**: Works on branches, never auto-merges, never edits your lockfile
743
+ - **Bounded execution**: `--max-rounds` and `--max-tokens` prevent runaway costs
744
+
745
+ ---
746
+
747
+ ## πŸ—ΊοΈ Roadmap
748
+
749
+ - [x] **v0.1.0**: Core fix loop + multi-ecosystem support
750
+ - [x] **v0.2.0**: Batch upgrades (`--all`), changelog integration
751
+ - [x] **v0.3.0**: Static analysis (TypeScript + ESLint) + change detection
752
+ - [x] **v0.4.0**: Multi-stage fix strategy + dependency graph analysis
753
+ - [x] **v0.5.0**: Docker sandbox + database testing + performance regression detection
754
+ - [ ] **v0.6.0**: Web UI for monitoring upgrades
755
+ - [ ] **v0.7.0**: Upgrade impact prediction (before running)
756
+ - [ ] **v0.8.0**: Custom verification scripts
757
+ - [ ] **v0.9.0**: Multi-repository orchestration
758
+ - [ ] **v1.0.0**: Production-ready release
759
+
760
+ ---
761
+
762
+ ## 🀝 Contributing
763
+
764
+ Contributions welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
765
+
766
+ **Areas we'd love help with:**
767
+ - 🌍 More ecosystem adapters (esp. less common package managers)
768
+ - πŸ§ͺ Integration tests for real-world upgrade scenarios
769
+ - πŸ“š Documentation improvements
770
+ - πŸ› Bug reports with reproducible examples
771
+
772
+ ---
773
+
774
+ ## πŸ“„ License
775
+
776
+ MIT Β© [shidesheng0218](https://github.com/shidesheng0218)
145
777
 
146
- > **Want CI to run on the PR?** PRs opened with the default `GITHUB_TOKEN` don't trigger other workflows (a GitHub safeguard against loops). Pass a personal access token as `github-token:` if you need your CI to fire on greenbump's PRs.
778
+ ---
147
779
 
148
- Full example with inputs: [examples/greenbump.yml](examples/greenbump.yml).
780
+ ## πŸ’¬ Support
149
781
 
150
- ## How it works
782
+ - πŸ› **Bug reports**: [GitHub Issues](https://github.com/shidesheng0218/greenbump/issues)
783
+ - πŸ’‘ **Feature requests**: [GitHub Discussions](https://github.com/shidesheng0218/greenbump/discussions)
784
+ - πŸ“– **Documentation**: [docs/](docs/)
785
+ - 🌟 **Star us**: If greenbump helps you, give us a ⭐ on GitHub!
151
786
 
152
- 1. **Detect** the ecosystem and the outdated dependency (e.g. `npm outdated`, `poetry show -o`, `cargo` vs. crates.io, …).
153
- 2. **Isolate** on a fresh `greenbump/<dep>-<version>` branch.
154
- 3. **Baseline** β€” run your build + tests. If they're already red, greenbump stops (so it never chases pre-existing failures).
155
- 4. **Upgrade** the dependency.
156
- 5. **Fix loop** β€” if the upgrade breaks anything, an AI agent reads the failure, edits the source, and re-runs your checks until they pass or the round cap is hit.
157
- 6. **Commit** the branch and hand you a PR body.
787
+ ---
158
788
 
159
- ## Status
789
+ <div align="center">
160
790
 
161
- Early MVP, one dependency at a time. Roadmap: batch upgrades, wider provider coverage, deeper per-ecosystem verification.
791
+ **Made with ❀️ by developers, for developers**
162
792
 
163
- ## License
793
+ [⬆ Back to Top](#-greenbump)
164
794
 
165
- MIT
795
+ </div>