alpiecode 10.9.1__tar.gz → 10.9.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. {alpiecode-10.9.1 → alpiecode-10.9.2}/PKG-INFO +1 -1
  2. {alpiecode-10.9.1 → alpiecode-10.9.2}/pyproject.toml +1 -1
  3. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/alpiecode.egg-info/PKG-INFO +1 -1
  4. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/__init__.py +1 -1
  5. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/blueprints.py +61 -2
  6. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/orchestrator.py +62 -34
  7. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/prompt.py +10 -2
  8. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/verifier.py +194 -0
  9. {alpiecode-10.9.1 → alpiecode-10.9.2}/test/test_lifecycle_and_portfolio.py +14 -0
  10. {alpiecode-10.9.1 → alpiecode-10.9.2}/test/test_verifier.py +93 -0
  11. {alpiecode-10.9.1 → alpiecode-10.9.2}/README.md +0 -0
  12. {alpiecode-10.9.1 → alpiecode-10.9.2}/setup.cfg +0 -0
  13. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/alpiecode/__init__.py +0 -0
  14. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/alpiecode.egg-info/SOURCES.txt +0 -0
  15. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/alpiecode.egg-info/dependency_links.txt +0 -0
  16. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/alpiecode.egg-info/entry_points.txt +0 -0
  17. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/alpiecode.egg-info/requires.txt +0 -0
  18. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/alpiecode.egg-info/top_level.txt +0 -0
  19. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/agent.py +0 -0
  20. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/assessment.py +0 -0
  21. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/backends/__init__.py +0 -0
  22. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/backends/base.py +0 -0
  23. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/backends/local_backend.py +0 -0
  24. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/backends/openai_backend.py +0 -0
  25. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/cache.py +0 -0
  26. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/cli.py +0 -0
  27. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/client.py +0 -0
  28. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/compaction.py +0 -0
  29. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/config.py +0 -0
  30. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/context.py +0 -0
  31. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/diff_preview.py +0 -0
  32. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/discovery.py +0 -0
  33. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/doctor.py +0 -0
  34. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/dream_rsi.py +0 -0
  35. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/executor.py +0 -0
  36. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/git_ops.py +0 -0
  37. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/github.py +0 -0
  38. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/guardian.py +0 -0
  39. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/guardrails.py +0 -0
  40. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/ipython_ext.py +0 -0
  41. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/local_model.py +0 -0
  42. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/media.py +0 -0
  43. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/memory.py +0 -0
  44. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/metrics.py +0 -0
  45. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/paths.py +0 -0
  46. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/progress.py +0 -0
  47. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/project_template.py +0 -0
  48. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/rephraser.py +0 -0
  49. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/server.py +0 -0
  50. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/session.py +0 -0
  51. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/accessibility-audit/SKILL.md +0 -0
  52. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/accessibility-testing/SKILL.md +0 -0
  53. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/accessibility-ui-components/SKILL.md +0 -0
  54. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/agentic-workflows/SKILL.md +0 -0
  55. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/api-design/SKILL.md +0 -0
  56. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/architecture-design/SKILL.md +0 -0
  57. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/backend-engineering/SKILL.md +0 -0
  58. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/browser-automation/SKILL.md +0 -0
  59. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/cli-development/SKILL.md +0 -0
  60. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/cloud-infrastructure/SKILL.md +0 -0
  61. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/code-generation/SKILL.md +0 -0
  62. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/code-review/SKILL.md +0 -0
  63. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/codebase-onboarding/SKILL.md +0 -0
  64. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/cost-optimization/SKILL.md +0 -0
  65. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/data-analysis/SKILL.md +0 -0
  66. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/data-engineering/SKILL.md +0 -0
  67. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/database-engineering/SKILL.md +0 -0
  68. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/dependency-management/SKILL.md +0 -0
  69. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/dependency-security/SKILL.md +0 -0
  70. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/dependency-upgrades/SKILL.md +0 -0
  71. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/devops-ci-cd/SKILL.md +0 -0
  72. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/docker-containers/SKILL.md +0 -0
  73. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/documentation/SKILL.md +0 -0
  74. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/documentation-site/SKILL.md +0 -0
  75. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/e2e-testing/SKILL.md +0 -0
  76. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/error-handling-resilience/SKILL.md +0 -0
  77. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/feature-development/SKILL.md +0 -0
  78. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/frontend-engineering/SKILL.md +0 -0
  79. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/git-workflow/SKILL.md +0 -0
  80. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/incident-response/SKILL.md +0 -0
  81. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/legacy-code-modernization/SKILL.md +0 -0
  82. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/llm-application-engineering/SKILL.md +0 -0
  83. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/localization-i18n/SKILL.md +0 -0
  84. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/mcp-server-development/SKILL.md +0 -0
  85. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/migration-engineering/SKILL.md +0 -0
  86. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/mobile-development/SKILL.md +0 -0
  87. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/model-evaluation/SKILL.md +0 -0
  88. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/nodejs-services/SKILL.md +0 -0
  89. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/observability/SKILL.md +0 -0
  90. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/performance-optimization/SKILL.md +0 -0
  91. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/privacy-data-protection/SKILL.md +0 -0
  92. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/prompt-engineering/SKILL.md +0 -0
  93. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/python-engineering/SKILL.md +0 -0
  94. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/rag-retrieval/SKILL.md +0 -0
  95. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/react-engineering/SKILL.md +0 -0
  96. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/release-management/SKILL.md +0 -0
  97. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/requirements-analysis/SKILL.md +0 -0
  98. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/responsive-design/SKILL.md +0 -0
  99. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/safe-refactoring/SKILL.md +0 -0
  100. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/secure-coding/SKILL.md +0 -0
  101. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/systematic-debugging/SKILL.md +0 -0
  102. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/technical-planning/SKILL.md +0 -0
  103. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/technical-research/SKILL.md +0 -0
  104. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/technical-writing/SKILL.md +0 -0
  105. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/test-engineering/SKILL.md +0 -0
  106. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/tool-integration/SKILL.md +0 -0
  107. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/typescript-engineering/SKILL.md +0 -0
  108. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/visual-regression-testing/SKILL.md +0 -0
  109. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/web-performance/SKILL.md +0 -0
  110. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/web-security-testing/SKILL.md +0 -0
  111. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills/workflow-automation/SKILL.md +0 -0
  112. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/skills.py +0 -0
  113. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/slash.py +0 -0
  114. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/subagent.py +0 -0
  115. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/system1.py +0 -0
  116. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/tools.py +0 -0
  117. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/updater.py +0 -0
  118. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/vscode_installer.py +0 -0
  119. {alpiecode-10.9.1 → alpiecode-10.9.2}/src/codeagent/walkthrough.py +0 -0
  120. {alpiecode-10.9.1 → alpiecode-10.9.2}/test/test_adaptive_resilience.py +0 -0
  121. {alpiecode-10.9.1 → alpiecode-10.9.2}/test/test_cli_ui.py +0 -0
  122. {alpiecode-10.9.1 → alpiecode-10.9.2}/test/test_context_and_trajectory.py +0 -0
  123. {alpiecode-10.9.1 → alpiecode-10.9.2}/test/test_deloop_and_sessions.py +0 -0
  124. {alpiecode-10.9.1 → alpiecode-10.9.2}/test/test_dream_rsi.py +0 -0
  125. {alpiecode-10.9.1 → alpiecode-10.9.2}/test/test_local_model_download.py +0 -0
  126. {alpiecode-10.9.1 → alpiecode-10.9.2}/test/test_non_thinking_and_local_stream.py +0 -0
  127. {alpiecode-10.9.1 → alpiecode-10.9.2}/test/test_project_templates.py +0 -0
  128. {alpiecode-10.9.1 → alpiecode-10.9.2}/test/test_skills_engine.py +0 -0
  129. {alpiecode-10.9.1 → alpiecode-10.9.2}/test/test_slash_and_diff.py +0 -0
  130. {alpiecode-10.9.1 → alpiecode-10.9.2}/test/test_subagents.py +0 -0
  131. {alpiecode-10.9.1 → alpiecode-10.9.2}/test/test_task_assessment.py +0 -0
  132. {alpiecode-10.9.1 → alpiecode-10.9.2}/test/test_walkthrough.py +0 -0
  133. {alpiecode-10.9.1 → alpiecode-10.9.2}/test/test_web_resilience_and_guardrails.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alpiecode
