alpiecode 10.7.5__tar.gz → 10.8.1__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-10.7.5 → alpiecode-10.8.1}/PKG-INFO +1 -1
- {alpiecode-10.7.5 → alpiecode-10.8.1}/pyproject.toml +1 -1
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/alpiecode.egg-info/PKG-INFO +1 -1
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/alpiecode.egg-info/SOURCES.txt +7 -1
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/__init__.py +1 -1
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/agent.py +21 -0
- alpiecode-10.8.1/src/codeagent/blueprints.py +243 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/cli.py +26 -2
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/compaction.py +9 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/context.py +57 -12
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/discovery.py +42 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/guardrails.py +118 -60
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/memory.py +166 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/orchestrator.py +98 -37
- alpiecode-10.8.1/src/codeagent/project_template.py +538 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/prompt.py +82 -7
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/slash.py +29 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/subagent.py +99 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/system1.py +42 -12
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/tools.py +157 -5
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/verifier.py +138 -0
- alpiecode-10.8.1/src/codeagent/walkthrough.py +295 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/test/test_non_thinking_and_local_stream.py +3 -3
- alpiecode-10.8.1/test/test_project_templates.py +181 -0
- alpiecode-10.8.1/test/test_walkthrough.py +130 -0
- alpiecode-10.8.1/test/test_web_resilience_and_guardrails.py +335 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/README.md +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/setup.cfg +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/alpiecode/__init__.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/alpiecode.egg-info/dependency_links.txt +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/alpiecode.egg-info/entry_points.txt +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/alpiecode.egg-info/requires.txt +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/alpiecode.egg-info/top_level.txt +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/assessment.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/backends/__init__.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/backends/base.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/backends/local_backend.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/backends/openai_backend.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/cache.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/client.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/config.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/diff_preview.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/doctor.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/dream_rsi.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/executor.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/extension/alpiecode.vsix +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/git_ops.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/github.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/guardian.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/ipython_ext.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/local_model.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/media.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/metrics.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/paths.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/progress.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/rephraser.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/server.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/session.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/updater.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/src/codeagent/vscode_installer.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/test/test_adaptive_resilience.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/test/test_cli_ui.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/test/test_context_and_trajectory.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/test/test_dream_rsi.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/test/test_local_model_download.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/test/test_slash_and_diff.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/test/test_subagents.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/test/test_task_assessment.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.1}/test/test_verifier.py +0 -0
|
@@ -10,6 +10,7 @@ src/alpiecode.egg-info/top_level.txt
|
|
|
10
10
|
src/codeagent/__init__.py
|
|
11
11
|
src/codeagent/agent.py
|
|
12
12
|
src/codeagent/assessment.py
|
|
13
|
+
src/codeagent/blueprints.py
|
|
13
14
|
src/codeagent/cache.py
|
|
14
15
|
src/codeagent/cli.py
|
|
15
16
|
src/codeagent/client.py
|
|
@@ -33,6 +34,7 @@ src/codeagent/metrics.py
|
|
|
33
34
|
src/codeagent/orchestrator.py
|
|
34
35
|
src/codeagent/paths.py
|
|
35
36
|
src/codeagent/progress.py
|
|
37
|
+
src/codeagent/project_template.py
|
|
36
38
|
src/codeagent/prompt.py
|
|
37
39
|
src/codeagent/rephraser.py
|
|
38
40
|
src/codeagent/server.py
|
|
@@ -44,6 +46,7 @@ src/codeagent/tools.py
|
|
|
44
46
|
src/codeagent/updater.py
|
|
45
47
|
src/codeagent/verifier.py
|
|
46
48
|
src/codeagent/vscode_installer.py
|
|
49
|
+
src/codeagent/walkthrough.py
|
|
47
50
|
src/codeagent/backends/__init__.py
|
|
48
51
|
src/codeagent/backends/base.py
|
|
49
52
|
src/codeagent/backends/local_backend.py
|
|
@@ -55,7 +58,10 @@ test/test_context_and_trajectory.py
|
|
|
55
58
|
test/test_dream_rsi.py
|
|
56
59
|
test/test_local_model_download.py
|
|
57
60
|
test/test_non_thinking_and_local_stream.py
|
|
61
|
+
test/test_project_templates.py
|
|
58
62
|
test/test_slash_and_diff.py
|
|
59
63
|
test/test_subagents.py
|
|
60
64
|
test/test_task_assessment.py
|
|
61
|
-
test/test_verifier.py
|
|
65
|
+
test/test_verifier.py
|
|
66
|
+
test/test_walkthrough.py
|
|
67
|
+
test/test_web_resilience_and_guardrails.py
|
|
@@ -17,7 +17,7 @@ Supports:
|
|
|
17
17
|
from pathlib import Path
|
|
18
18
|
from typing import Optional, Any, Dict
|
|
19
19
|
|
|
20
|
-
__version__ = "10.
|
|
20
|
+
__version__ = "10.8.1"
|
|
21
21
|
|
|
22
22
|
def run(task: str, workdir: str = ".", reasoning_level: str = "thinking", **kwargs):
|
|
23
23
|
"""Run an autonomous coding task programmatically."""
|
|
@@ -689,6 +689,27 @@ def run_agent(
|
|
|
689
689
|
else:
|
|
690
690
|
print(f"\n🛑 Safety ceiling ({event.data['ceiling']}) reached.")
|
|
691
691
|
|
|
692
|
+
elif event.type == "web_preview" and verbose:
|
|
693
|
+
status_spinner.stop()
|
|
694
|
+
wp_data = event.data
|
|
695
|
+
if HAS_RICH:
|
|
696
|
+
console.print(Panel(
|
|
697
|
+
f"[bold green]🌐 Web Application Ready to View[/bold green]\n\n"
|
|
698
|
+
f"• [bold cyan]Direct Browser Link:[/bold cyan] [underline]{wp_data.get('file_url')}[/underline]\n"
|
|
699
|
+
f"• [bold cyan]Local Dev Server:[/bold cyan] [yellow]{wp_data.get('server_cmd')}[/yellow]\n"
|
|
700
|
+
f"• [bold cyan]Localhost URL:[/bold cyan] [underline]{wp_data.get('localhost_url')}[/underline]",
|
|
701
|
+
title="🚀 Localhost Launch Panel",
|
|
702
|
+
border_style="green",
|
|
703
|
+
padding=(0, 1),
|
|
704
|
+
))
|
|
705
|
+
else:
|
|
706
|
+
print(
|
|
707
|
+
f"\n🌐 Web Application Ready to View:\n"
|
|
708
|
+
f" Direct Link: {wp_data.get('file_url')}\n"
|
|
709
|
+
f" Dev Server: {wp_data.get('server_cmd')}\n"
|
|
710
|
+
f" Localhost: {wp_data.get('localhost_url')}\n"
|
|
711
|
+
)
|
|
712
|
+
|
|
692
713
|
elif event.type == "done":
|
|
693
714
|
status_spinner.stop()
|
|
694
715
|
if not event.data.get("success", True):
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Pre-Flight Domain Blueprint Engine for AlpieCode.
|
|
3
|
+
|
|
4
|
+
Binds concrete, unambiguous engineering blueprints to user tasks:
|
|
5
|
+
- WEB_APP : Browser-first HTML5, CSS Grid/Flexbox, Vanilla JS, python3 http.server
|
|
6
|
+
- CLI_SCRIPT : Self-contained, standard library, argparse, zero bloat
|
|
7
|
+
- REST_API : FastAPI / Flask with in-process TestClient verification
|
|
8
|
+
- NATIVE_CPP : POSIX sockets/HTTP UI, const-correct mutexes, standard algorithms
|
|
9
|
+
- GAME : Complete loop, collision, input, rendering, game over/restart
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from dataclasses import dataclass, field
|
|
13
|
+
from enum import Enum
|
|
14
|
+
from typing import Dict, List, Optional
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class BlueprintType(str, Enum):
|
|
18
|
+
WEB_APP = "web_app"
|
|
19
|
+
CLI_SCRIPT = "cli_script"
|
|
20
|
+
REST_API = "rest_api"
|
|
21
|
+
NATIVE_CPP = "native_cpp"
|
|
22
|
+
GAME = "game"
|
|
23
|
+
AI_ML = "ai_ml"
|
|
24
|
+
AGENT_SYNTHESIZER = "agent_synthesizer"
|
|
25
|
+
GENERAL = "general"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass
|
|
29
|
+
class DomainBlueprint:
|
|
30
|
+
name: str
|
|
31
|
+
blueprint_type: BlueprintType
|
|
32
|
+
target_files: List[str]
|
|
33
|
+
entry_point: str
|
|
34
|
+
execution_runner: str
|
|
35
|
+
prohibitions: List[str] = field(default_factory=list)
|
|
36
|
+
architecture_rules: List[str] = field(default_factory=list)
|
|
37
|
+
|
|
38
|
+
def render_contract(self) -> str:
|
|
39
|
+
"""Render strict execution contract markdown for prompt injection."""
|
|
40
|
+
files_str = ", ".join(f"`{f}`" for f in self.target_files) if self.target_files else "Application files"
|
|
41
|
+
prohib_md = "\n".join(f"- ⛔ {p}" for p in self.prohibitions)
|
|
42
|
+
rules_md = "\n".join(f"- ✅ {r}" for r in self.architecture_rules)
|
|
43
|
+
|
|
44
|
+
return f"""## Pre-Flight Domain Blueprint: {self.name.upper()}
|
|
45
|
+
- **Primary Deliverables**: {files_str}
|
|
46
|
+
- **Entry Point**: `{self.entry_point}`
|
|
47
|
+
- **Execution / Runner**: `{self.execution_runner}`
|
|
48
|
+
|
|
49
|
+
### Architecture Rules
|
|
50
|
+
{rules_md}
|
|
51
|
+
|
|
52
|
+
### Strict Prohibitions
|
|
53
|
+
{prohib_md}
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# ── Specialized Domain Blueprint Definitions ───────────────────────────
|
|
58
|
+
|
|
59
|
+
def get_web_app_blueprint(task: str) -> DomainBlueprint:
|
|
60
|
+
return DomainBlueprint(
|
|
61
|
+
name="Browser-First Web Application",
|
|
62
|
+
blueprint_type=BlueprintType.WEB_APP,
|
|
63
|
+
target_files=["index.html", "styles.css", "app.js"],
|
|
64
|
+
entry_point="index.html",
|
|
65
|
+
execution_runner="python3 -m http.server 8000 (view at http://localhost:8000)",
|
|
66
|
+
architecture_rules=[
|
|
67
|
+
"Write `index.html` FIRST with rich static-first markup: Pre-render headers, hero, navigation, card containers, and modal structure in HTML. NEVER leave an empty body or empty `<div id='app'>`.",
|
|
68
|
+
"Include an on-screen Error Boundary in `index.html` via `window.addEventListener('error', ...)` to display any JavaScript exceptions visually instead of a blank white screen.",
|
|
69
|
+
"Write `styles.css` SECOND: Modern responsive styling (CSS Grid/Flexbox, clean typography, badge counters, glassmorphism, card hover lift).",
|
|
70
|
+
"Write `app.js` THIRD: Universal vanilla JavaScript in an IIFE `(function() { 'use strict'; ... })();`. Every ID queried (`document.getElementById`) MUST match an `id` present in `index.html`.",
|
|
71
|
+
"Use `download_asset` or curated Unsplash CDN URLs / inline SVGs for all imagery to ensure 100% working images without 404 broken icons.",
|
|
72
|
+
"Write EXACTLY ONE complete file per turn in order (Turn 1: index.html, Turn 2: styles.css, Turn 3: app.js).",
|
|
73
|
+
"Verify all files exist and validate JavaScript with `node --check app.js` before completing.",
|
|
74
|
+
],
|
|
75
|
+
prohibitions=[
|
|
76
|
+
"NEVER generate an empty `<div id='app'></div>` without pre-rendered static HTML fallback markup (prevents blank white screens).",
|
|
77
|
+
"NEVER use ES module `import`/`export` in browser scripts without a bundler -- use self-executing functions so it works on both `file://` and `http://localhost`.",
|
|
78
|
+
"NEVER write standalone `.jsx` files without a build tool like Vite -- Node cannot execute raw JSX.",
|
|
79
|
+
"NEVER write utility files like `utils/formatPrice.js` before `index.html` exists.",
|
|
80
|
+
"NEVER start blocking daemon servers with `&` or real `sleep` in terminal commands.",
|
|
81
|
+
],
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def get_cli_script_blueprint(task: str) -> DomainBlueprint:
|
|
86
|
+
return DomainBlueprint(
|
|
87
|
+
name="Self-Contained CLI / Utility",
|
|
88
|
+
blueprint_type=BlueprintType.CLI_SCRIPT,
|
|
89
|
+
target_files=["main.py"],
|
|
90
|
+
entry_point="main.py",
|
|
91
|
+
execution_runner="python3 main.py",
|
|
92
|
+
architecture_rules=[
|
|
93
|
+
"Implement complete, working logic in Turn 1 with zero stubs or placeholders.",
|
|
94
|
+
"Use standard library `argparse` for flexible command-line argument parsing.",
|
|
95
|
+
"Handle edge cases and invalid inputs gracefully with clear error messages.",
|
|
96
|
+
"Verify by running `python3 main.py` or writing a quick hermetic unit test.",
|
|
97
|
+
],
|
|
98
|
+
prohibitions=[
|
|
99
|
+
"NEVER split simple utility scripts across multiple unnecessary files.",
|
|
100
|
+
"NEVER leave placeholder functions (`pass` or `...`). Implement real working code.",
|
|
101
|
+
],
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def get_rest_api_blueprint(task: str) -> DomainBlueprint:
|
|
106
|
+
return DomainBlueprint(
|
|
107
|
+
name="REST API Service",
|
|
108
|
+
blueprint_type=BlueprintType.REST_API,
|
|
109
|
+
target_files=["app.py", "test_app.py"],
|
|
110
|
+
entry_point="app.py",
|
|
111
|
+
execution_runner="pytest test_app.py",
|
|
112
|
+
architecture_rules=[
|
|
113
|
+
"Define modular endpoints with input validation, proper HTTP status codes, and JSON responses.",
|
|
114
|
+
"ALWAYS test endpoints using in-process test clients (`TestClient(app)` for FastAPI or `app.test_client()` for Flask).",
|
|
115
|
+
"Verify with `pytest` in under 0.1 seconds.",
|
|
116
|
+
],
|
|
117
|
+
prohibitions=[
|
|
118
|
+
"NEVER start background servers with `uvicorn &` or `flask run &` and curl -- use TestClient.",
|
|
119
|
+
"NEVER leave unhandled exceptions in request routes.",
|
|
120
|
+
],
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def get_native_cpp_blueprint(task: str) -> DomainBlueprint:
|
|
125
|
+
return DomainBlueprint(
|
|
126
|
+
name="Native C/C++ System",
|
|
127
|
+
blueprint_type=BlueprintType.NATIVE_CPP,
|
|
128
|
+
target_files=["main.cpp"],
|
|
129
|
+
entry_point="main.cpp",
|
|
130
|
+
execution_runner="g++ -std=c++17 -O2 -o app main.cpp && ./app",
|
|
131
|
+
architecture_rules=[
|
|
132
|
+
"Always include required standard headers: `<algorithm>`, `<memory>`, `<mutex>`, `<thread>`.",
|
|
133
|
+
"Mutexes locked in `const` methods MUST be declared `mutable std::mutex mtx;`.",
|
|
134
|
+
"Never use the same identifier for member variables and accessor functions (e.g. `m_isPaused` vs `isPaused()`).",
|
|
135
|
+
"If the user asked for a website in C++, serve an HTML5/Canvas UI from a C++ HTTP server, never an ASCII terminal app.",
|
|
136
|
+
"Verify compilation with `g++ -std=c++17 -O2` with exit code 0.",
|
|
137
|
+
],
|
|
138
|
+
prohibitions=[
|
|
139
|
+
"NEVER claim completion if compilation fails with exit code != 0.",
|
|
140
|
+
"NEVER access private class members from helper functions without accessors.",
|
|
141
|
+
],
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def get_game_blueprint(task: str) -> DomainBlueprint:
|
|
146
|
+
return DomainBlueprint(
|
|
147
|
+
name="Interactive 60FPS Game",
|
|
148
|
+
blueprint_type=BlueprintType.GAME,
|
|
149
|
+
target_files=["index.html", "game.js", "styles.css"],
|
|
150
|
+
entry_point="index.html",
|
|
151
|
+
execution_runner="python3 -m http.server 8000",
|
|
152
|
+
architecture_rules=[
|
|
153
|
+
"Implement a fixed-timestep 60 FPS game loop (`requestAnimationFrame(loop)` with delta `dt`) using HTML5 2D Canvas.",
|
|
154
|
+
"Include complete game state management (`TITLE`, `PLAYING`, `PAUSED`, `GAMEOVER`) with score and high-score persisted in `localStorage`.",
|
|
155
|
+
"Synthesize retro sound effects with the Web Audio API (`AudioContext` oscillator for jumps, points, and game-over) with ZERO external audio file dependencies.",
|
|
156
|
+
"Add dual input support: keyboard listeners (Arrow keys / WASD / Space) and responsive on-screen touch/mouse buttons for mobile.",
|
|
157
|
+
"Deliver 100% complete, working game physics (AABB / circle collision) with zero stubs.",
|
|
158
|
+
],
|
|
159
|
+
prohibitions=[
|
|
160
|
+
"NEVER deliver a game with missing collision or non-functional controls.",
|
|
161
|
+
"NEVER link external audio files (.mp3/.wav) that do not exist on disk -- use Web Audio API.",
|
|
162
|
+
],
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def get_ai_ml_blueprint(task: str) -> DomainBlueprint:
|
|
167
|
+
return DomainBlueprint(
|
|
168
|
+
name="AI / ML Pipeline",
|
|
169
|
+
blueprint_type=BlueprintType.AI_ML,
|
|
170
|
+
target_files=["model.py", "train.py", "test_model.py"],
|
|
171
|
+
entry_point="test_model.py",
|
|
172
|
+
execution_runner="pytest test_model.py",
|
|
173
|
+
architecture_rules=[
|
|
174
|
+
"Provide automatic synthetic dataset generation (`numpy` / `pandas` / `sklearn.datasets`) if no external dataset is present.",
|
|
175
|
+
"Structure clean separation of concerns: `model.py` (architecture / estimator), `train.py` (training loop and metrics), and `test_model.py` (unit tests).",
|
|
176
|
+
"Track and log key evaluation metrics: Loss, Accuracy, F1-Score, or Mean Squared Error.",
|
|
177
|
+
"Ensure the test suite runs a fast 1-epoch / 10-sample verification pass in under 2.0 seconds.",
|
|
178
|
+
],
|
|
179
|
+
prohibitions=[
|
|
180
|
+
"NEVER hardcode dependency on unavailable massive remote datasets without a local synthetic fallback.",
|
|
181
|
+
"NEVER block the test suite with 100+ training epochs -- keep test execution sub-second.",
|
|
182
|
+
],
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def get_agent_synthesizer_blueprint(task: str) -> DomainBlueprint:
|
|
187
|
+
return DomainBlueprint(
|
|
188
|
+
name="Autonomous Agent System",
|
|
189
|
+
blueprint_type=BlueprintType.AGENT_SYNTHESIZER,
|
|
190
|
+
target_files=["agent.py", "tools.py", "test_agent.py", "AGENTS.md"],
|
|
191
|
+
entry_point="test_agent.py",
|
|
192
|
+
execution_runner="pytest test_agent.py",
|
|
193
|
+
architecture_rules=[
|
|
194
|
+
"Implement a clean, deterministic turn-based execution while-loop with stop conditions and safety ceilings.",
|
|
195
|
+
"Define explicit tool schemas and safe execution dispatch functions with input validation.",
|
|
196
|
+
"Include persistent project memory (`AGENTS.md`) documenting agent behaviors, tool contracts, and rules.",
|
|
197
|
+
"Deliver comprehensive unit tests in `test_agent.py` verifying tool invocation, loop execution, and error handling.",
|
|
198
|
+
],
|
|
199
|
+
prohibitions=[
|
|
200
|
+
"NEVER leave infinite loops without turn limits or cancel tokens.",
|
|
201
|
+
"NEVER allow unhandled tool exceptions to crash the agent master loop.",
|
|
202
|
+
],
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
# ── Blueprint Router ───────────────────────────────────────────────────
|
|
207
|
+
|
|
208
|
+
def resolve_domain_blueprint(task: str, repo: Optional[Dict] = None, intent: str = "create") -> Optional[DomainBlueprint]:
|
|
209
|
+
"""
|
|
210
|
+
Route task intent to the optimal Domain Blueprint.
|
|
211
|
+
Runs deterministically in < 1ms.
|
|
212
|
+
"""
|
|
213
|
+
task_lower = task.lower().strip()
|
|
214
|
+
|
|
215
|
+
# 1. Autonomous Agent Systems
|
|
216
|
+
if any(kw in task_lower for kw in ("create an agent", "build an agent", "code agent", "multi-agent", "autonomous agent", "agent system", "swarm")):
|
|
217
|
+
return get_agent_synthesizer_blueprint(task)
|
|
218
|
+
|
|
219
|
+
# 2. AI / Machine Learning
|
|
220
|
+
if any(kw in task_lower for kw in ("machine learning", "deep learning", "neural network", "train a model", "classifier", "pytorch", "tensorflow", "scikit-learn", "sklearn")):
|
|
221
|
+
return get_ai_ml_blueprint(task)
|
|
222
|
+
|
|
223
|
+
# 3. C / C++ Tasks
|
|
224
|
+
if any(kw in task_lower for kw in ("c++", "cpp", "g++", "gcc", "clang", "in c", "in c++")):
|
|
225
|
+
return get_native_cpp_blueprint(task)
|
|
226
|
+
|
|
227
|
+
# 4. Interactive Games
|
|
228
|
+
if any(kw in task_lower for kw in ("game", "snake", "pong", "tetris", "arcade", "flappy", "chess", "sudoku")):
|
|
229
|
+
return get_game_blueprint(task)
|
|
230
|
+
|
|
231
|
+
# 5. Web Applications / E-Commerce / Frontend
|
|
232
|
+
if any(kw in task_lower for kw in ("website", "web app", "webapp", "e-commerce", "ecommerce", "store", "dashboard", "frontend", "html", "landing page")):
|
|
233
|
+
return get_web_app_blueprint(task)
|
|
234
|
+
|
|
235
|
+
# 6. REST APIs / Microservices
|
|
236
|
+
if any(kw in task_lower for kw in ("api", "rest api", "fastapi", "flask", "endpoint", "microservice", "crud")):
|
|
237
|
+
return get_rest_api_blueprint(task)
|
|
238
|
+
|
|
239
|
+
# 7. CLI Scripts / Utilities
|
|
240
|
+
if any(kw in task_lower for kw in ("script", "cli", "command-line", "utility", "tool", "parse", "convert", "calculator")):
|
|
241
|
+
return get_cli_script_blueprint(task)
|
|
242
|
+
|
|
243
|
+
return None
|
|
@@ -29,7 +29,7 @@ def _show_banner():
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
def _normalize_args():
|
|
32
|
-
known_commands = {"init", "serve", "run", "chat", "plan", "diff", "undo", "doctor", "explain", "dream", "version", "-h", "--help", "-v", "--version"}
|
|
32
|
+
known_commands = {"init", "scaffold", "serve", "run", "chat", "plan", "diff", "undo", "doctor", "explain", "dream", "version", "-h", "--help", "-v", "--version"}
|
|
33
33
|
subcommand = None
|
|
34
34
|
|
|
35
35
|
# Normalize common flag typos / aliases before parsing
|
|
@@ -121,7 +121,13 @@ def main():
|
|
|
121
121
|
sub.add_parser("version", help="Show current version")
|
|
122
122
|
|
|
123
123
|
# ── init ──
|
|
124
|
-
sub.add_parser("init", help="Configure
|
|
124
|
+
init_p = sub.add_parser("init", help="Configure endpoint or initialize project documentation")
|
|
125
|
+
init_p.add_argument("--project", action="store_true", help="Initialize project documentation and persistent memory")
|
|
126
|
+
init_p.add_argument("--profile", choices=["basic", "standard", "advanced"], default="standard", help="Documentation profile (basic, standard, advanced)")
|
|
127
|
+
|
|
128
|
+
# ── scaffold ──
|
|
129
|
+
scaffold_p = sub.add_parser("scaffold", help="Scaffold project-level documentation, rules, and memory store")
|
|
130
|
+
scaffold_p.add_argument("--profile", choices=["basic", "standard", "advanced"], default="standard", help="Documentation profile (basic, standard, advanced)")
|
|
125
131
|
|
|
126
132
|
# ── serve ──
|
|
127
133
|
serve_p = sub.add_parser("serve", help="Start the AlpieCode API server", parents=[common])
|
|
@@ -168,6 +174,24 @@ def main():
|
|
|
168
174
|
print(f"alpiecode {__version__}")
|
|
169
175
|
return
|
|
170
176
|
|
|
177
|
+
if args.command in ("scaffold",) or (args.command == "init" and getattr(args, "project", False)):
|
|
178
|
+
from .project_template import initialize_project_structure, ProjectProfile, ProjectMetadata
|
|
179
|
+
profile_map = {
|
|
180
|
+
"basic": ProjectProfile.BASIC,
|
|
181
|
+
"standard": ProjectProfile.STANDARD,
|
|
182
|
+
"advanced": ProjectProfile.ADVANCED,
|
|
183
|
+
}
|
|
184
|
+
prof = profile_map.get(getattr(args, "profile", "standard") or "standard", ProjectProfile.STANDARD)
|
|
185
|
+
meta = ProjectMetadata(name=Path.cwd().name or "Project")
|
|
186
|
+
created = initialize_project_structure(Path.cwd(), profile=prof, meta=meta)
|
|
187
|
+
if created:
|
|
188
|
+
print(f"✅ Initialized project documentation ({prof.value.upper()} profile):")
|
|
189
|
+
for f in created:
|
|
190
|
+
print(f" • {f}")
|
|
191
|
+
else:
|
|
192
|
+
print("ℹ️ Project documentation already exists. No files were overwritten.")
|
|
193
|
+
return
|
|
194
|
+
|
|
171
195
|
if args.command == "init":
|
|
172
196
|
interactive_init()
|
|
173
197
|
return
|
|
@@ -61,6 +61,15 @@ def _summarize_tool_result(tool_name: str, content: str) -> str:
|
|
|
61
61
|
if tool_name == "update_plan":
|
|
62
62
|
return content
|
|
63
63
|
|
|
64
|
+
c_lower = content.lower()
|
|
65
|
+
if "error:" in c_lower or "syntax" in c_lower or "failed" in c_lower:
|
|
66
|
+
first_line = content.strip().splitlines()[0][:90]
|
|
67
|
+
return f"[Historical tool result (addressed in subsequent turns): {first_line}]"
|
|
68
|
+
|
|
69
|
+
if tool_name == "write_file" or "wrote " in c_lower or "successfully wrote" in c_lower:
|
|
70
|
+
first_line = content.strip().splitlines()[0][:90]
|
|
71
|
+
return f"[Completed: {first_line}]"
|
|
72
|
+
|
|
64
73
|
if len(content) <= 300:
|
|
65
74
|
return content
|
|
66
75
|
|
|
@@ -223,10 +223,11 @@ class ContextManager:
|
|
|
223
223
|
self._build_metadata_entry(msg, tool_name=tool_name, custom=metadata)
|
|
224
224
|
)
|
|
225
225
|
|
|
226
|
-
def rolling_compact_old_tools(self, keep_last_turns: int =
|
|
226
|
+
def rolling_compact_old_tools(self, keep_last_turns: int = 2) -> None:
|
|
227
227
|
"""
|
|
228
|
-
Truncate large historical tool outputs
|
|
229
|
-
|
|
228
|
+
Truncate large historical tool outputs and bulky assistant payloads
|
|
229
|
+
from turns older than keep_last_turns.
|
|
230
|
+
Preserves update_plan and recent turns intact.
|
|
230
231
|
Note: Operates on working _messages, while _raw_messages / raw_history remains pristine.
|
|
231
232
|
"""
|
|
232
233
|
self.invalidate_cache()
|
|
@@ -240,25 +241,69 @@ class ContextManager:
|
|
|
240
241
|
cutoff_idx = assistant_indices[-keep_last_turns]
|
|
241
242
|
for i in range(cutoff_idx):
|
|
242
243
|
msg = self._messages[i]
|
|
243
|
-
if isinstance(msg, dict)
|
|
244
|
+
if not isinstance(msg, dict):
|
|
245
|
+
continue
|
|
246
|
+
role = msg.get("role")
|
|
247
|
+
if role == "tool":
|
|
244
248
|
content = str(msg.get("content", ""))
|
|
245
249
|
# Never truncate update_plan output
|
|
246
|
-
if "[Plan updated]" in content or "Plan Status:" in content
|
|
250
|
+
if "[Plan updated]" in content or "Plan Status:" in content:
|
|
247
251
|
continue
|
|
252
|
+
|
|
248
253
|
msg = dict(msg)
|
|
249
254
|
self._messages[i] = msg
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
msg["content"] = f"[
|
|
255
|
-
|
|
256
|
-
|
|
255
|
+
|
|
256
|
+
c_lower = content.lower()
|
|
257
|
+
if "error:" in c_lower or "syntax" in c_lower or "failed" in c_lower:
|
|
258
|
+
first_line = content.strip().splitlines()[0][:90]
|
|
259
|
+
msg["content"] = f"[Historical result (addressed in subsequent turns): {first_line}]"
|
|
260
|
+
elif "wrote " in c_lower or "successfully wrote" in c_lower:
|
|
261
|
+
first_line = content.strip().splitlines()[0][:90]
|
|
262
|
+
msg["content"] = f"[Completed: {first_line}]"
|
|
263
|
+
elif "exit_code" in content:
|
|
264
|
+
try:
|
|
265
|
+
import json as _json
|
|
266
|
+
_data = _json.loads(content.split("\n", 1)[-1] if content.startswith("⚠️") else content)
|
|
267
|
+
_code = _data.get("exit_code", 0)
|
|
268
|
+
_out = _data.get("stdout", "").strip()
|
|
269
|
+
_err = _data.get("stderr", "").strip()
|
|
270
|
+
_summary = f"exit_code={_code}"
|
|
271
|
+
if _err:
|
|
272
|
+
_summary += f", err: {_err[:80]}"
|
|
273
|
+
elif _out:
|
|
274
|
+
_summary += f", out: {_out[:80]}"
|
|
275
|
+
msg["content"] = f"[Command result: {_summary}]"
|
|
276
|
+
except Exception:
|
|
277
|
+
msg["content"] = content[:150] + "... [condensed]"
|
|
278
|
+
elif len(content) > 250:
|
|
279
|
+
lines = content.splitlines()
|
|
280
|
+
if len(lines) > 6:
|
|
281
|
+
preview_start = "\n".join(lines[:2])
|
|
282
|
+
preview_end = "\n".join(lines[-2:])
|
|
283
|
+
msg["content"] = f"[Output: {len(lines)} lines truncated for brevity]\n{preview_start}\n...\n{preview_end}"
|
|
284
|
+
else:
|
|
285
|
+
msg["content"] = content[:150] + f"... [truncated {len(content)} chars]"
|
|
286
|
+
|
|
257
287
|
# Update tokens in metadata
|
|
258
288
|
if i < len(self._metadata):
|
|
259
289
|
self._metadata[i] = dict(self._metadata[i])
|
|
260
290
|
self._metadata[i]["tokens"] = self._estimate_single_message_tokens(msg)
|
|
261
291
|
|
|
292
|
+
elif role == "assistant":
|
|
293
|
+
msg = dict(msg)
|
|
294
|
+
self._messages[i] = msg
|
|
295
|
+
if msg.get("tool_calls"):
|
|
296
|
+
msg["tool_calls"] = compact_tool_calls(msg["tool_calls"])
|
|
297
|
+
if msg.get("content"):
|
|
298
|
+
c = compact_text_tool_calls(msg["content"])
|
|
299
|
+
if len(c) > 200:
|
|
300
|
+
msg["content"] = c[:200] + "... [condensed]"
|
|
301
|
+
else:
|
|
302
|
+
msg["content"] = c
|
|
303
|
+
if i < len(self._metadata):
|
|
304
|
+
self._metadata[i] = dict(self._metadata[i])
|
|
305
|
+
self._metadata[i]["tokens"] = self._estimate_single_message_tokens(msg)
|
|
306
|
+
|
|
262
307
|
def build_context(
|
|
263
308
|
self,
|
|
264
309
|
max_tokens: Optional[int] = None,
|
|
@@ -61,6 +61,16 @@ class TaskContext:
|
|
|
61
61
|
enable_thinking: bool = False
|
|
62
62
|
requires_strict_format: bool = False
|
|
63
63
|
|
|
64
|
+
# Project-Level Documentation & Persistent Memory State
|
|
65
|
+
project_profile: str = "standard" # basic, standard, advanced
|
|
66
|
+
has_project_agents_md: bool = False
|
|
67
|
+
project_agents_content: Optional[str] = None
|
|
68
|
+
has_project_session: bool = False
|
|
69
|
+
project_session_data: Optional[Dict[str, Any]] = None
|
|
70
|
+
|
|
71
|
+
# Pre-Flight Domain Blueprint
|
|
72
|
+
blueprint: Optional[Any] = None
|
|
73
|
+
|
|
64
74
|
|
|
65
75
|
# -- Intent Detection ------------------------------------------------------
|
|
66
76
|
|
|
@@ -700,6 +710,30 @@ def build_task_context(task: str, workdir: Path) -> TaskContext:
|
|
|
700
710
|
except Exception:
|
|
701
711
|
pass
|
|
702
712
|
|
|
713
|
+
# Phase 6: Project Documentation & Persistent Memory Scan
|
|
714
|
+
agents_path = Path(workdir) / "AGENTS.md"
|
|
715
|
+
has_agents_md = agents_path.is_file()
|
|
716
|
+
agents_content = None
|
|
717
|
+
if has_agents_md:
|
|
718
|
+
try:
|
|
719
|
+
agents_content = agents_path.read_text(encoding="utf-8")
|
|
720
|
+
except Exception:
|
|
721
|
+
pass
|
|
722
|
+
|
|
723
|
+
from .memory import read_project_session
|
|
724
|
+
session_data = read_project_session(workdir)
|
|
725
|
+
has_session = session_data is not None
|
|
726
|
+
|
|
727
|
+
if complexity in ("high", "extreme") or len(repo.get("frameworks", [])) > 1:
|
|
728
|
+
project_profile = "advanced"
|
|
729
|
+
elif complexity == "low" and repo.get("file_count", 0) <= 2:
|
|
730
|
+
project_profile = "basic"
|
|
731
|
+
else:
|
|
732
|
+
project_profile = "standard"
|
|
733
|
+
|
|
734
|
+
from .blueprints import resolve_domain_blueprint
|
|
735
|
+
blueprint = resolve_domain_blueprint(task, repo, intent)
|
|
736
|
+
|
|
703
737
|
return TaskContext(
|
|
704
738
|
symbol_index=symbol_index,
|
|
705
739
|
# Assessment & Strategy
|
|
@@ -727,4 +761,12 @@ def build_task_context(task: str, workdir: Path) -> TaskContext:
|
|
|
727
761
|
tool_set=budget["tool_set"],
|
|
728
762
|
enable_thinking=enable_thinking,
|
|
729
763
|
requires_strict_format=requires_strict_format,
|
|
764
|
+
# Project Documentation & Persistent Memory State
|
|
765
|
+
project_profile=project_profile,
|
|
766
|
+
has_project_agents_md=has_agents_md,
|
|
767
|
+
project_agents_content=agents_content,
|
|
768
|
+
has_project_session=has_session,
|
|
769
|
+
project_session_data=session_data,
|
|
770
|
+
# Pre-Flight Domain Blueprint
|
|
771
|
+
blueprint=blueprint,
|
|
730
772
|
)
|