alpiecode 0.9.8__tar.gz → 1.0.0__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.
- {alpiecode-0.9.8 → alpiecode-1.0.0}/PKG-INFO +1 -1
- alpiecode-1.0.0/README.md +96 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/pyproject.toml +1 -1
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/alpiecode.egg-info/PKG-INFO +1 -1
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/backends/openai_backend.py +15 -7
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/executor.py +6 -2
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/tools.py +41 -3
- alpiecode-0.9.8/README.md +0 -74
- {alpiecode-0.9.8 → alpiecode-1.0.0}/setup.cfg +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/alpiecode.egg-info/SOURCES.txt +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/alpiecode.egg-info/dependency_links.txt +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/alpiecode.egg-info/entry_points.txt +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/alpiecode.egg-info/requires.txt +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/alpiecode.egg-info/top_level.txt +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/__init__.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/agent.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/backends/__init__.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/backends/base.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/backends/local_backend.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/cache.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/cli.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/client.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/compaction.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/config.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/context.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/extension/alpiecode.vsix +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/github.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/guardian.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/local_model.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/media.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/memory.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/orchestrator.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/prompt.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/server.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/session.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/updater.py +0 -0
- {alpiecode-0.9.8 → alpiecode-1.0.0}/src/codeagent/vscode_installer.py +0 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# 🤖 AlpieCode
|
|
2
|
+
|
|
3
|
+
> **Autonomous AI Software Engineering Agent** powered by 169Pi. Operates locally on your device (CPU/GPU) with zero internet, or connects to high-speed cloud VLM endpoints. Integrates seamlessly into **CLI**, **REST/SSE API**, and **VS Code IDE**.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
_ _ _ ____ _
|
|
7
|
+
/ \ | |_ _| | ___ / ___|___ __| | ___
|
|
8
|
+
/ _ \ | | '_ \ |/ _ \ | / _ \ / _` |/ _ / ___ \| | |_) | | __/ |__| (_) | (_| | __/
|
|
9
|
+
/_/ \_\_|_.__/|_|\___|\____\___/ \__,_|\___|
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
[](https://www.python.org/downloads/)
|
|
13
|
+
[](https://opensource.org/licenses/MIT)
|
|
14
|
+
[](https://fastapi.tiangolo.com)
|
|
15
|
+
[](./vscode)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## ⚡ Quick Start
|
|
20
|
+
|
|
21
|
+
### 1. Installation
|
|
22
|
+
```bash
|
|
23
|
+
pip install --upgrade alpiecode
|
|
24
|
+
```
|
|
25
|
+
*Or install from source with uv:*
|
|
26
|
+
```bash
|
|
27
|
+
git clone https://github.com/169pi/codeagent-poc.git
|
|
28
|
+
cd codeagent-poc
|
|
29
|
+
uv venv && source .venv/bin/activate
|
|
30
|
+
uv pip install -e .
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 2. Run Autonomous Coding Tasks (CLI)
|
|
34
|
+
```bash
|
|
35
|
+
# Direct task execution
|
|
36
|
+
alpiecode run "Create a FastAPI REST API for a todo app with full test coverage"
|
|
37
|
+
|
|
38
|
+
# Dry-run planning (read-only)
|
|
39
|
+
alpiecode plan "Refactor database connection to async SQLModel"
|
|
40
|
+
|
|
41
|
+
# Multimodal UI generation from image / screenshot
|
|
42
|
+
alpiecode run "Build an HTML/CSS landing page matching this design" --image ./mockup.png
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 3. Launch Backend & VS Code Extension
|
|
46
|
+
```bash
|
|
47
|
+
alpiecode serve
|
|
48
|
+
```
|
|
49
|
+
*Starts the background API and automatically installs the AlpieCode VS Code Extension.*
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 🌟 Key Highlights
|
|
54
|
+
|
|
55
|
+
- 🌐 **Dual Online & Offline Modes**: High-speed cloud VLM (80-120 tok/s) when online, automatic fallback to local GGUF (`169Pi/Alpie_learn_prototype_GGUF_NEW`) on CPU/GPU when offline.
|
|
56
|
+
- 💭 **Thinking & Non-Thinking Modes**: Deep chain-of-thought reasoning for complex multi-file projects, or instant low-latency mode for rapid edits.
|
|
57
|
+
- 🖼️ **Multimodal Perception**: Analyze UI mockups, screenshots, video recordings (`--video`), YouTube links (`--url`), and GitHub repos (`--github`).
|
|
58
|
+
- ⚡ **VS Code Ghost-Text Autocomplete**: Real-time Fill-In-Middle inline suggestions. Press `Tab` to accept.
|
|
59
|
+
- 📝 **Native Side-by-Side Diff Previews**: Inspect `Original ↔ Modified` diffs with one-click `Accept` or `Reject` in VS Code before writing to disk.
|
|
60
|
+
- 🛡️ **Guardian Safety Gate**: Automatically classifies shell commands into `SAFE`, `WARNING`, and hard-blocks `DANGEROUS` operations (`rm -rf /`, `sudo`, `mkfs`).
|
|
61
|
+
- 🧠 **Cross-Session Memory & Plan Preservation**: Automatically remembers working build/test commands and project architecture across chat sessions.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 📖 Complete Documentation
|
|
66
|
+
|
|
67
|
+
For the full detailed manual covering all 14 tools, CLI flags, REST API endpoints, vision extraction, and offline GGUF setup:
|
|
68
|
+
|
|
69
|
+
👉 **[Read the Full Documentation (DOCUMENTATION.md)](./DOCUMENTATION.md)**
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 🛠️ CLI Cheat Sheet
|
|
74
|
+
|
|
75
|
+
| Command | Description |
|
|
76
|
+
|:---|:---|
|
|
77
|
+
| `alpiecode run "<task>"` | Execute an autonomous software engineering task |
|
|
78
|
+
| `alpiecode chat` | Multi-turn interactive terminal REPL |
|
|
79
|
+
| `alpiecode plan "<task>"` | Generate a structured execution plan (read-only dry run) |
|
|
80
|
+
| `alpiecode diff` | Show git diff of all modifications made by AlpieCode |
|
|
81
|
+
| `alpiecode serve` | Start API server on `http://127.0.0.1:7169` & install VS Code plugin |
|
|
82
|
+
| `alpiecode init` | Guided setup wizard (pre-download offline GGUF model) |
|
|
83
|
+
|
|
84
|
+
### Important Flags
|
|
85
|
+
- `--image <path>` : Analyze screenshot/diagram for vision tasks
|
|
86
|
+
- `--video <path>` : Extract keyframes from video for debugging
|
|
87
|
+
- `--url <url>` : Analyze YouTube tutorial/bug report
|
|
88
|
+
- `--github <repo>` : Explore open-source repo (e.g. `facebook/react`)
|
|
89
|
+
- `--no-thinking` : Disable reasoning tokens for instant execution
|
|
90
|
+
- `--max-turns <n>` : Set maximum turn limit (default: `50`)
|
|
91
|
+
- `--workdir <dir>` : Set target workspace directory
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 📄 License
|
|
96
|
+
MIT License. Built by the **169Pi AI Research Team**.
|
|
@@ -63,14 +63,22 @@ class OpenAIBackend:
|
|
|
63
63
|
tool_calls = None
|
|
64
64
|
if msg.tool_calls:
|
|
65
65
|
import json
|
|
66
|
-
tool_calls = [
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
tool_calls = []
|
|
67
|
+
for tc in msg.tool_calls:
|
|
68
|
+
try:
|
|
69
|
+
args = json.loads(tc.function.arguments or "{}")
|
|
70
|
+
except (json.JSONDecodeError, TypeError):
|
|
71
|
+
args = {}
|
|
72
|
+
# Defensive: ensure args is always a dict (model sometimes returns lists or strings)
|
|
73
|
+
if not isinstance(args, dict):
|
|
74
|
+
args = {}
|
|
75
|
+
tool_calls.append(
|
|
76
|
+
ToolCall(
|
|
77
|
+
id=tc.id,
|
|
78
|
+
name=tc.function.name,
|
|
79
|
+
arguments=args,
|
|
80
|
+
)
|
|
71
81
|
)
|
|
72
|
-
for tc in msg.tool_calls
|
|
73
|
-
]
|
|
74
82
|
|
|
75
83
|
reasoning = getattr(msg, "reasoning", None) or getattr(msg, "reasoning_content", None)
|
|
76
84
|
|
|
@@ -133,9 +133,11 @@ class ToolExecutor:
|
|
|
133
133
|
if on_tool_start:
|
|
134
134
|
on_tool_start(tc.name, tc.arguments)
|
|
135
135
|
t0 = time.monotonic()
|
|
136
|
+
# Defensive: ensure arguments is always a dict
|
|
137
|
+
safe_args = tc.arguments if isinstance(tc.arguments, dict) else {}
|
|
136
138
|
fn = self.dispatch.get(tc.name)
|
|
137
139
|
if fn:
|
|
138
|
-
future = pool.submit(fn,
|
|
140
|
+
future = pool.submit(fn, safe_args)
|
|
139
141
|
else:
|
|
140
142
|
future = pool.submit(lambda: f"error: Unknown tool '{tc.name}'")
|
|
141
143
|
future_to_tc[future] = (tc, t0)
|
|
@@ -161,10 +163,12 @@ class ToolExecutor:
|
|
|
161
163
|
if on_tool_start:
|
|
162
164
|
on_tool_start(tc.name, tc.arguments)
|
|
163
165
|
t0 = time.monotonic()
|
|
166
|
+
# Defensive: ensure arguments is always a dict
|
|
167
|
+
safe_args = tc.arguments if isinstance(tc.arguments, dict) else {}
|
|
164
168
|
fn = self.dispatch.get(tc.name)
|
|
165
169
|
if fn:
|
|
166
170
|
try:
|
|
167
|
-
res_str = str(fn(
|
|
171
|
+
res_str = str(fn(safe_args))
|
|
168
172
|
except Exception as e:
|
|
169
173
|
res_str = f"error: {e}"
|
|
170
174
|
else:
|
|
@@ -334,6 +334,24 @@ def _smart_truncate(text: str, max_chars: int = 6000) -> str:
|
|
|
334
334
|
)
|
|
335
335
|
|
|
336
336
|
|
|
337
|
+
|
|
338
|
+
def _extract_script_path(command: str) -> str:
|
|
339
|
+
"""Extract the script file path from a bash command, if any."""
|
|
340
|
+
import re as _re
|
|
341
|
+
patterns = [
|
|
342
|
+
r"python3?\s+(?:-[a-zA-Z]+\s+)*([^\s|>&;]+\.py)",
|
|
343
|
+
r"node\s+([^\s|>&;]+\.js)",
|
|
344
|
+
r"ruby\s+([^\s|>&;]+\.rb)",
|
|
345
|
+
r"\./([^\s|>&;]+)",
|
|
346
|
+
r"bash\s+([^\s|>&;]+\.sh)",
|
|
347
|
+
]
|
|
348
|
+
for pat in patterns:
|
|
349
|
+
m = _re.search(pat, command)
|
|
350
|
+
if m:
|
|
351
|
+
return m.group(1)
|
|
352
|
+
return ""
|
|
353
|
+
|
|
354
|
+
|
|
337
355
|
def _bash(workdir: Path, command: str) -> str:
|
|
338
356
|
"""Run a shell command with guardian safety gate.
|
|
339
357
|
|
|
@@ -391,13 +409,33 @@ def _bash(workdir: Path, command: str) -> str:
|
|
|
391
409
|
"exit_code": result.returncode,
|
|
392
410
|
})
|
|
393
411
|
|
|
394
|
-
#
|
|
412
|
+
# ── Smart Guardrail 1: Failed command — inject actionable hints ──
|
|
395
413
|
if result.returncode != 0:
|
|
396
|
-
|
|
414
|
+
script_file = _extract_script_path(command)
|
|
415
|
+
hint = (
|
|
397
416
|
f"⚠️ COMMAND FAILED (exit_code={result.returncode}). "
|
|
398
417
|
f"Read the error output carefully and fix the ROOT CAUSE.\n"
|
|
399
|
-
+ output
|
|
400
418
|
)
|
|
419
|
+
if script_file:
|
|
420
|
+
hint += (
|
|
421
|
+
f"💡 HINT: Use read_file to examine \'{script_file}\' around the "
|
|
422
|
+
f"failing line before making edits. Do NOT guess — read first.\n"
|
|
423
|
+
)
|
|
424
|
+
output = hint + output
|
|
425
|
+
|
|
426
|
+
# ── Smart Guardrail 2: Silent success — script ran but no output ──
|
|
427
|
+
elif result.returncode == 0 and not stdout.strip() and not stderr.strip():
|
|
428
|
+
script_file = _extract_script_path(command)
|
|
429
|
+
if script_file:
|
|
430
|
+
output += (
|
|
431
|
+
"\n\n⚠️ WARNING: Command succeeded (exit_code=0) but produced "
|
|
432
|
+
"NO OUTPUT. This usually means:\n"
|
|
433
|
+
" 1. The main execution block (if __name__ == \'__main__\') is missing or broken\n"
|
|
434
|
+
" 2. An exception is being silently caught with a bare \'except: pass\'\n"
|
|
435
|
+
" 3. The print/output statements were accidentally removed\n"
|
|
436
|
+
f"→ Use read_file to check \'{script_file}\' — especially the main block "
|
|
437
|
+
"at the bottom of the file. Do NOT re-run the same command."
|
|
438
|
+
)
|
|
401
439
|
|
|
402
440
|
return output
|
|
403
441
|
except subprocess.TimeoutExpired:
|
alpiecode-0.9.8/README.md
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# AlpieCode
|
|
2
|
-
|
|
3
|
-
Autonomous AI Coding Agent CLI backed by 169Pi Alpie VLM / OpenAI-compatible endpoint
|
|
4
|
-
(speaks the `/v1/chat/completions` tool-calling protocol).
|
|
5
|
-
|
|
6
|
-
```
|
|
7
|
-
_ _ _ ____ _
|
|
8
|
-
/ \ | |_ _| | ___ / ___|___ __| | ___
|
|
9
|
-
/ _ \ | | '_ \ |/ _ \ | / _ \ / _` |/ _ \
|
|
10
|
-
/ ___ \| | |_) | | __/ |__| (_) | (_| | __/
|
|
11
|
-
/_/ \_\_|_.__/|_|\___|\____\___/ \__,_|\___|
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## Quick Start
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
git clone <repo-url>
|
|
18
|
-
cd codeagent-poc
|
|
19
|
-
uv venv && source .venv/bin/activate
|
|
20
|
-
uv pip install -e .
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
The defaults point directly to the team's Alpie VLM endpoint (`http://20.245.200.125:8000/v1` with model `169Pi/grpo_phase_2_merged`), so you can start using it immediately:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
cd your-repo
|
|
27
|
-
alpiecode "explain what this project does"
|
|
28
|
-
# or
|
|
29
|
-
alpiecode run "fix the failing test in tests/test_foo.py"
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Usage
|
|
33
|
-
|
|
34
|
-
### 1. Direct Task Execution
|
|
35
|
-
```bash
|
|
36
|
-
alpiecode "create a python script to calculate fibonacci numbers and add unit tests"
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### 2. Explicit Run Subcommand
|
|
40
|
-
```bash
|
|
41
|
-
alpiecode run "refactor database connection in main.py" --max-turns 30
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### 3. Interactive Chat Mode
|
|
45
|
-
```bash
|
|
46
|
-
alpiecode chat
|
|
47
|
-
```
|
|
48
|
-
Maintains context across multiple prompts in an interactive REPL session. Type `exit` or `quit` to stop.
|
|
49
|
-
|
|
50
|
-
### 4. Configuration (Optional)
|
|
51
|
-
```bash
|
|
52
|
-
alpiecode init
|
|
53
|
-
```
|
|
54
|
-
Configures custom endpoint settings saved to `~/.alpiecode/config.json`. Or set env vars:
|
|
55
|
-
```bash
|
|
56
|
-
export ALPIECODE_BASE_URL=http://your-host:8000/v1
|
|
57
|
-
export ALPIECODE_MODEL=169Pi/grpo_phase_2_merged
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Built-in Tool Support
|
|
61
|
-
AlpieCode comes equipped with native tool calling:
|
|
62
|
-
- **`list_files`**: Inspect repository directory structure.
|
|
63
|
-
- **`read_file`**: Read file contents with line range filtering.
|
|
64
|
-
- **`write_file`**: Create new files or overwrite existing ones.
|
|
65
|
-
- **`edit_file`**: Make exact, targeted line string replacements.
|
|
66
|
-
- **`bash`**: Execute shell commands/tests in the repository directory.
|
|
67
|
-
|
|
68
|
-
## Automatic Checkpoints
|
|
69
|
-
AlpieCode automatically initializes `git` if not already present and creates a commit checkpoint after every turn.
|
|
70
|
-
If you ever need to rollback:
|
|
71
|
-
```bash
|
|
72
|
-
git log --oneline
|
|
73
|
-
git reset --hard <checkpoint-sha>
|
|
74
|
-
```
|
|
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
|
|
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
|