Skip to content
Docsv0.7.2

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()
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().

There are three ways to get a project:

// By identifier — id:…, local:…, github:…, or a path
const project = await denvig.projects.retrieve('github:marcqualie/denvig')
// Every project discovered under your configured project paths
const all = await denvig.projects.list({ withConfig: true })
// Detect the active project from cwd, returning nulls instead of throwing
const { project, slug } = await denvig.projects.detect()

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()
const service = await project.services.retrieve('api')
const status = await service.start({ port: 'random' })
console.log(status)
await service.stop()
// The version denvig was compiled with
denvig.version()
// Global configuration, with the source files it was loaded from
const config = await denvig.config.retrieve()
// Gateway state
const gateway = await denvig.gateway.status()
// Certificates
const certs = await denvig.certs.list()