alpiecode 10.7.5__tar.gz → 10.8.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {alpiecode-10.7.5 → alpiecode-10.8.0}/PKG-INFO +1 -1
- {alpiecode-10.7.5 → alpiecode-10.8.0}/pyproject.toml +1 -1
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/alpiecode.egg-info/PKG-INFO +1 -1
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/alpiecode.egg-info/SOURCES.txt +7 -1
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/__init__.py +1 -1
- alpiecode-10.8.0/src/codeagent/blueprints.py +187 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/cli.py +26 -2
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/compaction.py +9 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/context.py +57 -12
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/discovery.py +42 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/guardrails.py +118 -60
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/memory.py +166 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/orchestrator.py +89 -37
- alpiecode-10.8.0/src/codeagent/project_template.py +538 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/prompt.py +65 -7
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/slash.py +29 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/system1.py +42 -12
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/tools.py +5 -4
- alpiecode-10.8.0/src/codeagent/walkthrough.py +295 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/test/test_non_thinking_and_local_stream.py +3 -3
- alpiecode-10.8.0/test/test_project_templates.py +181 -0
- alpiecode-10.8.0/test/test_walkthrough.py +130 -0
- alpiecode-10.8.0/test/test_web_resilience_and_guardrails.py +203 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/README.md +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/setup.cfg +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/alpiecode/__init__.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/alpiecode.egg-info/dependency_links.txt +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/alpiecode.egg-info/entry_points.txt +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/alpiecode.egg-info/requires.txt +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/alpiecode.egg-info/top_level.txt +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/agent.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/assessment.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/backends/__init__.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/backends/base.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/backends/local_backend.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/backends/openai_backend.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/cache.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/client.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/config.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/diff_preview.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/doctor.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/dream_rsi.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/executor.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/extension/alpiecode.vsix +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/git_ops.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/github.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/guardian.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/ipython_ext.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/local_model.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/media.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/metrics.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/paths.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/progress.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/rephraser.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/server.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/session.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/subagent.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/updater.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/verifier.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/src/codeagent/vscode_installer.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/test/test_adaptive_resilience.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/test/test_cli_ui.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/test/test_context_and_trajectory.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/test/test_dream_rsi.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/test/test_local_model_download.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/test/test_slash_and_diff.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/test/test_subagents.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/test/test_task_assessment.py +0 -0
- {alpiecode-10.7.5 → alpiecode-10.8.0}/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.0"
|
|
21
21
|
|
|
22
22
|
def run(task: str, workdir: str = ".", reasoning_level: str = "thinking", **kwargs):
|
|
23
23
|
"""Run an autonomous coding task programmatically."""
|
|
@@ -0,0 +1,187 @@
|
|
|
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
|
+
GENERAL = "general"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass
|
|
27
|
+
class DomainBlueprint:
|
|
28
|
+
name: str
|
|
29
|
+
blueprint_type: BlueprintType
|
|
30
|
+
target_files: List[str]
|
|
31
|
+
entry_point: str
|
|
32
|
+
execution_runner: str
|
|
33
|
+
prohibitions: List[str] = field(default_factory=list)
|
|
34
|
+
architecture_rules: List[str] = field(default_factory=list)
|
|
35
|
+
|
|
36
|
+
def render_contract(self) -> str:
|
|
37
|
+
"""Render strict execution contract markdown for prompt injection."""
|
|
38
|
+
files_str = ", ".join(f"`{f}`" for f in self.target_files) if self.target_files else "Application files"
|
|
39
|
+
prohib_md = "\n".join(f"- ⛔ {p}" for p in self.prohibitions)
|
|
40
|
+
rules_md = "\n".join(f"- ✅ {r}" for r in self.architecture_rules)
|
|
41
|
+
|
|
42
|
+
return f"""## Pre-Flight Domain Blueprint: {self.name.upper()}
|
|
43
|
+
- **Primary Deliverables**: {files_str}
|
|
44
|
+
- **Entry Point**: `{self.entry_point}`
|
|
45
|
+
- **Execution / Runner**: `{self.execution_runner}`
|
|
46
|
+
|
|
47
|
+
### Architecture Rules
|
|
48
|
+
{rules_md}
|
|
49
|
+
|
|
50
|
+
### Strict Prohibitions
|
|
51
|
+
{prohib_md}
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# ── Specialized Domain Blueprint Definitions ───────────────────────────
|
|
56
|
+
|
|
57
|
+
def get_web_app_blueprint(task: str) -> DomainBlueprint:
|
|
58
|
+
return DomainBlueprint(
|
|
59
|
+
name="Browser-First Web Application",
|
|
60
|
+
blueprint_type=BlueprintType.WEB_APP,
|
|
61
|
+
target_files=["index.html", "styles.css", "app.js"],
|
|
62
|
+
entry_point="index.html",
|
|
63
|
+
execution_runner="python3 -m http.server 8000 (view at http://localhost:8000)",
|
|
64
|
+
architecture_rules=[
|
|
65
|
+
"Write `index.html` FIRST: Semantic HTML5 layout, clear container IDs, linked styles.css and app.js.",
|
|
66
|
+
"Write `styles.css` SECOND: Modern responsive styling using CSS Flexbox and Grid, clean typography.",
|
|
67
|
+
"Write `app.js` THIRD: Vanilla ES6 JavaScript for client-side state, item rendering, and interactive modals.",
|
|
68
|
+
"Write EXACTLY ONE complete file per turn in order (Turn 1: index.html, Turn 2: styles.css, Turn 3: app.js).",
|
|
69
|
+
"Verify all files exist and validate JavaScript with `node --check app.js` before completing.",
|
|
70
|
+
],
|
|
71
|
+
prohibitions=[
|
|
72
|
+
"NEVER write standalone `.jsx` files without a build tool like Vite -- Node cannot execute raw JSX.",
|
|
73
|
+
"NEVER write utility files like `utils/formatPrice.js` before `index.html` exists.",
|
|
74
|
+
"NEVER start blocking daemon servers with `&` or real `sleep` in terminal commands.",
|
|
75
|
+
],
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def get_cli_script_blueprint(task: str) -> DomainBlueprint:
|
|
80
|
+
return DomainBlueprint(
|
|
81
|
+
name="Self-Contained CLI / Utility",
|
|
82
|
+
blueprint_type=BlueprintType.CLI_SCRIPT,
|
|
83
|
+
target_files=["main.py"],
|
|
84
|
+
entry_point="main.py",
|
|
85
|
+
execution_runner="python3 main.py",
|
|
86
|
+
architecture_rules=[
|
|
87
|
+
"Implement complete, working logic in Turn 1 with zero stubs or placeholders.",
|
|
88
|
+
"Use standard library `argparse` for flexible command-line argument parsing.",
|
|
89
|
+
"Handle edge cases and invalid inputs gracefully with clear error messages.",
|
|
90
|
+
"Verify by running `python3 main.py` or writing a quick hermetic unit test.",
|
|
91
|
+
],
|
|
92
|
+
prohibitions=[
|
|
93
|
+
"NEVER split simple utility scripts across multiple unnecessary files.",
|
|
94
|
+
"NEVER leave placeholder functions (`pass` or `...`). Implement real working code.",
|
|
95
|
+
],
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def get_rest_api_blueprint(task: str) -> DomainBlueprint:
|
|
100
|
+
return DomainBlueprint(
|
|
101
|
+
name="REST API Service",
|
|
102
|
+
blueprint_type=BlueprintType.REST_API,
|
|
103
|
+
target_files=["app.py", "test_app.py"],
|
|
104
|
+
entry_point="app.py",
|
|
105
|
+
execution_runner="pytest test_app.py",
|
|
106
|
+
architecture_rules=[
|
|
107
|
+
"Define modular endpoints with input validation, proper HTTP status codes, and JSON responses.",
|
|
108
|
+
"ALWAYS test endpoints using in-process test clients (`TestClient(app)` for FastAPI or `app.test_client()` for Flask).",
|
|
109
|
+
"Verify with `pytest` in under 0.1 seconds.",
|
|
110
|
+
],
|
|
111
|
+
prohibitions=[
|
|
112
|
+
"NEVER start background servers with `uvicorn &` or `flask run &` and curl -- use TestClient.",
|
|
113
|
+
"NEVER leave unhandled exceptions in request routes.",
|
|
114
|
+
],
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def get_native_cpp_blueprint(task: str) -> DomainBlueprint:
|
|
119
|
+
return DomainBlueprint(
|
|
120
|
+
name="Native C/C++ System",
|
|
121
|
+
blueprint_type=BlueprintType.NATIVE_CPP,
|
|
122
|
+
target_files=["main.cpp"],
|
|
123
|
+
entry_point="main.cpp",
|
|
124
|
+
execution_runner="g++ -std=c++17 -O2 -o app main.cpp && ./app",
|
|
125
|
+
architecture_rules=[
|
|
126
|
+
"Always include required standard headers: `<algorithm>`, `<memory>`, `<mutex>`, `<thread>`.",
|
|
127
|
+
"Mutexes locked in `const` methods MUST be declared `mutable std::mutex mtx;`.",
|
|
128
|
+
"Never use the same identifier for member variables and accessor functions (e.g. `m_isPaused` vs `isPaused()`).",
|
|
129
|
+
"If the user asked for a website in C++, serve an HTML5/Canvas UI from a C++ HTTP server, never an ASCII terminal app.",
|
|
130
|
+
"Verify compilation with `g++ -std=c++17 -O2` with exit code 0.",
|
|
131
|
+
],
|
|
132
|
+
prohibitions=[
|
|
133
|
+
"NEVER claim completion if compilation fails with exit code != 0.",
|
|
134
|
+
"NEVER access private class members from helper functions without accessors.",
|
|
135
|
+
],
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def get_game_blueprint(task: str) -> DomainBlueprint:
|
|
140
|
+
return DomainBlueprint(
|
|
141
|
+
name="Interactive Game",
|
|
142
|
+
blueprint_type=BlueprintType.GAME,
|
|
143
|
+
target_files=["index.html", "game.js", "styles.css"],
|
|
144
|
+
entry_point="index.html",
|
|
145
|
+
execution_runner="python3 -m http.server 8000",
|
|
146
|
+
architecture_rules=[
|
|
147
|
+
"Implement complete game loop (update, render, event handling) using HTML5 Canvas or Pygame.",
|
|
148
|
+
"Include ALL game mechanics: player controls, obstacle/enemy spawning, collision physics, score tracking, win/loss states.",
|
|
149
|
+
"Add smooth keyboard/touch input listeners and an interactive restart button.",
|
|
150
|
+
"Deliver complete, runnable code with zero TODOs or missing game states.",
|
|
151
|
+
],
|
|
152
|
+
prohibitions=[
|
|
153
|
+
"NEVER deliver a game with missing collision or non-functional controls.",
|
|
154
|
+
],
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
# ── Blueprint Router ───────────────────────────────────────────────────
|
|
159
|
+
|
|
160
|
+
def resolve_domain_blueprint(task: str, repo: Optional[Dict] = None, intent: str = "create") -> Optional[DomainBlueprint]:
|
|
161
|
+
"""
|
|
162
|
+
Route task intent to the optimal Domain Blueprint.
|
|
163
|
+
Runs deterministically in < 1ms.
|
|
164
|
+
"""
|
|
165
|
+
task_lower = task.lower().strip()
|
|
166
|
+
|
|
167
|
+
# 1. C / C++ Tasks
|
|
168
|
+
if any(kw in task_lower for kw in ("c++", "cpp", "g++", "gcc", "clang", "in c", "in c++")):
|
|
169
|
+
return get_native_cpp_blueprint(task)
|
|
170
|
+
|
|
171
|
+
# 2. Interactive Games
|
|
172
|
+
if any(kw in task_lower for kw in ("game", "snake", "pong", "tetris", "arcade", "flappy", "chess", "sudoku")):
|
|
173
|
+
return get_game_blueprint(task)
|
|
174
|
+
|
|
175
|
+
# 3. Web Applications / E-Commerce / Frontend
|
|
176
|
+
if any(kw in task_lower for kw in ("website", "web app", "webapp", "e-commerce", "ecommerce", "store", "dashboard", "frontend", "html", "landing page")):
|
|
177
|
+
return get_web_app_blueprint(task)
|
|
178
|
+
|
|
179
|
+
# 4. REST APIs / Microservices
|
|
180
|
+
if any(kw in task_lower for kw in ("api", "rest api", "fastapi", "flask", "endpoint", "microservice", "crud")):
|
|
181
|
+
return get_rest_api_blueprint(task)
|
|
182
|
+
|
|
183
|
+
# 5. CLI Scripts / Utilities
|
|
184
|
+
if any(kw in task_lower for kw in ("script", "cli", "command-line", "utility", "tool", "parse", "convert", "calculator")):
|
|
185
|
+
return get_cli_script_blueprint(task)
|
|
186
|
+
|
|
187
|
+
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
|
)
|