codeshift 0.3.5__tar.gz → 0.3.7__tar.gz

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 (118) hide show
  1. codeshift-0.3.7/PKG-INFO +472 -0
  2. codeshift-0.3.7/README.md +416 -0
  3. codeshift-0.3.7/codeshift.egg-info/PKG-INFO +472 -0
  4. {codeshift-0.3.5 → codeshift-0.3.7}/pyproject.toml +4 -4
  5. codeshift-0.3.5/PKG-INFO +0 -368
  6. codeshift-0.3.5/README.md +0 -312
  7. codeshift-0.3.5/codeshift.egg-info/PKG-INFO +0 -368
  8. {codeshift-0.3.5 → codeshift-0.3.7}/LICENSE +0 -0
  9. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/__init__.py +0 -0
  10. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/analyzer/__init__.py +0 -0
  11. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/analyzer/risk_assessor.py +0 -0
  12. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/api/__init__.py +0 -0
  13. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/api/auth.py +0 -0
  14. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/api/config.py +0 -0
  15. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/api/database.py +0 -0
  16. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/api/main.py +0 -0
  17. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/api/models/__init__.py +0 -0
  18. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/api/models/auth.py +0 -0
  19. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/api/models/billing.py +0 -0
  20. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/api/models/migrate.py +0 -0
  21. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/api/models/usage.py +0 -0
  22. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/api/routers/__init__.py +0 -0
  23. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/api/routers/auth.py +0 -0
  24. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/api/routers/billing.py +0 -0
  25. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/api/routers/migrate.py +0 -0
  26. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/api/routers/usage.py +0 -0
  27. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/api/routers/webhooks.py +0 -0
  28. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/cli/__init__.py +0 -0
  29. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/cli/commands/__init__.py +0 -0
  30. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/cli/commands/apply.py +0 -0
  31. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/cli/commands/auth.py +0 -0
  32. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/cli/commands/diff.py +0 -0
  33. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/cli/commands/scan.py +0 -0
  34. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/cli/commands/upgrade.py +0 -0
  35. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/cli/commands/upgrade_all.py +0 -0
  36. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/cli/main.py +0 -0
  37. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/cli/package_manager.py +0 -0
  38. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/cli/quota.py +0 -0
  39. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge/__init__.py +0 -0
  40. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge/cache.py +0 -0
  41. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge/generator.py +0 -0
  42. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge/models.py +0 -0
  43. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge/parser.py +0 -0
  44. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge/sources.py +0 -0
  45. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge_base/__init__.py +0 -0
  46. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge_base/libraries/aiohttp.yaml +0 -0
  47. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge_base/libraries/attrs.yaml +0 -0
  48. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge_base/libraries/celery.yaml +0 -0
  49. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge_base/libraries/click.yaml +0 -0
  50. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge_base/libraries/django.yaml +0 -0
  51. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge_base/libraries/fastapi.yaml +0 -0
  52. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge_base/libraries/flask.yaml +0 -0
  53. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge_base/libraries/httpx.yaml +0 -0
  54. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge_base/libraries/marshmallow.yaml +0 -0
  55. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge_base/libraries/numpy.yaml +0 -0
  56. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge_base/libraries/pandas.yaml +0 -0
  57. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge_base/libraries/pydantic.yaml +0 -0
  58. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge_base/libraries/pytest.yaml +0 -0
  59. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge_base/libraries/requests.yaml +0 -0
  60. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge_base/libraries/sqlalchemy.yaml +0 -0
  61. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge_base/loader.py +0 -0
  62. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/knowledge_base/models.py +0 -0
  63. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/__init__.py +0 -0
  64. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/ast_transforms.py +0 -0
  65. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/engine.py +0 -0
  66. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/llm_migrator.py +0 -0
  67. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/transforms/__init__.py +0 -0
  68. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/transforms/aiohttp_transformer.py +0 -0
  69. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/transforms/attrs_transformer.py +0 -0
  70. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/transforms/celery_transformer.py +0 -0
  71. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/transforms/click_transformer.py +0 -0
  72. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/transforms/django_transformer.py +0 -0
  73. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/transforms/fastapi_transformer.py +0 -0
  74. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/transforms/flask_transformer.py +0 -0
  75. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/transforms/httpx_transformer.py +0 -0
  76. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/transforms/marshmallow_transformer.py +0 -0
  77. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/transforms/numpy_transformer.py +0 -0
  78. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/transforms/pandas_transformer.py +0 -0
  79. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/transforms/pydantic_v1_to_v2.py +0 -0
  80. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/transforms/pytest_transformer.py +0 -0
  81. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/transforms/requests_transformer.py +0 -0
  82. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/migrator/transforms/sqlalchemy_transformer.py +0 -0
  83. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/scanner/__init__.py +0 -0
  84. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/scanner/code_scanner.py +0 -0
  85. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/scanner/dependency_parser.py +0 -0
  86. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/utils/__init__.py +0 -0
  87. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/utils/api_client.py +0 -0
  88. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/utils/cache.py +0 -0
  89. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/utils/config.py +0 -0
  90. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/utils/llm_client.py +0 -0
  91. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/validator/__init__.py +0 -0
  92. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/validator/syntax_checker.py +0 -0
  93. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift/validator/test_runner.py +0 -0
  94. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift.egg-info/SOURCES.txt +0 -0
  95. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift.egg-info/dependency_links.txt +0 -0
  96. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift.egg-info/entry_points.txt +0 -0
  97. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift.egg-info/requires.txt +0 -0
  98. {codeshift-0.3.5 → codeshift-0.3.7}/codeshift.egg-info/top_level.txt +0 -0
  99. {codeshift-0.3.5 → codeshift-0.3.7}/setup.cfg +0 -0
  100. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_aiohttp_transforms.py +0 -0
  101. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_attrs_transforms.py +0 -0
  102. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_celery_transforms.py +0 -0
  103. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_click_transforms.py +0 -0
  104. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_code_scanner.py +0 -0
  105. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_django_transforms.py +0 -0
  106. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_fastapi_transforms.py +0 -0
  107. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_flask_transforms.py +0 -0
  108. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_httpx_transforms.py +0 -0
  109. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_knowledge_base.py +0 -0
  110. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_marshmallow_transforms.py +0 -0
  111. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_numpy_transforms.py +0 -0
  112. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_pandas_transforms.py +0 -0
  113. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_pydantic_transforms.py +0 -0
  114. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_pytest_transforms.py +0 -0
  115. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_requests_transforms.py +0 -0
  116. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_risk_assessor.py +0 -0
  117. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_sqlalchemy_transforms.py +0 -0
  118. {codeshift-0.3.5 → codeshift-0.3.7}/tests/test_syntax_checker.py +0 -0
