alpiecode 10.10.8__tar.gz → 10.10.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. {alpiecode-10.10.8 → alpiecode-10.10.9}/PKG-INFO +1 -1
  2. {alpiecode-10.10.8 → alpiecode-10.10.9}/pyproject.toml +1 -1
  3. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/alpiecode.egg-info/PKG-INFO +1 -1
  4. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/alpiecode.egg-info/SOURCES.txt +2 -0
  5. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/__init__.py +1 -1
  6. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/assessment.py +1 -0
  7. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/backends/local_backend.py +1 -1
  8. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/blueprints.py +2 -0
  9. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/convergence.py +4 -0
  10. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/discovery.py +1 -6
  11. alpiecode-10.10.9/src/codeagent/execution_safety.py +52 -0
  12. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/executor.py +12 -3
  13. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/local_model.py +23 -3
  14. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/orchestrator.py +19 -5
  15. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/prompt.py +26 -12
  16. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/system1.py +4 -4
  17. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/tools.py +40 -69
  18. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_context_and_trajectory.py +4 -4
  19. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_deloop_and_sessions.py +6 -6
  20. alpiecode-10.10.9/test/test_execution_recovery.py +206 -0
  21. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_frontier_architecture.py +1 -1
  22. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_report_convergence.py +23 -5
  23. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_truncation_resilience.py +7 -14
  24. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_web_resilience_and_guardrails.py +3 -3
  25. {alpiecode-10.10.8 → alpiecode-10.10.9}/README.md +0 -0
  26. {alpiecode-10.10.8 → alpiecode-10.10.9}/setup.cfg +0 -0
  27. {alpiecode-10.10.8 → alpiecode-10.10.9}/setup.py +0 -0
  28. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/alpiecode/__init__.py +0 -0
  29. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/alpiecode.egg-info/dependency_links.txt +0 -0
  30. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/alpiecode.egg-info/entry_points.txt +0 -0
  31. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/alpiecode.egg-info/requires.txt +0 -0
  32. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/alpiecode.egg-info/top_level.txt +0 -0
  33. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/__main__.py +0 -0
  34. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/agent.py +0 -0
  35. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/backends/__init__.py +0 -0
  36. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/backends/base.py +0 -0
  37. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/backends/openai_backend.py +0 -0
  38. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/cache.py +0 -0
  39. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/capabilities.py +0 -0
  40. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/chat_tags.py +0 -0
  41. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/cli.py +0 -0
  42. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/client.py +0 -0
  43. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/compaction.py +0 -0
  44. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/config.py +0 -0
  45. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/context.py +0 -0
  46. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/diff_preview.py +0 -0
  47. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/doctor.py +0 -0
  48. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/dream_rsi.py +0 -0
  49. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/evaluation.py +0 -0
  50. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/git_ops.py +0 -0
  51. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/github.py +0 -0
  52. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/grounding.py +0 -0
  53. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/guardian.py +0 -0
  54. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/guardrails.py +0 -0
  55. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/ipython_ext.py +0 -0
  56. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/lifecycle.py +0 -0
  57. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/media.py +0 -0
  58. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/memory.py +0 -0
  59. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/metrics.py +0 -0
  60. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/onboarding.py +0 -0
  61. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/paths.py +0 -0
  62. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/progress.py +0 -0
  63. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/project_template.py +0 -0
  64. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/rephraser.py +0 -0
  65. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/server.py +0 -0
  66. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/session.py +0 -0
  67. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/accessibility-audit/SKILL.md +0 -0
  68. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/accessibility-testing/SKILL.md +0 -0
  69. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/accessibility-ui-components/SKILL.md +0 -0
  70. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/agentic-workflows/SKILL.md +0 -0
  71. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/api-design/SKILL.md +0 -0
  72. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/architecture-design/SKILL.md +0 -0
  73. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/backend-engineering/SKILL.md +0 -0
  74. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/browser-automation/SKILL.md +0 -0
  75. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/cli-development/SKILL.md +0 -0
  76. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/cloud-infrastructure/SKILL.md +0 -0
  77. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/code-generation/SKILL.md +0 -0
  78. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/code-review/SKILL.md +0 -0
  79. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/codebase-onboarding/SKILL.md +0 -0
  80. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/cost-optimization/SKILL.md +0 -0
  81. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/data-analysis/SKILL.md +0 -0
  82. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/data-engineering/SKILL.md +0 -0
  83. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/database-engineering/SKILL.md +0 -0
  84. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/dependency-management/SKILL.md +0 -0
  85. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/dependency-security/SKILL.md +0 -0
  86. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/dependency-upgrades/SKILL.md +0 -0
  87. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/devops-ci-cd/SKILL.md +0 -0
  88. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/docker-containers/SKILL.md +0 -0
  89. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/documentation/SKILL.md +0 -0
  90. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/documentation-site/SKILL.md +0 -0
  91. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/e2e-testing/SKILL.md +0 -0
  92. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/error-handling-resilience/SKILL.md +0 -0
  93. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/feature-development/SKILL.md +0 -0
  94. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/frontend-engineering/SKILL.md +0 -0
  95. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/git-workflow/SKILL.md +0 -0
  96. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/incident-response/SKILL.md +0 -0
  97. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/legacy-code-modernization/SKILL.md +0 -0
  98. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/llm-application-engineering/SKILL.md +0 -0
  99. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/localization-i18n/SKILL.md +0 -0
  100. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/mcp-server-development/SKILL.md +0 -0
  101. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/migration-engineering/SKILL.md +0 -0
  102. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/mobile-development/SKILL.md +0 -0
  103. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/model-evaluation/SKILL.md +0 -0
  104. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/nodejs-services/SKILL.md +0 -0
  105. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/observability/SKILL.md +0 -0
  106. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/performance-optimization/SKILL.md +0 -0
  107. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/privacy-data-protection/SKILL.md +0 -0
  108. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/prompt-engineering/SKILL.md +0 -0
  109. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/python-engineering/SKILL.md +0 -0
  110. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/rag-retrieval/SKILL.md +0 -0
  111. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/react-engineering/SKILL.md +0 -0
  112. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/release-management/SKILL.md +0 -0
  113. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/requirements-analysis/SKILL.md +0 -0
  114. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/responsive-design/SKILL.md +0 -0
  115. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/safe-refactoring/SKILL.md +0 -0
  116. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/secure-coding/SKILL.md +0 -0
  117. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/systematic-debugging/SKILL.md +0 -0
  118. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/technical-planning/SKILL.md +0 -0
  119. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/technical-research/SKILL.md +0 -0
  120. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/technical-writing/SKILL.md +0 -0
  121. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/test-engineering/SKILL.md +0 -0
  122. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/tool-integration/SKILL.md +0 -0
  123. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/typescript-engineering/SKILL.md +0 -0
  124. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/visual-regression-testing/SKILL.md +0 -0
  125. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/web-performance/SKILL.md +0 -0
  126. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/web-security-testing/SKILL.md +0 -0
  127. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills/workflow-automation/SKILL.md +0 -0
  128. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/skills.py +0 -0
  129. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/slash.py +0 -0
  130. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/subagent.py +0 -0
  131. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/updater.py +0 -0
  132. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/verifier.py +0 -0
  133. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/vision.py +0 -0
  134. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/vscode_installer.py +0 -0
  135. {alpiecode-10.10.8 → alpiecode-10.10.9}/src/codeagent/walkthrough.py +0 -0
  136. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_adaptive_resilience.py +0 -0
  137. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_chat_tags_and_offline_multimodal.py +0 -0
  138. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_cli_ui.py +0 -0
  139. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_dream_rsi.py +0 -0
  140. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_gpu_detection.py +0 -0
  141. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_lifecycle_and_portfolio.py +0 -0
  142. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_local_model_download.py +0 -0
  143. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_memory_optimization.py +0 -0
  144. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_non_thinking_and_local_stream.py +0 -0
  145. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_onboarding.py +0 -0
  146. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_project_templates.py +0 -0
  147. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_release_foundations.py +0 -0
  148. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_security_config.py +0 -0
  149. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_skills_engine.py +0 -0
  150. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_slash_and_diff.py +0 -0
  151. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_subagents.py +0 -0
  152. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_task_assessment.py +0 -0
  153. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_token_economy_and_256k.py +0 -0
  154. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_verifier.py +0 -0
  155. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_visual_grounding.py +0 -0
  156. {alpiecode-10.10.8 → alpiecode-10.10.9}/test/test_walkthrough.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alpiecode
