mlx-code 0.0.8__tar.gz → 0.0.10__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 (37) hide show
  1. mlx_code-0.0.10/PKG-INFO +219 -0
  2. mlx_code-0.0.10/README.md +190 -0
  3. mlx_code-0.0.10/mlx_code/__init__.py +0 -0
  4. mlx_code-0.0.10/mlx_code/apis.py +1133 -0
  5. mlx_code-0.0.10/mlx_code/gits.py +252 -0
  6. mlx_code-0.0.10/mlx_code/lsp_tool.py +882 -0
  7. {mlx_code-0.0.8 → mlx_code-0.0.10}/mlx_code/main.py +792 -745
  8. mlx_code-0.0.10/mlx_code/mcb.py +243 -0
  9. mlx_code-0.0.10/mlx_code/mcb_tool.py +73 -0
  10. mlx_code-0.0.10/mlx_code/repl.py +766 -0
  11. mlx_code-0.0.10/mlx_code/stream_log.py +62 -0
  12. mlx_code-0.0.10/mlx_code/tools.py +504 -0
  13. mlx_code-0.0.10/mlx_code/util.py +49 -0
  14. mlx_code-0.0.10/mlx_code/view_git.py +951 -0
  15. mlx_code-0.0.8/mlx_code/log.py → mlx_code-0.0.10/mlx_code/view_log.py +235 -218
  16. mlx_code-0.0.10/mlx_code.egg-info/PKG-INFO +219 -0
  17. mlx_code-0.0.10/mlx_code.egg-info/SOURCES.txt +24 -0
  18. mlx_code-0.0.10/mlx_code.egg-info/entry_points.txt +5 -0
  19. mlx_code-0.0.10/mlx_code.egg-info/requires.txt +9 -0
  20. {mlx_code-0.0.8 → mlx_code-0.0.10}/mlx_code.egg-info/top_level.txt +1 -0
  21. mlx_code-0.0.10/setup.py +31 -0
  22. mlx_code-0.0.10/tests/__init__.py +0 -0
  23. mlx_code-0.0.10/tests/test.py +75 -0
  24. mlx_code-0.0.8/PKG-INFO +0 -557
  25. mlx_code-0.0.8/README.md +0 -528
  26. mlx_code-0.0.8/mlx_code/__init__.py +0 -4
  27. mlx_code-0.0.8/mlx_code/ledger.py +0 -192
  28. mlx_code-0.0.8/mlx_code/pie.py +0 -2105
  29. mlx_code-0.0.8/mlx_code/symgraph.py +0 -483
  30. mlx_code-0.0.8/mlx_code.egg-info/PKG-INFO +0 -557
  31. mlx_code-0.0.8/mlx_code.egg-info/SOURCES.txt +0 -15
  32. mlx_code-0.0.8/mlx_code.egg-info/entry_points.txt +0 -4
  33. mlx_code-0.0.8/mlx_code.egg-info/requires.txt +0 -7
  34. mlx_code-0.0.8/setup.py +0 -21
  35. {mlx_code-0.0.8 → mlx_code-0.0.10}/LICENSE +0 -0
  36. {mlx_code-0.0.8 → mlx_code-0.0.10}/mlx_code.egg-info/dependency_links.txt +0 -0
  37. {mlx_code-0.0.8 → mlx_code-0.0.10}/setup.cfg +0 -0
