← Back to PRs

#11221: cli: add schedule subcommand (local-first command scheduler)

by itskai-dev open 2026-02-07 15:25 View on GitHub →
docs cli stale
Adds a new CLI (add/list/remove/run-now) with local-first persistence (schedule.json + schedule-runs.jsonl), overlap locks, and no-shell execution. Includes docs at docs/cli/schedule.md and unit tests (vitest) for store + lock.\n\nMotivation: make recurring kit workflows easy/portable, with standardized run logs for future UI/alerts.\n\nNotes: This is a best-effort contribution; happy to iterate if maintainers want tweaks. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR introduces a new `openclaw schedule` subcommand group (add/list/remove/run-now) backed by local-first persistence in `~/.openclaw/schedule.json` and an append-only run log (`schedule-runs.jsonl`). It adds a simple per-job lock file mechanism to prevent overlapping runs and runs commands via `spawn(..., { shell: false })`. Main areas touched: - CLI registration (`src/cli/program/register.subclis.ts`, `src/cli/schedule-cli/**`) - Scheduling core: types, store (load/save/add/remove/get), run logging, and lock handling (`src/schedule/**`) - New docs and vitest unit tests for store/lock. Two correctness issues need addressing before merge (see inline comments): JSON mode can hang for chatty commands due to undrained stdio pipes, and the commander option collectors can throw when `prev` is undefined. <h3>Confidence Score: 3/5</h3> - This PR is close to mergeable but has two runtime edge cases that can break `schedule` usage. - Core logic is straightforward and covered by basic unit tests, but the current implementation can hang in `run-now --json` for commands with large output and can throw at runtime when parsing repeatable options depending on commander behavior. - src/schedule/run.ts, src/cli/schedule-cli/register.schedule-add.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs