@devyrpauli/mddocs 0.1.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/LICENSE +21 -0
- package/NOTICE.md +8 -0
- package/README.md +294 -0
- package/bin.mjs +10 -0
- package/cli.mjs +58738 -0
- package/dist/apple-touch-icon.png +0 -0
- package/dist/assets/blue.png +0 -0
- package/dist/assets/copy-icon.svg +6 -0
- package/dist/assets/editor.js +1564 -0
- package/dist/assets/lime.png +0 -0
- package/dist/assets/lottie.min.js +1 -0
- package/dist/assets/mint.png +0 -0
- package/dist/assets/orange.png +0 -0
- package/dist/assets/pink.png +0 -0
- package/dist/assets/proof-logo-animation-v2.lottie +0 -0
- package/dist/assets/proof-logo.svg +9 -0
- package/dist/assets/purple.png +0 -0
- package/dist/assets/red.png +0 -0
- package/dist/assets/stamp-bg.svg +21 -0
- package/dist/assets/yellow.png +0 -0
- package/dist/favicon-16x16.png +0 -0
- package/dist/favicon-32x32.png +0 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.html +1071 -0
- package/dist/web-artifact-manifest.json +6 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Every
|
|
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/NOTICE.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Attribution
|
|
2
|
+
|
|
3
|
+
This project is built on proof-sdk (https://github.com/EveryInc/proof-sdk),
|
|
4
|
+
MIT-licensed by Every Inc. The `packages/doc-*`, `src/`, and `server/` trees
|
|
5
|
+
originate from proof-sdk and retain its license (see LICENSE).
|
|
6
|
+
|
|
7
|
+
"Proof" is a trademark of Every Inc.; this project is not affiliated with or
|
|
8
|
+
endorsed by them and does not use the Proof name (see TRADEMARKS.md).
|
package/README.md
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
# mddocs
|
|
2
|
+
|
|
3
|
+
Local-first, git-native collaboration for Markdown, with a CLI, real-time
|
|
4
|
+
multiplayer, and an agent API.
|
|
5
|
+
|
|
6
|
+
Think of it as "Google Docs for `.md` files" that lives in your repo: comments,
|
|
7
|
+
suggestions, authorship/provenance, and full history, all stored inside the
|
|
8
|
+
Markdown file and versioned by plain git. Humans and AI agents can edit the same
|
|
9
|
+
document together, live. No hosted service.
|
|
10
|
+
|
|
11
|
+
`mddocs` is a thin, self-hostable layer built on the MIT-licensed
|
|
12
|
+
[`proof-sdk`](https://github.com/EveryInc/proof-sdk). It reuses Proof's marks
|
|
13
|
+
model and browser editor, and adds a local-first, git-backed workflow, a
|
|
14
|
+
command-line interface, a real-time collaboration server, and an agent HTTP API,
|
|
15
|
+
all keeping the `.md` file plus git as the single source of truth.
|
|
16
|
+
|
|
17
|
+
Install from npm:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install -g @devyrpauli/mddocs
|
|
21
|
+
mddocs --help
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Note: `mddocs` is a working title; the npm package is published under the
|
|
25
|
+
`@devyrpauli` scope while the name is settled, and the command is `mddocs`. You
|
|
26
|
+
can also run from source (see [Install from source](#install-from-source)).
|
|
27
|
+
|
|
28
|
+
## Why
|
|
29
|
+
|
|
30
|
+
Proof is a good collaborative Markdown editor, and `proof-sdk` is open-source,
|
|
31
|
+
but the usual way to self-host collaboration is to stand up a database-backed
|
|
32
|
+
server. `mddocs` takes a different approach:
|
|
33
|
+
|
|
34
|
+
- The file is the database. Comments, suggestions, and provenance are serialized
|
|
35
|
+
into a `<!-- PROOF ... -->` JSON footer inside the same `.md` file. Open the
|
|
36
|
+
file anywhere and the collaboration state travels with it.
|
|
37
|
+
- git is the history and async-sync layer. Edits are ordinary commits. Async
|
|
38
|
+
collaboration is just branches and merges; a conflicted footer is union-resolved
|
|
39
|
+
by `mddocs resolve`.
|
|
40
|
+
- Live multiplayer is a relay, not a new source of truth. `mddocs serve` hosts a
|
|
41
|
+
real-time session (Yjs over WebSocket); every settled change is written straight
|
|
42
|
+
back to the `.md` and auto-committed. The database never takes over.
|
|
43
|
+
- The CLI and HTTP API are clients too. Add a comment, file a suggestion, or read
|
|
44
|
+
state without a browser, which is useful for scripts and AI agents.
|
|
45
|
+
|
|
46
|
+
## What you get
|
|
47
|
+
|
|
48
|
+
| Capability | How |
|
|
49
|
+
|---|---|
|
|
50
|
+
| Browser editor (comments, suggestions, provenance) | `mddocs open <file>` (single-user) or `mddocs serve <file>` (multiplayer) |
|
|
51
|
+
| Real-time multiplayer with presence | `mddocs serve <file>`: everyone on the URL co-edits live; edits persist to the file plus git |
|
|
52
|
+
| Role-based share links (editor / commenter / viewer) | `serve` prints a link per role; viewers are read-only, enforced server-side |
|
|
53
|
+
| Agent HTTP API | AI tools read state and post comments/suggestions live, attributed to `ai:<model>` |
|
|
54
|
+
| Comments and suggestions from the terminal | `mddocs comment ...`, `mddocs suggest ...`, `mddocs accept`/`reject` |
|
|
55
|
+
| History and diff | `mddocs log <file>`, `mddocs diff <file> [rev]` (plain git underneath) |
|
|
56
|
+
| Async multiplayer and conflict resolution | edit on branches; `mddocs resolve <file>` unions a conflicted PROOF footer |
|
|
57
|
+
| Authorship and provenance | every mark records `by` (`human:<user>` or `ai:<model>`) and `at` |
|
|
58
|
+
| Re-anchoring | marks re-attach to their quoted text after external edits; unmatched marks are flagged orphaned, never dropped |
|
|
59
|
+
|
|
60
|
+
## Requirements
|
|
61
|
+
|
|
62
|
+
- Node 20+ (developed on v24)
|
|
63
|
+
- git on your PATH (for history and multiplayer)
|
|
64
|
+
|
|
65
|
+
## Install from source
|
|
66
|
+
|
|
67
|
+
For development, or to run the latest from the repo:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
git clone https://github.com/devYRPauli/mddocs.git
|
|
71
|
+
cd mddocs
|
|
72
|
+
npm install
|
|
73
|
+
npm run build # builds the browser editor bundle into dist/ (needed for open/serve)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`npm run build` only needs to be re-run if you change the editor or `@proof/*`
|
|
77
|
+
sources. The CLI itself runs straight from source via `tsx`.
|
|
78
|
+
|
|
79
|
+
Until the package is published, run the CLI through `tsx`:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
alias mddocs='npx tsx "$(pwd)/packages/mddocs-cli/src/bin.ts"'
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The examples below use `mddocs` as if it were installed on your PATH.
|
|
86
|
+
|
|
87
|
+
## Quickstart
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# In a git repo holding your markdown:
|
|
91
|
+
git init # if it isn't one already
|
|
92
|
+
mddocs init # mark .md files as mddocs-managed (.gitattributes)
|
|
93
|
+
|
|
94
|
+
# Single-user editing in the browser (comments/suggestions persist to the file):
|
|
95
|
+
mddocs open notes.md
|
|
96
|
+
|
|
97
|
+
# A live multiplayer session you can share on your LAN:
|
|
98
|
+
mddocs serve notes.md # prints role links and an agent API block; Ctrl-C to stop
|
|
99
|
+
|
|
100
|
+
# Or collaborate straight from the terminal:
|
|
101
|
+
mddocs comment add notes.md --quote "the API is fast" --text "cite a benchmark?"
|
|
102
|
+
mddocs suggest notes.md --quote "teh" --replace "the"
|
|
103
|
+
mddocs accept <suggestion-id> --file notes.md
|
|
104
|
+
|
|
105
|
+
# History is just git:
|
|
106
|
+
mddocs log notes.md
|
|
107
|
+
mddocs diff notes.md
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Real-time multiplayer and sharing: `mddocs serve`
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
mddocs serve notes.md [--port <n>] [--host <ip>] [--no-autocommit]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Hosts a live editing session on one port: the browser editor, a Yjs/WebSocket
|
|
117
|
+
collaboration channel, and the agent API. Everyone who opens the URL co-edits the
|
|
118
|
+
same document in real time; every settled change is serialized back to `notes.md`
|
|
119
|
+
and auto-committed to git. Use `--host 0.0.0.0` to share on your LAN.
|
|
120
|
+
|
|
121
|
+
`serve` prints three role links. Share the one matching the access you want to
|
|
122
|
+
grant:
|
|
123
|
+
|
|
124
|
+
| Link | Role | Can do |
|
|
125
|
+
|---|---|---|
|
|
126
|
+
| edit (you) | editor | read, comment, edit |
|
|
127
|
+
| comment link | commenter | read, comment |
|
|
128
|
+
| view link | viewer | read only |
|
|
129
|
+
|
|
130
|
+
- An absent or unknown token gets the least privilege (viewer), so a leaked bare
|
|
131
|
+
URL cannot edit.
|
|
132
|
+
- Viewers are enforced server-side: a viewer's WebSocket connection is read-only,
|
|
133
|
+
so a crafted client still cannot write. The commenter-vs-editor split is gated
|
|
134
|
+
in the editor UI (a comment is itself a write).
|
|
135
|
+
|
|
136
|
+
## Agent HTTP API
|
|
137
|
+
|
|
138
|
+
A live `serve` session also exposes an HTTP API so AI agents can read the
|
|
139
|
+
document and post comments/suggestions. They appear in every connected editor in
|
|
140
|
+
real time and persist to git, attributed to `ai:<model>`. `serve` prints the base
|
|
141
|
+
URL and an agent token; send it as the `x-share-token` header.
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
GET /api/agent/:slug/state -> { content, marks }
|
|
145
|
+
POST /api/agent/:slug/comment { quote, text, model? } -> { id }
|
|
146
|
+
POST /api/agent/:slug/suggest { quote, replace|insert|delete, model? } -> { id, kind }
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Read the live document:
|
|
151
|
+
curl -H "x-share-token: $TOKEN" http://127.0.0.1:<port>/api/agent/notes.md/state
|
|
152
|
+
|
|
153
|
+
# Post a comment as an agent:
|
|
154
|
+
curl -X POST -H "x-share-token: $TOKEN" -H 'content-type: application/json' \
|
|
155
|
+
-d '{"quote":"The latency is acceptable.","text":"Quantify, p50 or p99?","model":"claude-opus-4-8"}' \
|
|
156
|
+
http://127.0.0.1:<port>/api/agent/notes.md/comment
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
See [`examples/agent-reviewer.mjs`](examples/agent-reviewer.mjs) for a runnable
|
|
160
|
+
reviewer agent and a human-plus-agent walkthrough.
|
|
161
|
+
|
|
162
|
+
## Resolving merge conflicts: `mddocs resolve`
|
|
163
|
+
|
|
164
|
+
When two people edit a document on different branches and you `git merge`, the
|
|
165
|
+
prose merges normally but the `<!-- PROOF -->` footer can conflict. Union both
|
|
166
|
+
sides' marks:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
git merge other-branch # may leave a conflicted footer
|
|
170
|
+
mddocs resolve notes.md # unions both sides' marks; on id collision, latest `at` wins
|
|
171
|
+
git add notes.md && git commit
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Command reference
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
mddocs open <file> [--port <n>] [--no-autocommit] single-user browser editor (loopback)
|
|
178
|
+
mddocs serve <file> [--port <n>] [--host <ip>] [--no-autocommit]
|
|
179
|
+
live multiplayer, role links, agent API
|
|
180
|
+
mddocs init mark the repo as mddocs-managed
|
|
181
|
+
mddocs resolve <file> union a git-conflicted PROOF footer
|
|
182
|
+
|
|
183
|
+
mddocs comment add <file> --quote <q> --text <t> add a comment anchored to <q>
|
|
184
|
+
mddocs comment ls <file> [--open|--resolved|--orphaned]
|
|
185
|
+
mddocs comment reply <id> --text <t> --file <f> reply in a comment thread
|
|
186
|
+
mddocs comment resolve <id> --file <f> resolve a comment thread
|
|
187
|
+
|
|
188
|
+
mddocs suggest <file> --quote <q> (--replace <c> | --insert <c> | --delete)
|
|
189
|
+
mddocs accept <id> --file <f> mark a suggestion accepted
|
|
190
|
+
mddocs reject <id> --file <f> mark a suggestion rejected
|
|
191
|
+
|
|
192
|
+
mddocs log <file> commit history for a document
|
|
193
|
+
mddocs diff <file> [rev] changes vs working tree or a revision
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Notes. Id-only commands (`reply`, `resolve`, `accept`, `reject`) take an explicit
|
|
197
|
+
`--file`; a global mark-to-file index is a later milestone. `accept` and `reject`
|
|
198
|
+
record the decision on the mark (`status`); the prose rewrite for an accepted
|
|
199
|
+
suggestion is applied in the editor.
|
|
200
|
+
|
|
201
|
+
## Architecture
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
mddocs/ (fork of the proof-sdk monorepo)
|
|
205
|
+
packages/doc-core @proof/core reused marks model, embed/extract, anchoring
|
|
206
|
+
packages/doc-editor @proof/editor reused browser editor (served from dist/)
|
|
207
|
+
packages/mddocs-local mddocs-local new engine
|
|
208
|
+
doc.ts loadDoc / saveDoc (atomic, embed/extract)
|
|
209
|
+
reanchor.ts re-resolve marks against current text
|
|
210
|
+
footer.ts detect and union-resolve a conflicted PROOF footer
|
|
211
|
+
git.ts history / diff / commit (simple-git)
|
|
212
|
+
serve.ts single-user editor host (HTTP file API)
|
|
213
|
+
collab.ts file-backed Hocuspocus server (live relay)
|
|
214
|
+
serialize.ts prosemirror-fragment to/from markdown (headless Milkdown boundary)
|
|
215
|
+
share.ts multiplayer host: role links, bootstrap, WS, agent routes
|
|
216
|
+
agent.ts agent operations over a live Hocuspocus DirectConnection
|
|
217
|
+
packages/mddocs-cli mddocs-cli new commander CLI over the engine
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Live multiplayer reuses upstream's Yjs and Hocuspocus stack as an in-memory
|
|
221
|
+
concurrency layer only; the resolved markdown and marks are persisted through the
|
|
222
|
+
same engine path as the CLI (`saveDoc`, reanchor, debounced git commit). The
|
|
223
|
+
editor's canonical content is the `prosemirror` Y.XmlFragment, which `serialize.ts`
|
|
224
|
+
converts to and from markdown using upstream's headless Milkdown serializer.
|
|
225
|
+
Every call into `@proof/core` goes through one adapter
|
|
226
|
+
(`packages/mddocs-local/src/proof.ts`).
|
|
227
|
+
|
|
228
|
+
### How data is stored
|
|
229
|
+
|
|
230
|
+
A managed document is just Markdown with a trailing footer:
|
|
231
|
+
|
|
232
|
+
```markdown
|
|
233
|
+
# My document
|
|
234
|
+
|
|
235
|
+
The body everyone reads and diffs normally.
|
|
236
|
+
|
|
237
|
+
<!-- PROOF
|
|
238
|
+
{"version":2,"marks":{"<id>":{"kind":"comment","by":"human:alice","at":"...","quote":"...","data":{"text":"...","resolved":false}}}}
|
|
239
|
+
-->
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
`loadDoc`/`saveDoc` split and rejoin this footer; the prose above it stays clean,
|
|
243
|
+
diffable text.
|
|
244
|
+
|
|
245
|
+
## Development
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
npm test -w mddocs-local # engine unit and integration tests (incl. headless collab/agent)
|
|
249
|
+
npm test -w mddocs-cli # CLI integration tests against real temp git repos
|
|
250
|
+
npm run typecheck -w mddocs-local
|
|
251
|
+
npm run typecheck -w mddocs-cli
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
The live collaboration and agent paths are covered headlessly (real
|
|
255
|
+
`HocuspocusProvider` clients driven in-process, no browser needed); the
|
|
256
|
+
browser-interactive path is verified manually.
|
|
257
|
+
|
|
258
|
+
## Roadmap
|
|
259
|
+
|
|
260
|
+
- M1: local-first editor and CLI (comments, suggestions, provenance, git history). Done.
|
|
261
|
+
- M2: live collaboration server (real-time multiplayer, file plus git canonical). Done.
|
|
262
|
+
- M2.5: share links and roles (editor/commenter/viewer, server-side viewer enforcement). Done.
|
|
263
|
+
- M3: agent HTTP API (read state, post comments/suggestions live). Done.
|
|
264
|
+
|
|
265
|
+
## Upcoming updates
|
|
266
|
+
|
|
267
|
+
Contributions welcome. Next on the list:
|
|
268
|
+
|
|
269
|
+
- Agent direct-rewrite endpoint: let agents edit prose directly, not just propose
|
|
270
|
+
(v1 is propose-only; humans accept).
|
|
271
|
+
- Per-agent identity tokens and rate limiting, instead of one shared agent token.
|
|
272
|
+
- Commenter-granularity enforcement: viewers are enforced server-side; enforce the
|
|
273
|
+
comment-vs-edit split on the wire too.
|
|
274
|
+
- CLI `accept` applies the prose rewrite (today it records the decision; applying
|
|
275
|
+
the edit to the body is editor-only).
|
|
276
|
+
- Global mark-to-file index, so id-only commands no longer need an explicit `--file`.
|
|
277
|
+
- Presence and events for agents.
|
|
278
|
+
- Publish as an installable `mddocs` binary on npm, with a real project name.
|
|
279
|
+
- CI to run both test suites on every push.
|
|
280
|
+
- Upstream the `@proof/core` TS2308 fix
|
|
281
|
+
([proof-sdk#57](https://github.com/EveryInc/proof-sdk/pull/57)) and drop the
|
|
282
|
+
local fork patch once merged.
|
|
283
|
+
|
|
284
|
+
## Attribution and license
|
|
285
|
+
|
|
286
|
+
Built on [`proof-sdk`](https://github.com/EveryInc/proof-sdk) (MIT, Every Inc).
|
|
287
|
+
The `packages/doc-*`, `src/`, and `server/` trees originate from proof-sdk and
|
|
288
|
+
retain its license; see [`LICENSE`](LICENSE), [`NOTICE.md`](NOTICE.md), and
|
|
289
|
+
[`TRADEMARKS.md`](TRADEMARKS.md). The original upstream README is preserved as
|
|
290
|
+
[`README.proof-sdk.md`](README.proof-sdk.md). "Proof" is a trademark of Every
|
|
291
|
+
Inc.; this project is not affiliated with or endorsed by them.
|
|
292
|
+
|
|
293
|
+
Local modifications to the vendored SDK are tracked in
|
|
294
|
+
[`FORK_PATCHES.md`](FORK_PATCHES.md).
|
package/bin.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Entry point for the published package. Points the editor host at the bundled
|
|
3
|
+
// dist/ (via MDDOCS_DIST) before loading the CLI, then runs it.
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
5
|
+
import { dirname, join } from 'node:path'
|
|
6
|
+
|
|
7
|
+
const here = dirname(fileURLToPath(import.meta.url))
|
|
8
|
+
process.env.MDDOCS_DIST ||= join(here, 'dist')
|
|
9
|
+
|
|
10
|
+
await import('./cli.mjs')
|