codefreedom 0.1.0__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 (38) hide show
  1. codefreedom-0.1.0/LICENSE +201 -0
  2. codefreedom-0.1.0/PKG-INFO +262 -0
  3. codefreedom-0.1.0/README.md +228 -0
  4. codefreedom-0.1.0/pyproject.toml +77 -0
  5. codefreedom-0.1.0/setup.cfg +4 -0
  6. codefreedom-0.1.0/src/codefreedom/__init__.py +3 -0
  7. codefreedom-0.1.0/src/codefreedom/__main__.py +5 -0
  8. codefreedom-0.1.0/src/codefreedom/cli/__init__.py +1 -0
  9. codefreedom-0.1.0/src/codefreedom/cli/claude.py +122 -0
  10. codefreedom-0.1.0/src/codefreedom/cli/litellm_cli.py +352 -0
  11. codefreedom-0.1.0/src/codefreedom/cli/main.py +325 -0
  12. codefreedom-0.1.0/src/codefreedom/cli/proxy.py +332 -0
  13. codefreedom-0.1.0/src/codefreedom/env_loader.py +101 -0
  14. codefreedom-0.1.0/src/codefreedom/examples/.env.example +205 -0
  15. codefreedom-0.1.0/src/codefreedom/examples/.env.secrets.example +79 -0
  16. codefreedom-0.1.0/src/codefreedom/examples/profiles/claude-code-profiles.json +81 -0
  17. codefreedom-0.1.0/src/codefreedom/examples/profiles/claude-code-profiles.schema.json +84 -0
  18. codefreedom-0.1.0/src/codefreedom/examples/proxy/config.yaml +112 -0
  19. codefreedom-0.1.0/src/codefreedom/examples/proxy/docker-compose.yml +127 -0
  20. codefreedom-0.1.0/src/codefreedom/examples/proxy/providers/anthropic-compatible.yaml +50 -0
  21. codefreedom-0.1.0/src/codefreedom/examples/proxy/providers/azure-foundry.yaml +76 -0
  22. codefreedom-0.1.0/src/codefreedom/examples/proxy/providers/deepseek.yaml +71 -0
  23. codefreedom-0.1.0/src/codefreedom/examples/proxy/providers/local.yaml +107 -0
  24. codefreedom-0.1.0/src/codefreedom/examples/proxy/providers/nvidia.yaml +103 -0
  25. codefreedom-0.1.0/src/codefreedom/examples/proxy/providers/openai-compatible.yaml +57 -0
  26. codefreedom-0.1.0/src/codefreedom/examples/proxy/providers/opencode-zen.yaml +87 -0
  27. codefreedom-0.1.0/src/codefreedom/launcher.py +389 -0
  28. codefreedom-0.1.0/src/codefreedom/profiles.py +200 -0
  29. codefreedom-0.1.0/src/codefreedom.egg-info/PKG-INFO +262 -0
  30. codefreedom-0.1.0/src/codefreedom.egg-info/SOURCES.txt +36 -0
  31. codefreedom-0.1.0/src/codefreedom.egg-info/dependency_links.txt +1 -0
  32. codefreedom-0.1.0/src/codefreedom.egg-info/entry_points.txt +3 -0
  33. codefreedom-0.1.0/src/codefreedom.egg-info/requires.txt +15 -0
  34. codefreedom-0.1.0/src/codefreedom.egg-info/top_level.txt +1 -0
  35. codefreedom-0.1.0/tests/test_env_loader.py +116 -0
  36. codefreedom-0.1.0/tests/test_init.py +177 -0
  37. codefreedom-0.1.0/tests/test_profiles.py +120 -0
  38. codefreedom-0.1.0/tests/test_proxy.py +197 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Nilay Parikh
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,262 @@
1
+ Metadata-Version: 2.4
2
+ Name: codefreedom
3
+ Version: 0.1.0
4
+ Summary: CLI for running Claude Code through LiteLLM — local AI inference, anywhere
5
+ Author-email: Nilay Parikh <nilay.parikh@gmail.com>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/nilayparikh/codefreedom
8
+ Project-URL: Repository, https://github.com/nilayparikh/codefreedom
9
+ Keywords: claude-code,litellm,ai,llm,local-inference
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software 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
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: PyYAML>=6.0
22
+ Requires-Dist: types-PyYAML
23
+ Provides-Extra: litellm
24
+ Requires-Dist: litellm[proxy]>=1.50; extra == "litellm"
25
+ Requires-Dist: prometheus-client>=0.20; extra == "litellm"
26
+ Provides-Extra: dev
27
+ Requires-Dist: mypy>=1.0; extra == "dev"
28
+ Requires-Dist: ruff>=0.1; extra == "dev"
29
+ Requires-Dist: pytest>=7.0; extra == "dev"
30
+ Requires-Dist: types-PyYAML; extra == "dev"
31
+ Provides-Extra: all
32
+ Requires-Dist: codefreedom[dev,litellm]; extra == "all"
33
+ Dynamic: license-file
34
+
35
+ # CodeFreedom
36
+
37
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
38
+ [![Python](https://img.shields.io/badge/python-3.10+-blue.svg)](pyproject.toml)
39
+ [![Integration Tests](https://github.com/nilayparikh/codefreedom/actions/workflows/integration-test.yml/badge.svg)](https://github.com/nilayparikh/codefreedom/actions/workflows/integration-test.yml)
40
+ [![PyPI](https://img.shields.io/pypi/v/codefreedom.svg)](https://pypi.org/project/codefreedom/)
41
+
42
+ **Claude Code launcher and LiteLLM proxy — AI-augmented coding, anywhere.**
43
+
44
+ CodeFreedom gives you a single CLI tool (`codefreedom` / `cf`) that:
45
+
46
+ 1. **Runs Claude Code** natively or inside a Docker container with GPU passthrough, profile-based model routing, and multi-session support.
47
+ 2. **Manages a LiteLLM proxy** — stateless by default, with optional PostgreSQL for the Admin UI, spend tracking, and key management.
48
+ 3. **Routes to any provider** — local self-hosted models, cloud APIs (DeepSeek, Azure, NVIDIA, OpenCode Zen), or any OpenAI/Anthropic-compatible endpoint.
49
+
50
+ ## Why CodeFreedom?
51
+
52
+ CodeFreedom extracts the **LiteLLM proxy** and **Claude Code launcher** from the [`.init`](https://github.com/nilayparikh/spark-init) stack into a standalone, portable tool. Where `.init` is a full Docker Compose stack with PostgreSQL, observability, and llama.cpp backends, CodeFreedom is the lightweight companion you can install anywhere and use with any LiteLLM-compatible backend.
53
+
54
+ | Feature | `.init` | `codefreedom` |
55
+ | -------------------- | ----------------------- | ----------------------------------------- |
56
+ | LiteLLM proxy | ✅ (part of full stack) | ✅ (standalone, stateless) |
57
+ | Claude Code launcher | ✅ (`claude-code.py`) | ✅ (`codefreedom claude`) |
58
+ | PostgreSQL | ✅ (bundled) | ✅ (optional — connect external Postgres) |
59
+ | llama.cpp backends | ✅ (bundled) | ❌ (use .init for local inference) |
60
+ | Observability | ✅ (Grafana/Mimir/Loki) | ❌ (use .init) |
61
+ | pip installable | ❌ | ✅ |
62
+
63
+ ## Quick Start
64
+
65
+ ### Installation
66
+
67
+ **From PyPI (recommended):**
68
+
69
+ ```bash
70
+ pip install codefreedom
71
+ ```
72
+
73
+ **From source:**
74
+
75
+ ```bash
76
+ git clone https://github.com/nilayparikh/codefreedom.git
77
+ cd codefreedom
78
+ pip install -e .
79
+ ```
80
+
81
+ Now you can run `codefreedom` or `cf` from anywhere:
82
+
83
+ ```bash
84
+ codefreedom --help
85
+ cf --help
86
+ ```
87
+
88
+ ### Initialize
89
+
90
+ ```bash
91
+ # Creates ~/.codefreedom/ with default profiles and proxy configs
92
+ codefreedom --init
93
+
94
+ # Overwrite existing files
95
+ codefreedom --init --force
96
+ ```
97
+
98
+ This creates:
99
+
100
+ ```
101
+ ~/.codefreedom/
102
+ ├── profiles/
103
+ │ ├── claude-code.json # Profile definitions
104
+ │ └── claude-code-profiles.schema.json # JSON Schema for validation
105
+ └── proxy/
106
+ ├── docker-compose.yml # Docker Compose for LiteLLM
107
+ └── config/
108
+ ├── config.yaml # LiteLLM proxy configuration
109
+ └── providers/ # Provider-specific configs
110
+ ├── deepseek.yaml
111
+ ├── azure-foundry.yaml
112
+ ├── nvidia.yaml
113
+ ├── local.yaml
114
+ ├── openai-compatible.yaml
115
+ ├── anthropic-compatible.yaml
116
+ └── opencode-zen.yaml
117
+ ```
118
+
119
+ ### 1. Start the LiteLLM Proxy
120
+
121
+ ```bash
122
+ # Edit ~/.codefreedom/proxy/config/config.yaml to configure providers
123
+ # Set LITELLM_MASTER_KEY in your environment
124
+
125
+ # Start via Docker Compose
126
+ codefreedom proxy --up --docker
127
+
128
+ # Or start natively (requires: pip install codefreedom[litellm])
129
+ codefreedom proxy --up
130
+
131
+ # Validate config
132
+ codefreedom proxy --validate
133
+ ```
134
+
135
+ The proxy starts stateless — no database, no Prisma, just model routing.
136
+ See [LiteLLM Proxy → Database](docs/litellm.md#database-backends) for PostgreSQL setup.
137
+
138
+ ### 2. Launch Claude Code
139
+
140
+ ```bash
141
+ # Default: native mode with Flash model
142
+ codefreedom claude
143
+
144
+ # Short alias
145
+ cf cc
146
+
147
+ # Pick a model profile
148
+ codefreedom claude --profile pro
149
+ codefreedom claude --profile ultra
150
+
151
+ # Run in sandboxed Docker container
152
+ codefreedom claude --sandbox
153
+
154
+ # Use native Anthropic /login auth (bypass proxy)
155
+ codefreedom claude --native-models
156
+
157
+ # List available profiles
158
+ codefreedom claude --list-profiles
159
+
160
+ # Manage the container
161
+ codefreedom claude --status
162
+ codefreedom claude --stop
163
+ ```
164
+
165
+ ### 3. Pass Arguments to Claude
166
+
167
+ ```bash
168
+ cf cc -p "Explain this codebase"
169
+ cf cc --resume "<session-id>"
170
+ cf cc --profile pro --worktree feature-branch
171
+ ```
172
+
173
+ ## CLI Reference
174
+
175
+ ```
176
+ codefreedom | cf
177
+
178
+ ├── --init Initialize ~/.codefreedom/ with default profiles
179
+ │ └── --force Overwrite existing configs
180
+
181
+ ├── claude | cc Launch Claude Code
182
+ │ ├── --profile NAME Model profile (default: 'default')
183
+ │ ├── --sandbox Run in sandboxed Docker container
184
+ │ ├── --native-models Use native Anthropic /login auth (bypass proxy)
185
+ │ ├── --stop Stop the container
186
+ │ ├── --status Show container status
187
+ │ └── --list-profiles List available profiles
188
+
189
+ └── proxy | px Manage LiteLLM proxy
190
+ ├── --up Start the proxy (default: native)
191
+ ├── --up --docker Start via Docker Compose
192
+ ├── --down Stop the proxy
193
+ ├── --status Show proxy status
194
+ └── --validate Validate LiteLLM config
195
+ ```
196
+
197
+ ## Profiles
198
+
199
+ Profiles control which model Claude Code uses and which API endpoint it routes through. Defined in `~/.codefreedom/profiles/claude-code.json`.
200
+
201
+ | Profile | Model | Description |
202
+ | --------- | ------------------- | -------------------------------------------------------- |
203
+ | `default` | `CodeFreedom/Flash` | Base profile — routes through local LiteLLM proxy |
204
+ | `ultra` | `CodeFreedom/Ultra` | Architecture, planning, complex reasoning |
205
+ | `pro` | `CodeFreedom/Pro` | Bounded implementation, precise code writing |
206
+ | `air` | `CodeFreedom/Air` | Mechanical scanning, large-file reading |
207
+ | `bare` | _(default)_ | Minimal — no model aliases, routes through LiteLLM proxy |
208
+
209
+ Create custom profiles by editing `~/.codefreedom/profiles/claude-code.json`.
210
+ A JSON Schema is provided at `~/.codefreedom/profiles/claude-code-profiles.schema.json`.
211
+
212
+ ## Database (Optional)
213
+
214
+ The proxy runs **stateless by default** — no database, no Prisma, no persistence.
215
+ Model routing works out of the box.
216
+
217
+ | Backend | Use Case |
218
+ | ------------------ | -------------------------------------------------- |
219
+ | **None** (default) | Dev/CI — stateless model routing, zero persistence |
220
+ | **PostgreSQL** | Admin UI, spend tracking, key management, teams |
221
+
222
+ See [LiteLLM Proxy → Database](docs/litellm.md#database-backends) for setup.
223
+
224
+ ## Architecture
225
+
226
+ ```
227
+ ┌──────────────────────────────────────────────────────────┐
228
+ │ codefreedom CLI │
229
+ │ codefreedom claude | codefreedom proxy │
230
+ └──────────┬───────────────────────┬───────────────────────┘
231
+ │ │
232
+ ▼ ▼
233
+ ┌───────────────┐ ┌─────────────────┐
234
+ │ Claude Code │ │ LiteLLM Proxy │
235
+ │ (Docker) │────▶│ (Docker) │
236
+ │ GPU passthru │ │ :4000 │
237
+ └───────────────┘ └────────┬────────┘
238
+
239
+ ┌─────────────┼─────────────┐
240
+ ▼ ▼ ▼
241
+ ┌──────────┐ ┌──────────┐ ┌──────────┐
242
+ │ DeepSeek │ │ Azure │ │ DGX │
243
+ │ (cloud) │ │ (cloud) │ │ (local) │
244
+ └──────────┘ └──────────┘ └──────────┘
245
+ ```
246
+
247
+ ## Documentation
248
+
249
+ - [Getting Started](docs/getting-started.md) — detailed setup guide
250
+ - [LiteLLM Proxy](docs/litellm.md) — configuration and provider setup
251
+ - [Claude Code Launcher](docs/claude-code.md) — profiles, Docker, and advanced usage
252
+
253
+ ## Requirements
254
+
255
+ - Python 3.10+
256
+ - Docker (for Docker mode and LiteLLM proxy)
257
+ - NVIDIA Container Toolkit (for GPU passthrough)
258
+ - Node.js + `@anthropic-ai/claude-code` (for native/local mode only)
259
+
260
+ ## License
261
+
262
+ Apache 2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,228 @@
1
+ # CodeFreedom
2
+
3
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
4
+ [![Python](https://img.shields.io/badge/python-3.10+-blue.svg)](pyproject.toml)
5
+ [![Integration Tests](https://github.com/nilayparikh/codefreedom/actions/workflows/integration-test.yml/badge.svg)](https://github.com/nilayparikh/codefreedom/actions/workflows/integration-test.yml)
6
+ [![PyPI](https://img.shields.io/pypi/v/codefreedom.svg)](https://pypi.org/project/codefreedom/)
7
+
8
+ **Claude Code launcher and LiteLLM proxy — AI-augmented coding, anywhere.**
9
+
10
+ CodeFreedom gives you a single CLI tool (`codefreedom` / `cf`) that:
11
+
12
+ 1. **Runs Claude Code** natively or inside a Docker container with GPU passthrough, profile-based model routing, and multi-session support.
13
+ 2. **Manages a LiteLLM proxy** — stateless by default, with optional PostgreSQL for the Admin UI, spend tracking, and key management.
14
+ 3. **Routes to any provider** — local self-hosted models, cloud APIs (DeepSeek, Azure, NVIDIA, OpenCode Zen), or any OpenAI/Anthropic-compatible endpoint.
15
+
16
+ ## Why CodeFreedom?
17
+
18
+ CodeFreedom extracts the **LiteLLM proxy** and **Claude Code launcher** from the [`.init`](https://github.com/nilayparikh/spark-init) stack into a standalone, portable tool. Where `.init` is a full Docker Compose stack with PostgreSQL, observability, and llama.cpp backends, CodeFreedom is the lightweight companion you can install anywhere and use with any LiteLLM-compatible backend.
19
+
20
+ | Feature | `.init` | `codefreedom` |
21
+ | -------------------- | ----------------------- | ----------------------------------------- |
22
+ | LiteLLM proxy | ✅ (part of full stack) | ✅ (standalone, stateless) |
23
+ | Claude Code launcher | ✅ (`claude-code.py`) | ✅ (`codefreedom claude`) |
24
+ | PostgreSQL | ✅ (bundled) | ✅ (optional — connect external Postgres) |
25
+ | llama.cpp backends | ✅ (bundled) | ❌ (use .init for local inference) |
26
+ | Observability | ✅ (Grafana/Mimir/Loki) | ❌ (use .init) |
27
+ | pip installable | ❌ | ✅ |
28
+
29
+ ## Quick Start
30
+
31
+ ### Installation
32
+
33
+ **From PyPI (recommended):**
34
+
35
+ ```bash
36
+ pip install codefreedom
37
+ ```
38
+
39
+ **From source:**
40
+
41
+ ```bash
42
+ git clone https://github.com/nilayparikh/codefreedom.git
43
+ cd codefreedom
44
+ pip install -e .
45
+ ```
46
+
47
+ Now you can run `codefreedom` or `cf` from anywhere:
48
+
49
+ ```bash
50
+ codefreedom --help
51
+ cf --help
52
+ ```
53
+
54
+ ### Initialize
55
+
56
+ ```bash
57
+ # Creates ~/.codefreedom/ with default profiles and proxy configs
58
+ codefreedom --init
59
+
60
+ # Overwrite existing files
61
+ codefreedom --init --force
62
+ ```
63
+
64
+ This creates:
65
+
66
+ ```
67
+ ~/.codefreedom/
68
+ ├── profiles/
69
+ │ ├── claude-code.json # Profile definitions
70
+ │ └── claude-code-profiles.schema.json # JSON Schema for validation
71
+ └── proxy/
72
+ ├── docker-compose.yml # Docker Compose for LiteLLM
73
+ └── config/
74
+ ├── config.yaml # LiteLLM proxy configuration
75
+ └── providers/ # Provider-specific configs
76
+ ├── deepseek.yaml
77
+ ├── azure-foundry.yaml
78
+ ├── nvidia.yaml
79
+ ├── local.yaml
80
+ ├── openai-compatible.yaml
81
+ ├── anthropic-compatible.yaml
82
+ └── opencode-zen.yaml
83
+ ```
84
+
85
+ ### 1. Start the LiteLLM Proxy
86
+
87
+ ```bash
88
+ # Edit ~/.codefreedom/proxy/config/config.yaml to configure providers
89
+ # Set LITELLM_MASTER_KEY in your environment
90
+
91
+ # Start via Docker Compose
92
+ codefreedom proxy --up --docker
93
+
94
+ # Or start natively (requires: pip install codefreedom[litellm])
95
+ codefreedom proxy --up
96
+
97
+ # Validate config
98
+ codefreedom proxy --validate
99
+ ```
100
+
101
+ The proxy starts stateless — no database, no Prisma, just model routing.
102
+ See [LiteLLM Proxy → Database](docs/litellm.md#database-backends) for PostgreSQL setup.
103
+
104
+ ### 2. Launch Claude Code
105
+
106
+ ```bash
107
+ # Default: native mode with Flash model
108
+ codefreedom claude
109
+
110
+ # Short alias
111
+ cf cc
112
+
113
+ # Pick a model profile
114
+ codefreedom claude --profile pro
115
+ codefreedom claude --profile ultra
116
+
117
+ # Run in sandboxed Docker container
118
+ codefreedom claude --sandbox
119
+
120
+ # Use native Anthropic /login auth (bypass proxy)
121
+ codefreedom claude --native-models
122
+
123
+ # List available profiles
124
+ codefreedom claude --list-profiles
125
+
126
+ # Manage the container
127
+ codefreedom claude --status
128
+ codefreedom claude --stop
129
+ ```
130
+
131
+ ### 3. Pass Arguments to Claude
132
+
133
+ ```bash
134
+ cf cc -p "Explain this codebase"
135
+ cf cc --resume "<session-id>"
136
+ cf cc --profile pro --worktree feature-branch
137
+ ```
138
+
139
+ ## CLI Reference
140
+
141
+ ```
142
+ codefreedom | cf
143
+
144
+ ├── --init Initialize ~/.codefreedom/ with default profiles
145
+ │ └── --force Overwrite existing configs
146
+
147
+ ├── claude | cc Launch Claude Code
148
+ │ ├── --profile NAME Model profile (default: 'default')
149
+ │ ├── --sandbox Run in sandboxed Docker container
150
+ │ ├── --native-models Use native Anthropic /login auth (bypass proxy)
151
+ │ ├── --stop Stop the container
152
+ │ ├── --status Show container status
153
+ │ └── --list-profiles List available profiles
154
+
155
+ └── proxy | px Manage LiteLLM proxy
156
+ ├── --up Start the proxy (default: native)
157
+ ├── --up --docker Start via Docker Compose
158
+ ├── --down Stop the proxy
159
+ ├── --status Show proxy status
160
+ └── --validate Validate LiteLLM config
161
+ ```
162
+
163
+ ## Profiles
164
+
165
+ Profiles control which model Claude Code uses and which API endpoint it routes through. Defined in `~/.codefreedom/profiles/claude-code.json`.
166
+
167
+ | Profile | Model | Description |
168
+ | --------- | ------------------- | -------------------------------------------------------- |
169
+ | `default` | `CodeFreedom/Flash` | Base profile — routes through local LiteLLM proxy |
170
+ | `ultra` | `CodeFreedom/Ultra` | Architecture, planning, complex reasoning |
171
+ | `pro` | `CodeFreedom/Pro` | Bounded implementation, precise code writing |
172
+ | `air` | `CodeFreedom/Air` | Mechanical scanning, large-file reading |
173
+ | `bare` | _(default)_ | Minimal — no model aliases, routes through LiteLLM proxy |
174
+
175
+ Create custom profiles by editing `~/.codefreedom/profiles/claude-code.json`.
176
+ A JSON Schema is provided at `~/.codefreedom/profiles/claude-code-profiles.schema.json`.
177
+
178
+ ## Database (Optional)
179
+
180
+ The proxy runs **stateless by default** — no database, no Prisma, no persistence.
181
+ Model routing works out of the box.
182
+
183
+ | Backend | Use Case |
184
+ | ------------------ | -------------------------------------------------- |
185
+ | **None** (default) | Dev/CI — stateless model routing, zero persistence |
186
+ | **PostgreSQL** | Admin UI, spend tracking, key management, teams |
187
+
188
+ See [LiteLLM Proxy → Database](docs/litellm.md#database-backends) for setup.
189
+
190
+ ## Architecture
191
+
192
+ ```
193
+ ┌──────────────────────────────────────────────────────────┐
194
+ │ codefreedom CLI │
195
+ │ codefreedom claude | codefreedom proxy │
196
+ └──────────┬───────────────────────┬───────────────────────┘
197
+ │ │
198
+ ▼ ▼
199
+ ┌───────────────┐ ┌─────────────────┐
200
+ │ Claude Code │ │ LiteLLM Proxy │
201
+ │ (Docker) │────▶│ (Docker) │
202
+ │ GPU passthru │ │ :4000 │
203
+ └───────────────┘ └────────┬────────┘
204
+
205
+ ┌─────────────┼─────────────┐
206
+ ▼ ▼ ▼
207
+ ┌──────────┐ ┌──────────┐ ┌──────────┐
208
+ │ DeepSeek │ │ Azure │ │ DGX │
209
+ │ (cloud) │ │ (cloud) │ │ (local) │
210
+ └──────────┘ └──────────┘ └──────────┘
211
+ ```
212
+
213
+ ## Documentation
214
+
215
+ - [Getting Started](docs/getting-started.md) — detailed setup guide
216
+ - [LiteLLM Proxy](docs/litellm.md) — configuration and provider setup
217
+ - [Claude Code Launcher](docs/claude-code.md) — profiles, Docker, and advanced usage
218
+
219
+ ## Requirements
220
+
221
+ - Python 3.10+
222
+ - Docker (for Docker mode and LiteLLM proxy)
223
+ - NVIDIA Container Toolkit (for GPU passthrough)
224
+ - Node.js + `@anthropic-ai/claude-code` (for native/local mode only)
225
+
226
+ ## License
227
+
228
+ Apache 2.0 — see [LICENSE](LICENSE).