A Rust daemon that enables local editor access to Google Docs with real-time sync and conflict resolution.
- OAuth2 authentication with PKCE
- Real-time document synchronization
- UTF-8/UTF-16 index mapping for Google Docs compatibility
- JSON-RPC API for editor integration
- Export formats: .docx, .pdf, .md, .txt
- Explicit conflict resolution with merge markers
- Change detection via polling
┌─────────────────┐ JSON-RPC ┌─────────────────┐ OAuth2/HTTPS ┌─────────────────┐
│ VS Code │ ◄────────────► │ Cedar Daemon │ ◄─────────────────► │ Google APIs │
│ Neovim │ │ │ │ • Docs API │
│ Emacs │ │ • Auth Manager │ │ • Drive API │
│ Any Editor │ │ • Diff Engine │ │ │
└─────────────────┘ │ • Sync Engine │ └─────────────────┘
│ • RPC Server │
└─────────────────┘
Prerequisites: Rust, Google Cloud Project with Docs/Drive APIs enabled, OAuth2 desktop credentials
- Build:
cargo build --release
- Google Cloud Setup:
- Enable Google Docs API and Google Drive API
- Create OAuth2 credentials (Desktop Application)
- Set redirect URI:
http://127.0.0.1:8080
- Configure
~/.config/cedar/config.toml
:[google] client_id = "your-client-id.googleusercontent.com" client_secret = "your-client-secret" redirect_uri = "http://127.0.0.1:8080" scopes = ["https://www.googleapis.com/auth/documents", "https://www.googleapis.com/auth/drive.readonly"] [server] host = "127.0.0.1" port = 3030
- Run:
./target/release/cedar
JSON-RPC 2.0 server at http://127.0.0.1:3030
Core Methods:
authenticate
- Start OAuth2 flowopen_document(document_id, suggestions_mode)
- Open doc for editingsync_document(document_id, content, revision_id)
- Sync local changesexport_document(document_id, format)
- Export to .docx/.pdf/.md/.txt
// VS Code/TypeScript
async function openDoc(docId: string) {
return fetch('http://127.0.0.1:3030', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
jsonrpc: '2.0', method: 'open_document',
params: {document_id: docId}, id: 1
})
}).then(r => r.json());
}
Environment Variables:
CEDAR_CONFIG_PATH
- Custom config locationCEDAR_LOG_LEVEL
- Log verbosityCEDAR_BIND_HOST/PORT
- Server overrides
Suggestion Modes: inline
(default), accepted
, rejected
- Local-first: no server storage
- OAuth2 + PKCE authentication
- Minimal API permissions
- Encrypted token storage
- HTTPS enforcement
<<<<<<< LOCAL
Your local changes
=======
Remote changes from Google Docs
>>>>>>> REMOTE
# Test
cargo test
cargo test --test integration
cargo test --features proptest
# Quality
cargo clippy -- -D warnings
cargo fmt
Structure: src/{main,auth,config,docs,drive,diff,rpc,errors}.rs
- Tables/images become placeholders
- Some rich formatting lost in conversion
- No real-time cursors (polling-based sync)
- Limited programmatic suggestion handling
- Webhook push notifications
- Offline document caching
- Comment integration
- Version history access
MIT - see LICENSE