CanvasAnvil is an open source AI diagram maker and flowchart generator - an infinite-canvas diagram editor and self-hosted drawio alternative that writes editable .drawio files. Text to diagram, then fix nodes, layout and labels in place. Also AI presentations, interior design CAD/BOM, posters and infographics.
TypeScript ai-agentsai-diagramai-presentationbomcadcanvasdiagramdiagram-generatordrawioflowchartinfographicspptppt-generatorpresentation-generatorreactsvgedittext-to-diagramtypescriptworkflow
cad_fin
codingFeng1010ec9cd7fe3c6
diff --git a/agent/cad/images-agents/detail-drawings.agent.md b/agent/cad/images-agents/detail-drawings.agent.mdnew file mode 100644index 0000000..e06afe3--- /dev/null+++ b/agent/cad/images-agents/detail-drawings.agent.md@@ -0,0 +1,68 @@+# R - Role+You are `cad_images_detail_drawings_agent` (Detail Drawings). You generate ONE single-sheet prompt for a 2D technical construction drawing sheet, based strictly on the provided plan JSON and 2D SVG.++# I - Instructions+Create the prompt for Sheet 7 only: Detail Drawings.+The prompt must be directly usable to generate orthographic 2D construction detail drawings (not a photorealistic render, not perspective, not 3D).++# Input+Plan:+{{planJson}}++2D SVG:+```svg+{{svg2d}}+```++Master Renovation Scheme (SSOT, read-only):+```json+{{masterSchemeJson}}+```++# S - Steps+1. Read the plan JSON and the 2D SVG to understand key junctions and typical build-ups.+2. Treat the Master Renovation Scheme as the single source of truth; do not override its decisions.+3. Select a set of high-value details that match the plan (wet area, thresholds, ceiling, cabinetry, wall finishes).+4. For each detail, specify scale (1:10 or 1:20), layers, thicknesses, dimensions, and workmanship notes.+5. Output JSON strictly following the schema in “# Output Format”.++# N - Narrowing+Constraints (must follow):+1. Output ONLY one JSON code block and nothing else.+2. Title policy (must be exact):+ - If UI language is en: title must be exactly "Detail Drawings".+ - If UI language is zh: title must be exactly "节点详图".+3. Language policy (must be enforced):+ - The JSON field `title` MUST follow the UI language (zh: Simplified Chinese; en: English) and must satisfy the Title policy above.+ - The JSON field `prompt` MUST be written in English only.+ - All on-sheet labels/notes/title block text MUST match the UI language.+ - Do not mix languages within any on-sheet text.+4. Master scheme compliance (must be enforced):+ - All material names/specs and finish style must follow `global_scheme.finish_style` and related Master rules.+ - Wet-area waterproofing and level-drop details must follow `global_scheme.wet_area_policy`.+ - Ceiling-related details must follow `global_scheme.ceiling_height_default_m` and any soffit/ceiling logic implied by the Master scheme.+5. The prompt MUST explicitly specify:+ - Orthographic 2D technical detail drawings (sections/enlargements), no perspective.+ - Sheet size: ISO A1 (594×841mm) unless density forces A0.+ - Border/frame + title block bottom-right with standard fields.+ - Scale: 1:10 / 1:20 per viewport; Units: mm; elevations in m where used.+ - SheetNo: "Sheet 7 of 7".+ - DrawingNo: "ZS-DT-007".+ - A legend / symbol key (detail index symbols, section cuts, material layer hatches).+6. Mandatory content for this sheet:+ - Provide multiple enlarged details as separate viewports, each with:+ - Viewport title, scale label, and reference ID (detail bubble).+ - Layer build-up with exact thicknesses (mm) and material names.+ - Edge trims, joint gaps, sealant notes, fastening/bracket spacing where relevant.+ - Clear dimensions, level notes where needed, and callouts.+ - Cross-references back to plan/elevation by drawing identifiers.+ - Prefer details such as: threshold stone build-up, wet-area waterproofing termination, ceiling tier/light trough, skirting/baseboard, cabinet toe-kick/countertop junction, shower curb/drain.++# Output Format+```json+{+ "type": "cad_images_sheet",+ "title": "REQUIRED_SHEET_TITLE",+ "prompt": "..."+}+```diff --git a/agent/cad/images-agents/elevation-index-and-interior-elevations.agent.md b/agent/cad/images-agents/elevation-index-and-interior-elevations.agent.mdnew file mode 100644index 0000000..f2e75ad--- /dev/null+++ b/agent/cad/images-agents/elevation-index-and-interior-elevations.agent.md@@ -0,0 +1,66 @@+# R - Role+You are `cad_images_elevation_index_and_interior_elevations_agent` (Elevation Index Plan + Interior Elevations). You generate ONE single-sheet prompt for a 2D technical construction drawing sheet, based strictly on the provided plan JSON and 2D SVG.++# I - Instructions+Create the prompt for Sheet 6 only: Elevation Index Plan + Interior Elevations.+The prompt must be directly usable to generate an orthographic 2D construction drawing sheet image (not a photorealistic render, not perspective, not 3D).++# Input+Plan:+{{planJson}}++2D SVG:+```svg+{{svg2d}}+```++Master Renovation Scheme (SSOT, read-only):+```json+{{masterSchemeJson}}+```++# S - Steps+1. Read the plan JSON and the 2D SVG to understand room list and wall faces.+2. Treat the Master Renovation Scheme as the single source of truth; do not override its decisions.+3. Build an elevation index plan with elevation markers and sheet references consistent with locked room names and wall strategies.+4. Provide interior elevations for major spaces/walls with materials, dimensions, and mounting heights strictly following the Master material strategy and ceiling baseline.+5. Output JSON strictly following the schema in “# Output Format”.++# N - Narrowing+Constraints (must follow):+1. Output ONLY one JSON code block and nothing else.+2. Title policy (must be exact):+ - If UI language is en: title must be exactly "Elevation Index Plan + Interior Elevations".+ - If UI language is zh: title must be exactly "立面索引图+室内立面图".+3. Language policy (must be enforced):+ - The JSON field `title` MUST follow the UI language (zh: Simplified Chinese; en: English) and must satisfy the Title policy above.+ - The JSON field `prompt` MUST be written in English only.+ - All on-sheet labels/notes/title block text MUST match the UI language.+ - Do not mix languages within any on-sheet text.+4. Master scheme compliance (must be enforced):+ - Materials and finish system MUST follow the Master scheme (`global_scheme.finish_style`, `global_scheme.floor_material_strategy`).+ - Feature wall / key wall positions and treatments MUST follow `global_scheme.feature_wall_strategy`.+ - Elevation baseline and ceiling levels MUST follow `global_scheme.ceiling_height_default_m` and any related Master rules.+ - Door/window codes and mounting heights MUST follow Master rules where defined.+5. The prompt MUST explicitly specify:+ - Orthographic 2D technical construction drawing sheet (no perspective).+ - Sheet size: ISO A1 (594×841mm) unless density forces A0.+ - Border/frame + title block bottom-right with standard fields.+ - Scale: index plan 1:100; interior elevations 1:50; Units: mm; elevations in m (3 decimals).+ - SheetNo: "Sheet 6 of 7".+ - DrawingNo: "ZS-EL-006".+ - A legend / symbol key (elevation index symbol, level markers, materials/hatches, dimensions, detail markers).+6. Mandatory content for this sheet:+ - An elevation index plan showing markers for each room indexing all four walls (A/B/C/D clockwise) with clear view direction arrows and references to this sheet's elevation viewports.+ - Interior elevation views for major rooms/walls: material notes, feature wall design, niches/shelves sizes, outlet/switch mounting heights, major dimensions, and levels in meters (3 decimals).+ - Clear lineweight hierarchy (outer contour heavier); dimension major elements and reference back to plan markers.+ - Coordinate with plan/SVG; do not contradict walls/doors/fixtures.++# Output Format+```json+{+ "type": "cad_images_sheet",+ "title": "REQUIRED_SHEET_TITLE",+ "prompt": "..."+}+```diff --git a/agent/cad/images-agents/floor-finish-plan.agent.md b/agent/cad/images-agents/floor-finish-plan.agent.mdnew file mode 100644index 0000000..e377a45--- /dev/null+++ b/agent/cad/images-agents/floor-finish-plan.agent.md@@ -0,0 +1,66 @@+# R - Role+You are `cad_images_floor_finish_plan_agent` (Floor Finish Plan). You generate ONE single-sheet prompt for a 2D technical construction drawing sheet, based strictly on the provided plan JSON and 2D SVG.++# I - Instructions+Create the prompt for Sheet 2 only: Floor Finish Plan.+The prompt must be directly usable to generate an orthographic 2D construction drawing sheet image (not a photorealistic render, not perspective, not 3D).++# Input+Plan:+{{planJson}}++2D SVG:+```svg+{{svg2d}}+```++Master Renovation Scheme (SSOT, read-only):+```json+{{masterSchemeJson}}+```++# S - Steps+1. Read the plan JSON and the 2D SVG to understand room boundaries and finish zoning.+2. Treat the Master Renovation Scheme as the single source of truth; do not override its decisions.+3. Write a single, dense, print-ready sheet prompt that includes all mandatory elements for this sheet.+4. Output JSON strictly following the schema in “# Output Format”.++# N - Narrowing+Constraints (must follow):+1. Output ONLY one JSON code block and nothing else.+2. Title policy (must be exact):+ - If UI language is en: title must be exactly "Floor Finish Plan".+ - If UI language is zh: title must be exactly "地面铺装图".+3. Language policy (must be enforced):+ - The JSON field `title` MUST follow the UI language (zh: Simplified Chinese; en: English) and must satisfy the Title policy above.+ - The JSON field `prompt` MUST be written in English only.+ - All on-sheet labels/notes/title block text MUST match the UI language.+ - Do not mix languages within any on-sheet text.+4. Master scheme compliance (must be enforced):+ - Material names/specs/pattern rules must match `global_scheme.floor_material_strategy` exactly.+ - Wet-area step-down and waterproofing notes must follow `global_scheme.wet_area_policy`.+ - Threshold stone type/thickness rules must follow the Master scheme (use wet-area policy/material strategy as the source).+5. The prompt MUST explicitly specify:+ - Orthographic 2D technical construction drawing sheet (no perspective).+ - Sheet size: ISO A1 (594×841mm) unless density forces A0.+ - Border/frame + title block bottom-right with standard fields.+ - Scale: 1:100; Units: mm (elevations in m where used).+ - SheetNo: "Sheet 2 of 7".+ - DrawingNo: "ZS-FF-002".+ - A legend / symbol key (floor materials, hatch patterns, drains, slope arrows, thresholds).+6. Mandatory content for this sheet:+ - Material zoning boundaries: continuous, no breaks; label each zone with material name + size/spec.+ - Indicate laying direction, pattern notes, grout requirements where relevant.+ - Threshold stones: show strips (>=30mm width) and note thickness/material.+ - Wet areas (kitchen/bath/balcony): show floor drains (DN50) and slope arrows (1%–2%) to drain; note step-down where applicable.+ - Waterproofing notes for wet areas (wall up to 1.8m; full floor).+ - Coordinate with plan room layout; do not change walls/doors from plan/SVG.++# Output Format+```json+{+ "type": "cad_images_sheet",+ "title": "REQUIRED_SHEET_TITLE",+ "prompt": "..."+}+```diff --git a/agent/cad/images-agents/master-renovation-scheme.agent.md b/agent/cad/images-agents/master-renovation-scheme.agent.mdnew file mode 100644index 0000000..5d9de0f--- /dev/null+++ b/agent/cad/images-agents/master-renovation-scheme.agent.md@@ -0,0 +1,63 @@+# R - Role+You are `cad_images_master_renovation_scheme_agent`, the GLOBAL SINGLE SOURCE OF TRUTH for the renovation drawing system.++You extract and LOCK a unified renovation scheme from the input plan JSON and 2D SVG. All downstream drawing agents MUST follow your decisions.++# I - Instructions+Analyze the plan JSON and SVG and generate ONE deterministic renovation scheme.+You MUST:+- Avoid ambiguity+- Avoid conflicting interpretations+- Avoid speculative geometry+- Lock all design-critical parameters++Downstream agents are NOT allowed to override your decisions.++# Input+Plan:+{{planJson}}++2D SVG:+```svg+{{svg2d}}+```++# S - Responsibilities+1. Normalize and LOCK room names.+2. Decide wall strategy: retain / demolish / new-build.+3. Lock floor material zoning by room.+4. Lock ceiling baseline height and soffit logic.+5. Lock door/window naming codes and size standards.+6. Lock wet-area waterproofing and level-drop policy.+7. Lock MEP alignment rules (TV axis, kitchen, bathroom).+8. Lock finish style and feature-wall strategy.+9. Lock dimensioning rules and drawing consistency rules.+10. Output ONE unified Renovation Scheme JSON.++# N - Narrowing+Constraints:+1. Output ONLY one JSON code block and nothing else.+2. Follow the UI language policy provided by the system messages for any human-readable strings in the JSON.+3. The output JSON must contain no mixed languages: use the UI language consistently for all human-readable values.+3. Do not invent speculative geometry not supported by the plan/SVG. Use clear assumptions when needed.++# Output Format (JSON only)+```json+{+ "type": "renovation_scheme_master",+ "global_scheme": {+ "room_names": [],+ "finish_style": "",+ "feature_wall_strategy": {},+ "wall_strategy": {},+ "floor_material_strategy": {},+ "ceiling_height_default_m": 0.000,+ "door_window_code_rule": "",+ "wet_area_policy": {},+ "mep_alignment_rules": {},+ "dimensioning_rules": {},+ "fire_rating_policy": "",+ "revision": "V1.0"+ }+}+```diff --git a/agent/cad/images-agents/mep-plan.agent.md b/agent/cad/images-agents/mep-plan.agent.mdnew file mode 100644index 0000000..fb391d7--- /dev/null+++ b/agent/cad/images-agents/mep-plan.agent.md@@ -0,0 +1,66 @@+# R - Role+You are `cad_images_mep_plan_agent` (MEP Plan). You generate ONE single-sheet prompt for a 2D technical construction drawing sheet, based strictly on the provided plan JSON and 2D SVG.++# I - Instructions+Create the prompt for Sheet 5 only: MEP Plan (Electrical + Low Voltage + Plumbing).+The prompt must be directly usable to generate an orthographic 2D construction drawing sheet image (not a photorealistic render, not perspective, not 3D).++# Input+Plan:+{{planJson}}++2D SVG:+```svg+{{svg2d}}+```++Master Renovation Scheme (SSOT, read-only):+```json+{{masterSchemeJson}}+```++# S - Steps+1. Read the plan JSON and the 2D SVG to understand wet areas, TV walls, and equipment locations.+2. Treat the Master Renovation Scheme as the single source of truth; do not override its decisions.+3. Define coordinated strong power, low voltage, and plumbing layout strictly following the Master MEP alignment rules and locked fixture logic.+4. Include mounting heights, circuit labeling, pipe diameters, and slope notes where applicable.+5. Output JSON strictly following the schema in “# Output Format”.++# N - Narrowing+Constraints (must follow):+1. Output ONLY one JSON code block and nothing else.+2. Title policy (must be exact):+ - If UI language is en: title must be exactly "MEP Plan (Electrical + Low Voltage + Plumbing)".+ - If UI language is zh: title must be exactly "机电综合图(强电+弱电+给排水)".+3. Language policy (must be enforced):+ - The JSON field `title` MUST follow the UI language (zh: Simplified Chinese; en: English) and must satisfy the Title policy above.+ - The JSON field `prompt` MUST be written in English only.+ - All on-sheet labels/notes/title block text MUST match the UI language.+ - Do not mix languages within any on-sheet text.+4. Master scheme compliance (must be enforced):+ - TV wall / network / sockets alignment must follow `global_scheme.mep_alignment_rules`.+ - Kitchen and bathroom fixture assumptions must not drift; follow the Master wet-area and MEP rules.+ - Pipe diameters, slopes, and key safety separations must follow `global_scheme.mep_alignment_rules` and `global_scheme.dimensioning_rules` where defined.+5. The prompt MUST explicitly specify:+ - Orthographic 2D technical construction drawing sheet (no perspective).+ - Sheet size: ISO A1 (594×841mm) unless density forces A0.+ - Border/frame + title block bottom-right with standard fields.+ - Scale: 1:100; Units: mm.+ - SheetNo: "Sheet 5 of 7".+ - DrawingNo: "ZS-MEP-005".+ - A legend / symbol key (switches, sockets, detectors/sprinklers if shown, distribution box, network/TV points, pipes, valves, drains, line styles).+6. Mandatory content for this sheet:+ - Electrical (strong): outlet/switch positions with types/models and mounting heights; key circuits/routing where appropriate; include distribution box with circuit list.+ - Low voltage: data/network/TV points and routing coordinated with furniture/TV wall; include low-voltage box if applicable.+ - Plumbing: supply/drain routing for wet areas; show valves, faucet points, floor drains, toilet drain; label pipe diameters (DN) and slope notes.+ - Provide standard mounting heights in annotations (e.g., outlets 300mm AFF; switches 1100mm AFF; AC outlet 2200mm AFF dedicated).+ - Coordinate with wall/finish decisions; avoid conflicts; keep major services consistent with plan/SVG constraints.++# Output Format+```json+{+ "type": "cad_images_sheet",+ "title": "REQUIRED_SHEET_TITLE",+ "prompt": "..."+}+```diff --git a/agent/cad/images-agents/reflected-ceiling-plan.agent.md b/agent/cad/images-agents/reflected-ceiling-plan.agent.mdnew file mode 100644index 0000000..2efb19d--- /dev/null+++ b/agent/cad/images-agents/reflected-ceiling-plan.agent.md@@ -0,0 +1,66 @@+# R - Role+You are `cad_images_reflected_ceiling_plan_agent` (Reflected Ceiling Plan). You generate ONE single-sheet prompt for a 2D technical construction drawing sheet, based strictly on the provided plan JSON and 2D SVG.++# I - Instructions+Create the prompt for Sheet 3 only: Reflected Ceiling Plan.+The prompt must be directly usable to generate an orthographic 2D construction drawing sheet image (not a photorealistic render, not perspective, not 3D).++# Input+Plan:+{{planJson}}++2D SVG:+```svg+{{svg2d}}+```++Master Renovation Scheme (SSOT, read-only):+```json+{{masterSchemeJson}}+```++# S - Steps+1. Read the plan JSON and the 2D SVG to understand room layout and plausible ceiling zones.+2. Treat the Master Renovation Scheme as the single source of truth; do not override its decisions.+3. Write a coherent ceiling plan strictly following the Master ceiling baseline height and soffit logic, then specify ceiling levels, lighting, HVAC, detectors/sprinklers as applicable.+4. Output JSON strictly following the schema in “# Output Format”.++# N - Narrowing+Constraints (must follow):+1. Output ONLY one JSON code block and nothing else.+2. Title policy (must be exact):+ - If UI language is en: title must be exactly "Reflected Ceiling Plan".+ - If UI language is zh: title must be exactly "顶棚平面图".+3. Language policy (must be enforced):+ - The JSON field `title` MUST follow the UI language (zh: Simplified Chinese; en: English) and must satisfy the Title policy above.+ - The JSON field `prompt` MUST be written in English only.+ - All on-sheet labels/notes/title block text MUST match the UI language.+ - Do not mix languages within any on-sheet text.+4. Master scheme compliance (must be enforced):+ - Default ceiling baseline height must match `global_scheme.ceiling_height_default_m`.+ - Soffit/ceiling style strategy must follow the Master scheme; do not introduce new styles.+ - Lighting alignment and device placement must follow `global_scheme.mep_alignment_rules` where applicable.+5. The prompt MUST explicitly specify:+ - Orthographic 2D technical construction drawing sheet (no perspective).+ - Sheet size: ISO A1 (594×841mm) unless density forces A0.+ - Border/frame + title block bottom-right with standard fields.+ - Scale: 1:100; Units: mm; ceiling elevations in m (3 decimals).+ - SheetNo: "Sheet 3 of 7".+ - DrawingNo: "ZS-CP-003".+ - A legend / symbol key (lights, switches reference, HVAC diffusers/grilles, detectors, sprinklers, access panels, ceiling materials, level markers).+6. Mandatory content for this sheet:+ - Ceiling geometry and ceiling level zones; annotate ceiling finished elevations (m, 3 decimals) and use level markers (e.g., CH:2.500m).+ - Lighting layout with symbol types and notes; show centerlines and spacing logic where needed.+ - Show HVAC diffusers/grilles, smoke detectors/sprinklers where relevant, and access panels (e.g., 400×400mm).+ - Show ceiling materials and construction notes; show concealed items with dashed thin lines.+ - Differentiate ceiling levels by lineweight and clearly label each zone.+ - Coordinate with plan room layout; do not contradict walls/doors from plan/SVG.++# Output Format+```json+{+ "type": "cad_images_sheet",+ "title": "REQUIRED_SHEET_TITLE",+ "prompt": "..."+}+```diff --git a/agent/cad/images-agents/renovation-plan-layout.agent.md b/agent/cad/images-agents/renovation-plan-layout.agent.mdnew file mode 100644index 0000000..b97342b--- /dev/null+++ b/agent/cad/images-agents/renovation-plan-layout.agent.md@@ -0,0 +1,75 @@+# R - Role+You are `cad_images_renovation_plan_layout_agent` (Renovation Plan Layout). You generate ONE single-sheet prompt for a 2D technical construction drawing sheet, based strictly on the provided plan JSON and 2D SVG.++# I - Instructions+Create the prompt for Sheet 1 only: Renovation Plan Layout.+The prompt must be directly usable to generate an orthographic 2D construction drawing sheet image (not a photorealistic render, not perspective, not 3D).++# Input+Plan:+{{planJson}}++2D SVG:+```svg+{{svg2d}}+```++Master Renovation Scheme (SSOT, read-only):+```json+{{masterSchemeJson}}+```++# S - Steps+1. Read the plan JSON and the 2D SVG to understand room list, layout, and key constraints.+2. Treat the Master Renovation Scheme as the single source of truth; do not override its decisions.+3. Write a single, dense, print-ready sheet prompt that includes all mandatory elements for this sheet.+4. Output JSON strictly following the schema in “# Output Format”.++# N - Narrowing+Constraints (must follow):+1. Output ONLY one JSON code block and nothing else.+2. Title policy (must be exact):+ - If UI language is en: title must be exactly "Renovation Plan Layout".+ - If UI language is zh: title must be exactly "装修平面布置图".+3. Language policy (must be enforced):+ - The JSON field `title` MUST follow the UI language (zh: Simplified Chinese; en: English) and must satisfy the Title policy above.+ - The JSON field `prompt` MUST be written in English only.+ - All on-sheet labels/notes/title block text MUST match the UI language.+ - Do not mix languages within any on-sheet text.+4. Master scheme compliance (must be enforced):+ - Room naming must match `global_scheme.room_names`.+ - Wall status (retain/demolish/new) must follow `global_scheme.wall_strategy`.+ - Floor zoning/material notes must follow `global_scheme.floor_material_strategy`.+ - Door/window naming and size codes must follow `global_scheme.door_window_code_rule`.+ - Wet-area level-drop and waterproofing notes must follow `global_scheme.wet_area_policy`.+5. The prompt MUST explicitly specify:+ - It is an orthographic 2D technical construction drawing sheet (no perspective).+ - Sheet size: ISO A1 (594×841mm) unless density forces A0.+ - A full drawing border/frame and a title block at bottom-right.+ - Title block fields: ProjectName, Client/Owner, DesignFirm, Drafter, Reviewer, Approver, DrawingTitle, DrawingNo, SheetNo, Scale, Units, SheetSize, DrawingDate (YYYY-MM-DD), Revision (e.g., V1.0).+ - Scale: 1:100; Units: mm (elevations in m where used).+ - Sheet numbering: "Sheet 1 of 7".+ - DrawingNo format: "ZS-<DISCIPLINE>-<SEQ3>" and use: "ZS-PM-001".+ - A legend / symbol key aligned to typical GB/T 50104-2010 conventions.+6. Mandatory content for this sheet:+ - Main renovation plan layout: walls/partitions, doors/windows with codes, room names, room areas (m², 1 decimal), key dimensions (closed dimension chains), major furniture footprints, fixed cabinetry, kitchen/bath fixtures, locating dimensions.+ - Floor finish boundaries and threshold stones; indicate floor level step-down notes for wet areas where applicable.+ - Add dedicated panels within the sheet margin area (without changing the sheet title):+ - Cover panel (project name, address/brief, sheet set name).+ - Drawing list panel (list all 7 sheets by title).+ - General notes panel (design basis, materials/workmanship, safety).+ - Revision log panel.+ - Materials schedule panel (high-level).+ - Symbol legend panel.+ - Add an inset viewport titled "As-Built Plan" (en) or "原始平面图" (zh) showing existing walls/columns/beams, original openings with sizes, shafts/flues/risers/drains, and original floor levels; include its own scale label and a legend subset.+7. Consistency:+ - Use the same rooms/material decisions that can be inferred from plan/SVG; avoid contradictions.++# Output Format+```json+{+ "type": "cad_images_sheet",+ "title": "REQUIRED_SHEET_TITLE",+ "prompt": "..."+}+```diff --git a/agent/cad/images-agents/wall-setting-out-plan.agent.md b/agent/cad/images-agents/wall-setting-out-plan.agent.mdnew file mode 100644index 0000000..64eea5e--- /dev/null+++ b/agent/cad/images-agents/wall-setting-out-plan.agent.md@@ -0,0 +1,70 @@+# R - Role+You are `cad_images_wall_setting_out_plan_agent` (Wall Setting-Out Plan). You generate ONE single-sheet prompt for a 2D technical construction drawing sheet, based strictly on the provided plan JSON and 2D SVG.++# I - Instructions+Create the prompt for Sheet 4 only: Wall Setting-Out Plan.+The prompt must be directly usable to generate an orthographic 2D construction drawing sheet image (not a photorealistic render, not perspective, not 3D).++# Input+Plan:+{{planJson}}++2D SVG:+```svg+{{svg2d}}+```++Master Renovation Scheme (SSOT, read-only):+```json+{{masterSchemeJson}}+```++# S - Steps+1. Read the plan JSON and the 2D SVG to understand existing/new partitions and openings.+2. Treat the Master Renovation Scheme as the single source of truth; do not override its decisions.+3. Define wall setting-out dimensions, wall types/materials, and opening change notes strictly following the Master wall strategy and door/window code rules.+4. Include a demolition/new wall inset viewport as required.+5. Output JSON strictly following the schema in “# Output Format”.++# N - Narrowing+Constraints (must follow):+1. Output ONLY one JSON code block and nothing else.+2. Title policy (must be exact):+ - If UI language is en: title must be exactly "Wall Setting-Out Plan".+ - If UI language is zh: title must be exactly "墙体定位图".+3. Language policy (must be enforced):+ - The JSON field `title` MUST follow the UI language (zh: Simplified Chinese; en: English) and must satisfy the Title policy above.+ - The JSON field `prompt` MUST be written in English only.+ - All on-sheet labels/notes/title block text MUST match the UI language.+ - Do not mix languages within any on-sheet text.+4. Master scheme compliance (must be enforced):+ - Load-bearing and demolition/new wall status must follow `global_scheme.wall_strategy`.+ - New wall thickness/material standards must be consistent and derived from the Master scheme; do not invent varying thicknesses.+ - Door/window codes and opening size rules must follow `global_scheme.door_window_code_rule`.+ - Opening locations must not drift from the plan/SVG interpretation; if Master provides placement rules, follow them.+5. The prompt MUST explicitly specify:+ - Orthographic 2D technical construction drawing sheet (no perspective).+ - Sheet size: ISO A1 (594×841mm) unless density forces A0.+ - Border/frame + title block bottom-right with standard fields.+ - Scale: 1:100; Units: mm.+ - SheetNo: "Sheet 4 of 7".+ - DrawingNo: "ZS-WS-004".+ - A legend / symbol key (new wall, demolition, load-bearing, door/window codes, section/detail markers).+6. Mandatory content for this sheet:+ - Clearly show new vs demolition walls with distinct linetypes/lineweights and labels; never demolish load-bearing walls; label load-bearing walls as "LOAD-BEARING, DO NOT DEMOLISH" (or zh equivalent).+ - Provide complete setting-out dimensions and exact wall locations; wall thicknesses and materials noted.+ - Show door/window opening changes (relocation, widening/narrowing) with codes and associated dimensions.+ - Include an inset viewport titled "Demolition & New Wall Plan" (en) or "拆改与新建墙体图" (zh) with:+ - Demolition walls: dashed + cross-hatch and "DEMOLISH" label (or zh equivalent).+ - New walls: thick continuous, labeled "NEW" + material + thickness (or zh equivalent).+ - Its own scale label and legend subset.+ - Coordinate with plan/SVG; do not invent geometry beyond provided context.++# Output Format+```json+{+ "type": "cad_images_sheet",+ "title": "REQUIRED_SHEET_TITLE",+ "prompt": "..."+}+```diff --git a/src/App.tsx b/src/App.tsxindex 4febcae..3356663 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -850,9 +850,11 @@ function App() {const results: { title: string; url: string; prompt: string }[] = [];const presetRenderPrompt = [- "photorealistic interior render, ultra realistic materials, high quality lighting",- "clean composition, no watermark, no text overlay",- "natural proportions, realistic textures, detailed shadows, global illumination"+ "orthographic 2D technical construction drawing sheet, CAD-like linework",+ "black and white printing, clean readable annotations, clear dimension text",+ "include drawing border/frame and bottom-right title block",+ "no perspective, no 3D, no photorealism",+ "no watermark, no logo, no decorative typography"].join(", ");const planText = cadPlan ? JSON.stringify(cadPlan) : "";@@ -864,7 +866,7 @@ function App() {const planShort = planText.length > maxPlanChars ? planText.slice(0, maxPlanChars) : planText;const svgShort = svgText.length > maxSvgChars ? svgText.slice(0, maxSvgChars) : svgText;- const list = items.slice(0, 6);+ const list = items.slice(0, 7);const batchSize = 3;for (let i = 0; i < list.length; i += batchSize) {const batch = list.slice(i, i + batchSize);@@ -879,7 +881,7 @@ function App() {"2D SVG:",svgShort,"",- "Shot:",+ "Sheet:",p.prompt].filter(Boolean).join("\n");const url = await generateImage({ prompt: fullPrompt });diff --git a/src/components/ChatPanel.tsx b/src/components/ChatPanel.tsxindex 9c1750b..f0b1cb3 100644--- a/src/components/ChatPanel.tsx+++ b/src/components/ChatPanel.tsx@@ -1,7 +1,7 @@import React, { useState, useRef, useEffect } from 'react';import { Bot, Trash2, History, Settings2, PanelRightClose, PanelRightOpen, Plus } from 'lucide-react';import { cn } from '@/lib/utils';-import { streamChatMessage, ChatMessage, getAIConfig } from '@/lib/ai-client';+import { streamChatMessage, generateChatMessage, ChatMessage, getAIConfig } from '@/lib/ai-client';import { DRAWIO_SYSTEM_PROMPT } from '@/lib/system-prompts';import { Button } from '@/components/ui/button';import { ChatInput } from '@/components/ChatInput';@@ -10,7 +10,7 @@ import { GlobalConstraintsDialog, STORAGE_GLOBAL_CONSTRAINTS_KEY } from '@/compoimport { HistoryDialog, HistoryItem } from '@/components/history-dialog';import { ResetWarningModal } from '@/components/reset-warning-modal';import { useFileProcessor } from '@/lib/use-file-processor';-import { buildCadBomMessages, buildCadImagesMessages, buildCadTasksSystemContent } from '@/lib/cad-tasks';+import { buildCadBomMessages, buildCadImagesMasterMessages, buildCadImagesSheetMessages, buildCadTasksSystemContent } from '@/lib/cad-tasks';import { CAD_PLAN_AGENT_PROMPT, CAD_SVG_GENERATE_AGENT_PROMPT, CAD_SVG_PATCH_AGENT_PROMPT } from '@/lib/cad-agents';import flowPatchAgentPrompt from "../../agent/flow/patch.md?raw";import flowReplaceAgentPrompt from "../../agent/flow/replace.md?raw";@@ -207,7 +207,10 @@ export function ChatPanel({if (!/^\s*\|?(\s*:?-+:?\s*\|)+\s*:?-+:?\s*\|?\s*$/.test(sep)) continue;const parseRow = (line: string) => {- const trimmed = line.trim();+ const trimmed = line+ .trim()+ .replace(/^[-*+]\s+/, "")+ .replace(/^\d+\.\s+/, "");const body = trimmed.startsWith("|") ? trimmed.slice(1) : trimmed;const body2 = body.endsWith("|") ? body.slice(0, -1) : body;return body2.split("|").map((c) => c.trim());@@ -665,9 +668,11 @@ export function ChatPanel({const constraintsKey = workspaceId ? `${STORAGE_GLOBAL_CONSTRAINTS_KEY}-${workspaceId}` : STORAGE_GLOBAL_CONSTRAINTS_KEY;const globalConstraints = typeof window !== 'undefined' ? localStorage.getItem(constraintsKey) || '' : '';const globalSystemPrompt = config.systemPrompt || '';- const systemContent = buildCadTasksSystemContent({ globalSystemPrompt, globalConstraints });+ const systemContent = [buildCadTasksSystemContent({ globalSystemPrompt, globalConstraints }), `UI language: ${uiLang}`]+ .filter(Boolean)+ .join("\n\n");const bomMessages: ChatMessage[] = buildCadBomMessages({ systemContent, planJson, svg2d });- const imagesMessages: ChatMessage[] = buildCadImagesMessages({ systemContent, planJson, svg2d });+ const masterMessages: ChatMessage[] = buildCadImagesMasterMessages({ systemContent, planJson, svg2d });setIsLoading(true);abortControllerRef.current?.abort();@@ -699,10 +704,95 @@ export function ChatPanel({})();const imagesTask = (async () => {- await streamChatMessage(imagesMessages, (chunk) => {- imagesFull = chunk;- }, chatModel, controller.signal);- if (imagesFull) emitCadJson(imagesFull);+ const extractJsonText = (text: string) => {+ const match = String(text || "").match(/```json\s*([\s\S]*?)```/);+ return match ? match[1].trim() : String(text || "").trim();+ };++ const tryParseJson = (text: string) => {+ const normalized = extractJsonText(text);+ try {+ return JSON.parse(normalized);+ } catch {+ const start = normalized.indexOf("{");+ const end = normalized.lastIndexOf("}");+ if (start >= 0 && end > start) {+ try {+ return JSON.parse(normalized.slice(start, end + 1));+ } catch {+ }+ }+ return null;+ }+ };++ const fallbackTitlesForOutput = [+ trText("装修平面布置图", "Renovation Plan Layout"),+ trText("地面铺装图", "Floor Finish Plan"),+ trText("顶棚平面图", "Reflected Ceiling Plan"),+ trText("墙体定位图", "Wall Setting-Out Plan"),+ trText("机电综合图(强电+弱电+给排水)", "MEP Plan (Electrical + Low Voltage + Plumbing)"),+ trText("立面索引图+室内立面图", "Elevation Index Plan + Interior Elevations"),+ trText("节点详图", "Detail Drawings"),+ ];+ const fallbackTitlesForPromptEnglish = [+ "Renovation Plan Layout",+ "Floor Finish Plan",+ "Reflected Ceiling Plan",+ "Wall Setting-Out Plan",+ "MEP Plan (Electrical + Low Voltage + Plumbing)",+ "Elevation Index Plan + Interior Elevations",+ "Detail Drawings",+ ];++ let masterSchemeJson = "";+ try {+ const masterText = await generateChatMessage(masterMessages, chatModel, { signal: controller.signal, timeoutMs: 120000 });+ const parsedMaster = tryParseJson(masterText);+ if (parsedMaster?.type === "renovation_scheme_master" && parsedMaster?.global_scheme) {+ masterSchemeJson = JSON.stringify(parsedMaster, null, 2);+ }+ } catch {+ }++ const imagesSheetMessages = buildCadImagesSheetMessages({ systemContent, planJson, svg2d, masterSchemeJson });++ const settled = await Promise.allSettled(+ imagesSheetMessages.map((s) =>+ generateChatMessage(s.messages, chatModel, { signal: controller.signal, timeoutMs: 120000 })+ )+ );++ const prompts = settled.map((r, idx) => {+ const fallbackTitleForOutput = fallbackTitlesForOutput[idx] || trText("装修图", "Drawing");+ const fallbackTitleForPrompt = fallbackTitlesForPromptEnglish[idx] || "Drawing";+ const onSheetLanguageRule =+ uiLang === "zh"+ ? "All on-sheet labels/notes/title block text must be in Simplified Chinese."+ : "All on-sheet labels/notes/title block text must be in English.";+ const fallbackPrompt = `Generate an orthographic 2D technical construction drawing sheet: ${fallbackTitleForPrompt}. Include border, bottom-right title block, scale/units, legend/symbols, key annotations and dimensions, consistent with the provided plan JSON and 2D SVG. ${onSheetLanguageRule}`;++ if (r.status !== "fulfilled") return { title: fallbackTitleForOutput, prompt: fallbackPrompt };+ const text = String(r.value || "").trim();+ const parsed = tryParseJson(text);++ if (parsed?.type === "cad_images_sheet" && typeof parsed?.title === "string" && typeof parsed?.prompt === "string") {+ const p = parsed.prompt.trim();+ return { title: parsed.title, prompt: p || fallbackPrompt };+ }++ if (parsed?.type === "cad_images" && Array.isArray(parsed?.prompts) && parsed.prompts.length > 0) {+ const first = parsed.prompts[0];+ const title = typeof first?.title === "string" ? first.title : fallbackTitleForOutput;+ const prompt = typeof first?.prompt === "string" ? first.prompt.trim() : "";+ return { title, prompt: prompt || fallbackPrompt };+ }++ return { title: fallbackTitleForOutput, prompt: fallbackPrompt };+ });++ imagesFull = JSON.stringify({ type: "cad_images", prompts }, null, 2);+ emitCadJson(imagesFull);})();try {@@ -920,20 +1010,18 @@ export function ChatPanel({const planJson = cadContext?.plan ? JSON.stringify(cadContext.plan) : "";const svg2d = cadContext?.svg2d || "";- if (agent === "cad_bom_agent" || agent === "cad_images_agent") {- const systemContentTasks = buildCadTasksSystemContent({ globalSystemPrompt, globalConstraints });- const taskMessages =- agent === "cad_bom_agent"- ? buildCadBomMessages({ systemContent: systemContentTasks, planJson, svg2d })- : buildCadImagesMessages({ systemContent: systemContentTasks, planJson, svg2d });+ if (agent === "cad_bom_agent") {+ const systemContentTasks = [buildCadTasksSystemContent({ globalSystemPrompt, globalConstraints }), `UI language: ${uiLang}`]+ .filter(Boolean)+ .join("\n\n");+ const taskMessages = buildCadBomMessages({ systemContent: systemContentTasks, planJson, svg2d });const taskFull = await runCadTaskMessages(taskMessages);if (taskFull) {emitCadJson(taskFull);- if (agent === "cad_bom_agent") {- const fallback = parseMarkdownBomTable(taskFull);- if (fallback) onCodeAction?.(JSON.stringify(fallback), "cad");- }+ const fallback = parseMarkdownBomTable(taskFull);+ if (fallback) onCodeAction?.(JSON.stringify(fallback), "cad");+const producedHasPlan = /"type"\s*:\s*"cad_plan"/.test(taskFull);const producedHasSvg2d = /```svg[\s\S]*?```/.test(taskFull);const producedHasImages = /"type"\s*:\s*"cad_images"/.test(taskFull);@@ -952,6 +1040,122 @@ export function ChatPanel({return;}+ if (agent === "cad_images_agent") {+ const systemContentTasks = [buildCadTasksSystemContent({ globalSystemPrompt, globalConstraints }), `UI language: ${uiLang}`]+ .filter(Boolean)+ .join("\n\n");+ const masterMessages: ChatMessage[] = buildCadImagesMasterMessages({ systemContent: systemContentTasks, planJson, svg2d });++ updateLastAssistant(trText("正在生成出图提示词…", "Generating drawing prompts…"));++ const extractJsonText = (text: string) => {+ const match = String(text || "").match(/```json\s*([\s\S]*?)```/);+ return match ? match[1].trim() : String(text || "").trim();+ };++ const tryParseJson = (text: string) => {+ const normalized = extractJsonText(text);+ try {+ return JSON.parse(normalized);+ } catch {+ const start = normalized.indexOf("{");+ const end = normalized.lastIndexOf("}");+ if (start >= 0 && end > start) {+ try {+ return JSON.parse(normalized.slice(start, end + 1));+ } catch {+ }+ }+ return null;+ }+ };++ const fallbackTitlesForOutput = [+ trText("装修平面布置图", "Renovation Plan Layout"),+ trText("地面铺装图", "Floor Finish Plan"),+ trText("顶棚平面图", "Reflected Ceiling Plan"),+ trText("墙体定位图", "Wall Setting-Out Plan"),+ trText("机电综合图(强电+弱电+给排水)", "MEP Plan (Electrical + Low Voltage + Plumbing)"),+ trText("立面索引图+室内立面图", "Elevation Index Plan + Interior Elevations"),+ trText("节点详图", "Detail Drawings"),+ ];+ const fallbackTitlesForPromptEnglish = [+ "Renovation Plan Layout",+ "Floor Finish Plan",+ "Reflected Ceiling Plan",+ "Wall Setting-Out Plan",+ "MEP Plan (Electrical + Low Voltage + Plumbing)",+ "Elevation Index Plan + Interior Elevations",+ "Detail Drawings",+ ];++ let masterSchemeJson = "";+ try {+ const masterText = await generateChatMessage(masterMessages, chatModel, { signal: controller.signal, timeoutMs: 120000 });+ const parsedMaster = tryParseJson(masterText);+ if (parsedMaster?.type === "renovation_scheme_master" && parsedMaster?.global_scheme) {+ masterSchemeJson = JSON.stringify(parsedMaster, null, 2);+ }+ } catch {+ }++ const imagesSheetMessages = buildCadImagesSheetMessages({+ systemContent: systemContentTasks,+ planJson,+ svg2d,+ masterSchemeJson,+ });++ const settled = await Promise.allSettled(+ imagesSheetMessages.map((s) =>+ generateChatMessage(s.messages, chatModel, { signal: controller.signal, timeoutMs: 120000 })+ )+ );++ const prompts = settled.map((r, idx) => {+ const fallbackTitleForOutput = fallbackTitlesForOutput[idx] || trText("装修图", "Drawing");+ const fallbackTitleForPrompt = fallbackTitlesForPromptEnglish[idx] || "Drawing";+ const onSheetLanguageRule =+ uiLang === "zh"+ ? "All on-sheet labels/notes/title block text must be in Simplified Chinese."+ : "All on-sheet labels/notes/title block text must be in English.";+ const fallbackPrompt = `Generate an orthographic 2D technical construction drawing sheet: ${fallbackTitleForPrompt}. Include border, bottom-right title block, scale/units, legend/symbols, key annotations and dimensions, consistent with the provided plan JSON and 2D SVG. ${onSheetLanguageRule}`;++ if (r.status !== "fulfilled") return { title: fallbackTitleForOutput, prompt: fallbackPrompt };+ const text = String(r.value || "").trim();+ const parsed = tryParseJson(text);++ if (parsed?.type === "cad_images_sheet" && typeof parsed?.title === "string" && typeof parsed?.prompt === "string") {+ const p = parsed.prompt.trim();+ return { title: parsed.title, prompt: p || fallbackPrompt };+ }++ if (parsed?.type === "cad_images" && Array.isArray(parsed?.prompts) && parsed.prompts.length > 0) {+ const first = parsed.prompts[0];+ const title = typeof first?.title === "string" ? first.title : fallbackTitleForOutput;+ const prompt = typeof first?.prompt === "string" ? first.prompt.trim() : "";+ return { title, prompt: prompt || fallbackPrompt };+ }++ return { title: fallbackTitleForOutput, prompt: fallbackPrompt };+ });++ const payload = JSON.stringify({ type: "cad_images", prompts }, null, 2);+ onCodeAction?.(payload, "cad");++ const guide = buildCadNextStepGuide({+ agent,+ beforeHasPlan,+ beforeHasSvg2d,+ producedHasPlan: false,+ producedHasSvg2d: false,+ producedHasImages: true,+ producedHasBom: false,+ });+ updateLastAssistant(guide || trText("已生成出图任务。", "Drawing tasks generated."));+ return;+ }+const agentPrompt =agent === "cad_plan_agent"? CAD_PLAN_AGENT_PROMPTdiff --git a/src/components/workspaces/CadWorkspace.tsx b/src/components/workspaces/CadWorkspace.tsxindex 81476bb..53dd339 100644--- a/src/components/workspaces/CadWorkspace.tsx+++ b/src/components/workspaces/CadWorkspace.tsx@@ -253,7 +253,7 @@ export function CadWorkspace({ onAddToChat, svg2d, plan, images = [], imagesLoadconst fixed = (bom.columns || []).map((_, i) => esc(arr[i] ?? ""));rows.push(fixed.join(","));}- const csv = rows.join("\r\n");+ const csv = `\uFEFF${rows.join("\r\n")}`;downloadBlob(new Blob([csv], { type: "text/csv;charset=utf-8" }), `bom-${Date.now()}.csv`);} finally {setIsExporting(false);diff --git a/src/lib/cad-tasks.ts b/src/lib/cad-tasks.tsindex 5daaee8..a06efd0 100644--- a/src/lib/cad-tasks.ts+++ b/src/lib/cad-tasks.ts@@ -1,7 +1,14 @@import type { ChatMessage } from "@/lib/ai-client";import cadBomPromptTemplate from "../../agent/cad/bom-prompt.md?raw";-import cadImagesPromptTemplate from "../../agent/cad/images-prompt.md?raw";+import cadImagesMasterRenovationSchemeTemplate from "../../agent/cad/images-agents/master-renovation-scheme.agent.md?raw";+import cadRenovationPlanLayoutTemplate from "../../agent/cad/images-agents/renovation-plan-layout.agent.md?raw";+import cadFloorFinishPlanTemplate from "../../agent/cad/images-agents/floor-finish-plan.agent.md?raw";+import cadReflectedCeilingPlanTemplate from "../../agent/cad/images-agents/reflected-ceiling-plan.agent.md?raw";+import cadWallSettingOutPlanTemplate from "../../agent/cad/images-agents/wall-setting-out-plan.agent.md?raw";+import cadMepPlanTemplate from "../../agent/cad/images-agents/mep-plan.agent.md?raw";+import cadElevationIndexAndInteriorElevationsTemplate from "../../agent/cad/images-agents/elevation-index-and-interior-elevations.agent.md?raw";+import cadDetailDrawingsTemplate from "../../agent/cad/images-agents/detail-drawings.agent.md?raw";function applyTemplate(template: string, vars: Record<string, string>) {let out = String(template || "");@@ -18,13 +25,6 @@ export function buildCadBomPrompt(args: { planJson: string; svg2d: string }) {});}-export function buildCadImagesPrompt(args: { planJson: string; svg2d: string }) {- return applyTemplate(cadImagesPromptTemplate, {- planJson: String(args.planJson || ""),- svg2d: String(args.svg2d || ""),- });-}-export function buildCadTasksSystemContent(args: {globalSystemPrompt: string;globalConstraints: string;@@ -43,13 +43,51 @@ export function buildCadBomMessages(args: {];}-export function buildCadImagesMessages(args: {+export function buildCadImagesMasterMessages(args: {systemContent: string;planJson: string;svg2d: string;}): ChatMessage[] {return [{ role: "system", content: args.systemContent },- { role: "user", content: buildCadImagesPrompt({ planJson: args.planJson, svg2d: args.svg2d }) },+ {+ role: "user",+ content: applyTemplate(cadImagesMasterRenovationSchemeTemplate, {+ planJson: String(args.planJson || ""),+ svg2d: String(args.svg2d || ""),+ }),+ },+ ];+}++export function buildCadImagesSheetMessages(args: {+ systemContent: string;+ planJson: string;+ svg2d: string;+ masterSchemeJson?: string;+}): Array<{ sheetId: string; messages: ChatMessage[] }> {+ const sheets: Array<{ sheetId: string; template: string }> = [+ { sheetId: "renovation_plan_layout", template: cadRenovationPlanLayoutTemplate },+ { sheetId: "floor_finish_plan", template: cadFloorFinishPlanTemplate },+ { sheetId: "reflected_ceiling_plan", template: cadReflectedCeilingPlanTemplate },+ { sheetId: "wall_setting_out_plan", template: cadWallSettingOutPlanTemplate },+ { sheetId: "mep_plan", template: cadMepPlanTemplate },+ { sheetId: "elevation_index_and_interior_elevations", template: cadElevationIndexAndInteriorElevationsTemplate },+ { sheetId: "detail_drawings", template: cadDetailDrawingsTemplate },];++ return sheets.map((s) => ({+ sheetId: s.sheetId,+ messages: [+ { role: "system", content: args.systemContent },+ {+ role: "user",+ content: applyTemplate(s.template, {+ planJson: String(args.planJson || ""),+ svg2d: String(args.svg2d || ""),+ masterSchemeJson: String(args.masterSchemeJson || ""),+ }),+ },+ ],+ }));}