@@ -0,0 +1,219 @@
1
+ Metadata-Version: 2.4
2
+ Name: mlx-code
3
+ Version: 0.0.10
4
+ Summary: Coding Agent for Mac
5
+ Home-page: https://github.com/JosefAlbers/mlx-code
6
+ Author: J Joe
7
+ Author-email: albersj66@gmail.com
8
+ License: Apache-2.0
9
+ Requires-Python: >=3.12.8
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: mlx-lm>=0.31.3; platform_system == "Darwin"
13
+ Requires-Dist: httpx
14
+ Requires-Dist: pydantic
15
+ Requires-Dist: GitPython
16
+ Provides-Extra: all
17
+ Requires-Dist: python-lsp-server[all]; extra == "all"
18
+ Dynamic: author
19
+ Dynamic: author-email
20
+ Dynamic: description
21
+ Dynamic: description-content-type
22
+ Dynamic: home-page
23
+ Dynamic: license
24
+ Dynamic: license-file
25
+ Dynamic: provides-extra
26
+ Dynamic: requires-dist
27
+ Dynamic: requires-python
28
+ Dynamic: summary
29
+
30
+ # mlx-code
31
+
32
+ A lightweight coding agent built on Apple's MLX framework.
33
+
34
+ [![demo](https://raw.githubusercontent.com/JosefAlbers/mlx-code/main/assets/mlx-code.gif)](https://youtu.be/0lkY7YQCyCo)
35
+
36
+ ---
37
+
38
+ ## Features
39
+
40
+ - **Composable by design**: `Agent`, `Tool`, and the REPL are separate pieces you can import and wire together however you like
41
+ - **Swappable backends**: point the harness at the local MLX server, a remote provider, or any OpenAI-compatible endpoint without changing anything else
42
+ - **Git worktree isolation**: every session gets a fresh worktree so the agent can't silently corrupt your working tree
43
+ - **9 built-in tools**: `Read`, `Write`, `Edit`, `Bash`, `Grep`, `Find`, `Ls`, `Skill`, `Agent`
44
+ - **Interactive REPL commands**: `/clear`, `/history`, `/tools`, `/branch`, `/abort`
45
+
46
+ ---
47
+
48
+ ## Quick Start
49
+
50
+ ```bash
51
+ pip install mlx-code
52
+ mlc
53
+ ```
54
+
55
+ ---
56
+
57
+ ## Command Line
58
+
59
+ ### `mlc`: local server + harness
60
+
61
+ Starts the MLX inference server and launches a harness against it.
62
+
63
+ ```bash
64
+ # Default: local MLX server + built-in REPL harness
65
+ mlc
66
+
67
+ # Use a different harness (routes traffic through the local server)
68
+ mlc --leash claude
69
+ mlc --leash gemini
70
+ mlc --leash codex
71
+
72
+ # Server only, no harness
73
+ mlc --leash none
74
+
75
+ # Specify a model
76
+ mlc --model mlx-community/Qwen3.5-4B-OptiQ-4bit
77
+
78
+ # Restrict the tools available to the agent
79
+ mlc --tools Read Write Bash
80
+
81
+ # Custom system prompt
82
+ mlc --system "You are a helpful assistant."
83
+
84
+ # Load skills from a directory (scans recursively for SKILL.md files)
85
+ mlc --skill ./my-skills
86
+
87
+ # Resume a previous session from a git commit hash
88
+ mlc --resume <commit-hash>
89
+
90
+ # Because `mlc` reads from stdin when it isn't a TTY, it composes naturally with shell pipes:
91
+ echo "Here's the solution you proposed: <excerpt>$(mlc -p "write code for a chrome extension to play youtube x5 speed")</excerpt> Now argue against it. What are the edge cases this doesn't handle? What assumptions did you make that might not hold in a production system? What would you change if you knew this code would be read by a senior engineer in a security audit?" | mlc
92
+ ```
93
+
94
+ ### `mlc-run`: harness only
95
+
96
+ Runs the agent harness against an already-running server or a remote provider.
97
+
98
+ ```bash
99
+ # Connect to a local server at 127.0.0.1:8000 (default)
100
+ mlc-run
101
+
102
+ # Remote providers
103
+ mlc-run --api claude
104
+ mlc-run --api gemini
105
+ mlc-run --api deepseek --model deepseek-v4-pro
106
+ mlc-run --api codex
107
+
108
+ # Custom endpoint
109
+ echo "explain lsp.py" | mlc-run -a deepseek | cat - PLAN.md | mlc-run --url http://localhost:9000
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Using as a Library
115
+
116
+ Import the pieces you need to build background workers, scheduled jobs, or event-triggered handlers.
117
+
118
+ ### Spawn an agent from Python
119
+
120
+ ```python
121
+ import asyncio
122
+ from mlx_code.repl import Agent
123
+
124
+ async def main():
125
+ agent = Agent(system="You are a concise technical writer.")
126
+ await agent.run("Summarise all *.py files changed in the last 7 days. Save to digest.md.")
127
+
128
+ asyncio.run(main())
129
+ ```
130
+
131
+ ### Multi-agent pipeline
132
+
133
+ ```python
134
+ import asyncio
135
+ from mlx_code.repl import Agent
136
+
137
+ async def main():
138
+ researcher = Agent(system="You are a research assistant.")
139
+ await researcher.run("Research PBFT consensus. Save a structured summary to kb/draft.md.")
140
+
141
+ reviewer = Agent(system="You are a critical reviewer.")
142
+ await reviewer.run(
143
+ "Read kb/draft.md. Write a one-paragraph critique to kb/critique.md. "
144
+ "Use only information in that file."
145
+ )
146
+
147
+ asyncio.run(main())
148
+ ```
149
+
150
+ ### Parallel workers with `asyncio.gather`
151
+
152
+ ```python
153
+ import asyncio
154
+ from mlx_code.repl import Agent
155
+
156
+ async def main():
157
+ topics = ["history", "algorithms", "industry_usage"]
158
+ agents = [Agent() for _ in topics]
159
+ await asyncio.gather(*[
160
+ a.run(f"Research the {t} of Byzantine Fault Tolerance. Save to kb/{t}.md.")
161
+ for a, t in zip(agents, topics)
162
+ ])
163
+ reducer = Agent()
164
+ await reducer.run("Read all files in kb/. Synthesise into final_report.md.")
165
+
166
+ asyncio.run(main())
167
+ ```
168
+
169
+ ### Resume a session from a git commit
170
+
171
+ mlx-code stores the full conversation as JSON in each commit message, so you can restore both the workspace state and the agent's memory from any checkpoint.
172
+
173
+ ```python
174
+ import asyncio
175
+ from mlx_code.gits import resume_worktree
176
+ from mlx_code.repl import Agent, repl
177
+
178
+ async def main():
179
+ gwt, messages = resume_worktree(".", "abc1234")
180
+ agent = Agent(ctx={"gwt": gwt})
181
+ agent.messages = messages
182
+ await repl(agent)
183
+
184
+ asyncio.run(main())
185
+ ```
186
+
187
+ ### Custom tools
188
+
189
+ Subclass `Tool`, define a Pydantic schema, and pass the class at instantiation.
190
+
191
+ ```python
192
+ from mlx_code.tools import Tool
193
+ from mlx_code.repl import Agent
194
+ from pydantic import BaseModel, Field
195
+
196
+ class QueryParams(BaseModel):
197
+ query: str = Field(description="SQL query to run")
198
+
199
+ class LiveDBTool(Tool):
200
+ name = "QueryDB"
201
+ description = "Execute a query against the dev database"
202
+ parameters = QueryParams
203
+
204
+ async def execute(self, params: QueryParams, signal=None) -> dict:
205
+ result = run_query(params.query) # your logic here
206
+ return {"content": [{"type": "text", "text": result}], "is_error": False}
207
+
208
+ agent = Agent(extra_tool_classes=[LiveDBTool], tool_names=["QueryDB"])
209
+ ```
210
+
211
+ ---
212
+
213
+ ## Credits
214
+
215
+ Built on [mlx](https://github.com/ml-explore/mlx) and [mlx-lm](https://github.com/ml-explore/mlx-lm). Inspired by Mario Zechner's [pi](https://github.com/badlogic/pi-mono).
216
+
217
+ ## License
218
+
219
+ Apache License 2.0: see [LICENSE](LICENSE) for details.
@@ -0,0 +1,190 @@
1
+ # mlx-code
2
+
3
+ A lightweight coding agent built on Apple's MLX framework.
4
+
5
+ [![demo](https://raw.githubusercontent.com/JosefAlbers/mlx-code/main/assets/mlx-code.gif)](https://youtu.be/0lkY7YQCyCo)
6
+
7
+ ---
8
+
9
+ ## Features
10
+
11
+ - **Composable by design**: `Agent`, `Tool`, and the REPL are separate pieces you can import and wire together however you like
12
+ - **Swappable backends**: point the harness at the local MLX server, a remote provider, or any OpenAI-compatible endpoint without changing anything else
13
+ - **Git worktree isolation**: every session gets a fresh worktree so the agent can't silently corrupt your working tree
14
+ - **9 built-in tools**: `Read`, `Write`, `Edit`, `Bash`, `Grep`, `Find`, `Ls`, `Skill`, `Agent`
15
+ - **Interactive REPL commands**: `/clear`, `/history`, `/tools`, `/branch`, `/abort`
16
+
17
+ ---
18
+
19
+ ## Quick Start
20
+
21
+ ```bash
22
+ pip install mlx-code
23
+ mlc
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Command Line
29
+
30
+ ### `mlc`: local server + harness
31
+
32
+ Starts the MLX inference server and launches a harness against it.
33
+
34
+ ```bash
35
+ # Default: local MLX server + built-in REPL harness
36
+ mlc
37
+
38
+ # Use a different harness (routes traffic through the local server)
39
+ mlc --leash claude
40
+ mlc --leash gemini
41
+ mlc --leash codex
42
+
43
+ # Server only, no harness
44
+ mlc --leash none
45
+
46
+ # Specify a model
47
+ mlc --model mlx-community/Qwen3.5-4B-OptiQ-4bit
48
+
49
+ # Restrict the tools available to the agent
50
+ mlc --tools Read Write Bash
51
+
52
+ # Custom system prompt
53
+ mlc --system "You are a helpful assistant."
54
+
55
+ # Load skills from a directory (scans recursively for SKILL.md files)
56
+ mlc --skill ./my-skills
57
+
58
+ # Resume a previous session from a git commit hash
59
+ mlc --resume <commit-hash>
60
+
61
+ # Because `mlc` reads from stdin when it isn't a TTY, it composes naturally with shell pipes:
62
+ echo "Here's the solution you proposed: <excerpt>$(mlc -p "write code for a chrome extension to play youtube x5 speed")</excerpt> Now argue against it. What are the edge cases this doesn't handle? What assumptions did you make that might not hold in a production system? What would you change if you knew this code would be read by a senior engineer in a security audit?" | mlc
63
+ ```
64
+
65
+ ### `mlc-run`: harness only
66
+
67
+ Runs the agent harness against an already-running server or a remote provider.
68
+
69
+ ```bash
70
+ # Connect to a local server at 127.0.0.1:8000 (default)
71
+ mlc-run
72
+
73
+ # Remote providers
74
+ mlc-run --api claude
75
+ mlc-run --api gemini
76
+ mlc-run --api deepseek --model deepseek-v4-pro
77
+ mlc-run --api codex
78
+
79
+ # Custom endpoint
80
+ echo "explain lsp.py" | mlc-run -a deepseek | cat - PLAN.md | mlc-run --url http://localhost:9000
81
+ ```
82
+
83
+ ---
84
+
85
+ ## Using as a Library
86
+
87
+ Import the pieces you need to build background workers, scheduled jobs, or event-triggered handlers.
88
+
89
+ ### Spawn an agent from Python
90
+
91
+ ```python
92
+ import asyncio
93
+ from mlx_code.repl import Agent
94
+
95
+ async def main():
96
+ agent = Agent(system="You are a concise technical writer.")
97
+ await agent.run("Summarise all *.py files changed in the last 7 days. Save to digest.md.")
98
+
99
+ asyncio.run(main())
100
+ ```
101
+
102
+ ### Multi-agent pipeline
103
+
104
+ ```python
105
+ import asyncio
106
+ from mlx_code.repl import Agent
107
+
108
+ async def main():
109
+ researcher = Agent(system="You are a research assistant.")
110
+ await researcher.run("Research PBFT consensus. Save a structured summary to kb/draft.md.")
111
+
112
+ reviewer = Agent(system="You are a critical reviewer.")
113
+ await reviewer.run(
114
+ "Read kb/draft.md. Write a one-paragraph critique to kb/critique.md. "
115
+ "Use only information in that file."
116
+ )
117
+
118
+ asyncio.run(main())
119
+ ```
120
+
121
+ ### Parallel workers with `asyncio.gather`
122
+
123
+ ```python
124
+ import asyncio
125
+ from mlx_code.repl import Agent
126
+
127
+ async def main():
128
+ topics = ["history", "algorithms", "industry_usage"]
129
+ agents = [Agent() for _ in topics]
130
+ await asyncio.gather(*[
131
+ a.run(f"Research the {t} of Byzantine Fault Tolerance. Save to kb/{t}.md.")
132
+ for a, t in zip(agents, topics)
133
+ ])
134
+ reducer = Agent()
135
+ await reducer.run("Read all files in kb/. Synthesise into final_report.md.")
136
+
137
+ asyncio.run(main())
138
+ ```
139
+
140
+ ### Resume a session from a git commit
141
+
142
+ mlx-code stores the full conversation as JSON in each commit message, so you can restore both the workspace state and the agent's memory from any checkpoint.
143
+
144
+ ```python
145
+ import asyncio
146
+ from mlx_code.gits import resume_worktree
147
+ from mlx_code.repl import Agent, repl
148
+
149
+ async def main():
150
+ gwt, messages = resume_worktree(".", "abc1234")
151
+ agent = Agent(ctx={"gwt": gwt})
152
+ agent.messages = messages
153
+ await repl(agent)
154
+
155
+ asyncio.run(main())
156
+ ```
157
+
158
+ ### Custom tools
159
+
160
+ Subclass `Tool`, define a Pydantic schema, and pass the class at instantiation.
161
+
162
+ ```python
163
+ from mlx_code.tools import Tool
164
+ from mlx_code.repl import Agent
165
+ from pydantic import BaseModel, Field
166
+
167
+ class QueryParams(BaseModel):
168
+ query: str = Field(description="SQL query to run")
169
+
170
+ class LiveDBTool(Tool):
171
+ name = "QueryDB"
172
+ description = "Execute a query against the dev database"
173
+ parameters = QueryParams
174
+
175
+ async def execute(self, params: QueryParams, signal=None) -> dict:
176
+ result = run_query(params.query) # your logic here
177
+ return {"content": [{"type": "text", "text": result}], "is_error": False}
178
+
179
+ agent = Agent(extra_tool_classes=[LiveDBTool], tool_names=["QueryDB"])
180
+ ```
181
+
182
+ ---
183
+
184
+ ## Credits
185
+
186
+ Built on [mlx](https://github.com/ml-explore/mlx) and [mlx-lm](https://github.com/ml-explore/mlx-lm). Inspired by Mario Zechner's [pi](https://github.com/badlogic/pi-mono).
187
+
188
+ ## License
189
+
190
+ Apache License 2.0: see [LICENSE](LICENSE) for details.
File without changes