freeai-code 0.1.0__tar.gz → 0.1.2__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 (39) hide show
  1. freeai_code-0.1.2/PKG-INFO +231 -0
  2. freeai_code-0.1.2/README.md +198 -0
  3. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/__init__.py +1 -1
  4. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/cli.py +142 -0
  5. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/client.py +7 -62
  6. freeai_code-0.1.2/free_code/cloud.py +210 -0
  7. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/config.py +4 -4
  8. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/models.py +5 -8
  9. freeai_code-0.1.2/freeai_code.egg-info/PKG-INFO +231 -0
  10. {freeai_code-0.1.0 → freeai_code-0.1.2}/freeai_code.egg-info/SOURCES.txt +1 -0
  11. {freeai_code-0.1.0 → freeai_code-0.1.2}/pyproject.toml +9 -6
  12. freeai_code-0.1.0/PKG-INFO +0 -109
  13. freeai_code-0.1.0/README.md +0 -79
  14. freeai_code-0.1.0/freeai_code.egg-info/PKG-INFO +0 -109
  15. {freeai_code-0.1.0 → freeai_code-0.1.2}/LICENSE +0 -0
  16. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/__main__.py +0 -0
  17. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/agent.py +0 -0
  18. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/auth.py +0 -0
  19. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/context/__init__.py +0 -0
  20. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/context/discovery.py +0 -0
  21. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/context/repo_map.py +0 -0
  22. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/context/window.py +0 -0
  23. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/streaming.py +0 -0
  24. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/tools/__init__.py +0 -0
  25. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/tools/file_ops.py +0 -0
  26. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/tools/git_ops.py +0 -0
  27. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/tools/list_files.py +0 -0
  28. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/tools/search.py +0 -0
  29. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/tools/shell.py +0 -0
  30. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/tools/test_runner.py +0 -0
  31. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/ui/__init__.py +0 -0
  32. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/ui/diff_view.py +0 -0
  33. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/ui/prompt.py +0 -0
  34. {freeai_code-0.1.0 → freeai_code-0.1.2}/free_code/ui/terminal.py +0 -0
  35. {freeai_code-0.1.0 → freeai_code-0.1.2}/freeai_code.egg-info/dependency_links.txt +0 -0
  36. {freeai_code-0.1.0 → freeai_code-0.1.2}/freeai_code.egg-info/entry_points.txt +0 -0
  37. {freeai_code-0.1.0 → freeai_code-0.1.2}/freeai_code.egg-info/requires.txt +0 -0
  38. {freeai_code-0.1.0 → freeai_code-0.1.2}/freeai_code.egg-info/top_level.txt +0 -0
  39. {freeai_code-0.1.0 → freeai_code-0.1.2}/setup.cfg +0 -0