3
- Version: 10.9.1
3
+ Version: 10.9.2
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.9.1"
7
+ version = "10.9.2"
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.9.1
3
+ Version: 10.9.2
4
4
  Summary: AlpieCode
5
5
  Requires-Python: >=3.9
6
6
  Requires-Dist: huggingface_hub>=0.20.0
@@ -17,7 +17,7 @@ Supports:
17
17
  from pathlib import Path
18
18
  from typing import Optional, Any, Dict
19
19
 
20
- __version__ = "10.9.1"
20
+ __version__ = "10.9.2"
21
21
 
22
22
  def run(task: str, workdir: str = ".", reasoning_level: str = "thinking", **kwargs):
23
23
  """Run an autonomous coding task programmatically."""
@@ -21,6 +21,7 @@ class BlueprintType(str, Enum):
21
21
  WEB_ANGULAR = "web_angular"
22
22
  WEB_GOLANG = "web_golang"
23
23
  PORTFOLIO = "portfolio"
24
+ EVENT_CELEBRATION = "event_celebration"
24
25
  CLI_SCRIPT = "cli_script"
25
26
  REST_API = "rest_api"
26
27
  NATIVE_CPP = "native_cpp"
@@ -76,10 +77,14 @@ def get_web_app_blueprint(task: str) -> DomainBlueprint:
76
77
  "Architecture: 100% Pure Vanilla Web Stack (HTML5 + CSS3 + Vanilla JavaScript IIFE). Fast, zero dependencies, zero build step, instant load.",
77
78
  "Design Aesthetic: Light-Mode-First Default (clean white/slate surfaces `#ffffff`/`#f8fafc`, rich dark slate text `#0f172a`, subtle 1px border dividers `#e2e8f0`, soft elevated card shadows). Modern, crisp, and professional (Apple/Stripe/Vercel standard).",
78
79
  "Dual-Theme Switch: Every website MUST include a Theme Toggle switch button in the header/navbar (`#theme-toggle`) with Sun ☀️ and Moon 🌙 SVG icons.",
79
- "Turn 1 (`index.html`): Write FIRST with rich semantic markup: Sticky Header/Navbar with brand, navigation links, and `#theme-toggle` button; Pre-rendered hero banner, responsive cards/containers, interactive forms, and modal structure. <html lang='en'> MUST NOT have data-theme='dark' or class='dark'. Initial page load MUST display Light Mode first! NEVER leave an empty body or empty `<div id='app'>`.",
80
+ "Turn 1 (`index.html`): Write FIRST with rich semantic markup: Sticky Header/Navbar with brand, navigation links, and `#theme-toggle` button; Pre-rendered hero banner, responsive cards/containers, interactive forms, and modal structure. Explicitly give IDs to all interactive elements to match the app.js contract: `#theme-toggle`, `#close-btn` (or `#modal-close`), `#modal-overlay`, `#rsvp-form`, `#invitation-card`. <html lang='en'> MUST NOT have data-theme='dark' or class='dark'. Initial page load MUST display Light Mode first! NEVER leave an empty body or empty `<div id='app'>`.",
80
81
  "Include an on-screen Error Boundary in `index.html` via `window.addEventListener('error', ...)` to display any JavaScript exceptions visually instead of a blank white screen.",
81
82
  "Turn 2 (`styles.css`): Modern, responsive CSS defining custom properties in `:root` (--bg: #f8fafc, --surface: #ffffff, --text: #0f172a, --text-muted: #64748b, --border: #e2e8f0, --primary: #2563eb, --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05)) and dark overrides strictly under `[data-theme='dark']` with smooth 200ms transitions. Body MUST use background-color: var(--bg); color: var(--text);. NEVER write an unconditional @media (prefers-color-scheme: dark) block that turns the site dark without the toggle.",
