alpiecode 10.10.12__tar.gz → 10.10.13__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.10.12 → alpiecode-10.10.13}/PKG-INFO +1 -1
- {alpiecode-10.10.12 → alpiecode-10.10.13}/pyproject.toml +1 -1
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/alpiecode.egg-info/PKG-INFO +1 -1
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/alpiecode.egg-info/SOURCES.txt +4 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/__init__.py +1 -1
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/backends/local_backend.py +20 -5
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/backends/openai_backend.py +10 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/context.py +5 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/execution_safety.py +11 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/executor.py +2 -2
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/local_model.py +22 -2
- alpiecode-10.10.13/src/codeagent/local_protocol.py +26 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/prompt.py +28 -203
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/slash.py +1 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/tools.py +24 -2
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/vision.py +1 -1
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_adaptive_resilience.py +2 -2
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_frontier_architecture.py +2 -1
- alpiecode-10.10.13/test/test_local_protocol.py +35 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_observed_evidence.py +10 -0
- alpiecode-10.10.13/test/test_offline_repair_eval.py +18 -0
- alpiecode-10.10.13/test/test_repair_evidence.py +67 -0
- alpiecode-10.10.13/test/test_stream_protocol_preservation.py +45 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_tool_boundary.py +21 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_web_resilience_and_guardrails.py +2 -0
- alpiecode-10.10.12/test/test_repair_evidence.py +0 -34
- {alpiecode-10.10.12 → alpiecode-10.10.13}/README.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/setup.cfg +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/setup.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/alpiecode/__init__.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/alpiecode.egg-info/dependency_links.txt +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/alpiecode.egg-info/entry_points.txt +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/alpiecode.egg-info/requires.txt +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/alpiecode.egg-info/top_level.txt +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/__main__.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/agent.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/assessment.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/backends/__init__.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/backends/base.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/blueprints.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/cache.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/capabilities.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/chat_tags.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/cli.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/client.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/compaction.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/config.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/convergence.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/diff_preview.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/discovery.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/doctor.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/dream_rsi.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/evaluation.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/git_ops.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/github.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/grounding.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/guardian.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/guardrails.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/ipython_ext.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/lifecycle.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/media.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/memory.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/metrics.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/onboarding.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/orchestrator.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/paths.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/progress.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/project_template.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/rephraser.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/server.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/session.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/accessibility-audit/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/accessibility-testing/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/accessibility-ui-components/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/agentic-workflows/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/api-design/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/architecture-design/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/backend-engineering/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/browser-automation/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/cli-development/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/cloud-infrastructure/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/code-generation/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/code-review/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/codebase-onboarding/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/cost-optimization/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/data-analysis/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/data-engineering/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/database-engineering/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/dependency-management/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/dependency-security/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/dependency-upgrades/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/devops-ci-cd/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/docker-containers/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/documentation/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/documentation-site/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/e2e-testing/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/error-handling-resilience/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/feature-development/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/frontend-engineering/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/git-workflow/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/incident-response/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/legacy-code-modernization/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/llm-application-engineering/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/localization-i18n/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/mcp-server-development/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/migration-engineering/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/mobile-development/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/model-evaluation/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/nodejs-services/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/observability/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/performance-optimization/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/privacy-data-protection/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/prompt-engineering/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/python-engineering/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/rag-retrieval/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/react-engineering/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/release-management/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/requirements-analysis/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/responsive-design/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/safe-refactoring/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/secure-coding/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/systematic-debugging/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/technical-planning/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/technical-research/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/technical-writing/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/test-engineering/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/tool-integration/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/typescript-engineering/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/visual-regression-testing/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/web-performance/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/web-security-testing/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills/workflow-automation/SKILL.md +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/skills.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/subagent.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/system1.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/tool_boundary.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/updater.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/verifier.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/vscode_installer.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/src/codeagent/walkthrough.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_chat_tags_and_offline_multimodal.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_cli_ui.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_context_and_trajectory.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_deloop_and_sessions.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_dream_rsi.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_execution_recovery.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_gpu_detection.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_lifecycle_and_portfolio.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_local_model_download.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_memory_optimization.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_nested_xml_tools.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_non_thinking_and_local_stream.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_onboarding.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_project_templates.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_release_foundations.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_report_convergence.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_security_config.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_skills_engine.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_slash_and_diff.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_subagents.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_task_assessment.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_token_economy_and_256k.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_truncation_resilience.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_verifier.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_visual_grounding.py +0 -0
- {alpiecode-10.10.12 → alpiecode-10.10.13}/test/test_walkthrough.py +0 -0
|
@@ -37,6 +37,7 @@ src/codeagent/guardrails.py
|
|
|
37
37
|
src/codeagent/ipython_ext.py
|
|
38
38
|
src/codeagent/lifecycle.py
|
|
39
39
|
src/codeagent/local_model.py
|
|
40
|
+
src/codeagent/local_protocol.py
|
|
40
41
|
src/codeagent/media.py
|
|
41
42
|
src/codeagent/memory.py
|
|
42
43
|
src/codeagent/metrics.py
|
|
@@ -136,10 +137,12 @@ test/test_frontier_architecture.py
|
|
|
136
137
|
test/test_gpu_detection.py
|
|
137
138
|
test/test_lifecycle_and_portfolio.py
|
|
138
139
|
test/test_local_model_download.py
|
|
140
|
+
test/test_local_protocol.py
|
|
139
141
|
test/test_memory_optimization.py
|
|
140
142
|
test/test_nested_xml_tools.py
|
|
141
143
|
test/test_non_thinking_and_local_stream.py
|
|
142
144
|
test/test_observed_evidence.py
|
|
145
|
+
test/test_offline_repair_eval.py
|
|
143
146
|
test/test_onboarding.py
|
|
144
147
|
test/test_project_templates.py
|
|
145
148
|
test/test_release_foundations.py
|
|
@@ -148,6 +151,7 @@ test/test_report_convergence.py
|
|
|
148
151
|
test/test_security_config.py
|
|
149
152
|
test/test_skills_engine.py
|
|
150
153
|
test/test_slash_and_diff.py
|
|
154
|
+
test/test_stream_protocol_preservation.py
|
|
151
155
|
test/test_subagents.py
|
|
152
156
|
test/test_task_assessment.py
|
|
153
157
|
test/test_token_economy_and_256k.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.10.
|
|
20
|
+
__version__ = "10.10.13"
|
|
21
21
|
|
|
22
22
|
def run(task: str, workdir: str = ".", reasoning_level: str = "thinking", **kwargs):
|
|
23
23
|
"""Run an autonomous coding task programmatically."""
|
|
@@ -96,7 +96,7 @@ class LocalBackend:
|
|
|
96
96
|
raw_content = _smart_truncate(raw_content, max_chars=6000 if name == "read_file" else 1800)
|
|
97
97
|
|
|
98
98
|
tool_text = f"[Tool Result for {name}]:\n{raw_content}"
|
|
99
|
-
if sanitized and sanitized[-1].get("role") == "user":
|
|
99
|
+
if sanitized and sanitized[-1].get("role") == "user" and isinstance(sanitized[-1].get("content"), str):
|
|
100
100
|
sanitized[-1]["content"] += "\n\n" + tool_text
|
|
101
101
|
else:
|
|
102
102
|
sanitized.append({"role": "user", "content": tool_text})
|
|
@@ -192,7 +192,7 @@ class LocalBackend:
|
|
|
192
192
|
name = fn.get("name", "unknown")
|
|
193
193
|
args = fn.get("arguments", "{}")
|
|
194
194
|
# Do not duplicate full file content in context history
|
|
195
|
-
if name in ("write_file", "edit_file", "apply_patch"):
|
|
195
|
+
if name in ("write_file", "edit_file", "apply_patch") and len(str(args)) > 6000:
|
|
196
196
|
try:
|
|
197
197
|
import json as _json
|
|
198
198
|
a_dict = _json.loads(args) if isinstance(args, str) else args
|
|
@@ -231,8 +231,9 @@ class LocalBackend:
|
|
|
231
231
|
if coalesced and coalesced[-1].get("role") == "user":
|
|
232
232
|
c_val = coalesced[-1].get("content")
|
|
233
233
|
prompt_hint = (
|
|
234
|
-
"\n\n[Next Action:
|
|
235
|
-
"
|
|
234
|
+
"\n\n[Next Action: Use the response format specified by the system. "
|
|
235
|
+
"Base the next action on the actual tool result. A failed test requires diagnosis, not completion. "
|
|
236
|
+
"After the requested changes pass verification, finish with a concise summary.]"
|
|
236
237
|
)
|
|
237
238
|
if isinstance(c_val, str):
|
|
238
239
|
if any(k in c_val for k in ("[Tool Result", "[Workspace State", "Files created so far", "[CRITICAL STYLING DIRECTIVE")):
|
|
@@ -347,6 +348,9 @@ class LocalBackend:
|
|
|
347
348
|
enable_thinking=enable_thinking,
|
|
348
349
|
)
|
|
349
350
|
msg = resp.choices[0].message
|
|
351
|
+
from ..local_protocol import unwrap_answer
|
|
352
|
+
if msg.content:
|
|
353
|
+
msg.content = unwrap_answer(msg.content)
|
|
350
354
|
|
|
351
355
|
tool_calls = None
|
|
352
356
|
if msg.tool_calls:
|
|
@@ -431,6 +435,7 @@ class LocalBackend:
|
|
|
431
435
|
in_think = enable_thinking
|
|
432
436
|
think_started = False
|
|
433
437
|
full_content = []
|
|
438
|
+
raw_tool_text = []
|
|
434
439
|
full_reasoning = []
|
|
435
440
|
tool_calls_dict = {}
|
|
436
441
|
# In non-thinking mode, swallow any accidental <think>...</think> generated by model
|
|
@@ -445,6 +450,8 @@ class LocalBackend:
|
|
|
445
450
|
delta = choice.get("delta") or {}
|
|
446
451
|
|
|
447
452
|
explicit_reasoning = delta.get("reasoning") or delta.get("reasoning_content")
|
|
453
|
+
if explicit_reasoning:
|
|
454
|
+
raw_tool_text.append(explicit_reasoning)
|
|
448
455
|
if explicit_reasoning and enable_thinking:
|
|
449
456
|
if not think_started:
|
|
450
457
|
think_started = True
|
|
@@ -495,6 +502,9 @@ class LocalBackend:
|
|
|
495
502
|
|
|
496
503
|
text = delta.get("content")
|
|
497
504
|
if text:
|
|
505
|
+
# Tool protocol parsing must not depend on UI reasoning suppression.
|
|
506
|
+
# Markers can span arbitrary token chunks or appear inside think tags.
|
|
507
|
+
raw_tool_text.append(text)
|
|
498
508
|
if suppress_think:
|
|
499
509
|
# Silently swallow any think tags/blocks emitted in fast mode
|
|
500
510
|
if "<think>" in text:
|
|
@@ -612,6 +622,8 @@ class LocalBackend:
|
|
|
612
622
|
tool_calls.append(ToolCall(id=item["id"], name=item["name"], arguments=args))
|
|
613
623
|
|
|
614
624
|
final_content_str = "".join(full_content).strip()
|
|
625
|
+
from ..local_protocol import unwrap_answer
|
|
626
|
+
final_content_str = unwrap_answer(final_content_str)
|
|
615
627
|
if not enable_thinking and final_content_str:
|
|
616
628
|
import re
|
|
617
629
|
final_content_str = re.sub(r"^\s*<think>.*?</think>\s*", "", final_content_str, flags=re.DOTALL).strip()
|
|
@@ -642,7 +654,10 @@ class LocalBackend:
|
|
|
642
654
|
|
|
643
655
|
if not tool_calls:
|
|
644
656
|
from ..executor import parse_text_tool_calls
|
|
645
|
-
|
|
657
|
+
raw_text = "".join(raw_tool_text)
|
|
658
|
+
parsed_tcs = parse_text_tool_calls(raw_text) if "<tool_call>" in raw_text else []
|
|
659
|
+
if not parsed_tcs:
|
|
660
|
+
parsed_tcs = parse_text_tool_calls(final_content_str) if final_content_str else []
|
|
646
661
|
if not parsed_tcs and final_reasoning_str:
|
|
647
662
|
parsed_tcs = parse_text_tool_calls(final_reasoning_str)
|
|
648
663
|
if parsed_tcs and not final_content_str:
|
|
@@ -484,6 +484,7 @@ class OpenAIBackend:
|
|
|
484
484
|
inside_suppressed_think = False
|
|
485
485
|
think_started = False
|
|
486
486
|
full_content = []
|
|
487
|
+
raw_tool_text = []
|
|
487
488
|
full_reasoning = []
|
|
488
489
|
tool_calls_dict = {}
|
|
489
490
|
|
|
@@ -535,6 +536,8 @@ class OpenAIBackend:
|
|
|
535
536
|
|
|
536
537
|
# Explicit reasoning field from some models
|
|
537
538
|
explicit_reasoning = getattr(delta, "reasoning", None) or getattr(delta, "reasoning_content", None)
|
|
539
|
+
if explicit_reasoning:
|
|
540
|
+
raw_tool_text.append(explicit_reasoning)
|
|
538
541
|
if explicit_reasoning and enable_thinking:
|
|
539
542
|
if not think_started:
|
|
540
543
|
think_started = True
|
|
@@ -545,6 +548,7 @@ class OpenAIBackend:
|
|
|
545
548
|
# Content deltas (contains <think>...</think> on vLLM/Qwen models)
|
|
546
549
|
if delta.content:
|
|
547
550
|
text = delta.content
|
|
551
|
+
raw_tool_text.append(text)
|
|
548
552
|
if suppress_think:
|
|
549
553
|
# In non-thinking mode, swallow any think tags/blocks emitted by local models
|
|
550
554
|
if "<think>" in text:
|
|
@@ -639,6 +643,12 @@ class OpenAIBackend:
|
|
|
639
643
|
|
|
640
644
|
final_content = final_content_str
|
|
641
645
|
final_reasoning = final_reasoning_str if final_reasoning_str else None
|
|
646
|
+
if not tool_calls and "<tool_call>" in "".join(raw_tool_text):
|
|
647
|
+
from ..executor import parse_text_tool_calls
|
|
648
|
+
parsed = parse_text_tool_calls("".join(raw_tool_text))
|
|
649
|
+
if parsed:
|
|
650
|
+
tool_calls = [ToolCall(id=f"text_call_{i+1}", name=call["name"], arguments=call["arguments"])
|
|
651
|
+
for i, call in enumerate(parsed)]
|
|
642
652
|
|
|
643
653
|
yield ("done", ChatResponse(
|
|
644
654
|
content=final_content,
|
|
@@ -232,6 +232,11 @@ class ContextManager:
|
|
|
232
232
|
Preserves update_plan and recent turns intact.
|
|
233
233
|
Note: Operates on working _messages, while _raw_messages / raw_history remains pristine.
|
|
234
234
|
"""
|
|
235
|
+
# Keep source, applied edits and tracebacks while they fit. Turn count
|
|
236
|
+
# alone is not memory pressure: a repair often needs an earlier read
|
|
237
|
+
# after an intervening edit and test failure.
|
|
238
|
+
if not needs_compaction(self._messages, self.max_tokens):
|
|
239
|
+
return
|
|
235
240
|
self.invalidate_cache()
|
|
236
241
|
assistant_indices = [
|
|
237
242
|
i for i, m in enumerate(self._messages)
|
|
@@ -20,6 +20,17 @@ def command_result(output: str) -> Optional[dict]:
|
|
|
20
20
|
return None
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
def command_succeeded(output: str) -> bool:
|
|
24
|
+
result = command_result(output)
|
|
25
|
+
if result is None or result["exit_code"] != 0:
|
|
26
|
+
return False
|
|
27
|
+
logs = str(result.get("stdout", "")) + "\n" + str(result.get("stderr", ""))
|
|
28
|
+
return not any(marker in logs for marker in (
|
|
29
|
+
"Traceback (most recent call last)", "ERROR collecting", "ERRORS ===",
|
|
30
|
+
"FAILURES ===", "FAILED (", "AssertionError:", "SyntaxError:", "TypeError:",
|
|
31
|
+
))
|
|
32
|
+
|
|
33
|
+
|
|
23
34
|
def shell_command(command: str, windows: bool) -> List[str]:
|
|
24
35
|
if windows:
|
|
25
36
|
# Windows' bash.exe can be a WSL launcher with no installed Linux shell.
|
|
@@ -675,9 +675,9 @@ class ToolExecutor:
|
|
|
675
675
|
cmd_str = safe_args.get("command", "").strip()
|
|
676
676
|
norm_cmd = re.sub(r"\s*\|\s*(?:head|tail|grep|sed|less|cat)\b.*", "", cmd_str)
|
|
677
677
|
norm_cmd = re.sub(r"\s*2>&1\s*", " ", norm_cmd).strip()
|
|
678
|
-
from .execution_safety import command_result
|
|
678
|
+
from .execution_safety import command_result, command_succeeded
|
|
679
679
|
observed = command_result(res_str)
|
|
680
|
-
if
|
|
680
|
+
if command_succeeded(res_str):
|
|
681
681
|
if norm_cmd in self.successful_bash_commands:
|
|
682
682
|
res_str += (
|
|
683
683
|
"\n\n[VERIFICATION] This command already succeeded since the last recorded edit. "
|
|
@@ -855,6 +855,18 @@ class LocalModel:
|
|
|
855
855
|
if tools:
|
|
856
856
|
params["tools"] = tools
|
|
857
857
|
params["tool_choice"] = kwargs.get("tool_choice", "auto")
|
|
858
|
+
if getattr(handler, "_alpie_native_template", False):
|
|
859
|
+
from .local_protocol import response_schema
|
|
860
|
+
params["response_format"] = {"type":"json_object", "schema":response_schema(tools)}
|
|
861
|
+
# Grammar constrains syntax; instructions define the intended meaning.
|
|
862
|
+
instruction = ('\nReturn exactly one JSON object: {"name":"tool_name","arguments":{...}} '
|
|
863
|
+
'to call a tool, or {"answer":"your answer"}. Use DONE: in the answer only after verification. '
|
|
864
|
+
'Do not emit XML, Python function notation, or pretend tool results. Read source before editing.')
|
|
865
|
+
params["messages"] = [{**m, "content":m["content"] + instruction}
|
|
866
|
+
if m.get("role") == "system" and isinstance(m.get("content"),str)
|
|
867
|
+
else dict(m) for m in msgs]
|
|
868
|
+
handler.enable_thinking = False
|
|
869
|
+
params["stop"] = [s for s in params["stop"] if s != "</tool_call>"]
|
|
858
870
|
|
|
859
871
|
def _safe_stream_generator():
|
|
860
872
|
from .execution_safety import GenerationGuard
|
|
@@ -870,13 +882,21 @@ class LocalModel:
|
|
|
870
882
|
for chunk in gen:
|
|
871
883
|
for choice in chunk.get("choices", []):
|
|
872
884
|
delta = choice.get("delta") or {}
|
|
873
|
-
|
|
885
|
+
text_field = next((key for key in ("content", "reasoning", "reasoning_content") if delta.get(key)), "content")
|
|
886
|
+
content = delta.get(text_field) or ""
|
|
874
887
|
previous_length = len(boundary.text)
|
|
875
888
|
end = boundary.feed(content)
|
|
889
|
+
if params.get("response_format") and end is None:
|
|
890
|
+
try:
|
|
891
|
+
stripped = boundary.text.lstrip()
|
|
892
|
+
_, json_end = json.JSONDecoder().raw_decode(stripped)
|
|
893
|
+
end = len(boundary.text) - len(stripped) + json_end
|
|
894
|
+
except ValueError:
|
|
895
|
+
pass
|
|
876
896
|
if end is not None:
|
|
877
897
|
# Yield exactly the completed call, then return control to
|
|
878
898
|
# the executor. The model must observe its result next turn.
|
|
879
|
-
delta[
|
|
899
|
+
delta[text_field] = content[:max(0, end - previous_length)]
|
|
880
900
|
yield chunk
|
|
881
901
|
return
|
|
882
902
|
guard.feed(content)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Constrain local tool turns to the existing tool schemas."""
|
|
2
|
+
import json
|
|
3
|
+
from typing import Any, Dict, List
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def response_schema(tools: List[Dict[str, Any]]) -> dict:
|
|
7
|
+
choices = []
|
|
8
|
+
for tool in tools:
|
|
9
|
+
fn = tool["function"]
|
|
10
|
+
choices.append({"type":"object", "properties":{
|
|
11
|
+
"name":{"type":"string", "enum":[fn["name"]]},
|
|
12
|
+
"arguments":fn["parameters"],
|
|
13
|
+
}, "required":["name","arguments"], "additionalProperties":False})
|
|
14
|
+
choices.append({"type":"object", "properties":{"answer":{"type":"string"}},
|
|
15
|
+
"required":["answer"], "additionalProperties":False})
|
|
16
|
+
return {"anyOf":choices}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def unwrap_answer(text: str) -> str:
|
|
20
|
+
try:
|
|
21
|
+
value = json.loads(text)
|
|
22
|
+
if isinstance(value,dict) and set(value) == {"answer"} and isinstance(value["answer"],str):
|
|
23
|
+
return value["answer"]
|
|
24
|
+
except ValueError:
|
|
25
|
+
pass
|
|
26
|
+
return text
|
|
@@ -13,160 +13,8 @@ from .tools import TOOLS
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
# ── Core tool schemas (for low-complexity / default tasks) ─────────────
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"type": "function",
|
|
19
|
-
"function": {
|
|
20
|
-
"name": "bash",
|
|
21
|
-
"description": "Run a shell command. Returns stdout, stderr, exit_code.",
|
|
22
|
-
"parameters": {
|
|
23
|
-
"type": "object",
|
|
24
|
-
"properties": {"command": {"type": "string"}},
|
|
25
|
-
"required": ["command"],
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"type": "function",
|
|
31
|
-
"function": {
|
|
32
|
-
"name": "read_file",
|
|
33
|
-
"description": "Read file contents with line numbers.",
|
|
34
|
-
"parameters": {
|
|
35
|
-
"type": "object",
|
|
36
|
-
"properties": {
|
|
37
|
-
"path": {"type": "string"},
|
|
38
|
-
"start_line": {"type": "integer"},
|
|
39
|
-
"end_line": {"type": "integer"},
|
|
40
|
-
},
|
|
41
|
-
"required": ["path"],
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"type": "function",
|
|
47
|
-
"function": {
|
|
48
|
-
"name": "write_file",
|
|
49
|
-
"description": "Create or overwrite a file. Pass append=True to append to an existing file.",
|
|
50
|
-
"parameters": {
|
|
51
|
-
"type": "object",
|
|
52
|
-
"properties": {
|
|
53
|
-
"path": {"type": "string"},
|
|
54
|
-
"content": {"type": "string"},
|
|
55
|
-
"append": {"type": "boolean"},
|
|
56
|
-
},
|
|
57
|
-
"required": ["path", "content"],
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"type": "function",
|
|
63
|
-
"function": {
|
|
64
|
-
"name": "append_file",
|
|
65
|
-
"description": "Append content to the end of an existing file (ideal for continuing large files that hit token limits).",
|
|
66
|
-
"parameters": {
|
|
67
|
-
"type": "object",
|
|
68
|
-
"properties": {
|
|
69
|
-
"path": {"type": "string"},
|
|
70
|
-
"content": {"type": "string"},
|
|
71
|
-
},
|
|
72
|
-
"required": ["path", "content"],
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
"type": "function",
|
|
78
|
-
"function": {
|
|
79
|
-
"name": "edit_file",
|
|
80
|
-
"description": "Replace old_str with new_str in a file.",
|
|
81
|
-
"parameters": {
|
|
82
|
-
"type": "object",
|
|
83
|
-
"properties": {
|
|
84
|
-
"path": {"type": "string"},
|
|
85
|
-
"old_str": {"type": "string"},
|
|
86
|
-
"new_str": {"type": "string"},
|
|
87
|
-
},
|
|
88
|
-
"required": ["path", "old_str", "new_str"],
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
"type": "function",
|
|
94
|
-
"function": {
|
|
95
|
-
"name": "list_files",
|
|
96
|
-
"description": "List files in directory recursively.",
|
|
97
|
-
"parameters": {
|
|
98
|
-
"type": "object",
|
|
99
|
-
"properties": {
|
|
100
|
-
"path": {"type": "string", "default": "."},
|
|
101
|
-
"max_depth": {"type": "integer", "default": 3},
|
|
102
|
-
},
|
|
103
|
-
"required": [],
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
"type": "function",
|
|
109
|
-
"function": {
|
|
110
|
-
"name": "download_asset",
|
|
111
|
-
"description": "Download an image from a URL or generate an SVG vector illustration for websites, games, or apps.",
|
|
112
|
-
"parameters": {
|
|
113
|
-
"type": "object",
|
|
114
|
-
"properties": {
|
|
115
|
-
"destination": {"type": "string", "description": "Relative workspace file path (e.g. 'images/apples.jpg' or 'assets/icon.svg')"},
|
|
116
|
-
"url": {"type": "string", "description": "Optional direct image URL to download"},
|
|
117
|
-
"svg_content": {"type": "string", "description": "Optional raw SVG code to save as vector asset"},
|
|
118
|
-
"category": {"type": "string", "description": "Category for auto-curated imagery (e.g. 'fruits', 'vegetables', 'tech', 'avatar')"},
|
|
119
|
-
},
|
|
120
|
-
"required": ["destination"],
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
"type": "function",
|
|
126
|
-
"function": {
|
|
127
|
-
"name": "load_skill",
|
|
128
|
-
"description": "Load a specialist skill from the catalogue (e.g. 'frontend-engineering', 'systematic-debugging', 'responsive-design').",
|
|
129
|
-
"parameters": {
|
|
130
|
-
"type": "object",
|
|
131
|
-
"properties": {
|
|
132
|
-
"name": {"type": "string", "description": "Exact name of the skill to load"},
|
|
133
|
-
},
|
|
134
|
-
"required": ["name"],
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
"type": "function",
|
|
140
|
-
"function": {
|
|
141
|
-
"name": "list_skills",
|
|
142
|
-
"description": "List available specialist skills from the catalogue.",
|
|
143
|
-
"parameters": {
|
|
144
|
-
"type": "object",
|
|
145
|
-
"properties": {
|
|
146
|
-
"filter": {"type": "string", "description": "Optional keyword search filter"},
|
|
147
|
-
},
|
|
148
|
-
"required": [],
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
"type": "function",
|
|
154
|
-
"function": {
|
|
155
|
-
"name": "complete_task",
|
|
156
|
-
"description": "Call this tool when all requested files and features are fully implemented and verified. Signals task completion.",
|
|
157
|
-
"parameters": {
|
|
158
|
-
"type": "object",
|
|
159
|
-
"properties": {
|
|
160
|
-
"summary": {
|
|
161
|
-
"type": "string",
|
|
162
|
-
"description": "Concise 2-4 sentence summary of what was implemented and verified.",
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
"required": ["summary"],
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
]
|
|
16
|
+
CORE_TOOL_NAMES = ('bash', 'read_file', 'write_file', 'append_file', 'edit_file', 'list_files', 'download_asset', 'load_skill', 'list_skills', 'complete_task')
|
|
17
|
+
CORE_TOOLS = [tool for tool in TOOLS if tool["function"]["name"] in CORE_TOOL_NAMES]
|
|
170
18
|
|
|
171
19
|
# ── Offline tool schemas (same as CORE_TOOLS) ─────────────────────────
|
|
172
20
|
OFFLINE_TOOLS = list(CORE_TOOLS) # Offline uses the same lean set
|
|
@@ -479,55 +327,32 @@ When the task is complete and verified:
|
|
|
479
327
|
"""
|
|
480
328
|
|
|
481
329
|
OFFLINE_SYSTEM_PROMPT = """\
|
|
482
|
-
You are AlpieCode,
|
|
483
|
-
You are running in OFFLINE mode
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
* app.js: Defensive DOM queries (if (el) el.addEventListener(...)), theme switch in localStorage (default light), event handlers.
|
|
509
|
-
* Every turn must contain a <tool_call> until all required files are created.
|
|
510
|
-
|
|
511
|
-
Rules:
|
|
512
|
-
1. Write clean code using standard library or vanilla frontend (HTML/CSS/JS).
|
|
513
|
-
2. NEVER run pip, uv pip, or package install commands — they will fail offline.
|
|
514
|
-
3. Use the project's existing test runner if installed, including pytest offline. Report unavailable dependencies honestly.
|
|
515
|
-
4. Output tool calls (use JSON format inside <tool_call>):
|
|
516
|
-
<tool_call>
|
|
517
|
-
{"name": "read_file", "arguments": {"path": "<file>"}}
|
|
518
|
-
</tool_call>
|
|
519
|
-
<tool_call>
|
|
520
|
-
{"name": "edit_file", "arguments": {"path": "<file>", "old_str": "<exact_existing_lines>", "new_str": "<replacement_lines>"}}
|
|
521
|
-
</tool_call>
|
|
522
|
-
<tool_call>
|
|
523
|
-
{"name": "bash", "arguments": {"command": "<command>"}}
|
|
524
|
-
</tool_call>
|
|
525
|
-
<tool_call>
|
|
526
|
-
{"name": "write_file", "arguments": {"path": "<file>", "content": "<full_code>"}}
|
|
527
|
-
</tool_call>
|
|
528
|
-
5. Verify changes with relevant tests; do not create replacement applications for repair tasks.
|
|
529
|
-
6. C/C++: Never collision between member vars and methods. Mutex in const methods must be mutable. Include <algorithm>. Serve interactive HTML5 UI from HTTP server, never console app.
|
|
530
|
-
7. When done and verified, output: DONE: <summary>.
|
|
330
|
+
You are AlpieCode, a software engineering assistant built by 169Pi.
|
|
331
|
+
You are running in OFFLINE mode using a local model. Internet research is unavailable.
|
|
332
|
+
|
|
333
|
+
Follow the user's task and active working directory. Use available tools for facts.
|
|
334
|
+
For a repair:
|
|
335
|
+
1. Read the relevant source and identify the reported failure from the image or error output.
|
|
336
|
+
2. Explain the specific cause using that evidence; a short file is not necessarily incomplete.
|
|
337
|
+
3. Make the smallest targeted edit that preserves the existing implementation.
|
|
338
|
+
Infer missing values from their consumers: preserve the required types, shapes and input data.
|
|
339
|
+
Do not invent sample values, repeat or truncate inputs, or change unrelated computations.
|
|
340
|
+
4. For edit_file, old_str must be a nonempty exact fragment copied from the source.
|
|
341
|
+
To insert missing code, replace an existing anchor with the new code plus that anchor.
|
|
342
|
+
Never replace an existing application with a new implementation to fix a local defect.
|
|
343
|
+
5. Run a relevant executable check or the project's installed test runner.
|
|
344
|
+
Check the requested behavior as well as the exit code; a program can run with incorrect output.
|
|
345
|
+
6. After successful verification, return DONE: with the actual change and check result, then stop.
|
|
346
|
+
|
|
347
|
+
Wait for each tool result before choosing the next action. A rejected edit changes nothing.
|
|
348
|
+
When a call fails, use the actual error to correct its arguments or inspect a specific source range.
|
|
349
|
+
Do not repeat identical reads or invent syntax errors after successful execution.
|
|
350
|
+
If blocked, report the missing evidence or environment problem and leave completion unverified.
|
|
351
|
+
|
|
352
|
+
For new programs, inspect the workspace and create complete code in manageable files.
|
|
353
|
+
For explanations or research, answer the request without unnecessary file creation.
|
|
354
|
+
For images/video, distinguish observed content from guesses; sampled frames are not full video analysis.
|
|
355
|
+
Use the runtime's requested tool format. Never invent tool results, tests, citations or specifications.
|
|
531
356
|
"""
|
|
532
357
|
|
|
533
358
|
|
|
@@ -160,6 +160,7 @@ def handle_slash_command(
|
|
|
160
160
|
f"• Model: [bold cyan]{cur_model}[/bold cyan]",
|
|
161
161
|
f"• Thinking / Reasoning: [bold yellow]{thinking_status}[/bold yellow]",
|
|
162
162
|
f"• Debug Diagnostics: [bold]{debug_status}[/bold]",
|
|
163
|
+
f"• Runtime Source: {Path(__file__).resolve().parent}",
|
|
163
164
|
f"• Working Dir: {workdir}",
|
|
164
165
|
f"• Context Tokens: {est_tokens:,} / {ctx_tokens:,} ({int(est_tokens / max(1, ctx_tokens) * 100)}%)",
|
|
165
166
|
f"• Session Turns: {user_turns}",
|
|
@@ -105,7 +105,7 @@ TOOLS = [
|
|
|
105
105
|
"type": "object",
|
|
106
106
|
"properties": {
|
|
107
107
|
"path": {"type": "string", "description": "Relative path to the file"},
|
|
108
|
-
"old_str": {"type": "string", "description": "
|
|
108
|
+
"old_str": {"type": "string", "minLength": 1, "description": "Copy a nonempty exact source fragment from read_file. To insert code, use an existing anchor and include that anchor in new_str."},
|
|
109
109
|
"new_str": {"type": "string", "description": "Replacement string"},
|
|
110
110
|
},
|
|
111
111
|
"required": ["path", "old_str", "new_str"],
|
|
@@ -748,6 +748,8 @@ def _edit_file(workdir: Path, path: str, old_str: str, new_str: str) -> str:
|
|
|
748
748
|
if not p.exists():
|
|
749
749
|
return f"error: file not found: {path}"
|
|
750
750
|
text = p.read_text(encoding="utf-8", errors="replace")
|
|
751
|
+
if not old_str:
|
|
752
|
+
return "error: old_str must be a nonempty source anchor. Copy an existing line from read_file and include it in new_str when inserting code."
|
|
751
753
|
if old_str == new_str:
|
|
752
754
|
return "skipped: old_str and new_str are identical — no change needed."
|
|
753
755
|
count = text.count(old_str)
|
|
@@ -757,6 +759,26 @@ def _edit_file(workdir: Path, path: str, old_str: str, new_str: str) -> str:
|
|
|
757
759
|
elif count > 1:
|
|
758
760
|
return f"error: old_str matched {count} times in '{path}'. Must match exactly 1 occurrence. Include more surrounding lines in old_str to make it unique."
|
|
759
761
|
else:
|
|
762
|
+
# Tolerate blank-line differences only. Nonblank source (including its
|
|
763
|
+
# indentation) must still match exactly; never guess similar code.
|
|
764
|
+
source_lines = text.splitlines(keepends=True)
|
|
765
|
+
indexed = [(i, line.rstrip()) for i, line in enumerate(source_lines) if line.strip()]
|
|
766
|
+
wanted = [line.rstrip() for line in old_str.splitlines() if line.strip()]
|
|
767
|
+
hits = [i for i in range(len(indexed) - len(wanted) + 1)
|
|
768
|
+
if wanted and [line for _, line in indexed[i:i + len(wanted)]] == wanted]
|
|
769
|
+
if len(hits) == 1:
|
|
770
|
+
start = indexed[hits[0]][0]
|
|
771
|
+
end = indexed[hits[0] + len(wanted) - 1][0] + 1
|
|
772
|
+
replacement = new_str
|
|
773
|
+
if source_lines[end - 1].endswith("\n") and not replacement.endswith("\n"):
|
|
774
|
+
replacement += "\n"
|
|
775
|
+
candidate = "".join(source_lines[:start]) + replacement + "".join(source_lines[end:])
|
|
776
|
+
valid, reason = validate_code_syntax(path, candidate)
|
|
777
|
+
if not valid:
|
|
778
|
+
return f"error: Edit would result in a syntax error in '{path}':\n{reason}"
|
|
779
|
+
# Re-enter the exact-match path so cache invalidation and normal
|
|
780
|
+
# post-edit processing remain identical.
|
|
781
|
+
return _edit_file(workdir, path, "".join(source_lines[start:end]), replacement)
|
|
760
782
|
# Suggest nearby text, but never apply a guessed replacement.
|
|
761
783
|
import difflib
|
|
762
784
|
lines = text.splitlines(keepends=True)
|
|
@@ -1452,5 +1474,5 @@ def make_dispatch(workdir: Path):
|
|
|
1452
1474
|
),
|
|
1453
1475
|
"load_skill": lambda a: _load_skill(workdir, str(a.get("name") or a.get("skill") or "")),
|
|
1454
1476
|
"list_skills": lambda a: _list_skills(workdir, a.get("filter") or a.get("query")),
|
|
1455
|
-
"complete_task": lambda a: f"
|
|
1477
|
+
"complete_task": lambda a: f"Completion requested; verification pending: {a.get('summary') or a.get('message') or a.get('result') or 'No summary provided.'}",
|
|
1456
1478
|
}
|
|
@@ -155,7 +155,7 @@ def create_vision_handler(model_path: Path, projectors: List[Path], formats: Any
|
|
|
155
155
|
system = self._caller_system
|
|
156
156
|
if self._caller_tools:
|
|
157
157
|
system += ("\n\n<tools>\n" + json.dumps(self._caller_tools)
|
|
158
|
-
+ "\n</tools>\nUse
|
|
158
|
+
+ "\n</tools>\nUse the response format specified above to call one of these tools.")
|
|
159
159
|
text, count = re.subn(r"(?s)(<\|im_start\|>system\n).*?(<\|im_end\|>)",
|
|
160
160
|
lambda match: match[1] + system + match[2], text, count=1)
|
|
161
161
|
if count != 1:
|
|
@@ -260,5 +260,5 @@ def test_technical_scope_policy_filtering_in_system_prompts():
|
|
|
260
260
|
|
|
261
261
|
# Offline prompt
|
|
262
262
|
prompt_offline = pb.build_system_prompt(Path("."), is_offline=True, complexity="low")
|
|
263
|
-
assert "
|
|
264
|
-
assert "
|
|
263
|
+
assert "software engineering assistant" in prompt_offline
|
|
264
|
+
assert "smallest targeted edit" in prompt_offline
|