Skip to content

feat(domain): add scheduled workflows engine with CLI, web UI, and daemon integration#441

Open
arielshad wants to merge 16 commits intomainfrom
feat/scheduled-workflows
Open

feat(domain): add scheduled workflows engine with CLI, web UI, and daemon integration#441
arielshad wants to merge 16 commits intomainfrom
feat/scheduled-workflows

Conversation

@arielshad
Copy link
Contributor

Summary

Adds a complete workflow engine to shep that lets users define reusable automation scripts (expressed as agent prompts) and execute them on demand via CLI/web UI or on a recurring cron schedule managed by the daemon process.

  • Domain layer: TypeSpec-defined Workflow and WorkflowExecution entities with enums for trigger type and execution status. IClock port interface for testable time. Workflow notification events (started, completed, failed) integrated with notification bus.
  • Persistence layer: SQLite migration (045) for workflows and workflow_executions tables. Mapper functions with Row interfaces. Repository implementations with soft delete, prepared statements, and retention-based purge.
  • Application layer: 10 use cases (CreateWorkflow, UpdateWorkflow, DeleteWorkflow, ListWorkflows, GetWorkflow, RunWorkflow, ScheduleWorkflow, EnableWorkflow, DisableWorkflow, GetWorkflowHistory). Repository port interfaces.
  • Infrastructure: WorkflowSchedulerService using croner for cron evaluation, sequential execution queue, crash recovery sweep on startup, and 30-day retention purge. Registered in DI container.
  • CLI: shep workflow command group with 10 subcommands (create, list, show, run, schedule, enable, disable, history, update, delete). Includes --from-template support with two built-in templates (github-issue-triage, branch-rebase).
  • Web UI: Workflow management page with list view, enable/disable toggles, manual trigger buttons, cron badge display, and summary stats. Settings page updated with workflow notification toggles.
  • Daemon integration: Scheduler service initialized alongside existing watchers in the serve command.

Evidence

  • 190 workflow-related tests passing across 18 test files — unit tests for mappers (28), use cases (47), templates (7), scheduler service (11), CLI commands (45), format helpers (14), serve integration (3), TUI steps (5); integration tests for repositories (48), command flow (11)
  • CLI workflow command group with all 10 subcommands fully functional
  • Full CLI demo: create, template-create, schedule, list, show, disable/enable, history, update, delete
  • Web UI: workflows page empty state and populated state with enable/disable toggles and run buttons
  • Web UI: settings page with workflow notification toggles

Test plan

  • All 4653 unit tests pass
  • All 569 integration tests pass
  • Build compiles without errors
  • Linter passes with zero warnings
  • CI pipeline passes (e2e feature-create-drawer test has a pre-existing failure on main — not introduced by this PR)

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

arielshad and others added 16 commits March 20, 2026 22:24
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Covers cron library selection (croner), domain model design, database
schema, scheduler service architecture, execution model, repository
layer, use case organization, CLI structure, web UI architecture,
notification integration, crash recovery, and built-in templates.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…led workflows

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Define ScheduledWorkflow entity (SoftDeletableEntity), WorkflowExecution
entity (BaseEntity), WorkflowTriggerType enum, and WorkflowExecutionStatus
enum in TypeSpec. Install croner v10.x for cron expression parsing and
scheduling. Compile TypeSpec to generate TypeScript types.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add IClock port interface for testable time handling in the scheduler
service, with RealClock infrastructure implementation and unit tests.
Extend NotificationEventType enum with WorkflowStarted, WorkflowCompleted,
and WorkflowFailed events. Add corresponding NotificationEventConfig
fields, settings mapper columns, migration 044, defaults factory entries,
web UI toggles, and update all affected test fixtures.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add SQLite migration (045), bidirectional mappers, repository port
interfaces, and repository implementations for ScheduledWorkflow and
WorkflowExecution entities. Includes 76 tests covering mappers
(unit) and repositories (integration) with full round-trip data
integrity verification.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ed workflows

Implement 9 use cases (Create, Update, Delete, List, Get, Run, Schedule,
GetHistory, Toggle), the WorkflowSchedulerService with polling-based
execution engine, 2 built-in workflow templates, and DI container
registrations.

Key components:
- Cron validation/nextRunAt calculation via croner (shared helper)
- Sequential execution with FIFO queue in WorkflowSchedulerService
- Crash recovery (marks stale running executions as failed on startup)
- 30-day retention cleanup every 100 scheduler ticks
- Notification events (WorkflowStarted/Completed/Failed)
- Injectable IClock for deterministic testing
- Issue-triage and branch-rebase workflow templates

58 tests across 10 test files covering all use cases, scheduler service
lifecycle, execution, notifications, crash recovery, and retention.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add the complete 'shep workflow' CLI command group with 10 subcommands
(create, list, show, run, schedule, enable, disable, history, update,
delete), register it in the main CLI program, and integrate the
WorkflowSchedulerService into the daemon's _serve command startup and
shutdown lifecycle.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add /workflows page with server actions for listing workflows,
viewing execution history, toggling enabled state, and triggering
manual runs. Build client components (WorkflowsPageClient,
WorkflowList, WorkflowListItem, WorkflowExecutionHistory) with
colocated Storybook stories. Add Workflows nav item to sidebar.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Croner was only listed in packages/core/package.json but the compiled
CLI dist runs from the workspace root. With pnpm strict mode, the root
cannot resolve packages not in its own dependencies.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The _serve.command.test.ts was missing mocks for the workflow scheduler
service and its DI tokens (IWorkflowRepository, IWorkflowExecutionRepository,
IClock) added by the scheduled workflows feature integration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Evidence includes:
- 190 passing tests across 18 test files (unit + integration)
- CLI workflow command help text and demo output
- App screenshots: empty workflows page, populated workflows page,
  settings page with workflow notification toggles

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ature

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…er actions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link

Dev Release Published

Artifact Version Install
npm 1.135.2-pr441.6804dc0 npm install -g @shepai/cli@1.135.2-pr441.6804dc0

Published from commit 6596214 | View CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant