opencode-scheduler
Advanced tools
+2
-2
| /** | ||
| * OpenCode Scheduler Plugin | ||
| * | ||
| * Schedule recurring jobs using launchd (Mac) or systemd (Linux). | ||
| * Schedule recurring jobs using launchd (Mac), systemd (Linux), or schtasks (Windows). | ||
| * Jobs are stored under ~/.config/opencode/scheduler/ (scoped by workdir). | ||
@@ -10,3 +10,3 @@ * | ||
| * - Catches up on missed runs (if computer was asleep) | ||
| * - Cross-platform (Mac + Linux) | ||
| * - Cross-platform (Mac + Linux + Windows) | ||
| * - Working directory support for MCP configs | ||
@@ -13,0 +13,0 @@ * - Environment variable injection (PATH for node/npx) |
+1
-1
| { | ||
| "name": "opencode-scheduler", | ||
| "version": "1.2.0", | ||
| "version": "1.3.0", | ||
| "description": "OpenCode plugin for scheduling recurring jobs using launchd (Mac) or systemd (Linux)", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
+73
-8
@@ -9,4 +9,6 @@ # opencode-scheduler | ||
| This is an [OpenCode](https://opencode.ai) plugin that uses your OS's native scheduler (launchd on Mac, systemd on Linux) to run prompts reliably—survives reboots, catches up on missed runs. | ||
| This is an [OpenCode](https://opencode.ai) plugin that uses your OS's native scheduler (launchd on macOS, systemd on Linux, Task Scheduler on Windows) to run prompts reliably. | ||
| As of `v1.2.0`, jobs are scoped by `workdir` (so different projects don't collide), and scheduled runs are supervised (no overlap + optional timeout). | ||
| ## Install | ||
@@ -52,2 +54,3 @@ | ||
| | Delete | `Delete the standing-desk job` | | ||
| | Global cleanup (dry run) | `Run scheduler global cleanup` | | ||
@@ -57,5 +60,5 @@ ## How It Works | ||
| 1. You describe what you want scheduled in natural language | ||
| 2. The plugin creates a cron job and installs it in your OS scheduler | ||
| 3. At the scheduled time, OpenCode runs your prompt autonomously | ||
| 4. Output is logged to `~/.config/opencode/logs/` | ||
| 2. The plugin writes a job file (scoped by `workdir`) and installs a timer in your OS scheduler | ||
| 3. At the scheduled time, the OS scheduler calls a small supervisor script | ||
| 4. The supervisor runs the job, appends logs, and updates job metadata | ||
@@ -66,2 +69,22 @@ You can also trigger a job immediately via `run_job`—it runs fire-and-forget and appends to the same log file. | ||
| ### Reliability Guarantees (Scheduled Runs) | ||
| - **No overlap**: if the previous run is still active, the next scheduled tick is skipped. | ||
| - **Non-interactive by default**: scheduled runs force `OPENCODE_PERMISSION` to deny "question" prompts, so jobs don't hang waiting for approvals. | ||
| - **Optional timeout**: set `timeoutSeconds` to hard-stop long runs (SIGTERM, then SIGKILL). | ||
| ### Platform Support | ||
| | Platform | Scheduler backend | Notes | | ||
| |------|------|------| | ||
| | macOS | `launchd` | Full support (supervised scheduled runs) | | ||
| | Linux | `systemd --user` | Full support (supervised scheduled runs) | | ||
| | Windows | `schtasks` (Task Scheduler) | Supported with cron subset mapping (see limits below) | | ||
| Windows Task Scheduler limits: | ||
| - Cron expressions that use unsupported combinations (for example, month + weekday constraints, or month-only without explicit day-of-month) return a clear error with guidance. | ||
| - Complex cron schedules may be expanded into multiple Windows tasks under `\\OpenCode\\opencode-job-...`. | ||
| - Windows scheduled runs currently do **not** use the supervisor pipeline used on macOS/Linux, so no-overlap and timeout enforcement are not guaranteed by the OS integration itself. | ||
| --- | ||
@@ -104,7 +127,34 @@ | ||
| | `delete_job` | Remove a scheduled job | | ||
| | `cleanup_global` | Remove scheduler artifacts across all scopes (dry-run by default) | | ||
| | `run_job` | Execute a job immediately (fire-and-forget) | | ||
| | `job_logs` | View the latest logs from a job | | ||
| `schedule_job` and `update_job` accept an optional `timeoutSeconds` (integer seconds). Use `0` (or omit) to disable. | ||
| Tools accept an optional `format: "json"` argument to return structured output with `success`, `output`, `shouldContinue`, and `data`. | ||
| ### Global Cleanup | ||
| Use `cleanup_global` to clean scheduler artifacts across all scopes. It always starts in dry-run mode unless you pass `confirm: true`. | ||
| - Dry run (safe default): | ||
| ```json | ||
| { "confirm": false } | ||
| ``` | ||
| - Execute global cleanup of job definitions + lock files + scheduler units: | ||
| ```json | ||
| { "confirm": true } | ||
| ``` | ||
| - Also delete logs and run history: | ||
| ```json | ||
| { "confirm": true, "includeHistory": true } | ||
| ``` | ||
| The tool reports exactly how many artifacts were removed, grouped by location (jobs, locks, logs, runs, launchd/systemd units). | ||
| ### Storage | ||
@@ -114,7 +164,13 @@ | ||
| |------|-------| | ||
| | Job configs | `~/.config/opencode/jobs/*.json` | | ||
| | Logs | `~/.config/opencode/logs/*.log` | | ||
| | launchd plists (Mac) | `~/Library/LaunchAgents/com.opencode.job.*.plist` | | ||
| | systemd units (Linux) | `~/.config/systemd/user/opencode-job-*.{service,timer}` | | ||
| | Job configs (scoped) | `~/.config/opencode/scheduler/scopes/<scopeId>/jobs/*.json` | | ||
| | Run records (scoped) | `~/.config/opencode/scheduler/scopes/<scopeId>/runs/*.jsonl` | | ||
| | Locks (scoped) | `~/.config/opencode/scheduler/scopes/<scopeId>/locks/*.json` | | ||
| | Logs (scoped) | `~/.config/opencode/logs/scheduler/<scopeId>/*.log` | | ||
| | Supervisor script | `~/.config/opencode/scheduler/supervisor.pl` | | ||
| | launchd plists (Mac) | `~/Library/LaunchAgents/com.opencode.job.<scopeId>.*.plist` | | ||
| | systemd units (Linux) | `~/.config/systemd/user/opencode-job-<scopeId>-*.{service,timer}` | | ||
| | Task Scheduler entries (Windows) | `\\OpenCode\\opencode-job-<scopeId>-*` | | ||
| Legacy note: older versions stored jobs in `~/.config/opencode/jobs/*.json` and used unscoped unit names. `delete_job` removes both scoped and legacy artifacts. | ||
| ### Working Directory | ||
@@ -130,2 +186,10 @@ | ||
| ### Scopes | ||
| Scopes are derived from the job's `workdir` (normalized absolute path). This isolates job storage, logs, and OS scheduler unit names per project. | ||
| - `list_jobs` defaults to the **current scope** (your current working directory). | ||
| - Use `allScopes: true` to list jobs across all scopes. | ||
| - Use `includeLegacy: true` to include pre-`v1.2.0` jobs stored in `~/.config/opencode/jobs`. | ||
| ### Attach URL (optional) | ||
@@ -168,2 +232,3 @@ | ||
| - Linux: `systemctl --user list-timers | grep opencode` | ||
| - Windows: `schtasks /Query /TN "\\OpenCode\\opencode-job-*"` | ||
@@ -170,0 +235,0 @@ 2. Check logs: `Show logs for my-job` |
Sorry, the diff of this file is too big to display
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
548205
3.2%14761
2.19%238
37.57%41
2.5%