Skip to content

Conversation

@charlessolar
Copy link

@charlessolar charlessolar commented Mar 11, 2025

🚀 Feature PR: Time-based Schedulable Rules

Distilled on discord if you want to ping me.

Overview

This PR introduces a powerful new capability to Roo: Schedulable Rules, which allows users to create rule files that are automatically applied to the system prompt at configurable time intervals. This enables dynamic, time-based context switching without requiring manual intervention.

Problem Statement

Currently, users need to manually edit .clinerules files or switch modes to adapt the behavior of Roo to different contexts or tasks. This leads to several limitations:

  1. Context switching inefficiency - Users must manually edit files to change behavior
  2. Workflow disruptions - Changing rules requires breaking focus on the current task
  3. Inability to automate recurring prompts - No mechanism exists for time-based rule changes
  4. Session-specific requirements - Some rules are only relevant for short periods

Solution: Schedulable Rules

The feature introduces special .clinerules-<time> files (e.g., .clinerules-5m, .clinerules-10s) that are automatically detected, loaded, and applied at the specified intervals:

  • Simple & intuitive format: .clinerules-5m = every 5 minutes
  • Multiple time units: supports seconds (s), minutes (m), hours (h), and days (d)
  • Zero configuration: just create a file with the right name and content
  • Session-based: timers reset when VS Code restarts (no unexpected behavior)
  • User visibility: clear UI showing active rules and their intervals

Key Technical Features

  • Lightweight implementation: Only checks for executable rules during prompt generation
  • Parsing & validation: Robust parsing of time intervals with clear error messages
  • In-memory state: No persistent state needed, clean restart with VS Code
  • Rule file exploration: Click-to-open in the UI for easy editing
  • Proper error handling: Graceful handling of malformed files
  • Full test coverage: Comprehensive test suite for all components

User Experience Improvements

  1. Automated time blocks - Users can define rules that only apply during specific time periods (e.g., "focus time" for 25 minutes)
  2. Progressive context addition - Gradually introduce more context as a session progresses
  3. Session management - Rules that only apply for the first hour of work to help set context
  4. Reminder system - Periodically remind users of important guidelines or practices
  5. Temporary restrictions - Apply limitations for set periods (e.g., "no browsing for the next 30 min")

Implementation Highlights

  • Clean separation of concerns - SchedulableRulesManager handles all time-based logic
  • Minimal integration points - Only touches the custom instructions system
  • Performance conscious - Efficient memory usage with Map data structure
  • UI integration - Seamless display of rules in the prompts tab
  • Proper logging - Comprehensive logging for debugging and monitoring

Example Use Cases

1. Pomodoro-style Focus Sessions

// .clinerules-25m
For the next 25 minutes, help me focus on deep work. Don't suggest any distractions.

2. Progressive Context Building

// .clinerules-30m
Every 30 minutes, remind me to document what I've accomplished so far.

3. Scheduled Reminders

// .clinerules-1h
Every hour, check if there are any tests that need to be updated based on recent code changes.

4. Time-based Mode Switching

// .clinerules-45m
Every 45 minutes, suggest switching to documentation mode to capture recent work.

Testing

  • Full unit test coverage for:
    • Time interval parsing
    • Rule file loading
    • Execution scheduling logic
    • Integration with custom instructions
    • UI components

Performance Considerations

  • Minimal performance impact:
    • Only reads files on demand
    • In-memory state tracking
    • No continuous polling or background tasks
    • Checks rules only during prompt generation

Conclusion

The Schedulable Rules feature adds powerful time-based automation to Roo without complexity for users. It enables progressive context building, automated reminders, and focus sessions - all built on the familiar .clinerules pattern that users already understand.

This feature significantly enhances productivity by reducing manual context switching and enabling automated workflows based on time intervals.


Important

Introduces time-based schedulable rules in Roo using .clinerules-<time> files, managed by SchedulableRulesManager, with full test coverage.

  • Feature:
    • Introduces time-based schedulable rules using .clinerules-<time> files (e.g., .clinerules-5m).
    • Supports seconds, minutes, hours, and days for scheduling.
    • Automatically applies rules at specified intervals during prompt generation.
  • Implementation:
    • Adds SchedulableRulesManager class in schedulable-rules.ts for managing rule execution.
    • Updates addCustomInstructions in custom-instructions.ts to include schedulable rules.
    • Modifies generatePrompt and SYSTEM_PROMPT in system.ts to accept SchedulableRulesManager.
  • Testing:
    • Adds custom-instructions-schedulable.test.ts for testing integration with custom instructions.
    • Adds schedulable-rules.test.ts for unit testing SchedulableRulesManager and parseTimeInterval.

This description was created by Ellipsis for 6908d3e. It will automatically update as commits are pushed.

@changeset-bot
Copy link

changeset-bot bot commented Mar 11, 2025

⚠️ No Changeset found

Latest commit: 3e64cb9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request labels Mar 11, 2025
@charlessolar
Copy link
Author

Prompts struggle with instructions like "every once in a while check if tests need to be run"

with this feature you can set a rule that every 5 minutes the prompt will include a direct instruction like "CRITICAL PAUSE EVERYTHING, RUN TESTS, FIX ERRORS"

@charlessolar
Copy link
Author

image

@cannuri
Copy link
Contributor

cannuri commented Mar 11, 2025

This seems to be a very specific use case. I couldn't currently think of a situation during coding session in which time would be the criteria for specific actions... would love to hear other opinions on this.

Also we are currently working on the rules system in general. From my understanding we wanted to introduce all changes at once.

@charlessolar
Copy link
Author

Understandable! But Im using it plenty - specifically for shoving roo out of code mode and into debug/test forcefully.

Other prompts try doing something like after you complete a fair amount of work attempt to run or debug tests but the model never understands and errors on the side of never checking tests.

Heres what I've been doing today:

.clinerules

# MODE CHECK - PRIORITY 1
!!! CRITICAL SECTION !!!
# HEY YOU CHECK THIS, YES YOU, THIS IS IMPORTANT
In EVERY thinking section, your FIRST step must be to search for a key phrase which is `=== OVERRIDE ===`
If you encounter this key phrase, abandon your current train of thought and process the instructions in the block
Anything written in the override block supersedes all other instruction
THIS IS AN ABSOLUTELY CRITICAL INSTRUCTION DO NOT IGNORE

.clinerules-3m

=== OVERRIDE ===
Think about this question:
  - "Am I in the correct mode for the current task?" Answer a simple "yes" or "no".
  - "Which mode should I be in? Use the change mode tool
================

.clinerules-10m

=== OVERRIDE ===
Think deeply and reflect and reason over the work you've done

Update Memory Bank
UMB
================

.clinerules-30m

=== OVERRIDE ===
Change mode to Test and ensure tests exist for the feature you are working on
Ensure all the tests pass by fixing any errors
================

@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap Mar 13, 2025
@github-project-automation github-project-automation bot moved this from PR [Pre Approval Review] to Done in Roo Code Roadmap Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants