mycode-aiagent 0.4.1__tar.gz → 0.4.3__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 (27) hide show
  1. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/PKG-INFO +35 -21
  2. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/README.md +34 -20
  3. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/my_code/__init__.py +1 -2
  4. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/my_code/backends/__init__.py +6 -8
  5. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/my_code/backends/openai_backend.py +5 -2
  6. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/my_code/cli.py +11 -11
  7. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/mycode_aiagent.egg-info/PKG-INFO +35 -21
  8. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/mycode_aiagent.egg-info/SOURCES.txt +0 -1
  9. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/pyproject.toml +1 -1
  10. mycode_aiagent-0.4.1/my_code/backends/ricky_backend.py +0 -15
  11. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/my_code/__main__.py +0 -0
  12. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/my_code/analyzer.py +0 -0
  13. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/my_code/backends/base.py +0 -0
  14. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/my_code/backends/claude_backend.py +0 -0
  15. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/my_code/backends/mcp_backend.py +0 -0
  16. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/my_code/generator.py +0 -0
  17. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/my_code/mcp_client.py +0 -0
  18. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/my_code/server.py +0 -0
  19. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/my_code/utils/__init__.py +0 -0
  20. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/my_code/utils/prompts.py +0 -0
  21. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/mycode_aiagent.egg-info/dependency_links.txt +0 -0
  22. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/mycode_aiagent.egg-info/entry_points.txt +0 -0
  23. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/mycode_aiagent.egg-info/requires.txt +0 -0
  24. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/mycode_aiagent.egg-info/top_level.txt +0 -0
  25. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/setup.cfg +0 -0
  26. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/tests/test_library.py +0 -0
  27. {mycode_aiagent-0.4.1 → mycode_aiagent-0.4.3}/tests/test_server.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mycode-aiagent
3
- Version: 0.4.1
3
+ Version: 0.4.3
4
4
  Summary: Style-aware code generation — analyze any codebase and generate new code that matches its style
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://github.com/RyanAbbottData/MyCode
@@ -90,16 +90,29 @@ MyCode delegates inference to a pluggable backend. Choose one based on what you
90
90
 
91
91
  | Backend | Flag | Requirement |
92
92
  |---|---|---|
93
- | Local LLM | `--backend llama` (default) | MCP server running at `localhost:8000` |
94
- | Anthropic Claude | `--backend claude` | `ANTHROPIC_API_KEY` env var or `--api-key` |
93
+ | Anthropic Claude | `--backend claude` (default) | `ANTHROPIC_API_KEY` env var or `--api-key` |
95
94
  | OpenAI | `--backend openai` | `OPENAI_API_KEY` env var or `--api-key` |
96
- | MyCode server | `--backend mcp` | A running MyCode MCP server at `--mcp-url` |
95
+ | Local LLM (OpenAI-compatible) | `--backend local` | LLM server at `--llm-url` (default: `http://localhost:8080/v1`) |
96
+ | Any MCP server | `--backend mcp` | A running MyCode MCP server at `--mcp-url` |
97
97
 
98
98
  When `--backend mcp` is used with `analyze` or `generate`, the CLI delegates the entire operation to the running MyCode server — it calls the server's `analyze_codebase` or `generate_code` tool directly instead of running the pipeline locally. This is the recommended way to use MyCode in a multi-project or agentic setup.
99
99
 
100
100
  ### Setting up a local LLM
101
101
 
