Automations¶
Charts declares one snapshot source (charts.state) and no events source, so it has no cursor and no generated timer recipe. An automation refreshes a chart by calling one of the plugin's methods; the automation owns the cadence and Charts owns the drawing.
A nightly rerender from a workspace file:
// In an OpenCode automation, one turn a day:
const checked = await tools.charts.validate({
spec: { mark: "line", encoding: { x: { field: "month", type: "temporal" }, y: { field: "revenue", type: "quantitative" } } },
data: { path: "data/revenue.csv" },
})
if (checked.valid) {
const plan = await tools.charts.plan_render({ documentPath: "outputs/charts/revenue.chart.json", expectedRevision: "sha256:…" })
await tools.charts.render({ planId: plan.planId })
}
- A new chart is
tools.charts.plan_render/renderorplan_quick/quick; a saved chart whose data changed is a new document, and one whose presentation changed isplan_update/update. tools.charts.recommendanswers which chart fits a question, andtools.charts.cataloguehands out a working call.- Charts writes local files only: schedule it when the reader wants the file, and keep the output folder inside the workspace.
access: "read-only"lets the plans run but makes every commit fail cleanly; useask-changesorallfor a scheduled writer, or have the automation ask the person to confirm.
OpenCode automations are the scheduler. Do not add a cron job or a systemd timer in this repository.