opencode-dataset
v0.1.2
Published
OpenCode plugin and OpenTUI review CLI for collecting fine-tuning datasets.
Readme
opencode-dataset
Capture OpenCode agent sessions into a local JSONL dataset, review examples in an OpenTUI terminal UI, and export to the formats LLM researchers actually use.
Fast path
Install once:
opencode plugin opencode-datasetAdd the plugin to opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
[
"opencode-dataset",
{
"datasetPath": ".opencode/datasets/opencode-dataset.jsonl"
}
]
]
}The older opencode-dataset-plugin package name also works, but opencode-dataset is the shorter recommended name.
OpenCode installs npm plugins with Bun at startup. Captured records are written as newline-delimited JSON so they are easy to diff, stream, and load with Hugging Face Datasets:
from datasets import load_dataset
dataset = load_dataset("json", data_files=".opencode/datasets/opencode-dataset.jsonl")What It Captures
- Tool calls with redacted args/output
- Session diffs and edited file paths
- Message and message-part events
- Permission ask/reply records
- Explicit high-quality examples through the
save_training_exampletool
Secrets are redacted before storage for common API keys, bearer tokens, GitHub tokens, AWS access keys, JWTs, private keys, and sensitive object keys like password, token, secret, and authorization.
Review
Run the OpenTUI review surface:
bunx opencode-dataset review --path .opencode/datasets/opencode-dataset.jsonlWhen there are pending records, the TUI starts in pending review mode. When everything is already accepted or rejected, it opens in all-records mode so you can still inspect the dataset.
Keys:
j/k: movea: acceptr: rejectt: toggle pending/all recordsq: quit
For CI or quick checks:
bunx opencode-dataset review --once --path .opencode/datasets/opencode-dataset.jsonlExport
Accepted records export by default. Add --include-pending when you want a quick raw dump before review.
bunx opencode-dataset export --format openai --path .opencode/datasets/opencode-dataset.jsonl > train.openai.jsonl
bunx opencode-dataset export --format alpaca --path .opencode/datasets/opencode-dataset.jsonl > train.alpaca.jsonl
bunx opencode-dataset export --format sharegpt --path .opencode/datasets/opencode-dataset.jsonl > train.sharegpt.jsonl
bunx opencode-dataset export --format dpo --path .opencode/datasets/opencode-dataset.jsonl > train.dpo.jsonlFormats:
canonical: raw plugin recordsopenai:{ "messages": [{ "role": "user" }, { "role": "assistant" }] }alpaca:{ "instruction", "input", "output" }sharegpt:{ "conversations": [{ "from": "human" }, { "from": "gpt" }] }dpo:{ "prompt", "chosen", "rejected" }
Agent Tool
The plugin registers save_training_example. Ask OpenCode to call it after a good completed task:
Save this as a training example with tags ["typescript", "bugfix"].The saved record is marked accepted immediately, so it exports without needing review.
Local Development
bun install
bun run build
bun run typecheck
bun test
bun run demo
bun run review -- --once
bun run export:openaibun run demo appends a sample accepted record to .opencode/datasets/opencode-dataset.jsonl.
