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
- Host: GitHub
- URL: https://github.com/s4wave/ocpipe
- Owner: s4wave
- License: mit
- Created: 2025-12-27T04:51:21.000Z (about 2 months ago)
- Default Branch: master
- Last Pushed: 2026-02-13T02:43:45.000Z (4 days ago)
- Last Synced: 2026-02-13T11:13:16.725Z (4 days ago)
- Topics: bun, claude-code, opencode, typescript, zod
- Language: TypeScript
- Homepage:
- Size: 222 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
ocpipe
Build LLM pipelines with OpenCode, Claude Code, and Zod.
Inspired by DSPy.
---
- **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.