An open API service indexing awesome lists of open source software.

https://github.com/s4wave/ocpipe

structured prompts ft. Zod
https://github.com/s4wave/ocpipe

bun claude-code opencode typescript zod

Last synced: 3 days ago
JSON representation

structured prompts ft. Zod

Awesome Lists containing this project

README

          

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

```bash
bun add ocpipe
```

```typescript
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 // { name: string }
type GreetOut = InferOutputs // { greeting: string }
```

### Backends

ocpipe supports two backends for running LLM agents:

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

```typescript
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.

```typescript
// 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](https://github.com/paralin/opencode). Once the following PRs are merged, the official release will work:

- [#5426](https://github.com/anomalyco/opencode/pull/5426) - Adds session export command
- [#5339](https://github.com/anomalyco/opencode/pull/5339) - Adds `--tools` flag to limit available tools (optional)

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

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

### Documentation

- [Getting Started](./GETTING_STARTED.md) - Tutorial with examples
- [Design](./DESIGN.md) - Architecture and concepts
- [Contributing](./CONTRIBUTING.md) - Development setup

---

[Discord](https://discord.gg/opencode) · [OpenCode](https://github.com/sst/opencode)

An [Aperture Robotics](https://github.com/aperturerobotics) project.