82
- "Turn 3 (`app.js`): Universal vanilla JavaScript IIFE `(function() { 'use strict'; ... })();`. Implement: 1) Theme toggle logic: initialize with `const saved = localStorage.getItem('theme') || 'light'; document.documentElement.setAttribute('data-theme', saved);` and add click listener on `#theme-toggle` to flip between 'light' and 'dark' and save to localStorage (DO NOT auto-switch to dark on load); 2) Interactive features (filtering, cart, modals, event handlers); 3) Form submission validation with visual toast/alert feedback. Keep `app.js` concise and modular (< 350 lines).",
83
+ "Turn 3 (`app.js`): Universal vanilla JavaScript IIFE `(function() { 'use strict'; ... })();`. "
84
+ "CRITICAL DEFENSIVE DOM ACCESS: In app.js, ALWAYS check element existence before adding event listeners or setting properties: "
85
+ "`const btn = document.getElementById('close-btn'); if (btn) { btn.addEventListener('click', ...); }` OR optional chaining `document.getElementById('close-btn')?.addEventListener('click', ...);`. "
86
+ "NEVER call .addEventListener directly without checking for null. "
87
+ "Implement: 1) Theme toggle logic: initialize with `const saved = localStorage.getItem('theme') || 'light'; document.documentElement.setAttribute('data-theme', saved);` and add click listener on `#theme-toggle` to flip between 'light' and 'dark' and save to localStorage (DO NOT auto-switch to dark on load); 2) Interactive features (invitation card animations, filtering, modals with `#close-btn`, event handlers); 3) Form submission validation with visual toast/alert feedback. Keep `app.js` concise and modular (< 350 lines).",
83
88
  "Visual Assets: Use `download_asset` or curated Unsplash CDN URLs / 100% clean inline SVGs for all imagery and icons to ensure ZERO 404 broken images.",
84
89
  "Write EXACTLY ONE complete file per turn in order (Turn 1: index.html, Turn 2: styles.css, Turn 3: app.js).",
85
90
  "Verify all files exist and validate JavaScript with `node --check app.js` before completing.",
@@ -426,6 +431,56 @@ def get_developer_portfolio_blueprint(task: str) -> DomainBlueprint:
426
431
  )
427
432
 
428
433
 
434
+ def get_event_celebration_blueprint(task: str) -> DomainBlueprint:
435
+ # Detect festival or event theme
436
+ theme_name = "Festive Celebration"
437
+ task_l = task.lower()
438
+ if "diwali" in task_l:
439
+ theme_name = "Diwali Celebration & Festival of Lights"
440
+ elif "christmas" in task_l:
441
+ theme_name = "Christmas & Holiday Celebration"
442
+ elif "new year" in task_l:
443
+ theme_name = "New Year Festive Celebration"
444
+ elif "wedding" in task_l:
445
+ theme_name = "Wedding Celebration & Invitation"
446
+
447
+ return DomainBlueprint(
448
+ name=f"Interactive Event Website ({theme_name})",
449
+ blueprint_type=BlueprintType.EVENT_CELEBRATION,
450
+ target_files=["index.html", "styles.css", "app.js"],
451
+ entry_point="index.html",
452
+ execution_runner="python3 -m http.server 8000 (view at http://localhost:8000)",
453
+ architecture_rules=[
454
+ "Design Aesthetic: Light-Mode-First Default (warm ivory/amber `#fffbeb` and clean white `#ffffff` surfaces, rich dark slate typography `#1e293b`, royal gold `#d97706` and warm amber `#b45309` festive accents, soft elevated card shadows). Clean, modern, luxury event standard.",
455
+ "Dual-Theme Switch: Sticky header/navbar MUST include accessible Theme Toggle button (`#theme-toggle`) with Sun ☀️ and Moon 🌙 SVG icons toggling dark mode (`#0f172a` midnight surfaces with glowing gold diya/lantern accents).",
456
+ "Turn 1 (`index.html`): Write FIRST with complete pre-rendered semantic HTML5: "
457
+ "1) Sticky Navbar with event brand, dates, and `#theme-toggle`; "
458
+ "2) Hero banner with greeting, festive countdown timer, and 'View Invitation' button; "
459
+ "3) Interactive 3D Invitation Card (`<div class='card-3d' id='invitation-card'>`) with `.card-front` (ornate festive border, diya/lantern SVG, headline) and `.card-back` (schedule, venue, and 'RSVP Now' button `#open-rsvp-btn`); "
460
+ "4) Atmospheric celebration canvas (`<canvas id='fx-canvas'></canvas>`) for subtle sparkles/fireworks; "
461
+ "5) Event highlights & schedule cards; "
462
+ "6) Interactive RSVP Modal (`<div id='modal-overlay' class='modal-overlay'>`) with card `#rsvp-modal`, close button `<button id='close-btn' class='close-btn'>&times;</button>`, and form `<form id='rsvp-form'>`; "
463
+ "7) Floating toast container (`<div id='toast-container'></div>`) for RSVP confirmation; "
464
+ "8) Error boundary script. All interactive elements MUST have explicit IDs.",
465
+ "Turn 2 (`styles.css`): Modern CSS using custom properties in `:root` (--bg: #ffffff, --surface: #fffbeb, --accent: #d97706, --text: #1e293b, --border: #fde68a, --shadow: 0 10px 25px -5px rgba(217, 119, 6, 0.15)) and dark mode under `[data-theme='dark']`. 3D card flip styles: `.card-container { perspective: 1000px; } .card-3d { transform-style: preserve-3d; transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1); } .card-3d.flipped { transform: rotateY(180deg); } .card-front, .card-back { backface-visibility: hidden; } .card-back { transform: rotateY(180deg); }`. Modal overlay with backdrop-blur. Responsive Flexbox/Grid.",
466
+ "Turn 3 (`app.js`): Vanilla JS IIFE: "
467
+ "1) Theme toggle logic: initialize with `const saved = localStorage.getItem('theme') || 'light'; document.documentElement.setAttribute('data-theme', saved);` and wire `#theme-toggle` click listener; "
468
+ "2) Interactive 3D card flip: click on `#invitation-card` or 'Flip Card' button toggles `.flipped` class; "
469
+ "3) Modal open/close: `#open-rsvp-btn` opens `#modal-overlay`, `#close-btn` and clicking overlay closes it; "
470
+ "4) RSVP form submission: `#rsvp-form` validates inputs and displays animated toast in `#toast-container`; "
471
+ "5) Canvas FX: 60 FPS lightweight sparkle/firework particle loop on `#fx-canvas` with auto-resize; "
472
+ "CRITICAL DEFENSIVE DOM ACCESS: In app.js, ALWAYS check element existence before adding listeners: `const btn = document.getElementById('close-btn'); if (btn) { btn.addEventListener('click', ...); }` OR `?.addEventListener(...)`.",
473
+ "Visual Assets: 100% clean inline vector SVGs for diyas, lanterns, sparklers, and icons. ZERO broken 404 images.",
474
+ ],
475
+ prohibitions=[
476
+ "NEVER default initial page load to dark mode.",
477
+ "NEVER call .addEventListener directly without checking if the element exists.",
478
+ "NEVER leave empty body or empty `<div id='app'>` without static pre-rendered HTML.",
479
+ "NEVER load heavy external CDN libraries (React, Babel, Vue, Angular) via `<script>`.",
480
+ ],
481
+ )
482
+
483
+
429
484
  # ── Blueprint Router ───────────────────────────────────────────────────
