From bd9f428a1044e2d9c42ac25a18cc11ee7ee54b48 Mon Sep 17 00:00:00 2001 From: DavidBabinec Date: Sat, 11 Jul 2026 16:35:59 +0200 Subject: [PATCH 1/2] fix(agent): make CSS edits replaceable and priority-aware --- docs/features/agent.md | 19 +- docs/reference/css-class-registry.md | 26 +- server/ai/tools/site/systemPrompt.ts | 5 +- server/ai/tools/site/writeTools.ts | 4 +- src/__tests__/agent/agentSlice.test.ts | 2 +- src/__tests__/agent/executor.test.ts | 221 +++++++- src/__tests__/agent/renderEvidence.test.ts | 28 + src/__tests__/agent/toolCallDisplay.test.ts | 35 ++ .../architecture/module-size-budgets.test.ts | 1 - .../canvas/classStyleInjector.test.ts | 21 + .../editor-store/ambientRule.test.ts | 23 + .../editor-store/styleRuleSlice.test.ts | 45 ++ .../page-tree/scopedClassClone.test.ts | 13 + .../publisher/classStyleInjector.test.ts | 44 ++ src/__tests__/publisher/sizesResolver.test.ts | 40 ++ src/__tests__/siteImport/colorTokens.test.ts | 10 + .../cssToStyleRules-substitution.test.ts | 6 + .../siteImport/cssToStyleRules.test.ts | 27 + .../siteImport/stylesheetModes.test.ts | 28 + src/admin/pages/site/agent/cssTools.ts | 88 ++++ src/admin/pages/site/agent/executor.ts | 67 +-- src/admin/pages/site/agent/renderEvidence.ts | 14 + src/admin/pages/site/agent/types.ts | 4 + src/admin/pages/site/canvas/canvasClassCss.ts | 12 +- .../pages/site/panels/AgentPanel/index.ts | 1 + .../site/panels/AgentPanel/toolCallDisplay.ts | 27 +- .../slices/styleRule/conditionActions.ts | 11 + .../store/slices/styleRule/crudActions.ts | 494 ++++++++++++++++-- .../store/slices/styleRule/propertyActions.ts | 19 + .../store/slices/styleRule/registryActions.ts | 13 + .../site/store/slices/styleRule/types.ts | 58 +- src/admin/pages/site/store/subtreeSnapshot.ts | 26 + src/core/ai/toolSchemas.ts | 38 +- src/core/css-substitution/index.ts | 32 +- src/core/page-tree/index.ts | 8 +- src/core/page-tree/scopedClassClone.ts | 13 + src/core/page-tree/styleRule.ts | 50 +- src/core/publisher/classCss.ts | 92 +++- src/core/publisher/index.ts | 6 +- src/core/publisher/sizesResolver.ts | 27 +- src/core/siteImport/classCascades.ts | Bin 19943 -> 19745 bytes src/core/siteImport/colorTokens.ts | 13 +- src/core/siteImport/cssDeclarationReader.ts | 19 + src/core/siteImport/cssToStyleRules.ts | 60 +-- src/core/siteImport/declarationCascade.ts | 117 +++++ src/core/siteImport/fontTokens.ts | 19 +- 46 files changed, 1691 insertions(+), 235 deletions(-) create mode 100644 src/__tests__/agent/toolCallDisplay.test.ts create mode 100644 src/admin/pages/site/agent/cssTools.ts create mode 100644 src/core/siteImport/cssDeclarationReader.ts create mode 100644 src/core/siteImport/declarationCascade.ts diff --git a/docs/features/agent.md b/docs/features/agent.md index b485b70d0..4d8bfb2d2 100644 --- a/docs/features/agent.md +++ b/docs/features/agent.md @@ -13,7 +13,7 @@ The agent runs on a provider-agnostic AI runtime (`server/ai/`) that can drive a ## TL;DR - **Structure via HTML.** `site_insert_html` and `site_replace_node_html` accept semantic HTML strings; the browser executor calls `importHtml` (the same pipeline as the paste-HTML UI) to convert them into first-class, editable `PageNode`s. -- **Styling via CSS.** The agent emits CSS the same way a human pastes it: a `