@@ -0,0 +1,472 @@
1
+ Metadata-Version: 2.4
2
+ Name: codeshift
3
+ Version: 0.3.7
4
+ Summary: AI-powered CLI tool that migrates Python code to handle breaking dependency changes
5
+ Author: PyResolve Team
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Ragab-Technologies/Codeshift
8
+ Project-URL: Repository, https://github.com/Ragab-Technologies/Codeshift
9
+ Project-URL: Issues, https://github.com/Ragab-Technologies/Codeshift/issues
10
+ Keywords: migration,dependencies,ast,refactoring,pydantic
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: click>=8.0
23
+ Requires-Dist: libcst>=1.0
24
+ Requires-Dist: anthropic>=0.20
25
+ Requires-Dist: pyyaml>=6.0
26
+ Requires-Dist: rich>=13.0
27
+ Requires-Dist: toml>=0.10
28
+ Requires-Dist: packaging>=23.0
29
+ Requires-Dist: httpx>=0.25
30
+ Requires-Dist: pytest>=8.4.2
31
+ Requires-Dist: nox>=2025.11.12
32
+ Requires-Dist: black>=24.10.0
33
+ Requires-Dist: mypy>=1.19.1
34
+ Requires-Dist: supabase>=2.27.2
35
+ Requires-Dist: pre-commit>=4.5.1
36
+ Provides-Extra: api
37
+ Requires-Dist: fastapi>=0.109.0; extra == "api"
38
+ Requires-Dist: uvicorn>=0.27.0; extra == "api"
39
+ Requires-Dist: supabase>=2.3.0; extra == "api"
40
+ Requires-Dist: stripe>=7.0.0; extra == "api"
41
+ Requires-Dist: pydantic-settings>=2.1.0; extra == "api"
42
+ Requires-Dist: email-validator>=2.0.0; extra == "api"
43
+ Provides-Extra: dev
44
+ Requires-Dist: pytest>=7.0; extra == "dev"
45
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
46
+ Requires-Dist: black<25.0,>=24.0; extra == "dev"
47
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
48
+ Requires-Dist: mypy>=1.0; extra == "dev"
49
+ Requires-Dist: nox>=2024.0; extra == "dev"
50
+ Requires-Dist: pre-commit>=3.6.0; extra == "dev"
51
+ Requires-Dist: types-toml>=0.10; extra == "dev"
52
+ Requires-Dist: types-PyYAML>=6.0; extra == "dev"
53
+ Provides-Extra: all
54
+ Requires-Dist: codeshift[api,dev]; extra == "all"
55
+ Dynamic: license-file
56
+
57
+ # Codeshift
58
+
59
+ [![PyPI version](https://badge.fury.io/py/codeshift.svg)](https://pypi.org/project/codeshift/)
60
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
61
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
62
+
63
+ **Don't just flag the update. Fix the break.**
64
+
65
+ Codeshift is an AI-powered CLI tool that migrates Python code when dependencies are upgraded. Unlike Dependabot or Renovate which only bump version numbers, Codeshift rewrites your code to be compatible with new library APIs.
66
+
67
+ ## Why Codeshift?
68
+
69
+ Upgrading a dependency often means updating dozens of call sites to match a new API. Codeshift automates that:
70
+
71
+ - **Scans** your project for outdated dependencies
72
+ - **Detects** breaking changes from changelogs and migration guides
73
+ - **Rewrites** your code using deterministic AST transforms or LLM assistance
74
+ - **Shows** a detailed diff with explanations before touching any file
75
+
76
+ ## Features
77
+
78
+ - **Deterministic AST transforms** for 15 popular libraries (no LLM required)
79
+ - **Auto-generated knowledge bases** - fetches changelogs and migration guides from GitHub, parses them with an LLM to detect breaking changes
80
+ - **Tiered migration engine** - deterministic transforms first, KB-guided LLM second, pure LLM fallback last
81
+ - **Confidence-based change detection** - shows HIGH/MEDIUM/LOW confidence breaking changes before migration
82
+ - **Beautiful diff output** with per-change explanations
83
+ - **Backup and restore** so you can safely revert
84
+ - **Batch upgrades** - migrate all outdated dependencies in one command
85
+
86
+ ## Supported Libraries
87
+
88
+ ### Tier 1 (Deterministic AST Transforms - Free, No LLM Required)
89
+
90
+ | Library | Migration Path | Status |
91
+ |---------|---------------|--------|
92
+ | Pydantic | v1 → v2 | Supported |
93
+ | FastAPI | 0.x → 0.100+ | Supported |
94
+ | SQLAlchemy | 1.4 → 2.0 | Supported |
95
+ | Pandas | 1.x → 2.x | Supported |
96
+ | Requests | Various | Supported |
97
+ | Django | 3.x → 4.x/5.x | Supported |
98
+ | Flask | 1.x → 2.x/3.x | Supported |
99
+ | NumPy | 1.x → 2.x | Supported |
100
+ | attrs | attr → attrs | Supported |
101
+ | Celery | 4.x → 5.x | Supported |
102
+ | Click | 7.x → 8.x | Supported |
103
+ | aiohttp | 2.x → 3.x | Supported |
104
+ | httpx | 0.x → 0.24+ | Supported |
105
+ | Marshmallow | 2.x → 3.x | Supported |
106
+ | pytest | 6.x → 7.x/8.x | Supported |
107
+
108
+ ### Any Library (Auto-Generated Knowledge Base)
109
+
110
+ Codeshift can migrate **any Python library** by automatically fetching changelogs from GitHub and detecting breaking changes. For libraries not in Tier 1, it uses KB-guided or pure LLM migration.
111
+
112
+ ## Installation
113
+
114
+ ```bash
115
+ pip install codeshift
116
+ ```
117
+
118
+ For development:
119
+
120
+ ```bash
121
+ pip install codeshift[dev]
122
+ ```
123
+
124
+ Verify the installation:
125
+
126
+ ```bash
127
+ codeshift --help
128
+ ```
129
+
130
+ ## Quick Start
131
+
132
+ ```bash
133
+ # 1. Scan your project for outdated dependencies
134
+ codeshift scan
135
+
136
+ # 2. Upgrade a specific library
137
+ codeshift upgrade pydantic --target 2.5.0
138
+
139
+ # 3. Review the proposed changes
140
+ codeshift diff
141
+
142
+ # 4. Apply the changes
143
+ codeshift apply
144
+
145
+ # 5. Run your tests to verify
146
+ pytest
147
+ ```
148
+
149
+ Or upgrade everything at once:
150
+
151
+ ```bash
152
+ codeshift upgrade-all
153
+ ```
154
+
155
+ ### Example Output
156
+
157
+ ```
158
+ $ codeshift upgrade pydantic --target 2.5.0
159
+
160
+ ╭──────────────────────── Codeshift Migration ─────────────────────────╮
161
+ │ Upgrading Pydantic to version 2.5.0 │
162
+ │ Migration guide: https://docs.pydantic.dev/latest/migration/ │
163
+ ╰──────────────────────────────────────────────────────────────────────╯
164
+
165
+ Fetching knowledge sources...
166
+ ✓ GitHub: CHANGELOG.md
167
+ ✓ GitHub: docs/migration.md
168
+
169
+ Breaking changes detected:
170
+
171
+ HIGH CONFIDENCE:
172
+ ├── .dict() → .model_dump()
173
+ ├── @validator → @field_validator
174
+ └── class Config → model_config = ConfigDict()
175
+
176
+ MEDIUM CONFIDENCE:
177
+ ├── .json() → .model_dump_json()
178
+ └── parse_obj() → model_validate()
179
+
180
+ Scanning for library usage...
181
+ Found 12 imports from pydantic
182
+ Found 45 usages of pydantic symbols
183
+
184
+ ┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━┓
185
+ ┃ File ┃ Changes ┃ Status ┃
186
+ ┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━┩
187
+ │ src/models/user.py │ 5 │ Ready │
188
+ │ src/api/schemas.py │ 3 │ Ready │
189
+ └────────────────────┴─────────┴────────┘
190
+
191
+ Total: 8 changes across 2 files
192
+ ```
193
+
194
+ ## Commands
195
+
196
+ ### `codeshift scan`
197
+
198
+ Scan your project for outdated dependencies and available migrations.
199
+
200
+ ```bash
201
+ codeshift scan [OPTIONS]
202
+
203
+ Options:
204
+ --path, -p PATH Path to scan (default: current directory)
205
+ --fetch-changes Fetch changelogs and detect breaking changes
206
+ --major-only Only show major version upgrades
207
+ --json-output Output results as JSON
208
+ --verbose, -v Show detailed output
209
+ ```
210
+
211
+ Example:
212
+
213
+ ```
214
+ $ codeshift scan
215
+
216
+ Found 13 dependencies
217
+
218
+ Outdated Dependencies (5)
219
+ ┏━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━┳━━━━━━━┳━━━━━━━━━━┓
220
+ ┃ Package ┃ Current ┃ Latest ┃ Type ┃ Tier ┃
221
+ ┡━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━╇━━━━━━━╇━━━━━━━━━━┩
222
+ │ pydantic │ 1.0 │ 2.5.0 │ Major │ Tier 1 │
223
+ │ rich │ 13.0 │ 14.0.0 │ Major │ Tier 2/3 │
224
+ └────────────┴─────────┴────────┴───────┴──────────┘
225
+
226
+ Suggested Migrations (2)
227
+ pydantic 1.0 → 2.5.0 (Tier 1 - deterministic)
228
+ rich 13.0 → 14.0.0 (Tier 2/3 - LLM-assisted)
229
+
230
+ Quick commands:
231
+ codeshift upgrade pydantic --target 2.5.0
232
+ codeshift upgrade rich --target 14.0.0
233
+ ```
234
+
235
+ ### `codeshift upgrade`
236
+
237
+ Analyze your codebase and propose changes for a specific library upgrade.
238
+
239
+ ```bash
240
+ codeshift upgrade <library> --target <version> [OPTIONS]
241
+
242
+ Arguments:
243
+ LIBRARY Library name to upgrade (required)
244
+
245
+ Options:
246
+ --target, -t VERSION Target version to upgrade to (required)
247
+ --path, -p PATH Path to analyze (default: current directory)
248
+ --file, -f PATH Analyze a single file instead of the entire project
249
+ --dry-run Show what would be changed without saving state
250
+ --verbose, -v Show detailed output
251
+ ```
252
+
253
+ ### `codeshift upgrade-all`
254
+
255
+ Upgrade all outdated packages to their latest versions in one go.
256
+
257
+ ```bash
258
+ codeshift upgrade-all [OPTIONS]
259
+
260
+ Options:
261
+ --path, -p PATH Path to analyze (default: current directory)
262
+ --all Include all outdated packages (not just Tier 1)
263
+ --tier1-only Only upgrade Tier 1 libraries (deterministic transforms)
264
+ --major-only Only perform major version upgrades
265
+ --include, -i LIB Only include specific libraries (repeatable)
266
+ --exclude, -e LIB Exclude specific libraries (repeatable)
267
+ --update-deps Update dependency files with new versions (default: yes)
268
+ --no-update-deps Skip updating dependency files
269
+ --dry-run Show what would be changed without saving state
270
+ --verbose, -v Show detailed output
271
+ ```
272
+
273
+ ### `codeshift diff`
274
+
275
+ View the detailed diff of proposed changes.
276
+
277
+ ```bash
278
+ codeshift diff [OPTIONS]
279
+
280
+ Options:
281
+ --path, -p PATH Path to the project (default: current directory)
282
+ --file, -f FILE Show diff for a specific file only
283
+ --no-color Disable colored output
284
+ --context, -c INT Number of context lines (default: 3)
285
+ --summary Show only a summary without the full diff
286
+ ```
287
+
288
+ ### `codeshift show`
289
+
290
+ Show the full transformed or original code for a file.
291
+
292
+ ```bash
293
+ codeshift show <file_path> [OPTIONS]
294
+
295
+ Arguments:
296
+ FILE_PATH File to display (required)
297
+
298
+ Options:
299
+ --path, -p PATH Path to the project (default: current directory)
300
+ --original Show the original code instead of the transformed version
301
+ ```
302
+
303
+ ### `codeshift apply`
304
+
305
+ Apply the proposed changes to your files.
306
+
307
+ ```bash
308
+ codeshift apply [OPTIONS]
309
+
310
+ Options:
311
+ --path, -p PATH Path to the project (default: current directory)
312
+ --file, -f FILE Apply changes to a specific file only
313
+ --backup Create .bak backup files before applying changes
314
+ --yes, -y Skip confirmation prompt
315
+ --validate Validate syntax after applying (default: yes)
316
+ --no-validate Skip syntax validation
317
+ ```
318
+
319
+ ### `codeshift reset`
320
+
321
+ Cancel the current migration and clear all pending changes.
322
+
323
+ ```bash
324
+ codeshift reset [OPTIONS]
325
+
326
+ Options:
327
+ --path, -p PATH Path to the project (default: current directory)
328
+ --yes, -y Skip confirmation prompt
329
+ ```
330
+
331
+ ### `codeshift restore`
332
+
333
+ Restore files from a backup created by `apply --backup`.
334
+
335
+ ```bash
336
+ codeshift restore <backup_dir> [OPTIONS]
337
+
338
+ Arguments:
339
+ BACKUP_DIR Path to backup directory (required)
340
+
341
+ Options:
342
+ --path, -p PATH Path to the project (default: current directory)
343
+ --yes, -y Skip confirmation prompt
344
+ ```
345
+
346
+ ### `codeshift libraries`
347
+
348
+ List all supported libraries and their migration paths.
349
+
350
+ ```bash
351
+ codeshift libraries
352
+ ```
353
+
354
+ ### `codeshift status`
355
+
356
+ Show current migration status, pending changes, and quota info.
357
+
358
+ ```bash
359
+ codeshift status [OPTIONS]
360
+
361
+ Options:
362
+ --path, -p PATH Path to the project (default: current directory)
363
+ ```
364
+
365
+ ### Account Commands
366
+
367
+ ```bash
368
+ codeshift login # Login to enable cloud features
369
+ codeshift register # Create a new account
370
+ codeshift logout # Logout and remove credentials
371
+ codeshift whoami # Show current user info
372
+ codeshift quota # Show usage and limits
373
+ codeshift upgrade-plan # View or upgrade your plan
374
+ codeshift billing # Open billing portal
375
+ ```
376
+
377
+ ## How It Works
378
+
379
+ ```
380
+ ┌─────────────────────────────────────────────────────────────────────┐
381
+ │ Knowledge Acquisition Pipeline │
382
+ │ ┌─────────────┐ ┌──────────────────┐ ┌─────────────────────┐ │
383
+ │ │ Local Cache │──▶│ On-Demand Gen │──▶│ LLM Parser │ │
384
+ │ │ (instant) │ │ (fetches sources)│ │ (breaking changes) │ │
385
+ │ └─────────────┘ └──────────────────┘ └─────────────────────┘ │
386
+ │ │ │
387
+ │ ┌───────────────┴───────────────┐ │
388
+ │ │ Source Fetchers │ │
389
+ │ │ ├── GitHub (CHANGELOG.md) │ │
390
+ │ │ ├── Docs (migration guides) │ │
391
+ │ │ └── Release notes │ │
392
+ │ └───────────────────────────────┘ │
393
+ └─────────────────────────────────────────────────────────────────────┘
394
+
395
+
396
+ ┌─────────────────────────────────────────────────────────────────────┐
397
+ │ Migration Engine (Tiered) │
398
+ │ Tier 1: AST Transforms │ Tier 2: KB-Guided │ Tier 3: LLM │
399
+ │ (deterministic) │ (context + LLM) │ (fallback) │
400
+ └─────────────────────────────────────────────────────────────────────┘
401
+ ```
402
+
403
+ 1. **Fetch Knowledge** - discovers and fetches changelogs, migration guides from GitHub/PyPI
404
+ 2. **Parse Changes** - uses an LLM to extract breaking changes with confidence levels (HIGH/MEDIUM/LOW)
405
+ 3. **Scan Codebase** - finds imports and usage of the target library using libcst
406
+ 4. **Tiered Migration**:
407
+ - **Tier 1**: deterministic AST transforms for 15 supported libraries - no LLM needed
408
+ - **Tier 2**: knowledge base guided migration with LLM assistance
409
+ - **Tier 3**: pure LLM migration for unknown patterns
410
+ 5. **Validate** - runs syntax checks on the transformed code
411
+ 6. **Report** - shows a detailed diff with explanations for each change
412
+
413
+ ## Pydantic v1 → v2 Example
414
+
415
+ Codeshift handles the following Pydantic migrations automatically:
416
+
417
+ | v1 Pattern | v2 Replacement |
418
+ |---|---|
419
+ | `Config` class | `model_config = ConfigDict(...)` |
420
+ | `@validator` | `@field_validator` with `@classmethod` |
421
+ | `@root_validator` | `@model_validator` |
422
+ | `.dict()` | `.model_dump()` |
423
+ | `.json()` | `.model_dump_json()` |
424
+ | `.schema()` | `.model_json_schema()` |
425
+ | `.parse_obj()` | `.model_validate()` |
426
+ | `orm_mode = True` | `from_attributes = True` |
427
+ | `Field(regex=...)` | `Field(pattern=...)` |
428
+
429
+ ## Configuration
430
+
431
+ Codeshift can be configured via `pyproject.toml`:
432
+
433
+ ```toml
434
+ [tool.codeshift]
435
+ # Path patterns to exclude from scanning
436
+ exclude = ["tests/*", "migrations/*"]
437
+
438
+ # Enable/disable LLM fallback
439
+ use_llm = true
440
+
441
+ # Anthropic API key (can also use ANTHROPIC_API_KEY env var)
442
+ # anthropic_api_key = "sk-..."
443
+ ```
444
+
445
+ ## Environment Variables
446
+
447
+ | Variable | Required | Description |
448
+ |---|---|---|
449
+ | `ANTHROPIC_API_KEY` | For Tier 2/3 | Enables LLM-powered migrations |
450
+ | `GITHUB_TOKEN` | No | Higher GitHub API rate limits |
451
+
452
+ ## Pricing
453
+
454
+ | Tier | Price | What You Get |
455
+ |------|-------|--------------|
456
+ | **Free** | $0/month | Tier 1 deterministic transforms for all 15 supported libraries. Runs entirely locally. |
457
+ | **Pro** | $19/month | Tier 2 KB-guided LLM migrations for any library |
458
+ | **Unlimited** | $49/month | Tier 3 pure LLM migrations + priority support |
459
+
460
+ ```bash
461
+ # Login to access Pro/Unlimited features
462
+ codeshift login
463
+
464
+ # Check your current plan and usage
465
+ codeshift quota
466
+ ```
467
+
468
+ ## License
469
+
470
+ This software is licensed under the [MIT License](LICENSE).
471
+
472
+ You are free to use, modify, and distribute this software. The CLI tool and all transforms are fully open source.