Skip to content

CodeEditorLand/Cocoon

Cocoon

🦋

+

🏞️


Cocoon 🦋

VS Code's extension host is a single Node.js event loop. One hung Promise blocks every other extension. There is no way to cancel an in-flight operation, no back-pressure, no preemption.

"Every extension runs in its own supervised fiber. One crash doesn't take down the rest."

License: CC0-1.0 NPM Version Node.js Version Effect Version

Cocoon intercepts require/import at the Node.js module level and routes all VS Code API calls through Effect-TS fibers. Extensions call vscode.workspace.openTextDocument() and get back a Thenable<TextDocument> exactly as documented. Internally, each call is a typed Effect that can be interrupted, raced with a timeout, and run concurrently. 50+ extensions activate in parallel. Language server crashes are handled in supervised scopes with automatic restart. The full VS Code marketplace works without modification.


What It Does 🔐

  • Every VS Code extension runs unchanged. The API contract is preserved in full. Nothing needs to be ported.
  • Supervised fiber isolation. One extension's hung Promise does not block another's fiber.
  • Automatic timeout and restart. Language server crashes are handled in supervised scopes.
  • Concurrent activation. 50+ extensions activate in parallel, not sequentially.
  • Performance tracing. Every extension operation can be traced without code changes.

In the Ecosystem 🦋 + 🏞️

graph LR
classDef mountain fill:#f9f,stroke:#333,stroke-width:2px;
classDef cocoon fill:#ccf,stroke:#333,stroke-width:2px;
classDef effectts fill:#cfc,stroke:#333,stroke-width:1px;
classDef vscode fill:#ddd,stroke:#666,stroke-width:1px,stroke-dasharray: 5 5;

subgraph "Cocoon 🦋 (Node.js SideCar)"
direction TB
Bootstrap["Bootstrap/Implementation/CocoonMain.ts"]:::effectts
AppLayer["Cocoon AppLayer"]:::effectts
EffectModules["Effect/ Modules (Bootstrap, Telemetry, Extension)"]:::effectts
PatchProcess["PatchProcess/ (Process Hardening)"]:::cocoon
APIServices["Services/ (APIFactory, ExtensionHost, Window, Workspace, etc.)"]:::cocoon
IPCService["Services/IPCService.ts + IPC/ Protocol"]:::cocoon
GRPCClient["Services/MountainGRPCClient.ts"]:::cocoon
TypeConverter["TypeConverter/ (DTO Serialization)"]:::cocoon

Bootstrap -- Builds & Runs --> AppLayer
AppLayer -- Composes --> EffectModules
AppLayer -- Composes --> APIServices
AppLayer -- Composes --> IPCService
APIServices -- Use --> GRPCClient
APIServices -- Use --> TypeConverter
GRPCClient -- Use --> IPCService
PatchProcess -- Hardens --> Bootstrap
end

subgraph "Mountain ⛰️  (Rust/Tauri Backend)"
VineGRPC["Vine gRPC Server"]:::mountain
end

subgraph "VS Code Extension"
ExtensionCode["Extension Code"]:::vscode
end

APIServices -- Provides `vscode` object to --> ExtensionCode
ExtensionCode -- Makes API calls to --> APIServices

GRPCClient -- gRPC <--> VineGRPC
Loading

Development 🛠️

Cocoon is a component of the Land workspace. Follow the Land Repository instructions to build and run.


License ⚖️

CC0 1.0 Universal. Public domain. No restrictions. LICENSE


See Also

Funding & Acknowledgements 🙏🏻

Cocoon is a core element of the Land ecosystem. This project is funded through NGI0 Commons Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet program. Learn more at the NLnet project page.

The project is operated by PlayForm, based in Sofia, Bulgaria.

PlayForm acts as the open-source steward for Code Editor Land under the NGI0 Commons Fund grant.

Land PlayForm NLnet NGI0 Commons Fund
Land PlayForm NLnet NGI0 Commons Fund

Project Maintainers: Source Open (Source/Open@Editor.Land) | GitHub Repository | Report an Issue | Security Policy

About

Cocoon 🦋 + Land 🏞️

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

 
 
 

Contributors