430
485
 
431
486
  def resolve_domain_blueprint(task: str, repo: Optional[Dict] = None, intent: str = "create") -> Optional[DomainBlueprint]:
@@ -439,6 +494,10 @@ def resolve_domain_blueprint(task: str, repo: Optional[Dict] = None, intent: str
439
494
  if any(kw in task_lower for kw in ("portfolio", "personal site", "personal website", "developer site", "resume website")):
440
495
  return get_developer_portfolio_blueprint(task)
441
496
 
497
+ # 0b. Event & Festive Celebration Websites
498
+ if any(kw in task_lower for kw in ("celebration", "festival", "diwali", "invitation", "holiday", "anniversary", "party website", "wedding")):
499
+ return get_event_celebration_blueprint(task)
500
+
442
501
  # 1. Autonomous Agent Systems
443
502
  if any(kw in task_lower for kw in ("create an agent", "build an agent", "code agent", "multi-agent", "autonomous agent", "agent system", "swarm")):
444
503
  return get_agent_synthesizer_blueprint(task)
@@ -368,11 +368,17 @@ class AgentOrchestrator:
368
368
  f" * DUAL THEME TOGGLE: Sticky navbar MUST include an accessible theme toggle button (<button id=\"theme-toggle\" class=\"theme-toggle\" aria-label=\"Toggle theme\">) with Sun ☀️ and Moon 🌙 SVG icons.\n"
369
369
  f" * CSS VARIABLES IN styles.css: Define light mode variables in :root (--bg: #f8fafc; --surface: #ffffff; --text: #0f172a; --border: #e2e8f0; --primary: #2563eb;) and dark mode strictly under [data-theme=\"dark\"] (--bg: #0b0f19; --surface: #111827; --text: #f9fafb; --border: #1f2937;) with smooth 200ms transitions. NEVER add an unconditional @media (prefers-color-scheme: dark) block that turns the site dark without the user's toggle!\n"
370
370
  f" * PERSISTENCE IN app.js: Initialize with `const saved = localStorage.getItem('theme') || 'light'; document.documentElement.setAttribute('data-theme', saved);`. Wire '#theme-toggle' click listener to toggle between 'light' and 'dark' and save to localStorage. DO NOT auto-dark on initial page load!\n"
371
+ f" * DEFENSIVE DOM ACCESS & ID CONTRACT (CRITICAL):\n"
372
+ f" 1) In index.html, give explicit IDs to ALL interactive elements: e.g. <button id=\"theme-toggle\">, <button id=\"close-btn\" class=\"close-btn\">, <form id=\"rsvp-form\">, <div id=\"modal-overlay\">.\n"
373
+ f" 2) In app.js, ALWAYS check element existence before adding event listeners or manipulating properties:\n"
374
+ f" `const closeBtn = document.getElementById('close-btn'); if (closeBtn) closeBtn.addEventListener('click', ...);`\n"
375
+ f" OR optional chaining: `document.getElementById('close-btn')?.addEventListener('click', ...);`.\n"
376
+ f" NEVER call `.addEventListener` directly on a bare selector without checking for null!\n"
371
377
  f" * 100% SVG ASSETS: Use inline clean vector SVGs for all icons, buttons, and logos. NEVER leave broken 404 images.\n"
372
378
  f"- SEQUENTIAL MULTI-FILE ORDER:\n"
373
- f" * Step 1 (Turn 1): Create '{bp.target_files[0]}' (index.html) with complete semantic structure, Navbar with brand and #theme-toggle, hero, content sections, and error boundary. Pure HTML5, NO React/Babel.\n"
379
+ f" * Step 1 (Turn 1): Create '{bp.target_files[0]}' (index.html) with complete semantic structure, Navbar with brand and #theme-toggle, hero, content sections, modals with #close-btn, and error boundary. Pure HTML5, NO React/Babel.\n"
374
380
  f" * Step 2: Implement '{bp.target_files[1]}' (styles.css) with CSS variables (:root light + [data-theme='dark']), responsive Grid/Flexbox, card hover lifts.\n"
375
- f" * Step 3: Implement '{bp.target_files[2]}' (app.js) with theme toggle logic, state handling, and interactive features.\n\n"
381
+ f" * Step 3: Implement '{bp.target_files[2]}' (app.js) with theme toggle logic, state handling, defensive DOM existence checks (if (btn) btn.addEventListener(...)), and interactive features.\n\n"
376
382
  )
377
383
  elif bp_type == "web_react":
378
384
  bp_directive = (
@@ -916,6 +922,27 @@ class AgentOrchestrator:
916
922
  })
917
923
  return
918
924
 
925
+ # ── Guard: In Re-Plan mode, forbid premature DONE without tool execution ──
926
+ if getattr(session, "_auto_verify_attempts", 0) > 0 and (not tool_calls or len(tool_calls) == 0):
927
+ replan_nudges = getattr(session, "_replan_tool_nudges", 0)
928
+ if replan_nudges < 2 and turn < safety_ceiling:
929
+ session._replan_tool_nudges = replan_nudges + 1
930
+ last_failure = getattr(session, "_last_verification_result", None)
931
+ failing_msg = last_failure.message if last_failure else "the detected verification error"
932
+ suggested = last_failure.suggested_action if last_failure else "Use edit_file or write_file."
933
+ session.context.add_user_message(
934
+ f"[RE-PLAN ACTION REQUIRED] You responded with 'DONE:' but did NOT execute any tool to apply the fix.\n"
935
+ f"The previous verification failure is still unresolved:\n{failing_msg}\n"
936
+ f"Action: {suggested}\n"
937
+ "You MUST execute edit_file or write_file to apply the fix NOW before you can mark the task as DONE."
938
+ )
939
+ yield AgentEvent("warning", {
940
+ "turn": turn,
941
+ "message": "Model declared DONE during re-plan without modifying files. Enforcing corrective tool execution.",
942
+ })
943
+ prior_turn_had_error = True
944
+ continue
945
+
919
946
  if resp.content:
920
947
  # Clean duplicate DONE: if repeated
921
948
  if resp.content.upper().count("DONE:") > 1:
@@ -932,38 +959,6 @@ class AgentOrchestrator:
932
959
  session.workdir, task, resp.content, session_touched_files, session_executed_commands, task_metrics, turn
933
960
  )
934
961
 
935
- # Generate and write real walkthrough.md file to the project workspace
936
- try:
937
- w_path = Path(session.workdir) / "walkthrough.md"
938
- w_content = generate_walkthrough_markdown(
939
- task=task,
940
- summary=resp.content,
941
- files=sorted(list(session_touched_files)),
942
- commands=session_executed_commands,
943
- workdir=session.workdir,
944
- task_context=task_context,
945
- )
946
- w_path.write_text(w_content, encoding="utf-8")
947
- session_touched_files.add("walkthrough.md")
948
- except Exception:
949
- pass
950
-
951
- yield AgentEvent("walkthrough", {
952
- "path": "walkthrough.md",
953
- "summary": resp.content,
954
- "files": sorted(list(session_touched_files)),
955
- "commands": session_executed_commands,
956
- })
957
-
958
- if any(f.endswith("index.html") or f == "index.html" for f in session_touched_files) or (Path(session.workdir) / "index.html").exists():
959
- html_p = Path(session.workdir) / "index.html"
960
- yield AgentEvent("web_preview", {
961
- "html_path": str(html_p.resolve()),
962
- "file_url": f"file://{html_p.resolve()}",
963
- "server_cmd": "python3 -m http.server 8000",
964
- "localhost_url": "http://localhost:8000",
965
- })
966
-
967
962
  # ── Component 1: Autonomous Verify-Before-Done Gate ──