3
- Version: 10.10.8
3
+ Version: 10.10.9
4
4
  Summary: AlpieCode
5
5
  Requires-Python: >=3.9
6
6
  Requires-Dist: huggingface_hub>=0.20.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "alpiecode"
7
- version = "10.10.8"
7
+ version = "10.10.9"
8
8
  description = "AlpieCode"
9
9
  requires-python = ">=3.9"
10
10
  dependencies = [
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alpiecode
3
- Version: 10.10.8
3
+ Version: 10.10.9
4
4
  Summary: AlpieCode
5
5
  Requires-Python: >=3.9
6
6
  Requires-Dist: huggingface_hub>=0.20.0
@@ -27,6 +27,7 @@ src/codeagent/discovery.py
27
27
  src/codeagent/doctor.py
28
28
  src/codeagent/dream_rsi.py
29
29
  src/codeagent/evaluation.py
30
+ src/codeagent/execution_safety.py
30
31
  src/codeagent/executor.py
31
32
  src/codeagent/git_ops.py
32
33
  src/codeagent/github.py
@@ -129,6 +130,7 @@ test/test_cli_ui.py
129
130
  test/test_context_and_trajectory.py
130
131
  test/test_deloop_and_sessions.py
131
132
  test/test_dream_rsi.py
133
+ test/test_execution_recovery.py
132
134
  test/test_frontier_architecture.py
133
135
  test/test_gpu_detection.py
134
136
  test/test_lifecycle_and_portfolio.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.8"
20
+ __version__ = "10.10.9"
21
21
 
22
22
  def run(task: str, workdir: str = ".", reasoning_level: str = "thinking", **kwargs):
23
23
  """Run an autonomous coding task programmatically."""
@@ -142,6 +142,7 @@ _EXPLAIN_INDICATORS = [
142
142
  ]
143
143
 
144
144
  _DEBUG_INDICATORS = [
145
+ r"\b(fix|repair)\b",
145
146
  r"\b(debug|diagnose|troubleshoot|trace|fix\s+bug|fix\s+the\s+bug)\b",
146
147
  r"\b(find\s+the\s+bug|find\s+the\s+issue|why\s+is\s+this\s+failing)\b",
147
148
  r"\b(traceback|stacktrace|exception|segfault|segmentation\s+fault)\b",
@@ -804,7 +804,7 @@ class LocalBackend:
804
804
 
805
805
  def shutdown(self) -> None:
806
806
  if self._model:
807
- self._model._llm = None
807
+ self._model.close()
808
808
  self._model = None
809
809
 
810
810
 
@@ -491,6 +491,8 @@ def resolve_domain_blueprint(task: str, repo: Optional[Dict] = None, intent: str
491
491
  Route task intent to the optimal Domain Blueprint.
492
492
  Runs deterministically in < 1ms.
493
493
  """
494
+ if intent in ("debug", "modify", "refactor"):
495
+ return None # Existing-project repairs must not invent scaffold deliverables.
494
496
  task_lower = task.lower().strip()
495
497
 
496
498
  # 0. Developer Portfolio Websites
@@ -16,6 +16,10 @@ class ConvergenceGuard:
16
16
  or args.get("filename") or args.get("command") or "")
17
17
  key = json.dumps([name, target])
18
18
  if failed:
19
+ from .execution_safety import infrastructure_failure
20
+ infrastructure = infrastructure_failure(output)
21
+ if infrastructure or '"error_kind": "shell_unavailable"' in output:
22
+ return "Stopped: shell infrastructure is unavailable; no application command ran. Repair the shell configuration before retrying."
19
23
  # Ignore changing generated content: the same rejection is no progress.
20
24
  previous, count = self._failures.get(key, (None, 0))
21
25
  count = count + 1 if previous == output else 1
@@ -215,12 +215,7 @@ def _detect_shell(os_name: str) -> str:
215
215
  """Detect available shell, aligned with tools.py execution path."""
216
216
 
217
217
  if os_name == "windows":
218
- # Check if bash binary exists (Git Bash / MSYS)
219
- if shutil.which("bash"):
220
- return "bash"
221
- if _is_wsl_available():
222
- return "wsl"
223
- # Fallback to PowerShell
218
+ # Native Windows execution must not accidentally select the WSL launcher.
224
219
  if shutil.which("powershell") or shutil.which("pwsh"):
225
220
  return "powershell"
226
221
  return "cmd"
@@ -0,0 +1,52 @@
1
+ """Shell selection and detection of unusable model generations."""
2
+
3
+ import re
4
+ import shutil
5
+ import json
6
+ from typing import List, Optional
7
+
8
+
9
+ def shell_command(command: str, windows: bool) -> List[str]:
10
+ if windows:
11
+ # Windows' bash.exe can be a WSL launcher with no installed Linux shell.
12
+ # Keep commands in the native workspace and its active virtual environment.
13
+ powershell = shutil.which("pwsh") or shutil.which("powershell")
14
+ if powershell:
15
+ script = "$ErrorActionPreference = 'Stop'; " + command + "; if ($LASTEXITCODE) { exit $LASTEXITCODE }"
16
+ return [powershell, "-NoProfile", "-NonInteractive", "-Command", script]
17
+ return ["cmd.exe", "/d", "/s", "/c", command]
18
+ return [shutil.which("bash") or "/bin/sh", "-c", command]
19
+
20
+
21
+ def infrastructure_failure(output: str) -> Optional[str]:
22
+ try:
23
+ result, _ = json.JSONDecoder().raw_decode(output.lstrip())
24
+ if isinstance(result, dict) and result.get("error_kind") == "shell_unavailable":
25
+ return "shell_unavailable: command execution could not start"
26
+ except (ValueError, TypeError):
27
+ pass
28
+ lower = output.lower()
29
+ if "execvpe(/bin/bash) failed" in lower or ("wsl" in lower and "createprocesscommon" in lower):
30
+ return "shell_unavailable: WSL could not start /bin/bash; no project command ran"
31
+ return None
32
+
33
+
34
+ class GenerationGuard:
35
+ """Reject degenerate repeated text before any partial tool call is parsed."""
36
+ def __init__(self) -> None:
37
+ self.tail = ""
38
+ self.pending = 0
39
+
40
+ def feed(self, text: str) -> None:
41
+ # Non-streaming tool arguments must be checked throughout, not just at the end.
42
+ if len(text) > 512:
43
+ for offset in range(0, len(text), 512):
44
+ self.feed(text[offset:offset + 512])
45
+ return
46
+ self.tail = (self.tail + text)[-8192:]
47
+ self.pending += len(text)
48
+ if self.pending < 128:
49
+ return
50
+ self.pending = 0
51
+ if re.search(r"(.{24,400}?)\1{5,}", self.tail, re.S):
52
+ raise RuntimeError("Generation stopped: repeated output detected. No partial tool call was executed; task remains unverified.")
@@ -183,6 +183,9 @@ def parse_text_tool_calls(text: str) -> List[dict]:
183
183
  def _parse_error_hint(stderr: str, stdout: str) -> str:
184
184
  """Parse common error patterns from bash output and return a targeted hint."""
185
185
  combined = (stderr + " " + stdout).strip()
186
+ from .execution_safety import infrastructure_failure
187
+ if infrastructure_failure(combined):
188
+ return "Shell startup failed before the application ran. Repair the shell configuration; do not modify application code to address this error."
186
189
  if not combined:
187
190
  return ""
188
191
 
@@ -450,13 +453,16 @@ class ToolExecutor:
450
453
  )
451
454
  else:
452
455
  # Stage 2: Sequential mutating tools (write_file, edit_file, bash)
456
+ infrastructure_blocked = False
453
457
  for tc in mut_calls:
454
458
  if on_tool_start:
455
459
  on_tool_start(tc.name, tc.arguments)
456
460
  t0 = time.monotonic()
457
461
  safe_args = _normalize_tool_arguments(tc.arguments)
458
462
  fn = self.dispatch.get(tc.name)
459
- if fn:
463
+ if infrastructure_blocked:
464
+ res_str = "error: Skipped because shell startup failed earlier in this batch. No action was executed."
465
+ elif fn:
460
466
  try:
461
467
  res_str = str(fn(safe_args))
462
468
  except Exception as e:
@@ -464,6 +470,9 @@ class ToolExecutor:
464
470
  else:
465
471
  res_str = f"error: Unknown tool '{tc.name}'"
466
472
  elapsed = (time.monotonic() - t0) * 1000
473
+ from .execution_safety import infrastructure_failure
474
+ if tc.name == "bash" and infrastructure_failure(res_str):
475
+ infrastructure_blocked = True
467
476
 
468
477
  # Clear passed verification set whenever code files are written or edited
469
478
  if tc.name in ("write_file", "edit_file", "apply_patch"):
@@ -478,7 +487,7 @@ class ToolExecutor:
478
487
  res_str += (
479
488
  f"\n\n🛑 REPEATED TOOL CALL LOOP DETECTED (attempt #{repeat_count}). "
480
489
  f"You have already executed '{tc.name}' with these exact parameters {repeat_count} times in a row. "
481
- "All checks have passed. Do NOT run this tool again. Output your final summary starting with: DONE: <summary>."
490
+ "Do NOT repeat this tool call. Inspect the actual results; do not claim checks passed without successful verification."
482
491
  )
483
492
 
484
493
  # Repetitive verification sequence guard
@@ -486,7 +495,7 @@ class ToolExecutor:
486
495
  cmd_str = safe_args.get("command", "").strip()
487
496
  norm_cmd = re.sub(r"\s*\|\s*(?:head|tail|grep|sed|less|cat)\b.*", "", cmd_str)
488
497
  norm_cmd = re.sub(r"\s*2>&1\s*", " ", norm_cmd).strip()
489
- if norm_cmd and norm_cmd in self.successful_bash_commands:
498
+ if norm_cmd and norm_cmd in self.successful_bash_commands and '"exit_code": 0' in res_str:
490
499
  res_str = (
491
500
  "{\"stdout\": \"Check already verified with exit code 0. Deliverables ready.\", \"stderr\": \"\", \"exit_code\": 0}"
492
501
  "\n\n🛑 CIRCUIT BREAKER TRIGGERED: This verification check has already passed with exit code 0, "
@@ -559,6 +559,13 @@ class LocalModel:
559
559
  self.model_path = download_model(self.repo_id, token=self.token)
560
560
  return self.model_path
561
561
 
562
+ def close(self) -> None:
563
+ import atexit
564
+ atexit.unregister(self.close)
565
+ llm, self._llm = self._llm, None
566
+ if llm is not None:
567
+ llm.close()
568
+
562
569
  def load(self):
563
570
  """Load the model into memory via llama-cpp-python."""
564
571
  if self._llm is not None:
@@ -681,6 +688,8 @@ class LocalModel:
681
688
 
682
689
  try:
683
690
  self._llm = Llama(**llama_kwargs)
691
+ import atexit
692
+ atexit.register(self.close)
684
693
  # In-Memory KV Prompt Prefix Caching for instant Turn 2+ speedup
685
694
  try:
686
695
  import llama_cpp
@@ -826,14 +835,25 @@ class LocalModel:
826
835
  params["tool_choice"] = kwargs.get("tool_choice", "auto")
827
836
 
828
837
  def _safe_stream_generator():
838
+ from .execution_safety import GenerationGuard
839
+ guard = GenerationGuard()
829
840
  cur_max = params["max_tokens"]
830
841
  while True:
831
842
  params["max_tokens"] = cur_max
832
843
  try:
833
844
  gen = llm.create_chat_completion(**params)
834
- first_chunk = next(gen)
835
- yield first_chunk
836
- yield from gen
845
+ try:
846
+ for chunk in gen:
847
+ for choice in chunk.get("choices", []):
848
+ delta = choice.get("delta") or {}
849
+ guard.feed(delta.get("content") or "")
850
+ for call in delta.get("tool_calls") or []:
851
+ guard.feed((call.get("function") or {}).get("arguments") or "")
852
+ yield chunk
853
+ finally:
854
+ close = getattr(gen, "close", None)
855
+ if close:
856
+ close()
837
857
  return
838
858
  except ValueError as ve:
839
859
  err_msg = str(ve)
@@ -113,7 +113,7 @@ def _check_tool_results_had_error(results) -> bool:
113
113
  if name == "bash":
114
114
  try:
115
115
  clean_json = content.split("\n", 1)[-1] if content.startswith("⚠️") else content
116
- data = json.loads(clean_json)
116
+ data, _ = json.JSONDecoder().raw_decode(clean_json.lstrip())
117
117
  if isinstance(data, dict):
118
118
  if data.get("exit_code", 0) != 0:
119
119
  return True
@@ -420,6 +420,13 @@ class AgentOrchestrator:
420
420
 
421
421
  # Prepend explicit positional blueprint directive so Turn 1 adheres to the target architecture
422
422
  bp = getattr(task_context, "blueprint", None)
423
+ if task_context.intent in ("modify", "debug", "refactor"):
424
+ effective_task = (
425
+ "[PROJECT ENHANCEMENT DIRECTIVE: EXISTING CODEBASE]\n"
426
+ "NON-DESTRUCTIVE WORKFLOW: Locate and read the relevant implementation, reproduce the issue, "
427
+ "and use targeted edits. Preserve existing behavior. Do not invent replacement application "
428
+ "files or treat shell startup failures as source-code bugs.\n\n" + effective_task
429
+ )
423
430
  if bp:
424
431
  bp_type = getattr(bp, "blueprint_type", None)
425
432
  is_existing_project = (
@@ -697,8 +704,15 @@ class AgentOrchestrator:
697
704
  # ── Stall Detection & Corrective Intervention ──
698
705
  if progress_monitor.is_stalled(threshold=3):
699
706
  advice = progress_monitor.get_stall_advice()
707
+ if task_context.intent in ("debug", "modify", "refactor"):
708
+ advice = (
709
+ "[SYSTEM - PROGRESS MONITOR] Inspection is repeating without progress. "
710
+ "Identify the missing evidence and inspect a different relevant source or reproduce the defect. "
711
+ "Make a targeted edit only when supported by the evidence. If blocked, explain why; "
712
+ "do not create a replacement application or claim verification succeeded."
713
+ )
700
714
  uncreated = [f for f in named_deliverables if f not in session_touched_files]
701
- if uncreated:
715
+ if uncreated and task_context.intent == "create":
702
716
  advice += f"\nNote: The following files requested in the task have not been created yet: {', '.join(uncreated)}. Create them now using write_file."
703
717
  session.context.add_user_message(advice)
704
718
  yield AgentEvent("stall_intervention", {
@@ -710,9 +724,9 @@ class AgentOrchestrator:
710
724
  if progress_monitor.stall_interventions >= 3:
711
725
  session.context.add_user_message(
712
726
  "[SYSTEM DIRECTIVE] Multiple stall interventions have detected repetitive inspection without code modifications. "
713
- "Do NOT continue reading or grepping files. You must take active corrective action immediately: "
714
- "use edit_file to fix errors in existing source files, or write_file to produce deliverables, "
715
- "then compile/run to verify. Do not output DONE until the code compiles cleanly."
727
+ "Find the missing evidence or report the blocking condition. For repairs, inspect the existing source "
728
+ "and use edit_file only after identifying the root cause. Do not invent replacement applications "
729
+ "or change source code to work around shell startup failures. Report verification honestly."
716
730
  )
717
731
 
718
732
  # ── Turn-Level Adaptive Reasoning Dynamics ──
@@ -181,7 +181,7 @@ You write complete, working code in a single pass and verify it by running it.
181
181
  ## Technical Focus Scope
182
182
  This session is strictly focused on software engineering and technical implementation. For purely technical tasks, bypass all non-applicable geopolitical, territorial, and sovereign policy deliberation in internal reasoning traces. Focus internal reasoning exclusively on software architecture, code correctness, execution efficiency, and explicit format constraints.
183
183
 
184
- # CRITICAL RULE: WRITE CODE FIRST
184
+ # CRITICAL RULE: UNDERSTAND THE TASK BEFORE EDITING
185
185
 
186
186
  # CRITICAL: FAST TESTING & EXECUTION (NO REAL SLEEP)
187
187
  - NEVER use real `time.sleep()` in unit tests for timers, rate limiters, token buckets, or delays.
@@ -189,12 +189,12 @@ This session is strictly focused on software engineering and technical implement
189
189
  - ALWAYS use virtual clocks or mock time: `unittest.mock.patch('time.monotonic')`, `unittest.mock.patch('time.time')`, or pass a custom `time_func` to advance time instantaneously.
190
190
  - All unit tests MUST finish in under 0.05 seconds.
191
191
 
192
- Your #1 priority is to PRODUCE CODE on Turn 1. Do NOT explore, list files, \
193
- or read project structure before writing code unless you are modifying an \
194
- existing file. For new projects, WRITE THE COMPLETE CODE IMMEDIATELY.
192
+ For existing projects, inspect the relevant source and reproduce the issue before editing.
193
+ Apply minimal edits and preserve existing behavior. Shell startup failures are environment
194
+ failures, not evidence of application bugs. Never invent replacement applications to bypass them.
195
195
 
196
196
  ## Workflow
197
- 1. **WRITE**: Use write_file to create complete, working code on Turn 1
197
+ 1. **INSPECT**: Read relevant existing source; use edit_file for repairs and write_file for new files
198
198
  2. **RUN**: Use bash to test immediately after writing (for interactive scripts, test functions non-interactively, e.g. `python3 -c "from module import ...; ..."` or write unit tests)
199
199
  3. **FIX**: If execution fails, read the error, use edit_file to fix, re-run
200
200
  4. **DONE**: When everything works, output: DONE: <summary>
@@ -492,14 +492,15 @@ When the analysis/report is complete, provide the final answer and stop using to
492
492
  ## Technical Focus Scope
493
493
  Strictly software engineering. For technical tasks, bypass all non-applicable geopolitical policy deliberation in internal reasoning traces. Focus purely on technical implementation, correctness, and execution.
494
494
 
495
- # CRITICAL RULE: WRITE CODE FIRST
495
+ # CRITICAL RULE: FOLLOW THE TASK SCOPE
496
496
 
497
497
  # CRITICAL: FAST TESTING & EXECUTION (NO REAL SLEEP)
498
498
  - NEVER use real `time.sleep()` in unit tests for timers, rate limiters, or delays.
499
499
  - ALWAYS use virtual clocks or mock time: `unittest.mock.patch('time.monotonic')`, `unittest.mock.patch('time.time')`.
500
500
  - All unit tests MUST finish in under 0.05 seconds.
501
501
 
502
- - For single-file tasks, write complete code on Turn 1. Verify by running it.
502
+ - For repairs, inspect the existing code and use edit_file for minimal changes. Preserve unrelated behavior.
503
+ - For new single-file programs, write complete code and verify by running it.
503
504
  - For multi-file frontend web projects (when explicitly asked to build an HTML/CSS/JS website):
504
505
  * Write EXACTLY ONE complete file per turn (Turn 1: index.html, Turn 2: styles.css, Turn 3: app.js).
505
506
  * index.html: Semantic HTML5, navbar with #theme-toggle button, modals with #close-btn, forms (#rsvp-form), explicit IDs.
@@ -510,7 +511,7 @@ Strictly software engineering. For technical tasks, bypass all non-applicable ge
510
511
  Rules:
511
512
  1. Write clean code using standard library or vanilla frontend (HTML/CSS/JS).
512
513
  2. NEVER run pip, uv pip, or package install commands — they will fail offline.
513
- 3. For testing, use `python3 -m unittest` or `node --check <file>` for JavaScript.
514
+ 3. Use the project's existing test runner if installed, including pytest offline. Report unavailable dependencies honestly.
514
515
  4. Output tool calls:
515
516
  <tool_call>
516
517
  {"name": "write_file", "arguments": {"path": "<file>", "content": "<full_code>"}}
@@ -518,7 +519,7 @@ Rules:
518
519
  <tool_call>
519
520
  {"name": "bash", "arguments": {"command": "<command>"}}
520
521
  </tool_call>
521
- 5. Always create the files and run them to verify.
522
+ 5. Verify changes with relevant tests; do not create replacement applications for repair tasks.
522
523
  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.
523
524
  7. When done and verified, output: DONE: <summary>.
524
525
  """
@@ -534,7 +535,7 @@ You write complete, working code and verify it through direct execution.
534
535
  This session is strictly focused on software engineering and technical architecture. For purely technical tasks, bypass all non-applicable geopolitical, territorial, and sovereign policy deliberation in internal reasoning traces. Focus internal reasoning exclusively on software architecture, code correctness, execution efficiency, and explicit format constraints.
535
536
 
536
537
  # CRITICAL OPERATING PRINCIPLES
537
- 1. PRODUCE COMPLETE CODE FIRST: Your #1 priority is to implement complete code on Turn 1. Never output placeholders, stubs, or TODOs.
538
+ 1. INSPECT BEFORE REPAIRING: For existing projects, read the relevant source, reproduce the issue, and make minimal edits. Create new implementations only when requested. Never output placeholders, stubs, or TODOs.
538
539
  2. SEQUENTIAL MULTI-FILE CONTRACT: For multi-file projects, create files in logical dependency order, emitting EXACTLY ONE complete file per turn to prevent output truncation and guarantee 100% valid syntax.
539
540
  3. VERIFY VIA EXECUTION: Verify your changes by running tests, compiling, or checking syntax (e.g. node --check for JS, python3 -m unittest for Python).
540
541
  4. COMPLETION: Once all deliverables are implemented and verified, call the `complete_task` tool or output `DONE: <summary>`.
@@ -610,6 +611,13 @@ SKILL_TECHNICAL_RESEARCH = """\
610
611
 
611
612
  def select_jit_skills(task: str, task_context=None, complexity: str = "low") -> List[str]:
612
613
  """Select targeted domain skills dynamically to eliminate attention dilution."""
614
+ if getattr(task_context, "intent", "") in ("debug", "modify", "refactor"):
615
+ return [
616
+ "## Existing Project Repair\n"
617
+ "Use the existing framework, files, dependencies and test runner. Inspect the relevant code "
618
+ "and failure evidence before editing. Preserve CRUD behavior, interfaces and unrelated UI. "
619
+ "Add focused regression tests for the reproduced defect; do not scaffold a replacement application."
620
+ ]
613
621
  skills = []
614
622
  task_lower = (task or "").lower()
615
623
  bp = getattr(task_context, "blueprint", None)
@@ -790,7 +798,7 @@ WSL_RULES = """\
790
798
 
791
799
  POWERSHELL_RULES = """\
792
800
  ## Shell Environment: PowerShell (Windows)
793
- - Use `;` to chain commands, NOT `&&` (PowerShell does not support `&&`)
801
+ - Run verification commands separately. Windows PowerShell 5.1 does not support `&&`; replacing it with `;` loses failure short-circuiting.
794
802
  - Use `$env:VAR = "value"` for environment variables, NOT `export VAR=value`
795
803
  - Use `python` (not `python3`)
796
804
  - Do NOT use `echo -e` or ANSI escapes -- use `Write-Output`
@@ -917,7 +925,13 @@ class PromptBuilder:
917
925
  "If identity is uncertain, ask for clarification before recommending a purchase.\n"
918
926
  )
919
927
  if is_offline:
920
- prompt = evidence_policy + OFFLINE_SYSTEM_PROMPT
928
+ repair_policy = ("Repair task: read the relevant source before editing. Use edit_file for minimal fixes; "
929
+ "do not replace existing files or invent a new application. If execution is unavailable, "
930
+ "report the environment failure and leave verification unconfirmed.\n"
931
+ if task_context is not None and getattr(task_context, "intent", "") in ("debug", "modify", "refactor") else "")
932
+ shell = getattr(task_context, "shell", "bash")
933
+ shell_policy = SHELL_RULES_MAP.get(shell, "") if shell in ("powershell", "cmd") else ""
934
+ prompt = shell_policy + "\n" + evidence_policy + repair_policy + OFFLINE_SYSTEM_PROMPT
921
935
  if task_context is not None:
922
936
  shell = getattr(task_context, "shell", "bash")
923
937
  if shell in SHELL_RULES_MAP:
@@ -513,14 +513,14 @@ class System1Controller:
513
513
  directive=directive,
514
514
  )
515
515
 
516
- # 2. Truncation Interception: Preserve partial file and enforce continuation via append_file
516
+ # 2. Truncated mutations are rejected, so never assume partial content exists.
517
517
  if err_type == ErrorType.TRUNCATION and tool_name in ("write_file", "edit_file", "append_file"):
518
518
  target_name = target_file or str(tool_args.get("path") or tool_args.get("file") or "file")
519
519
  self.total_interventions += 1
520
520
  directive = (
521
- f"[SYSTEM 1 DIRECTIVE] Truncation checkpoint: '{target_name}' was safely preserved on disk up to the cutoff line. "
522
- f"Do NOT rewrite '{target_name}' from line 1 or reduce features. "
523
- f"Please call 'append_file' (or 'write_file' with append=true) with the remaining code lines to finish '{target_name}'."
521
+ f"[SYSTEM 1 DIRECTIVE] Truncation checkpoint: the incomplete change to '{target_name}' was rejected. "
522
+ "Read the current file if it exists, then submit a smaller complete targeted edit. "
523
+ "Do not assume partial generated content was saved or append to an imagined checkpoint."
524
524
  )
525
525
  return JevDecision(
526
526
  action=ActionCategory.RETRY_WITH_DIRECTIVE,