The `opencode-local` package provides a Node.js interface for programmatic access to local Opencode project data. It allows developers to read information directly from the local Opencode SQLite database, bypassing the need to shell out to `opencode db` for each query. Additionally, it supports querying a running Opencode server for project lists, offering flexibility to retrieve data from either the local database or a live instance. The current stable version is 1.3.11, and while a specific release cadence isn't documented, its versioning suggests ongoing maintenance. A key differentiator is its dual capability to interface with both the local SQLite file and a remote Opencode server's API, along with dedicated utilities for exporting project data to JSON, making it a powerful tool for integrating Opencode project insights into developer workflows or custom tooling. It requires Node.js >=22.5.0 and an existing local Opencode installation.
Verified import paths — ran on the pinned version, not inferred.
Package primarily uses ES modules syntax. CommonJS `require` will not work directly for named exports in many environments.
This utility is accessed via a subpath import for modularity, not directly from the main package entry.
This is a TypeScript type definition. Using `import type` is recommended to prevent runtime issues and ensure type-only imports are handled correctly by bundlers.
This example demonstrates how to initialize the client, list projects from the local Opencode database, and then fetch sessions for a subset of those projects, logging the first results.
Breaking-change detection hasn't run for this library yet.
CVE tracking and dependency tree are planned for a later release.