102
- The `llama` backend expects an MCP server at `http://localhost:8000/mcp` that exposes two tools: one for code generation and one for analysis. Any MCP-compatible wrapper around a local model will work. Here is a recommended setup using [llama.cpp](https://github.com/ggerganov/llama.cpp):
102
+ Use `--backend local` to connect MyCode directly to any OpenAI-compatible LLM server (llama.cpp, LM Studio, Ollama, etc.) no wrapper needed. Point `--llm-url` at the server's `/v1` base URL:
103
+
104
+ ```bash
105
+ # Start your local LLM server (example: llama.cpp)
106
+ python -m llama_cpp.server --model ./models/codellama-7b-instruct.Q4_K_M.gguf --port 8080
107
+
108
+ # Analyze using the local LLM directly
109
+ my-code --backend local --llm-url http://localhost:8080/v1 analyze ./my_project
110
+
111
+ # Or start a MyCode MCP server backed by your local LLM
112
+ my-code --backend local --llm-url http://localhost:8080/v1 serve --port 8000 --daemon
113
+ ```
114
+
115
+ If you need a full MCP-wrapped setup instead (e.g. the local LLM exposes only `/v1/completions` without chat completions), here is a recommended pattern using [llama.cpp](https://github.com/ggerganov/llama.cpp):
103
116
 
104
117
  **1. Download a model**
105
118
 
@@ -126,7 +139,7 @@ python -m llama_cpp.server \
126
139
 
127
140
  **3. Wrap it with an MCP server**
128
141
 
129
- The `llama` backend communicates over MCP, not directly with the llama.cpp HTTP API. You need a thin MCP wrapper that exposes two tools:
142
+ The `mcp` backend communicates over MCP, not directly with the llama.cpp HTTP API. You need a thin MCP wrapper that exposes two tools:
130
143
  - A **code generation tool** (name must not contain `"analyze"`)
131
144
  - An **analysis tool** (name must contain `"analyze"`)
132
145
 
@@ -168,13 +181,13 @@ python llm_mcp_server.py
168
181
  **4. Point MyCode at it**
169
182
 
170
183
  ```bash
171
- my-code --backend llama --ricky-url http://localhost:8000/mcp analyze .
184
+ my-code --backend mcp --mcp-url http://localhost:8000/mcp analyze .
172
185
  ```
173
186
 
174
187
  Or set a custom URL if your server runs on a different port:
175
188
 
176
189
  ```bash
177
- my-code --backend llama --ricky-url http://localhost:9000/mcp analyze .
190
+ my-code --backend mcp --mcp-url http://localhost:9000/mcp analyze .
178
191
  ```
179
192
 
180
193
  ---
@@ -198,6 +211,7 @@ Using a different backend:
198
211
  ```bash
199
212
  my-code --backend claude analyze ./path/to/codebase
200
213
  my-code --backend openai --api-key sk-... analyze ./path/to/codebase
214
+ my-code --backend local --llm-url http://localhost:8080/v1 analyze ./path/to/codebase
201
215
  ```
202
216
 
203
217
  The profile is saved to `style_profile.json` by default. Specify a different path with `--profile`:
@@ -240,11 +254,11 @@ my-code --backend mcp --mcp-url http://localhost:8000/mcp generate "write a rate
240
254
  my-code [OPTIONS] COMMAND
241
255
 
242
256
  Options:
243
- --backend {llama,claude,openai,mcp} AI backend to use (default: llama)
257
+ --backend {claude,openai,local,mcp} AI backend to use (default: claude)
244
258
  --api-key TEXT API key for claude/openai backends
245
259
  --model TEXT Override the default model
246
- --ricky-url TEXT Local LLM MCP server URL (default: http://localhost:8000/mcp)
247
- --mcp-url TEXT Custom MCP server URL (default: http://localhost:8001/mcp)
260
+ --mcp-url TEXT MyCode MCP server URL (mcp backend, default: http://localhost:8001/mcp)
261
+ --llm-url TEXT Base URL of a local OpenAI-compatible LLM server (local backend, default: http://localhost:8080/v1)
248
262
  --profile TEXT Path to style profile JSON (default: style_profile.json)
249
263
 
250
264
  Commands:
@@ -274,9 +288,10 @@ from my_code import StyleAnalyzer, generate_code, make_backend
274
288
  from pathlib import Path
275
289
 
276
290
  # Create a backend
277
- backend = make_backend() # local LLM (default)
278
- backend = make_backend("claude") # Claude (reads ANTHROPIC_API_KEY)
279
- backend = make_backend("openai", api_key="sk-...") # OpenAI
291
+ backend = make_backend("claude") # Claude (reads ANTHROPIC_API_KEY)
292
+ backend = make_backend("openai", api_key="sk-...") # OpenAI (GPT models)
293
+ backend = make_backend("local", llm_url="http://localhost:8080/v1") # Local LLM (OpenAI-compatible)
294
+ backend = make_backend("mcp", mcp_url="http://localhost:8000/mcp") # Delegate to a MyCode server
280
295
 
281
296
  # Analyze a codebase
282
297
  analyzer = StyleAnalyzer(backend)
@@ -328,15 +343,15 @@ MyCode can expose itself as an MCP server so any MCP-compatible agent or orchest
328
343
  ### Quick start
329
344
 
330
345
  ```bash
331
- # Local LLM backend (default) — foreground, blocks until Ctrl-C
332
- my-code serve
333
-
334
- # Claude backend
346
+ # Claude backend — foreground, blocks until Ctrl-C
335
347
  my-code --backend claude serve --port 8080
336
348
 
337
349
  # OpenAI backend
338
350
  my-code --backend openai serve --port 8080
339
351
 
352
+ # Local LLM (OpenAI-compatible server on port 8080)
353
+ my-code --backend local --llm-url http://localhost:8080/v1 serve --port 8000
354
+
340
355
  # Bind on all interfaces
341
356
  my-code --backend claude serve --host 0.0.0.0 --port 8080
342
357
  ```
@@ -379,8 +394,8 @@ my-code stop --pid-file mycode-8081.pid
379
394
  Start a MyCode server as a daemon, then point `analyze` and `generate` at it with `--backend mcp`. The CLI calls the server's tools directly — the server handles all analysis and generation using whichever LLM it was started with.
380
395
 
381
396
  ```bash
382
- # Start the server (uses a local LLM at port 8001 as its brain)
383
- my-code --backend mcp --mcp-url http://localhost:8001/mcp serve --daemon --port 8000
397
+ # Start the server backed by a local LLM
398
+ my-code --backend local --llm-url http://localhost:8080/v1 serve --daemon --port 8000
384
399
 
385
400
  # Analyze a codebase via the server
386
401
  my-code --backend mcp --mcp-url http://localhost:8000/mcp analyze ./my_project
@@ -476,7 +491,6 @@ my_code/
476
491
  ├── cli.py # CLI entry point (my-code command)
477
492
  ├── backends/
478
493
  │ ├── base.py # AIBackend abstract base class
479
- │ ├── ricky_backend.py # Local LLM backend (connects via MCP)
480
494
  │ ├── claude_backend.py
481
495
  │ ├── openai_backend.py
482
496
  │ └── mcp_backend.py # Generic MCP server backend
@@ -61,16 +61,29 @@ MyCode delegates inference to a pluggable backend. Choose one based on what you
61
61
 
62
62
  | Backend | Flag | Requirement |
63
63
  |---|---|---|
64
- | Local LLM | `--backend llama` (default) | MCP server running at `localhost:8000` |
65
- | Anthropic Claude | `--backend claude` | `ANTHROPIC_API_KEY` env var or `--api-key` |
64
+ | Anthropic Claude | `--backend claude` (default) | `ANTHROPIC_API_KEY` env var or `--api-key` |
66
65
  | OpenAI | `--backend openai` | `OPENAI_API_KEY` env var or `--api-key` |
67
- | MyCode server | `--backend mcp` | A running MyCode MCP server at `--mcp-url` |
66
+ | Local LLM (OpenAI-compatible) | `--backend local` | LLM server at `--llm-url` (default: `http://localhost:8080/v1`) |
67
+ | Any MCP server | `--backend mcp` | A running MyCode MCP server at `--mcp-url` |
68
68
 
69
69
  When `--backend mcp` is used with `analyze` or `generate`, the CLI delegates the entire operation to the running MyCode server — it calls the server's `analyze_codebase` or `generate_code` tool directly instead of running the pipeline locally. This is the recommended way to use MyCode in a multi-project or agentic setup.
70
70
 
71
71
  ### Setting up a local LLM
72
72
 
73
- The `llama` backend expects an MCP server at `http://localhost:8000/mcp` that exposes two tools: one for code generation and one for analysis. Any MCP-compatible wrapper around a local model will work. Here is a recommended setup using [llama.cpp](https://github.com/ggerganov/llama.cpp):
73
+ Use `--backend local` to connect MyCode directly to any OpenAI-compatible LLM server (llama.cpp, LM Studio, Ollama, etc.) no wrapper needed. Point `--llm-url` at the server's `/v1` base URL:
74
+
75
+ ```bash
76
+ # Start your local LLM server (example: llama.cpp)
77
+ python -m llama_cpp.server --model ./models/codellama-7b-instruct.Q4_K_M.gguf --port 8080
78
+
79
+ # Analyze using the local LLM directly
80
+ my-code --backend local --llm-url http://localhost:8080/v1 analyze ./my_project
81
+
82
+ # Or start a MyCode MCP server backed by your local LLM
83
+ my-code --backend local --llm-url http://localhost:8080/v1 serve --port 8000 --daemon
84
+ ```
85
+
86
+ If you need a full MCP-wrapped setup instead (e.g. the local LLM exposes only `/v1/completions` without chat completions), here is a recommended pattern using [llama.cpp](https://github.com/ggerganov/llama.cpp):
74
87
 
75
88
  **1. Download a model**
76
89
 
@@ -97,7 +110,7 @@ python -m llama_cpp.server \
97
110
 
98
111
  **3. Wrap it with an MCP server**
99
112
 
100
- The `llama` backend communicates over MCP, not directly with the llama.cpp HTTP API. You need a thin MCP wrapper that exposes two tools:
113
+ The `mcp` backend communicates over MCP, not directly with the llama.cpp HTTP API. You need a thin MCP wrapper that exposes two tools:
101
114
  - A **code generation tool** (name must not contain `"analyze"`)
102
115
  - An **analysis tool** (name must contain `"analyze"`)
103
116
 
@@ -139,13 +152,13 @@ python llm_mcp_server.py
139
152
  **4. Point MyCode at it**
140
153
 
141
154
  ```bash
142
- my-code --backend llama --ricky-url http://localhost:8000/mcp analyze .
155
+ my-code --backend mcp --mcp-url http://localhost:8000/mcp analyze .
143
156
  ```
144
157
 
145
158
  Or set a custom URL if your server runs on a different port:
146
159
 
147
160
  ```bash
148
- my-code --backend llama --ricky-url http://localhost:9000/mcp analyze .
161
+ my-code --backend mcp --mcp-url http://localhost:9000/mcp analyze .
149
162
  ```
150
163
 
151
164
  ---
@@ -169,6 +182,7 @@ Using a different backend:
169
182
  ```bash
170
183
  my-code --backend claude analyze ./path/to/codebase
171
184
  my-code --backend openai --api-key sk-... analyze ./path/to/codebase
185
+ my-code --backend local --llm-url http://localhost:8080/v1 analyze ./path/to/codebase
172
186
  ```
173
187
 
174
188
  The profile is saved to `style_profile.json` by default. Specify a different path with `--profile`:
@@ -211,11 +225,11 @@ my-code --backend mcp --mcp-url http://localhost:8000/mcp generate "write a rate
211
225
  my-code [OPTIONS] COMMAND
212
226
 
213
227
  Options:
214
- --backend {llama,claude,openai,mcp} AI backend to use (default: llama)
228
+ --backend {claude,openai,local,mcp} AI backend to use (default: claude)
215
229
  --api-key TEXT API key for claude/openai backends
216
230
  --model TEXT Override the default model
217
- --ricky-url TEXT Local LLM MCP server URL (default: http://localhost:8000/mcp)
218
- --mcp-url TEXT Custom MCP server URL (default: http://localhost:8001/mcp)
231
+ --mcp-url TEXT MyCode MCP server URL (mcp backend, default: http://localhost:8001/mcp)
232
+ --llm-url TEXT Base URL of a local OpenAI-compatible LLM server (local backend, default: http://localhost:8080/v1)
219
233
  --profile TEXT Path to style profile JSON (default: style_profile.json)
220
234
 
221
235
  Commands:
@@ -245,9 +259,10 @@ from my_code import StyleAnalyzer, generate_code, make_backend
245
259
  from pathlib import Path
246
260
 
247
261
  # Create a backend
248
- backend = make_backend() # local LLM (default)
249
- backend = make_backend("claude") # Claude (reads ANTHROPIC_API_KEY)
250
- backend = make_backend("openai", api_key="sk-...") # OpenAI
262
+ backend = make_backend("claude") # Claude (reads ANTHROPIC_API_KEY)
263
+ backend = make_backend("openai", api_key="sk-...") # OpenAI (GPT models)
264
+ backend = make_backend("local", llm_url="http://localhost:8080/v1") # Local LLM (OpenAI-compatible)
265
+ backend = make_backend("mcp", mcp_url="http://localhost:8000/mcp") # Delegate to a MyCode server
251
266
 
252
267
  # Analyze a codebase
253
268
  analyzer = StyleAnalyzer(backend)
@@ -299,15 +314,15 @@ MyCode can expose itself as an MCP server so any MCP-compatible agent or orchest
299
314
  ### Quick start
300
315
 
301
316
  ```bash
302
- # Local LLM backend (default) — foreground, blocks until Ctrl-C
303
- my-code serve
304
-
305
- # Claude backend
317
+ # Claude backend — foreground, blocks until Ctrl-C
306
318
  my-code --backend claude serve --port 8080
307
319
 
308
320
  # OpenAI backend
309
321
  my-code --backend openai serve --port 8080
310
322
 
323
+ # Local LLM (OpenAI-compatible server on port 8080)
324
+ my-code --backend local --llm-url http://localhost:8080/v1 serve --port 8000
325
+
311
326
  # Bind on all interfaces
312
327
  my-code --backend claude serve --host 0.0.0.0 --port 8080
313
328
  ```
@@ -350,8 +365,8 @@ my-code stop --pid-file mycode-8081.pid
350
365
  Start a MyCode server as a daemon, then point `analyze` and `generate` at it with `--backend mcp`. The CLI calls the server's tools directly — the server handles all analysis and generation using whichever LLM it was started with.
351
366
 
352
367
  ```bash
353
- # Start the server (uses a local LLM at port 8001 as its brain)
354
- my-code --backend mcp --mcp-url http://localhost:8001/mcp serve --daemon --port 8000
368
+ # Start the server backed by a local LLM
369
+ my-code --backend local --llm-url http://localhost:8080/v1 serve --daemon --port 8000
355
370
 
356
371
  # Analyze a codebase via the server
357
372
  my-code --backend mcp --mcp-url http://localhost:8000/mcp analyze ./my_project
@@ -447,7 +462,6 @@ my_code/
447
462
  ├── cli.py # CLI entry point (my-code command)
448
463
  ├── backends/
449
464
  │ ├── base.py # AIBackend abstract base class
450
- │ ├── ricky_backend.py # Local LLM backend (connects via MCP)
451
465
  │ ├── claude_backend.py
452
466
  │ ├── openai_backend.py
453
467
  │ └── mcp_backend.py # Generic MCP server backend
@@ -2,7 +2,7 @@ __version__ = "0.3.0"
2
2
 
3
3
  from .analyzer import StyleAnalyzer
4
4
  from .generator import generate_code
5
- from .backends import AIBackend, ClaudeBackend, OpenAIBackend, RickyBackend, MCPBackend, make_backend
5
+ from .backends import AIBackend, ClaudeBackend, OpenAIBackend, MCPBackend, make_backend
6
6
  from .server import MCPServer
7
7
 
8
8
 
@@ -17,7 +17,6 @@ __all__ = [
17
17
  "AIBackend",
18
18
  "ClaudeBackend",
19
19
  "OpenAIBackend",
20
- "RickyBackend",
21
20
  "MCPBackend",
22
21
  "make_backend",
23
22
  "MCPServer",
@@ -3,17 +3,15 @@ import os
3
3
  from .base import AIBackend
4
4
  from .claude_backend import ClaudeBackend
5
5
  from .openai_backend import OpenAIBackend
6
- from .ricky_backend import RickyBackend
7
6
  from .mcp_backend import MCPBackend
8
7
 
9
- __all__ = ["AIBackend", "ClaudeBackend", "OpenAIBackend", "RickyBackend", "MCPBackend", "make_backend"]
10
-
8
+ __all__ = ["AIBackend", "ClaudeBackend", "OpenAIBackend", "MCPBackend", "make_backend"]
11
9
 
12
10
  def make_backend(
13
- backend: str = "llama",
11
+ backend: str = "claude",
14
12
  api_key: str | None = None,
15
- ricky_url: str = "http://localhost:8000/mcp",
16
13
  mcp_url: str = "http://localhost:8001/mcp",
14
+ llm_url: str = "http://localhost:8080/v1",
17
15
  model: str | None = None,
18
16
  timeout: int = 120,
19
17
  ) -> AIBackend:
@@ -27,8 +25,8 @@ def make_backend(
27
25
  if not key:
28
26
  raise ValueError("OpenAI backend requires OPENAI_API_KEY or --api-key")
29
27
  return OpenAIBackend(api_key=key, **{"model": model} if model else {})
28
+ if backend == "local":
29
+ return OpenAIBackend(api_key=api_key or "none", base_url=llm_url, **{"model": model} if model else {})
30
30
  if backend == "mcp":
31
31
  return MCPBackend(url=mcp_url, timeout=timeout)
32
- if backend == "llama":
33
- return RickyBackend(url=ricky_url, timeout=timeout)
34
- raise ValueError(f"Unknown backend {backend!r}. Choose: llama, claude, openai, mcp")
32
+ raise ValueError(f"Unknown backend {backend!r}. Choose: claude, openai, local, mcp")
@@ -2,12 +2,15 @@ from .base import AIBackend
2
2
 
3
3
 
4
4
  class OpenAIBackend(AIBackend):
5
- def __init__(self, api_key: str, model: str = "gpt-4o"):
5
+ def __init__(self, api_key: str, model: str = "gpt-4o", base_url: str | None = None):
6
6
  try:
7
7
  import openai
8
8
  except ImportError:
9
9
  raise ImportError("OpenAI backend requires 'openai': pip install 'my-code[openai]'")
10
- self._client = openai.OpenAI(api_key=api_key)
10
+ client_kwargs = {"api_key": api_key}
11
+ if base_url is not None:
12
+ client_kwargs["base_url"] = base_url
13
+ self._client = openai.OpenAI(**client_kwargs)
11
14
  self._model = model
12
15
 
13
16
  def _call(self, system: str, prompt: str) -> str:
@@ -2,8 +2,8 @@
2
2
  Style-aware code generation agent.
3
3
 
4
4
  Usage:
5
- my-code [--backend llama|claude|openai] analyze <dir>
6
- my-code [--backend llama|claude|openai] --api-key <key> generate "<task>"
5
+ my-code [--backend claude|openai|local|mcp] analyze <dir>
6
+ my-code [--backend claude|openai|local|mcp] --api-key <key> generate "<task>"
7
7
  """
8
8
 
9
9
  import argparse
@@ -38,8 +38,8 @@ def cmd_analyze(args):
38
38
  backend = make_backend(
39
39
  backend=args.backend,
40
40
  api_key=args.api_key,
41
- ricky_url=args.ricky_url,
42
41
  mcp_url=args.mcp_url,
42
+ llm_url=args.llm_url,
43
43
  model=args.model,
44
44
  timeout=args.timeout,
45
45
  )
@@ -70,8 +70,8 @@ def cmd_generate(args):
70
70
  backend = make_backend(
71
71
  backend=args.backend,
72
72
  api_key=args.api_key,
73
- ricky_url=args.ricky_url,
74
73
  mcp_url=args.mcp_url,
74
+ llm_url=args.llm_url,
75
75
  model=args.model,
76
76
  timeout=args.timeout,
77
77
  )
@@ -87,8 +87,8 @@ def _spawn_daemon(args):
87
87
  cmd = [
88
88
  sys.executable, "-m", "my_code",
89
89
  "--backend", args.backend,
90
- "--ricky-url", args.ricky_url,
91
90
  "--mcp-url", args.mcp_url,
91
+ "--llm-url", args.llm_url,
92
92
  "--timeout", str(args.timeout),
93
93
  "--profile", args.profile,
94
94
  "serve",
@@ -127,8 +127,8 @@ def cmd_serve(args):
127
127
  backend = make_backend(
128
128
  backend=args.backend,
129
129
  api_key=args.api_key,
130
- ricky_url=args.ricky_url,
131
130
  mcp_url=args.mcp_url,
131
+ llm_url=args.llm_url,
132
132
  model=args.model,
133
133
  timeout=args.timeout,
134
134
  )
@@ -138,13 +138,13 @@ def cmd_serve(args):
138
138
  def main():
139
139
  parser = argparse.ArgumentParser(description="Style-aware code agent")
140
140
  parser.add_argument(
141
- "--backend", default="llama", choices=["llama", "claude", "openai", "mcp"],
142
- help="AI backend to use (default: llama)",
141
+ "--backend", default="claude", choices=["claude", "openai", "local", "mcp"],
142
+ help="AI backend to use (default: claude)",
143
143
  )
144
144
  parser.add_argument("--api-key", default=None, help="API key (claude/openai); falls back to env var")
145
- parser.add_argument("--model", default=None, help="Override default model for claude/openai backends")
146
- parser.add_argument("--ricky-url", default="http://localhost:8000/mcp", help="Ricky MCP server URL (llama backend)")
147
- parser.add_argument("--mcp-url", default="http://localhost:8001/mcp", help="MCP server URL (mcp backend)")
145
+ parser.add_argument("--model", default=None, help="Override default model for claude/openai/local backends")
146
+ parser.add_argument("--mcp-url", default="http://localhost:8001/mcp", help="MyCode MCP server URL (mcp backend)")
147
+ parser.add_argument("--llm-url", default="http://localhost:8080/v1", help="Base URL of a local OpenAI-compatible LLM server (local backend)")
148
148
  parser.add_argument("--timeout", type=int, default=120, help="Request timeout in seconds (default: 120)")
149
149
  parser.add_argument("--profile", default=str(DEFAULT_PROFILE))
150
150
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mycode-aiagent
3
- Version: 0.4.1
3
+ Version: 0.4.3
4
4
  Summary: Style-aware code generation — analyze any codebase and generate new code that matches its style
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://github.com/RyanAbbottData/MyCode
@@ -90,16 +90,29 @@ MyCode delegates inference to a pluggable backend. Choose one based on what you
90
90
 
91
91
  | Backend | Flag | Requirement |
92
92
  |---|---|---|
93
- | Local LLM | `--backend llama` (default) | MCP server running at `localhost:8000` |
94
- | Anthropic Claude | `--backend claude` | `ANTHROPIC_API_KEY` env var or `--api-key` |
93
+ | Anthropic Claude | `--backend claude` (default) | `ANTHROPIC_API_KEY` env var or `--api-key` |
95
94
  | OpenAI | `--backend openai` | `OPENAI_API_KEY` env var or `--api-key` |
96
- | MyCode server | `--backend mcp` | A running MyCode MCP server at `--mcp-url` |
95
+ | Local LLM (OpenAI-compatible) | `--backend local` | LLM server at `--llm-url` (default: `http://localhost:8080/v1`) |
96
+ | Any MCP server | `--backend mcp` | A running MyCode MCP server at `--mcp-url` |
97
97
 
98
98
  When `--backend mcp` is used with `analyze` or `generate`, the CLI delegates the entire operation to the running MyCode server — it calls the server's `analyze_codebase` or `generate_code` tool directly instead of running the pipeline locally. This is the recommended way to use MyCode in a multi-project or agentic setup.
99
99
 
100
100
  ### Setting up a local LLM
101
101
 
102
- The `llama` backend expects an MCP server at `http://localhost:8000/mcp` that exposes two tools: one for code generation and one for analysis. Any MCP-compatible wrapper around a local model will work. Here is a recommended setup using [llama.cpp](https://github.com/ggerganov/llama.cpp):
102
+ Use `--backend local` to connect MyCode directly to any OpenAI-compatible LLM server (llama.cpp, LM Studio, Ollama, etc.) no wrapper needed. Point `--llm-url` at the server's `/v1` base URL:
103
+
104
+ ```bash
105
+ # Start your local LLM server (example: llama.cpp)
106
+ python -m llama_cpp.server --model ./models/codellama-7b-instruct.Q4_K_M.gguf --port 8080
107
+
108
+ # Analyze using the local LLM directly
109
+ my-code --backend local --llm-url http://localhost:8080/v1 analyze ./my_project
110
+
111
+ # Or start a MyCode MCP server backed by your local LLM
112
+ my-code --backend local --llm-url http://localhost:8080/v1 serve --port 8000 --daemon
113
+ ```
114
+
115
+ If you need a full MCP-wrapped setup instead (e.g. the local LLM exposes only `/v1/completions` without chat completions), here is a recommended pattern using [llama.cpp](https://github.com/ggerganov/llama.cpp):
103
116
 
104
117
  **1. Download a model**
105
118
 
@@ -126,7 +139,7 @@ python -m llama_cpp.server \
126
139
 
127
140
  **3. Wrap it with an MCP server**
128
141
 
129
- The `llama` backend communicates over MCP, not directly with the llama.cpp HTTP API. You need a thin MCP wrapper that exposes two tools:
142
+ The `mcp` backend communicates over MCP, not directly with the llama.cpp HTTP API. You need a thin MCP wrapper that exposes two tools:
130
143
  - A **code generation tool** (name must not contain `"analyze"`)
131
144
  - An **analysis tool** (name must contain `"analyze"`)
132
145
 
@@ -168,13 +181,13 @@ python llm_mcp_server.py
168
181
  **4. Point MyCode at it**
169
182
 
170
183
  ```bash
171
- my-code --backend llama --ricky-url http://localhost:8000/mcp analyze .
184
+ my-code --backend mcp --mcp-url http://localhost:8000/mcp analyze .
172
185
  ```
173
186
 
174
187
  Or set a custom URL if your server runs on a different port:
175
188
 
176
189
  ```bash
177
- my-code --backend llama --ricky-url http://localhost:9000/mcp analyze .
190
+ my-code --backend mcp --mcp-url http://localhost:9000/mcp analyze .
178
191
  ```
179
192
 
180
193
  ---
@@ -198,6 +211,7 @@ Using a different backend:
198
211
  ```bash
199
212
  my-code --backend claude analyze ./path/to/codebase
200
213
  my-code --backend openai --api-key sk-... analyze ./path/to/codebase
214
+ my-code --backend local --llm-url http://localhost:8080/v1 analyze ./path/to/codebase
201
215
  ```
202
216
 
203
217
  The profile is saved to `style_profile.json` by default. Specify a different path with `--profile`:
@@ -240,11 +254,11 @@ my-code --backend mcp --mcp-url http://localhost:8000/mcp generate "write a rate
240
254
  my-code [OPTIONS] COMMAND
241
255
 
242
256
  Options:
243
- --backend {llama,claude,openai,mcp} AI backend to use (default: llama)
257
+ --backend {claude,openai,local,mcp} AI backend to use (default: claude)
244
258
  --api-key TEXT API key for claude/openai backends
245
259
  --model TEXT Override the default model
246
- --ricky-url TEXT Local LLM MCP server URL (default: http://localhost:8000/mcp)
247
- --mcp-url TEXT Custom MCP server URL (default: http://localhost:8001/mcp)
260
+ --mcp-url TEXT MyCode MCP server URL (mcp backend, default: http://localhost:8001/mcp)
261
+ --llm-url TEXT Base URL of a local OpenAI-compatible LLM server (local backend, default: http://localhost:8080/v1)
248
262
  --profile TEXT Path to style profile JSON (default: style_profile.json)
249
263
 
250
264
  Commands:
@@ -274,9 +288,10 @@ from my_code import StyleAnalyzer, generate_code, make_backend
274
288
  from pathlib import Path
275
289
 
276
290
  # Create a backend
277
- backend = make_backend() # local LLM (default)
278
- backend = make_backend("claude") # Claude (reads ANTHROPIC_API_KEY)
279
- backend = make_backend("openai", api_key="sk-...") # OpenAI
291
+ backend = make_backend("claude") # Claude (reads ANTHROPIC_API_KEY)
292
+ backend = make_backend("openai", api_key="sk-...") # OpenAI (GPT models)
293
+ backend = make_backend("local", llm_url="http://localhost:8080/v1") # Local LLM (OpenAI-compatible)
294
+ backend = make_backend("mcp", mcp_url="http://localhost:8000/mcp") # Delegate to a MyCode server
280
295
 
281
296
  # Analyze a codebase
282
297
  analyzer = StyleAnalyzer(backend)
@@ -328,15 +343,15 @@ MyCode can expose itself as an MCP server so any MCP-compatible agent or orchest
328
343
  ### Quick start
329
344
 
330
345
  ```bash
331
- # Local LLM backend (default) — foreground, blocks until Ctrl-C
332
- my-code serve
333
-
334
- # Claude backend
346
+ # Claude backend — foreground, blocks until Ctrl-C
335
347
  my-code --backend claude serve --port 8080
336
348
 
337
349
  # OpenAI backend
338
350
  my-code --backend openai serve --port 8080
339
351
 
352
+ # Local LLM (OpenAI-compatible server on port 8080)
353
+ my-code --backend local --llm-url http://localhost:8080/v1 serve --port 8000
354
+
340
355
  # Bind on all interfaces
341
356
  my-code --backend claude serve --host 0.0.0.0 --port 8080
342
357
  ```
@@ -379,8 +394,8 @@ my-code stop --pid-file mycode-8081.pid
379
394
  Start a MyCode server as a daemon, then point `analyze` and `generate` at it with `--backend mcp`. The CLI calls the server's tools directly — the server handles all analysis and generation using whichever LLM it was started with.
380
395
 
381
396
  ```bash
382
- # Start the server (uses a local LLM at port 8001 as its brain)
383
- my-code --backend mcp --mcp-url http://localhost:8001/mcp serve --daemon --port 8000
397
+ # Start the server backed by a local LLM
398
+ my-code --backend local --llm-url http://localhost:8080/v1 serve --daemon --port 8000
384
399
 
385
400
  # Analyze a codebase via the server
386
401
  my-code --backend mcp --mcp-url http://localhost:8000/mcp analyze ./my_project
@@ -476,7 +491,6 @@ my_code/
476
491
  ├── cli.py # CLI entry point (my-code command)
477
492
  ├── backends/
478
493
  │ ├── base.py # AIBackend abstract base class
479
- │ ├── ricky_backend.py # Local LLM backend (connects via MCP)
480
494
  │ ├── claude_backend.py
481
495
  │ ├── openai_backend.py
482
496
  │ └── mcp_backend.py # Generic MCP server backend
@@ -12,7 +12,6 @@ my_code/backends/base.py
12
12
  my_code/backends/claude_backend.py
13
13
  my_code/backends/mcp_backend.py
14
14
  my_code/backends/openai_backend.py
15
- my_code/backends/ricky_backend.py
16
15
  my_code/utils/__init__.py
17
16
  my_code/utils/prompts.py
18
17
  mycode_aiagent.egg-info/PKG-INFO
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "mycode-aiagent"
7
- version = "0.4.1"
7
+ version = "0.4.3"
8
8
  description = "Style-aware code generation — analyze any codebase and generate new code that matches its style"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -1,15 +0,0 @@
1
- from .base import AIBackend
2
- from ..mcp_client import MCPClient
3
-
4
-
5
- class RickyBackend(AIBackend):
6
- max_file_chars: int = 1500
7
-
8
- def __init__(self, url: str = "http://localhost:8000/mcp", timeout: int = 120):
9
- self._client = MCPClient(url=url, timeout=timeout)
10
-
11
- def ask_for_code(self, prompt: str) -> str:
12
- return self._client.ask_for_code(prompt)
13
-
14
- def ask_to_analyze(self, prompt: str) -> str:
15
- return self._client.ask_to_analyze(prompt)
File without changes