@dovetail-ts/skills 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/LICENSE +21 -0
- package/README.md +21 -2
- package/assets/skills/dovetail/SKILL.md +291 -0
- package/assets/skills/dovetail-coedit/SKILL.md +151 -0
- package/assets/skills/dovetail-server/SKILL.md +266 -0
- package/assets/skills/dovetail-testing/SKILL.md +202 -0
- package/dist/chunk-OIN5V5PO.js +21 -0
- package/dist/chunk-OIN5V5PO.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +9 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @dovetail-ts/skills
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 480744b: First release of Dovetail: real-time and offline sync for Ember.
|
|
8
|
+
|
|
9
|
+
- `@dovetail-ts/core`: the connection life cycle, live store subscriptions, the optimistic ledger with rebase and rollback, the offline write queue in IndexedDB with a leader tab and dead letters, `DocSession` and `PresenceRoom`.
|
|
10
|
+
- `@dovetail-ts/warp-drive`: the store feed into WarpDrive.
|
|
11
|
+
- `@dovetail-ts/crdt`, `crdt-yjs`, `crdt-loro` and `crdt-automerge`: one `DocEngine` interface with three engines.
|
|
12
|
+
- `@dovetail-ts/tiptap`: co-editing in Tiptap 3 with carets, per-user undo, versions and comment threads.
|
|
13
|
+
- `@dovetail-ts/ember`, `notifications` and `inspector`: presence and status components, the inbox, toasts and activity feeds, and a dev panel.
|
|
14
|
+
- `@dovetail-ts/server`, the transports (`transport-ws`, `transport-sse`, `transport-cable`) and `conformance`: a Node server and one wire protocol that the Rails gems also pass.
|
|
15
|
+
- Adapters for Hocuspocus, Liveblocks, PartyKit and Supabase, and integrations for Switchyard, Millwork, Benchdog and Lattice. The Neon adapter is not in 1.0: it waits for a stable Neon Realtime client (1.1).
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Joe Gaudet
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @dovetail-ts/skills
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Installs the Dovetail agent skills for coding agents.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm i -D @dovetail-ts/skills && npx dovetail-skills
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
It writes these files into `.claude/`:
|
|
10
|
+
|
|
11
|
+
| File | What it is |
|
|
12
|
+
| ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| `skills/dovetail/SKILL.md` | Dovetail in an Ember app: the `dovetail` service, transports, live records, optimistic writes, the offline queue, dead letters, room resets, presence and notifications. |
|
|
14
|
+
| `skills/dovetail-server/SKILL.md` | The Node server and the Rails gems: the auth hooks, `handleWrite`, `validateUpdate`, `authorizeAwareness`, limits, stores, `broadcasts_dovetail` and the security checklist. |
|
|
15
|
+
| `skills/dovetail-coedit/SKILL.md` | Co-edit with Tiptap: the editor, the engines and their capabilities, carets, undo, versions and comment threads. |
|
|
16
|
+
| `skills/dovetail-testing/SKILL.md` | Tests: `inPageServer`, `FakeHub`, `NetworkSwitch`, `FakeClock`, each harness and the `@harnessed-ts/should` matchers. |
|
|
17
|
+
|
|
18
|
+
Run the command again after an upgrade to get the new text. The command replaces the Dovetail
|
|
19
|
+
skills and keeps the other files of `.claude/`. `--dry-run` lists what it writes.
|
|
20
|
+
|
|
21
|
+
Part of [Dovetail](https://joegaudet.com/dovetail/). Guide:
|
|
22
|
+
**https://joegaudet.com/dovetail/guide/getting-started/agent-skills.md** · MIT
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dovetail
|
|
3
|
+
description: Add Dovetail real-time and offline sync to an Ember app. Use when you configure the dovetail service (transport, getToken, store sink, queue), subscribe to live records, write optimistic changes, handle the offline queue, dead letters and room resets, or add the presence, status and notification components.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Dovetail in an Ember app
|
|
7
|
+
|
|
8
|
+
Dovetail pushes server changes into the WarpDrive store, shows local changes at once, keeps
|
|
9
|
+
writes in an offline queue, and gives presence, notifications and live co-edit.
|
|
10
|
+
|
|
11
|
+
- Co-edit with Tiptap: the `dovetail-coedit` skill.
|
|
12
|
+
- The Node server and the Rails gems: the `dovetail-server` skill.
|
|
13
|
+
- Tests: the `dovetail-testing` skill.
|
|
14
|
+
|
|
15
|
+
Full guide: https://joegaudet.com/dovetail/guide/getting-started/introduction.md
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
Dovetail needs ember-source 6.12 or later.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm add @dovetail-ts/core @dovetail-ts/warp-drive @dovetail-ts/ember @dovetail-ts/transport-ws
|
|
23
|
+
pnpm add yjs @tiptap/core @tiptap/pm @tiptap/starter-kit @tiptap/y-tiptap \
|
|
24
|
+
@tiptap/extension-collaboration @tiptap/extension-collaboration-caret
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The second line installs the peer dependencies of the editor of `@dovetail-ts/ember`. Add
|
|
28
|
+
`@dovetail-ts/notifications` for the inbox, the toasts and the activity feeds. Load the Joinery
|
|
29
|
+
tokens and CSS, because the components use them.
|
|
30
|
+
|
|
31
|
+
## Configure the service
|
|
32
|
+
|
|
33
|
+
Call `configure()` one time, for example in the application route. Await it before you use the
|
|
34
|
+
service.
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import Route from '@ember/routing/route'
|
|
38
|
+
import { service } from '@ember/service'
|
|
39
|
+
import type { DovetailService } from '@dovetail-ts/ember'
|
|
40
|
+
import { WebSocketTransport } from '@dovetail-ts/transport-ws'
|
|
41
|
+
import { storeSink } from '@dovetail-ts/warp-drive'
|
|
42
|
+
|
|
43
|
+
export default class ApplicationRoute extends Route {
|
|
44
|
+
@service declare dovetail: DovetailService
|
|
45
|
+
@service declare store: Store
|
|
46
|
+
@service declare session: Session
|
|
47
|
+
|
|
48
|
+
async beforeModel() {
|
|
49
|
+
await this.dovetail.configure({
|
|
50
|
+
transport: () => new WebSocketTransport({ url: 'wss://example.com/dovetail/ws' }),
|
|
51
|
+
getToken: () => this.session.token,
|
|
52
|
+
user: { id: 'u1', name: 'Ana Lima', color: '#1d4ed8' },
|
|
53
|
+
sink: storeSink(this.store),
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
| Option | What it does |
|
|
60
|
+
| ------------ | ------------------------------------------------------------------------------------------- |
|
|
61
|
+
| `transport` | A factory. A transport opens one time only, so the connection makes a new one for each try. |
|
|
62
|
+
| `getToken` | Called before each connection attempt. It can return a promise. |
|
|
63
|
+
| `user` | `{ id, name, color, avatarUrl? }` for the avatars, pointers and carets. |
|
|
64
|
+
| `sink` | Where the store feed goes. Without a sink, there are no writes and no queue. |
|
|
65
|
+
| `queue` | The offline write queue. The default is a `WriteQueue` on IndexedDB. |
|
|
66
|
+
| `docStorage` | Where local doc updates wait. The default is `IndexedDBDocStorage`. |
|
|
67
|
+
| `dbName` | The IndexedDB database name. The default is `dovetail`. |
|
|
68
|
+
| `connection` | More `Connection` options: `network`, `clock`, `heartbeatInterval`, `joinUserRoom`. |
|
|
69
|
+
| `sync` | More `SyncClient` options: `reload`, `locks`, `channel`, `lockName`, `backoff`. |
|
|
70
|
+
| `presence` | Presence timings: `awayAfter`, `typingTimeout`, `pointerThrottle`, `clock`. |
|
|
71
|
+
|
|
72
|
+
Rules:
|
|
73
|
+
|
|
74
|
+
- Give `getToken` when the server has an `authenticate` hook. The server refuses a missing or
|
|
75
|
+
blank token. An `unauthorized` error closes the connection, and the next attempt calls
|
|
76
|
+
`getToken` again, so return the newest token.
|
|
77
|
+
- Use a `#rrggbb` color. Other peers show gray (`#6b7280`) for a color that `isHexColor` refuses,
|
|
78
|
+
and the Yjs carets accept only `#rrggbb`. Give `avatarUrl` as an absolute `https:` URL.
|
|
79
|
+
- Use `wss:` and `https:` URLs only. The token goes in each `hello`.
|
|
80
|
+
|
|
81
|
+
## Pick a transport
|
|
82
|
+
|
|
83
|
+
| Package | Class | Server |
|
|
84
|
+
| ------------------------------ | ---------------------- | -------------------------------------- |
|
|
85
|
+
| `@dovetail-ts/transport-ws` | `WebSocketTransport` | The `/ws` route of the Node server. |
|
|
86
|
+
| `@dovetail-ts/transport-sse` | `SseTransport` | The `/sse` routes of the Node server. |
|
|
87
|
+
| `@dovetail-ts/transport-cable` | `CableTransport` | `Dovetail::Channel` of the Rails gem. |
|
|
88
|
+
| `@dovetail-ts/partykit` | `PartySocketTransport` | A PartyKit party that runs the server. |
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
import { SseTransport } from '@dovetail-ts/transport-sse'
|
|
92
|
+
import { CableTransport } from '@dovetail-ts/transport-cable'
|
|
93
|
+
|
|
94
|
+
// SSE: use it when a proxy blocks WebSockets. Give the same Authorization header each time.
|
|
95
|
+
const sse = () =>
|
|
96
|
+
new SseTransport({
|
|
97
|
+
url: 'https://example.com/dovetail/sse',
|
|
98
|
+
headers: { Authorization: `Bearer ${session.token}` },
|
|
99
|
+
})
|
|
100
|
+
// ActionCable, for the Rails gem. Give `consumer` in place of `url` to use the consumer of the app.
|
|
101
|
+
const cable = () => new CableTransport({ url: 'wss://example.com/cable' })
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## The service state
|
|
105
|
+
|
|
106
|
+
The tracked state: `connectionState` (`idle`, `connecting`, `open`, `reconnecting`, `offline`,
|
|
107
|
+
`closed`), `status` (`online`, `connecting`, `reconnecting`, `offline`), `online`, `queued`,
|
|
108
|
+
`deadLetters`, `errors`, and the core objects `connection` and `sync`.
|
|
109
|
+
|
|
110
|
+
## Live records
|
|
111
|
+
|
|
112
|
+
The server sends JSON:API documents and deletes to a room. `subscribe(owner, room)` puts the
|
|
113
|
+
feed of the room in the store until `owner` is destroyed.
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import Component from '@glimmer/component'
|
|
117
|
+
import { service } from '@ember/service'
|
|
118
|
+
import type { DovetailService } from '@dovetail-ts/ember'
|
|
119
|
+
|
|
120
|
+
export default class NotePage extends Component<{ Args: { id: string } }> {
|
|
121
|
+
@service declare dovetail: DovetailService
|
|
122
|
+
constructor(owner: unknown, args: { id: string }) {
|
|
123
|
+
super(owner, args)
|
|
124
|
+
this.dovetail.subscribe(this, `note:${args.id}`)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
- The feed sends changes, not the first state. Load the records with the API of your app first.
|
|
130
|
+
- Do not call `store.push` with a feed op. All server ops go through the optimistic ledger, so
|
|
131
|
+
a local change that waits for its ack stays on top.
|
|
132
|
+
- `storeSink(store, { codec })` changes each document before the push, for example with
|
|
133
|
+
Millwork codecs.
|
|
134
|
+
|
|
135
|
+
## Room resets: give reload
|
|
136
|
+
|
|
137
|
+
After a reconnect, the connection joins each room again with its last cursor. When the server
|
|
138
|
+
cannot send each change after that cursor, the join `ack` has `reset: true`, and the changes in
|
|
139
|
+
the gap are lost to the client. Give a `reload` hook so the client loads the room again:
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import type { RoomReload } from '@dovetail-ts/core'
|
|
143
|
+
|
|
144
|
+
await this.dovetail.configure({
|
|
145
|
+
// ...the options above
|
|
146
|
+
sync: {
|
|
147
|
+
reload: async (room): Promise<RoomReload> => {
|
|
148
|
+
const response = await fetch(`/api/rooms/${encodeURIComponent(room)}/records`)
|
|
149
|
+
return { documents: await response.json(), complete: true }
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
})
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
- The documents go through the ledger, so pending local writes stay on top.
|
|
156
|
+
- With `complete: true`, the client removes each record of the room feed that the documents do
|
|
157
|
+
not have. A record that the feed of another subscribed room gave stays.
|
|
158
|
+
- Without `reload`, a reset changes only the cursor. Always give it in a real app.
|
|
159
|
+
- `connection.onReset(room, listener)` is the lower-level hook.
|
|
160
|
+
|
|
161
|
+
## Optimistic writes
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
import { tempId } from '@dovetail-ts/core'
|
|
165
|
+
|
|
166
|
+
await this.dovetail.write('note:1', {
|
|
167
|
+
op: 'upsert',
|
|
168
|
+
document: { data: { type: 'note', id: tempId(), attributes: { title: 'Plan' } } },
|
|
169
|
+
})
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
- `write(room, op)` applies the op to the store at once and puts it in the queue. An op is
|
|
173
|
+
`{ op: 'upsert', document }` or `{ op: 'delete', ref: { type, id } }`.
|
|
174
|
+
- An `ack` rebases the waiting changes on the server document. A `reject` (4xx) rolls the change
|
|
175
|
+
back, adds it to `errors`, and puts the write in the dead letters.
|
|
176
|
+
- Use `tempId()` when the server makes the ids. The ledger and the queue change the temporary id
|
|
177
|
+
to the server id in each waiting write.
|
|
178
|
+
- Each tab shows each write. The server does not feed a write back to its sender, so each tab
|
|
179
|
+
applies the ack.
|
|
180
|
+
|
|
181
|
+
## The offline queue and dead letters
|
|
182
|
+
|
|
183
|
+
- Writes stay in IndexedDB. One leader tab (a Web Lock) sends the queue of all tabs, one write
|
|
184
|
+
at a time, in order. The page must be open: there is no Service Worker.
|
|
185
|
+
- A network error, `rate-limited`, or no answer in the ack timeout puts the write back in the
|
|
186
|
+
queue. It goes again after a backoff with jitter.
|
|
187
|
+
- A 4xx reject puts the write in `deadLetters`. A write that depends on a dead letter waits.
|
|
188
|
+
- `retry(id)` applies the change again and sends it again.
|
|
189
|
+
- `discard(id)` removes the dead letter and each write that depends on it. Their changes roll
|
|
190
|
+
back. Without a retry or a discard, the dependent writes wait for ever.
|
|
191
|
+
- Show `<Dovetail::DeadLetters />` so the user can retry or discard each write.
|
|
192
|
+
|
|
193
|
+
## Presence
|
|
194
|
+
|
|
195
|
+
For a room with no document:
|
|
196
|
+
|
|
197
|
+
```hbs
|
|
198
|
+
<Dovetail::Presence @room='board:1' as |presence|>
|
|
199
|
+
<Dovetail::AvatarStack @presence={{presence}} @max={{4}} />
|
|
200
|
+
<Dovetail::LiveCursors @presence={{presence}}>
|
|
201
|
+
<MyBoard />
|
|
202
|
+
</Dovetail::LiveCursors>
|
|
203
|
+
<Dovetail::Typing @presence={{presence}} />
|
|
204
|
+
</Dovetail::Presence>
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
- In code, `dovetail.presence(owner, room)` gives a `LivePresence` with a tracked `state`
|
|
208
|
+
(`{ self, peers }`), and `activity()`, `setPointer()`, `typing()`, `stopTyping()` and `set()`.
|
|
209
|
+
- A room has one awareness. For a room with a document, call `dovetail.doc()` before
|
|
210
|
+
`dovetail.presence()`. `<Dovetail::Editor @room>` does this, and yields `editor.presence`.
|
|
211
|
+
- `LiveCursors` sends the local pointer. For typing, call `presence.typing()` in the input
|
|
212
|
+
handler of your text field.
|
|
213
|
+
- Names, colors and avatars of peers are client data. Only `user.id` comes from the server.
|
|
214
|
+
The components show a name only as text, a color only when `isHexColor` accepts it, and an
|
|
215
|
+
avatar only from an `https:` URL. `@allowAvatarUrl` on the avatar stack sets your own policy.
|
|
216
|
+
- Set `--dovetail-online` and `--dovetail-away` to change the status dot colors.
|
|
217
|
+
|
|
218
|
+
## Status components
|
|
219
|
+
|
|
220
|
+
```hbs
|
|
221
|
+
<Dovetail::ConnectionBadge />
|
|
222
|
+
<Dovetail::SyncStatus />
|
|
223
|
+
<Dovetail::DeadLetters />
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
They read the service. Each value can come from an argument: `@state` and `@queued` on the
|
|
227
|
+
badge, `@status` and `@queued` on the sync status, and `@deadLetters`, `@onRetry` and
|
|
228
|
+
`@onDiscard` on the dead letters. In a `.gts` file, import them from `@dovetail-ts/ember`
|
|
229
|
+
(`ConnectionBadge`, `SyncStatus`, `DeadLetters`, `AvatarStack`, `Typing`, `LiveCursors`,
|
|
230
|
+
`Presence`).
|
|
231
|
+
|
|
232
|
+
## Notifications
|
|
233
|
+
|
|
234
|
+
The server sends each notification to the per-user room `user:<id>`. Make the inbox first, wrap
|
|
235
|
+
the store sink with it, then connect it to the sync client:
|
|
236
|
+
|
|
237
|
+
```ts
|
|
238
|
+
import { NotificationInbox } from '@dovetail-ts/notifications'
|
|
239
|
+
import { storeSink } from '@dovetail-ts/warp-drive'
|
|
240
|
+
|
|
241
|
+
const inbox = new NotificationInbox({
|
|
242
|
+
userId: user.id,
|
|
243
|
+
url: 'https://sync.example.com', // the base of the HTTP routes of the server
|
|
244
|
+
getToken: () => session.token,
|
|
245
|
+
})
|
|
246
|
+
await dovetail.configure({
|
|
247
|
+
transport,
|
|
248
|
+
getToken: () => session.token,
|
|
249
|
+
user,
|
|
250
|
+
sink: inbox.sink(storeSink(store)),
|
|
251
|
+
})
|
|
252
|
+
const stop = dovetail.sync ? inbox.connect(dovetail.sync) : () => {}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
- The inbox must wrap the sink. The server does not send a write back to its sender, so the
|
|
256
|
+
local "mark as read" reaches the inbox only through the ledger and the sink.
|
|
257
|
+
- Give `getToken` to the inbox too. It sends `Authorization: Bearer <token>` with each request.
|
|
258
|
+
- On Rails, mount the routes at `/dovetail/notifications` and give the inbox `url: '/dovetail'`.
|
|
259
|
+
- `markRead(id)` and `archive(id)` are optimistic writes, so they queue offline.
|
|
260
|
+
- Give `describe` to show names. The default text uses the ids.
|
|
261
|
+
|
|
262
|
+
```gts
|
|
263
|
+
import { Toaster } from '@ember-joinery/ember'
|
|
264
|
+
import { ActivityFeed, Inbox, InboxButton, ToastBridge } from '@dovetail-ts/notifications'
|
|
265
|
+
|
|
266
|
+
<template>
|
|
267
|
+
<InboxButton @inbox={{inbox}} {{on 'click' this.open}} />
|
|
268
|
+
<Inbox @inbox={{inbox}} />
|
|
269
|
+
<Toaster />
|
|
270
|
+
<ToastBridge @inbox={{inbox}} @client={{client}} @mute={{array 'assigned'}} />
|
|
271
|
+
<ActivityFeed @events={{this.events}} @scope={{hash type='note' id='1'}} />
|
|
272
|
+
</template>
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
- `ToastBridge` shows new notifications and the sync events `offline`, `online`, `dead-letter`
|
|
276
|
+
and `rollback` in the Joinery `Toaster`. `@types` picks the verbs, and `@mute` hides verbs and
|
|
277
|
+
sync events. Without Ember, call `bridgeToasts`.
|
|
278
|
+
- `ActivityFeed` groups the events of one actor and one verb. Give it
|
|
279
|
+
`notificationActivity(inbox.items)`, or the `events` of an `ActivityLog`.
|
|
280
|
+
|
|
281
|
+
## Without Ember
|
|
282
|
+
|
|
283
|
+
`Connection`, `SyncClient`, `WriteQueue`, `openDovetailDB`, `PresenceRoom` and `DocSession` of
|
|
284
|
+
`@dovetail-ts/core` do the same work. The service makes them for you. Read
|
|
285
|
+
https://joegaudet.com/dovetail/guide/features/connection.md.
|
|
286
|
+
|
|
287
|
+
## Hosted providers
|
|
288
|
+
|
|
289
|
+
Hocuspocus, Liveblocks, PartyKit and Supabase have adapters. Hocuspocus, Liveblocks and PartyKit
|
|
290
|
+
sync Yjs documents only. The Neon adapter waits for a later release. Read
|
|
291
|
+
https://joegaudet.com/dovetail/guide/features/hosted-adapters.md.
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dovetail-coedit
|
|
3
|
+
description: Add live co-edit to a Tiptap 3 editor with Dovetail (@dovetail-ts/tiptap and the Yjs, Loro or Automerge engines). Use when you add Dovetail::Editor or createDovetail, choose a CRDT engine, or add remote carets, per-user undo, versions or comment threads.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Co-edit with Tiptap
|
|
7
|
+
|
|
8
|
+
`@dovetail-ts/tiptap` adds collaboration, remote carets, per-user undo, version history,
|
|
9
|
+
comment threads and activity events to a Tiptap 3 editor. It does not use the paid Tiptap cloud
|
|
10
|
+
extensions. It works on each `DocEngine` that has a binding.
|
|
11
|
+
|
|
12
|
+
Full guide: https://joegaudet.com/dovetail/guide/features/tiptap.md
|
|
13
|
+
|
|
14
|
+
## The editor component (Ember)
|
|
15
|
+
|
|
16
|
+
```gts
|
|
17
|
+
import { on } from '@ember/modifier'
|
|
18
|
+
import { fn } from '@ember/helper'
|
|
19
|
+
import { Editor } from '@dovetail-ts/ember/editor'
|
|
20
|
+
import { AvatarStack } from '@dovetail-ts/ember'
|
|
21
|
+
|
|
22
|
+
<template>
|
|
23
|
+
<Editor @room='note:1' @label='Note' as |editor|>
|
|
24
|
+
<AvatarStack @presence={{editor.presence}} />
|
|
25
|
+
<button type='button' {{on 'click' (fn editor.features.versions.create 'Draft')}}>
|
|
26
|
+
Keep a version
|
|
27
|
+
</button>
|
|
28
|
+
</Editor>
|
|
29
|
+
</template>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
| Argument | Default | What it does |
|
|
33
|
+
| ---------- | ---------------- | ------------------------------------------------------------ |
|
|
34
|
+
| `@room` | none | The room. The editor gets the document from the service. |
|
|
35
|
+
| `@engine` | the Yjs engine | The engine of the document of `@room`. |
|
|
36
|
+
| `@binding` | `yjsBinding` | The binding of the engine. Change it with `@engine`. |
|
|
37
|
+
| `@doc` | none | A `LiveDoc` of your own, in place of `@room`. Needs `@user`. |
|
|
38
|
+
| `@user` | the service user | The local user of the carets. |
|
|
39
|
+
| `@label` | `Document` | The accessible name of the text box. |
|
|
40
|
+
|
|
41
|
+
- Configure the `dovetail` service first (the `dovetail` skill).
|
|
42
|
+
- It yields `presence` and `features` (`threads`, `versions`, `undo`, `redo`).
|
|
43
|
+
- `data-state` is `loading` until the doc session starts, then `syncing`, then `synced` when
|
|
44
|
+
the server has each local change.
|
|
45
|
+
- In code, `dovetail.doc(owner, room, engine, { doc })` gives a `LiveDoc`. The default document
|
|
46
|
+
name is `body`. Call `doc()` before `presence()` for the same room, because a room has one
|
|
47
|
+
awareness.
|
|
48
|
+
|
|
49
|
+
## An editor of your own
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { Editor } from '@tiptap/core'
|
|
53
|
+
import StarterKit from '@tiptap/starter-kit'
|
|
54
|
+
import { yjsEngine } from '@dovetail-ts/crdt-yjs'
|
|
55
|
+
import { createDovetail } from '@dovetail-ts/tiptap'
|
|
56
|
+
import { yjsBinding } from '@dovetail-ts/tiptap/yjs'
|
|
57
|
+
|
|
58
|
+
const handle = yjsEngine().create()
|
|
59
|
+
const dovetail = createDovetail({
|
|
60
|
+
handle,
|
|
61
|
+
binding: yjsBinding,
|
|
62
|
+
user: { id: 'u1', name: 'Ann', color: '#ff6b00' },
|
|
63
|
+
onActivity: event => log.add(event),
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
const editor = new Editor({
|
|
67
|
+
element,
|
|
68
|
+
// The CRDT has its own undo, so turn off the undo of StarterKit.
|
|
69
|
+
extensions: [StarterKit.configure({ undoRedo: false }), dovetail.extension],
|
|
70
|
+
})
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
- Make one `createDovetail` for each editor.
|
|
74
|
+
- Set `undoRedo: false` on StarterKit. Two undo stacks break per-user undo.
|
|
75
|
+
- The package sends no messages. Sync `handle` with a `DocSession` of `@dovetail-ts/core`, or
|
|
76
|
+
with a hosted adapter.
|
|
77
|
+
- Give a `#rrggbb` color. The Yjs carets accept only that form.
|
|
78
|
+
|
|
79
|
+
## Pick an engine
|
|
80
|
+
|
|
81
|
+
| Feature | Yjs (`@dovetail-ts/crdt-yjs`) | Loro (`@dovetail-ts/crdt-loro`) | Automerge (`@dovetail-ts/crdt-automerge`) |
|
|
82
|
+
| --------------- | ----------------------------- | --------------------------------- | ----------------------------------------- |
|
|
83
|
+
| Tiptap binding | Yes (`yjsBinding`) | Yes (`loroBinding`) | No |
|
|
84
|
+
| Remote carets | Yes | Yes | No |
|
|
85
|
+
| Per-user undo | Yes, by origin | Local changes only, not by origin | No |
|
|
86
|
+
| Version history | Yes (snapshots) | Yes (frontiers) | Engine API only |
|
|
87
|
+
| Comment anchors | Yes (relative positions) | Yes (Loro cursors) | Engine API only |
|
|
88
|
+
|
|
89
|
+
- Use Yjs unless you have a reason. It is the reference engine and has all features.
|
|
90
|
+
- The hosted adapters (Hocuspocus, Liveblocks, PartyKit) sync Yjs only.
|
|
91
|
+
- Loro: `loroBinding` comes from `@dovetail-ts/tiptap/loro`. Install `loro-crdt` and
|
|
92
|
+
`loro-prosemirror`. Start a new document on one peer only, and load it on the other peers
|
|
93
|
+
before they start an editor. Wait one task before the first edit. Make sure that the app has
|
|
94
|
+
one copy of each `prosemirror-*` package, or ProseMirror gives "Applying a mismatched
|
|
95
|
+
transaction".
|
|
96
|
+
- Automerge: there is no Tiptap binding. `createDovetail` throws a `CapabilityError`. Use it for
|
|
97
|
+
non-editor documents through the `DocHandle` API.
|
|
98
|
+
|
|
99
|
+
```gts
|
|
100
|
+
import { loroEngine } from '@dovetail-ts/crdt-loro'
|
|
101
|
+
import { loroBinding } from '@dovetail-ts/tiptap/loro'
|
|
102
|
+
import { Editor } from '@dovetail-ts/ember/editor'
|
|
103
|
+
|
|
104
|
+
const engine = loroEngine()
|
|
105
|
+
|
|
106
|
+
<template><Editor @room='note:1' @engine={{engine}} @binding={{loroBinding}} /></template>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Capabilities
|
|
110
|
+
|
|
111
|
+
`engine.capabilities` and `dovetail.capabilities` have the fields `tiptap`, `cursors`, `undo`,
|
|
112
|
+
`history` and `commentAnchors`. Check a field before you show a feature:
|
|
113
|
+
|
|
114
|
+
- No `tiptap`: `createDovetail` throws a `CapabilityError`.
|
|
115
|
+
- No `cursors`: the editor shows no remote carets.
|
|
116
|
+
- No `undo`: `undo()` and `redo()` do nothing and give `false`.
|
|
117
|
+
- No `history`: the `versions` methods throw a `CapabilityError`.
|
|
118
|
+
- No `commentAnchors`: the `threads` methods throw a `CapabilityError`.
|
|
119
|
+
|
|
120
|
+
`requireCapability(engine, name)` of `@dovetail-ts/crdt` throws when the engine does not have
|
|
121
|
+
the feature.
|
|
122
|
+
|
|
123
|
+
## Versions
|
|
124
|
+
|
|
125
|
+
- `versions.create(name?)` keeps the content now as a version. The versions are in the
|
|
126
|
+
document, so each peer sees them. Each version adds the size of the content.
|
|
127
|
+
- `versions.list()` gives the timeline, the oldest first.
|
|
128
|
+
- `versions.preview(id)` gives the content as Tiptap JSON. Show it in a second editor with
|
|
129
|
+
`editable: false`.
|
|
130
|
+
- `versions.restore(id)` makes the content equal to the version, as an edit of this user.
|
|
131
|
+
|
|
132
|
+
## Comment threads
|
|
133
|
+
|
|
134
|
+
- `threads.create(body)` starts a thread on the selection. Select some text first.
|
|
135
|
+
- `threads.reply(id, body)`, `threads.resolve(id)` and `threads.reopen(id)` change a thread.
|
|
136
|
+
- `threads.list()` gives `from` and `to`, the anchor now. They are null when the anchor is gone.
|
|
137
|
+
- `threads.subscribe(listener)` tells you about each change, also from peers.
|
|
138
|
+
- An open thread has the `dovetail-comment` class and a `data-thread-id` attribute. Give the
|
|
139
|
+
class a style.
|
|
140
|
+
- The author (`by`) is client data. Check it on the server when it must be true.
|
|
141
|
+
|
|
142
|
+
## Activity events
|
|
143
|
+
|
|
144
|
+
`onActivity` gets `edited` (at most one each minute), `commented` and `restored` events of the
|
|
145
|
+
local user. Give `log.add` of an `ActivityLog` (`@dovetail-ts/notifications`), and show
|
|
146
|
+
`log.events` in `<Dovetail::ActivityFeed>`. `<Dovetail::Editor>` does not take `onActivity`.
|
|
147
|
+
|
|
148
|
+
## Offline
|
|
149
|
+
|
|
150
|
+
Local doc updates go to IndexedDB (`IndexedDBDocStorage`) and go to the server when the room is
|
|
151
|
+
joined again. The session clears them only after the server has them.
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dovetail-server
|
|
3
|
+
description: Run and secure a Dovetail server, on Node (@dovetail-ts/server) or Rails (the dovetail and dovetail-rails gems). Use when you write the authenticate, authorize, handleWrite, validateUpdate or authorizeAwareness hooks, set limits or stores, publish records or notifications, use broadcasts_dovetail, or check a server before production.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# The Dovetail server
|
|
7
|
+
|
|
8
|
+
The Node server and the Rails gems follow the same rules and pass the same conformance suite.
|
|
9
|
+
The server trusts only its own hooks. Each frame of a client is untrusted data, and the server
|
|
10
|
+
checks it before use. Your hooks decide who the user is, what the user can do, and which data
|
|
11
|
+
is valid.
|
|
12
|
+
|
|
13
|
+
Full guide: https://joegaudet.com/dovetail/guide/servers/node-server.md and
|
|
14
|
+
https://joegaudet.com/dovetail/guide/servers/rails.md
|
|
15
|
+
|
|
16
|
+
## Node: start a server
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm add @dovetail-ts/server
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { createHash, timingSafeEqual } from 'node:crypto'
|
|
24
|
+
import { createDovetailServer, listen } from '@dovetail-ts/server'
|
|
25
|
+
|
|
26
|
+
/** The token is "<user id>.<secret>". The table keeps only the SHA-256 digest of the secret. */
|
|
27
|
+
async function authenticate(token: string | undefined) {
|
|
28
|
+
const dot = token?.indexOf('.') ?? -1
|
|
29
|
+
if (!token || dot < 1 || dot === token.length - 1) return null // Never query with a blank token.
|
|
30
|
+
const user = await users.find(token.slice(0, dot))
|
|
31
|
+
if (!user?.tokenDigest) return null
|
|
32
|
+
const digest = createHash('sha256')
|
|
33
|
+
.update(token.slice(dot + 1))
|
|
34
|
+
.digest()
|
|
35
|
+
const stored = Buffer.from(user.tokenDigest, 'hex')
|
|
36
|
+
return stored.length === digest.length && timingSafeEqual(stored, digest) ? user : null
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const server = createDovetailServer<User>({
|
|
40
|
+
authenticate,
|
|
41
|
+
// Only `true` allows. The action is 'join' or 'write'.
|
|
42
|
+
authorize: async (user, room, action) => (await canAccess(user, room, action)) === true,
|
|
43
|
+
handleWrite: async ({ user, id, room, op }) => {
|
|
44
|
+
if (await writes.applied(id)) return { ok: true } // A resend after a lost ack.
|
|
45
|
+
const document = await save(user, room, op)
|
|
46
|
+
if (!document) return { ok: false, status: 422, errors: [{ title: 'Invalid' }] }
|
|
47
|
+
await writes.markApplied(id)
|
|
48
|
+
return { ok: true, document }
|
|
49
|
+
},
|
|
50
|
+
onError: error => logger.error(error),
|
|
51
|
+
onWarning: warning => logger.warn(warning),
|
|
52
|
+
})
|
|
53
|
+
const { url, close } = await listen(server, { port: 3000, path: '/dovetail' })
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`listen` serves the routes on Node with `ws`: `GET /ws`, `GET` and `POST /sse`,
|
|
57
|
+
`GET /notifications` and `POST /notifications/read-all`. To mount the routes in your own Hono
|
|
58
|
+
app, use `dovetailRoutes(server)`, and give your `ws` server
|
|
59
|
+
`maxPayload: server.limits.maxMessageBytes`.
|
|
60
|
+
|
|
61
|
+
## The hooks
|
|
62
|
+
|
|
63
|
+
| Hook | Rule |
|
|
64
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------ |
|
|
65
|
+
| `authenticate` | `(token) => user \| null`. Null refuses the `hello`. The server refuses a blank token before the hook. |
|
|
66
|
+
| `allowAnonymous` | Set it only when anonymous users are permitted. Then the hook gets `undefined`. |
|
|
67
|
+
| `authorize` | `(user, room, action) => boolean`. Only `true` allows: `undefined` refuses. |
|
|
68
|
+
| `handleWrite` | `({ user, session, id, room, op }) => WriteResult`. Check each field. Reject with a 4xx status. |
|
|
69
|
+
| `validateUpdate` | `(update, { user, session, room, doc }) => boolean`. False or an exception refuses a doc update. |
|
|
70
|
+
| `authorizeAwareness` | `(user, room, state) => state \| false`. The state to relay, or false to refuse it. |
|
|
71
|
+
| `onSessionEnd` | `({ id, user, rooms }) => void`, one time when a connection closes. |
|
|
72
|
+
| `onError` | Gets each exception of a hook. The client gets only a safe `internal` error. |
|
|
73
|
+
|
|
74
|
+
Each hook can return a promise.
|
|
75
|
+
|
|
76
|
+
### authenticate
|
|
77
|
+
|
|
78
|
+
- Keep a digest of each token, not the token. Compare the digest in constant time
|
|
79
|
+
(`timingSafeEqual` of `node:crypto`).
|
|
80
|
+
- Never give a missing or blank token to a database query. A query for a null token finds the
|
|
81
|
+
first user with no token. Keep the blank check in the hook, also when the server checks it.
|
|
82
|
+
|
|
83
|
+
### authorize
|
|
84
|
+
|
|
85
|
+
- The server calls it with `'join'` for each join, and with `'write'` for each write, each
|
|
86
|
+
`doc-update` and each `doc-sync` step 2. A user with only the join right can read a document
|
|
87
|
+
but not change it.
|
|
88
|
+
- Return `true` only, with `=== true`. A function that returns a truthy object or `undefined`
|
|
89
|
+
is an error.
|
|
90
|
+
- A server with `authenticate` and no `authorize` allows each action, and warns at the start.
|
|
91
|
+
- A user can join only the own per-user room `user:<id>`, whatever `authorize` gives.
|
|
92
|
+
- The server calls it for each update. Keep a cache when the hook is slow.
|
|
93
|
+
|
|
94
|
+
### handleWrite
|
|
95
|
+
|
|
96
|
+
- `authorize` decides who can write. `handleWrite` decides if the write is valid.
|
|
97
|
+
- `{ ok: true }` acks and feeds the op. `{ ok: true, document }` acks with the server document
|
|
98
|
+
and feeds it; the client rebases on it. `{ ok: false, status, errors }` rejects with a 4xx
|
|
99
|
+
status and JSON:API errors; the client rolls back and puts the write in the dead letters.
|
|
100
|
+
- `id` is the write id. The offline queue sends a write again with the same id after a lost ack.
|
|
101
|
+
Keep the ids that you applied (a table with a unique key), and skip a resend:
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
const applied = new Set<string>() // In a real app: a table with a unique key.
|
|
105
|
+
|
|
106
|
+
const server = createDovetailServer({
|
|
107
|
+
async handleWrite({ id, op }) {
|
|
108
|
+
if (applied.has(id)) return { ok: true } // A resend: the change is in the database.
|
|
109
|
+
const document = await save(op)
|
|
110
|
+
applied.add(id)
|
|
111
|
+
return { ok: true, document }
|
|
112
|
+
},
|
|
113
|
+
})
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### validateUpdate
|
|
117
|
+
|
|
118
|
+
The server stores the bytes of a doc update and does not read them. Give `validateUpdate` for
|
|
119
|
+
each CRDT engine that you use. For Yjs, apply the update to an empty document in a `try`:
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
import * as Y from 'yjs'
|
|
123
|
+
|
|
124
|
+
const server = createDovetailServer({
|
|
125
|
+
mergeUpdates: updates => Y.mergeUpdates(updates),
|
|
126
|
+
validateUpdate: update => {
|
|
127
|
+
try {
|
|
128
|
+
Y.applyUpdate(new Y.Doc(), update)
|
|
129
|
+
return true
|
|
130
|
+
} catch {
|
|
131
|
+
return false
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
})
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### authorizeAwareness
|
|
138
|
+
|
|
139
|
+
Presence names, colors and avatars are client data. Without this hook, the server sets only
|
|
140
|
+
`state.user.id` to the id of the user. With the hook, the server relays the state that the hook
|
|
141
|
+
gives and does not set the id, so set it in the hook:
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
const server = createDovetailServer<User>({
|
|
145
|
+
authorizeAwareness: (user, room, state) => {
|
|
146
|
+
if (!user) return false
|
|
147
|
+
return { ...state, user: { id: user.id, name: user.name, color: user.color } }
|
|
148
|
+
},
|
|
149
|
+
})
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The author of a Tiptap comment is in the CRDT document, so it is client data too. Check the
|
|
153
|
+
thread data in your own server code when the author must be true.
|
|
154
|
+
|
|
155
|
+
## Push changes from your code
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
server.publish('note:1', { data: { type: 'note', id: '1', attributes: { title: 'Plan' } } })
|
|
159
|
+
server.remove('note:1', { type: 'note', id: '2' })
|
|
160
|
+
await server.notify('u2', {
|
|
161
|
+
verb: 'commented',
|
|
162
|
+
actor: { type: 'user', id: 'u1' },
|
|
163
|
+
target: { type: 'note', id: '1' },
|
|
164
|
+
})
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
- Call `publish` when a record changes outside Dovetail, for example in a job.
|
|
168
|
+
- A notification goes only to a per-user room. `publish` of a `notification` to another room
|
|
169
|
+
throws. Use `notify`, `markRead`, `archive` and `markAllRead`.
|
|
170
|
+
|
|
171
|
+
## Stores and limits
|
|
172
|
+
|
|
173
|
+
- The memory stores (`MemoryDocPersistence`, `MemoryNotificationStore`) are for development and
|
|
174
|
+
tests only. Give a `DocPersistence` (`append(room, doc, update)`, `load(room, doc)`) and a
|
|
175
|
+
`NotificationStore` in production.
|
|
176
|
+
- `limits` has safe defaults. Keep them, or make them smaller: `maxMessageBytes` (1 MiB),
|
|
177
|
+
`maxNameLength` (256), `maxOps` (1000), `maxDepth` (32), `maxRooms` (100), `feedHistory`
|
|
178
|
+
(1000), `feedHistoryBytes` (1 MiB), `roomIdleMs`, `maxConnections` (10000), `maxQueue`
|
|
179
|
+
(1000), `maxMessagesPerSecond` (200), `helloTimeoutMs` (10 s), `pingMs` and
|
|
180
|
+
`maxBufferedBytes` (4 MiB).
|
|
181
|
+
- When the feed history of a room does not have each op after the cursor of a join, the `ack`
|
|
182
|
+
has `reset: true`. The client must load the room again with its `reload` hook.
|
|
183
|
+
- The routes set no CORS headers. Serve the app and the server from one origin.
|
|
184
|
+
|
|
185
|
+
## Rails
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
bundle add dovetail-rails
|
|
189
|
+
bin/rails generate dovetail:install
|
|
190
|
+
bin/rails db:migrate
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
```ruby
|
|
194
|
+
# config/initializers/dovetail.rb
|
|
195
|
+
Dovetail::Rails.configure do |config|
|
|
196
|
+
# The token is "<user id>.<secret>". The table keeps only the SHA-256 digest of the secret.
|
|
197
|
+
config.authenticate = lambda do |token|
|
|
198
|
+
id, secret = token.to_s.split(".", 2)
|
|
199
|
+
next nil if id.blank? || secret.blank?
|
|
200
|
+
|
|
201
|
+
user = User.find_by(id: id)
|
|
202
|
+
digest = Digest::SHA256.hexdigest(secret)
|
|
203
|
+
user if user&.dovetail_token_digest &&
|
|
204
|
+
ActiveSupport::SecurityUtils.secure_compare(user.dovetail_token_digest, digest)
|
|
205
|
+
end
|
|
206
|
+
config.authorize = ->(user, room, action) { user.can?(action, room) == true }
|
|
207
|
+
config.handle_write = ->(write) { NoteWrites.apply(write) } # write: { user:, session:, id:, room:, op: }
|
|
208
|
+
# Your own check of the bytes for your CRDT engine. False or an exception refuses the update.
|
|
209
|
+
config.validate_update = ->(update, context) { DocUpdateCheck.valid?(update, context) }
|
|
210
|
+
config.authorize_awareness = lambda do |user, room, state|
|
|
211
|
+
state.merge("user" => { "id" => user.id.to_s, "name" => user.name })
|
|
212
|
+
end
|
|
213
|
+
config.notifications = Dovetail::Rails::RecordNotificationStore.new
|
|
214
|
+
config.on_error = ->(error) { Rails.logger.error(error) }
|
|
215
|
+
config.on_warning = ->(message) { Rails.logger.warn(message) }
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# config/routes.rb
|
|
219
|
+
mount Dovetail::Rails.notifications_app, at: "/dovetail/notifications"
|
|
220
|
+
|
|
221
|
+
class Note < ApplicationRecord
|
|
222
|
+
broadcasts_dovetail to: ->(note) { "note:#{note.id}" }, attributes: %i[title body updated_at]
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
class Comment < ApplicationRecord
|
|
226
|
+
notifies_dovetail to: :recipient, verb: "commented", actor: :author, target: :note
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
Dovetail::Rails.notify(user, verb: "mentioned", actor: author, target: note)
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
- The client uses `CableTransport` of `@dovetail-ts/transport-cable`.
|
|
233
|
+
- The hooks are the Node hooks in snake case: `authenticate`, `authorize`, `handle_write`,
|
|
234
|
+
`validate_update`, `authorize_awareness`, `allow_anonymous`, `on_session_end`, `on_error`,
|
|
235
|
+
`on_warning`. `authorize` allows only when it gives `true`.
|
|
236
|
+
- `handle_write` gets the write `id`. Skip a resend, as on Node.
|
|
237
|
+
- `broadcasts_dovetail` needs `attributes:` (an allowlist) or `document:`. Each member of the
|
|
238
|
+
room gets the document. Give only the columns that each member can see.
|
|
239
|
+
- The feed cursors come from `Rails.cache`. The cache must have an atomic `increment`.
|
|
240
|
+
- The gems have no socket limits. Set the limits in ActionCable, the Rack server or a proxy.
|
|
241
|
+
- The awareness states and the default doc store are in the memory of each process. Give
|
|
242
|
+
`config.docs` a shared store when you run more than one cable process.
|
|
243
|
+
- For Rack without Rails, use `Dovetail::Server.new(...)` of the `dovetail` gem.
|
|
244
|
+
|
|
245
|
+
## Security checklist
|
|
246
|
+
|
|
247
|
+
Do each step before production. Read
|
|
248
|
+
https://joegaudet.com/dovetail/guide/servers/security.md.
|
|
249
|
+
|
|
250
|
+
1. Give `authenticate`. Keep token digests, and compare them in constant time
|
|
251
|
+
(`timingSafeEqual`, Ruby `secure_compare`). Never give a missing or blank token to a
|
|
252
|
+
database query.
|
|
253
|
+
2. Give `authorize`. Make it return `true` only for a permitted user, room and action.
|
|
254
|
+
3. Check each write in `handleWrite`. Skip a resend with the write `id`.
|
|
255
|
+
4. Give `validateUpdate` for each CRDT engine that you use.
|
|
256
|
+
5. Give `authorizeAwareness` when the name of a user must come from your data. Set the user id
|
|
257
|
+
in it.
|
|
258
|
+
6. Replace the memory stores (`MemoryDocPersistence`, `MemoryNotificationStore`, Ruby
|
|
259
|
+
`MemoryFeedLog`).
|
|
260
|
+
7. Keep the default limits, or make them smaller. On Rails, set the socket limits in
|
|
261
|
+
ActionCable or in a proxy.
|
|
262
|
+
8. Give your `ws` server `maxPayload: server.limits.maxMessageBytes`.
|
|
263
|
+
9. Serve the app and the server from one origin. The routes set no CORS headers.
|
|
264
|
+
10. Use `wss:` and `https:` URLs only.
|
|
265
|
+
11. On Rails, give `attributes:` to each `broadcasts_dovetail`.
|
|
266
|
+
12. Send `onError` and `onWarning` (Ruby `on_error`, `on_warning`) to your logs.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dovetail-testing
|
|
3
|
+
description: Test an app that uses Dovetail with @dovetail-ts/test-support. Use when you write a test for Dovetail components, live records, writes, the offline queue, presence, notifications or co-edit, with inPageServer, FakeHub, NetworkSwitch, FakeClock, the harnesses and the @harnessed-ts/should matchers.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Test Dovetail
|
|
7
|
+
|
|
8
|
+
Each component test uses a harness of `@dovetail-ts/test-support` and the
|
|
9
|
+
`@harnessed-ts/should` matchers:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
await badge.state.should.equal('offline')
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
- Do not use `assert`, `expect` or raw DOM queries in a component test. Await each `should`.
|
|
16
|
+
- `harness.<method>.should` calls the method when the check runs.
|
|
17
|
+
- Plain logic with no UI (a reducer, a codec) can use the assertions of your test runner.
|
|
18
|
+
|
|
19
|
+
Full guide: https://joegaudet.com/dovetail/guide/testing/test-support.md and
|
|
20
|
+
https://joegaudet.com/dovetail/guide/testing/harnesses.md
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm add -D @dovetail-ts/test-support @harnessed-ts/core @harnessed-ts/ember @harnessed-ts/should
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## The fakes
|
|
27
|
+
|
|
28
|
+
| Part | Package | Use it for |
|
|
29
|
+
| ---------------------- | ----------------------------- | ------------------------------------------------------------------------ |
|
|
30
|
+
| `inPageServer()` | `@dovetail-ts/server/browser` | A real server and its transports in the page, with an online switch. |
|
|
31
|
+
| `FakeHub` | `@dovetail-ts/test-support` | An in-page transport hub, with the slow and flaky modes. |
|
|
32
|
+
| `NetworkSwitch` | `@dovetail-ts/test-support` | `online`, `offline`, `slow` (`latency`) or `flaky` (`dropRate`, `seed`). |
|
|
33
|
+
| `FakeClock` | `@dovetail-ts/test-support` | Timers that move only on `tick(ms)` or `runAll()`. |
|
|
34
|
+
| `installFakeIndexedDB` | `@dovetail-ts/test-support` | An in-memory IndexedDB for queue tests on Node. |
|
|
35
|
+
| `DovetailHarness` | `@dovetail-ts/test-support` | The base of the harnesses. `DovetailHarness.at(env, selector)`. |
|
|
36
|
+
|
|
37
|
+
- App code (a demo, a story) imports `inPageServer` from `@dovetail-ts/server/browser`. The lint
|
|
38
|
+
rule `ember/no-test-support-import` refuses test-support in `app/`.
|
|
39
|
+
- `inPageServer(options)` takes the options of `createDovetailServer` (`authenticate`,
|
|
40
|
+
`handleWrite`, ...). It gives `server`, `connect` and `network`.
|
|
41
|
+
`page.network.set('offline')` closes the open transports.
|
|
42
|
+
- With `FakeHub`, the device and the server have separate networks. Give the client
|
|
43
|
+
`ALWAYS_ONLINE` and set the hub `NetworkSwitch` to `offline` to show a server that is down.
|
|
44
|
+
- Give a `FakeClock` as the `clock` of the connection, the presence room, the sync client or the
|
|
45
|
+
server. An open connection always has a heartbeat timer, so use `heartbeatInterval: 0` with
|
|
46
|
+
`runAll()`, or use `tick`.
|
|
47
|
+
- On Node, call `installFakeIndexedDB()` in `beforeEach`, and call the function that it returns
|
|
48
|
+
in `afterEach`.
|
|
49
|
+
|
|
50
|
+
## Set up a rendering test
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import type Owner from '@ember/owner'
|
|
54
|
+
import { configure } from '@harnessed-ts/core'
|
|
55
|
+
import { LOCAL_LOCKS } from '@dovetail-ts/core'
|
|
56
|
+
import type { NetworkSignal } from '@dovetail-ts/core'
|
|
57
|
+
import type { DovetailConfig, DovetailService } from '@dovetail-ts/ember'
|
|
58
|
+
import type { ClientTransport } from '@dovetail-ts/protocol'
|
|
59
|
+
|
|
60
|
+
/** The messages arrive after the render, so each `should` check reads again until it passes. */
|
|
61
|
+
export function setupRetries(hooks: NestedHooks): void {
|
|
62
|
+
hooks.beforeEach(() => configure({ retryAssertions: true }))
|
|
63
|
+
hooks.afterEach(() => configure({ retryAssertions: false }))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let databases = 0
|
|
67
|
+
|
|
68
|
+
/** Configures the `dovetail` service of the test on an in-page server. */
|
|
69
|
+
export async function configureDovetail(
|
|
70
|
+
owner: Owner,
|
|
71
|
+
server: { connect(): ClientTransport; network: NetworkSignal },
|
|
72
|
+
config: Partial<DovetailConfig> = {},
|
|
73
|
+
): Promise<DovetailService> {
|
|
74
|
+
const dovetail = owner.lookup('service:dovetail') as DovetailService
|
|
75
|
+
await dovetail.configure({
|
|
76
|
+
transport: () => server.connect(),
|
|
77
|
+
user: { id: 'u1', name: 'Ana', color: '#1d4ed8' },
|
|
78
|
+
sink: { apply: () => {} },
|
|
79
|
+
// Each test has its own database, so the queue of one test does not go to the next one.
|
|
80
|
+
dbName: `test-${++databases}-${Date.now()}`,
|
|
81
|
+
connection: { network: server.network },
|
|
82
|
+
// One "tab" in the page: no Web Lock and no BroadcastChannel to other tests.
|
|
83
|
+
sync: { locks: LOCAL_LOCKS, channel: undefined },
|
|
84
|
+
...config,
|
|
85
|
+
})
|
|
86
|
+
return dovetail
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
- Turn on `retryAssertions`, because server messages arrive after the render.
|
|
91
|
+
- Give each test its own `dbName`.
|
|
92
|
+
- Give `sync: { locks: LOCAL_LOCKS, channel: undefined }`, so tests do not share a lock or a
|
|
93
|
+
channel.
|
|
94
|
+
- Give a real store sink (`storeSink(store)`) when the test reads records.
|
|
95
|
+
|
|
96
|
+
## Samples
|
|
97
|
+
|
|
98
|
+
Offline, with a queued write:
|
|
99
|
+
|
|
100
|
+
```gts
|
|
101
|
+
import { render } from '@ember/test-helpers'
|
|
102
|
+
import { ember } from '@harnessed-ts/ember'
|
|
103
|
+
import { ConnectionBadge, SyncStatus } from '@dovetail-ts/ember'
|
|
104
|
+
import { inPageServer } from '@dovetail-ts/server/browser'
|
|
105
|
+
import { ConnectionBadgeHarness, SyncStatusHarness } from '@dovetail-ts/test-support'
|
|
106
|
+
|
|
107
|
+
const page = inPageServer()
|
|
108
|
+
const dovetail = await configureDovetail(this.owner, page)
|
|
109
|
+
await render(
|
|
110
|
+
<template>
|
|
111
|
+
<ConnectionBadge />
|
|
112
|
+
<SyncStatus />
|
|
113
|
+
</template>,
|
|
114
|
+
)
|
|
115
|
+
const badge = new ConnectionBadgeHarness(ember())
|
|
116
|
+
const status = new SyncStatusHarness(ember())
|
|
117
|
+
await badge.state.should.equal('online')
|
|
118
|
+
|
|
119
|
+
page.network.set('offline')
|
|
120
|
+
await dovetail.write('note:1', {
|
|
121
|
+
op: 'upsert',
|
|
122
|
+
document: { data: { type: 'note', id: '1', attributes: { title: 'Plan' } } },
|
|
123
|
+
})
|
|
124
|
+
await badge.text.should.equal('Offline · 1 queued')
|
|
125
|
+
page.network.set('online')
|
|
126
|
+
await status.state.should.equal('saved')
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
A refused write goes to the dead letters:
|
|
130
|
+
|
|
131
|
+
```gts
|
|
132
|
+
const page = inPageServer({
|
|
133
|
+
handleWrite: () => ({
|
|
134
|
+
ok: false,
|
|
135
|
+
status: 422,
|
|
136
|
+
errors: [{ title: 'Invalid', detail: 'The title is empty' }],
|
|
137
|
+
}),
|
|
138
|
+
})
|
|
139
|
+
const dovetail = await configureDovetail(this.owner, page)
|
|
140
|
+
await render(<template><DeadLetters /></template>)
|
|
141
|
+
const letters = new DeadLettersHarness(ember())
|
|
142
|
+
await dovetail.write('note:1', {
|
|
143
|
+
op: 'upsert',
|
|
144
|
+
document: { data: { type: 'note', id: '1', attributes: { title: '' } } },
|
|
145
|
+
})
|
|
146
|
+
await letters.reasons.should.deep.equal(['The title is empty'])
|
|
147
|
+
await letters.discard(0)
|
|
148
|
+
await letters.state.should.equal('empty')
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
A second user is plain core code on the same in-page server, with a `FakeClock`:
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import { Connection, PresenceRoom } from '@dovetail-ts/core'
|
|
155
|
+
import { FakeClock } from '@dovetail-ts/test-support'
|
|
156
|
+
|
|
157
|
+
const clock = new FakeClock()
|
|
158
|
+
const connection = new Connection({ transport: page.connect, network: page.network })
|
|
159
|
+
connection.connect()
|
|
160
|
+
const ben = new PresenceRoom({
|
|
161
|
+
connection,
|
|
162
|
+
room: 'board:1',
|
|
163
|
+
user: { id: 'u2', name: 'Ben', color: '#b91c1c' },
|
|
164
|
+
clock,
|
|
165
|
+
typingTimeout: 1500,
|
|
166
|
+
})
|
|
167
|
+
await avatars.names.should.deep.equal(['Ana', 'Ben'])
|
|
168
|
+
ben.typing()
|
|
169
|
+
await typing.text.should.equal('Ben is typing')
|
|
170
|
+
clock.tick(1500)
|
|
171
|
+
await typing.state.should.equal('idle')
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
For the inbox, give `NotificationInbox` a `fetch` that returns an empty page (the in-page server
|
|
175
|
+
has no HTTP routes). Wait for the join of `user:u1` (`dovetail.connection?.onJoin`) before you
|
|
176
|
+
call `page.server.notify`.
|
|
177
|
+
|
|
178
|
+
For two editors, give the second `<Dovetail::Editor>` a `LiveDoc` on its own connection
|
|
179
|
+
(`@doc` and `@user`). The text of an editor also has the caret labels, so use
|
|
180
|
+
`content.should.contain(...)`, not `equal`.
|
|
181
|
+
|
|
182
|
+
## The harnesses
|
|
183
|
+
|
|
184
|
+
Make a harness with the driver of the test: `new ConnectionBadgeHarness(ember())`.
|
|
185
|
+
|
|
186
|
+
| Harness | Component | `state` | More |
|
|
187
|
+
| ------------------------ | ----------------------------- | ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
188
|
+
| `DovetailHarness` | Any element | `data-state` of the host | `text`. `DovetailHarness.at(env, selector)`. |
|
|
189
|
+
| `ConnectionBadgeHarness` | `<Dovetail::ConnectionBadge>` | `online`, `connecting`, `reconnecting`, `offline` | `text`, `queued` |
|
|
190
|
+
| `SyncStatusHarness` | `<Dovetail::SyncStatus>` | `saved`, `syncing`, `offline` | `text` |
|
|
191
|
+
| `AvatarStackHarness` | `<Dovetail::AvatarStack>` | `empty`, `present` | `names`, `statuses`, `labels`, `overflow`, `hoverAvatar(i)`, `focusAvatar(i)`, `tooltip` |
|
|
192
|
+
| `TypingHarness` | `<Dovetail::Typing>` | `idle`, `typing` | `text` |
|
|
193
|
+
| `LiveCursorsHarness` | `<Dovetail::LiveCursors>` | | `pointIn`, `cursorNames`, `position(name)` |
|
|
194
|
+
| `DeadLettersHarness` | `<Dovetail::DeadLetters>` | `empty`, `failed` | `titles`, `reasons`, `retry(i)`, `discard(i)` |
|
|
195
|
+
| `EditorHarness` | `<Dovetail::Editor>` | `loading`, `syncing`, `synced` | `type(text)`, `content`, `carets` |
|
|
196
|
+
| `InboxButtonHarness` | `<Dovetail::InboxButton>` | `unread`, `empty` | `unread`, `label`, `click` |
|
|
197
|
+
| `InboxHarness` | `<Dovetail::Inbox>` | `loading`, `error`, `empty`, `ready` | `notifications`, `states`, `selectedTab`, `showUnread`, `showAll`, `markRead(i)`, `archive(i)`, `markAllRead`, `loadMore`, `retry`, `notification(i)` |
|
|
198
|
+
| `NotificationRowHarness` | One row of the inbox | `unread`, `read` | `text`, `markRead`, `archive`, `canMarkRead` |
|
|
199
|
+
| `ActivityFeedHarness` | `<Dovetail::ActivityFeed>` | `empty`, `loading`, `ready` | `groups`, `hasMore`, `loadOlder` |
|
|
200
|
+
| `ToastBridgeHarness` | The Joinery `<Toaster>` | | `toasts`, `types` |
|
|
201
|
+
| `InspectorHarness` | `<DovetailInspector>` | the connection state, or `none` | `history`, `rooms`, `holders`, `queued`, `deadLetters`, `errors`, `peers`, `docs` |
|
|
202
|
+
| `DemoPaneHarness` | A pane of the Dovetail demo | | The tests of the marketing demo use it. An app does not need it. |
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { cpSync, readdirSync } from 'fs';
|
|
2
|
+
import { join, dirname, relative } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
// src/index.ts
|
|
6
|
+
var assets = join(dirname(fileURLToPath(import.meta.url)), "..", "assets");
|
|
7
|
+
function files(dir) {
|
|
8
|
+
return readdirSync(dir, { withFileTypes: true }).flatMap(
|
|
9
|
+
(e) => e.isDirectory() ? files(join(dir, e.name)) : [join(dir, e.name)]
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
function install(repo, { dryRun = false } = {}) {
|
|
13
|
+
const target = join(repo, ".claude");
|
|
14
|
+
const written = files(assets).map((f) => join(target, relative(assets, f)));
|
|
15
|
+
if (!dryRun) cpSync(assets, target, { recursive: true });
|
|
16
|
+
return written;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { install };
|
|
20
|
+
//# sourceMappingURL=chunk-OIN5V5PO.js.map
|
|
21
|
+
//# sourceMappingURL=chunk-OIN5V5PO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAMA,IAAM,MAAA,GAAS,KAAK,OAAA,CAAQ,aAAA,CAAc,YAAY,GAAG,CAAC,CAAA,EAAG,IAAA,EAAM,QAAQ,CAAA;AAE3E,SAAS,MAAM,GAAA,EAAuB;AACpC,EAAA,OAAO,YAAY,GAAA,EAAK,EAAE,aAAA,EAAe,IAAA,EAAM,CAAA,CAAE,OAAA;AAAA,IAAQ,OACvD,CAAA,CAAE,WAAA,EAAY,GAAI,KAAA,CAAM,KAAK,GAAA,EAAK,CAAA,CAAE,IAAI,CAAC,IAAI,CAAC,IAAA,CAAK,GAAA,EAAK,CAAA,CAAE,IAAI,CAAC;AAAA,GACjE;AACF;AAMO,SAAS,QAAQ,IAAA,EAAc,EAAE,SAAS,KAAA,EAAM,GAA0B,EAAC,EAAa;AAC7F,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,IAAA,EAAM,SAAS,CAAA;AACnC,EAAA,MAAM,OAAA,GAAU,KAAA,CAAM,MAAM,CAAA,CAAE,GAAA,CAAI,CAAA,CAAA,KAAK,IAAA,CAAK,MAAA,EAAQ,QAAA,CAAS,MAAA,EAAQ,CAAC,CAAC,CAAC,CAAA;AACxE,EAAA,IAAI,CAAC,QAAQ,MAAA,CAAO,MAAA,EAAQ,QAAQ,EAAE,SAAA,EAAW,MAAM,CAAA;AACvD,EAAA,OAAO,OAAA;AACT","file":"chunk-OIN5V5PO.js","sourcesContent":["// Copies the shipped skills into the .claude/ directory of a repo.\nimport { cpSync, readdirSync } from 'node:fs'\nimport { dirname, join, relative } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n// `src` and `dist` are both beside `assets`. `assets/skills` goes to `.claude/skills`.\nconst assets = join(dirname(fileURLToPath(import.meta.url)), '..', 'assets')\n\nfunction files(dir: string): string[] {\n return readdirSync(dir, { withFileTypes: true }).flatMap(e =>\n e.isDirectory() ? files(join(dir, e.name)) : [join(dir, e.name)],\n )\n}\n\n/**\n * Writes the skills into `<repo>/.claude/skills/`, and replaces older copies. The other files\n * of `.claude/` stay. Returns the paths that it writes.\n */\nexport function install(repo: string, { dryRun = false }: { dryRun?: boolean } = {}): string[] {\n const target = join(repo, '.claude')\n const written = files(assets).map(f => join(target, relative(assets, f)))\n if (!dryRun) cpSync(assets, target, { recursive: true })\n return written\n}\n"]}
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { install } from './chunk-OIN5V5PO.js';
|
|
3
|
+
|
|
4
|
+
// src/cli.ts
|
|
5
|
+
var dryRun = process.argv.includes("--dry-run");
|
|
6
|
+
for (const f of install(process.cwd(), { dryRun }))
|
|
7
|
+
console.log(`${dryRun ? "would write" : "wrote"} ${f}`);
|
|
8
|
+
//# sourceMappingURL=cli.js.map
|
|
9
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"names":[],"mappings":";;;;AAGA,IAAM,MAAA,GAAS,OAAA,CAAQ,IAAA,CAAK,QAAA,CAAS,WAAW,CAAA;AAChD,KAAA,MAAW,KAAK,OAAA,CAAQ,OAAA,CAAQ,KAAI,EAAG,EAAE,QAAQ,CAAA;AAC/C,EAAA,OAAA,CAAQ,IAAI,CAAA,EAAG,MAAA,GAAS,gBAAgB,OAAO,CAAA,CAAA,EAAI,CAAC,CAAA,CAAE,CAAA","file":"cli.js","sourcesContent":["#!/usr/bin/env node\nimport { install } from './index.js'\n\nconst dryRun = process.argv.includes('--dry-run')\nfor (const f of install(process.cwd(), { dryRun }))\n console.log(`${dryRun ? 'would write' : 'wrote'} ${f}`)\n"]}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dovetail-ts/skills",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Installs the Dovetail agent skills into the .claude/ directory of a repo.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Joe Gaudet <joe@joegaudet.com>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/joegaudet/dovetail.git",
|
|
10
|
+
"directory": "packages/skills"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://joegaudet.com/dovetail/",
|
|
13
|
+
"bugs": "https://github.com/joegaudet/dovetail/issues",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"realtime",
|
|
16
|
+
"offline",
|
|
17
|
+
"sync",
|
|
18
|
+
"crdt",
|
|
19
|
+
"claude",
|
|
20
|
+
"claude-code",
|
|
21
|
+
"agent",
|
|
22
|
+
"skill"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./package.json": "./package.json"
|
|
32
|
+
},
|
|
33
|
+
"bin": {
|
|
34
|
+
"dovetail-skills": "./dist/cli.js"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"assets",
|
|
39
|
+
"CHANGELOG.md",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE"
|
|
42
|
+
],
|
|
43
|
+
"sideEffects": false,
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"tsup": "^8.5.1"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=22.12.0"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsc --build --force && tsup"
|
|
55
|
+
}
|
|
6
56
|
}
|