alpiecode 10.8.0__tar.gz → 10.8.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.
- {alpiecode-10.8.0 → alpiecode-10.8.2}/PKG-INFO +1 -1
- {alpiecode-10.8.0 → alpiecode-10.8.2}/pyproject.toml +1 -1
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/alpiecode.egg-info/PKG-INFO +1 -1
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/alpiecode.egg-info/SOURCES.txt +0 -1
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/__init__.py +1 -1
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/agent.py +21 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/blueprints.py +69 -13
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/orchestrator.py +9 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/prompt.py +17 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/subagent.py +99 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/tools.py +152 -1
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/verifier.py +138 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/test/test_web_resilience_and_guardrails.py +132 -0
- alpiecode-10.8.0/src/codeagent/extension/alpiecode.vsix +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/README.md +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/setup.cfg +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/alpiecode/__init__.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/alpiecode.egg-info/dependency_links.txt +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/alpiecode.egg-info/entry_points.txt +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/alpiecode.egg-info/requires.txt +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/alpiecode.egg-info/top_level.txt +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/assessment.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/backends/__init__.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/backends/base.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/backends/local_backend.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/backends/openai_backend.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/cache.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/cli.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/client.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/compaction.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/config.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/context.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/diff_preview.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/discovery.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/doctor.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/dream_rsi.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/executor.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/git_ops.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/github.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/guardian.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/guardrails.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/ipython_ext.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/local_model.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/media.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/memory.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/metrics.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/paths.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/progress.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/project_template.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/rephraser.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/server.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/session.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/slash.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/system1.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/updater.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/vscode_installer.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/src/codeagent/walkthrough.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/test/test_adaptive_resilience.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/test/test_cli_ui.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/test/test_context_and_trajectory.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/test/test_dream_rsi.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/test/test_local_model_download.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/test/test_non_thinking_and_local_stream.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/test/test_project_templates.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/test/test_slash_and_diff.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/test/test_subagents.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/test/test_task_assessment.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/test/test_verifier.py +0 -0
- {alpiecode-10.8.0 → alpiecode-10.8.2}/test/test_walkthrough.py +0 -0
|
@@ -51,7 +51,6 @@ src/codeagent/backends/__init__.py
|
|
|
51
51
|
src/codeagent/backends/base.py
|
|
52
52
|
src/codeagent/backends/local_backend.py
|
|
53
53
|
src/codeagent/backends/openai_backend.py
|
|
54
|
-
src/codeagent/extension/alpiecode.vsix
|
|
55
54
|
test/test_adaptive_resilience.py
|
|
56
55
|
test/test_cli_ui.py
|
|
57
56
|
test/test_context_and_trajectory.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.8.
|
|
20
|
+
__version__ = "10.8.2"
|
|
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):
|
|
@@ -20,6 +20,8 @@ class BlueprintType(str, Enum):
|
|
|
20
20
|
REST_API = "rest_api"
|
|
21
21
|
NATIVE_CPP = "native_cpp"
|
|
22
22
|
GAME = "game"
|
|
23
|
+
AI_ML = "ai_ml"
|
|
24
|
+
AGENT_SYNTHESIZER = "agent_synthesizer"
|
|
23
25
|
GENERAL = "general"
|
|
24
26
|
|
|
25
27
|
|
|
@@ -62,13 +64,17 @@ def get_web_app_blueprint(task: str) -> DomainBlueprint:
|
|
|
62
64
|
entry_point="index.html",
|
|
63
65
|
execution_runner="python3 -m http.server 8000 (view at http://localhost:8000)",
|
|
64
66
|
architecture_rules=[
|
|
65
|
-
"Write `index.html` FIRST:
|
|
66
|
-
"
|
|
67
|
-
"Write `
|
|
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.",
|
|
68
72
|
"Write EXACTLY ONE complete file per turn in order (Turn 1: index.html, Turn 2: styles.css, Turn 3: app.js).",
|
|
69
73
|
"Verify all files exist and validate JavaScript with `node --check app.js` before completing.",
|
|
70
74
|
],
|
|
71
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`.",
|
|
72
78
|
"NEVER write standalone `.jsx` files without a build tool like Vite -- Node cannot execute raw JSX.",
|
|
73
79
|
"NEVER write utility files like `utils/formatPrice.js` before `index.html` exists.",
|
|
74
80
|
"NEVER start blocking daemon servers with `&` or real `sleep` in terminal commands.",
|
|
@@ -138,19 +144,61 @@ def get_native_cpp_blueprint(task: str) -> DomainBlueprint:
|
|
|
138
144
|
|
|
139
145
|
def get_game_blueprint(task: str) -> DomainBlueprint:
|
|
140
146
|
return DomainBlueprint(
|
|
141
|
-
name="Interactive Game",
|
|
147
|
+
name="Interactive 60FPS Game",
|
|
142
148
|
blueprint_type=BlueprintType.GAME,
|
|
143
149
|
target_files=["index.html", "game.js", "styles.css"],
|
|
144
150
|
entry_point="index.html",
|
|
145
151
|
execution_runner="python3 -m http.server 8000",
|
|
146
152
|
architecture_rules=[
|
|
147
|
-
"Implement
|
|
148
|
-
"Include
|
|
149
|
-
"
|
|
150
|
-
"
|
|
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.",
|
|
151
158
|
],
|
|
152
159
|
prohibitions=[
|
|
153
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.",
|
|
154
202
|
],
|
|
155
203
|
)
|
|
156
204
|
|
|
@@ -164,23 +212,31 @@ def resolve_domain_blueprint(task: str, repo: Optional[Dict] = None, intent: str
|
|
|
164
212
|
"""
|
|
165
213
|
task_lower = task.lower().strip()
|
|
166
214
|
|
|
167
|
-
# 1.
|
|
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
|
|
168
224
|
if any(kw in task_lower for kw in ("c++", "cpp", "g++", "gcc", "clang", "in c", "in c++")):
|
|
169
225
|
return get_native_cpp_blueprint(task)
|
|
170
226
|
|
|
171
|
-
#
|
|
227
|
+
# 4. Interactive Games
|
|
172
228
|
if any(kw in task_lower for kw in ("game", "snake", "pong", "tetris", "arcade", "flappy", "chess", "sudoku")):
|
|
173
229
|
return get_game_blueprint(task)
|
|
174
230
|
|
|
175
|
-
#
|
|
231
|
+
# 5. Web Applications / E-Commerce / Frontend
|
|
176
232
|
if any(kw in task_lower for kw in ("website", "web app", "webapp", "e-commerce", "ecommerce", "store", "dashboard", "frontend", "html", "landing page")):
|
|
177
233
|
return get_web_app_blueprint(task)
|
|
178
234
|
|
|
179
|
-
#
|
|
235
|
+
# 6. REST APIs / Microservices
|
|
180
236
|
if any(kw in task_lower for kw in ("api", "rest api", "fastapi", "flask", "endpoint", "microservice", "crud")):
|
|
181
237
|
return get_rest_api_blueprint(task)
|
|
182
238
|
|
|
183
|
-
#
|
|
239
|
+
# 7. CLI Scripts / Utilities
|
|
184
240
|
if any(kw in task_lower for kw in ("script", "cli", "command-line", "utility", "tool", "parse", "convert", "calculator")):
|
|
185
241
|
return get_cli_script_blueprint(task)
|
|
186
242
|
|
|
@@ -775,6 +775,15 @@ class AgentOrchestrator:
|
|
|
775
775
|
"commands": session_executed_commands,
|
|
776
776
|
})
|
|
777
777
|
|
|
778
|
+
if any(f.endswith("index.html") or f == "index.html" for f in session_touched_files) or (Path(session.workdir) / "index.html").exists():
|
|
779
|
+
html_p = Path(session.workdir) / "index.html"
|
|
780
|
+
yield AgentEvent("web_preview", {
|
|
781
|
+
"html_path": str(html_p.resolve()),
|
|
782
|
+
"file_url": f"file://{html_p.resolve()}",
|
|
783
|
+
"server_cmd": "python3 -m http.server 8000",
|
|
784
|
+
"localhost_url": "http://localhost:8000",
|
|
785
|
+
})
|
|
786
|
+
|
|
778
787
|
# ── Component 1: Autonomous Verify-Before-Done Gate ──
|
|
779
788
|
has_code_files = any(
|
|
780
789
|
f.endswith((".py", ".js", ".ts", ".jsx", ".tsx", ".rs", ".go", ".java", ".c", ".cpp"))
|
|
@@ -88,6 +88,23 @@ CORE_TOOLS = [
|
|
|
88
88
|
},
|
|
89
89
|
},
|
|
90
90
|
},
|
|
91
|
+
{
|
|
92
|
+
"type": "function",
|
|
93
|
+
"function": {
|
|
94
|
+
"name": "download_asset",
|
|
95
|
+
"description": "Download an image from a URL or generate an SVG vector illustration for websites, games, or apps.",
|
|
96
|
+
"parameters": {
|
|
97
|
+
"type": "object",
|
|
98
|
+
"properties": {
|
|
99
|
+
"destination": {"type": "string", "description": "Relative workspace file path (e.g. 'images/apples.jpg' or 'assets/icon.svg')"},
|
|
100
|
+
"url": {"type": "string", "description": "Optional direct image URL to download"},
|
|
101
|
+
"svg_content": {"type": "string", "description": "Optional raw SVG code to save as vector asset"},
|
|
102
|
+
"category": {"type": "string", "description": "Category for auto-curated imagery (e.g. 'fruits', 'vegetables', 'tech', 'avatar')"},
|
|
103
|
+
},
|
|
104
|
+
"required": ["destination"],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
91
108
|
]
|
|
92
109
|
|
|
93
110
|
# ── Offline tool schemas (same as CORE_TOOLS) ─────────────────────────
|
|
@@ -221,6 +221,101 @@ DONE: <pass/fail breakdown, failing test names, exact line numbers>
|
|
|
221
221
|
)
|
|
222
222
|
|
|
223
223
|
|
|
224
|
+
class FrontendSubagent(BaseSubagent):
|
|
225
|
+
"""UI/UX & Frontend Architect for modern, glassmorphic, static-first web applications."""
|
|
226
|
+
|
|
227
|
+
SYSTEM_PROMPT = """\
|
|
228
|
+
You are the Frontend Architect Subagent for AlpieCode.
|
|
229
|
+
Your role is to build beautiful, responsive, modern web frontends:
|
|
230
|
+
1. Ensure static-first HTML markup with pre-rendered components (never empty divs).
|
|
231
|
+
2. Use modern CSS (CSS Grid, Flexbox, glassmorphism, responsive typography, hover transitions).
|
|
232
|
+
3. Universal vanilla JavaScript wrapped in an IIFE. Ensure all DOM element IDs match index.html.
|
|
233
|
+
4. Use download_asset for crisp imagery and vector SVGs.
|
|
234
|
+
Conclude with:
|
|
235
|
+
DONE: <summary of UI components, styles, and interactivity implemented>
|
|
236
|
+
"""
|
|
237
|
+
|
|
238
|
+
def __init__(self, max_turns: int = 5):
|
|
239
|
+
super().__init__(
|
|
240
|
+
name="frontend",
|
|
241
|
+
role="Frontend & UI/UX Architect",
|
|
242
|
+
system_prompt=self.SYSTEM_PROMPT,
|
|
243
|
+
allowed_tools={"read_file", "write_file", "edit_file", "list_files", "download_asset"},
|
|
244
|
+
max_turns=max_turns,
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
class GameSubagent(BaseSubagent):
|
|
249
|
+
"""Interactive Game Architect for HTML5 Canvas and Pygame."""
|
|
250
|
+
|
|
251
|
+
SYSTEM_PROMPT = """\
|
|
252
|
+
You are the Interactive Game Architect Subagent for AlpieCode.
|
|
253
|
+
Your role is to build 60 FPS interactive games:
|
|
254
|
+
1. Implement a 60 FPS loop with requestAnimationFrame and delta-time `dt`.
|
|
255
|
+
2. Implement complete game states (TITLE, PLAYING, GAMEOVER) with high scores in localStorage.
|
|
256
|
+
3. Synthesize retro sound effects using the Web Audio API with zero external audio assets.
|
|
257
|
+
4. Support keyboard listeners and mobile touch controls.
|
|
258
|
+
Conclude with:
|
|
259
|
+
DONE: <game mechanics, controls, audio synthesis, and states implemented>
|
|
260
|
+
"""
|
|
261
|
+
|
|
262
|
+
def __init__(self, max_turns: int = 5):
|
|
263
|
+
super().__init__(
|
|
264
|
+
name="game",
|
|
265
|
+
role="Interactive Game Architect",
|
|
266
|
+
system_prompt=self.SYSTEM_PROMPT,
|
|
267
|
+
allowed_tools={"read_file", "write_file", "edit_file", "list_files", "bash"},
|
|
268
|
+
max_turns=max_turns,
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
class AIMLSubagent(BaseSubagent):
|
|
273
|
+
"""AI/ML Systems Engineer for models, pipelines, and evaluation."""
|
|
274
|
+
|
|
275
|
+
SYSTEM_PROMPT = """\
|
|
276
|
+
You are the AI/ML Systems Engineer Subagent for AlpieCode.
|
|
277
|
+
Your role is to construct machine learning pipelines:
|
|
278
|
+
1. Provide synthetic dataset generation if no data is provided.
|
|
279
|
+
2. Structure clean model definition, training loop, evaluation metrics, and model checkpoints.
|
|
280
|
+
3. Run a quick 1-epoch / 10-sample test pass to verify sub-second hermetic execution.
|
|
281
|
+
Conclude with:
|
|
282
|
+
DONE: <model architecture, training parameters, loss/accuracy metrics, and evaluation results>
|
|
283
|
+
"""
|
|
284
|
+
|
|
285
|
+
def __init__(self, max_turns: int = 5):
|
|
286
|
+
super().__init__(
|
|
287
|
+
name="aiml",
|
|
288
|
+
role="AI/ML Systems Engineer",
|
|
289
|
+
system_prompt=self.SYSTEM_PROMPT,
|
|
290
|
+
allowed_tools={"read_file", "write_file", "edit_file", "list_files", "bash"},
|
|
291
|
+
max_turns=max_turns,
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
class AgentArchitectSubagent(BaseSubagent):
|
|
296
|
+
"""Autonomous Agent Architect for synthesizing complete agent systems."""
|
|
297
|
+
|
|
298
|
+
SYSTEM_PROMPT = """\
|
|
299
|
+
You are the Agent Architect Subagent for AlpieCode.
|
|
300
|
+
Your role is to design and build autonomous agent systems:
|
|
301
|
+
1. Define clear agent roles, system prompts, and tool declaration schemas.
|
|
302
|
+
2. Implement deterministic turn-based execution while-loops with safety ceilings.
|
|
303
|
+
3. Build persistent memory structures (AGENTS.md, state containers).
|
|
304
|
+
4. Provide complete unit tests verifying tool dispatch and execution cycles.
|
|
305
|
+
Conclude with:
|
|
306
|
+
DONE: <agent specification, tool schemas, memory patterns, and test verification>
|
|
307
|
+
"""
|
|
308
|
+
|
|
309
|
+
def __init__(self, max_turns: int = 5):
|
|
310
|
+
super().__init__(
|
|
311
|
+
name="architect",
|
|
312
|
+
role="Autonomous Agent Architect",
|
|
313
|
+
system_prompt=self.SYSTEM_PROMPT,
|
|
314
|
+
allowed_tools={"read_file", "write_file", "edit_file", "list_files", "bash"},
|
|
315
|
+
max_turns=max_turns,
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
|
|
224
319
|
# ── Subagent Coordinator Registry ─────────────────────────────────────────────
|
|
225
320
|
|
|
226
321
|
class SubagentManager:
|
|
@@ -231,6 +326,10 @@ class SubagentManager:
|
|
|
231
326
|
"researcher": ResearcherSubagent(),
|
|
232
327
|
"reviewer": ReviewerSubagent(),
|
|
233
328
|
"tester": TesterSubagent(),
|
|
329
|
+
"frontend": FrontendSubagent(),
|
|
330
|
+
"game": GameSubagent(),
|
|
331
|
+
"aiml": AIMLSubagent(),
|
|
332
|
+
"architect": AgentArchitectSubagent(),
|
|
234
333
|
}
|
|
235
334
|
|
|
236
335
|
def register(self, subagent: BaseSubagent) -> None:
|
|
@@ -313,7 +313,7 @@ TOOLS = [
|
|
|
313
313
|
"properties": {
|
|
314
314
|
"subagent": {
|
|
315
315
|
"type": "string",
|
|
316
|
-
"enum": ["researcher", "reviewer", "tester"],
|
|
316
|
+
"enum": ["researcher", "reviewer", "tester", "frontend", "game", "aiml", "architect"],
|
|
317
317
|
"description": "The specialized subagent to invoke",
|
|
318
318
|
},
|
|
319
319
|
"prompt": {
|
|
@@ -325,6 +325,39 @@ TOOLS = [
|
|
|
325
325
|
},
|
|
326
326
|
},
|
|
327
327
|
},
|
|
328
|
+
{
|
|
329
|
+
"type": "function",
|
|
330
|
+
"function": {
|
|
331
|
+
"name": "download_asset",
|
|
332
|
+
"description": (
|
|
333
|
+
"Download high-resolution stock photography from Unsplash or direct image URLs, "
|
|
334
|
+
"or generate clean vector SVG illustrations, and save them into the project workspace (e.g. 'images/produce.jpg' or 'assets/fruit.svg'). "
|
|
335
|
+
"Guarantees that web applications and games have working, high-quality visuals without 404 broken images."
|
|
336
|
+
),
|
|
337
|
+
"parameters": {
|
|
338
|
+
"type": "object",
|
|
339
|
+
"properties": {
|
|
340
|
+
"destination": {
|
|
341
|
+
"type": "string",
|
|
342
|
+
"description": "Relative workspace path for the asset (e.g. 'images/apples.jpg' or 'assets/logo.svg')",
|
|
343
|
+
},
|
|
344
|
+
"url": {
|
|
345
|
+
"type": "string",
|
|
346
|
+
"description": "Optional direct image URL to download (e.g. from Unsplash, Wikimedia, or external CDN)",
|
|
347
|
+
},
|
|
348
|
+
"svg_content": {
|
|
349
|
+
"type": "string",
|
|
350
|
+
"description": "Optional raw SVG markup if generating a custom inline vector illustration",
|
|
351
|
+
},
|
|
352
|
+
"category": {
|
|
353
|
+
"type": "string",
|
|
354
|
+
"description": "Asset category for auto-curated imagery (e.g. 'fruits', 'vegetables', 'grocery', 'ecommerce', 'tech', 'avatar', 'cart')",
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
"required": ["destination"],
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
},
|
|
328
361
|
]
|
|
329
362
|
|
|
330
363
|
|
|
@@ -970,6 +1003,117 @@ def _clone_repo(workdir: Path, repo_url: str, branch: str = None) -> str:
|
|
|
970
1003
|
return clone_repo(repo_url, workdir, branch=branch)
|
|
971
1004
|
|
|
972
1005
|
|
|
1006
|
+
# ── Asset & Image Downloader Engine ───────────────────────────────────
|
|
1007
|
+
|
|
1008
|
+
CURATED_STOCK_IMAGES = {
|
|
1009
|
+
"fruits": "https://images.unsplash.com/photo-1619566636858-adf3ef46400b?w=600&auto=format&fit=crop&q=80",
|
|
1010
|
+
"vegetables": "https://images.unsplash.com/photo-1597362925123-77861d3fbac7?w=600&auto=format&fit=crop&q=80",
|
|
1011
|
+
"grocery": "https://images.unsplash.com/photo-1542838132-92c53300491e?w=600&auto=format&fit=crop&q=80",
|
|
1012
|
+
"ecommerce": "https://images.unsplash.com/photo-1472851294608-062f824d29cc?w=600&auto=format&fit=crop&q=80",
|
|
1013
|
+
"tech": "https://images.unsplash.com/photo-1518770660439-4636190af475?w=600&auto=format&fit=crop&q=80",
|
|
1014
|
+
"avatar": "https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=300&auto=format&fit=crop&q=80",
|
|
1015
|
+
"apple": "https://images.unsplash.com/photo-1560806887-1e4cd0b6cbd6?w=600&auto=format&fit=crop&q=80",
|
|
1016
|
+
"banana": "https://images.unsplash.com/photo-1571771894821-ce9b6c11b08e?w=600&auto=format&fit=crop&q=80",
|
|
1017
|
+
"orange": "https://images.unsplash.com/photo-1611080626919-7cf5a9dbab5b?w=600&auto=format&fit=crop&q=80",
|
|
1018
|
+
"carrot": "https://images.unsplash.com/photo-1598170845058-32b9d6a5da37?w=600&auto=format&fit=crop&q=80",
|
|
1019
|
+
"tomato": "https://images.unsplash.com/photo-1592924357228-91a4daadcfea?w=600&auto=format&fit=crop&q=80",
|
|
1020
|
+
"broccoli": "https://images.unsplash.com/photo-1459411621453-7b03977f4bfc?w=600&auto=format&fit=crop&q=80",
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
def _generate_default_svg(category: str, name: str) -> str:
|
|
1025
|
+
"""Generate a clean, modern SVG vector illustration for fallback or offline assets."""
|
|
1026
|
+
cat = (category or "").lower()
|
|
1027
|
+
nm = (name or "").lower()
|
|
1028
|
+
|
|
1029
|
+
if any(k in cat or k in nm for k in ("fruit", "apple", "berry", "cherry", "tomato")):
|
|
1030
|
+
primary_color = "#ef4444"
|
|
1031
|
+
accent_color = "#22c55e"
|
|
1032
|
+
icon_path = '<circle cx="50" cy="55" r="30" fill="{primary}" /><path d="M50 25 C50 15 65 15 65 25 Z" fill="{accent}" /><path d="M50 25 Q45 15 40 10" stroke="#78350f" stroke-width="3" fill="none" />'
|
|
1033
|
+
label = "Fresh Produce"
|
|
1034
|
+
elif any(k in cat or k in nm for k in ("vegetable", "green", "salad", "broccoli", "carrot")):
|
|
1035
|
+
primary_color = "#16a34a"
|
|
1036
|
+
accent_color = "#f97316"
|
|
1037
|
+
icon_path = '<path d="M30 65 L50 20 L70 65 Z" fill="{accent}" /><circle cx="50" cy="20" r="10" fill="{primary}" />'
|
|
1038
|
+
label = "Farm Fresh"
|
|
1039
|
+
elif any(k in cat or k in nm for k in ("cart", "shop", "ecommerce", "basket")):
|
|
1040
|
+
primary_color = "#3b82f6"
|
|
1041
|
+
accent_color = "#1d4ed8"
|
|
1042
|
+
icon_path = '<path d="M25 30 L35 30 L45 60 L75 60 L80 40 L35 40" stroke="{primary}" stroke-width="4" fill="none" /><circle cx="48" cy="70" r="5" fill="{primary}" /><circle cx="72" cy="70" r="5" fill="{primary}" />'
|
|
1043
|
+
label = "Shopping Cart"
|
|
1044
|
+
elif any(k in cat or k in nm for k in ("avatar", "user", "profile", "person")):
|
|
1045
|
+
primary_color = "#6366f1"
|
|
1046
|
+
accent_color = "#a5b4fc"
|
|
1047
|
+
icon_path = '<circle cx="50" cy="40" r="18" fill="{accent}" /><path d="M25 80 C25 60 75 60 75 80 Z" fill="{primary}" />'
|
|
1048
|
+
label = "User Avatar"
|
|
1049
|
+
else:
|
|
1050
|
+
primary_color = "#0ea5e9"
|
|
1051
|
+
accent_color = "#38bdf8"
|
|
1052
|
+
icon_path = '<rect x="25" y="25" width="50" height="50" rx="8" fill="{primary}" opacity="0.8" /><path d="M35 50 L45 60 L65 40" stroke="#ffffff" stroke-width="4" fill="none" />'
|
|
1053
|
+
label = "Asset"
|
|
1054
|
+
|
|
1055
|
+
rendered_icon = icon_path.replace("{primary}", primary_color).replace("{accent}", accent_color)
|
|
1056
|
+
return f"""<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100%" height="100%">
|
|
1057
|
+
<rect width="100" height="100" rx="12" fill="#f8fafc" />
|
|
1058
|
+
{rendered_icon}
|
|
1059
|
+
<text x="50" y="92" font-family="system-ui, sans-serif" font-size="7" font-weight="600" fill="#64748b" text-anchor="middle">{label}</text>
|
|
1060
|
+
</svg>"""
|
|
1061
|
+
|
|
1062
|
+
|
|
1063
|
+
def _download_asset(
|
|
1064
|
+
workdir: Path,
|
|
1065
|
+
destination: str,
|
|
1066
|
+
url: Optional[str] = None,
|
|
1067
|
+
svg_content: Optional[str] = None,
|
|
1068
|
+
category: Optional[str] = None,
|
|
1069
|
+
) -> str:
|
|
1070
|
+
target_path = _resolve_safe_path(workdir, destination)
|
|
1071
|
+
target_path.parent.mkdir(parents=True, exist_ok=True)
|
|
1072
|
+
|
|
1073
|
+
# 1. Custom SVG provided
|
|
1074
|
+
if svg_content and svg_content.strip():
|
|
1075
|
+
target_path.write_text(svg_content.strip(), encoding="utf-8")
|
|
1076
|
+
return f"Saved SVG asset to {destination} ({len(svg_content)} chars)"
|
|
1077
|
+
|
|
1078
|
+
# 2. Resolve URL: explicit URL, or curated stock URL
|
|
1079
|
+
resolved_url = url
|
|
1080
|
+
if not resolved_url and category:
|
|
1081
|
+
cat_key = category.lower().strip()
|
|
1082
|
+
for k, u in CURATED_STOCK_IMAGES.items():
|
|
1083
|
+
if k in cat_key or cat_key in k:
|
|
1084
|
+
resolved_url = u
|
|
1085
|
+
break
|
|
1086
|
+
|
|
1087
|
+
# If target is explicitly .svg and no URL specified, generate clean SVG
|
|
1088
|
+
if target_path.suffix.lower() == ".svg" and not resolved_url:
|
|
1089
|
+
svg_code = _generate_default_svg(category or "", target_path.name)
|
|
1090
|
+
target_path.write_text(svg_code, encoding="utf-8")
|
|
1091
|
+
return f"Generated modern vector SVG asset at {destination} ({len(svg_code)} chars)"
|
|
1092
|
+
|
|
1093
|
+
# 3. Download from network if URL available
|
|
1094
|
+
if resolved_url:
|
|
1095
|
+
try:
|
|
1096
|
+
import httpx
|
|
1097
|
+
with httpx.Client(timeout=12.0, follow_redirects=True) as client:
|
|
1098
|
+
resp = client.get(resolved_url)
|
|
1099
|
+
if resp.status_code == 200 and resp.content:
|
|
1100
|
+
target_path.write_bytes(resp.content)
|
|
1101
|
+
return f"Successfully downloaded asset from {resolved_url} to {destination} ({len(resp.content)} bytes)"
|
|
1102
|
+
except Exception:
|
|
1103
|
+
pass # Fall through to SVG fallback
|
|
1104
|
+
|
|
1105
|
+
# 4. Fallback if offline or download failed
|
|
1106
|
+
fallback_svg = _generate_default_svg(category or "", target_path.name)
|
|
1107
|
+
if target_path.suffix.lower() in (".jpg", ".jpeg", ".png"):
|
|
1108
|
+
svg_companion = target_path.with_suffix(".svg")
|
|
1109
|
+
svg_companion.write_text(fallback_svg, encoding="utf-8")
|
|
1110
|
+
# Also write an SVG file to target_path or keep svg_companion
|
|
1111
|
+
return f"Saved fallback vector SVG asset to {svg_companion.relative_to(workdir)}"
|
|
1112
|
+
else:
|
|
1113
|
+
target_path.write_text(fallback_svg, encoding="utf-8")
|
|
1114
|
+
return f"Created vector SVG asset at {destination}"
|
|
1115
|
+
|
|
1116
|
+
|
|
973
1117
|
# ── Dispatch factory ──────────────────────────────────────────────────
|
|
974
1118
|
|
|
975
1119
|
def make_dispatch(workdir: Path):
|
|
@@ -1098,4 +1242,11 @@ def make_dispatch(workdir: Path):
|
|
|
1098
1242
|
workdir, a.get("repo_url") or a.get("url", ""),
|
|
1099
1243
|
branch=a.get("branch"),
|
|
1100
1244
|
),
|
|
1245
|
+
"download_asset": lambda a: _download_asset(
|
|
1246
|
+
workdir,
|
|
1247
|
+
destination=a.get("destination") or a.get("path") or a.get("file") or "assets/asset.svg",
|
|
1248
|
+
url=a.get("url") or a.get("src"),
|
|
1249
|
+
svg_content=a.get("svg_content") or a.get("svg"),
|
|
1250
|
+
category=a.get("category") or a.get("type"),
|
|
1251
|
+
),
|
|
1101
1252
|
}
|
|
@@ -288,6 +288,20 @@ class IntelligentVerificationEngine:
|
|
|
288
288
|
except Exception:
|
|
289
289
|
pass
|
|
290
290
|
|
|
291
|
+
# JavaScript syntax check
|
|
292
|
+
elif tf.endswith((".js", ".mjs", ".cjs")):
|
|
293
|
+
try:
|
|
294
|
+
content = full_tf.read_text(encoding="utf-8", errors="replace")
|
|
295
|
+
from .guardrails import validate_code_syntax
|
|
296
|
+
is_valid, err_msg = validate_code_syntax(tf, content)
|
|
297
|
+
if not is_valid:
|
|
298
|
+
syntax_errs.append(f"- '{tf}': {err_msg}")
|
|
299
|
+
if not first_failing_file:
|
|
300
|
+
first_failing_file = tf
|
|
301
|
+
first_error_type = "js_syntax_error"
|
|
302
|
+
except Exception:
|
|
303
|
+
pass
|
|
304
|
+
|
|
291
305
|
if syntax_errs:
|
|
292
306
|
return VerificationResult(
|
|
293
307
|
passed=False,
|
|
@@ -302,6 +316,125 @@ class IntelligentVerificationEngine:
|
|
|
302
316
|
|
|
303
317
|
return VerificationResult(passed=True, tier="syntax")
|
|
304
318
|
|
|
319
|
+
def verify_web_dom_semantics(
|
|
320
|
+
self,
|
|
321
|
+
session_touched_files: Set[str],
|
|
322
|
+
) -> VerificationResult:
|
|
323
|
+
"""
|
|
324
|
+
Tier 2.5: Browser-DOM Semantic Contract Gate.
|
|
325
|
+
Verifies that:
|
|
326
|
+
1. index.html has static fallback components (> 120 characters of rendered body tags).
|
|
327
|
+
2. Referenced CSS stylesheets and JavaScript scripts exist on disk.
|
|
328
|
+
3. Every document.getElementById / querySelector('#id') in client JS matches a real id in index.html.
|
|
329
|
+
"""
|
|
330
|
+
html_file = None
|
|
331
|
+
for tf in session_touched_files:
|
|
332
|
+
if tf.endswith("index.html") or tf == "index.html":
|
|
333
|
+
html_file = self.workdir / tf
|
|
334
|
+
break
|
|
335
|
+
if not html_file and (self.workdir / "index.html").exists():
|
|
336
|
+
html_file = self.workdir / "index.html"
|
|
337
|
+
|
|
338
|
+
if not html_file or not html_file.is_file():
|
|
339
|
+
return VerificationResult(passed=True, tier="dom_semantics")
|
|
340
|
+
|
|
341
|
+
try:
|
|
342
|
+
html_content = html_file.read_text(encoding="utf-8", errors="replace")
|
|
343
|
+
except Exception:
|
|
344
|
+
return VerificationResult(passed=True, tier="dom_semantics")
|
|
345
|
+
|
|
346
|
+
# 1. Non-empty static HTML body check (Prevents blank white screen)
|
|
347
|
+
body_match = re.search(r"<body[^>]*>(.*?)</body>", html_content, re.DOTALL | re.IGNORECASE)
|
|
348
|
+
if body_match:
|
|
349
|
+
body_inner = body_match.group(1).strip()
|
|
350
|
+
stripped_content = re.sub(r"<(script|style)[^>]*>.*?</\1>", "", body_inner, flags=re.DOTALL | re.IGNORECASE).strip()
|
|
351
|
+
clean_tags = re.sub(r"\s+", " ", stripped_content)
|
|
352
|
+
if len(clean_tags) < 120 or clean_tags in ('<div id="app"></div>', '<div id="root"></div>', '<main></main>'):
|
|
353
|
+
return VerificationResult(
|
|
354
|
+
passed=False,
|
|
355
|
+
tier="dom_semantics",
|
|
356
|
+
error_type="empty_static_html",
|
|
357
|
+
failing_file=str(html_file.relative_to(self.workdir)),
|
|
358
|
+
message=(
|
|
359
|
+
f"Empty static body detected in '{html_file.name}'. "
|
|
360
|
+
"Web applications must provide rich pre-rendered static HTML markup (navigation, headings, product cards, buttons) "
|
|
361
|
+
"so the page is never blank even if client-side scripts encounter a delay or error."
|
|
362
|
+
),
|
|
363
|
+
suggested_action="Use edit_file to populate 'index.html' with complete initial HTML components.",
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
# 2. Extract all IDs defined in HTML
|
|
367
|
+
defined_ids = set(re.findall(r'\bid=["\']([a-zA-Z0-9_\-]+)["\']', html_content))
|
|
368
|
+
|
|
369
|
+
# 3. Check referenced scripts and stylesheets
|
|
370
|
+
referenced_scripts = re.findall(r'<script[^>]+src=["\']([^"\']+)["\']', html_content, re.IGNORECASE)
|
|
371
|
+
for s in referenced_scripts:
|
|
372
|
+
if s.startswith("http://") or s.startswith("https://") or s.startswith("//"):
|
|
373
|
+
continue
|
|
374
|
+
script_path = (self.workdir / s).resolve()
|
|
375
|
+
if not script_path.exists():
|
|
376
|
+
return VerificationResult(
|
|
377
|
+
passed=False,
|
|
378
|
+
tier="dom_semantics",
|
|
379
|
+
error_type="missing_script_asset",
|
|
380
|
+
failing_file=s,
|
|
381
|
+
message=f"'{html_file.name}' references script '{s}', but '{s}' was not created on disk.",
|
|
382
|
+
suggested_action=f"Create '{s}' using write_file.",
|
|
383
|
+
)
|
|
384
|
+
|
|
385
|
+
referenced_links = re.findall(r'<link[^>]+href=["\']([^"\']+)["\']', html_content, re.IGNORECASE)
|
|
386
|
+
for l in referenced_links:
|
|
387
|
+
if l.startswith("http://") or l.startswith("https://") or l.startswith("//"):
|
|
388
|
+
continue
|
|
389
|
+
if l.endswith(".css"):
|
|
390
|
+
css_path = (self.workdir / l).resolve()
|
|
391
|
+
if not css_path.exists():
|
|
392
|
+
return VerificationResult(
|
|
393
|
+
passed=False,
|
|
394
|
+
tier="dom_semantics",
|
|
395
|
+
error_type="missing_css_asset",
|
|
396
|
+
failing_file=l,
|
|
397
|
+
message=f"'{html_file.name}' links stylesheet '{l}', but '{l}' was not created on disk.",
|
|
398
|
+
suggested_action=f"Create '{l}' using write_file.",
|
|
399
|
+
)
|
|
400
|
+
|
|
401
|
+
# 4. Check for DOM ID selector alignment in touched JavaScript files
|
|
402
|
+
js_files = [
|
|
403
|
+
self.workdir / tf for tf in session_touched_files
|
|
404
|
+
if tf.endswith(".js") and (self.workdir / tf).is_file()
|
|
405
|
+
]
|
|
406
|
+
if not js_files and (self.workdir / "app.js").exists():
|
|
407
|
+
js_files = [self.workdir / "app.js"]
|
|
408
|
+
|
|
409
|
+
for jf in js_files:
|
|
410
|
+
try:
|
|
411
|
+
js_content = jf.read_text(encoding="utf-8", errors="replace")
|
|
412
|
+
queried_ids = set(re.findall(r"(?:getElementById|querySelector)\(['\"]#?([a-zA-Z0-9_\-]+)['\"]\)", js_content))
|
|
413
|
+
queried_ids = {qid for qid in queried_ids if not qid.startswith("${") and not qid.startswith("modal-")}
|
|
414
|
+
|
|
415
|
+
missing_ids = [qid for qid in queried_ids if qid not in defined_ids]
|
|
416
|
+
if missing_ids:
|
|
417
|
+
first_missing = missing_ids[0]
|
|
418
|
+
return VerificationResult(
|
|
419
|
+
passed=False,
|
|
420
|
+
tier="dom_semantics",
|
|
421
|
+
error_type="dom_id_mismatch",
|
|
422
|
+
failing_file=str(jf.relative_to(self.workdir)),
|
|
423
|
+
message=(
|
|
424
|
+
f"DOM Selector Mismatch: '{jf.name}' attempts to query ID '#{first_missing}', "
|
|
425
|
+
f"but id='{first_missing}' is NOT defined in '{html_file.name}'. "
|
|
426
|
+
"This triggers 'TypeError: Cannot set properties of null' and causes a blank screen."
|
|
427
|
+
),
|
|
428
|
+
suggested_action=(
|
|
429
|
+
f"Add id='{first_missing}' to the corresponding container in '{html_file.name}', "
|
|
430
|
+
f"or update '{jf.name}' to query an existing ID ({', '.join(list(defined_ids)[:4])})."
|
|
431
|
+
),
|
|
432
|
+
)
|
|
433
|
+
except Exception:
|
|
434
|
+
pass
|
|
435
|
+
|
|
436
|
+
return VerificationResult(passed=True, tier="dom_semantics")
|
|
437
|
+
|
|
305
438
|
def verify_tests(
|
|
306
439
|
self,
|
|
307
440
|
session_touched_files: Set[str],
|
|
@@ -479,6 +612,11 @@ class IntelligentVerificationEngine:
|
|
|
479
612
|
if not res2.passed:
|
|
480
613
|
return res2
|
|
481
614
|
|
|
615
|
+
# Tier 2.5: Browser-DOM Semantic Contract Gate (for Web Applications)
|
|
616
|
+
res_dom = self.verify_web_dom_semantics(session_touched_files)
|
|
617
|
+
if not res_dom.passed:
|
|
618
|
+
return res_dom
|
|
619
|
+
|
|
482
620
|
# Tier 3: Environment-aware targeted & full test runner
|
|
483
621
|
res3 = self.verify_tests(
|
|
484
622
|
session_touched_files,
|
|
@@ -201,3 +201,135 @@ def test_domain_blueprint_router():
|
|
|
201
201
|
assert py_bp.blueprint_type == BlueprintType.CLI_SCRIPT
|
|
202
202
|
assert "python3" in py_bp.execution_runner
|
|
203
203
|
|
|
204
|
+
# AI / ML task
|
|
205
|
+
ml_bp = resolve_domain_blueprint("train a model for sentiment classification using pytorch")
|
|
206
|
+
assert ml_bp is not None
|
|
207
|
+
assert ml_bp.blueprint_type == BlueprintType.AI_ML
|
|
208
|
+
assert "model.py" in ml_bp.target_files
|
|
209
|
+
|
|
210
|
+
# Agent Synthesizer task
|
|
211
|
+
agent_bp = resolve_domain_blueprint("create an agent system with tools and memory")
|
|
212
|
+
assert agent_bp is not None
|
|
213
|
+
assert agent_bp.blueprint_type == BlueprintType.AGENT_SYNTHESIZER
|
|
214
|
+
assert "agent.py" in agent_bp.target_files
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def test_download_asset_generates_svg_and_saves(tmp_path):
|
|
218
|
+
"""Verify download_asset produces clean SVG illustrations without network dependency."""
|
|
219
|
+
from codeagent.tools import make_dispatch
|
|
220
|
+
dispatch = make_dispatch(tmp_path)
|
|
221
|
+
|
|
222
|
+
# 1. Custom SVG content
|
|
223
|
+
custom_svg = '<svg viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" fill="red"/></svg>'
|
|
224
|
+
res1 = dispatch["download_asset"]({"destination": "assets/custom.svg", "svg_content": custom_svg})
|
|
225
|
+
assert "Saved SVG asset" in res1
|
|
226
|
+
assert (tmp_path / "assets" / "custom.svg").read_text() == custom_svg
|
|
227
|
+
|
|
228
|
+
# 2. Auto category fallback SVG / Unsplash download
|
|
229
|
+
res2 = dispatch["download_asset"]({"destination": "images/apple.svg", "category": "fruits"})
|
|
230
|
+
assert any(k in res2 for k in ("Successfully downloaded asset", "Generated modern vector SVG", "Created vector SVG"))
|
|
231
|
+
assert (tmp_path / "images" / "apple.svg").exists()
|
|
232
|
+
|
|
233
|
+
# 3. Direct SVG generator without URL
|
|
234
|
+
res3 = dispatch["download_asset"]({"destination": "images/banner.svg", "category": "ecommerce"})
|
|
235
|
+
assert (tmp_path / "images" / "banner.svg").exists()
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def test_verifier_catches_empty_static_html(tmp_path):
|
|
239
|
+
"""Tier 2.5 IVE must reject index.html if the body is an empty shell without pre-rendered markup."""
|
|
240
|
+
from codeagent.verifier import IntelligentVerificationEngine
|
|
241
|
+
ive = IntelligentVerificationEngine(tmp_path)
|
|
242
|
+
|
|
243
|
+
# Create empty root HTML shell
|
|
244
|
+
empty_html = """<!DOCTYPE html>
|
|
245
|
+
<html>
|
|
246
|
+
<head><title>Store</title></head>
|
|
247
|
+
<body>
|
|
248
|
+
<div id="app"></div>
|
|
249
|
+
</body>
|
|
250
|
+
</html>"""
|
|
251
|
+
(tmp_path / "index.html").write_text(empty_html)
|
|
252
|
+
|
|
253
|
+
res = ive.verify_web_dom_semantics({"index.html"})
|
|
254
|
+
assert res.passed is False
|
|
255
|
+
assert res.error_type == "empty_static_html"
|
|
256
|
+
assert "Empty static body" in res.message
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def test_verifier_catches_dom_id_mismatch(tmp_path):
|
|
260
|
+
"""Tier 2.5 IVE must catch when client JS queries an element ID that does not exist in index.html."""
|
|
261
|
+
from codeagent.verifier import IntelligentVerificationEngine
|
|
262
|
+
ive = IntelligentVerificationEngine(tmp_path)
|
|
263
|
+
|
|
264
|
+
valid_html = """<!DOCTYPE html>
|
|
265
|
+
<html>
|
|
266
|
+
<head><title>Fruit Store</title><link rel="stylesheet" href="styles.css"></head>
|
|
267
|
+
<body>
|
|
268
|
+
<header class="navbar"><h1>Fresh Organic Market Store</h1><p>Hand-picked farm fresh products</p></header>
|
|
269
|
+
<main><div id="products-grid"><p class="loading">Loading fresh produce catalog...</p></div></main>
|
|
270
|
+
<script src="app.js"></script>
|
|
271
|
+
</body>
|
|
272
|
+
</html>"""
|
|
273
|
+
(tmp_path / "index.html").write_text(valid_html)
|
|
274
|
+
(tmp_path / "styles.css").write_text("body { font-family: sans-serif; }")
|
|
275
|
+
# app.js queries nonexistent ID 'fruit-items' instead of 'products-grid'
|
|
276
|
+
bad_js = """(function() {
|
|
277
|
+
var container = document.getElementById('fruit-items');
|
|
278
|
+
container.innerHTML = '<p>Apples</p>';
|
|
279
|
+
})();"""
|
|
280
|
+
(tmp_path / "app.js").write_text(bad_js)
|
|
281
|
+
|
|
282
|
+
res = ive.verify_web_dom_semantics({"index.html", "styles.css", "app.js"})
|
|
283
|
+
assert res.passed is False
|
|
284
|
+
assert res.error_type == "dom_id_mismatch"
|
|
285
|
+
assert "fruit-items" in res.message
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def test_verifier_passes_clean_web_dom_semantics(tmp_path):
|
|
289
|
+
"""Tier 2.5 IVE passes when HTML has rich static components, matching IDs, and existing assets."""
|
|
290
|
+
from codeagent.verifier import IntelligentVerificationEngine
|
|
291
|
+
ive = IntelligentVerificationEngine(tmp_path)
|
|
292
|
+
|
|
293
|
+
valid_html = """<!DOCTYPE html>
|
|
294
|
+
<html lang="en">
|
|
295
|
+
<head>
|
|
296
|
+
<meta charset="UTF-8">
|
|
297
|
+
<title>Fresh Produce Market</title>
|
|
298
|
+
<link rel="stylesheet" href="styles.css">
|
|
299
|
+
</head>
|
|
300
|
+
<body>
|
|
301
|
+
<header><h1 id="store-title">Fresh Veg & Fruit</h1><button id="cart-btn">Cart (0)</button></header>
|
|
302
|
+
<main id="main-content">
|
|
303
|
+
<section id="products-grid">
|
|
304
|
+
<div class="card"><h3>Organic Apples</h3><p>$2.99</p></div>
|
|
305
|
+
</section>
|
|
306
|
+
</main>
|
|
307
|
+
<script src="app.js"></script>
|
|
308
|
+
</body>
|
|
309
|
+
</html>"""
|
|
310
|
+
(tmp_path / "index.html").write_text(valid_html)
|
|
311
|
+
(tmp_path / "styles.css").write_text("body { margin: 0; }")
|
|
312
|
+
valid_js = """(function() {
|
|
313
|
+
var grid = document.getElementById('products-grid');
|
|
314
|
+
var cartBtn = document.getElementById('cart-btn');
|
|
315
|
+
})();"""
|
|
316
|
+
(tmp_path / "app.js").write_text(valid_js)
|
|
317
|
+
|
|
318
|
+
res = ive.verify_web_dom_semantics({"index.html", "styles.css", "app.js"})
|
|
319
|
+
assert res.passed is True
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
def test_specialized_subagents_registered():
|
|
323
|
+
"""Verify that all specialized subagents are registered and functional."""
|
|
324
|
+
from codeagent.subagent import SubagentManager
|
|
325
|
+
mgr = SubagentManager()
|
|
326
|
+
agent_names = [a["name"] for a in mgr.list_subagents()]
|
|
327
|
+
assert "frontend" in agent_names
|
|
328
|
+
assert "game" in agent_names
|
|
329
|
+
assert "aiml" in agent_names
|
|
330
|
+
assert "architect" in agent_names
|
|
331
|
+
assert "researcher" in agent_names
|
|
332
|
+
assert "reviewer" in agent_names
|
|
333
|
+
assert "tester" in agent_names
|
|
334
|
+
|
|
335
|
+
|
|
Binary file
|
|
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
|
|
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
|