alpiecode 9.0.1__tar.gz → 9.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. {alpiecode-9.0.1 → alpiecode-9.0.2}/PKG-INFO +1 -1
  2. alpiecode-9.0.2/README.md +676 -0
  3. {alpiecode-9.0.1 → alpiecode-9.0.2}/pyproject.toml +1 -1
  4. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/alpiecode.egg-info/PKG-INFO +1 -1
  5. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/__init__.py +1 -1
  6. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/backends/openai_backend.py +24 -5
  7. alpiecode-9.0.1/README.md +0 -342
  8. {alpiecode-9.0.1 → alpiecode-9.0.2}/setup.cfg +0 -0
  9. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/alpiecode/__init__.py +0 -0
  10. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/alpiecode.egg-info/SOURCES.txt +0 -0
  11. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/alpiecode.egg-info/dependency_links.txt +0 -0
  12. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/alpiecode.egg-info/entry_points.txt +0 -0
  13. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/alpiecode.egg-info/requires.txt +0 -0
  14. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/alpiecode.egg-info/top_level.txt +0 -0
  15. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/agent.py +0 -0
  16. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/backends/__init__.py +0 -0
  17. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/backends/base.py +0 -0
  18. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/backends/local_backend.py +0 -0
  19. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/cache.py +0 -0
  20. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/cli.py +0 -0
  21. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/client.py +0 -0
  22. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/compaction.py +0 -0
  23. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/config.py +0 -0
  24. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/context.py +0 -0
  25. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/discovery.py +0 -0
  26. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/doctor.py +0 -0
  27. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/executor.py +0 -0
  28. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/extension/alpiecode.vsix +0 -0
  29. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/git_ops.py +0 -0
  30. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/github.py +0 -0
  31. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/guardian.py +0 -0
  32. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/guardrails.py +0 -0
  33. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/ipython_ext.py +0 -0
  34. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/local_model.py +0 -0
  35. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/media.py +0 -0
  36. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/memory.py +0 -0
  37. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/orchestrator.py +0 -0
  38. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/progress.py +0 -0
  39. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/prompt.py +0 -0
  40. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/rephraser.py +0 -0
  41. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/server.py +0 -0
  42. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/session.py +0 -0
  43. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/tools.py +0 -0
  44. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/updater.py +0 -0
  45. {alpiecode-9.0.1 → alpiecode-9.0.2}/src/codeagent/vscode_installer.py +0 -0
  46. {alpiecode-9.0.1 → alpiecode-9.0.2}/test/test_phase1.py +0 -0
  47. {alpiecode-9.0.1 → alpiecode-9.0.2}/test/test_phase2.py +0 -0
  48. {alpiecode-9.0.1 → alpiecode-9.0.2}/test/test_phase3.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alpiecode
3
- Version: 9.0.1
3
+ Version: 9.0.2
4
4
  Summary: AlpieCode — Autonomous AI Coding Agent CLI powered by local 169Pi GGUF VLM
5
5
  Requires-Python: >=3.9
6
6
  Requires-Dist: huggingface_hub>=0.20.0
