Skip to content

s4wave/ocpipe

Repository files navigation

ocpipe

Build LLM pipelines with OpenCode, Claude Code, and Zod.

Inspired by DSPy.

npm Build status


  • Type-safe Define inputs and outputs with Zod schemas
  • Modular Compose modules into complex pipelines
  • Checkpoints Resume from any step
  • Multi-backend Choose between OpenCode (75+ providers) or Claude Code SDK
  • Auto-correction Fixes schema mismatches automatically

Quick Start

bun add ocpipe
import { signature, field, module, Pipeline, createBaseState } from 'ocpipe'

const Greet = signature({
  doc: 'Generate a friendly greeting for the given name.',
  inputs: { name: field.string('The name of the person to greet') },
  outputs: { greeting: field.string('A friendly greeting message') },
})

const pipeline = new Pipeline(
  {
    name: 'hello-world',
    defaultModel: { providerID: 'opencode', modelID: 'minimax-m2.1-free' },
    defaultAgent: 'default',
  },
  createBaseState,
)

const result = await pipeline.run(module(Greet), { name: 'World' })
console.log(result.data.greeting)

// Extract types from signatures
import { InferInputs, InferOutputs } from 'ocpipe'
type GreetIn = InferInputs<typeof Greet> // { name: string }
type GreetOut = InferOutputs<typeof Greet> // { greeting: string }

Backends

ocpipe supports two backends for running LLM agents:

OpenCode (default) - Requires opencode CLI in your PATH. Supports 75+ providers.

const pipeline = new Pipeline(
  {
    name: 'my-pipeline',
    defaultModel: {
      providerID: 'anthropic',
      modelID: 'claude-sonnet-4-20250514',
    },
    defaultAgent: 'default',
  },
  createBaseState,
)

Claude Code - Uses @anthropic-ai/claude-agent-sdk. Install as a peer dependency.

// modelID: 'opus', 'sonnet', or 'haiku'
defaultModel: { backend: 'claude-code', modelID: 'sonnet' },
// permissionMode: 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan'
claudeCode: { permissionMode: 'acceptEdits' },

Requirements

For OpenCode backend: Currently requires this OpenCode fork. Once the following PRs are merged, the official release will work:

  • #5426 - Adds session export command
  • #5339 - Adds --tools flag to limit available tools (optional)

For Claude Code backend: Install the SDK as a peer dependency:

bun add @anthropic-ai/claude-agent-sdk

Documentation


Discord · OpenCode

An Aperture Robotics project.

About

structured prompts ft. Zod

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •