[PR #12417] feat: introduce automations across server, app, and TUI #14208

Closed
opened 2026-02-16 18:19:01 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12417

State: closed
Merged: No


What does this PR do?

Adds Automations. You can create a scheduled or manual automation that runs a prompt across one or more projects, spins up sessions, and records history. The server/domain, the API + SDK, the CLI/TUI, and the web app UI are all wired. The prompt editor was moved into a shared component so the automation dialog can reuse it, and added a shared import/export format.

This partially some automation related tickets:

Fixes #5891

Somewhat Related:

How did you verify your code works?

  • bun run typecheck in packages/util, packages/app, packages/opencode, packages/ui
  • bun test
  • manual tests with videos

Desktop

https://github.com/user-attachments/assets/e665b75f-a075-4016-af52-16f340e605a3

TUI

https://github.com/user-attachments/assets/fd176490-4381-4842-9a03-1d104138abee


AI generated details

Feature added

  • Automations: scheduled or on‑demand prompts that run across one or more projects, creating sessions and logging run history.

How it works

  • Create/update: An automation stores name, projects, prompt, schedule, enabled plus timestamps and last run/session.
  • Schedule: The server registers a global scheduler tick; due automations are executed in the background.
  • Execution:
  • For each target project, the server bootstraps the instance, renders the prompt (supports {{date}}, {{project.name}}, {{session.latest}}, {{session.query:...}}), and creates a session.
  • If the prompt starts with /, it runs as a command; otherwise it’s a normal prompt.
  • History + events: Each run creates AutomationRun entries and emits global events for UI/TUI live updates.
  • Manual run: POST /automation/:id/run returns immediately (async execution).

Systems changed

  • Server domain & scheduler
    • New automation domain (packages/opencode/src/automation/index.ts)
    • Scheduler registration on server start (packages/opencode/src/server/server.ts)
  • API + SDK
    • New automation routes (packages/opencode/src/server/routes/automation.ts)
    • OpenAPI + JS SDK regeneration (packages/sdk/openapi.json, packages/sdk/js/src/v2/gen/*)
  • CLI/TUI
    • CLI commands (packages/opencode/src/cli/cmd/automation.ts)
    • TUI dialogs + keybinds + sync (packages/opencode/src/cli/cmd/tui/*)
  • Web app
    • Automations page + dialogs (packages/app/src/pages/automations.tsx, packages/app/src/components/dialog-automation*.tsx)
    • Prompt editor refactor reused for automation prompt authoring (packages/app/src/components/prompt-editor.tsx)
  • Shared utilities
    • Import/export contract (packages/util/src/automation-transfer.ts)
    • Slug helper (packages/util/src/slugify.ts)
  • UI primitives
    • Icons + select behavior adjustments (packages/ui/src/components/icon.tsx, packages/ui/src/components/select.tsx)

Where data lives

  • Automations + history stored under the server storage:
    • ~/.local/share/opencode/storage/automation/*.json
    • ~/.local/share/opencode/storage/automation//run/*.json
  • Project list used in the automation dialog is from the server project registry:
    • ~/.local/share/opencode/storage/project/*.json
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12417 **State:** closed **Merged:** No --- ### What does this PR do? Adds Automations. You can create a scheduled or manual automation that runs a prompt across one or more projects, spins up sessions, and records history. The server/domain, the API + SDK, the CLI/TUI, and the web app UI are all wired. The prompt editor was moved into a shared component so the automation dialog can reuse it, and added a shared import/export format. This partially some automation related tickets: Fixes #5891 Somewhat Related: - #11498 - #11232 ### How did you verify your code works? - bun run typecheck in packages/util, packages/app, packages/opencode, packages/ui - bun test - manual tests with videos #### Desktop https://github.com/user-attachments/assets/e665b75f-a075-4016-af52-16f340e605a3 #### TUI https://github.com/user-attachments/assets/fd176490-4381-4842-9a03-1d104138abee --- ### AI generated details #### Feature added - Automations: scheduled or on‑demand prompts that run across one or more projects, creating sessions and logging run history. #### How it works - Create/update: An automation stores name, projects, prompt, schedule, enabled plus timestamps and last run/session. - Schedule: The server registers a global scheduler tick; due automations are executed in the background. - Execution: - For each target project, the server bootstraps the instance, renders the prompt (supports {{date}}, {{project.name}}, {{session.latest}}, {{session.query:...}}), and creates a session. - If the prompt starts with /, it runs as a command; otherwise it’s a normal prompt. - History + events: Each run creates AutomationRun entries and emits global events for UI/TUI live updates. - Manual run: POST /automation/:id/run returns immediately (async execution). #### Systems changed - ##### Server domain & scheduler - New automation domain (packages/opencode/src/automation/index.ts) - Scheduler registration on server start (packages/opencode/src/server/server.ts) - ##### API + SDK - New automation routes (packages/opencode/src/server/routes/automation.ts) - OpenAPI + JS SDK regeneration (packages/sdk/openapi.json, packages/sdk/js/src/v2/gen/*) - ##### CLI/TUI - CLI commands (packages/opencode/src/cli/cmd/automation.ts) - TUI dialogs + keybinds + sync (packages/opencode/src/cli/cmd/tui/*) - ##### Web app - Automations page + dialogs (packages/app/src/pages/automations.tsx, packages/app/src/components/dialog-automation*.tsx) - Prompt editor refactor reused for automation prompt authoring (packages/app/src/components/prompt-editor.tsx) - ##### Shared utilities - Import/export contract (packages/util/src/automation-transfer.ts) - Slug helper (packages/util/src/slugify.ts) - ##### UI primitives - Icons + select behavior adjustments (packages/ui/src/components/icon.tsx, packages/ui/src/components/select.tsx) #### Where data lives - ##### Automations + history stored under the server storage: - ~/.local/share/opencode/storage/automation/*.json - ~/.local/share/opencode/storage/automation/<id>/run/*.json - ##### Project list used in the automation dialog is from the server project registry: - ~/.local/share/opencode/storage/project/*.json
yindo added the pull-request label 2026-02-16 18:19:01 -05:00
yindo closed this issue 2026-02-16 18:19:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14208