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
- Very specific: line 15
All commands run from the code/ directory.
- Very specific: line 111
Always call setupDefaultNodeAugmentation() and setupDefaultNodeEvents() when implementing custom nodes.
- Distinctive: line 157
Every source file must start with:
- Very specific: line 173
Use import type for type-only imports (verbatimModuleSyntax is on).
- Very specific: line 181
Follow Conventional Commits.
- Very specific: line 202
Run npm run reset (which runs nx reset) to clear the Nx computation cache if builds behave unexpectedly.
≈ “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.
Files
<!--
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-sdkRepository 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 Point | Base Class | Purpose |
WeaveStore | Abstract class | Yjs sync transport (WebSocket, Azure WS, standalone) |
WeaveRenderer | Abstract class | Konva rendering engine |
WeaveNode | Abstract class | Canvas shape definition |
WeaveAction | Abstract class | Tool behavior (draw, select, move…) |
WeavePlugin | Abstract class | Cross-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
- A
WeaveStoreholds aY.Docwith two maps:weave(node state) andweaveMetadata. - On every Yjs
afterTransaction, subsequent state updates are batched viarequestAnimationFrame. onStateChangetriggersWeave.render(), which callsWeaveRenderer.render().- The renderer diffing maps each state element to a registered
WeaveNodebynodeType, callingonRender()for creates andonUpdate()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.0Path 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. noUnusedLocalsis enforced.- Use
import typefor type-only imports (verbatimModuleSyntaxis 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/yjsDual 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.
Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.
Of the Copilot instructions files we read, the 2,297 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository56 other files it gives its agents.
- AGENTS.mdAGENTS.md
- cavemanSkill
- design-an-interfaceSkill
- diagnoseSkill
- docouture-authoring-guidesSkill
- docouture-docs-internalsSkill
- docouture-docs-versioningSkill
- docouture-documenting-changesSkill
- docouture-getting-startedSkill
- docouture-writing-docs-pagesSkill
- edit-articleSkill
- git-guardrails-claude-codeSkill
- grill-meSkill
- grill-with-docsSkill
- handoffSkill
- improve-codebase-architectureSkill
- migrate-to-shoehornSkill
- openspec-apply-changeSkill
- openspec-archive-changeSkill
- openspec-exploreSkill
- openspec-proposeSkill
- openspec-sync-specsSkill
- openspec-update-changeSkill
- openspec-verify-changeSkill
- prototypeSkill
- qaSkill
- request-refactor-planSkill
- reviewSkill
- scaffold-exercisesSkill
- setup-matt-pocock-skillsSkill
- setup-pre-commitSkill
- tddSkill
- teachSkill
- to-issuesSkill
- to-prdSkill
- triageSkill
- ubiquitous-languageSkill
- write-a-skillSkill
- writing-beatsSkill
- writing-fragmentsSkill
- writing-shapeSkill
- zoom-outSkill
- openspec-apply-changeSkill
- openspec-archive-changeSkill
- openspec-exploreSkill
- openspec-proposeSkill
- openspec-sync-specsSkill
- openspec-update-changeSkill
- openspec-verify-changeSkill
- openspec-apply-changeSkill
- openspec-archive-changeSkill
- openspec-exploreSkill
- openspec-proposeSkill
- openspec-sync-specsSkill
- openspec-update-changeSkill
- openspec-verify-changeSkill
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.

