agentleFS
InditexTechInditexTech/weavejs/.github/copilot-instructions.md

weavejs

Copilot instructions246 starsChanged 46 days agoApache-2.0View on GitHub

SPDX-License-Identifier: Apache-2.0 --> Weave.js is a collaborative whiteboard/canvas SDK built on Konva (2D canvas rendering) and Yjs (CRDT-based real-time sync). It is a monorepo managed with Nx and npm workspaces. All source code lives under code/. All commands run from the code/ directory. The Weave class (in sdk/src/weave.ts) is the central orchestrator. It is constructed with a WeaveConfig that wires together the four extension points: Internally, Weave delegates to a set of Manager classes (e.g., WeaveStageManager, WeaveStateManager, WeavePluginsManager) which are…

  • Installs packages

We split this copilot-instructions.md into the rules it gives an agent

6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All commands run from the code/ directory.

    line 15
  2. Very specific:

    Always call setupDefaultNodeAugmentation() and setupDefaultNodeEvents() when implementing custom nodes.

    line 111
  3. Distinctive:

    Every source file must start with:

    line 157
  4. Very specific:

    Use import type for type-only imports (verbatimModuleSyntax is on).

    line 173
  5. Very specific:

    Follow Conventional Commits.

    line 181
  6. Very specific:

    Run npm run reset (which runs nx reset) to clear the Nx computation cache if builds behave unexpectedly.

    line 202

≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md
<!-- SPDX-FileCopyrightText: 2025 2025 INDUSTRIA DE DISEÑO TEXTIL S.A. (INDITEX S.A.) SPDX-License-Identifier: Apache-2.0 -->

Copilot Instructions for Weave.js

Project Overview

Weave.js is a collaborative whiteboard/canvas SDK built on Konva (2D canvas rendering) and Yjs (CRDT-based real-time sync). It is a monorepo managed with Nx and npm workspaces. All source code lives under code/.

Build, Test, and Lint Commands

All commands run from the code/ directory.

# Install dependencies
npm install

# Build all packages
npm run build

# Build a single package
npm run build --workspace=@inditextech/weave-sdk

# Lint all packages
npm run lint

# Lint a single package
npm run lint --workspace=@inditextech/weave-sdk

# Format all packages
npm run format

# Run all tests
npm run test

# Run tests for a single package
npm run test --workspace=@inditextech/weave-sdk

# Run a single test file (from within a package directory)
npx vitest run path/to/file.test.ts

# Type-check the SDK
npm run types:check --workspace=@inditextech/weave-sdk

Repository Structure

code/packages/
  sdk/                        # Core SDK (@inditextech/weave-sdk)
  types/                      # Shared TypeScript types (@inditextech/weave-types)
  react/                      # React integration (@inditextech/weave-react)
  renderer-konva-base/        # Base Konva renderer
  renderer-konva-react-reconciler/  # React-reconciler-based Konva renderer
  store-standalone/           # In-memory store (no network)
  store-websockets/           # WebSocket-based collaborative store
  store-azure-web-pubsub/     # Azure Web PubSub collaborative store
  create-backend-app/         # CLI to scaffold a backend test app
  create-frontend-app/        # CLI to scaffold a frontend test app
docs/                         # Fumadocs-based documentation site (MDX)

Architecture

The Weave class (in sdk/src/weave.ts) is the central orchestrator. It is constructed with a WeaveConfig that wires together the four extension points:

Extension PointBase ClassPurpose
WeaveStoreAbstract classYjs sync transport (WebSocket, Azure WS, standalone)
WeaveRendererAbstract classKonva rendering engine
WeaveNodeAbstract classCanvas shape definition
WeaveActionAbstract classTool behavior (draw, select, move…)
WeavePluginAbstract classCross-cutting features (selection, snapping, grid…)

Internally, Weave delegates to a set of Manager classes (e.g., WeaveStageManager, WeaveStateManager, WeavePluginsManager) which are not meant to be extended or replaced.

Data Flow

  1. A WeaveStore holds a Y.Doc with two maps: weave (node state) and weaveMetadata.
  2. On every Yjs afterTransaction, subsequent state updates are batched via requestAnimationFrame.
  3. onStateChange triggers Weave.render(), which calls WeaveRenderer.render().
  4. The renderer diffing maps each state element to a registered WeaveNode by nodeType, calling onRender() for creates and onUpdate() for updates.

Custom Node Pattern

Extend WeaveNode and implement at minimum:

export class MyNode extends WeaveNode {
  protected nodeType = 'myNodeType';
  initialize = undefined;

  onRender(props: WeaveElementAttributes): WeaveElementInstance {
    const group = new Konva.Group({ ...props, name: 'node' });
    // ... add Konva shapes to group
    this.setupDefaultNodeAugmentation(group);
    this.setupDefaultNodeEvents(group);
    return group;
  }

  onUpdate(instance: WeaveElementInstance, nextProps: WeaveElementAttributes): void {
    instance.setAttrs({ ...nextProps });
    // ... update child shapes
  }
}

Always call setupDefaultNodeAugmentation() and setupDefaultNodeEvents() when implementing custom nodes.

Custom Action Pattern

Extend WeaveAction and implement trigger():

export class MyToolAction extends WeaveAction {
  protected name = 'myTool';
  onPropsChange = undefined;
  onInit = undefined;

  trigger(cancelAction: () => void, params?: unknown): unknown {
    // Set up Konva stage event listeners
  }

  cleanup(): void {
    // Remove event listeners
  }
}

Custom Plugin Pattern

Extend WeavePlugin and implement lifecycle hooks:

export class MyPlugin extends WeavePlugin {
  protected name = 'myPlugin';

  initialize(): void { /* called once at construction */ }
  onInit(): void { /* called when Weave initializes */ }
  onRender(): void { /* called on each render */ }
  enable(): void { this.enabled = true; }
  disable(): void { this.enabled = false; }
}

Custom Store Pattern

Extend WeaveStore and implement the abstract methods connect(), disconnect(), handleAwarenessChange(), and setAwarenessInfo(). The base class handles all Yjs document management and undo/redo.

Key Conventions

SPDX License Headers

Every source file must start with:

// SPDX-FileCopyrightText: 2025 2025 INDUSTRIA DE DISEÑO TEXTIL S.A. (INDITEX S.A.)
//
// SPDX-License-Identifier: Apache-2.0

Path Aliases

Within the sdk package, @/ maps to ./src/. Use @inditextech/weave-types for shared types.

TypeScript

  • Strict mode is enabled. Avoid any; if unavoidable, use // eslint-disable-next-line @typescript-eslint/no-explicit-any.
  • noUnusedLocals is enforced.
  • Use import type for type-only imports (verbatimModuleSyntax is on).

Testing

Tests use Vitest. Test files follow the **/*.test.ts pattern. Not all packages currently have test suites.

Commit Messages

Follow Conventional Commits. Enforced by commitlint with @commitlint/config-conventional.

Peer Dependencies: Konva & Yjs

Both konva and yjs are peer dependencies pinned to exact versions (konva@10.0.2, yjs@13.6.27). When linking packages locally, set these env vars to avoid duplicate instances:

WEAVE_KONVA_PATH=<repo>/code/node_modules/konva
WEAVE_YJS_PATH=<repo>/code/node_modules/yjs

Dual Entry Points (SDK)

The SDK publishes two entry points:

  • . — browser/client (dist/sdk.js)
  • ./server — Node.js server-side (dist/sdk.node.js)

Server-side code lives in src/backend.ts and src/index.node.ts.

Nx Caching

Run npm run reset (which runs nx reset) to clear the Nx computation cache if builds behave unexpectedly.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.