IDE integration (VSCode + Zed + JetBrains)
develop specs/develop/ide-integration.kmd
Contract for in-IDE Koder Design support — spec preview on hover, token autocomplete, drift detection lint, and live theme preview inside the editor. Materializes ticket #021 as a normative spec plus follow-up impl tickets per IDE (VSCode, Zed, JetBrains future).
Quando esta spec se aplica
Triggers primários
- Implement IDE extension for Koder Design
Todos os triggers
- Ship Koder Design IDE support
- Add token autocomplete to a code editor
- Spec-preview-on-hover in Flutter / web source
Corpo da especificação
Spec — IDE integration
Facet Develop of Koder Design. Cross-link with
tools/design-kit-export.kmd.
Source ticket: meta/docs/stack#021. Spec stays here; impl
distributed across IDE-specific tickets in projects/koder-stack/.
Target IDEs
| IDE | Status | Distribution |
|---|---|---|
| VSCode | Tier 1 | VS Marketplace + Open VSX |
| Zed | Tier 1 | Zed Extensions registry |
| JetBrains (IntelliJ / Android Studio / Rider) | Tier 2 (future) | JetBrains Marketplace |
| Cursor / Windsurf / others using VSCode API | Tier 1 (free via VSIX) | Inherits VSCode extension |
| Vim / Neovim | Tier 3 | LSP client; depends on Koder LSP shared module |
Shared LSP server
Single LSP server (koder-design-lsp) powers all IDEs that speak LSP.
Implements:
textDocument/hover— spec previewtextDocument/completion— token autocompletetextDocument/codeAction— quick fixes (replace hardcoded color with token)textDocument/publishDiagnostics— drift detection warnings
LSP lives at engines/sdk/koder-design-lsp/ (new repo / module);
written in Go for distribution as a single binary.
Per-IDE extensions are thin wrappers: they install the LSP binary, spawn it as a subprocess, and forward requests.
R1 — Spec preview on hover
When user hovers over a Koder widget reference in source code:
KoderTitleBar( // hover here
...
)
LSP returns Hover content:
KoderTitleBar — Custom title bar for desktop variants
─────────────────────────────────────────────────────
Spec: specs/desktop-apps/title-bar-double-click.kmd
Drag in non-interactive area moves window; double-tap
toggles maximize. Uses `koder_kit` v0.16.0+.
[Open spec on kds.koder.dev ↗]
Hover contents include:
- Component name + 1-sentence summary
- Spec file path
- 1 paragraph of R1 (the canonical rule)
- Link to live spec page on kds.koder.dev
Recognition:
- Symbols matching
Koder<Name>fromkoder_kit/koder_web_kitimports - Token references like
KoderTokens.surfacePrimary - HTML custom elements
<koder-*>in web sources
R2 — Token autocomplete
When user types in a context expecting a color value:
| Source language | Trigger | Suggestion |
|---|---|---|
| Dart | Color(0xFF | List of KoderTokens.* color tokens |
| Dart | color: | Same |
| TS / JS | color: '# | List of CSS variables var(--kds-color-*) |
| CSS | color: # | Same |
| Kotlin (Compose) | Color(0xFF | List of LocalKoderTokens.current.* |
| Swift (SwiftUI) | Color(red: | List of KoderColors.* |
Suggestion includes:
- Token name
- Hex preview swatch in completion popup
- Light + dark hex side-by-side
- Light + dark contrast against current surface (info)
R3 — Drift detection
When source contains a hardcoded color that does NOT match any token:
Container(
color: Color(0xFF1976D2), // ← yellow underline
)
Diagnostic:
Koder Design drift: hardcoded color #1976D2 has no matching token.
- Closest token: KoderTokens.surfacePrimary (#1976D2 in material3 light)
- Quick fix: replace with KoderTokens.surfacePrimary
Severity: warning by default; configurable via workspace settings.
Detection scope:
- Files declaring
koder_kit/koder_web_kit/koder-designimports → drift detection active - Other files → off (don't false-positive non-Koder code)
R4 — Quick fixes
Code actions provided:
- Replace hardcoded color with token — replaces with closest
matching
KoderTokens.* - Open spec — opens the matching component spec in browser
- Insert Koder import — when a
Koder*widget is used but the import is missing
R5 — Live theme preview
(Advanced feature; ships in v2.)
When the workspace contains a Koder app, the extension renders a preview pane showing how the current source renders under the selected preset.
- Powered by the same WASM module used by
tools/theme-builder.kmd - Updates live as code changes
- Preset switcher in pane header
R6 — Configuration
Workspace settings (.vscode/settings.json /
.zed/settings.json):
{
"koder.design.preset": "material3",
"koder.design.driftDetection": "warning",
"koder.design.driftSensitivity": 10,
"koder.design.hoverPreview": true,
"koder.design.tokensVersion": "auto"
}
| Setting | Default | Effect |
|---|---|---|
preset | material3 | Preset for hover preview + token autocomplete swatches |
driftDetection | warning | off / info / warning / error |
driftSensitivity | 10 | Color distance (ΔE) threshold |
hoverPreview | true | Show spec preview popups |
tokensVersion | auto | Use latest published or pin version |
R7 — Distribution
| IDE | Extension repo | Maintenance |
|---|---|---|
| VSCode | engines/sdk/koder-design-vscode/ | Owner-maintained |
| Zed | engines/sdk/koder-design-zed/ | Owner-maintained |
| Shared LSP | engines/sdk/koder-design-lsp/ | Single binary; reused across IDEs |
Extension auto-update from the marketplace; LSP binary downloaded
on first activation per koder.design.tokensVersion.
R8 — Telemetry
Per errors/reporting.kmd and policies/identity-data-retention.kmd
contracts:
- Default: OFF
- Opt-in toggle in extension settings
- Reports: extension activation count, drift detection hit count, token autocomplete acceptance rate
- No file contents, no code, no PII — only counts + extension version
R9 — Accessibility
- Hover panels: keyboard-accessible (Ctrl+K hover, Escape closes)
- Diagnostics: screen reader announces drift warnings
- Spec links: have full accessible names (not just "Open ↗")
- Token swatches: include hex text label (not color-only)
R10 — Versioning
LSP + extensions follow Koder Design semver:
koder-design-lsp v1.x.0matcheskoder-design v1.x.0token schema- Extensions can run with LSP one minor version newer / older
- Major LSP bump = extension hard-requires matching major
R11 — Forbidden patterns
- ❌ Sending source code to a remote server (drift + hover MUST run locally via LSP)
- ❌ Auto-applying quick fixes without user action (always user-driven)
- ❌ Diagnostics with severity
errorby default (yellow / warning is correct level for drift) - ❌ Hardcoded token list in extension (always pulled from
@koder/design-tokenspackage) - ❌ Telemetry that ships file content / paths / identifiers
Cross-link
tools/design-kit-export.kmd— token source (extension consumes@koder/design-tokens)develop/code-samples-toggle.kmd— analogous cross-cutting devexpthemes/color-roles.kmd— token schema for autocompleteerrors/reporting.kmd— telemetry contract
Implementation tracking
Per-IDE impl tickets (in projects/koder-stack/):
#132— VSCode extension (Koder Design preview + spec browser)#133— Zed extension#134— Drift detection lint rule (LSP capability)#135— Token autocomplete LSP capability#136— JetBrains plugin (Tier 2, future)- Shared LSP server lives at
engines/sdk/koder-design-lsp/
Ticket meta/docs/stack#021 closed as consolidated-into-this-spec
plus the per-IDE tickets above.
Referências
specs/themes/color-roles.kmdspecs/tools/design-kit-export.kmdspecs/tools/theme-builder.kmdspecs/develop/code-samples-toggle.kmd