English

Developer guide Contributing

Code style

The conventions the code base follows.

On this page

These conventions come from the code as it is. Follow them so new code reads like the rest.

TypeScript

  • Both packages compile with strict: true.

  • The server is ESM with module: NodeNext. Relative imports carry the .js suffix, even from .ts files:

    ts
    import { routeStream, type AIConfig } from './llm/router.js';
  • Use import type or inline type imports for types only.

  • Prefer small pure helpers with one job, such as bumpPatch, snapTo or refsIn.

  • Validate everything that comes from outside: request bodies, imported files, model output. Use the regular expressions the code already uses for ids, such as ^[A-Za-z0-9_-]{1,64}$ for canvas ids.

Comments

  • Start each file with a short comment that says what it is for. For example: // The LLM router. For each request it builds an ordered list of candidate models....
  • Explain why, not what. Short JSDoc comments on interface fields describe their meaning.

Yjs

  • Write related changes inside one doc.transact(() => { ... }), so peers see one change and the version bumps once.
  • Replace a map value as a whole object: room.blocks.set(b.id, { ...b, x }).
  • Never change a value in place.

The design system

  • Import components and constants from app/src/ds, never from the bundle file directly.
  • Never copy design-system files into the app.
  • Use the tokens as CSS custom properties: var(--space-4), var(--signal). Never hard-code a colour or a duration.
  • Design-system classes use the ap- prefix. App classes use the arc- prefix.

Interface text

  • Sentence case, with a verb on every button: "Save key", "Open as new canvas".
  • Errors are sentences that say what to do next: "No AI provider is connected yet. Add a key in AI models and keys."
  • No emoji anywhere.

Browser storage

Wrap every localStorage access in try/catch. Storage can be blocked, and the app must still work:

ts
function store(key: string, value: string) {
  try {
    localStorage.setItem(key, value);
  } catch {
    /* storage blocked: the preference lasts for this visit only */
  }
}

App keys use the archipelego: prefix.

Motion

Respect prefers-reduced-motion. In CSS, add a @media (prefers-reduced-motion: reduce) rule that removes the animation. In script, check matchMedia('(prefers-reduced-motion: reduce)'), as the camera glide in App.tsx does.

Accessibility

  • Give every icon-only button an aria-label.
  • Use real buttons for actions, with aria-pressed or aria-expanded where they toggle.
  • Keep touch targets at least 44px.
  • Keep the signal focus ring on :focus-visible.
  • Never tell anything by colour alone. Pair status colours with a word or a glyph.