GlyphfieldDocs
Documentation/System reference

Source code editing

Round-trip the active artifact through validated JSON without separating code, canvas, persistence, and export.

Maintained with source

Every source-enabled Studio tool can be edited visually or structurally. Code opens the document beside the live canvas; window.glyphfield.studio exposes the same read/apply boundary to agents.

Design Lab with the live composition and inspector visible together
One artifact, two editing modesVisual controls and source stay synchronized

Human workflow

  1. Select a project and tool.
  2. Open Code from the tool action area.
  3. Make a targeted edit to the current source.
  4. Select Apply.
  5. Resolve any inline validation error.
  6. Inspect the canvas and layers.
  7. Continue visually, save the design, or export.

Reset reloads the latest visual snapshot into the editor. Close dismisses the drawer without applying uncommitted text. The drawer does not create a second copy of the artifact.

Agent workflow

const studio = window.glyphfield.studio;
const capabilities = studio.describe();
if (!capabilities.source.read || !capabilities.source.apply) {
  throw new Error(`${capabilities.toolId} does not expose source round trips.`);
}

const document = JSON.parse(studio.readSource());
// Preserve the document and edit only known fields.
await studio.applySource(document);

Application waits for the tool validator and two animation frames. Image decode, font loading, shader compilation, and encoding may take longer; wait for the relevant preview before capture.

Source families

FamilyToolsShape
Shared identityBrand identity and identity-bound foundationsComplete brand record or controlled identity subset
Portable canvasDesign LabCanvasDocument v2, Design Lab metadata source v4
MotionAnimationSequence, frame, transform, timing, shader, output, and audio state
Vector animationLottieRaw Lottie JSON when a JSON document is available
Expression configurationOpenGraph, Terminal, Partnership, Blog, Slides, ComponentsTool-specific content, layout, asset, and transform object
Derived publicationBrand bookIdentity is source; the book is regenerated output

Why current source is authoritative

Examples explain concepts but may omit fields added by later releases. readSource() contains the active migration result, stable IDs, exact asset references, layer order, saved frame/timeline values, and tool metadata. Starting there prevents logos from shifting, layers from reordering, or newer settings from disappearing.

Do not:

  • Recreate a CanvasDocument from an old code sample.
  • Change element IDs when updating content or style.
  • Drop unknown metadata or assets.
  • Write directly to localStorage or IndexedDB.
  • Apply one tool's document to another tool.
  • Treat a successful apply as visual verification.

Design Lab specifics

Design Lab source contains the complete composition: pages, elements, embedded/library assets, exact order, groups, layer shaders, text/converter effects, background color, output settings, shader frame history, and sequence timeline. Named saves and autosave use the same portable source.

Use a design-sequence HTTP response when an agent needs to create a new exact composition. Use readSource() for an existing one. Both are applied through the active Design Lab adapter, whose public tool ID is material.

Source versus generation request

POST /api/generate accepts a concise, versioned request and returns an artifact or apply-ready document. A source drawer exposes the richer state of one open browser tool. They are not interchangeable.

The safe bridge is explicit:

const generated = await fetch('/api/generate', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    kind: 'design-sequence',
    identity: { preset: 'gt' },
    shader: { materialId: 'paper-gem-smoke' },
    sequence: { cutCount: 10, finalHoldMs: 5000, pace: 'accelerating' }
  })
}).then((response) => response.json());

await window.glyphfield.studio.applySource(generated.document);

See Source format reference, Studio Browser API, and Agent recipes.

On this page