Sitesmith: AI site builder addon (frontend) #1
Reference in New Issue
Block a user
Delete Branch "sitesmith-ai-builder"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Frontend half of Sitesmith, the new AI site builder addon. Adds a chat modal to the Craft.js editor that takes a natural-language prompt and applies the AI's response (a
replace,patch, orask) to the editor state. Backed by the WHP-side PR: cloud-hosting-platform/whp#18Spec / plan are in the WHP repo:
docs/superpowers/specs/2026-05-23-sitesmith-ai-builder-design.mddocs/superpowers/plans/2026-05-23-sitesmith-ai-builder.mdWhat's in this PR
<script>,<form>,<style>,on*event handlers all stripped.canvas-summary.ts— compresses current canvas state to a ~1.5K-token textual summary the AI reads each turn (excludes style props, asset URLs, opaque HtmlBlock contents)src/types/sitesmith.ts):SitesmithStatus,SitesmithSummary,SitesmithMessage,SitesmithResponse(discriminated union over replace/patch/ask),SitesmithPatchOp(5-variant union),SerializedTreeNodeuseSitesmithhook — entitlement, history, send (adapts to the existinguseEditorConfig().whpConfigshape)apply-ai-response.ts— applies all 5 patch ops (update_props / replace_node / insert_after / insert_before / delete_node) plus fullreplaceflows for scope=site, page, section. IncludesserializeTreeForCraftto convert AI's nested tree into the Craft.js flat-nodes shape, andfindNodeIdByAiNodeIdfor stable AI-handle → Craft-id resolution.replaceAllPages,replaceCurrentPage,setHeader,setFooter(mirrors existingsetHeaderCraftState/setFooterCraftState/setPagesCraftStatepattern)src/panels/sitesmith/):SitesmithButton.tsx— topbar button with locked/capped visual statesSitesmithModal.tsx— full-screen modal orchestrating chat + applyMessageList.tsx,ChatInput.tsx,UpgradeBanner.tsx,ScopeConfirmDialog.tsxprops.aiNamewhen present (falls back to existingdisplayNamefor non-AI nodes)tests/sitesmith.spec.ts): 4 scenarios — locked, capped, bonus-credit override, full build+patch (preserves manual edit across turns)Backward compatibility
<script>/ event handlers in HtmlBlock will be stripped on render. Discussed with operator — only one test site uses HtmlBlock at the moment, no impact.Test plan
npm run test:unit— 17 unit tests pass:npx tsc --noEmit— cleannpm run build— bundle succeeds (786KB JS / 20KB CSS)Follow-up (Task 23 — needs staging deploy + test user creation):
npm run buildand copy to/docker/whp/web/site-builder/on stagingsitesmith_disabled,sitesmith_enabled,sitesmith_capped,sitesmith_bonus— each owning one sitetests/sitesmith.spec.tsheader commentPLAYWRIGHT_BASE_URL=https://192.168.1.105:8080 SITESMITH_TEST_PASSWORD=... npm run test:e2e:sitesmithCo-Authored-By
🤖 Generated with Claude Code