---
id: TASK-39
title: Port MycelialIntelligence system (global AI bar + shape)
status: To Do
assignee: []
created_date: '2026-02-18 19:51'
labels:
  - shape-port
  - phase-5
  - ai
  - infrastructure
milestone: m-0
dependencies:
  - TASK-25
references:
  - canvas-website/src/ui/MycelialIntelligenceBar.tsx
  - canvas-website/src/shapes/MycelialIntelligenceShapeUtil.tsx
priority: high
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Port the MycelialIntelligence system from canvas-website to rspace-online. This is a GLOBAL UI element (not just a shape).

Sources:
- canvas-website/src/ui/MycelialIntelligenceBar.tsx (2,231 lines) — the main AI bar
- canvas-website/src/shapes/MycelialIntelligenceShapeUtil.tsx (69 lines) — backward-compat shape

Target: rspace-online/lib/mycelial-intelligence-bar.ts (Web Component) + rspace-online/lib/folk-mycelial-intelligence.ts (shape)

This is the largest single migration item. Implement in phases:

Phase A: Basic chat UI bar (fixed bottom bar with prompt input + response display)
Phase B: Canvas context awareness (knows selected shapes, viewport contents)
Phase C: Shape creation/modification via AI commands (create shapes, edit properties)
Phase D: Full tool integration (all AI capabilities available through bar)

The bar should be added as a persistent element in canvas.html, independent of the shape system.
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 AI bar renders as persistent bottom UI element
- [ ] #2 Chat prompt sends to LLM and displays responses
- [ ] #3 Bar is context-aware of selected shapes and canvas state
- [ ] #4 Can create/modify shapes via AI commands
- [ ] #5 Backward-compat folk-mycelial-intelligence shape exists
- [ ] #6 Toolbar button toggles bar visibility
<!-- AC:END -->
