[Feature Request] File-Watcher Automations: Trigger Agent Chats on File/Directory Changes (Event-Driven Alternative to Cron)

Antigravity currently supports time-based scheduled automations (builtin: "schedule" / cron / /schedule). We propose adding an event-driven file watcher trigger (e.g., a /watch command or a "builtin": "watch" sidecar) that triggers an agent conversation whenever specified files or glob patterns are modified, created, or deleted.

Problem Statement & Motivation

Time-based scheduling (cron) works well for routine periodic checks (e.g., daily standup summaries or hourly PR reviews), but modern development workflows are inherently event-driven.

Currently, if a developer wants an agent to react to local code changes, they have to:

  1. Poll aggressively with cron (e.g., every 1–5 minutes), which wastes tokens, introduces unnecessary lag, and clutters history with no-op runs.
  2. Manually prompt the agent after every edit or test run.
  3. Build an external script using OS tools (like fswatch, inotifywait, or PowerShell FileSystemWatcher) to invoke the CLI, which lacks clean IDE integration.

Proposed Solution

1. In-Chat Slash Command (/watch)

Allow developers to start a file-watching session directly in chat:

text

/watch “src/**/*.ts” “Run tests for modified files and fix any failing unit tests”

Or with debouncing options:

text

/watch --pattern=“docs/**/*.md” --debounce=3000ms “Review documentation for clarity and style consistency”

2. Declarative Automation (sidecar.json)

Extend the automations/sidecar engine to support file triggers alongside cron schedules:

json

{

“builtin”: “file_watch”,

“display_name”: “Test & Lint Watcher”,

“restart_policy”: “always”,

“args”: {

“patterns”: [“src/**/*.ts”, “tests/**/*.ts”],

“ignore”: [“**/node_modules/**”, “**/.git/**”, “**/dist/**”],

“events”: [“modify”, “create”],

“debounce_ms”: 2000,

“max_runs_per_hour”: 15

},

“prompt”: “The following files were modified: {{changed_files}}. Run pytest/npm test on them and explain or fix any regressions.”

}

3. Context Injection

When a file change event triggers the agent, provide rich context in the initial turn:

  • List of changed/created/deleted file paths ({{changed_files}}).
  • Optional diff preview or patch snippet for modified files.

Target Use Cases

  • Continuous Test-Driven Pair Programming (TDD): The agent automatically inspects failing tests and offers inline fixes as soon as test files or source files are saved.
  • Documentation & Schema Sync: Modifying schema.prisma, OpenAPI specs, or protobuf definitions automatically prompts the agent to update client SDKs, types, or doc files.
  • Drop-Folder / Ingestion Automations: Dropping a new CSV, PDF, or log file into a designated directory triggers the agent to parse, validate, and summarize the data.
  • Auto-Linter & Style Fixer: Automatically reviewing code against .agents/rules/ or project guidelines whenever non-trivial edits are detected.

Key Considerations & Safeguards

  • Debouncing & Batching: Crucial to prevent multiple runs when IDEs auto-save rapidly or during git checkout / npm install. An adjustable debounce window (e.g., 1–3 seconds default) should bundle multiple related changes into a single agent turn.
  • .gitignore Awareness: Automatically inherit .gitignore rules to avoid triggering on temporary build artifacts, .lock files, or cache directories.
  • Token Budget & Rate Limiting: Built-in safeguards (e.g., max_runs_per_hour or a prompt asking “Do you want the agent to continue watching?”) to prevent runaway token spend.
  • Conversation Strategy: Configurable option to either start a fresh conversation per event batch or append as a new turn to an active thread.