mycode-aiagent 0.4.2__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.
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/PKG-INFO +31 -14
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/README.md +30 -13
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/my_code/backends/__init__.py +4 -2
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/my_code/backends/openai_backend.py +5 -2
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/my_code/cli.py +10 -5
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/mycode_aiagent.egg-info/PKG-INFO +31 -14
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/pyproject.toml +1 -1
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/my_code/__init__.py +0 -0
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/my_code/__main__.py +0 -0
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/my_code/analyzer.py +0 -0
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/my_code/backends/base.py +0 -0
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/my_code/backends/claude_backend.py +0 -0
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/my_code/backends/mcp_backend.py +0 -0
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/my_code/generator.py +0 -0
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/my_code/mcp_client.py +0 -0
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/my_code/server.py +0 -0
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/my_code/utils/__init__.py +0 -0
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/my_code/utils/prompts.py +0 -0
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/mycode_aiagent.egg-info/SOURCES.txt +0 -0
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/mycode_aiagent.egg-info/dependency_links.txt +0 -0
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/mycode_aiagent.egg-info/entry_points.txt +0 -0
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/mycode_aiagent.egg-info/requires.txt +0 -0
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/mycode_aiagent.egg-info/top_level.txt +0 -0
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/setup.cfg +0 -0
- {mycode_aiagent-0.4.2 → mycode_aiagent-0.4.3}/tests/test_library.py +0 -0
- {mycode_aiagent-0.4.2 → 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.
|
|
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
|
|
@@ -92,13 +92,27 @@ MyCode delegates inference to a pluggable backend. Choose one based on what you
|
|
|
92
92
|
|---|---|---|
|
|
93
93
|
| Anthropic Claude | `--backend claude` (default) | `ANTHROPIC_API_KEY` env var or `--api-key` |
|
|
94
94
|
| OpenAI | `--backend openai` | `OPENAI_API_KEY` env var or `--api-key` |
|
|
95
|
-
|
|
|
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` |
|
|
96
97
|
|
|
97
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.
|
|
98
99
|
|
|
99
100
|
### Setting up a local LLM
|
|
100
101
|
|
|
101
|
-
|
|
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):
|
|
102
116
|
|
|
103
117
|
**1. Download a model**
|
|
104
118
|
|
|
@@ -197,6 +211,7 @@ Using a different backend:
|
|
|
197
211
|
```bash
|
|
198
212
|
my-code --backend claude analyze ./path/to/codebase
|
|
199
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
|
|
200
215
|
```
|
|
201
216
|
|
|
202
217
|
The profile is saved to `style_profile.json` by default. Specify a different path with `--profile`:
|
|
@@ -239,10 +254,11 @@ my-code --backend mcp --mcp-url http://localhost:8000/mcp generate "write a rate
|
|
|
239
254
|
my-code [OPTIONS] COMMAND
|
|
240
255
|
|
|
241
256
|
Options:
|
|
242
|
-
--backend {claude,openai,mcp}
|
|
257
|
+
--backend {claude,openai,local,mcp} AI backend to use (default: claude)
|
|
243
258
|
--api-key TEXT API key for claude/openai backends
|
|
244
259
|
--model TEXT Override the default model
|
|
245
|
-
--mcp-url TEXT 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)
|
|
246
262
|
--profile TEXT Path to style profile JSON (default: style_profile.json)
|
|
247
263
|
|
|
248
264
|
Commands:
|
|
@@ -272,9 +288,10 @@ from my_code import StyleAnalyzer, generate_code, make_backend
|
|
|
272
288
|
from pathlib import Path
|
|
273
289
|
|
|
274
290
|
# Create a backend
|
|
275
|
-
backend = make_backend()
|
|
276
|
-
backend = make_backend("
|
|
277
|
-
backend = make_backend("
|
|
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
|
|
278
295
|
|
|
279
296
|
# Analyze a codebase
|
|
280
297
|
analyzer = StyleAnalyzer(backend)
|
|
@@ -326,15 +343,15 @@ MyCode can expose itself as an MCP server so any MCP-compatible agent or orchest
|
|
|
326
343
|
### Quick start
|
|
327
344
|
|
|
328
345
|
```bash
|
|
329
|
-
#
|
|
330
|
-
my-code serve
|
|
331
|
-
|
|
332
|
-
# Claude backend
|
|
346
|
+
# Claude backend — foreground, blocks until Ctrl-C
|
|
333
347
|
my-code --backend claude serve --port 8080
|
|
334
348
|
|
|
335
349
|
# OpenAI backend
|
|
336
350
|
my-code --backend openai serve --port 8080
|
|
337
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
|
+
|
|
338
355
|
# Bind on all interfaces
|
|
339
356
|
my-code --backend claude serve --host 0.0.0.0 --port 8080
|
|
340
357
|
```
|
|
@@ -377,8 +394,8 @@ my-code stop --pid-file mycode-8081.pid
|
|
|
377
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.
|
|
378
395
|
|
|
379
396
|
```bash
|
|
380
|
-
# Start the server
|
|
381
|
-
my-code --backend
|
|
397
|
+
# Start the server backed by a local LLM
|
|
398
|
+
my-code --backend local --llm-url http://localhost:8080/v1 serve --daemon --port 8000
|
|
382
399
|
|
|
383
400
|
# Analyze a codebase via the server
|
|
384
401
|
my-code --backend mcp --mcp-url http://localhost:8000/mcp analyze ./my_project
|
|
@@ -63,13 +63,27 @@ MyCode delegates inference to a pluggable backend. Choose one based on what you
|
|
|
63
63
|
|---|---|---|
|
|
64
64
|
| Anthropic Claude | `--backend claude` (default) | `ANTHROPIC_API_KEY` env var or `--api-key` |
|
|
65
65
|
| OpenAI | `--backend openai` | `OPENAI_API_KEY` env var or `--api-key` |
|
|
66
|
-
|
|
|
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` |
|
|
67
68
|
|
|
68
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.
|
|
69
70
|
|
|
70
71
|
### Setting up a local LLM
|
|
71
72
|
|
|
72
|
-
|
|
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):
|
|
73
87
|
|
|
74
88
|
**1. Download a model**
|
|
75
89
|
|
|
@@ -168,6 +182,7 @@ Using a different backend:
|
|
|
168
182
|
```bash
|
|
169
183
|
my-code --backend claude analyze ./path/to/codebase
|
|
170
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
|
|
171
186
|
```
|
|
172
187
|
|
|
173
188
|
The profile is saved to `style_profile.json` by default. Specify a different path with `--profile`:
|
|
@@ -210,10 +225,11 @@ my-code --backend mcp --mcp-url http://localhost:8000/mcp generate "write a rate
|
|
|
210
225
|
my-code [OPTIONS] COMMAND
|
|
211
226
|
|
|
212
227
|
Options:
|
|
213
|
-
--backend {claude,openai,mcp}
|
|
228
|
+
--backend {claude,openai,local,mcp} AI backend to use (default: claude)
|
|
214
229
|
--api-key TEXT API key for claude/openai backends
|
|
215
230
|
--model TEXT Override the default model
|
|
216
|
-
--mcp-url TEXT 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)
|
|
217
233
|
--profile TEXT Path to style profile JSON (default: style_profile.json)
|
|
218
234
|
|
|
219
235
|
Commands:
|
|
@@ -243,9 +259,10 @@ from my_code import StyleAnalyzer, generate_code, make_backend
|
|
|
243
259
|
from pathlib import Path
|
|
244
260
|
|
|
245
261
|
# Create a backend
|
|
246
|
-
backend = make_backend()
|
|
247
|
-
backend = make_backend("
|
|
248
|
-
backend = make_backend("
|
|
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
|
|
249
266
|
|
|
250
267
|
# Analyze a codebase
|
|
251
268
|
analyzer = StyleAnalyzer(backend)
|
|
@@ -297,15 +314,15 @@ MyCode can expose itself as an MCP server so any MCP-compatible agent or orchest
|
|
|
297
314
|
### Quick start
|
|
298
315
|
|
|
299
316
|
```bash
|
|
300
|
-
#
|
|
301
|
-
my-code serve
|
|
302
|
-
|
|
303
|
-
# Claude backend
|
|
317
|
+
# Claude backend — foreground, blocks until Ctrl-C
|
|
304
318
|
my-code --backend claude serve --port 8080
|
|
305
319
|
|
|
306
320
|
# OpenAI backend
|
|
307
321
|
my-code --backend openai serve --port 8080
|
|
308
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
|
+
|
|
309
326
|
# Bind on all interfaces
|
|
310
327
|
my-code --backend claude serve --host 0.0.0.0 --port 8080
|
|
311
328
|
```
|
|
@@ -348,8 +365,8 @@ my-code stop --pid-file mycode-8081.pid
|
|
|
348
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.
|
|
349
366
|
|
|
350
367
|
```bash
|
|
351
|
-
# Start the server
|
|
352
|
-
my-code --backend
|
|
368
|
+
# Start the server backed by a local LLM
|
|
369
|
+
my-code --backend local --llm-url http://localhost:8080/v1 serve --daemon --port 8000
|
|
353
370
|
|
|
354
371
|
# Analyze a codebase via the server
|
|
355
372
|
my-code --backend mcp --mcp-url http://localhost:8000/mcp analyze ./my_project
|
|
@@ -7,11 +7,11 @@ from .mcp_backend import MCPBackend
|
|
|
7
7
|
|
|
8
8
|
__all__ = ["AIBackend", "ClaudeBackend", "OpenAIBackend", "MCPBackend", "make_backend"]
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
def make_backend(
|
|
12
11
|
backend: str = "claude",
|
|
13
12
|
api_key: str | None = None,
|
|
14
13
|
mcp_url: str = "http://localhost:8001/mcp",
|
|
14
|
+
llm_url: str = "http://localhost:8080/v1",
|
|
15
15
|
model: str | None = None,
|
|
16
16
|
timeout: int = 120,
|
|
17
17
|
) -> AIBackend:
|
|
@@ -25,6 +25,8 @@ def make_backend(
|
|
|
25
25
|
if not key:
|
|
26
26
|
raise ValueError("OpenAI backend requires OPENAI_API_KEY or --api-key")
|
|
27
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 {})
|
|
28
30
|
if backend == "mcp":
|
|
29
31
|
return MCPBackend(url=mcp_url, timeout=timeout)
|
|
30
|
-
raise ValueError(f"Unknown backend {backend!r}. Choose: 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
|
-
|
|
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 claude|openai|mcp] analyze <dir>
|
|
6
|
-
my-code [--backend claude|openai|mcp] --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
|
|
@@ -39,6 +39,7 @@ def cmd_analyze(args):
|
|
|
39
39
|
backend=args.backend,
|
|
40
40
|
api_key=args.api_key,
|
|
41
41
|
mcp_url=args.mcp_url,
|
|
42
|
+
llm_url=args.llm_url,
|
|
42
43
|
model=args.model,
|
|
43
44
|
timeout=args.timeout,
|
|
44
45
|
)
|
|
@@ -70,6 +71,7 @@ def cmd_generate(args):
|
|
|
70
71
|
backend=args.backend,
|
|
71
72
|
api_key=args.api_key,
|
|
72
73
|
mcp_url=args.mcp_url,
|
|
74
|
+
llm_url=args.llm_url,
|
|
73
75
|
model=args.model,
|
|
74
76
|
timeout=args.timeout,
|
|
75
77
|
)
|
|
@@ -86,6 +88,7 @@ def _spawn_daemon(args):
|
|
|
86
88
|
sys.executable, "-m", "my_code",
|
|
87
89
|
"--backend", args.backend,
|
|
88
90
|
"--mcp-url", args.mcp_url,
|
|
91
|
+
"--llm-url", args.llm_url,
|
|
89
92
|
"--timeout", str(args.timeout),
|
|
90
93
|
"--profile", args.profile,
|
|
91
94
|
"serve",
|
|
@@ -125,6 +128,7 @@ def cmd_serve(args):
|
|
|
125
128
|
backend=args.backend,
|
|
126
129
|
api_key=args.api_key,
|
|
127
130
|
mcp_url=args.mcp_url,
|
|
131
|
+
llm_url=args.llm_url,
|
|
128
132
|
model=args.model,
|
|
129
133
|
timeout=args.timeout,
|
|
130
134
|
)
|
|
@@ -134,12 +138,13 @@ def cmd_serve(args):
|
|
|
134
138
|
def main():
|
|
135
139
|
parser = argparse.ArgumentParser(description="Style-aware code agent")
|
|
136
140
|
parser.add_argument(
|
|
137
|
-
"--backend", default="claude", choices=["claude", "openai", "mcp"],
|
|
141
|
+
"--backend", default="claude", choices=["claude", "openai", "local", "mcp"],
|
|
138
142
|
help="AI backend to use (default: claude)",
|
|
139
143
|
)
|
|
140
144
|
parser.add_argument("--api-key", default=None, help="API key (claude/openai); falls back to env var")
|
|
141
|
-
parser.add_argument("--model", default=None, help="Override default model for claude/openai backends")
|
|
142
|
-
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)")
|
|
143
148
|
parser.add_argument("--timeout", type=int, default=120, help="Request timeout in seconds (default: 120)")
|
|
144
149
|
parser.add_argument("--profile", default=str(DEFAULT_PROFILE))
|
|
145
150
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mycode-aiagent
|
|
3
|
-
Version: 0.4.
|
|
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
|
|
@@ -92,13 +92,27 @@ MyCode delegates inference to a pluggable backend. Choose one based on what you
|
|
|
92
92
|
|---|---|---|
|
|
93
93
|
| Anthropic Claude | `--backend claude` (default) | `ANTHROPIC_API_KEY` env var or `--api-key` |
|
|
94
94
|
| OpenAI | `--backend openai` | `OPENAI_API_KEY` env var or `--api-key` |
|
|
95
|
-
|
|
|
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` |
|
|
96
97
|
|
|
97
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.
|
|
98
99
|
|
|
99
100
|
### Setting up a local LLM
|
|
100
101
|
|
|
101
|
-
|
|
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):
|
|
102
116
|
|
|
103
117
|
**1. Download a model**
|
|
104
118
|
|
|
@@ -197,6 +211,7 @@ Using a different backend:
|
|
|
197
211
|
```bash
|
|
198
212
|
my-code --backend claude analyze ./path/to/codebase
|
|
199
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
|
|
200
215
|
```
|
|
201
216
|
|
|
202
217
|
The profile is saved to `style_profile.json` by default. Specify a different path with `--profile`:
|
|
@@ -239,10 +254,11 @@ my-code --backend mcp --mcp-url http://localhost:8000/mcp generate "write a rate
|
|
|
239
254
|
my-code [OPTIONS] COMMAND
|
|
240
255
|
|
|
241
256
|
Options:
|
|
242
|
-
--backend {claude,openai,mcp}
|
|
257
|
+
--backend {claude,openai,local,mcp} AI backend to use (default: claude)
|
|
243
258
|
--api-key TEXT API key for claude/openai backends
|
|
244
259
|
--model TEXT Override the default model
|
|
245
|
-
--mcp-url TEXT 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)
|
|
246
262
|
--profile TEXT Path to style profile JSON (default: style_profile.json)
|
|
247
263
|
|
|
248
264
|
Commands:
|
|
@@ -272,9 +288,10 @@ from my_code import StyleAnalyzer, generate_code, make_backend
|
|
|
272
288
|
from pathlib import Path
|
|
273
289
|
|
|
274
290
|
# Create a backend
|
|
275
|
-
backend = make_backend()
|
|
276
|
-
backend = make_backend("
|
|
277
|
-
backend = make_backend("
|
|
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
|
|
278
295
|
|
|
279
296
|
# Analyze a codebase
|
|
280
297
|
analyzer = StyleAnalyzer(backend)
|
|
@@ -326,15 +343,15 @@ MyCode can expose itself as an MCP server so any MCP-compatible agent or orchest
|
|
|
326
343
|
### Quick start
|
|
327
344
|
|
|
328
345
|
```bash
|
|
329
|
-
#
|
|
330
|
-
my-code serve
|
|
331
|
-
|
|
332
|
-
# Claude backend
|
|
346
|
+
# Claude backend — foreground, blocks until Ctrl-C
|
|
333
347
|
my-code --backend claude serve --port 8080
|
|
334
348
|
|
|
335
349
|
# OpenAI backend
|
|
336
350
|
my-code --backend openai serve --port 8080
|
|
337
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
|
+
|
|
338
355
|
# Bind on all interfaces
|
|
339
356
|
my-code --backend claude serve --host 0.0.0.0 --port 8080
|
|
340
357
|
```
|
|
@@ -377,8 +394,8 @@ my-code stop --pid-file mycode-8081.pid
|
|
|
377
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.
|
|
378
395
|
|
|
379
396
|
```bash
|
|
380
|
-
# Start the server
|
|
381
|
-
my-code --backend
|
|
397
|
+
# Start the server backed by a local LLM
|
|
398
|
+
my-code --backend local --llm-url http://localhost:8080/v1 serve --daemon --port 8000
|
|
382
399
|
|
|
383
400
|
# Analyze a codebase via the server
|
|
384
401
|
my-code --backend mcp --mcp-url http://localhost:8000/mcp analyze ./my_project
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "mycode-aiagent"
|
|
7
|
-
version = "0.4.
|
|
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"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|