Skip to content

feat(utils): add MessagePack TypeScript implementation#2

Open
mkotelnikov wants to merge 1164 commits into
mainfrom
feature/msgpack-typescript
Open

feat(utils): add MessagePack TypeScript implementation#2
mkotelnikov wants to merge 1164 commits into
mainfrom
feature/msgpack-typescript

Conversation

@mkotelnikov

Copy link
Copy Markdown
Contributor

Summary

  • Add pure TypeScript implementation of the MessagePack serialization format
  • Implement Encoder and Decoder classes with support for all standard types (nil, boolean, integers, floats, strings, binary, arrays, maps)
  • Include 66 comprehensive tests covering encoding, decoding, and roundtrip scenarios

References

Test plan

  • All 66 new msgpack tests pass
  • All 965 existing utils tests still pass
  • Lint and format checks pass

🤖 Generated with Claude Code

mkotelnikov and others added 30 commits January 16, 2026 13:06
- Add vitest configuration and 46 model unit tests
- Create comprehensive ARCHITECTURE.md documentation
- Tests cover all 9 model classes with proper API usage
- Document MVC pattern, context adapter, and user actions flow

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace private method call with createEmptyStore for receiving peers
- Add ID mapping to track stored object IDs during sync
- Map remote HEAD to actual stored commit ID when setting refs
- Ensure views update after synchronization by preserving correct IDs

This fixes issues where:
- Peers without a local repo couldn't sync
- Views (Repository, Commit History, Files) didn't update after sync
- Object IDs computed by storeCommit differed from sender's IDs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add message queue to process sync messages sequentially. Previously,
when multiple messages arrived rapidly, the data event callbacks would
run concurrently, causing sync-complete to execute before all objects
were stored. This resulted in refs being set correctly but the refresh
failing to find the commits.

Now messages are queued and processed one at a time, ensuring all
objects are stored before sync-complete triggers the view refresh.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Change the share URL from a code element to a clickable link that
opens in a new window. Added link-specific styling with hover effects.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
mkotelnikov and others added 29 commits January 20, 2026 11:33
- Create new @aspect/transport-adapters package for storage and repository adapters
- Move VcsRepositoryAccess, GitNativeRepositoryAccess, and StorageAdapter
- Add ObjectGraphWalker and wire format utilities
- Remove repository-access and storage-adapters modules from transport package
- Rename transport-connection to port-transport-connection in peer module
- Add git-request-parser to transport protocol
- Update package dependencies and exports

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement MessagePort to GitBidirectionalStream bridge for P2P git
transport. This enables git protocol communication over MessageChannel,
WebRTC, WebSocket, or any MessagePortLike interface.

Features:
- createGitStreamFromPort() - Bridge MessagePortLike to GitBidirectionalStream
- createGitStreamPair() - Create connected stream pair for testing
- ACK-based backpressure via port-stream
- Error handling and propagation
- Graceful close with pending data drain

Part of Epic: webrun-vcs-hq12 (P2P Transport Bridge)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement MessagePort to GitBidirectionalStream bridge for P2P git
transport. This enables git protocol communication over MessageChannel,
WebRTC, WebSocket, or any MessagePortLike interface.

Features:
- createGitStreamFromPort() - Bridge MessagePortLike to GitBidirectionalStream
- createGitStreamPair() - Create connected stream pair for testing
- ACK-based backpressure via port-stream
- Error handling and propagation
- Graceful close with pending data drain

Part of Epic: webrun-vcs-hq12 (P2P Transport Bridge)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement client-side P2P git protocol operations:
- fetchFromPeer() - Fetch objects from peer via git-upload-pack
- pushToPeer() - Push objects to peer via git-receive-pack
- Capability negotiation helpers
- Progress callback support

These functions use ClientProtocolSession to drive the git protocol
over MessagePortLike connections for P2P communication.

Part of Epic: webrun-vcs-4hsj (P2P Client Functions)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
End-to-end integration tests for P2P git transport:
- Full fetch cycle with upload-pack handler
- Empty repository handling
- Up-to-date detection
- Pack data reception
- Push to empty repository
- Multiple ref updates
- Progress callbacks
- Large number of refs
- Special characters in ref names

Part of Epic: webrun-vcs-lprt (P2P Integration Tests)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement two-way synchronization between P2P peers:
- planBidirectionalSync() - Plan sync actions for refs
- planSync() - Shorthand for planning
- executeSyncPlan() - Execute planned sync operations
- Conflict detection for divergent histories
- Ancestry-based merge direction detection
- Exclusion pattern support
- Configurable conflict resolution (prefer-local/remote)

Part of Epic: webrun-vcs-2x6l (Bidirectional Sync)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements complete P2P Git transport over MessagePort:

- Epic 1: P2P Transport Bridge
  - createGitStreamFromPort() bridges MessagePortLike to GitBidirectionalStream
  - createGitStreamPair() for testing
  - AsyncQueue for push-based to pull-based bridging

- Epic 2: P2P Client Functions
  - fetchFromPeer() implements git-upload-pack client
  - pushToPeer() implements git-receive-pack client
  - Capability negotiation and sideband support

- Epic 3: P2P Integration Tests
  - End-to-end tests over MessageChannel
  - Mock repository implementation

- Epic 4: Bidirectional Sync
  - planBidirectionalSync() for two-way sync planning
  - Conflict detection with ancestry checking
  - Configurable conflict resolution strategies

- Epic 5: Error Recovery
  - PortDisconnectedError, PortTimeoutError, TransferAbortedError
  - withTimeout() and createIdleTimeout() utilities
  - createDisconnectMonitor() for disconnect detection
  - createTransferTracker() for partial transfer state
  - withRetry() with exponential backoff
  - wrapP2POperation() combining all error recovery features

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Restores P2P Git transport implementation that was accidentally removed.

P2P Transport Features:
- createGitStreamFromPort() bridges MessagePortLike to GitStream
- fetchFromPeer() and pushToPeer() client operations
- planBidirectionalSync() for two-way sync with conflict detection
- Error recovery: timeouts, disconnect handling, retry logic

Documentation:
- Updated README with P2P transport section and examples
- Added P2P-ARCHITECTURE.md with detailed architecture docs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add a pure TypeScript implementation of the MessagePack serialization format.

Features:
- Encoder: pack JavaScript values to MessagePack binary format
- Decoder: unpack MessagePack data to JavaScript values
- Supports: nil, boolean, integers, floats, strings, binary, arrays, maps
- UTF-8 string encoding/decoding
- Configurable character set for decoding (UTF-8, ASCII, byte array)

Based on:
- MessagePack specification: https://github.com/msgpack/msgpack/blob/master/spec.md
- Original JS implementation: https://github.com/cuzic/MessagePack-JS (MIT)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant