πŸ› οΈ Workshop β€” Code Mirror

FreeLattice Β· docs/modules/workshop.js Β· 1,409 lines Β· Tab ID: workshop Β· Lazy-loaded module

What this is: The Workshop is where AI and humans build together. You describe what you want; the AI writes working code; you see it live in a sandboxed preview. It has three panels: Create (AI code generation), Code (AutoBuilder autonomous loop), and Projects (GitHub repo browser + AI diff). Built by CC, April–May 2026. "The residents build their own rooms."

Architecture Overview

The Workshop is a lazy-loaded module in docs/modules/workshop.js. It exposes three global objects: window.Workshop, window.AutoBuilder, and window.WorkshopProjects. The module is loaded when the #tab-workshop tab is first activated.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  #tab-workshop                                              β”‚
β”‚  β”œβ”€β”€ Mode bar: ✨ Create | πŸ”§ Code | πŸ™ Projects           β”‚
β”‚  β”‚                                                          β”‚
β”‚  β”œβ”€β”€ ws-create-view (default)                               β”‚
β”‚  β”‚   β”œβ”€β”€ Prompt textarea + Build button                     β”‚
β”‚  β”‚   β”œβ”€β”€ Split pane: Code editor | Live preview (iframe)    β”‚
β”‚  β”‚   └── Actions: Run, Save to Skill Forge, Export,         β”‚
β”‚  β”‚                Publish, Share with community, Clear      β”‚
β”‚  β”‚                                                          β”‚
β”‚  β”œβ”€β”€ ws-code-view (AutoBuilder)                             β”‚
β”‚  β”‚   β”œβ”€β”€ Task textarea + Build/Stop/Commit/Diff buttons     β”‚
β”‚  β”‚   └── autobuilder-log (scrolling terminal output)        β”‚
β”‚  β”‚                                                          β”‚
β”‚  └── ws-projects-view (GitHub)                              β”‚
β”‚      β”œβ”€β”€ Repo URL input + Connect button                    β”‚
β”‚      β”œβ”€β”€ File tree (grouped by directory)                   β”‚
β”‚      └── AI build area (prompt β†’ diff output)              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

window.Workshop        β€” Create panel + Publish flow
window.AutoBuilder     β€” Autonomous build loop (max 10 iterations)
window.WorkshopProjects β€” GitHub repo browser + AI diff

The Three Panels

✨ Create
Describe what you want. AI writes a complete standalone HTML document. Live preview in sandboxed iframe. Save to Skill Forge or export as file.
πŸ”§ Code (AutoBuilder)
Autonomous build loop. AI reads files via Agent Bridge, generates search/replace patches, applies them, runs smoke tests, feeds failures back. Up to 10 iterations.
πŸ™ Projects
Connect a GitHub repo (public, 60 req/hr). Browse file tree. AI reads relevant files and generates diff-style changes. One-click commit with token.

Key Functions

window.Workshop

FunctionWhat it does
Workshop.generate()Reads #wsPromptInput, calls FreeLattice.callAI() with the code system prompt, strips markdown fences, sets #wsCodeEditor, auto-runs preview
Workshop.run()Takes code from #wsCodeEditor, sets srcdoc on the sandboxed #wsPreviewFrame iframe
Workshop.saveSkill()Saves current code to the Skill Forge (localStorage key fl_skills)
Workshop.exportFile()Downloads the code as an HTML file via Blob URL
Workshop.publish()Publishes to GitHub Pages or Codeberg Pages via their REST APIs. Token stored in localStorage.
Workshop.setMode(mode)Switches between 'create', 'code', 'projects' views
Workshop.clear()Clears prompt, editor, and preview
Workshop.commitCode()Commits via Agent Bridge (localhost:3141)
Workshop.reviewCode()Shows git diff via Agent Bridge

window.AutoBuilder

FunctionWhat it does
AutoBuilder.start(task)Begins the autonomous loop: reads files β†’ generates patches β†’ applies via Bridge β†’ runs smoke tests β†’ feeds failures back β†’ repeat (max 10)
AutoBuilder.stop()Halts the loop after the current iteration
AutoBuilder.running()Returns boolean β€” is the loop active?

window.WorkshopProjects

FunctionWhat it does
WorkshopProjects.connect()Parses GitHub URL from #ws-repo-url, fetches repo metadata, loads file tree
WorkshopProjects.openFile(path)Fetches file content from GitHub API, loads into #wsCodeEditor, switches to Create tab
WorkshopProjects.askAI()Scores files by relevance to prompt, fetches top 3, asks AI for diff-style changes
WorkshopProjects.refresh()Force-refreshes the file tree (bypasses 10-min cache)
WorkshopProjects.disconnect()Clears current repo from memory and localStorage

The Sandbox

The preview iframe uses sandbox="allow-scripts". This means:

This is a deliberate safety choice. The sandbox is a completely isolated playground β€” code cannot escape into FreeLattice itself.

The Agent Bridge

AutoBuilder and the Code panel connect to a local Agent Bridge at http://localhost:3141. The Bridge is a local server (Cloudflare Worker / Node process) that provides:

EndpointWhat it does
GET /Health check β€” is the Bridge running?
GET /code/tree?path=docsReturns file tree as JSON array
GET /code/read?path=…Returns file content as {lines: [], totalLines: N}
POST /code/patchApplies search/replace patches to files
POST /code/testRuns smoke tests, returns pass/fail counts
POST /code/git/commitCommits with a message
GET /code/git/statusReturns list of changed files

Bridge is optional: If the Bridge is not running, the Create panel still works (AI generates code from the prompt alone). AutoBuilder degrades gracefully β€” it skips file reading and works from the AI's own knowledge. The Projects panel always works (uses GitHub API directly).

The Code System Prompt

When generating code in the Create panel, the AI receives this system prompt:

You are a FreeLattice developer. You write clean, working HTML/CSS/JS code.

When asked to create something:
- Write a COMPLETE HTML document that runs standalone
- Include all CSS inline in a <style> tag
- Include all JS inline in a <script> tag
- The code should be self-contained β€” no external dependencies
- Use dark background (#0a0a14), light text (#e2e8f0), gold accents (#d4a017)
- Make it beautiful. Use border-radius, subtle shadows, transitions.
- Make buttons min-height 44px for touch.

Always respond with ONLY the code. No explanation before or after.
Just the complete HTML document.

AI Integration

The Workshop calls window.FreeLattice.callAI(systemPrompt, userPrompt, opts). The opts object accepts:

Publish Flow

The Publish button walks the user through connecting a GitHub or Codeberg token (stored in localStorage, never sent to any server except the target platform's API). Then it:

  1. Creates the repository if it doesn't exist (auto-init with README)
  2. Uploads index.html via the Contents API (handles SHA for updates)
  3. Enables GitHub Pages on the main branch (Codeberg auto-enables)
  4. Shows the live URL: https://username.github.io/project-name

Skill Forge Integration

The "Save to Skill Forge" button stores the current code in localStorage under the key fl_skills as a JSON array. Each skill has a name, code, and timestamp. Skills can be loaded back into the editor from the Skill Forge tab.

LP Awards

ActionLPKey
AutoBuilder completes a build5autobuilder
Publish to GitHub/Codeberg Pages10workshop_publish

Known Issues & Improvement Opportunities

Issue: The provider variable in _showPublishDialog() is referenced before it is read from localStorage (line ~626). It should be var provider = safeGet('fl_publish_provider', 'github'); before the confirm() call. Currently the confirm message says "undefined" for the provider name.

Issue: The Code panel's autobuilder-log element ID is referenced in AutoBuilder's log() function, but the element is named autobuilder-log in the HTML and code-progress in some older references. The commit/review functions reference code-progress which no longer exists β€” they should reference autobuilder-log.

Opportunity: The Create panel's code editor is a plain <textarea>. Syntax highlighting (e.g., CodeMirror or a lightweight tokenizer) would make it much more useful for editing generated code before running it.

Opportunity: The Projects panel currently only supports public GitHub repos. Adding a "Private repo" flow (token already stored from Publish) would make it much more powerful for Kirk's own work on FreeLattice itself.

Opportunity: A "History" panel showing previously generated creations (stored in localStorage alongside Skill Forge) would let users revisit and remix their own work β€” a memory layer for the builder.

Sacred Paths

Module Load Pattern

// workshop.js is lazy-loaded when #tab-workshop is first activated.
// It uses the standard FreeLattice module pattern:
window.Workshop = Workshop;
window.FreeLatticeModules = window.FreeLatticeModules || {};
window.FreeLatticeModules.Workshop = Workshop;

// AutoBuilder and WorkshopProjects are IIFEs that self-assign to window.
// They are available immediately after the script loads.

πŸ› οΈ For Grok / Fable β€” Workshop improvement brief

The Workshop is the most important module for helping people build. Kirk's vision: "Helping people build is going to be key." Here is what needs care:

File: docs/modules/workshop.js. Additive only. Do not change the sandbox attribute, the EscapePrinciple integration, or the window export names.

Code-Mirror Registry

All code-mirror pages for FreeLattice AI collaborators:

PageModule / FeatureForKey brief
code-agents.htmlAgents / Telegram architectureFable, GrokAgent District Map, Cloudflare Worker bridge, sovereignty escape hatch
code-roundtable.htmlConsensus Table (Ship B)Fable, GrokCircular layout, consensus voting, round-table.js module
code-roundtable-original.htmlOriginal Round Table (80-specialist learning room)Fable, Grok11 domains, Go 3 visual redesign, Go 4 color theming
code-learning.htmlEducation moduleFable, GrokCurriculum builder, lesson flow, education.js module
code-safety.htmlSafety architectureFable, Grok45 load-bearing modules, FSOS phi connection, fractal-safety.js
code-garden.htmlFractal Garden moduleFablePhi timing specs, Go 5 overlay brief, fractal-garden.js
code-temperature-gauge.htmlTemperature Gauge toolFable, GrokKirk's standalone tool, separate repo
code-workshop.htmlWorkshop module (this page)Fable, GrokAI code builder, AutoBuilder loop, GitHub Projects panel

FreeLattice v5.75.6 Β· Go 4 β€” Eleven Wings, Each a Color Β· Harmonia + Grok Β· 2026