Skip to content

Add packages/core: thin SDK wrapper#7

Open
Aleexc12 wants to merge 4 commits intomainfrom
feat/packages-core
Open

Add packages/core: thin SDK wrapper#7
Aleexc12 wants to merge 4 commits intomainfrom
feat/packages-core

Conversation

@Aleexc12
Copy link
Collaborator

@Aleexc12 Aleexc12 commented Feb 25, 2026

Issue for this PR

Closes N/A — foundational package, no prior issue.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds packages/core — a minimal wrapper around the OpenCode SDK that spawns and manages the server as a child process, exposing the raw SDK client for consumers.

3 files, ~100 lines total:

  • RalphCore.create() — spawns the opencode server, returns a ready-to-use instance
  • core.client — raw OpencodeClient from @opencode-ai/sdk, no abstraction layer
  • core.dispose() — shuts down the managed server process

Architecture decisions

  • Wrap, don't run alongside — Ralph spawns and manages the OpenCode server as a child process. One process to start, one API to consume.
  • Thin wrapper, no indirection — The original version had 15 service classes wrapping 57 endpoints with Hono HTTP routes. That was unnecessary — the SDK client already provides a clean, typed API. Core's job is lifecycle management (spawn, connect, dispose), not re-wrapping every endpoint.
  • Raw SDK client — Consumers (TUI, future CLI) import @ralph/core, call RalphCore.create(), and use core.client directly with the SDK's native interface. No custom error types, no service layer, no HTTP routes.

How did you verify your code works?

  • 24 endpoint tests covering session CRUD, prompting (big-pickle), project/config/providers, files/search, app metadata (agents/skills/commands), path, VCS, and cleanup
  • All 24 passing on both Windows (MSYS) and Linux (WSL2)
  • Known upstream issue: dispose() doesn't reliably kill the server on Windows (proc.kill() / SIGTERM). Works correctly on Linux.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@Aleexc12 Aleexc12 changed the title Add packages/core: OpenCode SDK wrapper (15 services, 57 endpoints) Add packages/core: thin SDK wrapper Mar 1, 2026
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