Skip to content

Commit 1ae8e74

Browse files
lodyai[bot]zxch3n
andauthored
feat: add user-focused Loro skill (#961)
* feat: add Loro skill repository guide * refactor: focus Loro skill on user onboarding * docs: index Loro language bindings in skill --------- Co-authored-by: Zixuan Chen <zx@loro.dev>
1 parent d28f6b3 commit 1ae8e74

9 files changed

Lines changed: 145 additions & 150 deletions

skills/loro/SKILL.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,44 @@
11
---
22
name: loro
3-
description: "Comprehensive guide for using Loro across document modeling, synchronization, versioning, rich text editors, app-state mirroring, performance tradeoffs, and wasm bindings. Use when Codex needs to work with `loro-crdt`, `loro`, `loro-prosemirror`, `loro-mirror`, or `crates/loro-wasm` for: (1) Choosing CRDT container types and document structure, (2) Designing sync, persistence, checkout, or history workflows, (3) Integrating rich-text editors and stable selections, (4) Mirroring app state with schemas and React, (5) Reasoning about versions, events, import status, or Inspector output, or (6) Maintaining the WASM binding layer."
3+
description: "Practical guide for helping app developers evaluate, adopt, and use Loro for local-first collaboration. Use when Codex needs to answer questions or write examples for `loro-crdt`, `loro`, `loro-prosemirror`, `loro-codemirror`, `loro-mirror`, language bindings such as Swift/Python/C#/Go/React Native, or Loro-powered apps about: (1) Deciding whether Loro fits a product, (2) Getting started in JavaScript/TypeScript, Rust, or another supported binding, (3) Choosing CRDT containers and document structure, (4) Designing sync, persistence, snapshots, versioning, undo, presence, or time travel, (5) Integrating rich-text editors and stable selections, (6) Mirroring app state with React, or (7) Understanding performance and tradeoffs."
44
---
55

66
# Loro
77

8-
Use this skill as the single entry point for all Loro work. Load one primary chapter first. Load a second chapter only when the task clearly crosses domains.
8+
Use this skill to help users build applications with Loro. Start from the user's product goal, then choose the narrowest chapter that answers it. Load a second chapter only when the task crosses domains.
99

1010
## Select A Chapter
1111

1212
- Read [references/topic-map.md](references/topic-map.md) if the task is broad and you need to route it.
13-
- Read [references/fit-and-architecture.md](references/fit-and-architecture.md) for CRDT fit, local-first framing, setup, and high-level architecture.
14-
- Read [references/containers-and-encoding.md](references/containers-and-encoding.md) for container choice, composition, encoding, persistence, shallow snapshots, and redaction.
15-
- Read [references/sync-versioning-and-events.md](references/sync-versioning-and-events.md) for sync flows, frontiers, version vectors, checkout, import status, timestamps, event timing, and Inspector.
13+
- Read [references/fit-and-architecture.md](references/fit-and-architecture.md) for product fit, installation, language/package choices, first examples, and core mental models.
14+
- Read [references/containers-and-encoding.md](references/containers-and-encoding.md) for choosing containers, shaping documents, exporting updates, snapshots, persistence, shallow snapshots, and redaction.
15+
- Read [references/sync-versioning-and-events.md](references/sync-versioning-and-events.md) for realtime/offline sync, version vectors, frontiers, checkout, undo, presence, timestamps, events, and Inspector.
1616
- Read [references/richtext-and-editors.md](references/richtext-and-editors.md) for `LoroText`, cursors, `applyDelta`, `updateByLine`, `loro-prosemirror`, Tiptap, and CodeMirror.
1717
- Read [references/mirror-and-react.md](references/mirror-and-react.md) for `loro-mirror`, `$cid`, `idSelector`, validation, selectors, and React integration.
18-
- Read [references/wasm-maintenance.md](references/wasm-maintenance.md) for `crates/loro-wasm`, `#[wasm_bindgen]`, pending-event flushing, wrapper decoration, and tests.
19-
- Read [references/performance-and-research.md](references/performance-and-research.md) for benchmarks, Eg-Walker tradeoffs, movable-tree context, rich-text design context, and project history.
18+
- Read [references/performance-and-tradeoffs.md](references/performance-and-tradeoffs.md) for scaling, document/update size, loading speed, and workload tradeoffs.
2019

2120
## Route Common Tasks
2221

22+
- “I am new to Loro / should I use it / show me a first example”
23+
- Start with `fit-and-architecture.md`
24+
- “Which language package or binding should I use?”
25+
- Start with `fit-and-architecture.md`
2326
- “Build a collaborative document model / choose data types / persist history”
2427
- Start with `containers-and-encoding.md`
2528
- Add `sync-versioning-and-events.md` if version/history behavior matters
26-
-Debug checkout / detached mode / missing imports / event timing
29+
-Sync devices, store data, use snapshots, time travel, undo, or presence
2730
- Start with `sync-versioning-and-events.md`
2831
- “Integrate ProseMirror, Tiptap, CodeMirror, or custom rich text”
2932
- Start with `richtext-and-editors.md`
3033
- Add `sync-versioning-and-events.md` if undo/version/event behavior matters
3134
- “Model app state with loro-mirror or loro-mirror-react”
3235
- Start with `mirror-and-react.md`
3336
- Add `containers-and-encoding.md` if schema semantics depend on container choice
34-
-Change wasm bindings or debug pending event flushing
35-
- Start with `wasm-maintenance.md`
36-
- “Decide whether Loro is even the right tool / explain tradeoffs
37+
-Explain performance, large documents, loading, update size, or tradeoffs
38+
- Start with `performance-and-tradeoffs.md`
39+
- “Decide whether Loro is the right tool”
3740
- Start with `fit-and-architecture.md`
38-
- Add `performance-and-research.md` if benchmark or research context matters
41+
- Add `performance-and-tradeoffs.md` if workload scale matters
3942

4043
## Execute The Task
4144

@@ -46,12 +49,13 @@ Use this skill as the single entry point for all Loro work. Load one primary cha
4649
- choose data types by merge behavior,
4750
- distinguish state version from history version,
4851
- keep ephemeral state out of persisted CRDT data,
49-
- respect the binding/runtime invariants in `crates/loro-wasm`.
52+
- use stable cursors for collaborative selections,
53+
- design sync around updates and snapshots rather than a central locking protocol.
5054

5155
## Keep Guardrails
5256

5357
- Do not assume CRDTs are the right fit for hard invariants, exclusivity, or authorization-at-write-time problems.
5458
- Do not model editable text as plain strings when user intent requires merged edits.
5559
- Do not reuse peer IDs across concurrent sessions.
5660
- Do not confuse detached documents with detached containers.
57-
- Do not change wasm-exposed mutators without checking pending-event flushing behavior.
61+
- Do not persist cursor presence, hover state, or connection state inside the main document; use ephemeral state.

skills/loro/agents/openai.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
interface:
22
display_name: "Loro"
3-
short_description: "Complete Loro guide for modeling, sync, editors, and wasm"
4-
default_prompt: "Use $loro to solve a Loro modeling, sync, editor, mirror, versioning, or wasm-maintenance task."
3+
short_description: "Guide for adopting and using Loro in apps"
4+
default_prompt: "Use $loro to design or explain a Loro-powered app, from choosing a language binding through modeling, sync, editors, React state, and performance."
Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Fit And Architecture
1+
# Getting Started And Fit
22

33
## When Loro Fits
44

@@ -14,11 +14,59 @@
1414
- Authorization decisions that must be enforced at write time.
1515
- Arbitrary graph-shaped or non-JSON-like data without an adaptation layer.
1616

17+
## Install
18+
19+
- JavaScript/TypeScript: install `loro-crdt`.
20+
- Rust: install the `loro` crate.
21+
- Use editor integrations when available instead of writing editor sync from scratch:
22+
- `loro-prosemirror` for ProseMirror and Tiptap-style editors.
23+
- `loro-codemirror` for CodeMirror 6.
24+
- Use `loro-mirror` and `loro-mirror-react` when the app already thinks in immutable state and actions.
25+
26+
## Language And Package Index
27+
28+
- JavaScript/TypeScript: [`loro-crdt`](https://www.npmjs.com/package/loro-crdt). Start here for web apps and most examples in the Loro docs.
29+
- Rust: [`loro`](https://crates.io/crates/loro) and [`docs.rs/loro`](https://docs.rs/loro). Use for native Rust apps, services, CLIs, and custom infrastructure.
30+
- Swift: [`loro-swift`](https://github.com/loro-dev/loro-swift). Use for Swift/iOS/macOS experiments and native apps.
31+
- Python: [`loro-py`](https://github.com/loro-dev/loro-py). Use for Python apps, scripts, and server-side tooling.
32+
- React Native: [`loro-react-native`](https://github.com/loro-dev/loro-react-native). Use for mobile apps that need native React Native bindings.
33+
- C#: [`loro-cs`](https://github.com/sensslen/loro-cs). Community-maintained .NET/C# binding; check its README and release state before adopting.
34+
- Go: [`loro-go`](https://github.com/aholstenson/loro-go). Community-maintained Go binding; check platform support and API completeness before adopting.
35+
- Cross-language FFI base: [`loro-ffi`](https://github.com/loro-dev/loro-ffi). Use this as the reference for generated/native bindings and as a starting point for new language bindings.
36+
37+
Prefer the official JS/TS or Rust package when there is no product reason to choose another language. For community bindings, verify platform binaries, Loro core version, and API coverage before making product commitments.
38+
39+
## First JavaScript Example
40+
41+
```ts
42+
import { LoroDoc } from "loro-crdt";
43+
44+
const docA = new LoroDoc();
45+
const listA = docA.getList("items");
46+
listA.insert(0, "A");
47+
listA.insert(1, "B");
48+
49+
const update = docA.export({ mode: "update" });
50+
51+
const docB = new LoroDoc();
52+
docB.import(update);
53+
54+
console.log(docB.toJSON()); // { items: ["A", "B"] }
55+
```
56+
57+
## First Design Questions
58+
59+
1. What parts of the state should merge when edited concurrently?
60+
2. Which data needs durable history, and which data is only presence or UI state?
61+
3. Do users need text/rich-text intent preservation, ordered moves, tree moves, or simple last-write-wins fields?
62+
4. How will peers exchange updates, and where will snapshots or updates be persisted?
63+
1764
## Conceptual Model
1865

1966
- Loro is a CRDT framework for local-first apps.
2067
- It trades strict coordination for strong eventual consistency.
21-
- Under the hood it mixes Fugue-style correctness with Eg-Walker-inspired replay and simple local indexing.
68+
- Each peer edits locally, exports updates, imports updates from other peers, and converges after seeing the same operations.
69+
- Loro records history, so versioning and time travel are core concepts rather than an afterthought.
2270

2371
## Document Shape Constraints
2472

@@ -28,21 +76,12 @@
2876

2977
## Entry Points
3078

31-
- JS/TS: `loro-crdt`
32-
- Rust: `loro`
33-
- Swift: `loro-swift`
34-
- Python: `loro-py`
35-
- Ecosystem integrations include editor bindings, state-mirroring layers, and Inspector.
36-
37-
## Setup Notes
38-
39-
- In JS frontends, install `loro-crdt`.
40-
- In Vite-based apps, WASM support and top-level-await handling must be configured correctly.
41-
- Inspector is the quickest interactive tool for browsing state and history during development.
79+
- Core packages and language bindings are listed in `Language And Package Index`.
80+
- Ecosystem integrations include editor bindings, state-mirroring layers, React Native, and Inspector.
4281

43-
## Read Order Inside This Skill
82+
## Practical Start Path
4483

45-
1. Start here for fit and high-level tradeoffs.
46-
2. Switch to `containers-and-encoding.md` for concrete data types and storage choices.
47-
3. Switch to `sync-versioning-and-events.md` for history, events, and sync state.
48-
4. Switch to `richtext-and-editors.md` or `mirror-and-react.md` for integrations.
84+
1. Pick container types in `containers-and-encoding.md`.
85+
2. Decide sync and persistence shape in `sync-versioning-and-events.md`.
86+
3. Add editor or React integration only after the document model is clear.
87+
4. Use Inspector during development to inspect state and history.

skills/loro/references/performance-and-research.md

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Performance And Tradeoffs
2+
3+
Use this chapter when users ask whether Loro can handle a workload, how to store data efficiently, or why one sync/storage design is preferable to another.
4+
5+
## What To Compare
6+
7+
- Encoded document size and update size.
8+
- Snapshot export/import time.
9+
- Update import time.
10+
- Memory footprint while editing and loading.
11+
- Conflict-heavy collaboration versus mostly independent edits.
12+
- Initial load path versus steady-state sync path.
13+
14+
## Practical Defaults
15+
16+
- Use update exchange for live collaboration.
17+
- Use snapshots for fast startup checkpoints.
18+
- Store frequent small updates between snapshots when durable replay is needed.
19+
- Recompact by exporting a fresh snapshot after enough updates accumulate.
20+
- Consider shallow snapshots when old history can be archived or discarded.
21+
22+
## Workload-Specific Advice
23+
24+
- Collaborative text: use `LoroText`; do not model text as a plain string just to reduce apparent complexity.
25+
- Reorder-heavy collections: use `LoroMovableList` instead of delete+insert if move identity matters.
26+
- Hierarchies: use `LoroTree`; avoid forcing tree-shaped data into ad hoc map/list structures.
27+
- High-frequency presence or cursor movement: use `EphemeralStore`, not the persisted document.
28+
- Hard invariants such as balances, bookings, or permissions still need application/server-side validation outside the CRDT merge.
29+
30+
## Benchmark Interpretation
31+
32+
- Treat benchmarks as workload indicators, not universal rankings.
33+
- A smaller full snapshot does not automatically mean smaller incremental updates.
34+
- A fast import path matters most for startup and bulk sync.
35+
- A compact update path matters most for live collaboration and bandwidth-constrained clients.
36+
- Shallow snapshots reduce retained history, but peers with only older history may need a fresh snapshot or archived history to sync.
37+
38+
## Explain Tradeoffs
39+
40+
- Loro optimizes for local editing, automatic merging, history, and version control.
41+
- Strong eventual consistency means peers converge after receiving the same operations.
42+
- Loro does not provide central locking, serializable transactions, or write-time authorization by itself.
43+
- Pick containers by merge semantics first, then tune storage and sync format for performance.

skills/loro/references/richtext-and-editors.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
- Use two cursors for selections: anchor and head.
3131
- Resolve live offsets with `doc.getCursorPos(...)`.
3232
- Persist updated cursors returned from resolution to reduce replay cost.
33-
- WASM text offsets are UTF-16 indices.
33+
- JavaScript text offsets are UTF-16 indices.
3434

3535
## ProseMirror And Tiptap
3636

@@ -55,4 +55,4 @@
5555

5656
- Do not model editable prose as `string` in a `LoroMap`.
5757
- Do not store collaborative selections as plain indices.
58-
- Do not mix old and new ProseMirror cursor APIs accidentally; inspect the package version and current codebase first.
58+
- Do not mix old and new ProseMirror cursor APIs accidentally; check the installed package version and current API docs first.

skills/loro/references/sync-versioning-and-events.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
- Some older examples describe JS events as microtask-delayed.
6767
- Modern `loro-crdt` dispatches events synchronously at the JS boundary.
68-
- Always check the package version and current codebase before assuming old timing semantics.
68+
- Check the installed package version and current API docs before relying on old timing examples.
6969

7070
## Event Sources
7171

@@ -93,7 +93,7 @@
9393

9494
- If imports arrive out of order, inspect `ImportStatus.pending`.
9595
- If checkout seems stale, compare DocState version to OpLog version.
96-
- If a hook missed an implicit commit, audit `subscribePreCommit(...)` rather than adding ad hoc commit calls.
96+
- If commit metadata hooks miss implicit commits, use `subscribePreCommit(...)` rather than adding ad hoc commit calls.
9797

9898
## Undo, Cursor, And Ephemeral Presence
9999

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
11
# Topic Map
22

3-
Use this file to choose the right chapter inside the unified `loro` skill.
3+
Use this file to choose the right user-facing chapter inside the unified `loro` skill.
44

55
## Route By User Ask
66

7+
- “I am new to Loro. How do I start?”
8+
- Read `fit-and-architecture.md`
9+
- “Which package, language binding, or platform should I use?”
10+
- Read `fit-and-architecture.md`
711
- “Should I use Loro here?”
812
- Read `fit-and-architecture.md`
913
- “Which container should I choose?”
1014
- Read `containers-and-encoding.md`
11-
- “How should I sync, persist, time-travel, or debug imports?”
15+
- “How should I sync, persist, time-travel, use undo, or debug imports?”
1216
- Read `sync-versioning-and-events.md`
1317
- “How do I integrate rich text editors?”
1418
- Read `richtext-and-editors.md`
1519
- “How do I use loro-mirror with React?”
1620
- Read `mirror-and-react.md`
17-
- “How do I change crates/loro-wasm safely?”
18-
- Read `wasm-maintenance.md`
19-
- “Why does Loro behave this way, and what are the performance tradeoffs?”
20-
- Read `performance-and-research.md`
21+
- “How will Loro behave at scale?”
22+
- Read `performance-and-tradeoffs.md`
2123

22-
## Product Fit And High-Level Architecture
24+
## Getting Started And Product Fit
2325

24-
- CRDT basics, CAP tradeoffs, local-first framing, OT comparison
26+
- Install choices, language bindings, first example, local-first framing
2527
- Read `fit-and-architecture.md`
2628
- When CRDTs are the wrong fit
2729
- Read `fit-and-architecture.md`
28-
- Package entry points, setup notes, ecosystem overview
30+
- Package entry points and ecosystem overview
2931
- Read `fit-and-architecture.md`
3032

31-
## Containers, Composition, Encoding, Persistence
33+
## Containers, Composition, Storage
3234

3335
- Choosing between `LoroMap`, `LoroList`, `LoroMovableList`, `LoroTree`, `LoroCounter`, `LoroText`
3436
- Read `containers-and-encoding.md`
@@ -51,6 +53,8 @@ Use this file to choose the right chapter inside the unified `loro` skill.
5153
- Read `sync-versioning-and-events.md`
5254
- Event timing, `subscribePreCommit`, Inspector
5355
- Read `sync-versioning-and-events.md`
56+
- Undo, cursors, and ephemeral presence
57+
- Read `sync-versioning-and-events.md`
5458

5559
## Text, Rich Text, And Editors
5660

@@ -68,20 +72,11 @@ Use this file to choose the right chapter inside the unified `loro` skill.
6872
- `loro-mirror-react`, selectors, provider/hooks patterns
6973
- Read `mirror-and-react.md`
7074

71-
## WASM Binding Maintenance
72-
73-
- `crates/loro-wasm` API changes
74-
- Read `wasm-maintenance.md`
75-
- Pending-event flushing and JS decorator allowlists
76-
- Read `wasm-maintenance.md`
77-
- Binding aliases, generated TS docs, wasm tests
78-
- Read `wasm-maintenance.md`
79-
80-
## Performance And Research Context
75+
## Performance And Tradeoffs
8176

82-
- Benchmark interpretation
83-
- Read `performance-and-research.md`
84-
- Event-graph replay and efficiency tradeoffs
85-
- Read `performance-and-research.md`
86-
- Movable-tree algorithm context, rich-text algorithm context, project history
87-
- Read `performance-and-research.md`
77+
- Loading speed, encoded size, memory, update size
78+
- Read `performance-and-tradeoffs.md`
79+
- Conflict-heavy vs low-conflict workloads
80+
- Read `performance-and-tradeoffs.md`
81+
- When to use snapshots, shallow snapshots, or update streams
82+
- Read `performance-and-tradeoffs.md`

0 commit comments

Comments
 (0)