@@ -0,0 +1,676 @@
1
+ # ⚡ AlpieCode: Autonomous AI Software Engineering Agent & Full Developer Platform
2
+
3
+ [![Python Version](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue.svg)](https://www.python.org/)
4
+ [![Version](https://img.shields.io/badge/alpiecode-v9.0.1-emerald.svg)](https://github.com/169Pi/codeagent-poc)
5
+ [![VS Code Extension](https://img.shields.io/badge/vscode%20extension-v8.0.8-blueviolet.svg)](https://marketplace.visualstudio.com/)
6
+ [![FastAPI](https://img.shields.io/badge/FastAPI-0.100%2B-009688.svg)](https://fastapi.tiangolo.com/)
7
+ [![Jupyter & Colab](https://img.shields.io/badge/Jupyter%20%7C%20Colab-Ready-f37726.svg)](https://colab.research.google.com/)
8
+ [![Platforms](https://img.shields.io/badge/platform-Linux%20%7C%20WSL2%20%7C%20macOS%20%7C%20Windows-lightgrey.svg)](https://github.com/169Pi/codeagent-poc)
9
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
10
+
11
+ > **Powered by 169Pi Alpie Vision-Language-Action Models (Local GGUF & Remote Cloud API)**
12
+ > *An enterprise-grade, autonomous software engineering agent seamlessly integrated across the Command Line (CLI), VS Code Extension, FastAPI Backend Server, Python SDK, Jupyter Notebooks, and Google Colab.*
13
+
14
+ ---
15
+
16
+ ## 📑 Table of Contents
17
+ 1. [🌟 Overview & Capabilities](#-overview--capabilities)
18
+ 2. [🏗️ Core Architecture & Hybrid Dual-Engine](#️-core-architecture--hybrid-dual-engine)
19
+ 3. [📦 Complete Installation Guide](#-complete-installation-guide)
20
+ 4. [🚀 Backend API Server (`alpiecode serve`)](#-backend-api-server-alpiecode-serve)
21
+ 5. [⌨️ Command-Line Interface (CLI) Full Reference](#️-command-line-interface-cli-full-reference)
22
+ 6. [💻 VS Code Extension Deep-Dive](#-vs-code-extension-deep-dive)
23
+ 7. [🐍 Python SDK Reference (Programmatic Usage)](#-python-sdk-reference-programmatic-usage)
24
+ 8. [📓 Jupyter Notebooks, JupyterLab & Google Colab](#-jupyter-notebooks-jupyterlab--google-colab)
25
+ 9. [🛠️ 15 Built-In Autonomous Agent Tools](#️-15-built-in-autonomous-agent-tools)
26
+ 10. [🛡️ Safety Guardian, Git Checkpoints & Memory System](#️-safety-guardian-git-checkpoints--memory-system)
27
+ 11. [⚙️ Configuration & Environment Variables](#️-configuration--environment-variables)
28
+ 12. [❓ FAQ & Troubleshooting](#-faq--troubleshooting)
29
+
30
+ ---
31
+
32
+ ## 🌟 Overview & Capabilities
33
+
34
+ **AlpieCode** is an autonomous software engineering assistant that acts as a principal developer in your repository. Rather than simply generating isolated snippets, AlpieCode operates as a full-loop agent:
35
+ - **Discovers & Understands**: Recursively indexes codebases, reads files, and executes ripgrep regex searches.
36
+ - **Reasons & Plans**: Formulates implementation plans, manages checkpointed deliverables, and explains complex architectures.
37
+ - **Generates & Modifies**: Writes production code, applies surgical whitespace-accurate diff patches, and refactors existing components.
38
+ - **Executes & Self-Heals**: Executes commands in an isolated sandbox, automatically captures build/test errors, and iterates until tests pass.
39
+ - **Works Everywhere**: From the terminal and VS Code sidebar to automated Python scripts and interactive Google Colab notebooks.
40
+
41
+ ### 🎯 Feature Matrix Across Interfaces
42
+ | Feature / Capability | CLI | VS Code Extension | Python SDK | Jupyter & Colab |
43
+ | :--- | :---: | :---: | :---: | :---: |
44
+ | **Autonomous Coding Loops (`run`)** | ✅ | ✅ | ✅ | ✅ |
45
+ | **Multi-Turn Interactive Chat** | ✅ | ✅ | ✅ | ✅ |
46
+ | **Architectural Planning (`plan`)** | ✅ | ✅ | ✅ | ✅ |
47
+ | **Deep Code Explanation (`explain`)** | ✅ | ✅ | ✅ | ✅ |
48
+ | **Interactive Diff / Plan-First Review** | — | ✅ (Accept/Reject/Edit) | — | — |
49
+ | **Inline Ghost-Text Code Autocomplete** | — | ✅ (Tab to accept) | — | — |
50
+ | **Live Token Speed & Counter Meter** | — | ✅ | — | ✅ |
51
+ | **Multimodal Vision (Images/Screenshots)** | ✅ (`--image`) | ✅ (Paste / Upload) | ✅ | ✅ |
52
+ | **Video & YouTube URL Analysis** | ✅ (`--video`, `--url`) | — | ✅ | — |
53
+ | **Autonomous GitHub Repo Analysis** | ✅ (`--github`) | ✅ | ✅ | — |
54
+ | **Proactive `.venv` & Dependency Setup** | ✅ | ✅ | ✅ | ✅ |
55
+ | **Persistent Project Memory** | ✅ | ✅ | ✅ | ✅ |
56
+ | **Zero-Crash Smart GGUF Fallback** | ✅ | ✅ | ✅ | ✅ |
57
+
58
+ ---
59
+
60
+ ## 🏗️ Core Architecture & Hybrid Dual-Engine
61
+
62
+ AlpieCode employs an intelligent **Hybrid Dual-Engine** routing system that pairs the speed and depth of cloud Vision-Language-Action models with the resilience of completely offline local GGUF models.
63
+
64
+ ```
65
+ ┌────────────────────────────────────────────────────────────────────────────────────────┐
66
+ │ CLIENT LAYER │
67
+ │ VS Code Extension Terminal CLI Python SDK Jupyter / Colab │
68
+ │ (Sidebar & Ghost-Text) (alpiecode run/chat) (import alpiecode) (%alpie / %%alpie)│
69
+ └──────────────────────────┬───────────────────────┬──────────────────────┬──────────────┘
70
+ │ │ │
71
+ ▼ ▼ ▼
72
+ ┌────────────────────────────────────────────────────────────────────────────────────────┐
73
+ │ FASTAPI BACKEND SERVER (`alpiecode serve`) │
74
+ │ • POST /chat (SSE Stream) • POST /completion (Inline Ghost) • GET /sessions │
75
+ │ • POST /cancel/{id} • GET /health • GET /metrics │
76
+ └──────────────────────────────────────────┬─────────────────────────────────────────────┘
77
+
78
+
79
+ ┌────────────────────────────────────────────────────────────────────────────────────────┐
80
+ │ AGENT ORCHESTRATOR │
81
+ │ • 5-Layer Context Assembly (System + Summary + Anchors + Turns + Request) │
82
+ │ • Rolling Compaction with Lazy-Cached Summaries │
83
+ │ • Session State Isolation & Reentrancy Guards │
84
+ │ • Persistent Cross-Session Memory (~/.alpiecode/memories/) │
85
+ └──────────────────────────────────────────┬─────────────────────────────────────────────┘
86
+
87
+
88
+ ┌────────────────────────────────────────────────────────────────────────────────────────┐
89
+ │ HYBRID DUAL-ENGINE ROUTER │
90
+ │ │
91
+ │ ┌──────────────────────────────────────────────┐ │
92
+ │ │ Active Internet Connectivity? │ │
93
+ │ └──────────────┬────────────────┬──────────────┘ │
94
+ │ │ │ │
95
+ │ YES (Online) NO (Offline) │
96
+ │ │ │ │
97
+ │ ▼ ▼ │
98
+ │ ┌────────────────────────┐ ┌────────────────────────┐ │
99
+ │ │ OpenAIBackend │ │ LocalBackend │ │
100
+ │ │ (Remote 169Pi Cloud VLM│ │ (Local GGUF Engine) │ │
101
+ │ │ High-Throughput API) │ │ (Zero Internet Req.) │ │
102
+ │ └────────────────────────┘ └────────────────────────┘ │
103
+ └──────────────────────────────────────────┬─────────────────────────────────────────────┘
104
+
105
+
106
+ ┌────────────────────────────────────────────────────────────────────────────────────────┐
107
+ │ 15 AUTONOMOUS AGENT TOOLS │
108
+ │ write_file • edit_file • read_file • apply_patch • bash • list_files │
109
+ │ file_search • view_image • fetch_url • web_search • clone_repo • update_plan │
110
+ │ extract_memories • compact_context • diagnostics │
111
+ │ │ │
112
+ │ ▼ │
113
+ │ SAFETY GUARDIAN & SANDBOX GATE │
114
+ │ (Blocks destructive commands, enforces paths, sandbox execution) │
115
+ └────────────────────────────────────────────────────────────────────────────────────────┘
116
+ ```
117
+
118
+ ### ⚡ Smart Fallback Resilience
119
+ - **Network-Aware Routing**: Local GGUF fallback triggers **only when internet is genuinely unavailable**, preventing unnecessary model loading on brief cloud API delays or transient server timeouts (which are retried automatically).
120
+ - **Sanitized Chat Templates**: Converts complex multi-turn OpenAI tool schemas and system structures into sanitized templates compatible with local Jinja2 GGUF renderers.
121
+ - **Zero Crashes**: If network drops mid-session, the agent gracefully recovers or provides clear diagnostic feedback.
122
+
123
+ ---
124
+
125
+ ## 📦 Complete Installation Guide
126
+
127
+ ### 1. Prerequisites
128
+ - **Python**: `>= 3.9` (Recommended: Python 3.10, 3.11, or 3.12)
129
+ - **Platforms**:
130
+ - **Linux**: Ubuntu 20.04+, Debian 11+, Fedora, Arch Linux
131
+ - **Windows**: Native Windows 10/11 or Windows Subsystem for Linux (WSL2 / Ubuntu)
132
+ - **macOS**: Apple Silicon (M1/M2/M3/M4) & Intel
133
+ - **Dev Tools (Recommended)**: `git`, `curl`, `ripgrep` (optional, falls back automatically)
134
+
135
+ ---
136
+
137
+ ### 2. Python Package Installation
138
+
139
+ #### Option A: Quick Install via pip (Any Virtual Environment)
140
+ Activate any virtual environment of your choice (`venv`, `conda`, `uv`, `virtualenv`, `poetry`) and install directly:
141
+ ```bash
142
+ # 1. Activate your preferred virtual environment (e.g. venv)
143
+ python3 -m venv myenv
144
+ source myenv/bin/activate # On Windows: myenv\Scripts\activate
145
+
146
+ # Or using Conda:
147
+ # conda create -n alpie python=3.11 -y && conda activate alpie
148
+
149
+ # 2. Install AlpieCode
150
+ pip install alpiecode
151
+ ```
152
+
153
+ #### Option B: From Source / Editable Mode (Recommended for Developers)
154
+ ```bash
155
+ # Clone the repository
156
+ git clone https://github.com/169Pi/codeagent-poc.git
157
+ cd codeagent-poc
158
+
159
+ # Create and activate a virtual environment
160
+ python3 -m venv .venv
161
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
162
+
163
+ # Install in editable mode with all dependencies
164
+ pip install -e .
165
+ ```
166
+
167
+ #### Option C: From Wheel (.whl)
168
+ ```bash
169
+ # Build the distribution
170
+ python3 -m pip install --upgrade build
171
+ python3 -m build
172
+
173
+ # Install the wheel
174
+ pip install dist/alpiecode-9.0.1-py3-none-any.whl
175
+ ```
176
+
177
+ #### Verify CLI Installation:
178
+ ```bash
179
+ alpiecode version
180
+ # Output: alpiecode 9.0.1
181
+
182
+ alpiecode doctor
183
+ ```
184
+
185
+ ---
186
+
187
+ ### 3. VS Code Extension Installation
188
+
189
+ The VS Code extension provides the AI sidebar, plan-first review, and inline ghost-text completions.
190
+
191
+ #### Automatic Installation (Zero Configuration)
192
+ Simply launch the AlpieCode backend server from your terminal:
193
+ ```bash
194
+ alpiecode serve
195
+ ```
196
+ If the VS Code extension is not already installed, AlpieCode **automatically packages and installs the `.vsix` into VS Code**!
197
+
198
+ #### Manual Installation via CLI:
199
+ ```bash
200
+ # Using the pre-built VSIX file
201
+ code --install-extension vscode/alpiecode-8.0.8.vsix
202
+ ```
203
+
204
+ #### Manual Packaging (For Extension Developers):
205
+ ```bash
206
+ cd vscode
207
+ npm install
208
+ npm run compile
209
+ npx @vscode/vsce package
210
+ code --install-extension alpiecode-8.0.8.vsix
211
+ ```
212
+
213
+ ---
214
+
215
+ ## 🚀 Backend API Server (`alpiecode serve`)
216
+
217
+ The AlpieCode FastAPI server runs as a high-concurrency daemon connecting local development environments, VS Code sidebars, remote IDEs, and external scripts to the autonomous agent engine.
218
+
219
+ ### Launching the Server
220
+ ```bash
221
+ # Default: binds to 127.0.0.1 on port 7169
222
+ alpiecode serve
223
+
224
+ # Custom Host and Port:
225
+ alpiecode serve --host 0.0.0.0 --port 8080
226
+ ```
227
+
228
+ ```text
229
+ _ _ _ ____ _
230
+ / \ | |_ _| | ___ / ___|___ __| | ___
231
+ / _ \ | | '_ \ |/ _ \ | / _ \ / _` |/ _ \
232
+ / ___ \| | |_) | | __/ |__| (_) | (_| | __/
233
+ /_/ \_\_|_.__/|_|\___|\____\___/ \__,_|\___|
234
+
235
+ ✅ AlpieCode VS Code extension is installed.
236
+ 🚀 Starting AlpieCode Server on http://127.0.0.1:7169
237
+ INFO: Uvicorn running on http://127.0.0.1:7169 (Press CTRL+C to quit)
238
+ ```
239
+
240
+ ### REST & SSE API Endpoints Reference
241
+
242
+ | Method | Endpoint | Description | Payload / Parameters |
243
+ | :--- | :--- | :--- | :--- |
244
+ | `POST` | `/chat` | Executes an agent task, streaming events in real time via **Server-Sent Events (SSE)**. | `{"task": str, "workdir": str, "session_id": Optional[str], "image": Optional[str], "reasoning_level": "thinking"\|"high"\|"low"}` |
245
+ | `POST` | `/completion` | Provides ultra-low-latency inline code completions (ghost text) ahead of cursor. | `{"prompt": str, "suffix": str, "language": str, "max_tokens": int}` |
246
+ | `GET` | `/health` | Health diagnostic check reporting server uptime, backend availability, and cache stats. | *None* |
247
+ | `GET` | `/sessions` | Lists active multi-turn sessions with token counts and workspace paths. | *None* |
248
+ | `DELETE`| `/sessions/{session_id}` | Deletes a session container and cleans up associated resources. | `session_id` in path |
249
+ | `POST` | `/cancel/{session_id}` | Gracefully cancels an in-progress agent task. | `session_id` in path |
250
+ | `GET` | `/metrics` | Returns token usage, speeds, and agent execution performance statistics. | *None* |
251
+
252
+ ---
253
+
254
+ ## ⌨️ Command-Line Interface (CLI) Full Reference
255
+
256
+ The `alpiecode` CLI provides a developer-friendly command suite:
257
+
258
+ ```text
259
+ usage: alpiecode [-h] [-v] [--workdir WORKDIR] [--image IMAGE] [--video VIDEO]
260
+ [--url URL] [--github GITHUB] [--max-turns MAX_TURNS]
261
+ [--thinking] [--no-thinking] [--no-update] [--quiet] [--debug]
262
+ {version,init,serve,run,chat,plan,diff,undo,doctor,explain} ...
263
+ ```
264
+
265
+ ---
266
+
267
+ ### 1. `alpiecode run "<task>"`
268
+ Executes an end-to-end autonomous software engineering task:
269
+ ```bash
270
+ # Standard task in the current directory:
271
+ alpiecode run "Create a FastAPI app with SQLite auth and JWT tokens"
272
+
273
+ # Specify a target project directory:
274
+ alpiecode run "Fix all failing pytest tests" --workdir /path/to/project
275
+
276
+ # Multimodal image analysis (mockup to code, UI bug fix):
277
+ alpiecode run "Implement this dashboard layout in React and Tailwind" --image ./mockup.png
278
+
279
+ # Video walkthrough or screen recording analysis:
280
+ alpiecode run "Reproduce and fix the UI crash shown in this screen recording" --video ./bug_repro.mp4
281
+
282
+ # Analyze a YouTube tutorial or demonstration URL:
283
+ alpiecode run "Implement the architecture explained in this video" --url "https://youtube.com/watch?v=xyz"
284
+
285
+ # Analyze and clone an open-source GitHub repository:
286
+ alpiecode run "Analyze the plugin architecture of this repo and summarize it" --github "psf/requests"
287
+
288
+ # Force deep reasoning mode or fast execution mode:
289
+ alpiecode run "Audit the cryptographic security of auth.py" --thinking
290
+ alpiecode run "Add docstrings to all functions in utils.py" --no-thinking
291
+
292
+ # Show full agent discovery intelligence and tool arguments:
293
+ alpiecode run "Refactor database migrations" --debug
294
+ ```
295
+
296
+ ---
297
+
298
+ ### 2. `alpiecode chat`
299
+ Starts a persistent, interactive terminal REPL with multi-turn memory:
300
+ ```bash
301
+ alpiecode chat
302
+ ```
303
+ *Features:*
304
+ - Retains context, variable names, and architectural decisions across turns.
305
+ - Rolling compaction prevents context window overflow.
306
+ - Checkpoints git state after each turn for easy rollback.
307
+ - Exit anytime by typing `exit`, `quit`, or pressing `Ctrl+C`.
308
+
309
+ ---
310
+
311
+ ### 3. `alpiecode plan "<task>"`
312
+ Generates an actionable architectural plan **without making file modifications**:
313
+ ```bash
314
+ alpiecode plan "Migrate the frontend from JavaScript to TypeScript"
315
+ ```
316
+ *Process:*
317
+ 1. Explores existing files and types (`list_files`, `file_search`, `read_file`).
318
+ 2. Synthesizes a structured checklist plan with milestones.
319
+ 3. Outputs clear implementation steps and risk assessments.
320
+
321
+ ---
322
+
323
+ ### 4. `alpiecode explain "<target>"`
324
+ Deep-dives into a local file, function, or technical concept:
325
+ ```bash
326
+ # Explain a local file:
327
+ alpiecode explain src/codeagent/orchestrator.py
328
+
329
+ # Explain a technical concept or codebase component:
330
+ alpiecode explain "How does the rolling context compaction work in AlpieCode?"
331
+ ```
332
+
333
+ ---
334
+
335
+ ### 5. `alpiecode diff`
336
+ Inspects all file changes and diffs made by AlpieCode since the last git checkpoint:
337
+ ```bash
338
+ alpiecode diff
339
+ ```
340
+
341
+ ---
342
+
343
+ ### 6. `alpiecode undo`
344
+ Instantly rolls back all file edits made during the last AlpieCode session:
345
+ ```bash
346
+ alpiecode undo
347
+ ```
348
+
349
+ ---
350
+
351
+ ### 7. `alpiecode doctor`
352
+ Runs an instant system and environment diagnostic suite:
353
+ ```bash
354
+ alpiecode doctor
355
+ ```
356
+ *Health Checks:*
357
+ - **Python Runtime**: Python version and active virtual environment status.
358
+ - **Hardware Acceleration**: CUDA availability, GPU device name, and VRAM.
359
+ - **Network & Latency**: DNS resolution, ping latency (ms), and remote API reachability.
360
+ - **Compilers & Dev Tools**: Presence of `gcc`, `g++`, `git`, `node`, `java`, etc.
361
+ - **VS Code Extension**: Installation verification and version check.
362
+
363
+ ---
364
+
365
+ ### 8. `alpiecode init`
366
+ Interactive CLI wizard to configure endpoints, API keys, models, and defaults:
367
+ ```bash
368
+ alpiecode init
369
+ ```
370
+
371
+ ---
372
+
373
+ ## 💻 VS Code Extension Deep-Dive
374
+
375
+ The AlpieCode VS Code extension integrates directly into your daily IDE workflow.
376
+
377
+ ```
378
+ ┌────────────────────────────────────────────────────────┐
379
+ │ ALPIECODE CHAT ⚡ 48 tok/s · 1.4k│
380
+ ├────────────────────────────────────────────────────────┤
381
+ │ 🤖 Mode: [Online Cloud VLM] Reasoning: [High (Thinking)▼]
382
+ │ │
383
+ │ 👤 Create a login endpoint with rate limiting. │
384
+ │ │
385
+ │ 🤖 ── Proposed Changes: auth.py ───────────────────── │
386
+ │ ┌────────────────────────────────────────────────────┐ │
387
+ │ │ 📋 Change Plan Card │ │
388
+ │ │ - from flask import Flask │ │
389
+ │ │ + from flask import Flask, request, jsonify │ │
390
+ │ │ + from flask_limiter import Limiter │ │
391
+ │ │ │ │
392
+ │ │ [✅ Accept] [❌ Reject] [✏️ Edit Request] │ │
393
+ │ └────────────────────────────────────────────────────┘ │
394
+ │ │
395
+ │ 📦 'flask_limiter' required but not installed. │
396
+ │ [Create .venv & Install] [Install Globally] [Skip] │
397
+ ├────────────────────────────────────────────────────────┤
398
+ │ > Type /plan, /explain, /doctor, or ask a question... │
399
+ │ [📎 Image] [📋 Plan-First: ON] [Send ❯] │
400
+ └────────────────────────────────────────────────────────┘
401
+ ```
402
+
403
+ ### 1. 📋 Plan-First Review & Change Approval Workflow
404
+ - When modifying existing files, AlpieCode presents an interactive **Change Plan Card** with side-by-side / unified diffs (`-` red / `+` green).
405
+ - **`✅ Accept`**: Commits the change, opens the file in your active editor, and runs verification.
406
+ - **`❌ Reject`**: Discards the modification cleanly.
407
+ - **`✏️ Edit Request`**: Opens an inline input box to provide steering instructions (e.g. *"Use Redis backend for rate limiting"*).
408
+
409
+ ---
410
+
411
+ ### 2. 🗂️ Persistent Multi-Turn Conversation History
412
+ - **Active Thread Context**: Each chat conversation maintains a persistent `sessionId`. The model retains all prior turns, files discussed, and tool results.
413
+ - **History Drawer**: Click the **History** button (`🕒`) in the sidebar header to view, reload, or delete up to **50 past conversations** saved in VS Code global storage.
414
+
415
+ ---
416
+
417
+ ### 3. 🧠 Reasoning Level Selector
418
+ Toggle model behavior directly in the sidebar dropdown:
419
+ - 🧠 **High (Thinking)**: Maximal chain-of-thought reasoning, multi-step problem solving, and complex architectural design.
420
+ - ⚡ **Low (Fast)**: Direct code generation with zero reasoning overhead for quick one-liners and docstring edits.
421
+
422
+ ---
423
+
424
+ ### 4. ⚡ Slash Commands (`/`)
425
+ Type **`/`** in the chat input to invoke quick commands:
426
+ - `📋 /plan <task>` — Creates a structured architectural plan without modifying code.
427
+ - `💡 /explain <file>` — Explains code, architecture, or algorithms step-by-step.
428
+ - `🩺 /doctor` — Executes full system diagnostic checks in the chat window.
429
+
430
+ ---
431
+
432
+ ### 5. 🖱️ Right-Click Context Menu Actions
433
+ Highlight any code in your editor, right-click, and choose:
434
+ - **Fix This Error**: Automatically aggregates language diagnostics (errors, warnings) and selected code to generate an instant fix.
435
+ - **Generate Tests**: Writes unit tests (pytest, jest, etc.) for the selected function or class.
436
+ - **Explain Code**: Explains the selected snippet line-by-line.
437
+ - **Refactor / Optimize**: Cleans, modernizes, and improves the performance of the highlighted block.
438
+ - **Ask About Selection**: Prompts for a custom question regarding the highlighted code.
439
+
440
+ ---
441
+
442
+ ### 6. 👻 Inline Ghost-Text Code Autocomplete
443
+ As you write code in any file, AlpieCode streams inline suggestions ahead of your cursor:
444
+ - Non-intrusive gray ghost-text suggestions.
445
+ - Press **`Tab`** to accept the suggestion, or keep typing to ignore.
446
+ - Intelligent debounce and circuit breakers ensure zero editor lag.
447
+
448
+ ---
449
+
450
+ ### 7. 🐍 Proactive Virtual Environment (`.venv`) Auto-Prompt
451
+ When generated code requires external libraries (`numpy`, `pandas`, `fastapi`, etc.):
452
+ - AlpieCode scans the AST imports before execution.
453
+ - If packages are missing, an interactive prompt appears:
454
+ ```text
455
+ 📦 'fastapi' is required but not installed in your active environment.
456
+ 🐍 No virtual environment detected. Create one?
457
+
458
+ [Create .venv & Install] [Install Globally] [Skip]
459
+ ```
460
+ - Choosing **Create .venv & Install** automatically spins up `.venv`, installs the packages, and runs the script using `.venv/bin/python3`.
461
+
462
+ ---
463
+
464
+ ### 8. 📊 Live Token & Speed Meter
465
+ Displays real-time performance indicators in the sidebar header:
466
+ `🟢 Online API` ── `⚡ 46 tok/s · 📊 1,820 tokens`
467
+
468
+ ---
469
+
470
+ ### 9. 📎 Multimodal Image Attachment
471
+ - Drag-and-drop UI screenshots directly into the chat.
472
+ - Paste images directly from your clipboard (**`Ctrl+V`** / **`Cmd+V`**).
473
+ - Click **`📎 Image`** to browse and attach mockups, architecture diagrams, or error screenshots.
474
+
475
+ ---
476
+
477
+ ### 10. ⚙️ Extension Settings (`settings.json`)
478
+ Configure AlpieCode in your VS Code settings:
479
+ ```json
480
+ {
481
+ "alpiecode.serverUrl": "http://127.0.0.1:7169",
482
+ "alpiecode.showReasoning": true,
483
+ "alpiecode.enableAutocomplete": true,
484
+ "alpiecode.autoRunCode": true,
485
+ "alpiecode.autoFixErrors": true,
486
+ "alpiecode.planFirstReview": true,
487
+ "alpiecode.githubUsername": "my-github-handle",
488
+ "alpiecode.confirmGitPush": true
489
+ }
490
+ ```
491
+
492
+ ---
493
+
494
+ ## 🐍 Python SDK Reference (Programmatic Usage)
495
+
496
+ Automate engineering workflows directly in Python scripts and CI/CD pipelines:
497
+
498
+ ```python
499
+ import alpiecode
500
+
501
+ # 1. Execute an autonomous engineering task
502
+ alpiecode.run(
503
+ task="Build a benchmark script comparing Polars vs Pandas on 10M rows",
504
+ workdir="./benchmarks",
505
+ reasoning_level="thinking" # "thinking" | "high" | "low"
506
+ )
507
+
508
+ # 2. Generate an implementation plan
509
+ alpiecode.plan(
510
+ task="Refactor authentication layer to use OAuth2 and JWT tokens",
511
+ workdir="."
512
+ )
513
+
514
+ # 3. Explain a file or architecture
515
+ alpiecode.explain(
516
+ target="src/codeagent/orchestrator.py",
517
+ workdir="."
518
+ )
519
+
520
+ # 4. Run system health diagnostics
521
+ status_code = alpiecode.doctor()
522
+ ```
523
+
524
+ ---
525
+
526
+ ## 📓 Jupyter Notebooks, JupyterLab & Google Colab
527
+
528
+ AlpieCode delivers a first-class developer experience inside Jupyter Notebooks and Google Colab with reactive UI cards and live status badges.
529
+
530
+ ```
531
+ ┌─────────────────────────────────────────────────────────────┐
532
+ │ 🤖 AlpieCode Agent [RUNNING] │
533
+ │ Task: Train an XGBoost model on iris dataset │
534
+ │ │
535
+ │ ✓ $ python -m pip install xgboost scikit-learn │
536
+ │ ✓ write_file train.py │
537
+ │ ✓ $ python train.py │
538
+ │ │
539
+ │ ✨ Code block automatically populated in next cell. │
540
+ │ Hit Shift+Enter to run. │
541
+ └─────────────────────────────────────────────────────────────┘
542
+ ```
543
+
544
+ ### 1. Setup in Colab or Jupyter
545
+ In any notebook cell:
546
+ ```python
547
+ # Install AlpieCode (in Colab)
548
+ !pip install alpiecode
549
+
550
+ # Load the IPython magic extension
551
+ %load_ext alpiecode
552
+ ```
553
+
554
+ ---
555
+
556
+ ### 2. Magic Commands
557
+
558
+ #### Single-Line Magic (`%alpie`)
559
+ ```python
560
+ %alpie Create a function to calculate Fibonacci numbers using memoization
561
+ ```
562
+
563
+ #### Multi-Line Cell Magic (`%%alpie`)
564
+ ```python
565
+ %%alpie
566
+ Create an end-to-end data pipeline script data_pipeline.py:
567
+ 1. Load dataset from https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv
568
+ 2. Preprocess features with StandardScaler
569
+ 3. Train an XGBoost classifier with 5-fold cross validation
570
+ 4. Print the mean accuracy and confusion matrix
571
+ ```
572
+
573
+ #### Auto-Insert Code into Next Cell (`--insert` / `--code`)
574
+ Use `--insert` to have AlpieCode **automatically populate the generated code into the very next notebook cell**, ready for you to press **`Shift+Enter`**:
575
+ ```python
576
+ %alpie --insert Build a PyTorch neural network for MNIST digit classification
577
+ ```
578
+
579
+ #### Specialized Notebook Magics:
580
+ ```python
581
+ # Plan without modifying files
582
+ %alpie_plan Build a custom PyTorch dataset loader for audio spectrograms
583
+
584
+ # Explain code or notebook variables
585
+ %alpie_explain model.py
586
+
587
+ # System diagnostic check
588
+ %alpie_doctor
589
+
590
+ # Reset conversation context between notebook sections
591
+ %alpie_reset
592
+ ```
593
+
594
+ ---
595
+
596
+ ## 🛠️ 15 Built-In Autonomous Agent Tools
597
+
598
+ The AlpieCode orchestrator autonomously selects and coordinates 15 specialized tools:
599
+
600
+ | # | Tool Name | Category | Description | Key Inputs |
601
+ | :-: | :--- | :--- | :--- | :--- |
602
+ | **1** | `write_file` | File System | Creates new files or completely overwrites existing files safely. | `path`, `content` |
603
+ | **2** | `edit_file` | File System | Replaces specific text blocks with surgical whitespace matching. | `path`, `old_str`, `new_str` |
604
+ | **3** | `read_file` | File System | Reads entire files or specific line ranges (`start_line`, `end_line`). | `path`, `start_line`, `end_line` |
605
+ | **4** | `apply_patch` | File System | Applies standard unified diff format patches. | `patch` |
606
+ | **5** | `bash` | Execution | Runs shell commands inside an isolated sandbox with safety gates. | `command`, `timeout` |
607
+ | **6** | `list_files` | Discovery | Recursively lists repository files with pattern matching & pruning. | `path`, `pattern`, `max_depth` |
608
+ | **7** | `file_search` | Discovery | High-speed ripgrep regex search across codebase contents. | `query`, `path`, `include` |
609
+ | **8** | `view_image` | Vision | Inspects and analyzes images, UI mockups, and screenshots. | `path` |
610
+ | **9** | `fetch_url` | Research | Fetches and extracts clean documentation and web pages. | `url` |
611
+ | **10**| `web_search` | Research | Queries DuckDuckGo for live API documentation and references. | `query`, `max_results` |
612
+ | **11**| `clone_repo` | Repository | Clones open-source repositories for local reference. | `repo_url`, `destination` |
613
+ | **12**| `update_plan` | Planning | Updates structured milestone checklists (`[x]` / `[ ]`). | `plan` |
614
+ | **13**| `extract_memories`| Memory | Extracts and persists project patterns and build commands. | `memories` |
615
+ | **14**| `compact_context` | Optimization| Compresses conversation history to prevent context overflow. | `summary` |
616
+ | **15**| `diagnostics` | Intelligence | Queries compiler and linter diagnostics for active files. | `path` |
617
+
618
+ ---
619
+
620
+ ## 🛡️ Safety Guardian, Git Checkpoints & Memory System
621
+
622
+ ### 1. Safety Guardian Gate (`src/codeagent/guardian.py`)
623
+ - **Destructive Command Blocking**: Intercepts and blocks commands like `rm -rf /`, `mkfs`, raw disk partitioning, fork bombs, and system-level modifications.
624
+ - **Sandbox Boundary Enforcement**: Prohibits writes outside the active project root directory (`workdir`).
625
+ - **Rate-Limited Auto-Fix Loops**: Automatically stops recursive error-fixing loops after **3 attempts** to prevent token waste and infinite loops.
626
+
627
+ ### 2. Git Checkpointing & Undo (`src/codeagent/git_ops.py`)
628
+ - **Automatic Checkpoints**: AlpieCode automatically creates temporary git checkpoints before executing tasks and after each multi-turn step.
629
+ - **One-Click Rollback**: Run `alpiecode undo` or reject a proposed plan in VS Code to restore your workspace to its exact prior state.
630
+
631
+ ### 3. Persistent Cross-Session Memory (`src/codeagent/memory.py`)
632
+ - Automatically captures project architecture patterns, build scripts, test conventions, and known quirks.
633
+ - Persisted locally in `~/.alpiecode/memories/` and injected into future sessions so the agent never asks the same question twice.
634
+
635
+ ### 4. Cross-Platform WSL2 Path Normalization
636
+ - Automatically translates Windows UNC paths (`\\wsl.localhost\...` and `\\wsl$\...`) to native Linux paths (`/home/...`) and routes commands through `wsl -d Ubuntu -- bash -c "..."` seamlessly.
637
+
638
+ ---
639
+
640
+ ## ⚙️ Configuration & Environment Variables
641
+
642
+ Configure AlpieCode globally via `alpiecode init` or by exporting environment variables:
643
+
644
+ | Environment Variable | Default Value | Description |
645
+ | :--- | :--- | :--- |
646
+ | `OPENAI_API_BASE` | `https://test.169pi.ai/v1` | URL for the high-throughput 169Pi cloud VLM endpoint. |
647
+ | `OPENAI_API_KEY` | `EMPTY` | API authentication key (if required). |
648
+ | `ALPIECODE_MODEL` | `alpie_9b` | Target model name. |
649
+ | `ALPIECODE_SERVER_URL` | `http://127.0.0.1:7169` | Default URL for backend API server. |
650
+ | `ALPIECODE_N_CTX` | `262144` (Online) / `32768` (Offline) | Maximum context window size in tokens. |
651
+ | `ALPIECODE_TEMPERATURE` | `0.6` (Thinking) / `0.0` (Fast) | Model sampling temperature. |
652
+
653
+ ---
654
+
655
+ ## ❓ FAQ & Troubleshooting
656
+
657
+ #### Q: How does the agent decide when to use Local GGUF vs. the Online API?
658
+ > **A:** AlpieCode always prioritizes the high-throughput **Online Cloud API**. It only switches to the **Local GGUF Engine** if an internet check confirms the system is genuinely offline. Transient server delays or timeouts retry automatically rather than falling back.
659
+
660
+ #### Q: How do I reload the VS Code extension after updating the backend?
661
+ > **A:** In VS Code, press **`Ctrl+Shift+P`** (or **`Cmd+Shift+P`** on macOS) and select **`Developer: Reload Window`**.
662
+
663
+ #### Q: Port 7169 is already in use. How do I change the port?
664
+ > **A:** Start the server with a custom port:
665
+ > ```bash
666
+ > alpiecode serve --port 8080
667
+ > ```
668
+ > Then update the `alpiecode.serverUrl` setting in VS Code:
669
+ > ```json
670
+ > "alpiecode.serverUrl": "http://127.0.0.1:8080"
671
+ > ```
672
+
673
+ #### Q: Can I run AlpieCode completely offline on an airplane or air-gapped machine?
674
+ > **A:** Yes! AlpieCode includes full offline GGUF local model execution. Simply run any CLI command (`alpiecode run "..."`) or start the local server, and it will execute locally using CPU or CUDA hardware acceleration with zero internet access required.
675
+
676
+ ---
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "alpiecode"
7
- version = "9.0.1"
7
+ version = "9.0.2"
8
8
  description = "AlpieCode — Autonomous AI Coding Agent CLI powered by local 169Pi GGUF VLM"
9
9
  requires-python = ">=3.9"
10
10
  dependencies = [
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alpiecode
3
- Version: 9.0.1
3
+ Version: 9.0.2
4
4
  Summary: AlpieCode — Autonomous AI Coding Agent CLI powered by local 169Pi GGUF VLM
5
5
  Requires-Python: >=3.9
6
6
  Requires-Dist: huggingface_hub>=0.20.0
@@ -16,7 +16,7 @@ Supports:
16
16
  from pathlib import Path
17
17
  from typing import Optional, Any, Dict
18
18
 
19
- __version__ = "9.0.1"
19
+ __version__ = "9.0.2"
20
20
 
21
21
  def run(task: str, workdir: str = ".", reasoning_level: str = "thinking", **kwargs):
22
22
  """Run an autonomous coding task programmatically."""
@@ -133,21 +133,40 @@ class OpenAIBackend:
133
133
  return self._client
134
134
 
135
135
  def _get_available_model(self, client: OpenAI) -> str:
136
- """Auto-discover the served model name from /v1/models."""
136
+ """Auto-discover the served model name from /v1/models.
137
+
138
+ Uses a dedicated short-timeout (3s) probe to avoid blocking the agent
139
+ for minutes when the /v1/models endpoint is slow or unavailable.
140
+ Falls back instantly to the configured model name on any failure.
141
+ """
137
142
  if self._resolved_model:
138
143
  return self._resolved_model
139
144
  try:
140
- models_list = client.models.list()
145
+ import httpx
146
+ # Use a dedicated short-timeout client for model discovery only.
147
+ # The shared HTTP client has a 120s read timeout which causes
148
+ # multi-minute hangs when /v1/models is slow or unresponsive.
149
+ probe_client = OpenAI(
150
+ base_url=self._cfg.base_url,
151
+ api_key=self._cfg.api_key or "not-needed",
152
+ http_client=httpx.Client(timeout=httpx.Timeout(3.0, connect=2.0)),
153
+ )
154
+ models_list = probe_client.models.list()
141
155
  if models_list.data:
142
156
  for m in models_list.data:
143
157
  if m.id == self._cfg.model or getattr(m, "root", None) == self._cfg.model:
144
158
  self._resolved_model = m.id
159
+ logger.info("Resolved model: %s", self._resolved_model)
145
160
  return self._resolved_model
146
161
  self._resolved_model = models_list.data[0].id
162
+ logger.info("Using first available model: %s", self._resolved_model)
147
163
  return self._resolved_model
148
- except Exception:
149
- pass
150
- return self._cfg.model
164
+ except Exception as e:
165
+ logger.debug("Model discovery failed (%.1fs timeout), using configured model '%s': %s",
166
+ 3.0, self._cfg.model, e)
167
+ # Fast fallback: use the configured model name directly
168
+ self._resolved_model = self._cfg.model
169
+ return self._resolved_model
151
170
 
152
171
  def chat_completion_stream(
153
172
  self,
alpiecode-9.0.1/README.md DELETED
@@ -1,342 +0,0 @@
1
- # ⚡ AlpieCode: The Autonomous AI Coding Agent & Full Developer Platform
2
- > **Powered by 169Pi Alpie Vision-Language-Action Models (Local GGUF & Remote Cloud API)**
3
- > *Seamlessly integrated across VS Code, Command Line (CLI), Python SDK, Jupyter Notebooks, and Google Colab.*
4
-
5
- ---
6
-
7
- ## 📑 Table of Contents
8
- 1. [🌟 Executive Overview](#-executive-overview)
9
- 2. [🏗️ Core Architecture & Hybrid Dual-Engine](#️-core-architecture--hybrid-dual-engine)
10
- 3. [📦 Installation & Getting Started](#-installation--getting-started)
11
- 4. [💻 VS Code Extension Deep-Dive](#-vs-code-extension-deep-dive)
12
- 5. [⌨️ Command-Line Interface (CLI) Guide](#️-command-line-interface-cli-guide)
13
- 6. [📓 Jupyter Notebooks, JupyterLab & Google Colab](#-jupyter-notebooks-jupyterlab--google-colab)
14
- 7. [🛠️ 15 Built-In Agentic Tools](#️-15-built-in-agentic-tools)
15
- 8. [🛡️ Safety Guardian, Virtual Environment & Guardrails](#️-safety-guardian-virtual-environment--guardrails)
16
- 9. [❓ FAQ & Troubleshooting](#-faq--troubleshooting)
17
-
18
- ---
19
-
20
- ## 🌟 Executive Overview
21
-
22
- **AlpieCode** is a full-stack, state-of-the-art autonomous software engineering agent designed to reason, plan, write, test, debug, and explain code across multiple environments.
23
-
24
- ### 🎯 Key Capabilities at a Glance
25
- | Environment | Key Features |
26
- | :--- | :--- |
27
- | **VS Code Extension** | Plan-First Review Cards, Slash Commands (`/`), Reasoning Selector (`High/Med/Low`), Proactive `.venv` Auto-Prompt, Live Token/Speed Meter, Multimodal Screenshot Attachment, Inline Ghost Text (`Tab` to complete), Sandbox Output Cards |
28
- | **Terminal CLI** | `alpiecode serve`, `alpiecode run`, `alpiecode chat`, `alpiecode plan`, `alpiecode explain`, `alpiecode doctor`, `alpiecode diff`, `alpiecode init` |
29
- | **Notebooks & Colab** | `%load_ext alpiecode`, `%alpie <task>`, `%%alpie <multiline>`, `%alpie_plan`, `%alpie_explain`, `%alpie_doctor` |
30
- | **Python SDK** | `import alpiecode; alpiecode.run("...")`, `alpiecode.plan()`, `alpiecode.explain()`, `alpiecode.doctor()` |
31
-
32
- ---
33
-
34
- ## 🏗️ Core Architecture & Hybrid Dual-Engine
35
-
36
- AlpieCode features an intelligent **Hybrid Dual-Engine** routing architecture:
37
-
38
- ```
39
- ┌───────────────────────────┐
40
- │ User Prompt / Task │
41
- └─────────────┬─────────────┘
42
-
43
-
44
- ┌───────────────────────────┐
45
- │ Server Reachability Ping │
46
- └──────┬─────────────┬──────┘
47
- │ │
48
- Online (Port 8000 Up) Offline (No Connection)
49
- │ │
50
- ▼ ▼
51
- ┌─────────────────┐ ┌──────────────────────┐
52
- │ OpenAIBackend │ │ LocalBackend │
53
- │ (Azure VLM API) │ │ (Local GGUF Engine) │
54
- │ 169Pi Remote │ │ 169Pi Offline Model │
55
- └────────┬────────┘ └──────────┬───────────┘
56
- │ │
57
- └───────────┬───────────┘
58
-
59
- ┌───────────────────────┐
60
- │ Agent Orchestrator │
61
- │ • Context Compaction │
62
- │ • Tool Executor │
63
- │ • Memory Extraction │
64
- └───────────┬───────────┘
65
-
66
- SSE Stream Events / Terminal Output
67
- ```
68
-
69
- 1. **Online Cloud VLM API** (`OpenAIBackend`): When connected to the network, queries the high-throughput 169Pi model hosted on cloud infrastructure.
70
- 2. **Local GGUF Offline Engine** (`LocalBackend`): If internet is lost or the remote server is offline, AlpieCode **automatically falls back to local GGUF weights** (`169Pi/Alpie_learn_prototype_GGUF_NEW`) using CPU/GPU CUDA acceleration — zero crashes.
71
-
72
- ---
73
-
74
- ## 📦 Installation & Getting Started
75
-
76
- ### 1. Requirements
77
- - **Python**: `>= 3.9` (Recommended: Python 3.10 – 3.12)
78
- - **Platforms**: Linux (Ubuntu/Debian), Windows (Native & WSL2), macOS (Apple Silicon & Intel)
79
- - **Editor (Optional)**: VS Code / Cursor / VSCodium (for extension support)
80
-
81
- ### 2. Python Package Installation
82
- ```bash
83
- # Option A: Install from local repository (Editable Mode)
84
- git clone https://github.com/169Pi/codeagent-poc.git
85
- cd codeagent-poc
86
- pip install -e .
87
-
88
- # Option B: Install via pre-built Wheel
89
- pip install alpiecode-2.0.7-py3-none-any.whl
90
- ```
91
-
92
- ### 3. Launching the AlpieCode API Server
93
- The API server coordinates between the agent engine and the VS Code extension / SDK:
94
- ```bash
95
- alpiecode serve
96
- ```
97
- *Output:*
98
- ```text
99
- _ _ _ ____ _
100
- / \ | |_ _| | ___ / ___|___ __| | ___
101
- / _ \ | | '_ \ |/ _ \ | / _ \ / _` |/ _ \
102
- / ___ \| | |_) | | __/ |__| (_) | (_| | __/
103
- /_/ \_\_|_.__/|_|\___|\____\___/ \__,_|\___|
104
-
105
- ✅ AlpieCode VS Code extension is installed.
106
- 🚀 Starting AlpieCode Server on http://127.0.0.1:7169
107
- INFO: Uvicorn running on http://127.0.0.1:7169 (Press CTRL+C to quit)
108
- ```
109
-
110
- ---
111
-
112
- ## 💻 VS Code Extension Deep-Dive
113
-
114
- The AlpieCode VS Code extension provides an IDE sidebar pairing modern AI interaction patterns with developer control:
115
-
116
- ### 1. ⚡ Slash Commands Autocomplete (`/`)
117
- Type **`/`** in the chat input area to trigger a floating command palette:
118
- - `📋 /plan <task>` — Generate an architectural plan without making destructive file edits.
119
- - `💡 /explain <file>` — Explain a file, function, or concept step-by-step.
120
- - `🩺 /doctor` — Run full system diagnostic health checks in the chat.
121
- - `🧪 /test` — Automatically generate unit tests and execute verification.
122
- - `🔍 /diff` — Inspect recent changes made by AlpieCode in this session.
123
- - `🗑️ /clear` — Reset and start a fresh chat session.
124
-
125
- ### 2. 🧠 169Pi Reasoning Effort Dropdown Selector (`⌃`)
126
- Situated directly in the bottom options bar:
127
- - ⚖️ **Medium (Default)**: Balanced reasoning depth and generation speed (`temperature: 0.1`).
128
- - 🧠 **High**: Deep chain-of-thought step-by-step reasoning, full context, maximal accuracy (`temperature: 0.2`).
129
- - ⚡ **Low (Fast)**: Direct code generation without reasoning traces (`temperature: 0.0`) for quick edits and one-liners.
130
-
131
- ### 3. 📋 Plan-First Review & Change Approval Workflow
132
- - **New Files**: Written directly to disk, opened in the editor, and auto-executed in the sandbox.
133
- - **Modifying Existing Files**: Displays an interactive **Change Plan Card** in chat with an inline line-by-line diff preview (`-` red / `+` green):
134
- - **`✅ Accept`**: Applies the change, opens the file, and runs verification.
135
- - **`❌ Reject`**: Discards the proposed modification cleanly.
136
- - **`✏️ Edit Request`**: Opens an inline input box to type custom instructions (e.g., *"Use an iterative approach instead of recursion"*).
137
-
138
- ### 4. 🐍 Proactive Virtual Environment (`.venv`) Auto-Detection
139
- When generated Python code imports external packages (`numpy`, `pandas`, `flask`, etc.):
140
- - AlpieCode scans the AST imports before execution.
141
- - If the package is not installed, it pops up:
142
- ```text
143
- 📦 'numpy' is required by matrix_multiplication.py but not installed.
144
- 🐍 No virtual environment found. Create one?
145
-
146
- [Create .venv & Install] [Install Globally] [Skip]
147
- ```
148
- - Selecting **Create .venv & Install** creates `.venv`, installs the package, and executes the script using `.venv/bin/python3`!
149
-
150
- ### 5. 📊 Live Token & Speed Meter
151
- Top-right header displays real-time generation speed and token accumulation:
152
- `🟢 Online API` ── `⚡ 42 tok/s · 📊 1,240 tokens`
153
-
154
- ### 6. 📎 Multimodal Image Attachment
155
- Drag-and-drop screenshots, paste from clipboard (`Ctrl+V`), or click **`📎 Image`** to send mockups, diagrams, and error screenshots to the VLM.
156
-
157
- ### 7. 👻 Inline Ghost Text Code Completions
158
- As you type in any code editor, AlpieCode streams gray inline suggestions ahead of your cursor (press **`Tab`** to accept).
159
-
160
- ---
161
-
162
- ## ⌨️ Command-Line Interface (CLI) Guide
163
-
164
- AlpieCode offers a complete suite of standalone terminal commands:
165
-
166
- ### `alpiecode run "<task>"`
167
- Runs an autonomous coding task in the current repository:
168
- ```bash
169
- alpiecode run "Create a FastAPI service with SQLite database and CRUD endpoints"
170
- ```
171
-
172
- ### `alpiecode chat`
173
- Starts an interactive terminal chat REPL with multi-turn conversation memory:
174
- ```bash
175
- alpiecode chat
176
- ```
177
-
178
- ### `alpiecode plan "<task>"`
179
- Generates a structured implementation plan without making any file edits:
180
- ```bash
181
- alpiecode plan "Refactor authentication layer to use OAuth2 and JWT tokens"
182
- ```
183
-
184
- ### `alpiecode explain "<target>"`
185
- Explains any file, class, function, or concept:
186
- ```bash
187
- # Explain a local file:
188
- alpiecode explain src/codeagent/orchestrator.py
189
-
190
- # Explain a concept:
191
- alpiecode explain "How does the tool calling loop work in AlpieCode?"
192
- ```
193
-
194
- ### `alpiecode doctor`
195
- Runs an instant system health and environment diagnostic:
196
- ```bash
197
- alpiecode doctor
198
- ```
199
- *Checks:*
200
- - Python version & Virtual Environment status
201
- - CUDA / GPU hardware acceleration
202
- - General Internet connectivity (8.8.8.8) & Remote VLM latency (ms)
203
- - Compilers & runtimes (`gcc`, `g++`, `git`, `node`, `java`, etc.)
204
- - VS Code extension installation status
205
-
206
- ### `alpiecode diff`
207
- Shows all code modifications made by AlpieCode since the last git checkpoint:
208
- ```bash
209
- alpiecode diff
210
- ```
211
-
212
- ### `alpiecode init`
213
- Interactively configures custom model endpoints, API keys, and context parameters:
214
- ```bash
215
- alpiecode init
216
- ```
217
-
218
- ---
219
-
220
- ## 📓 Jupyter Notebooks, JupyterLab & Google Colab
221
-
222
- ### 1. 🪄 IPython Magic Commands
223
-
224
- Load AlpieCode in any Jupyter / Colab cell:
225
- ```python
226
- %load_ext alpiecode
227
- ```
228
-
229
- #### Line Magic (`%alpie`)
230
- ```python
231
- %alpie create a python function to compute moving averages on a pandas Series
232
- ```
233
-
234
- #### Cell Magic (`%%alpie`)
235
- ```python
236
- %%alpie
237
- Create a script train_model.py that:
238
- 1. Loads dataset from data.csv
239
- 2. Preprocesses numerical and categorical columns with ColumnTransformer
240
- 3. Trains an XGBoost classifier and evaluates with ROC-AUC score
241
- 4. Saves the model with joblib
242
- ```
243
-
244
- #### Specialized Notebook Magics:
245
- ```python
246
- %alpie_plan Build a custom PyTorch dataset loader for audio spectrograms
247
- %alpie_explain model.py
248
- %alpie_doctor
249
- ```
250
-
251
- ---
252
-
253
- ### 2. 🐍 Python SDK API (Programmatic Usage)
254
-
255
- ```python
256
- import alpiecode
257
-
258
- # 1. Execute task
259
- alpiecode.run("Create a benchmark script comparing numpy vs cupy matrix multiplication")
260
-
261
- # 2. Plan a project
262
- alpiecode.plan("Implement a Redis caching layer for API responses")
263
-
264
- # 3. Explain code
265
- alpiecode.explain("src/codeagent/tools.py")
266
-
267
- # 4. System health check
268
- alpiecode.doctor()
269
- ```
270
-
271
- ---
272
-
273
- ### 3. ☁️ Google Colab Setup Guide
274
-
275
- In Google Colab:
276
- ```python
277
- # Cell 1: Install AlpieCode wheel
278
- !pip install alpiecode
279
-
280
- # Cell 2: Load Extension
281
- %load_ext alpiecode
282
-
283
- # Cell 3: Execute Task
284
- %alpie build a random forest regressor on housing data and display metrics
285
- ```
286
-
287
- ---
288
-
289
- ## 🛠️ 15 Built-In Agentic Tools
290
-
291
- The AlpieCode agent autonomously orchestrates **15 specialized tools**:
292
-
293
- | Tool Name | Category | Purpose |
294
- | :--- | :--- | :--- |
295
- | `write_file` | File System | Creates new files or overwrites existing files safely |
296
- | `edit_file` | File System | Precise replacement of target text blocks with exact whitespace matching |
297
- | `read_file` | File System | Reads complete files or specific line ranges (`start_line`, `end_line`) |
298
- | `apply_patch` | File System | Applies standard unified diff format patches |
299
- | `bash` | System Execution | Runs shell commands with environment isolation & guardian safety gate |
300
- | `list_files` | Workspace Discovery | Recursive directory listing with pattern filtering |
301
- | `file_search` | Workspace Discovery | Ripgrep regex search across the entire codebase |
302
- | `view_image` | Multimodal Vision | Inspects and analyzes image files and UI screenshots |
303
- | `fetch_url` | Web & Research | Fetches live documentation and web pages |
304
- | `web_search` | Web & Research | Searches technical references and API docs online |
305
- | `clone_repo` | Repository | Clones public git repositories into workspace for reference |
306
- | `update_plan` | Agent Planning | Updates structured implementation plan checkpoints (`[x]` / `[ ]`) |
307
- | `extract_memories` | Memory | Saves long-term user preferences and project patterns |
308
- | `compact_context` | Optimization | Compresses multi-turn conversation context to prevent token overflows |
309
- | `diagnostics` | Code Intelligence | Inspects compiler and linter diagnostics |
310
-
311
- ---
312
-
313
- ## 🛡️ Safety Guardian, Virtual Environment & Guardrails
314
-
315
- 1. **Safety Guardian Gate** (`src/codeagent/guardian.py`):
316
- - Blocks destructive shell commands (e.g. `rm -rf /`, `mkfs`, raw disk writes).
317
- - Enforces execution inside the designated project root directory (`workdir`).
318
- 2. **Auto-Fix Loop Rate Limiting**:
319
- - Caps automated error retry loops at **3 attempts max** to prevent infinite error-fix cycles.
320
- - Prompts the user with actionable diagnostics if errors persist.
321
- 3. **Cross-Platform WSL & Shell Normalization**:
322
- - Automatically detects Windows UNC paths (`\\wsl.localhost\...` / `\\wsl$\...`) and routes commands through `wsl -e bash -c`.
323
- - Native execution on PowerShell, macOS (zsh), and Linux (bash).
324
- 4. **Context Window Compaction**:
325
- - Compresses long multi-turn sessions into concise summaries when context approaches token limits.
326
-
327
- ---
328
-
329
- ## ❓ FAQ & Troubleshooting
330
-
331
- #### Q: The extension shows "Local GGUF" even though I am connected to the internet. Why?
332
- > **A:** AlpieCode checks reachability of the specific remote model API (`https://test.169pi.ai/v1`). If the remote endpoint is unreachable, it automatically switches to **Local GGUF** so you can continue coding without interruption. Run `alpiecode doctor` to verify.
333
-
334
- #### Q: How do I test the extension after updates?
335
- > **A:** In VS Code, press **`Ctrl+Shift+P`** → select **`Developer: Reload Window`**.
336
-
337
- #### Q: Can I use AlpieCode offline without internet?
338
- > **A:** Yes! AlpieCode includes full offline GGUF inference (`169Pi/Alpie_learn_prototype_GGUF_NEW`) with local tool execution.
339
-
340
- ---
341
-
342
- *Generated by AlpieCode AI Platform — Version 2.0.7 / Extension v0.8.5*
File without changes
File without changes
File without changes
File without changes