968
963
  has_code_files = any(
969
964
  f.endswith((".py", ".js", ".ts", ".jsx", ".tsx", ".rs", ".go", ".java", ".c", ".cpp"))
@@ -997,6 +992,7 @@ class AgentOrchestrator:
997
992
 
998
993
  if not v_res.passed:
999
994
  session._auto_verify_attempts = verify_attempts + 1
995
+ session._last_verification_result = v_res
1000
996
  if session._auto_verify_attempts < 3:
1001
997
  replan_prompt = format_replan_directive(v_res, is_offline=is_offline)
1002
998
  session.context.add_user_message(replan_prompt)
@@ -1047,6 +1043,38 @@ class AgentOrchestrator:
1047
1043
 
1048
1044
  session._auto_verify_passed = True
1049
1045
 
1046
+ # Generate and write real walkthrough.md file to the project workspace (only after verification passes)
1047
+ try:
1048
+ w_path = Path(session.workdir) / "walkthrough.md"
1049
+ w_content = generate_walkthrough_markdown(
1050
+ task=task,
1051
+ summary=resp.content,
1052
+ files=sorted(list(session_touched_files)),
1053
+ commands=session_executed_commands,
1054
+ workdir=session.workdir,
1055
+ task_context=task_context,
1056
+ )
1057
+ w_path.write_text(w_content, encoding="utf-8")
1058
+ session_touched_files.add("walkthrough.md")
1059
+ except Exception:
1060
+ pass
1061
+
1062
+ yield AgentEvent("walkthrough", {
1063
+ "path": "walkthrough.md",
1064
+ "summary": resp.content,
1065
+ "files": sorted(list(session_touched_files)),
1066
+ "commands": session_executed_commands,
1067
+ })
1068
+
1069
+ if any(f.endswith("index.html") or f == "index.html" for f in session_touched_files) or (Path(session.workdir) / "index.html").exists():
1070
+ html_p = Path(session.workdir) / "index.html"
1071
+ yield AgentEvent("web_preview", {
1072
+ "html_path": str(html_p.resolve()),
1073
+ "file_url": f"file://{html_p.resolve()}",
1074
+ "server_cmd": "python3 -m http.server 8000",
1075
+ "localhost_url": "http://localhost:8000",
1076
+ })
1077
+
1050
1078
  # ── 9-Stage Loop: Stage 8 (Review) & Stage 9 (Report) ──
1051
1079
  yield AgentEvent("phase", {
1052
1080
  "stage": "review",
@@ -241,6 +241,10 @@ When creating or modifying multi-file projects (e.g. websites, full-stack apps,
241
241
  * Sticky Header/Navbar MUST include an accessible Theme Toggle button (`#theme-toggle`) with Sun ☀️ and Moon 🌙 SVG icons.
242
242
  * In `styles.css`: Define light mode tokens in `:root` (`--bg: #f8fafc`, `--surface: #ffffff`, `--text: #0f172a`, `--border: #e2e8f0`, `--primary: #2563eb;`, `--shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);`). Define dark mode tokens ONLY under `[data-theme="dark"]`. NEVER add an unconditional `@media (prefers-color-scheme: dark)` block that turns the site dark automatically without the toggle!
243
243
  * In `app.js`: Initialize theme cleanly with `const savedTheme = localStorage.getItem('theme') || 'light'; document.documentElement.setAttribute('data-theme', savedTheme);`. Default is ALWAYS 'light' if not saved. Attach a click listener to `#theme-toggle` to toggle between 'light' and 'dark', update `data-theme`, and save to `localStorage`. DO NOT auto-dark on page load!
244
+ * Defensive DOM Access & Contract (MANDATORY): In `app.js`, ALWAYS verify element existence before attaching listeners or mutating properties:
245
+ `const closeBtn = document.getElementById('close-btn'); if (closeBtn) closeBtn.addEventListener('click', ...);` OR optional chaining `document.getElementById('close-btn')?.addEventListener('click', ...);`.
246
+ NEVER call `.addEventListener` directly on a bare selector without checking for null!
247
+ In `index.html`, give explicit IDs to all interactive elements matching `app.js`: `#theme-toggle`, `#close-btn` (or `#modal-close`), `#rsvp-form`, `#modal-overlay`, `#invitation-card`.
244
248
  * Visual Polish: Modern system font stack (`-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif`), card hover lift (`transform: translateY(-2px)`), pill badges, styled buttons with hover states, and 100% inline SVG vector icons. ZERO broken 404 images!
245
249
  - **NEVER run `node <file>.jsx`**: Node.js does NOT execute JSX natively and will crash with `TypeError: Unknown file extension ".jsx"`. If using React, bundle it or use vanilla ES6 JavaScript which runs everywhere natively.
246
250
  - **Testing & Verification**:
@@ -382,6 +386,10 @@ For multi-file projects, build in dependency order, emitting ONE complete file p
382
386
  * Sticky Header/Navbar MUST include an accessible Theme Toggle button (`#theme-toggle`) with Sun ☀️ and Moon 🌙 SVG icons.
383
387
  * In `styles.css`: Define light mode tokens in `:root` (`--bg: #f8fafc`, `--surface: #ffffff`, `--text: #0f172a`, `--border: #e2e8f0`, `--primary: #2563eb;`, `--shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);`). Define dark mode tokens ONLY under `[data-theme="dark"]`. NEVER add an unconditional `@media (prefers-color-scheme: dark)` block that turns the site dark automatically without the toggle!
384
388
  * In `app.js`: Initialize theme cleanly with `const savedTheme = localStorage.getItem('theme') || 'light'; document.documentElement.setAttribute('data-theme', savedTheme);`. Default is ALWAYS 'light' if not saved. Attach a click listener to `#theme-toggle` to toggle between 'light' and 'dark', update `data-theme`, and save to `localStorage`. DO NOT auto-dark on page load!
389
+ * Defensive DOM Access & Contract (MANDATORY): In `app.js`, ALWAYS verify element existence before attaching listeners or mutating properties:
390
+ `const closeBtn = document.getElementById('close-btn'); if (closeBtn) closeBtn.addEventListener('click', ...);` OR optional chaining `document.getElementById('close-btn')?.addEventListener('click', ...);`.
391
+ NEVER call `.addEventListener` directly on a bare selector without checking for null!
392
+ In `index.html`, give explicit IDs to all interactive elements matching `app.js`: `#theme-toggle`, `#close-btn` (or `#modal-close`), `#rsvp-form`, `#modal-overlay`, `#invitation-card`.
385
393
  * Visual Polish: Modern system font stack (`-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif`), card hover lift (`transform: translateY(-2px)`), pill badges, styled buttons with hover states, and 100% inline SVG vector icons. ZERO broken 404 images!
386
394
  - **NEVER run `node <file>.jsx`**: Node.js does NOT execute JSX natively and will crash with `TypeError: Unknown file extension ".jsx"`. If using React, bundle it or use vanilla ES6 JavaScript which runs everywhere natively.
387
395
  - **Testing & Verification**:
@@ -454,9 +462,9 @@ Strictly software engineering. For technical tasks, bypass all non-applicable ge
454
462
  - For single-file tasks, write complete code on Turn 1. Verify by running it.
455
463
  - For multi-file projects (HTML/CSS/JS or backend+frontend):
456
464
  * Write EXACTLY ONE complete file per turn (Turn 1: index.html, Turn 2: styles.css, Turn 3: app.js).
457
- * index.html: Semantic HTML5, navbar with #theme-toggle button, containers, forms, and IDs.
465
+ * index.html: Semantic HTML5, navbar with #theme-toggle button, modals with #close-btn, forms (#rsvp-form), explicit IDs.
458
466
  * styles.css: Light-mode first (clean white/slate), CSS variables (:root and [data-theme='dark']), responsive Grid/Flexbox.
459
- * app.js: Vanilla JavaScript: theme switch persisted in localStorage (default light), filter/cart logic, event handlers.
467
+ * app.js: Defensive DOM queries (if (el) el.addEventListener(...)), theme switch in localStorage (default light), event handlers.
460
468
  * Every turn must contain a <tool_call> until all required files are created.
461
469
 
462
470
  Rules:
@@ -428,6 +428,39 @@ class IntelligentVerificationEngine:
428
428
 
429
429
  missing_ids = sorted([qid for qid in queried_ids if qid not in defined_ids])
430
430
  if missing_ids:
431
+ # ── Autonomous DOM Healing ──
432
+ # Automatically reconcile missing IDs into html_file to prevent blank screens
433
+ healed = False
434
+ for mid in list(missing_ids):
435
+ # A. Check if an element has class="{mid}" without an id
436
+ class_pattern = re.compile(rf'(<[a-zA-Z0-9\-]+[^>]*?class=["\'][^"\']*\b{re.escape(mid)}\b[^"\']*["\'][^>]*?)(/?>)', re.IGNORECASE)
437
+ if class_pattern.search(html_content) and f'id="{mid}"' not in html_content:
438
+ html_content = class_pattern.sub(rf'\1 id="{mid}"\2', html_content, count=1)
439
+ defined_ids.add(mid)
440
+ missing_ids.remove(mid)
441
+ healed = True
442
+ # B. Check for close buttons (e.g. close-btn, modal-close)
443
+ elif mid in ("close-btn", "modal-close", "close", "close-modal") and re.search(r'(<button[^>]*?(?:class=["\'][^"\']*(?:close|modal)[^"\']*["\']|aria-label=["\']Close["\'])[^>]*?)(/?>)', html_content, re.IGNORECASE):
444
+ html_content = re.sub(r'(<button[^>]*?(?:class=["\'][^"\']*(?:close|modal)[^"\']*["\']|aria-label=["\']Close["\'])[^>]*?)(/?>)', rf'\1 id="{mid}"\2', html_content, count=1, flags=re.IGNORECASE)
445
+ defined_ids.add(mid)
446
+ missing_ids.remove(mid)
447
+ healed = True
448
+
449
+ if healed:
450
+ try:
451
+ html_file.write_text(html_content, encoding="utf-8")
452
+ if events_queue is not None:
453
+ events_queue.append(("dom_auto_heal", {
454
+ "html_file": html_file.name,
455
+ "healed_ids": list(defined_ids),
456
+ }))
457
+ except Exception:
458
+ pass
459
+
460
+ # If all missing IDs were healed, proceed without failing
461
+ if not missing_ids:
462
+ continue
463
+
431
464
  missing_str = ", ".join(f"'#{mid}'" for mid in missing_ids[:5])
432
465
  return VerificationResult(
433
466
  passed=False,
@@ -449,6 +482,162 @@ class IntelligentVerificationEngine:
449
482
 
450
483
  return VerificationResult(passed=True, tier="dom_semantics")
451
484
 
485
+ def verify_browser_runtime_smoke(
486
+ self,
487
+ session_touched_files: Set[str],
488
+ ) -> VerificationResult:
489
+ """Tier 2.6: Headless Browser Runtime Smoke Gate.
490
+
491
+ Executes client JavaScript files in an in-process headless Node DOM environment
492
+ populated with the defined IDs from index.html. Catches runtime exceptions (e.g.
493
+ TypeError: Cannot read properties of null, ReferenceError, unhandled throws)
494
+ that would otherwise cause blank screens or frozen buttons in the user's browser.
495
+ Runs hermetically in < 50ms.
496
+ """
497
+ html_files = [
498
+ self.workdir / tf for tf in session_touched_files
499
+ if tf.endswith(".html") and (self.workdir / tf).is_file()
500
+ ]
501
+ if not html_files and (self.workdir / "index.html").exists():
502
+ html_files = [self.workdir / "index.html"]
503
+
504
+ if not html_files:
505
+ return VerificationResult(passed=True, tier="browser_runtime")
506
+
507
+ html_file = html_files[0]
508
+ try:
509
+ html_content = html_file.read_text(encoding="utf-8", errors="replace")
510
+ except Exception:
511
+ return VerificationResult(passed=True, tier="browser_runtime")
512
+
513
+ defined_ids = list(set(re.findall(r'\bid=["\']([a-zA-Z0-9_\-]+)["\']', html_content)))
514
+
515
+ js_files = [
516
+ self.workdir / tf for tf in session_touched_files
517
+ if tf.endswith(".js") and (self.workdir / tf).is_file()
518
+ ]
519
+ if not js_files and (self.workdir / "app.js").exists():
520
+ js_files = [self.workdir / "app.js"]
521
+
522
+ if not js_files:
523
+ return VerificationResult(passed=True, tier="browser_runtime")
524
+
525
+ import shutil
526
+ node_bin = shutil.which("node")
527
+ if not node_bin:
528
+ return VerificationResult(passed=True, tier="browser_runtime")
529
+
530
+ for jf in js_files:
531
+ try:
532
+ js_content = jf.read_text(encoding="utf-8", errors="replace")
533
+ if not js_content.strip():
534
+ continue
535
+
536
+ harness_code = """
537
+ const definedIds = new Set(%s);
538
+ global.window = global;
539
+ global.localStorage = {
540
+ _data: {},
541
+ getItem(k) { return this._data[k] || null; },
542
+ setItem(k, v) { this._data[k] = String(v); },
543
+ removeItem(k) { delete this._data[k]; }
544
+ };
545
+
546
+ function createMockEl(id, tag) {
547
+ return {
548
+ id: id || '',
549
+ tagName: (tag || 'DIV').toUpperCase(),
550
+ classList: { add() {}, remove() {}, toggle() {}, contains() { return false; } },
551
+ style: {},
552
+ innerHTML: '',
553
+ textContent: '',
554
+ appendChild(c) { return c; },
555
+ removeChild(c) { return c; },
556
+ addEventListener(evt, fn) {},
557
+ removeEventListener(evt, fn) {},
558
+ setAttribute(k, v) {},
559
+ getAttribute(k) { return null; },
560
+ querySelector(s) { return createMockEl('sub'); },
561
+ querySelectorAll(s) { return []; },
562
+ dispatchEvent(e) { return true; },
563
+ getBoundingClientRect() { return { top: 0, left: 0, width: 100, height: 100 }; },
564
+ focus() {},
565
+ blur() {}
566
+ };
567
+ }
568
+
569
+ global.document = {
570
+ documentElement: createMockEl('html', 'HTML'),
571
+ body: createMockEl('body', 'BODY'),
572
+ head: createMockEl('head', 'HEAD'),
573
+ getElementById(id) {
574
+ if (!definedIds.has(id)) return null;
575
+ return createMockEl(id);
576
+ },
577
+ querySelector(sel) {
578
+ if (sel.startsWith('#')) return this.getElementById(sel.slice(1));
579
+ return createMockEl(sel.replace(/^[.#]/, ''));
580
+ },
581
+ querySelectorAll(sel) {
582
+ if (sel.startsWith('#') && !definedIds.has(sel.slice(1))) return [];
583
+ return [createMockEl('el')];
584
+ },
585
+ createElement(tag) { return createMockEl('', tag); },
586
+ addEventListener(evt, fn) {},
587
+ removeEventListener(evt, fn) {},
588
+ location: { href: 'http://localhost:8000/', reload() {} }
589
+ };
590
+
591
+ global.location = global.document.location;
592
+ global.requestAnimationFrame = (fn) => setTimeout(fn, 16);
593
+ global.cancelAnimationFrame = (id) => clearTimeout(id);
594
+ global.AudioContext = class { createOscillator() { return { connect() {}, start() {}, stop() {} }; } createGain() { return { connect() {}, gain: { value: 1 } }; } };
595
+ global.webkitAudioContext = global.AudioContext;
596
+
597
+ try {
598
+ eval(%s);
599
+ console.log(JSON.stringify({ ok: true }));
600
+ } catch (err) {
601
+ console.log(JSON.stringify({ ok: false, error: err.message, stack: err.stack }));
602
+ }
603
+ """ % (json.dumps(defined_ids), json.dumps(js_content))
604
+
605
+ res = subprocess.run(
606
+ [node_bin, "-e", harness_code],
607
+ capture_output=True,
608
+ text=True,
609
+ timeout=2.0,
610
+ )
611
+
612
+ if res.returncode == 0 and res.stdout.strip():
613
+ lines = res.stdout.strip().splitlines()
614
+ for line in reversed(lines):
615
+ if line.startswith("{") and line.endswith("}"):
616
+ try:
617
+ payload = json.loads(line)
618
+ if not payload.get("ok"):
619
+ err_msg = payload.get("error", "Unknown runtime error")
620
+ return VerificationResult(
621
+ passed=False,
622
+ tier="browser_runtime",
623
+ error_type="runtime_exception",
624
+ failing_file=str(jf.relative_to(self.workdir)),
625
+ message=f"Browser Runtime Exception in '{jf.name}': {err_msg}",
626
+ suggested_action=(
627
+ f"Ensure all DOM queries check for null or use optional chaining (?.) in '{jf.name}'. "
628
+ f"Avoid calling .addEventListener on null elements."
629
+ ),
630
+ )
631
+ break
632
+ except Exception:
633
+ pass
634
+ except subprocess.TimeoutExpired:
635
+ pass
636
+ except Exception:
637
+ pass
638
+
639
+ return VerificationResult(passed=True, tier="browser_runtime")
640
+
452
641
  def verify_tests(
453
642
  self,
454
643
  session_touched_files: Set[str],
@@ -631,6 +820,11 @@ class IntelligentVerificationEngine:
631
820
  if not res_dom.passed:
632
821
  return res_dom
633
822
 
823
+ # Tier 2.6: Headless Browser Runtime Smoke Gate (in-process Node evaluation)
824
+ res_runtime = self.verify_browser_runtime_smoke(session_touched_files)
825
+ if not res_runtime.passed:
826
+ return res_runtime
827
+
634
828
  # Tier 3: Environment-aware targeted & full test runner
635
829
  res3 = self.verify_tests(
636
830
  session_touched_files,
@@ -275,6 +275,20 @@ class TestDomainBlueprintsAndTheming:
275
275
  assert "templates/index.html" in bp_go_web.target_files
276
276
  assert "net/http" in bp_go_web.render_contract()
277
277
 
278
+ # 5. Event & Celebration Website
279
+ bp_event = resolve_domain_blueprint("create a website for diwali celebration and add invitation card")
280
+ assert bp_event is not None
281
+ assert bp_event.blueprint_type == BlueprintType.EVENT_CELEBRATION
282
+ assert "index.html" in bp_event.target_files
283
+ assert "styles.css" in bp_event.target_files
284
+ assert "app.js" in bp_event.target_files
285
+ contract = bp_event.render_contract()
286
+ assert "invitation-card" in contract
287
+ assert "close-btn" in contract
288
+ assert "theme-toggle" in contract
289
+ assert "fx-canvas" in contract
290
+ assert "CRITICAL DEFENSIVE DOM ACCESS" in contract
291
+
278
292
  def test_interactive_arrow_selection_navigation(self, monkeypatch):
279
293
  from codeagent.blueprints import _interactive_arrow_select
280
294
 
@@ -210,3 +210,96 @@ def test_tier5_replan_directive_formatting():
210
210
  assert "Reasoning Path Directive:" in prompt_online
211
211
  assert "Failing Target: test_auth.py:42" in prompt_online
212
212
  assert "pytest test_auth.py" in prompt_online
213
+
214
+
215
+ def test_dom_semantics_auto_healing_matching_class(tmp_path: Path):
216
+ engine = IntelligentVerificationEngine(tmp_path)
217
+ html = tmp_path / "index.html"
218
+ html.write_text(
219
+ "<!DOCTYPE html><html><body>"
220
+ "<header><nav><a href='#'>Brand</a><button id='theme-toggle'>Toggle</button></nav></header>"
221
+ "<main><h1>Diwali Celebration Event</h1><div class='modal'><button class='close-btn'>&times;</button></div></main>"
222
+ "<footer><p>Happy Diwali 2026</p></footer>"
223
+ "</body></html>",
224
+ encoding="utf-8"
225
+ )
226
+ js = tmp_path / "app.js"
227
+ js.write_text(
228
+ "document.getElementById('close-btn').addEventListener('click', () => {});",
229
+ encoding="utf-8"
230
+ )
231
+
232
+ res = engine.verify_web_dom_semantics({"index.html", "app.js"})
233
+ assert res.passed is True
234
+ # Verify index.html was auto-healed with id="close-btn"
235
+ healed_html = html.read_text(encoding="utf-8")
236
+ assert 'id="close-btn"' in healed_html
237
+ assert 'class=\'close-btn\'' in healed_html or 'class="close-btn"' in healed_html
238
+
239
+
240
+ def test_dom_semantics_auto_healing_close_button_alias(tmp_path: Path):
241
+ engine = IntelligentVerificationEngine(tmp_path)
242
+ html = tmp_path / "index.html"
243
+ html.write_text(
244
+ "<!DOCTYPE html><html><body>"
245
+ "<header><nav><a href='#'>Diwali Festival</a><button id='theme-toggle'>Toggle</button></nav></header>"
246
+ "<main><h1>Welcome to Diwali Celebration</h1><div class='modal'><button class='modal-close'>&times;</button></div></main>"
247
+ "<footer><p>&copy; 2026 Diwali Committee</p></footer>"
248
+ "</body></html>",
249
+ encoding="utf-8"
250
+ )
251
+ js = tmp_path / "app.js"
252
+ js.write_text(
253
+ "document.getElementById('close-btn').addEventListener('click', () => {});",
254
+ encoding="utf-8"
255
+ )
256
+
257
+ res = engine.verify_web_dom_semantics({"index.html", "app.js"})
258
+ assert res.passed is True
259
+ healed_html = html.read_text(encoding="utf-8")
260
+ assert 'id="close-btn"' in healed_html
261
+
262
+
263
+ def test_browser_runtime_smoke_catches_runtime_exception(tmp_path: Path):
264
+ engine = IntelligentVerificationEngine(tmp_path)
265
+ html = tmp_path / "index.html"
266
+ html.write_text(
267
+ "<!DOCTYPE html><html><body>"
268
+ "<header><nav><button id='theme-toggle'>Toggle</button></nav></header>"
269
+ "<main><h1>Celebration</h1></main>"
270
+ "</body></html>",
271
+ encoding="utf-8"
272
+ )
273
+ js = tmp_path / "app.js"
274
+ # Queries missing ID without check -> throws TypeError: Cannot read properties of null
275
+ js.write_text(
276
+ "document.getElementById('nonexistent-element').addEventListener('click', () => {});",
277
+ encoding="utf-8"
278
+ )
279
+
280
+ res = engine.verify_browser_runtime_smoke({"index.html", "app.js"})
281
+ assert res.passed is False
282
+ assert res.tier == "browser_runtime"
283
+ assert res.error_type == "runtime_exception"
284
+ assert "Cannot read properties of null" in res.message or "null" in res.message
285
+
286
+
287
+ def test_browser_runtime_smoke_passes_defensive_js(tmp_path: Path):
288
+ engine = IntelligentVerificationEngine(tmp_path)
289
+ html = tmp_path / "index.html"
290
+ html.write_text(
291
+ "<!DOCTYPE html><html><body>"
292
+ "<header><nav><button id='theme-toggle'>Toggle</button></nav></header>"
293
+ "<main><h1>Celebration</h1></main>"
294
+ "</body></html>",
295
+ encoding="utf-8"
296
+ )
297
+ js = tmp_path / "app.js"
298
+ # Defensive optional chaining -> does not throw
299
+ js.write_text(
300
+ "document.getElementById('nonexistent-element')?.addEventListener('click', () => {});",
301
+ encoding="utf-8"
302
+ )
303
+
304
+ res = engine.verify_browser_runtime_smoke({"index.html", "app.js"})
305
+ assert res.passed is True
File without changes
File without changes