Early exit pattern matching for command output with fast error detection
Project description
earlyexit ๐
Stop long-running commands the instant an error appears - Like timeout + grep -m 1 combined, but smarter: monitors stderr, detects hangs, and uniquely captures full error context with configurable delay-exit (continue reading for N seconds after match to get stack traces and cleanup logs), plus clear exit codes.
Essential for AI-assisted coding where agents run commands unattended - earlyexit makes intelligent decisions to exit early when no human is watching, enabling fast feedback loops for AI code generation iterations.
Self-learning capability: Optionally captures execution telemetry (patterns, timing, matches) in local SQLite database for ML-driven optimization of delays, timeouts, and pattern effectiveness - learns from your usage to improve over time.
Implements the early error detection pattern for faster feedback during long-running commands, CI/CD pipelines, log monitoring, and autonomous agent workflows.
๐ฏ Purpose
Traditional grep processes the entire input stream or exits immediately with -m 1 (losing error context). earlyexit detects errors instantly but with a unique delay-exit feature (default 10s) to capture full stack traces, cleanup logs, and error context before terminating - something no standard Unix tool provides.
๐ค Why Critical for AI-Assisted Development
In modern AI-assisted coding (Cursor, Copilot, Aider, etc.), small errors are more common and humans aren't watching:
- AI agents generate code rapidly โ More iterations, more potential errors
- Unattended execution โ No human monitoring terminal output in real-time
- Fast feedback loops essential โ AI needs immediate error signals to correct course
- Intelligent automated decisions โ Tool must decide when to exit, not human
earlyexit acts as your autonomous error sentinel, making smart decisions about when to stop failed operations and providing clear, actionable exit codes for AI agents to interpret.
Traditional workflow (human watching):
$ npm test # Human sees "Error" at line 3, hits Ctrl-C
# Waits 2 minutes for nothing...
AI-assisted workflow (agent running):
$ earlyexit 'Error|FAIL' npm test # Exits at 0.5s with context
# Agent immediately knows to fix and retry
Perfect for:
- ๐ค AI agent workflows (autonomous coding assistants)
- ๐ง Long-running build processes
- ๐งช Test suites
- ๐ Deployment pipelines
- ๐ Log monitoring
- โฑ๏ธ Time-sensitive operations
๐ฆ Installation
# Install from PyPI (when published)
pip install earlyexit
# Install from source
git clone https://github.com/rsleedbx/earlyexit
cd earlyexit
pip install -e .
# With Perl-compatible regex support
pip install -e ".[perl]"
๐ Two Ways to Use earlyexit
Mode 1: Pipe Mode (Traditional Unix Style)
Read from stdin, like grep:
# Basic usage
command | earlyexit 'ERROR'
# With timeout
long_running_command | earlyexit -t 30 'Error|Failed'
# Chain with other tools
terraform apply 2>&1 | tee terraform.log | earlyexit -t 600 -i 'error'
# Multiple pipes
make 2>&1 | grep -v warning | earlyexit 'error'
# With head to limit output
pytest -v | earlyexit 'FAILED' | head -20
Mode 2: Command Mode (Like timeout)
Run command directly:
# Basic usage
earlyexit 'ERROR' command
# With timeout
earlyexit -t 60 'Error' terraform apply -auto-approve
# Monitor both stdout and stderr
earlyexit --both 'Error|Failed' ./build.sh
# Detect hangs (idle timeout)
earlyexit --idle-timeout 30 'Error' ./long-running-app
# Detect slow startup
earlyexit --first-output-timeout 10 'Error' ./slow-service
Quick Comparison
| Feature | Pipe Mode | Command Mode |
|---|---|---|
| Syntax | cmd | earlyexit 'pat' |
earlyexit 'pat' cmd |
| Chainable | โ Can pipe further | โ Terminal command |
| Monitor stderr | Need 2>&1 |
Use --stderr or --both |
| Idle detection | โ Not available | โ
--idle-timeout |
| Startup detection | โ Not available | โ
--first-output-timeout |
| Error context capture | โ Not available | โ
--delay-exit (unique!) |
| Custom FDs | โ Not available | โ
--fd 3 --fd 4 |
| Like | grep, awk |
timeout, watch |
๐ Usage
Pipe Mode
command | earlyexit [OPTIONS] PATTERN
Command Mode
earlyexit [OPTIONS] PATTERN COMMAND [ARGS...]
Arguments
PATTERN Regular expression pattern to match
COMMAND [ARGS...] Optional: Command to run (command mode)
Options:
-t, --timeout SECONDS Overall timeout in seconds
--idle-timeout SECONDS Timeout if no output for N seconds (hang detection)
--first-output-timeout SECONDS Timeout if first output not seen within N seconds
--delay-exit SECONDS After match, continue reading for N seconds to capture
error context (default: 10 for command mode, 0 for pipe mode)
-m, --max-count NUM Stop after NUM matches (default: 1)
-i, --ignore-case Case-insensitive matching
-E, --extended-regexp Extended regex (Python re module, default)
-P, --perl-regexp Perl-compatible regex (requires regex module)
-v, --invert-match Invert match - select non-matching lines
-q, --quiet Quiet mode - suppress output, only exit code
-n, --line-number Prefix output with line number
--stderr Monitor stderr instead of stdout (command mode)
--both Monitor both stdout and stderr (command mode)
--fd N Monitor file descriptor N (e.g., --fd 3 --fd 4)
--fd-pattern FD PAT Set specific pattern for file descriptor FD
--fd-prefix Add stream labels [stdout]/[stderr]/[fd3]
--stderr-prefix Alias for --fd-prefix
--color WHEN Colorize output: always, auto (default), never
--version Show version
-h, --help Show help message
Usage Modes:
Pipe Mode: command | earlyexit 'pattern' (read from stdin)
Command Mode: earlyexit 'pattern' command (run command directly)
Exit Codes:
0 - Pattern matched (error detected)
1 - No match found (success)
2 - Timeout exceeded (any timeout type)
3 - Other error
Timeout Types:
-t Overall timeout - command exceeds total time limit
--idle Idle timeout - no output for specified seconds (hang detection)
--first First output timeout - no output within initial period (startup detection)
๐ก Examples by Mode
๐ Pipe Mode Examples
Perfect for: Monitoring existing pipelines, chaining with other tools, capturing logs
Example 1: Basic Pipe Usage
# Simple error detection
./build.sh 2>&1 | earlyexit 'error'
# With timeout
long_command | earlyexit -t 60 'Error|Failed'
# Case-insensitive
terraform apply 2>&1 | earlyexit -i 'error'
Example 2: Terraform Operations (Pipe Mode)
# Exit immediately on error, 10min timeout
terraform apply -auto-approve 2>&1 | \
stdbuf -o0 tee terraform.log | \
earlyexit -t 600 -i 'error'
if [ $? -eq 0 ]; then
echo "โ Terraform failed - check terraform.log"
exit 1
elif [ $? -eq 2 ]; then
echo "โฑ๏ธ Terraform timed out after 10 minutes"
exit 2
else
echo "โ
Terraform completed successfully"
fi
Example 3: Chaining with Other Tools
# Save logs and monitor
make 2>&1 | tee build.log | earlyexit 'error'
# Filter then monitor
kubectl logs -f pod | grep -v DEBUG | earlyexit 'ERROR'
# Limit output with head
pytest -v | earlyexit 'FAILED' | head -50
# Multiple processing stages
./app 2>&1 | \
stdbuf -o0 tee app.log | \
grep -v INFO | \
earlyexit -i 'error|fatal'
Example 4: Log Monitoring (Pipe Mode)
# Monitor application logs in real-time
tail -f /var/log/app.log | earlyexit -t 300 -i 'error|exception|fatal'
if [ $? -eq 0 ]; then
echo "๐จ Error detected in logs!"
# Send alert, trigger remediation, etc.
fi
Example 5: Test Suite with Pipes
# Stop after 5 test failures
pytest -v | earlyexit -m 5 'FAILED'
if [ $? -eq 0 ]; then
echo "โ Tests failed - stopping early"
exit 1
fi
โก Command Mode Examples
Perfect for: Direct execution, hang detection, startup monitoring, stderr separation
Example 1: Basic Command Execution
# Simple usage
earlyexit 'ERROR' ./app
# With timeout
earlyexit -t 300 'Error|Failed' terraform apply -auto-approve
# Case-insensitive
earlyexit -i 'error' make build
Example 2: Advanced Monitoring
# Detect hangs - timeout if no output for 30 seconds
earlyexit --idle-timeout 30 'Error' ./long-running-app
# Detect slow startup - timeout if no output within 10 seconds
earlyexit --first-output-timeout 10 'Error' ./slow-service
# Combine all timeouts
earlyexit \
-t 300 \
--idle-timeout 30 \
--first-output-timeout 10 \
'Error' ./app
# After detecting error, wait 10s to capture full error context (default)
earlyexit 'Error' ./app
# Wait only 5 seconds after error for quick exit
earlyexit --delay-exit 5 'Error' ./app
# Wait longer for comprehensive error logs
earlyexit --delay-exit 30 'Error' ./app
# Exit immediately on error (no delay)
earlyexit --delay-exit 0 'FATAL' ./app
Example 3: Stream Separation
# Monitor stderr only
earlyexit --stderr 'ERROR' ./my-script.sh
# Monitor both streams with labels
earlyexit --both --fd-prefix 'Error|Warning|Fatal' ./app
# Different patterns for different streams
earlyexit \
--fd-pattern 1 'FAILED' \
--fd-pattern 2 'ERROR' \
./test.sh
Example 4: Terraform Operations (Command Mode)
# Exit immediately on error, 10min timeout
terraform apply -auto-approve 2>&1 | \
stdbuf -o0 tee terraform.log | \
earlyexit -t 600 -i 'error'
if [ $? -eq 0 ]; then
echo "โ Terraform failed - check terraform.log"
exit 1
elif [ $? -eq 2 ]; then
echo "โฑ๏ธ Terraform timed out after 10 minutes"
exit 2
else
echo "โ
Terraform completed successfully"
fi
# Direct execution with monitoring
earlyexit -t 600 'error' terraform apply -auto-approve
if [ $? -eq 0 ]; then
echo "โ Terraform failed"
exit 1
fi
Example 5: Database Provisioning (Command Mode)
# Monitor with hang detection
earlyexit \
-t 1800 \
--idle-timeout 120 \
'Error|Failed|Exception' \
mist create --cloud aws --db mysql
case $? in
0) echo "โ Database creation failed"; exit 1 ;;
1) echo "โ
Database created successfully" ;;
2) echo "โฑ๏ธ Timeout occurred"; exit 2 ;;
esac
Example 6: CI/CD Pipeline (Command Mode)
# Comprehensive monitoring
earlyexit \
-t 3600 \
--idle-timeout 60 \
--first-output-timeout 15 \
'error|fatal' \
./build.sh
exit $? # Propagate exit code
๐ Choosing the Right Mode
Use Pipe Mode when:
- โ
Already have a pipeline with
tee,grep, etc. - โ Need to capture logs while monitoring
- โ Want to process output with multiple tools
- โ Working with tools that merge stdout/stderr
- โ Need to pipe output to another command
Use Command Mode when:
- โ Need to detect hangs/frozen processes
- โ Need to detect slow startup
- โ Want to monitor stdout and stderr separately
- โ Need to monitor custom file descriptors
- โ Want to use per-stream patterns
- โ Running a single command without piping
๐ Common Patterns
Pattern 1: Save Logs + Monitor (Pipe Mode)
command 2>&1 | stdbuf -o0 tee output.log | earlyexit -t 300 'Error'
Pattern 2: Comprehensive Monitoring (Command Mode)
earlyexit -t 300 --idle-timeout 30 --first-output-timeout 10 'Error' command
Pattern 3: Multiple Processing (Pipe Mode)
command 2>&1 | grep -v DEBUG | earlyexit 'ERROR' | head -100
Pattern 4: Stream Separation (Command Mode)
earlyexit --both --fd-prefix --fd-pattern 2 'ERROR' command
Example 7: Multiple Patterns
# Pipe mode
app_command | earlyexit -E '(ERROR|FATAL|EXCEPTION|SEGFAULT|PANIC)'
# Command mode
earlyexit -E '(ERROR|FATAL|EXCEPTION|SEGFAULT|PANIC)' app_command
Example 8: With Line Numbers
# Pipe mode
long_log_file | earlyexit -n -i 'error'
# Output: 1234:ERROR: Connection failed
# Command mode
earlyexit -n -i 'error' tail -f app.log
Example 9: Health Checks
# Pipe mode - continuous monitoring
while true; do
curl -s http://localhost:8080/health
sleep 1
done | earlyexit -v 'OK' -t 60
# Command mode - startup check
earlyexit --first-output-timeout 5 'error' ./health-check.sh
๐ Pattern Syntax & Regex Engines
earlyexit supports multiple regex engines controlled by command-line flags:
Default: Python Extended Regex
No flag needed - Uses Python's re module (compatible with grep -E):
# Multiple alternatives
earlyexit 'error|warning|fatal'
# Character classes
earlyexit '[Ee]rror'
# Quantifiers
earlyexit 'fail(ed|ure)?'
earlyexit 'error[0-9]+'
# Word boundaries
earlyexit '\berror\b'
# Anchors
earlyexit '^ERROR' # Start of line
earlyexit 'ERROR$' # End of line
# Escape sequences
earlyexit '\d+' # Digits
earlyexit '\w+' # Word characters
earlyexit '\s+' # Whitespace
Perl-Compatible Regex (-P flag)
Requires: pip install earlyexit[perl] or pip install regex
Advanced features using the regex module (compatible with grep -P):
# Variable-length lookbehinds
earlyexit -P '(?<=ERROR: ).*'
earlyexit -P '(?<!IGNORE )ERROR'
# Named groups
earlyexit -P '(?P<level>ERROR|WARN): (?P<msg>.*)'
# Recursive patterns (nested structures)
earlyexit -P '\(((?:[^()]++|(?R))*+)\)'
# Possessive quantifiers (better performance)
earlyexit -P 'error.*+failed'
# Atomic groups
earlyexit -P '(?>error|errors)'
# Unicode properties
earlyexit -P '\p{Letter}+'
earlyexit -P '\p{Digit}+'
Regex Engine Comparison
| Feature | Default (re) |
Perl -P (regex) |
|---|---|---|
| Basic patterns | โ | โ |
Alternation | |
โ | โ |
Quantifiers *+?{n} |
โ | โ |
| Character classes | โ | โ |
Anchors ^$ |
โ | โ |
| Groups & backreferences | โ | โ |
| Lookaheads | โ | โ |
| Fixed-length lookbehinds | โ | โ |
| Variable-length lookbehinds | โ | โ |
| Recursive patterns | โ | โ |
| Possessive quantifiers | โ | โ |
| Atomic groups | โ | โ |
| Unicode properties | โ | โ |
Quick Reference
# Choose your regex engine
earlyexit 'pattern' cmd # Default: Python re
earlyexit -E 'pattern' cmd # Explicit: Python re
earlyexit -P 'pattern' cmd # Advanced: Perl regex
# Common patterns
earlyexit 'ERROR|FATAL' # Multiple words
earlyexit -i 'error' # Case-insensitive
earlyexit '\b(ERROR|FATAL)\b' # Whole words only
earlyexit '^ERROR' # Start of line
earlyexit 'ERROR.*connection' # ERROR followed by connection
earlyexit -P '(?<=ERROR: ).*' # Everything after "ERROR: "
earlyexit -P '(?<!IGNORE )ERROR' # ERROR not preceded by IGNORE
๐ฏ Use Cases
1. AI Agent Workflows ๐ค
Enable AI coding assistants to run commands autonomously with intelligent error detection:
# AI agent running tests unattended
earlyexit --delay-exit 10 'FAILED|ERROR|Exception' npm test
# Exit code 0 = error found โ Agent analyzes logs and fixes code
# Exit code 1 = all tests passed โ Agent proceeds to next task
# AI agent running build with hang detection
earlyexit -t 600 --idle-timeout 30 'error|fatal' ./build.sh
# Captures full compilation errors with context
# Detects hung builds and reports back to agent
# Agent-driven deployment validation
earlyexit \
--first-output-timeout 30 \
--idle-timeout 60 \
'Error|Failed|Unhealthy' \
kubectl rollout status deployment/app
# Agents get immediate feedback on deployment failures
# Clear exit codes enable automated rollback decisions
Why this matters for AI coding:
- โ Zero human intervention - agents monitor and react automatically
- โ Fast iteration loops - immediate error feedback โ faster fixes
- โ Rich error context - delay-exit captures full stack traces for AI analysis
- โ Clear exit codes - 0=error, 1=success, 2=timeout - perfect for agent logic
- โ Multi-stream monitoring - catches errors in stdout, stderr, and custom FDs
2. Fast Feedback in CI/CD
Stop the build immediately on first error instead of waiting for full completion:
# GitLab CI example
script:
- make build 2>&1 | earlyexit -t 3600 'error' || exit 1
3. Cost Optimization
Save compute costs by stopping failed cloud operations early:
# Stop provisioning if errors detected in first 5 minutes
terraform apply | earlyexit -t 300 'Error:' && terraform destroy -auto-approve
4. Development Workflow
Get instant feedback during development:
# Watch for compilation errors
npm run watch | earlyexit 'ERROR'
5. Monitoring & Alerting
Detect issues in production logs:
# Alert on first critical error
kubectl logs -f pod-name | earlyexit 'CRITICAL' && send-alert
โก Performance Comparison
| Tool | Behavior | Time to Detect Error |
|---|---|---|
grep |
Processes entire input | After full completion |
grep -m 1 |
Stops after first match | Immediate (but no timeout) |
earlyexit |
Stops after first match + timeout | Immediate + safety net |
Real-World Example
# Command that takes 30 minutes but fails at 5 minutes
# grep: Waits full 30 minutes
command | grep 'Error' # 30 minutes wasted
# earlyexit: Exits at 5 minutes
command | earlyexit -t 1800 'Error' # Saves 25 minutes!
๐ง Integration with Other Tools
With tee (save logs + monitor)
command 2>&1 | stdbuf -o0 tee output.log | earlyexit -t 300 'Error'
With timeout (double safety)
timeout 600 bash << 'EOF'
command 2>&1 | stdbuf -o0 tee log.txt | earlyexit -t 300 'Error'
EOF
With stdbuf (unbuffered output)
command 2>&1 | stdbuf -o0 tee log.txt | earlyexit 'Error'
๐งช Testing
# Test success (no match)
echo "Starting..." | earlyexit 'Error' # Exit 1
# Test match (immediate exit)
echo "Error detected" | earlyexit 'Error' # Exit 0
# Test timeout
sleep 10 | earlyexit -t 2 'Error' # Exit 2 after 2 seconds
# Test case-insensitive
echo "ERROR" | earlyexit -i 'error' # Exit 0
# Test max count
printf "Error\nError\nError\n" | earlyexit -m 2 'Error' # Exit 0 after 2 matches
# Test invert match
echo "OK" | earlyexit -v 'Error' # Exit 1 (OK is not Error)
echo "Error" | earlyexit -v 'OK' # Exit 0 (Error doesn't match OK)
๐ Exit Codes
| Exit Code | Meaning | Use Case |
|---|---|---|
| 0 | Pattern matched | Error detected - fail fast |
| 1 | No match | Success - continue |
| 2 | Timeout | Command took too long |
| 3 | Error | Invalid pattern, broken pipe, etc. |
| 130 | Interrupted | Ctrl+C pressed |
๐ Comparison with Other Tools
vs grep
| Feature | grep | earlyexit (pipe) | earlyexit (command) |
|---|---|---|---|
| Pattern matching | โ | โ | โ |
| Extended regex | โ -E | โ -E | โ -E |
| Perl regex | โ -P | โ -P | โ -P |
| Stop on first match | โ ๏ธ -m 1 | โ default | โ default |
| Delay-exit (capture error context) | โ | โ | โ --delay-exit (unique!) |
| Timeout | โ | โ -t | โ -t |
| Hang detection | โ | โ | โ --idle-timeout |
| Startup detection | โ | โ | โ --first-output-timeout |
| Stream separation | โ | โ ๏ธ with 2>&1 | โ --both, --stderr |
| Exit code clarity | โ ๏ธ Complex | โ 0/1/2/3 | โ 0/1/2/3 |
| Pipeable | โ | โ | โ |
vs timeout
| Feature | timeout | earlyexit (command) |
|---|---|---|
| Run commands | โ | โ |
| Overall timeout | โ | โ -t |
| Pattern matching | โ | โ |
| Delay-exit (capture error context) | โ | โ --delay-exit (unique!) |
| Hang detection | โ | โ --idle-timeout |
| Startup detection | โ | โ --first-output-timeout |
| Stream separation | โ | โ --stderr, --both |
| Per-FD patterns | โ | โ --fd-pattern |
| Early exit on match | โ | โ |
๐ Troubleshooting
Pattern not matching?
# Test your pattern separately
echo "test string" | earlyexit 'pattern'
# Enable line numbers to see what's being processed
command | earlyexit -n 'pattern'
# Use -i for case-insensitive if needed
command | earlyexit -i 'pattern'
Timeout not working?
# Ensure timeout is numeric
earlyexit -t 10 'pattern' # โ
Correct
earlyexit -t 10s 'pattern' # โ Wrong - no 's' suffix
Buffering issues?
# Use stdbuf to disable buffering
command 2>&1 | stdbuf -o0 tee log.txt | earlyexit 'pattern'
๐ Best Practices
-
For AI agents and unattended execution, combine multiple safeguards:
# Comprehensive monitoring for autonomous agents earlyexit \ -t 600 \ # Overall timeout (prevent infinite runs) --idle-timeout 30 \ # Hang detection (no output = stuck) --first-output-timeout 10 \ # Startup validation (ensure it runs) --delay-exit 10 \ # Error context capture (get full logs) 'ERROR|FAILED|Exception' \ ./agent-task.sh # Agent can confidently interpret: # Exit 0 = Error detected with full context โ analyze logs and fix # Exit 1 = Task completed successfully โ proceed to next step # Exit 2 = Timeout/hang detected โ retry or escalate
-
Save logs with tee:
command 2>&1 | stdbuf -o0 tee log.txt | earlyexit -t 300 'Error'
-
Use case-insensitive for error detection:
earlyexit -i 'error' # Matches Error, ERROR, error
-
Multiple patterns with extended regex:
earlyexit -E '(error|warning|fatal|exception)'
-
Check exit codes properly (critical for AI agents):
command | earlyexit 'Error' case $? in 0) echo "Error detected"; exit 1 ;; 1) echo "Success" ;; 2) echo "Timeout"; exit 2 ;; *) echo "Unexpected error"; exit 3 ;; esac
-
Use delay-exit to capture full error context (command mode):
# Wait 10s after error to capture stack traces, cleanup logs, etc. (default) earlyexit 'ERROR' ./app # โ Captures full error context # Quick exit for known fatal errors earlyexit --delay-exit 2 'FATAL|PANIC' ./app # โก Fast fail # Wait longer for comprehensive context earlyexit --delay-exit 30 'Error' ./long-cleanup-app # In pipe mode, use explicit delay if needed ./app 2>&1 | earlyexit --delay-exit 10 'Error' # Default is 0 for pipes
๐ค Self-Learning System (Coming Soon)
earlyexit includes an optional self-learning capability that captures execution telemetry for ML-driven optimization:
What it Learns
- Pattern Effectiveness: Which patterns work best for your projects (Python tests vs Node builds)
- Optimal Delays: Learns ideal
--delay-exittimes per command type (stack traces need longer) - False Positive Reduction: Identifies "Error" strings that aren't real errors
- Timing Optimization: Suggests optimal timeouts based on historical runs
- Anomaly Detection: Warns when commands behave unusually
Privacy-First Design
All data stored locally in ~/.earlyexit/telemetry.db by default:
- โ No cloud upload (unless you opt-in)
- โ Automatic PII scrubbing (passwords, tokens, paths)
- โ Configurable retention (default 90 days)
- โ
Easy to disable:
--no-telemetryflag orEARLYEXIT_NO_TELEMETRY=1env var - โ Negligible performance impact: <1ms overhead (tested)
Disable telemetry completely:
# Per-command
$ earlyexit --no-telemetry 'ERROR' -- ./script.sh
# Globally via environment variable
$ export EARLYEXIT_NO_TELEMETRY=1 # Add to ~/.bashrc or ~/.zshrc
$ earlyexit 'ERROR' -- ./script.sh # No database created or accessed
# In CI/CD (Dockerfile, GitHub Actions, etc.)
ENV EARLYEXIT_NO_TELEMETRY=1 # Docker
env:
EARLYEXIT_NO_TELEMETRY: 1 # GitHub Actions
When disabled:
- โ No SQLite database created
- โ Existing database not accessed or modified
- โ All core features (pattern matching, timeouts, delay-exit) work normally
- โ ML features (
suggest,--auto-tune) unavailable
For ephemeral systems (CI/CD, containers):
- โ Optional HTTP backend for remote storage
- โ Fire-and-forget async sending (no blocking)
- โ See TELEMETRY_BACKENDS.md for options
Example: Self-Improving
# First run with default settings
$ earlyexit 'Error' npm test
# Exits after 45s (10s delay was too long)
# Provide feedback
$ earlyexit feedback --delay-should-be 5
โ Feedback recorded
# Next time, get smart suggestions
$ earlyexit suggest 'npm test'
Recommended: earlyexit --delay-exit 5 'Error|FAIL|ร' npm test
Based on 47 similar executions in this project
# Auto-apply learned settings (opt-in)
$ earlyexit --auto-tune 'Error' npm test
Using learned settings: --delay-exit 5 --idle-timeout 30
Data Captured for ML
See LEARNING_SYSTEM.md for complete details:
- โ Command metadata (type, language, environment)
- โ Pattern match events (timing, location, context)
- โ Exit conditions (why it stopped, was it correct?)
- โ Performance metrics (runtime, idle periods)
- โ User feedback (ratings, corrections)
Benefits for AI Agents
- Reduced trial-and-error: Agent learns from past runs
- Project-specific tuning: Automatically adapts to your codebase
- Confidence scoring: ML provides uncertainty estimates
- Continuous improvement: Gets smarter with every run
Roadmap
- Phase 1 (Current): Design and schema โ
- Phase 2: Basic telemetry capture (coming soon)
- Phase 3: Analysis and reporting CLI
- Phase 4: ML inference for real-time suggestions
- Phase 5: Federated learning (opt-in community patterns)
Note: All learning features are opt-in and can be completely disabled.
๐ License
MIT License - see LICENSE file for details
๐ค Contributing
Contributions welcome! Please open an issue or PR on GitHub.
๐ Additional Documentation
- TIMEOUT_GUIDE.md - Complete timeout and hang detection guide
- REGEX_REFERENCE.md - Complete regex pattern reference
- FD_MONITORING.md - File descriptor monitoring guide
- LEARNING_SYSTEM.md - ๐ค Self-learning and ML optimization system
- TELEMETRY_BACKENDS.md - Storage options (SQLite, HTTP, hybrid)
- ENHANCEMENTS.md - Technical implementation details
๐ Related Projects
- timeout - Command timeout utility (part of GNU coreutils)
- stdbuf - Modify buffering of streams (part of GNU coreutils)
- ripgrep (rg) - Fast grep alternative in Rust
๐ฎ Contact
Robert Lee - robert.lee@databricks.com
Made with โค๏ธ for developers who value fast feedback
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file earlyexit-0.0.2.tar.gz.
File metadata
- Download URL: earlyexit-0.0.2.tar.gz
- Upload date:
- Size: 113.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7eb17df6257264ff2fa2a4b373cfc208906c2b141310eb75348272a0c6062913
|
|
| MD5 |
5e3cc2c9f0f16d9a08de43c9f180229a
|
|
| BLAKE2b-256 |
a90c11d3f4f8d449ef38c6ce3b0527da38e7314829849093e39b6229afc76184
|
File details
Details for the file earlyexit-0.0.2-py3-none-any.whl.
File metadata
- Download URL: earlyexit-0.0.2-py3-none-any.whl
- Upload date:
- Size: 39.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce98e5cdd7ff68f1892d90767da582886cf615ac5d509d5da3fb52c913a8e29b
|
|
| MD5 |
4b07f1aba4bba22df33692f492ef738e
|
|
| BLAKE2b-256 |
ec1104c5d50c15aa55519f04540b43807c8cb770faa247fcdd5269388c23a26f
|