alexforge 0.2.0__py3-none-any.whl
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.
- alexforge-0.2.0.dist-info/METADATA +1091 -0
- alexforge-0.2.0.dist-info/RECORD +53 -0
- alexforge-0.2.0.dist-info/WHEEL +5 -0
- alexforge-0.2.0.dist-info/entry_points.txt +2 -0
- alexforge-0.2.0.dist-info/licenses/LICENSE +21 -0
- alexforge-0.2.0.dist-info/top_level.txt +1 -0
- localforge/__init__.py +3 -0
- localforge/__main__.py +18 -0
- localforge/agent/__init__.py +27 -0
- localforge/agent/agents.py +274 -0
- localforge/agent/base.py +162 -0
- localforge/agent/display.py +119 -0
- localforge/agent/orchestrator.py +431 -0
- localforge/agent/state_manager.py +51 -0
- localforge/chat/__init__.py +17 -0
- localforge/chat/engine.py +3288 -0
- localforge/chat/session.py +106 -0
- localforge/chat/tools.py +3820 -0
- localforge/cli/__init__.py +5 -0
- localforge/cli/display.py +245 -0
- localforge/cli/main.py +1610 -0
- localforge/cloud/__init__.py +19 -0
- localforge/cloud/agents.py +343 -0
- localforge/cloud/auth.py +156 -0
- localforge/cloud/auto_auth.py +1252 -0
- localforge/cloud/client.py +975 -0
- localforge/cloud/engine.py +4434 -0
- localforge/cloud/exceptions.py +37 -0
- localforge/cloud/memory.py +162 -0
- localforge/cloud/prompts.py +1607 -0
- localforge/cloud/session.py +161 -0
- localforge/cloud/token_refresh.py +378 -0
- localforge/context_manager/__init__.py +6 -0
- localforge/context_manager/assembler.py +285 -0
- localforge/context_manager/budget.py +197 -0
- localforge/core/__init__.py +86 -0
- localforge/core/config.py +139 -0
- localforge/core/git_utils.py +125 -0
- localforge/core/models.py +205 -0
- localforge/core/ollama_client.py +574 -0
- localforge/core/prompt_templates.py +418 -0
- localforge/index/__init__.py +6 -0
- localforge/index/dependency_graph.py +319 -0
- localforge/index/indexer.py +958 -0
- localforge/index/search.py +375 -0
- localforge/patching/__init__.py +6 -0
- localforge/patching/patcher.py +257 -0
- localforge/patching/validator.py +339 -0
- localforge/retrieval/__init__.py +5 -0
- localforge/retrieval/ranking.py +160 -0
- localforge/retrieval/retriever.py +372 -0
- localforge/verifier/__init__.py +5 -0
- localforge/verifier/runner.py +844 -0
|
@@ -0,0 +1,1091 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: alexforge
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: A local-first, repo-aware AI coding agent powered by Ollama
|
|
5
|
+
Home-page: https://github.com/alexforge/localforge.git
|
|
6
|
+
Author: localforge contributors
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Requires-Python: >=3.11
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: pydantic>=2.0
|
|
12
|
+
Requires-Dist: pydantic-settings>=2.0
|
|
13
|
+
Requires-Dist: rich>=13.0
|
|
14
|
+
Requires-Dist: httpx>=0.25
|
|
15
|
+
Requires-Dist: typer>=0.9
|
|
16
|
+
Requires-Dist: pathspec>=0.11
|
|
17
|
+
Requires-Dist: pyyaml>=6.0
|
|
18
|
+
Requires-Dist: playwright>=1.40.0
|
|
19
|
+
Requires-Dist: cryptography>=41.0
|
|
20
|
+
Requires-Dist: pyspnego>=0.10
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest; extra == "dev"
|
|
23
|
+
Requires-Dist: pytest-asyncio; extra == "dev"
|
|
24
|
+
Requires-Dist: pytest-mock; extra == "dev"
|
|
25
|
+
Requires-Dist: black; extra == "dev"
|
|
26
|
+
Requires-Dist: ruff; extra == "dev"
|
|
27
|
+
Requires-Dist: mypy; extra == "dev"
|
|
28
|
+
Requires-Dist: types-PyYAML; extra == "dev"
|
|
29
|
+
Dynamic: home-page
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
Dynamic: requires-python
|
|
32
|
+
|
|
33
|
+
# AlexForge
|
|
34
|
+
|
|
35
|
+
**A local-first, repo-aware AI coding agent powered by Ollama.**
|
|
36
|
+
|
|
37
|
+
AlexForge is a fully offline, privacy-first AI coding agent that lives in your
|
|
38
|
+
terminal. Point it at a codebase, describe a task in plain English, and it will
|
|
39
|
+
analyze the code, build an execution plan, generate patches, run verification,
|
|
40
|
+
and iterate — all using a local LLM through [Ollama](https://ollama.com).
|
|
41
|
+
|
|
42
|
+
> **Your code never leaves your machine.** No API keys. No cloud. No telemetry.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Why AlexForge?
|
|
47
|
+
|
|
48
|
+
| Feature | AlexForge | Cloud-based agents |
|
|
49
|
+
|---------|------------|--------------------|
|
|
50
|
+
| **Privacy** | 100 % local — code never leaves your machine | Code sent to external servers |
|
|
51
|
+
| **Cost** | Free forever (runs on your hardware) | Per-token billing |
|
|
52
|
+
| **Internet** | Works fully offline | Requires internet connection |
|
|
53
|
+
| **Repo awareness** | SQLite-indexed codebase with FTS5 search | Context window stuffing |
|
|
54
|
+
| **Safety** | Diff preview + confirmation + backups + rollback | Varies |
|
|
55
|
+
| **Transparency** | Open source, inspectable agent prompts | Black box |
|
|
56
|
+
|
|
57
|
+
### What makes it stand out
|
|
58
|
+
|
|
59
|
+
- **Tool-use from chat.** The LLM can autonomously read files, write code,
|
|
60
|
+
edit files, run shell commands, and search the codebase — all from within
|
|
61
|
+
the interactive chat. No more copy-pasting suggestions; the agent acts
|
|
62
|
+
directly on your code, similar to Claude Code.
|
|
63
|
+
- **Multi-agent architecture.** Six specialist agents (Analyzer → Planner →
|
|
64
|
+
Coder → Verifier → Reflector → Summarizer) collaborate through structured
|
|
65
|
+
JSON handoffs, each with its own system prompt and output schema. This
|
|
66
|
+
separation of concerns produces more reliable results than single-prompt
|
|
67
|
+
approaches.
|
|
68
|
+
- **Interactive chat.** `alexforge chat` gives you a conversational REPL —
|
|
69
|
+
ask questions about your codebase, explore code, and plan changes
|
|
70
|
+
interactively. Chat history persists between sessions. Built-in slash
|
|
71
|
+
commands: `/run`, `/read`, `/context`, `/tokens`, and more.
|
|
72
|
+
- **Streaming output.** See model responses as they generate, token by token.
|
|
73
|
+
No more staring at a spinner — watch the agent think in real time.
|
|
74
|
+
- **Git integration.** Automatic git checkpoints before and after autofix runs.
|
|
75
|
+
Track changes with your existing git workflow alongside file-based backups.
|
|
76
|
+
- **Auto-detect context window.** Queries the Ollama API to determine your
|
|
77
|
+
model's actual context window size — no manual configuration needed.
|
|
78
|
+
- **Token-budget-aware.** A dedicated context assembler and token budget manager
|
|
79
|
+
keep every prompt within the model's context window — no silent truncation
|
|
80
|
+
surprises.
|
|
81
|
+
- **Smart retrieval.** Combines FTS5 full-text search, filename fuzzy matching,
|
|
82
|
+
symbol search, and optional ripgrep integration. Chunks are ranked by
|
|
83
|
+
term-frequency, path relevance, recency, and deduplicated automatically.
|
|
84
|
+
- **Multi-language indexing.** Enhanced symbol extraction for Python, JavaScript,
|
|
85
|
+
TypeScript, Go, Rust, Java, C#, Ruby, PHP, C/C++, and more — including
|
|
86
|
+
interfaces, types, enums, constants, async functions, and module exports.
|
|
87
|
+
- **Safe by default.** Every patch is shown as a diff, backed up before
|
|
88
|
+
application, validated for syntax and safety, and only written after explicit
|
|
89
|
+
approval (or `--yes`). Rollback is always one command away. Destructive
|
|
90
|
+
shell commands are blocked for safety.
|
|
91
|
+
- **Project rules.** Add conventions to `.localforge/rules.md` and they're
|
|
92
|
+
injected into every agent prompt — the agent follows your coding standards.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Table of Contents
|
|
97
|
+
|
|
98
|
+
1. [Requirements](#requirements)
|
|
99
|
+
2. [Installation](#installation)
|
|
100
|
+
3. [Quick Start](#quick-start)
|
|
101
|
+
4. [Complete CLI Reference](#complete-cli-reference)
|
|
102
|
+
5. [Architecture](#architecture)
|
|
103
|
+
6. [Agent Loop](#agent-loop)
|
|
104
|
+
7. [How Retrieval Works](#how-retrieval-works)
|
|
105
|
+
8. [Project Rules](#project-rules)
|
|
106
|
+
9. [Configuration Reference](#configuration-reference)
|
|
107
|
+
10. [Model Recommendations](#model-recommendations)
|
|
108
|
+
11. [Choosing and Switching Models](#choosing-and-switching-models)
|
|
109
|
+
12. [Workflow Examples](#workflow-examples)
|
|
110
|
+
13. [Safety & Backups](#safety--backups)
|
|
111
|
+
14. [Tips for Best Results](#tips-for-best-results)
|
|
112
|
+
15. [Limitations](#limitations)
|
|
113
|
+
16. [Comparison with Cloud Agents](#comparison-with-cloud-agents)
|
|
114
|
+
17. [Changelog](#changelog)
|
|
115
|
+
18. [Contributing](#contributing)
|
|
116
|
+
19. [License](#license)
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Requirements
|
|
121
|
+
|
|
122
|
+
| Dependency | Version | Notes |
|
|
123
|
+
|------------|---------|-------|
|
|
124
|
+
| Python | **3.11 +** | 3.12 and 3.13 work too |
|
|
125
|
+
| [Ollama](https://ollama.com) | latest | Must be running (`ollama serve`) |
|
|
126
|
+
| ripgrep (`rg`) | *optional* | Speeds up file discovery if installed |
|
|
127
|
+
| Git | *optional* | Used for change tracking |
|
|
128
|
+
|
|
129
|
+
### Hardware recommendations
|
|
130
|
+
|
|
131
|
+
| Setup | VRAM | Recommended model | Profile |
|
|
132
|
+
|-------|------|-------------------|---------|
|
|
133
|
+
| Minimum | 4–6 GB | `qwen2.5-coder:7b` | `small` |
|
|
134
|
+
| Recommended | 8–16 GB | `qwen2.5-coder:14b` | `medium` |
|
|
135
|
+
| Best results | 24+ GB | `qwen2.5-coder:32b` | `large` |
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Installation
|
|
140
|
+
|
|
141
|
+
### Recommended: pipx (zero-friction, works immediately)
|
|
142
|
+
|
|
143
|
+
[`pipx`](https://pipx.pypa.io) installs CLI tools in isolated environments and
|
|
144
|
+
automatically wires them into your PATH — no manual setup, works on the first
|
|
145
|
+
try on any machine.
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Install pipx (once per machine)
|
|
149
|
+
py -m pip install --user pipx
|
|
150
|
+
py -m pipx ensurepath
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Close and reopen your terminal, then:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
pipx install alexforge
|
|
157
|
+
alexforge --version # works immediately
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
> **Windows users:** `pipx ensurepath` handles PATH for you. After running it
|
|
161
|
+
> once, every subsequent `pipx install <tool>` just works.
|
|
162
|
+
|
|
163
|
+
### Alternative: plain pip
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
pip install alexforge
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
> **Note:** On Windows, `pip install` may place the `alexforge` command in a
|
|
170
|
+
> Scripts directory that is not yet on your PATH. If `alexforge` is not
|
|
171
|
+
> recognised after install, run the one-time fix below and restart your
|
|
172
|
+
> terminal.
|
|
173
|
+
|
|
174
|
+
#### Windows PATH fix (one time only)
|
|
175
|
+
|
|
176
|
+
```powershell
|
|
177
|
+
alexforge setup-shell
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
If the `alexforge` command is still not available yet, use:
|
|
181
|
+
|
|
182
|
+
```powershell
|
|
183
|
+
py -m localforge setup-shell
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Then **close and reopen your terminal** — `alexforge` will work from that
|
|
187
|
+
point on, permanently.
|
|
188
|
+
|
|
189
|
+
### From source (development)
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
git clone https://github.com/alexforge/localforge.git
|
|
193
|
+
cd localforge
|
|
194
|
+
pip install -e ".[dev]"
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Quick Start
|
|
200
|
+
|
|
201
|
+
### 1. Start with cloud-chat (fastest path)
|
|
202
|
+
|
|
203
|
+
If your main workflow is cloud-powered coding assistance, start here first:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
cd your-project/
|
|
207
|
+
alexforge cloud-chat
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
What happens on first run:
|
|
211
|
+
- You paste browser auth headers when prompted.
|
|
212
|
+
- AlexForge validates and caches credentials locally.
|
|
213
|
+
- It auto-checks your repo index and creates/refreshes it if needed.
|
|
214
|
+
- You enter an interactive cloud session (Gemini 3.1 Pro preview).
|
|
215
|
+
|
|
216
|
+
Useful options:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
alexforge cloud-chat --fresh-auth # force re-authentication
|
|
220
|
+
alexforge cloud-chat --repo ./myapp # target a specific repo
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### 2. Install Ollama and pull a model (for local mode)
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
# Install Ollama from https://ollama.com
|
|
227
|
+
ollama pull qwen2.5-coder:7b
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### 3. Initialize your project
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
cd your-project/
|
|
234
|
+
alexforge init
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
This creates a `.localforge/` directory with:
|
|
238
|
+
- `config.yml` — model and behavior settings
|
|
239
|
+
- `rules.md` — project-specific coding rules (injected into every prompt)
|
|
240
|
+
- `commands.yml` — custom verification commands
|
|
241
|
+
|
|
242
|
+
### 4. Index the codebase
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
alexforge index
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Builds a SQLite index with full-text search, symbol extraction, and file
|
|
249
|
+
metadata. Runs in seconds for most repos. Re-run after major changes.
|
|
250
|
+
|
|
251
|
+
### 5. Search your code (optional)
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
alexforge search "authentication"
|
|
255
|
+
alexforge search "UserModel" --mode symbol
|
|
256
|
+
alexforge search "config.py" --mode filename
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### 6. Run the full autofix pipeline
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
alexforge autofix "fix the authentication bug in the login endpoint"
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
The agent will: analyze → plan → patch → verify → reflect → iterate. All
|
|
266
|
+
locally, all with your approval at each step.
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Complete CLI Reference
|
|
271
|
+
|
|
272
|
+
### Global Options
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
alexforge --version # Show version
|
|
276
|
+
alexforge --verbose # Enable debug logging (aliases: --debug)
|
|
277
|
+
alexforge --help # Show all commands
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### `alexforge cloud-chat`
|
|
281
|
+
|
|
282
|
+
Start an interactive cloud-powered coding session.
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
alexforge cloud-chat
|
|
286
|
+
alexforge cloud-chat --fresh-auth
|
|
287
|
+
alexforge cloud-chat --repo ./myapp
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
When to use this:
|
|
291
|
+
- You want fast autonomous assistance with cloud model quality.
|
|
292
|
+
- You are okay using browser-derived auth headers at runtime.
|
|
293
|
+
|
|
294
|
+
Behavior summary:
|
|
295
|
+
- Prompts for auth headers (or reuses cached ones if still valid).
|
|
296
|
+
- Validates credentials and safely re-prompts on invalid/expired auth.
|
|
297
|
+
- Ensures repo index exists before session starts.
|
|
298
|
+
- Opens an interactive chat loop for coding tasks.
|
|
299
|
+
|
|
300
|
+
| Flag | Description |
|
|
301
|
+
|------|-------------|
|
|
302
|
+
| `--fresh-auth` | Force re-entering authentication headers |
|
|
303
|
+
| `--repo`, `-r` | Path to the repository root |
|
|
304
|
+
|
|
305
|
+
### `alexforge init`
|
|
306
|
+
|
|
307
|
+
Initialize a `.localforge/` directory with default configuration files.
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
alexforge init # current directory
|
|
311
|
+
alexforge init /path/to/repo # specific repo
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Creates: `config.yml`, `rules.md`, `commands.yml`.
|
|
315
|
+
|
|
316
|
+
### `alexforge index`
|
|
317
|
+
|
|
318
|
+
Build or refresh the SQLite code index for fast retrieval. Does **not** require
|
|
319
|
+
Ollama to be running.
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
alexforge index # incremental update (only re-indexes changed files)
|
|
323
|
+
alexforge index --force # full re-index from scratch
|
|
324
|
+
alexforge index --repo ./myapp
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
| Flag | Description |
|
|
328
|
+
|------|-------------|
|
|
329
|
+
| `--force` | Re-index all files from scratch |
|
|
330
|
+
| `--repo`, `-r` | Path to the repository root (default: `.`) |
|
|
331
|
+
|
|
332
|
+
### `alexforge search`
|
|
333
|
+
|
|
334
|
+
Search the codebase index directly — great for exploring what the agent will see.
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
alexforge search "database connection" # search everything
|
|
338
|
+
alexforge search "UserModel" --mode symbol # search symbol names only
|
|
339
|
+
alexforge search "config" --mode filename # search file names only
|
|
340
|
+
alexforge search "authenticate" --mode text # full-text search only
|
|
341
|
+
alexforge search "login" --limit 20 # more results
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
| Flag | Description |
|
|
345
|
+
|------|-------------|
|
|
346
|
+
| `--mode`, `-m` | Search mode: `all`, `text`, `filename`, `symbol` |
|
|
347
|
+
| `--limit`, `-n` | Max results (default: `10`) |
|
|
348
|
+
| `--repo`, `-r` | Path to the repository root |
|
|
349
|
+
|
|
350
|
+
### `alexforge analyze`
|
|
351
|
+
|
|
352
|
+
Retrieve the most relevant code chunks for a given task description. Useful to
|
|
353
|
+
preview what context the agent will work with.
|
|
354
|
+
|
|
355
|
+
```bash
|
|
356
|
+
alexforge analyze "why is the login endpoint slow?"
|
|
357
|
+
alexforge analyze "add pagination to the users API" --limit 20
|
|
358
|
+
alexforge analyze "..." --model codellama:13b
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
| Flag | Description |
|
|
362
|
+
|------|-----------|
|
|
363
|
+
| `--limit`, `-n` | Max chunks to retrieve (default: `10`) |
|
|
364
|
+
| `--model`, `-m` | Override the Ollama model |
|
|
365
|
+
| `--repo`, `-r` | Path to the repository root |
|
|
366
|
+
|
|
367
|
+
### `alexforge plan`
|
|
368
|
+
|
|
369
|
+
Run analysis and produce an execution plan, saved to `.localforge/last_plan.json`.
|
|
370
|
+
|
|
371
|
+
```bash
|
|
372
|
+
alexforge plan "add input validation to the signup form"
|
|
373
|
+
alexforge plan "..." --model qwen2.5-coder:32b
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
| Flag | Description |
|
|
377
|
+
|------|-----------|
|
|
378
|
+
| `--model`, `-m` | Override the Ollama model |
|
|
379
|
+
| `--repo`, `-r` | Path to the repository root |
|
|
380
|
+
|
|
381
|
+
### `alexforge patch`
|
|
382
|
+
|
|
383
|
+
Generate and apply code patches from a saved plan.
|
|
384
|
+
|
|
385
|
+
```bash
|
|
386
|
+
alexforge patch "add input validation to the signup form"
|
|
387
|
+
alexforge patch "fix bug" --step 2 # execute only step 2
|
|
388
|
+
alexforge patch "fix bug" --dry-run # preview without writing
|
|
389
|
+
alexforge patch "fix bug" --yes # auto-approve all patches
|
|
390
|
+
alexforge patch "fix bug" --model codellama:13b
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
| Flag | Description |
|
|
394
|
+
|------|-----------|
|
|
395
|
+
| `--step`, `-s` | Execute only this step number |
|
|
396
|
+
| `--dry-run` | Show patches without applying |
|
|
397
|
+
| `--yes`, `-y` | Auto-approve all patches |
|
|
398
|
+
| `--model`, `-m` | Override the Ollama model |
|
|
399
|
+
| `--repo`, `-r` | Path to the repository root |
|
|
400
|
+
|
|
401
|
+
### `alexforge verify`
|
|
402
|
+
|
|
403
|
+
Run the project's verification suite. Auto-detects: **pytest**, **ruff**,
|
|
404
|
+
**mypy**, **npm test**, **go test**.
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
alexforge verify
|
|
408
|
+
alexforge verify --repo ./myapp
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### `alexforge autofix`
|
|
412
|
+
|
|
413
|
+
**The main command.** Runs the full agent pipeline end-to-end: analyze → plan →
|
|
414
|
+
patch → verify → reflect → iterate.
|
|
415
|
+
|
|
416
|
+
```bash
|
|
417
|
+
alexforge autofix "fix the failing test in test_users.py"
|
|
418
|
+
alexforge autofix "refactor the database layer to use async" --model codellama:13b
|
|
419
|
+
alexforge autofix "add caching to the API" --yes --profile large
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
| Flag | Description |
|
|
423
|
+
|------|-------------|
|
|
424
|
+
| `--yes`, `-y` | Auto-approve all patches |
|
|
425
|
+
| `--dry-run` | Show patches without applying them |
|
|
426
|
+
| `--model`, `-m` | Override the Ollama model |
|
|
427
|
+
| `--profile`, `-p` | Model profile: `small`, `medium`, `large` |
|
|
428
|
+
| `--max-iterations` | Override max agent iterations |
|
|
429
|
+
| `--repo`, `-r` | Path to the repository root |
|
|
430
|
+
|
|
431
|
+
### `alexforge diff`
|
|
432
|
+
|
|
433
|
+
Show unified diffs for changes made by alexforge (uses the backup system).
|
|
434
|
+
|
|
435
|
+
```bash
|
|
436
|
+
alexforge diff # latest backup
|
|
437
|
+
alexforge diff 20260403_143022 # specific timestamp
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
### `alexforge rollback`
|
|
441
|
+
|
|
442
|
+
Undo changes by restoring files from a backup snapshot.
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
alexforge rollback # list available backups
|
|
446
|
+
alexforge rollback 20260403T143022 # restore specific backup
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### `alexforge status`
|
|
450
|
+
|
|
451
|
+
Show project status: index stats, Ollama health, model info, git status, and last task.
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
alexforge status
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### `alexforge models`
|
|
458
|
+
|
|
459
|
+
List all available models on your Ollama instance and show the current default.
|
|
460
|
+
|
|
461
|
+
```bash
|
|
462
|
+
alexforge models
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
### `alexforge set-model`
|
|
466
|
+
|
|
467
|
+
Set your default model interactively or by specifying a model name directly.
|
|
468
|
+
|
|
469
|
+
```bash
|
|
470
|
+
alexforge set-model # interactive selection
|
|
471
|
+
alexforge set-model qwen2.5-coder:14b # set directly
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
| Flag | Description |
|
|
475
|
+
|------|-------------|
|
|
476
|
+
| `--repo`, `-r` | Path to the repository root |
|
|
477
|
+
|
|
478
|
+
### `alexforge chat`
|
|
479
|
+
|
|
480
|
+
Start an interactive **local** conversational REPL (Ollama) about your codebase.
|
|
481
|
+
Ask questions, explore code, and plan changes interactively. Chat history
|
|
482
|
+
persists between sessions.
|
|
483
|
+
|
|
484
|
+
```bash
|
|
485
|
+
alexforge chat
|
|
486
|
+
alexforge chat --model codellama:13b
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
| Flag | Description |
|
|
490
|
+
|------|-------------|
|
|
491
|
+
| `--model`, `-m` | Override the Ollama model |
|
|
492
|
+
| `--repo`, `-r` | Path to the repository root |
|
|
493
|
+
|
|
494
|
+
**In-chat commands:**
|
|
495
|
+
|
|
496
|
+
| Command | Description |
|
|
497
|
+
|---------|-------------|
|
|
498
|
+
| `/clear` | Clear chat history |
|
|
499
|
+
| `/context <query>` | Search codebase and show matching context |
|
|
500
|
+
| `/history` | Show conversation history |
|
|
501
|
+
| `/help` | Show available commands |
|
|
502
|
+
| `/quit` | Exit the chat |
|
|
503
|
+
|
|
504
|
+
### `alexforge history`
|
|
505
|
+
|
|
506
|
+
Show a list of previous autofix task runs.
|
|
507
|
+
|
|
508
|
+
```bash
|
|
509
|
+
alexforge history
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
---
|
|
513
|
+
|
|
514
|
+
## Architecture
|
|
515
|
+
|
|
516
|
+
```
|
|
517
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
518
|
+
│ CLI (Typer) │
|
|
519
|
+
│ init │ index │ search │ analyze │ plan │ patch │ verify │
|
|
520
|
+
│ autofix │ cloud-chat │ diff │ rollback │ status │ chat │ history │
|
|
521
|
+
└───────────────────────┬─────────────────────────────────────┘
|
|
522
|
+
│
|
|
523
|
+
┌────────────▼────────────┐
|
|
524
|
+
│ AgentOrchestrator │
|
|
525
|
+
│ (coordinates pipeline) │
|
|
526
|
+
└────┬───┬───┬───┬───┬───┘
|
|
527
|
+
│ │ │ │ │
|
|
528
|
+
┌──────────┘ │ │ │ └──────────┐
|
|
529
|
+
▼ ▼ ▼ ▼ ▼
|
|
530
|
+
┌─────────┐ ┌────────┐ ┌────────┐ ┌───────────┐
|
|
531
|
+
│ Analyzer│ │Planner │ │ Coder │ │ Verifier │
|
|
532
|
+
└─────────┘ └────────┘ └────────┘ └───────────┘
|
|
533
|
+
│ │
|
|
534
|
+
┌──────┘ ┌────────┘
|
|
535
|
+
▼ ▼
|
|
536
|
+
┌──────────┐ ┌──────────┐
|
|
537
|
+
│Reflector │ │Summarizer│
|
|
538
|
+
└──────────┘ └──────────┘
|
|
539
|
+
|
|
540
|
+
┌─────────────────────────────────────────────┐
|
|
541
|
+
│ Support Layer │
|
|
542
|
+
│ │
|
|
543
|
+
│ ┌──────────────┐ ┌───────────────────┐ │
|
|
544
|
+
│ │ Repository │ │ Context Manager │ │
|
|
545
|
+
│ │ Indexer │ │ (Budget + Asm.) │ │
|
|
546
|
+
│ │ (SQLite) │ │ │ │
|
|
547
|
+
│ └──────────────┘ └───────────────────┘ │
|
|
548
|
+
│ │
|
|
549
|
+
│ ┌──────────────┐ ┌───────────────────┐ │
|
|
550
|
+
│ │ Retriever │ │ File Patcher │ │
|
|
551
|
+
│ │ + Ranking │ │ (backup + apply) │ │
|
|
552
|
+
│ └──────────────┘ └───────────────────┘ │
|
|
553
|
+
│ │
|
|
554
|
+
│ ┌──────────────┐ ┌───────────────────┐ │
|
|
555
|
+
│ │ Ollama Client│ │ Verification │ │
|
|
556
|
+
│ │ (httpx) │ │ Runner │ │
|
|
557
|
+
│ └──────────────┘ └───────────────────┘ │
|
|
558
|
+
└─────────────────────────────────────────────┘
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
### Component overview
|
|
562
|
+
|
|
563
|
+
| Component | Location | Purpose |
|
|
564
|
+
|-----------|----------|---------|
|
|
565
|
+
| **CLI** | `localforge/cli/` | Typer-based CLI with cloud and local commands |
|
|
566
|
+
| **Agents** | `localforge/agent/` | 6 specialist agents + orchestrator |
|
|
567
|
+
| **Chat** | `localforge/chat/` | Interactive local chat REPL with session persistence |
|
|
568
|
+
| **Cloud Chat** | `localforge/cloud/` | Cloud client, auth handling, and autonomous cloud chat loop |
|
|
569
|
+
| **Core** | `localforge/core/` | Config, data models, Ollama client, Git utils, prompt templates |
|
|
570
|
+
| **Index** | `localforge/index/` | SQLite-backed code index + FTS5 search |
|
|
571
|
+
| **Retrieval** | `localforge/retrieval/` | Multi-strategy context retrieval + ranking |
|
|
572
|
+
| **Context Manager** | `localforge/context_manager/` | Token counting, budget allocation, prompt assembly |
|
|
573
|
+
| **Patching** | `localforge/patching/` | File patching with backup, rollback, fuzzy matching |
|
|
574
|
+
| **Verifier** | `localforge/verifier/` | Project detection + automated test/lint/type-check |
|
|
575
|
+
|
|
576
|
+
---
|
|
577
|
+
|
|
578
|
+
## Agent Loop
|
|
579
|
+
|
|
580
|
+
The orchestrator drives a multi-phase loop. Each phase uses a dedicated agent
|
|
581
|
+
with its own system prompt and structured JSON output schema.
|
|
582
|
+
|
|
583
|
+
```
|
|
584
|
+
┌──────────────┐
|
|
585
|
+
│ User Task │
|
|
586
|
+
└──────┬───────┘
|
|
587
|
+
▼
|
|
588
|
+
┌──────────────┐
|
|
589
|
+
│ 1. ANALYZE │──── Understand the task & codebase
|
|
590
|
+
└──────┬───────┘
|
|
591
|
+
▼
|
|
592
|
+
┌──────────────┐
|
|
593
|
+
│ 2. PLAN │──── Produce ordered step list
|
|
594
|
+
└──────┬───────┘
|
|
595
|
+
▼
|
|
596
|
+
┌───────────────────────┐
|
|
597
|
+
│ For each plan step: │
|
|
598
|
+
│ ┌──────────────────┐ │
|
|
599
|
+
│ │ 3. CODE (patch) │ │
|
|
600
|
+
│ └────────┬─────────┘ │
|
|
601
|
+
│ ▼ │
|
|
602
|
+
│ ┌──────────────────┐ │
|
|
603
|
+
│ │ 4. VERIFY │ │
|
|
604
|
+
│ └────────┬─────────┘ │
|
|
605
|
+
│ │ │
|
|
606
|
+
│ pass? │ fail? │
|
|
607
|
+
│ ▼ │ ▼ │
|
|
608
|
+
│ [next] │ ┌──────┐ │
|
|
609
|
+
│ │ │REFLECT│ │
|
|
610
|
+
│ │ └──┬───┘ │
|
|
611
|
+
│ │ │ │
|
|
612
|
+
│ │ retry │
|
|
613
|
+
│ │ (≤3x) │
|
|
614
|
+
└───────────────────────┘
|
|
615
|
+
▼
|
|
616
|
+
┌──────────────┐
|
|
617
|
+
│ 5. FINAL │──── Full verification suite
|
|
618
|
+
│ VERIFY │
|
|
619
|
+
└──────┬───────┘
|
|
620
|
+
▼
|
|
621
|
+
┌──────────────┐
|
|
622
|
+
│ 6. SUMMARIZE │──── Generate change summary
|
|
623
|
+
└──────────────┘
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
### Agent details
|
|
627
|
+
|
|
628
|
+
| Agent | Input | Output | Purpose |
|
|
629
|
+
|-------|-------|--------|---------|
|
|
630
|
+
| **Analyzer** | Task + retrieved code + repo structure | Structured analysis (understanding, files, complexity) | Understand what needs to be done |
|
|
631
|
+
| **Planner** | Analysis + code context | Ordered step list with file mappings | Break work into small, executable steps |
|
|
632
|
+
| **Coder** | Plan step + file content + context | Search/replace patch (exact or full-file for CREATE) | Write the actual code change |
|
|
633
|
+
| **Verifier** | Verification command output + step info | Pass/fail decision + next action | Interpret test/lint results |
|
|
634
|
+
| **Reflector** | Failed attempts + error history | Revised approach instructions | Learn from failures and suggest alternatives |
|
|
635
|
+
| **Summarizer** | All patches + verification results | Human-readable summary | Explain what was done |
|
|
636
|
+
|
|
637
|
+
Each step retry includes the Reflector agent, which analyzes the failure and
|
|
638
|
+
suggests a different approach. Maximum retries per step: **3**.
|
|
639
|
+
|
|
640
|
+
---
|
|
641
|
+
|
|
642
|
+
## How Retrieval Works
|
|
643
|
+
|
|
644
|
+
AlexForge uses a multi-strategy retrieval pipeline (not just keyword search):
|
|
645
|
+
|
|
646
|
+
1. **Query decomposition** — The task description is split into 3–5 focused
|
|
647
|
+
sub-queries: quoted strings, snake_case identifiers, CamelCase names, file
|
|
648
|
+
name hints, and significant keywords.
|
|
649
|
+
|
|
650
|
+
2. **Multi-strategy search** — For each sub-query:
|
|
651
|
+
- **FTS5 lexical search** over indexed code chunks
|
|
652
|
+
- **Filename fuzzy matching** using SequenceMatcher
|
|
653
|
+
- **Symbol search** (function/class names) via SQL
|
|
654
|
+
- **ripgrep** integration (if available) for regex matches
|
|
655
|
+
|
|
656
|
+
3. **Scoring and ranking** — Chunks are scored by:
|
|
657
|
+
- Lexical relevance (FTS5 rank)
|
|
658
|
+
- Term-frequency of query keywords in content
|
|
659
|
+
- Path relevance (filename matches task keywords)
|
|
660
|
+
- Recency (recently modified files get a boost)
|
|
661
|
+
- Deduplication penalty (similar chunks are penalized)
|
|
662
|
+
|
|
663
|
+
4. **Token budget fitting** — Final chunks are greedily packed into the model's
|
|
664
|
+
context window, with high-value chunks truncated rather than dropped entirely.
|
|
665
|
+
|
|
666
|
+
---
|
|
667
|
+
|
|
668
|
+
## Project Rules
|
|
669
|
+
|
|
670
|
+
Create `.localforge/rules.md` with your project conventions. These rules are
|
|
671
|
+
automatically injected into every agent's system prompt.
|
|
672
|
+
|
|
673
|
+
```markdown
|
|
674
|
+
# Project Rules
|
|
675
|
+
|
|
676
|
+
- Always use type hints in Python code
|
|
677
|
+
- Follow PEP 8 style guidelines
|
|
678
|
+
- Write docstrings for all public functions
|
|
679
|
+
- Use `pytest` for testing with descriptive test names
|
|
680
|
+
- Import ordering: stdlib, third-party, local (enforced by ruff)
|
|
681
|
+
- All API endpoints must have error handling
|
|
682
|
+
- Database queries must use parameterized statements
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
The agent will follow these rules when generating patches.
|
|
686
|
+
|
|
687
|
+
---
|
|
688
|
+
|
|
689
|
+
## Configuration Reference
|
|
690
|
+
|
|
691
|
+
All configuration lives in `.localforge/config.yml`. Run `alexforge init` to
|
|
692
|
+
generate a starter file.
|
|
693
|
+
|
|
694
|
+
| Field | Type | Default | Description |
|
|
695
|
+
|-------|------|---------|-------------|
|
|
696
|
+
| `model_name` | `string` | `qwen2.5-coder:7b` | Ollama model tag |
|
|
697
|
+
| `ollama_base_url` | `string` | `http://localhost:11434` | Ollama HTTP API URL |
|
|
698
|
+
| `max_context_tokens` | `int` | `16384` | Max tokens in LLM context window |
|
|
699
|
+
| `max_iterations` | `int` | `50` | Max agent loop iterations |
|
|
700
|
+
| `repo_path` | `string` | `.` | Repository root path |
|
|
701
|
+
| `index_db_path` | `string` | `.localforge/index.db` | SQLite index location |
|
|
702
|
+
| `auto_approve` | `bool` | `false` | Auto-approve patches |
|
|
703
|
+
| `dry_run` | `bool` | `false` | Preview patches only |
|
|
704
|
+
| `log_level` | `string` | `INFO` | Logging level |
|
|
705
|
+
| `model_profile` | `string` | `small` | Profile: `small`, `medium`, `large` |
|
|
706
|
+
|
|
707
|
+
### Environment variable overrides
|
|
708
|
+
|
|
709
|
+
Variables prefixed with `LOCALFORGE_` override config values:
|
|
710
|
+
|
|
711
|
+
```bash
|
|
712
|
+
LOCALFORGE_MODEL_NAME=codellama:13b alexforge autofix "fix the bug"
|
|
713
|
+
LOCALFORGE_MAX_CONTEXT_TOKENS=8192 alexforge autofix "refactor"
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
### Model Profiles
|
|
717
|
+
|
|
718
|
+
| Profile | Context Window | Retrieval Limit | Chunk Size | Reasoning Depth |
|
|
719
|
+
|---------|---------------|-----------------|------------|-----------------|
|
|
720
|
+
| `small` | 8 192 | 5 | 512 | 2 |
|
|
721
|
+
| `medium` | 8 192 | 10 | 1 024 | 4 |
|
|
722
|
+
| `large` | 32 768 | 20 | 2 048 | 8 |
|
|
723
|
+
|
|
724
|
+
---
|
|
725
|
+
|
|
726
|
+
## Model Recommendations
|
|
727
|
+
|
|
728
|
+
AlexForge works with any Ollama-compatible model. Tested recommendations:
|
|
729
|
+
|
|
730
|
+
| Model | Size | Profile | Best For |
|
|
731
|
+
|-------|------|---------|----------|
|
|
732
|
+
| `qwen2.5-coder:7b` | 7 B | `small` | Fast iteration, simple fixes |
|
|
733
|
+
| `qwen2.5-coder:14b` | 14 B | `medium` | Good balance of speed and quality |
|
|
734
|
+
| `qwen2.5-coder:32b` | 32 B | `large` | Complex refactors, multi-file changes |
|
|
735
|
+
| `codellama:13b` | 13 B | `medium` | Strong at code generation |
|
|
736
|
+
| `deepseek-coder-v2:16b` | 16 B | `medium` | Excellent reasoning |
|
|
737
|
+
| `llama3.1:8b` | 8 B | `small` | General-purpose, good at planning |
|
|
738
|
+
|
|
739
|
+
**Tips:**
|
|
740
|
+
|
|
741
|
+
- Start with `qwen2.5-coder:7b` on `small` profile — it's fast and capable.
|
|
742
|
+
- Upgrade to a larger model only when you see plan quality issues.
|
|
743
|
+
- The `large` profile with a 32 B+ model gives the best results but requires
|
|
744
|
+
significant VRAM (≥ 24 GB).
|
|
745
|
+
- Set `max_context_tokens` to match your model's actual context window for best
|
|
746
|
+
results.
|
|
747
|
+
|
|
748
|
+
---
|
|
749
|
+
|
|
750
|
+
## Choosing and Switching Models
|
|
751
|
+
|
|
752
|
+
AlexForge gives you three ways to work with models:
|
|
753
|
+
|
|
754
|
+
### 1. List available models
|
|
755
|
+
|
|
756
|
+
See all models you have pulled in your Ollama instance:
|
|
757
|
+
|
|
758
|
+
```bash
|
|
759
|
+
alexforge models
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
This displays all available models with a checkmark next to your current default.
|
|
763
|
+
|
|
764
|
+
### 2. Set your default model
|
|
765
|
+
|
|
766
|
+
Permanently change your default model for the project:
|
|
767
|
+
|
|
768
|
+
```bash
|
|
769
|
+
# Interactive selection (shows numbered list)
|
|
770
|
+
alexforge set-model
|
|
771
|
+
|
|
772
|
+
# Direct selection
|
|
773
|
+
alexforge set-model qwen2.5-coder:14b
|
|
774
|
+
```
|
|
775
|
+
|
|
776
|
+
This updates `.localforge/config.yml` so all future commands use the new model.
|
|
777
|
+
|
|
778
|
+
### 3. Override on a per-command basis
|
|
779
|
+
|
|
780
|
+
Use `--model` (or `-m`) flag on **any** command that uses the LLM:
|
|
781
|
+
|
|
782
|
+
```bash
|
|
783
|
+
# One-time override for different commands
|
|
784
|
+
alexforge autofix "fix the bug" --model codellama:13b
|
|
785
|
+
alexforge chat --model qwen2.5-coder:32b
|
|
786
|
+
alexforge plan "refactor" --model llama3.1:8b
|
|
787
|
+
alexforge patch "fix" --model deepseek-coder-v2:16b
|
|
788
|
+
alexforge analyze "slow endpoint" --model qwen2.5-coder:14b
|
|
789
|
+
```
|
|
790
|
+
|
|
791
|
+
The flag takes precedence over your default config.
|
|
792
|
+
|
|
793
|
+
### Environment variable override
|
|
794
|
+
|
|
795
|
+
For scripting or CI/CD, use environment variables:
|
|
796
|
+
|
|
797
|
+
```bash
|
|
798
|
+
export LOCALFORGE_MODEL_NAME=qwen2.5-coder:14b
|
|
799
|
+
alexforge autofix "fix the bug"
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
### Quick model switching workflow
|
|
803
|
+
|
|
804
|
+
```bash
|
|
805
|
+
# 1. See available models
|
|
806
|
+
alexforge models
|
|
807
|
+
|
|
808
|
+
# 2. Try a model on one command
|
|
809
|
+
alexforge autofix "small fix" --model llama3.1:8b
|
|
810
|
+
|
|
811
|
+
# 3. If you like it, make it the default
|
|
812
|
+
alexforge set-model llama3.1:8b
|
|
813
|
+
|
|
814
|
+
# 4. All future commands use it
|
|
815
|
+
alexforge autofix "bigger task"
|
|
816
|
+
```
|
|
817
|
+
|
|
818
|
+
---
|
|
819
|
+
|
|
820
|
+
## Workflow Examples
|
|
821
|
+
|
|
822
|
+
### Fix a bug
|
|
823
|
+
|
|
824
|
+
```bash
|
|
825
|
+
alexforge init
|
|
826
|
+
alexforge index
|
|
827
|
+
alexforge autofix "fix the null pointer exception in UserService.get_by_id"
|
|
828
|
+
```
|
|
829
|
+
|
|
830
|
+
### Add a feature
|
|
831
|
+
|
|
832
|
+
```bash
|
|
833
|
+
alexforge autofix "add pagination to the GET /users endpoint with page and limit query params"
|
|
834
|
+
```
|
|
835
|
+
|
|
836
|
+
### Targeted step-by-step
|
|
837
|
+
|
|
838
|
+
```bash
|
|
839
|
+
# 1. See what context the agent has
|
|
840
|
+
alexforge analyze "refactor database module to use connection pooling"
|
|
841
|
+
|
|
842
|
+
# 2. Generate a plan (review before executing)
|
|
843
|
+
alexforge plan "refactor database module to use connection pooling"
|
|
844
|
+
|
|
845
|
+
# 3. Execute step-by-step with manual approval
|
|
846
|
+
alexforge patch "refactor database module to use connection pooling"
|
|
847
|
+
|
|
848
|
+
# 4. Or execute a single step
|
|
849
|
+
alexforge patch "refactor database module to use connection pooling" --step 2
|
|
850
|
+
|
|
851
|
+
# 5. Verify the changes
|
|
852
|
+
alexforge verify
|
|
853
|
+
```
|
|
854
|
+
|
|
855
|
+
### Dry-run (preview without changes)
|
|
856
|
+
|
|
857
|
+
```bash
|
|
858
|
+
alexforge autofix "add error handling to all API endpoints" --dry-run
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
### With a different model
|
|
862
|
+
|
|
863
|
+
```bash
|
|
864
|
+
alexforge autofix "optimize the database queries" --model qwen2.5-coder:32b --profile large
|
|
865
|
+
```
|
|
866
|
+
|
|
867
|
+
### Code exploration
|
|
868
|
+
|
|
869
|
+
```bash
|
|
870
|
+
# Search for functions related to auth
|
|
871
|
+
alexforge search "authenticate" --mode symbol
|
|
872
|
+
|
|
873
|
+
# Find files matching a pattern
|
|
874
|
+
alexforge search "database" --mode filename
|
|
875
|
+
|
|
876
|
+
# Full-text search
|
|
877
|
+
alexforge search "connection pool" --mode text
|
|
878
|
+
```
|
|
879
|
+
|
|
880
|
+
### Chat with your codebase
|
|
881
|
+
|
|
882
|
+
```bash
|
|
883
|
+
# Start an interactive chat session
|
|
884
|
+
alexforge chat
|
|
885
|
+
|
|
886
|
+
# In the chat:
|
|
887
|
+
# > How does the authentication flow work?
|
|
888
|
+
# > What would break if I changed the User model?
|
|
889
|
+
# > /context database connection pooling
|
|
890
|
+
# > Can you explain the retrieval pipeline?
|
|
891
|
+
```
|
|
892
|
+
|
|
893
|
+
### Undo changes
|
|
894
|
+
|
|
895
|
+
```bash
|
|
896
|
+
# List available backups
|
|
897
|
+
alexforge rollback
|
|
898
|
+
|
|
899
|
+
# Restore to a specific backup
|
|
900
|
+
alexforge rollback 20260403T143022
|
|
901
|
+
|
|
902
|
+
# Or use the diff command to review changes first
|
|
903
|
+
alexforge diff
|
|
904
|
+
```
|
|
905
|
+
|
|
906
|
+
### Debug mode
|
|
907
|
+
|
|
908
|
+
```bash
|
|
909
|
+
# See exactly what the agent is doing
|
|
910
|
+
alexforge --verbose autofix "fix the bug in auth.py"
|
|
911
|
+
```
|
|
912
|
+
|
|
913
|
+
---
|
|
914
|
+
|
|
915
|
+
## Safety & Backups
|
|
916
|
+
|
|
917
|
+
AlexForge is designed to be safe by default:
|
|
918
|
+
|
|
919
|
+
| Safety Feature | Description |
|
|
920
|
+
|----------------|-------------|
|
|
921
|
+
| **File backups** | Every file is backed up to `.localforge/backups/<timestamp>/` before any patch is applied |
|
|
922
|
+
| **Diff preview** | Every patch is displayed as a unified diff before application |
|
|
923
|
+
| **Confirmation prompt** | Patches require explicit `y` approval unless `--yes` is passed |
|
|
924
|
+
| **Dry-run mode** | Use `--dry-run` to preview all changes without writing anything |
|
|
925
|
+
| **Rollback** | `alexforge rollback <timestamp>` restores any backup state |
|
|
926
|
+
| **Verification** | After patching, the agent runs lint, type-check, and tests automatically |
|
|
927
|
+
| **Patch validation** | Patches are validated for syntax correctness and scanned for dangerous patterns (eval, os.system, hardcoded secrets, etc.) |
|
|
928
|
+
| **Path traversal protection** | File paths are validated to stay within the repository root |
|
|
929
|
+
| **Iteration cap** | The agent stops after `max_iterations` (default: 50) to prevent runaway loops |
|
|
930
|
+
| **No network** | All processing happens locally via Ollama. Zero external network calls |
|
|
931
|
+
|
|
932
|
+
---
|
|
933
|
+
|
|
934
|
+
## Tips for Best Results
|
|
935
|
+
|
|
936
|
+
1. **Be specific in your task description.** Instead of "fix the bug", say "fix
|
|
937
|
+
the null check in `UserService.get_by_id` that causes a crash when the user
|
|
938
|
+
doesn't exist".
|
|
939
|
+
|
|
940
|
+
2. **Index frequently.** Run `alexforge index` after major changes so the agent
|
|
941
|
+
has fresh context. Incremental indexing is fast.
|
|
942
|
+
|
|
943
|
+
3. **Use `analyze` first.** Before running `autofix`, use `alexforge analyze`
|
|
944
|
+
to preview what code the agent will see. If the relevant code isn't in the
|
|
945
|
+
results, adjust your task description.
|
|
946
|
+
|
|
947
|
+
4. **Start with `plan`.** For complex tasks, run `alexforge plan` first to
|
|
948
|
+
review the generated plan before execution.
|
|
949
|
+
|
|
950
|
+
5. **Use project rules.** Add your coding conventions to `.localforge/rules.md`
|
|
951
|
+
— the agent quality improves significantly when it knows your standards.
|
|
952
|
+
|
|
953
|
+
6. **Match the profile to your model.** A `small` profile with a 7B model is
|
|
954
|
+
faster and often sufficient. Only use `large` when the task genuinely needs
|
|
955
|
+
a bigger context window.
|
|
956
|
+
|
|
957
|
+
7. **Review patches carefully.** Even with verification, AI-generated patches
|
|
958
|
+
should be reviewed. The diff preview exists for a reason.
|
|
959
|
+
|
|
960
|
+
8. **Use `search` for exploration.** The `alexforge search` command is a fast
|
|
961
|
+
way to explore your codebase using the same index the agent uses.
|
|
962
|
+
|
|
963
|
+
---
|
|
964
|
+
|
|
965
|
+
## Limitations
|
|
966
|
+
|
|
967
|
+
AlexForge is alpha software. Known limitations:
|
|
968
|
+
|
|
969
|
+
| Limitation | Detail |
|
|
970
|
+
|------------|--------|
|
|
971
|
+
| **No semantic embedding search** | Retrieval is lexical + symbol-based. The embedding API exists but is not yet integrated into the search pipeline. |
|
|
972
|
+
| **No multi-repo support** | Operates on one repository at a time. |
|
|
973
|
+
| **LLM quality ceiling** | Output quality is bounded by the local model. Small models may produce incorrect patches for complex tasks. |
|
|
974
|
+
| **Context window pressure** | Very large files may be truncated to fit the token budget. Auto-detection helps, but some models still have small context windows. |
|
|
975
|
+
| **No runtime debugging** | The agent cannot set breakpoints or inspect runtime state. |
|
|
976
|
+
|
|
977
|
+
---
|
|
978
|
+
|
|
979
|
+
## Comparison with Cloud Agents
|
|
980
|
+
|
|
981
|
+
| Capability | AlexForge | Claude Code / Cursor |
|
|
982
|
+
|------------|------------|----------------------|
|
|
983
|
+
| **Privacy** | 100 % local, code never leaves machine | Code sent to cloud APIs |
|
|
984
|
+
| **Cost** | Free (uses your GPU) | Per-token or subscription billing |
|
|
985
|
+
| **Offline** | Fully offline | Requires internet |
|
|
986
|
+
| **Multi-agent** | 6 specialist agents with structured handoffs | Typically single-agent |
|
|
987
|
+
| **Interactive chat** | Yes (`alexforge chat` with persistent history) | Yes |
|
|
988
|
+
| **Streaming output** | Yes (token-by-token) | Yes |
|
|
989
|
+
| **Git integration** | Auto-checkpoints before/after changes | Varies |
|
|
990
|
+
| **Code search** | SQLite FTS5 + symbols + ripgrep | Embedding-based or none |
|
|
991
|
+
| **Multi-language** | Python, JS/TS, Go, Rust, Java, C#, Ruby, PHP, C/C++ | Yes |
|
|
992
|
+
| **Safety** | Backup + diff + confirm + rollback + validation | Varies |
|
|
993
|
+
| **Token awareness** | Explicit budget management + auto-detect context window | May silently truncate |
|
|
994
|
+
| **Verification** | Auto-detects & runs pytest, ruff, mypy, npm test, go test | Usually manual |
|
|
995
|
+
| **Project rules** | `.localforge/rules.md` injected into all prompts | `.cursorrules` / CLAUDE.md |
|
|
996
|
+
| **Model quality** | Limited by local hardware (7B–70B) | GPT-4, Claude 3.5, etc. |
|
|
997
|
+
|
|
998
|
+
**Where AlexForge wins:** privacy, cost, offline use, transparency, safety
|
|
999
|
+
features, multi-agent architecture, token budget management, zero configuration.
|
|
1000
|
+
|
|
1001
|
+
**Where cloud agents win:** model quality (access to frontier models), semantic
|
|
1002
|
+
search, larger context windows, faster inference on large models.
|
|
1003
|
+
|
|
1004
|
+
---
|
|
1005
|
+
|
|
1006
|
+
## Changelog
|
|
1007
|
+
|
|
1008
|
+
### v0.4.0
|
|
1009
|
+
|
|
1010
|
+
- **Tool-use from chat.** The chat engine now supports autonomous tool
|
|
1011
|
+
execution — the LLM can read files, write files, edit code, run shell
|
|
1012
|
+
commands, and search the codebase on its own, similar to Claude Code.
|
|
1013
|
+
- **New slash commands.** `/run <cmd>` to execute shell commands, `/read <path>`
|
|
1014
|
+
to read files, `/tokens` to see session token usage — all from within chat.
|
|
1015
|
+
- **Shell execution safety.** Destructive commands (`rm`, `del`, `format`, etc.)
|
|
1016
|
+
are blocked. Output is truncated at 20KB. Commands time out after 60 seconds.
|
|
1017
|
+
- **Path traversal hardening.** Uses `Path.is_relative_to()` instead of string
|
|
1018
|
+
prefix checks for cross-platform safety.
|
|
1019
|
+
- **Chat context window auto-detect.** The `chat` command now auto-detects the
|
|
1020
|
+
model's context window, matching the `autofix` command's behavior.
|
|
1021
|
+
- **Resource cleanup fixes.** Async `ollama.close()` now runs in the same event
|
|
1022
|
+
loop for both `chat` and `patch` commands, preventing resource leaks.
|
|
1023
|
+
- **Orchestrator path fix.** File reading during plan execution now correctly
|
|
1024
|
+
resolves repo-relative paths instead of relying on CWD.
|
|
1025
|
+
- **Version sync fix.** `__init__.py` and `pyproject.toml` versions are now
|
|
1026
|
+
consistent.
|
|
1027
|
+
- **New: 132 tests** (up from 109).
|
|
1028
|
+
- Version bump to 0.4.0.
|
|
1029
|
+
|
|
1030
|
+
### v0.3.0
|
|
1031
|
+
|
|
1032
|
+
- **Interactive chat.** `alexforge chat` — conversational REPL with codebase
|
|
1033
|
+
context retrieval, persistent chat history, and slash commands.
|
|
1034
|
+
- **Streaming output.** Model responses now stream token-by-token to the
|
|
1035
|
+
terminal instead of showing only a spinner.
|
|
1036
|
+
- **Auto-detect context window.** Queries the Ollama `/api/show` endpoint to
|
|
1037
|
+
determine the model's actual context window size automatically.
|
|
1038
|
+
- **Git integration.** Automatic git checkpoints before and after `autofix`
|
|
1039
|
+
runs. The `status` command now shows git branch and changed files.
|
|
1040
|
+
- **Enhanced symbol extraction.** Full support for Python (async, constants),
|
|
1041
|
+
JavaScript/TypeScript (const/let/var exports, interfaces, types, enums),
|
|
1042
|
+
Go (methods with receivers, struct/interface), Rust (pub fn, struct, enum,
|
|
1043
|
+
trait, impl), Java/Kotlin/C# (classes, interfaces, enums, methods),
|
|
1044
|
+
Ruby (modules), PHP, and C/C++.
|
|
1045
|
+
- **Task history.** `alexforge history` command shows previous autofix runs.
|
|
1046
|
+
- **Patch safety.** The patcher now runs safety and syntax validation before
|
|
1047
|
+
applying patches, with interactive warnings for dangerous operations.
|
|
1048
|
+
- **New: 109 tests** (up from 86).
|
|
1049
|
+
- Version bump to 0.3.0.
|
|
1050
|
+
|
|
1051
|
+
### v0.2.0
|
|
1052
|
+
|
|
1053
|
+
- Added `alexforge search` command (text, filename, symbol modes).
|
|
1054
|
+
- Added `alexforge rollback` command.
|
|
1055
|
+
- Added `--verbose`/`--debug` flag with logging.
|
|
1056
|
+
- Added project rules injection from `.localforge/rules.md`.
|
|
1057
|
+
- Fixed: removed unnecessary Ollama check from `index` command.
|
|
1058
|
+
- Fixed: converted smoke tests from inline scripts to proper pytest format.
|
|
1059
|
+
- Comprehensive README.
|
|
1060
|
+
|
|
1061
|
+
### v0.1.0
|
|
1062
|
+
|
|
1063
|
+
- Initial release with full multi-agent pipeline.
|
|
1064
|
+
|
|
1065
|
+
---
|
|
1066
|
+
|
|
1067
|
+
## Contributing
|
|
1068
|
+
|
|
1069
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
1070
|
+
|
|
1071
|
+
```bash
|
|
1072
|
+
# Development setup
|
|
1073
|
+
git clone https://github.com/alexforge/localforge.git
|
|
1074
|
+
cd alexforge
|
|
1075
|
+
pip install -e ".[dev]"
|
|
1076
|
+
|
|
1077
|
+
# Run tests
|
|
1078
|
+
python -m pytest tests/ -v
|
|
1079
|
+
|
|
1080
|
+
# Lint
|
|
1081
|
+
ruff check .
|
|
1082
|
+
|
|
1083
|
+
# Type check
|
|
1084
|
+
mypy alexforge/
|
|
1085
|
+
```
|
|
1086
|
+
|
|
1087
|
+
---
|
|
1088
|
+
|
|
1089
|
+
## License
|
|
1090
|
+
|
|
1091
|
+
MIT — see [LICENSE](LICENSE).
|