@@ -0,0 +1,231 @@
1
+ Metadata-Version: 2.4
2
+ Name: freeai-code
3
+ Version: 0.1.2
4
+ Summary: Free AI coding assistant — open-source Claude Code alternative. pip install freeai-code
5
+ Author-email: "Free.ai" <hello@free.ai>
6
+ License: MIT
7
+ Project-URL: Homepage, https://free.ai/coder/
8
+ Project-URL: Documentation, https://free.ai/api/
9
+ Project-URL: Repository, https://github.com/freeaigit/free-code
10
+ Project-URL: Bug Tracker, https://github.com/freeaigit/free-code/issues
11
+ Project-URL: Changelog, https://free.ai/changelog/
12
+ Keywords: ai,coding,assistant,cli,free,claude-code,cursor,copilot
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: click>=8.0
27
+ Requires-Dist: rich>=13.0
28
+ Requires-Dist: httpx>=0.25
29
+ Requires-Dist: pyyaml>=6.0
30
+ Requires-Dist: pathspec>=0.11
31
+ Requires-Dist: tiktoken>=0.5
32
+ Dynamic: license-file
33
+
34
+ # Free.ai Coder
35
+
36
+ Free AI coding assistant for your terminal. A free, open-source alternative to Claude Code, Cursor, and GitHub Copilot.
37
+
38
+ **[Website](https://free.ai/coder/)** | **[PyPI](https://pypi.org/project/freeai-code/)** | **[npm](https://www.npmjs.com/package/freeai-code)** | **[Web IDE](https://free.ai/coder/)**
39
+
40
+ ## Install
41
+
42
+ ```bash
43
+ # Universal (Linux / macOS)
44
+ curl -fsSL https://free.ai/install | sh
45
+
46
+ # pip
47
+ pip install freeai-code
48
+
49
+ # npm
50
+ npm install -g freeai-code
51
+ ```
52
+
53
+ ## Quick Start
54
+
55
+ ```bash
56
+ # Interactive coding session in your project directory
57
+ cd your-project/
58
+ free-code
59
+
60
+ # Ask a one-shot question about your codebase
61
+ free-code ask "How does the auth system work?"
62
+
63
+ # Execute a task
64
+ free-code run "Add unit tests for the User model"
65
+
66
+ # Run a task in the Free.ai cloud (codex-style) and watch it
67
+ free-code cloud "Fix the failing CI on main" --repo https://github.com/you/project
68
+
69
+ # Initialize and scan codebase
70
+ free-code init
71
+ ```
72
+
73
+ ## Commands
74
+
75
+ | Command | Description |
76
+ |---------|-------------|
77
+ | `free-code` | Interactive coding session (alias: `free-code chat`) |
78
+ | `free-code ask "question"` | One-shot question about the codebase |
79
+ | `free-code run "task"` | Execute a coding task |
80
+ | `free-code cloud "task"` | Run a coding task in the Free.ai cloud (`--repo URL`, `--model`, `--no-watch`, `--download DIR`) |
81
+ | `free-code tasks` | List your recent cloud tasks |
82
+ | `free-code init` | Initialize config, scan codebase |
83
+ | `free-code config` | Show current configuration |
84
+ | `free-code config set key value` | Set a config value |
85
+ | `free-code login` | Authenticate with Free.ai |
86
+
87
+ ## Features
88
+
89
+ - File read/write with diff preview and approval gates
90
+ - Shell command execution (with confirmation in safe mode)
91
+ - Git integration (status, diff, commit, branch)
92
+ - Test runner auto-detection (pytest, jest, go test, cargo test)
93
+ - Streaming output with syntax highlighting
94
+ - Context window optimization and repo map generation
95
+ - .gitignore-aware file discovery
96
+ - Session sync — continue conversations from [web](https://free.ai/coder/) to CLI and back
97
+ - Cloud tasks — run long coding tasks on Free.ai's GPUs and pick up the result later
98
+
99
+ ## Cloud Tasks
100
+
101
+ Run a coding task on Free.ai's infrastructure instead of your machine — like a codex agent from the terminal. Requires an API key: run `free-code login` and paste a key from [free.ai/developer](https://free.ai/developer/) (free tier works).
102
+
103
+ ```bash
104
+ # Submit and watch (polls until done, prints the markdown report)
105
+ free-code cloud "Add rate limiting to the API" --repo https://github.com/you/project
106
+
107
+ # Pick the cloud model
108
+ free-code cloud "Refactor the auth module" --model deepseek-coder
109
+
110
+ # Fire and forget (you get an email when it finishes)
111
+ free-code cloud "Write integration tests" --no-watch
112
+
113
+ # Download the resulting code as a zip, unpacked into ./result
114
+ free-code cloud "Fix the flaky test suite" --download ./result
115
+
116
+ # List recent tasks
117
+ free-code tasks
118
+ ```
119
+
120
+ ## Configuration
121
+
122
+ Config is stored at `~/.free-code/config.yaml`.
123
+
124
+ ```bash
125
+ # Set your Free.ai token (get one at https://free.ai/account/)
126
+ free-code config set token sk-free-xxx
127
+
128
+ # Use your own API key (BYOK — no markup, use your own provider)
129
+ free-code config set provider openai
130
+ free-code config set api_key sk-xxx
131
+
132
+ # Choose a model
133
+ free-code config set model qwen7b
134
+
135
+ # Enable safe mode (confirm before file writes)
136
+ free-code config set safe_mode true
137
+ ```
138
+
139
+ ### Supported Providers
140
+
141
+ | Provider | Default Model | Free Tier |
142
+ |----------|--------------|-----------|
143
+ | **free.ai** (default) | Qwen 7B | 50K tokens/day |
144
+ | **openai** | GPT-4o | BYOK — no markup |
145
+ | **anthropic** | Claude Sonnet 4 | BYOK — no markup |
146
+ | **google** | Gemini 2.5 Pro | BYOK — no markup |
147
+ | **openrouter** | 346+ models | BYOK — no markup |
148
+
149
+ ## How It Works
150
+
151
+ 1. Scans your project (respects .gitignore)
152
+ 2. Builds a context map of your codebase
153
+ 3. Sends your request + relevant code context to the AI
154
+ 4. AI plans steps, reads/writes files, runs commands
155
+ 5. You review and approve changes (safe mode)
156
+
157
+ All file operations happen locally on your machine. The AI sees only what it needs.
158
+
159
+ ## Pricing
160
+
161
+ - **Anonymous**: 10K tokens/day (Qwen Coder only)
162
+ - **Free account**: 50K tokens/day (sign up at [free.ai](https://free.ai/signup/))
163
+ - **Paid plans**: From $5/month for 200K tokens ([pricing](https://free.ai/pricing/))
164
+ - **BYOK**: $0 — bring your own API key, no markup
165
+
166
+ ## Links
167
+
168
+ - [Free.ai](https://free.ai) — 400+ free AI tools
169
+ - [Web IDE](https://free.ai/coder/) — Use in your browser
170
+ - [API Docs](https://free.ai/api/) — Build on top of Free.ai
171
+ - [Compare vs Claude Code](https://free.ai/compare/coder-vs-claude-code/)
172
+ - [Compare vs Cursor](https://free.ai/compare/coder-vs-cursor/)
173
+
174
+ ## vs Competitors
175
+
176
+ | Feature | Free.ai Coder | Claude Code | OpenAI Codex | Cursor | GitHub Copilot |
177
+ |---------|--------------|-------------|--------------|--------|----------------|
178
+ | Free tier | 50K tokens/day | None ($20/mo) | None ($200/mo) | None ($20/mo) | None ($10/mo) |
179
+ | Self-hosted models | Yes (Qwen, DeepSeek) | No | No | No | No |
180
+ | BYOK (bring your own key) | Yes — $0 markup | No | No | Partial | No |
181
+ | Open source CLI | Yes (MIT) | No | No | No | No |
182
+ | Web IDE | Yes (free.ai/coder/) | No | Yes | Yes | No |
183
+ | Terminal access | Yes | Yes | Yes | Yes | No |
184
+ | 346+ models | Yes | Claude only | GPT only | Multiple | GPT only |
185
+ | Session sync (CLI ↔ web) | Yes | No | No | No | No |
186
+
187
+ ## BYOK (Bring Your Own Key)
188
+
189
+ Use your own API keys from any provider — zero markup, zero fees. Free.ai just proxies the request.
190
+
191
+ ```bash
192
+ # OpenAI
193
+ free-code config set provider openai
194
+ free-code config set api_key sk-proj-xxx
195
+
196
+ # Anthropic
197
+ free-code config set provider anthropic
198
+ free-code config set api_key sk-ant-xxx
199
+
200
+ # Google
201
+ free-code config set provider google
202
+ free-code config set api_key AIzaSyxxx
203
+
204
+ # OpenRouter (access 346+ models)
205
+ free-code config set provider openrouter
206
+ free-code config set api_key sk-or-xxx
207
+ ```
208
+
209
+ When using BYOK, requests go directly to the provider. No markup. No logging. Your key, your usage, your bill.
210
+
211
+ You can also set keys via environment variables:
212
+
213
+ ```bash
214
+ export FREEAI_PROVIDER=openai
215
+ export FREEAI_API_KEY=sk-proj-xxx
216
+ free-code
217
+ ```
218
+
219
+ ## Free.ai Ecosystem
220
+
221
+ - **[Free.ai](https://free.ai)** — 400+ free AI tools on the web
222
+ - **[Python SDK](https://github.com/freeaigit/free-sdk)** — `pip install free-dot-ai` — use Free.ai from your code
223
+ - **[CLI Coder](https://github.com/freeaigit/free-code)** — `pip install freeai-code` — AI coding in your terminal
224
+ - **[iOS App](https://free.ai/ios/)** — Native iPhone/iPad app
225
+ - **[Android App](https://free.ai/android/)** — Native Android app
226
+ - **[API Docs](https://free.ai/api/)** — Build on top of Free.ai
227
+ - **[Web IDE](https://free.ai/coder/)** — Code in your browser
228
+
229
+ ## License
230
+
231
+ MIT
@@ -0,0 +1,198 @@
1
+ # Free.ai Coder
2
+
3
+ Free AI coding assistant for your terminal. A free, open-source alternative to Claude Code, Cursor, and GitHub Copilot.
4
+
5
+ **[Website](https://free.ai/coder/)** | **[PyPI](https://pypi.org/project/freeai-code/)** | **[npm](https://www.npmjs.com/package/freeai-code)** | **[Web IDE](https://free.ai/coder/)**
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ # Universal (Linux / macOS)
11
+ curl -fsSL https://free.ai/install | sh
12
+
13
+ # pip
14
+ pip install freeai-code
15
+
16
+ # npm
17
+ npm install -g freeai-code
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ```bash
23
+ # Interactive coding session in your project directory
24
+ cd your-project/
25
+ free-code
26
+
27
+ # Ask a one-shot question about your codebase
28
+ free-code ask "How does the auth system work?"
29
+
30
+ # Execute a task
31
+ free-code run "Add unit tests for the User model"
32
+
33
+ # Run a task in the Free.ai cloud (codex-style) and watch it
34
+ free-code cloud "Fix the failing CI on main" --repo https://github.com/you/project
35
+
36
+ # Initialize and scan codebase
37
+ free-code init
38
+ ```
39
+
40
+ ## Commands
41
+
42
+ | Command | Description |
43
+ |---------|-------------|
44
+ | `free-code` | Interactive coding session (alias: `free-code chat`) |
45
+ | `free-code ask "question"` | One-shot question about the codebase |
46
+ | `free-code run "task"` | Execute a coding task |
47
+ | `free-code cloud "task"` | Run a coding task in the Free.ai cloud (`--repo URL`, `--model`, `--no-watch`, `--download DIR`) |
48
+ | `free-code tasks` | List your recent cloud tasks |
49
+ | `free-code init` | Initialize config, scan codebase |
50
+ | `free-code config` | Show current configuration |
51
+ | `free-code config set key value` | Set a config value |
52
+ | `free-code login` | Authenticate with Free.ai |
53
+
54
+ ## Features
55
+
56
+ - File read/write with diff preview and approval gates
57
+ - Shell command execution (with confirmation in safe mode)
58
+ - Git integration (status, diff, commit, branch)
59
+ - Test runner auto-detection (pytest, jest, go test, cargo test)
60
+ - Streaming output with syntax highlighting
61
+ - Context window optimization and repo map generation
62
+ - .gitignore-aware file discovery
63
+ - Session sync — continue conversations from [web](https://free.ai/coder/) to CLI and back
64
+ - Cloud tasks — run long coding tasks on Free.ai's GPUs and pick up the result later
65
+
66
+ ## Cloud Tasks
67
+
68
+ Run a coding task on Free.ai's infrastructure instead of your machine — like a codex agent from the terminal. Requires an API key: run `free-code login` and paste a key from [free.ai/developer](https://free.ai/developer/) (free tier works).
69
+
70
+ ```bash
71
+ # Submit and watch (polls until done, prints the markdown report)
72
+ free-code cloud "Add rate limiting to the API" --repo https://github.com/you/project
73
+
74
+ # Pick the cloud model
75
+ free-code cloud "Refactor the auth module" --model deepseek-coder
76
+
77
+ # Fire and forget (you get an email when it finishes)
78
+ free-code cloud "Write integration tests" --no-watch
79
+
80
+ # Download the resulting code as a zip, unpacked into ./result
81
+ free-code cloud "Fix the flaky test suite" --download ./result
82
+
83
+ # List recent tasks
84
+ free-code tasks
85
+ ```
86
+
87
+ ## Configuration
88
+
89
+ Config is stored at `~/.free-code/config.yaml`.
90
+
91
+ ```bash
92
+ # Set your Free.ai token (get one at https://free.ai/account/)
93
+ free-code config set token sk-free-xxx
94
+
95
+ # Use your own API key (BYOK — no markup, use your own provider)
96
+ free-code config set provider openai
97
+ free-code config set api_key sk-xxx
98
+
99
+ # Choose a model
100
+ free-code config set model qwen7b
101
+
102
+ # Enable safe mode (confirm before file writes)
103
+ free-code config set safe_mode true
104
+ ```
105
+
106
+ ### Supported Providers
107
+
108
+ | Provider | Default Model | Free Tier |
109
+ |----------|--------------|-----------|
110
+ | **free.ai** (default) | Qwen 7B | 50K tokens/day |
111
+ | **openai** | GPT-4o | BYOK — no markup |
112
+ | **anthropic** | Claude Sonnet 4 | BYOK — no markup |
113
+ | **google** | Gemini 2.5 Pro | BYOK — no markup |
114
+ | **openrouter** | 346+ models | BYOK — no markup |
115
+
116
+ ## How It Works
117
+
118
+ 1. Scans your project (respects .gitignore)
119
+ 2. Builds a context map of your codebase
120
+ 3. Sends your request + relevant code context to the AI
121
+ 4. AI plans steps, reads/writes files, runs commands
122
+ 5. You review and approve changes (safe mode)
123
+
124
+ All file operations happen locally on your machine. The AI sees only what it needs.
125
+
126
+ ## Pricing
127
+
128
+ - **Anonymous**: 10K tokens/day (Qwen Coder only)
129
+ - **Free account**: 50K tokens/day (sign up at [free.ai](https://free.ai/signup/))
130
+ - **Paid plans**: From $5/month for 200K tokens ([pricing](https://free.ai/pricing/))
131
+ - **BYOK**: $0 — bring your own API key, no markup
132
+
133
+ ## Links
134
+
135
+ - [Free.ai](https://free.ai) — 400+ free AI tools
136
+ - [Web IDE](https://free.ai/coder/) — Use in your browser
137
+ - [API Docs](https://free.ai/api/) — Build on top of Free.ai
138
+ - [Compare vs Claude Code](https://free.ai/compare/coder-vs-claude-code/)
139
+ - [Compare vs Cursor](https://free.ai/compare/coder-vs-cursor/)
140
+
141
+ ## vs Competitors
142
+
143
+ | Feature | Free.ai Coder | Claude Code | OpenAI Codex | Cursor | GitHub Copilot |
144
+ |---------|--------------|-------------|--------------|--------|----------------|
145
+ | Free tier | 50K tokens/day | None ($20/mo) | None ($200/mo) | None ($20/mo) | None ($10/mo) |
146
+ | Self-hosted models | Yes (Qwen, DeepSeek) | No | No | No | No |
147
+ | BYOK (bring your own key) | Yes — $0 markup | No | No | Partial | No |
148
+ | Open source CLI | Yes (MIT) | No | No | No | No |
149
+ | Web IDE | Yes (free.ai/coder/) | No | Yes | Yes | No |
150
+ | Terminal access | Yes | Yes | Yes | Yes | No |
151
+ | 346+ models | Yes | Claude only | GPT only | Multiple | GPT only |
152
+ | Session sync (CLI ↔ web) | Yes | No | No | No | No |
153
+
154
+ ## BYOK (Bring Your Own Key)
155
+
156
+ Use your own API keys from any provider — zero markup, zero fees. Free.ai just proxies the request.
157
+
158
+ ```bash
159
+ # OpenAI
160
+ free-code config set provider openai
161
+ free-code config set api_key sk-proj-xxx
162
+
163
+ # Anthropic
164
+ free-code config set provider anthropic
165
+ free-code config set api_key sk-ant-xxx
166
+
167
+ # Google
168
+ free-code config set provider google
169
+ free-code config set api_key AIzaSyxxx
170
+
171
+ # OpenRouter (access 346+ models)
172
+ free-code config set provider openrouter
173
+ free-code config set api_key sk-or-xxx
174
+ ```
175
+
176
+ When using BYOK, requests go directly to the provider. No markup. No logging. Your key, your usage, your bill.
177
+
178
+ You can also set keys via environment variables:
179
+
180
+ ```bash
181
+ export FREEAI_PROVIDER=openai
182
+ export FREEAI_API_KEY=sk-proj-xxx
183
+ free-code
184
+ ```
185
+
186
+ ## Free.ai Ecosystem
187
+
188
+ - **[Free.ai](https://free.ai)** — 400+ free AI tools on the web
189
+ - **[Python SDK](https://github.com/freeaigit/free-sdk)** — `pip install free-dot-ai` — use Free.ai from your code
190
+ - **[CLI Coder](https://github.com/freeaigit/free-code)** — `pip install freeai-code` — AI coding in your terminal
191
+ - **[iOS App](https://free.ai/ios/)** — Native iPhone/iPad app
192
+ - **[Android App](https://free.ai/android/)** — Native Android app
193
+ - **[API Docs](https://free.ai/api/)** — Build on top of Free.ai
194
+ - **[Web IDE](https://free.ai/coder/)** — Code in your browser
195
+
196
+ ## License
197
+
198
+ MIT
@@ -1,3 +1,3 @@
1
1
  """Free.ai Coder CLI — Free AI coding assistant."""
2
2
 
3
- __version__ = "0.1.0"
3
+ __version__ = "0.1.2"
@@ -211,6 +211,148 @@ def run(task: tuple) -> None:
211
211
  sys.exit(1)
212
212
 
213
213
 
214
+ @main.command()
215
+ @click.argument("prompt", nargs=-1, required=True)
216
+ @click.option("--repo", "repo_url", default=None, metavar="URL",
217
+ help="Git repository URL to run the task against.")
218
+ @click.option("--model", "model",
219
+ type=click.Choice(["qwen-coder-32b", "deepseek-coder"]),
220
+ default="qwen-coder-32b", show_default=True,
221
+ help="Cloud model to run the task with.")
222
+ @click.option("--no-watch", is_flag=True,
223
+ help="Submit and exit without polling for the result.")
224
+ @click.option("--download", "download_dir", metavar="DIR",
225
+ type=click.Path(file_okay=False), default=None,
226
+ help="Download and unzip the task output into DIR on completion.")
227
+ def cloud(prompt: tuple, repo_url: Optional[str], model: str,
228
+ no_watch: bool, download_dir: Optional[str]) -> None:
229
+ """Run a coding task in the Free.ai cloud and stream its progress."""
230
+ import time
231
+
232
+ from free_code.cloud import (
233
+ AuthRequired,
234
+ CloudClient,
235
+ CloudError,
236
+ POLL_INTERVAL,
237
+ queue_position_of,
238
+ task_id_of,
239
+ )
240
+ from free_code.ui.terminal import print_error, print_info, print_markdown, print_success
241
+
242
+ client = CloudClient()
243
+ prompt_str = " ".join(prompt)
244
+
245
+ try:
246
+ task = client.submit(prompt_str, repo_url=repo_url, model=model)
247
+ except AuthRequired as e:
248
+ console.print(str(e))
249
+ sys.exit(1)
250
+ except CloudError as e:
251
+ print_error(str(e))
252
+ sys.exit(1)
253
+
254
+ task_id = task_id_of(task)
255
+ if not task_id:
256
+ print_error(f"Unexpected API response: {task}")
257
+ sys.exit(1)
258
+
259
+ position = queue_position_of(task)
260
+ if position is not None:
261
+ print_success(f"Task submitted: {task_id} (queue position {position})")
262
+ else:
263
+ print_success(f"Task submitted: {task_id}")
264
+
265
+ if no_watch and not download_dir:
266
+ print_info("Check progress with: free-code tasks")
267
+ return
268
+ if no_watch and download_dir:
269
+ print_info("--download requires watching the task; polling anyway.")
270
+
271
+ last_printed = None
272
+ try:
273
+ while True:
274
+ try:
275
+ task = client.get(task_id)
276
+ except CloudError as e:
277
+ print_error(str(e))
278
+ sys.exit(1)
279
+
280
+ status = str(task.get("status", "")).lower()
281
+ position = queue_position_of(task)
282
+ line = f"queued (position {position})" if status == "queued" and position is not None else status
283
+ if line != last_printed:
284
+ print_info(f"Status: {line}")
285
+ last_printed = line
286
+
287
+ if status in ("completed", "failed", "cancelled", "error"):
288
+ break
289
+ time.sleep(POLL_INTERVAL)
290
+ except KeyboardInterrupt:
291
+ console.print(f"\n[dim]Stopped watching. Task {task_id} keeps running; "
292
+ f"check it with: free-code tasks[/dim]")
293
+ return
294
+
295
+ if status == "completed":
296
+ result_text = task.get("result_text") or task.get("result") or ""
297
+ if result_text:
298
+ console.print()
299
+ print_markdown(str(result_text))
300
+ output_url = task.get("output_url")
301
+ if output_url:
302
+ print_info(f"Output: {output_url}")
303
+ if download_dir:
304
+ try:
305
+ dest = client.download_output(str(output_url), download_dir)
306
+ print_success(f"Output downloaded and extracted to {dest}")
307
+ except CloudError as e:
308
+ print_error(str(e))
309
+ sys.exit(1)
310
+ elif download_dir:
311
+ print_info("Task completed but has no downloadable output.")
312
+ else:
313
+ error = task.get("error") or task.get("result_text") or "no details"
314
+ print_error(f"Task {status}: {error}")
315
+ sys.exit(1)
316
+
317
+
318
+ @main.command()
319
+ def tasks() -> None:
320
+ """List your recent cloud tasks."""
321
+ from free_code.cloud import AuthRequired, CloudClient, CloudError, task_id_of
322
+ from free_code.ui.terminal import print_error
323
+
324
+ client = CloudClient()
325
+ try:
326
+ items = client.list()
327
+ except AuthRequired as e:
328
+ console.print(str(e))
329
+ sys.exit(1)
330
+ except CloudError as e:
331
+ print_error(str(e))
332
+ sys.exit(1)
333
+
334
+ if not items:
335
+ console.print("[dim]No cloud tasks yet. Start one with: "
336
+ "free-code cloud \"task description\"[/dim]")
337
+ return
338
+
339
+ table = Table(title="Cloud Tasks", show_header=True, header_style="bold")
340
+ table.add_column("ID", style="cyan")
341
+ table.add_column("Status")
342
+ table.add_column("Created")
343
+ table.add_column("Task")
344
+
345
+ for item in items:
346
+ task_id = task_id_of(item)
347
+ preview = str(item.get("prompt") or item.get("preview") or "").replace("\n", " ")
348
+ if len(preview) > 60:
349
+ preview = preview[:57] + "..."
350
+ created = str(item.get("created_at") or item.get("created") or "")[:19].replace("T", " ")
351
+ table.add_row(task_id[:8], str(item.get("status", "")), created, preview)
352
+
353
+ console.print(table)
354
+
355
+
214
356
  @main.command()
215
357
  def init() -> None:
216
358
  """Initialize free-code in the current project."""
@@ -8,6 +8,7 @@ from typing import Any, AsyncIterator, Dict, List, Optional
8
8
 
9
9
  import httpx
10
10
 
11
+ from free_code import __version__
11
12
  from free_code.config import (
12
13
  get_api_url,
13
14
  get_auth_header,
@@ -29,7 +30,7 @@ class CoderClient:
29
30
  self.api_url = get_api_url(self.config)
30
31
  self.headers = get_auth_header(self.config)
31
32
  self.headers["Content-Type"] = "application/json"
32
- self.headers["User-Agent"] = "free-code/0.1.0"
33
+ self.headers["User-Agent"] = f"free-code/{__version__}"
33
34
 
34
35
  async def chat_stream(
35
36
  self,
@@ -38,73 +39,15 @@ class CoderClient:
38
39
  tools: Optional[List[Dict[str, Any]]] = None,
39
40
  ) -> AsyncIterator[Dict[str, Any]]:
40
41
  """Stream a chat completion, yielding parsed events."""
41
- if self.provider == "free.ai":
42
- async for event in self._stream_free_ai(messages, system, tools):
43
- yield event
44
- elif self.provider == "anthropic":
42
+ if self.provider == "anthropic":
45
43
  async for event in self._stream_anthropic(messages, system, tools):
46
44
  yield event
47
45
  else:
48
- # OpenAI-compatible (OpenAI, OpenRouter, Google via compat)
46
+ # OpenAI-compatible (Free.ai /v1/chat/completions, OpenAI,
47
+ # OpenRouter, Google via compat)
49
48
  async for event in self._stream_openai_compat(messages, system, tools):
50
49
  yield event
51
50
 
52
- async def _stream_free_ai(
53
- self,
54
- messages: List[Dict[str, str]],
55
- system: Optional[str] = None,
56
- tools: Optional[List[Dict[str, Any]]] = None,
57
- ) -> AsyncIterator[Dict[str, Any]]:
58
- """Stream from the Free.ai coder agent endpoint."""
59
- payload: Dict[str, Any] = {
60
- "messages": messages,
61
- "model": self.model,
62
- "stream": True,
63
- }
64
- if system:
65
- payload["system"] = system
66
- if tools:
67
- payload["tools"] = tools
68
-
69
- try:
70
- async with httpx.AsyncClient(timeout=DEFAULT_TIMEOUT) as client:
71
- async with client.stream(
72
- "POST",
73
- self.api_url,
74
- json=payload,
75
- headers=self.headers,
76
- ) as response:
77
- if response.status_code != 200:
78
- body = await response.aread()
79
- yield {
80
- "type": "error",
81
- "content": f"API error {response.status_code}: {body.decode(errors='replace')}",
82
- }
83
- return
84
-
85
- buffer = ""
86
- async for chunk in response.aiter_text():
87
- buffer += chunk
88
- while "\n\n" in buffer:
89
- event_str, buffer = buffer.split("\n\n", 1)
90
- for line in event_str.strip().split("\n"):
91
- if line.startswith("data: "):
92
- data_str = line[6:]
93
- if data_str == "[DONE]":
94
- yield {"type": "done"}
95
- return
96
- try:
97
- yield json.loads(data_str)
98
- except json.JSONDecodeError:
99
- yield {"type": "text", "content": data_str}
100
- except httpx.ConnectError:
101
- yield {
102
- "type": "error",
103
- "content": "Cannot connect to Free.ai API. Check your internet connection.",
104
- }
105
- except httpx.TimeoutException:
106
- yield {"type": "error", "content": "Request timed out."}
107
-
108
51
  async def _stream_openai_compat(
109
52
  self,
110
53
  messages: List[Dict[str, str]],
@@ -122,6 +65,8 @@ class CoderClient:
122
65
  "messages": all_messages,
123
66
  "stream": True,
124
67
  }
68
+ if tools:
69
+ payload["tools"] = tools
125
70
 
126
71
  try:
127
72
  async with httpx.AsyncClient(timeout=DEFAULT_TIMEOUT) as client: