feat: add Yjs-based rich markdown file type to yjsfs - #19
Open
K-Mistele wants to merge 18 commits into
Open
Conversation
Adds a new package for rich markdown artifacts using TipTap/Yjs: - `packages/yjs-rich-markdown`: Core library with artifact store, path-keyed registry, and TipTap collaboration bindings - `examples/yjs-rich-markdown-demo`: TanStack Router demo app for testing collaboration, presence, and content isolation Learning tests confirm: - Multiple TipTap fragments in one Y.Doc remain isolated - One Durable Streams connection syncs all artifacts - Cursor presence is natively scoped per fragment (no adapter needed) - Both `fragment` and `field` binding modes work Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description
Ticket | Artifacts | Task
What problems was I solving
This PR enables AI agents to collaboratively edit rich markdown documents using TipTap/Yjs. Previously, agents could only work with plain text files via string-based edits. Now agents can:
Success is measured by: agents successfully editing rich artifacts without corrupting document structure, and multiple TipTap editors syncing correctly via one Yjs document.
What user-facing changes did I ship
bun run --cwd packages/yjs-rich-markdown agent)How I implemented it
Core Package:
packages/yjs-rich-markdownY.Map<ArtifactMetadata>in oneY.DocYXmlProxyBindingsproviding a DSL for agents to navigate and mutate YXml trees (root, children, get, append, prepend, insertBefore, insertAfter, insertText, deleteText, splitText, wrapTextRange, wrap, remove, setAttribute, etc.)YXML_PROXY_AGENT_PROMPTwith console.log diagnostic guidance and the full bindings DSL contractMarkdownManagerforreadArtifactMarkdown/writeArtifactMarkdownfragmentandfieldmodesAgent Tools
EditToolinterface implementation delegating to apply sub-agentCLI Agent
list_artifacts,read_artifact,write_artifact,edit, andinspect_artifacttools, connects to Durable Streams, supports--interactive,--prompt,--verbose,--streamflagsQuickJS Sandbox:
packages/quickjs-execQuickJsSyncExecandQuickJsAsyncExecwithrunWithConsoleAPI, structured error capture viaQuickJsExecutionErrorwith code frame renderingDemo App:
examples/yjs-rich-markdown-demo/,/single,/compare,/same-doc,/awarenessserver/index.tsDeviations from the plan
Implemented as planned
runWithConsolewithglobalThis.__quickjsConsoleLogspatternYXmlProxyBindingsfull binding set matching the DSL specificationYXML_PROXY_AGENT_PROMPTwith diagnostic guidanceRichMarkdownArtifactStorepath-keyed registryMarkdownManageryjs-fskept unaware of rich artifacts per design decisionDeviations/surprises
QuickJsRunWithConsoleResultis a discriminated union: Plan specified{ value, console }but implementation uses{ ok: true, value, console } | { ok: false, error, console }- an improvement that bakes in structured error capture{ ok: false, error, console }instead of thrown exceptionsQuickJsExecutionErrorwith code frame added: Not in plan; adds source code context rendering for debugging generated code failures@tiptap/markdownsupport@tiptap/extension-collaboration-caret: The TipTap v3 rename of@tiptap/extension-collaboration-cursorAdditions not in plan
QuickJsExecutionErrorclass withcodeFramesource context renderingreadArtifactfor raw XML output (supportsinspect_artifacttool)test/yxml-proxy-prompt-examples.test.ts- validates prompt examples are executabletest/yxml-invalid-structures.test.ts- documents lossy Markdown serializationdoneandi_am_stucktools in apply sub-agentawaitSubAgentintegration for streaming sub-agent outputItems planned but not implemented
/commentsdemo route - not createdawareness-scope.test.ts,durable-streams-sync.test.ts- test files not created (functionality verified via demo app)How to verify it
Manual Testing
CLI Agent Testing
list_artifactsto see artifactsread_artifactto read contenteditto make semantic editsAutomated Tests
bun run typecheck bun run testDescription for the changelog
Add Yjs-based rich markdown file type with TipTap collaboration, sandboxed QuickJS agent editing via YXml proxy bindings, and CLI agent for rich artifact management.