Getting Started
The SDK is resource-oriented: you create a client, resolve a project, then chain into its worktrees, actions, services, dependencies, and config. Global concerns — certificates and the global config — hang directly off the client.
import { DenvigSDK } from '@denvig/sdk'
const denvig = new DenvigSDK({ client: 'my-app' })
const project = await denvig.projects.retrieve('local:/path/to/project')const service = await project.services.retrieve('api')await service.start()Creating a client
Section titled “Creating a client”import { DenvigSDK } from '@denvig/sdk'
const denvig = new DenvigSDK({ client: 'my-app', // required — attributes SDK calls in the usage log cwd: process.cwd(), // optional — used to detect the active project})| Option | Description |
|---|---|
client |
Required. Identifier for your integration (e.g. raycast, my-app). Logged as via: sdk:<client>. |
cwd |
Working directory used to detect the project when none is given explicitly. Defaults to process.cwd(). |
Resolving a project
Section titled “Resolving a project”There are three ways to get a project:
// By identifier — id:…, local:…, github:…, or a pathconst project = await denvig.projects.retrieve('github:marcqualie/denvig')
// Every project discovered under your configured project pathsconst all = await denvig.projects.list({ withConfig: true })
// Detect the active project from cwd, returning nulls instead of throwingconst { project, slug } = await denvig.projects.detect()Running an action
Section titled “Running an action”Actions stream their output to the parent process, exactly as the CLI does:
const action = await project.actions.retrieve('build')console.log(action.commands) // the resolved shell command(s)
const { success } = await action.run()Managing a service
Section titled “Managing a service”const service = await project.services.retrieve('api')
const status = await service.start({ port: 'random' })console.log(status)
await service.stop()Global operations
Section titled “Global operations”// The version denvig was compiled withdenvig.version()
// Global configuration, with the source files it was loaded fromconst config = await denvig.config.retrieve()
// Gateway stateconst gateway = await denvig.gateway.status()
// Certificatesconst certs = await denvig.certs.list()Where to go next
Section titled “Where to go next”- Projects & Worktrees — the core resource model.
- Services — start, stop, and inspect services.
- Gateway — drive the reverse proxy programmatically.
- Certificates and Dependencies.
- Error Handling — the SDK’s error types.