|
| 1 | +# WorkflowX — AI Developer Context |
| 2 | + |
| 3 | +## What This Is |
| 4 | +WorkflowX is a workflow intelligence system. It reads events from screen capture tools |
| 5 | +(Screenpipe, ActivityWatch), clusters them into workflow sessions, uses LLMs to infer |
| 6 | +what the user was trying to do, diagnoses friction, generates replacement workflows |
| 7 | +(connected to Agenticom for execution), and measures whether replacements actually work. |
| 8 | +A background daemon runs the full pipeline automatically on a smart schedule. |
| 9 | + |
| 10 | +## Repository Structure |
| 11 | +``` |
| 12 | +src/workflowx/ |
| 13 | +├── models.py # Core Pydantic domain models (the contract) |
| 14 | +├── config.py # Config from env vars / .env |
| 15 | +├── storage.py # Local JSON storage (file-per-day, patterns, outcomes) |
| 16 | +├── export.py # JSON/CSV export for external analysis |
| 17 | +├── measurement.py # Before/after ROI tracking |
| 18 | +├── dashboard.py # HTML ROI dashboard (static snapshot + live server mode) |
| 19 | +├── server.py # Live dashboard HTTP server (GET / and GET /api/data) |
| 20 | +├── daemon.py # Background scheduler — all pipeline stages, smart cadences |
| 21 | +├── notifications.py # macOS native notifications via osascript |
| 22 | +├── mcp_server.py # MCP server for Claude/Cursor integration |
| 23 | +├── capture/ # Adapters for data sources |
| 24 | +│ ├── screenpipe.py # Reads Screenpipe's SQLite DB |
| 25 | +│ └── activitywatch.py # Reads ActivityWatch REST API |
| 26 | +├── inference/ # The intelligence layer |
| 27 | +│ ├── clusterer.py # Groups raw events into workflow sessions |
| 28 | +│ ├── intent.py # LLM-based intent inference + classification questions |
| 29 | +│ ├── reporter.py # Daily/weekly report generation |
| 30 | +│ └── patterns.py # Cross-day pattern detection + friction trends |
| 31 | +├── replacement/ # Workflow replacement engine |
| 32 | +│ └── engine.py # LLM-powered proposals + Agenticom YAML |
| 33 | +├── api/ # FastAPI endpoints (Phase 4) |
| 34 | +└── cli/ # Click CLI — 16 commands |
| 35 | + └── main.py |
| 36 | +``` |
| 37 | + |
| 38 | +## CLI Commands (16 total) |
| 39 | +```bash |
| 40 | +workflowx status # Connection status, storage stats |
| 41 | +workflowx capture # Read events from Screenpipe/ActivityWatch |
| 42 | +workflowx analyze # LLM intent inference on sessions |
| 43 | +workflowx validate # Answer classification questions |
| 44 | +workflowx report # Daily/weekly workflow report |
| 45 | +workflowx propose # Generate replacement proposals |
| 46 | + |
| 47 | +# Phase 2 |
| 48 | +workflowx patterns # Detect recurring high-friction workflows |
| 49 | +workflowx trends # Weekly friction trajectory |
| 50 | +workflowx export # JSON/CSV export |
| 51 | +workflowx mcp # Start MCP server for Claude/Cursor |
| 52 | + |
| 53 | +# Phase 3 |
| 54 | +workflowx adopt # Mark a replacement as adopted, start ROI tracking |
| 55 | +workflowx measure # Measure actual ROI of adopted replacements |
| 56 | +workflowx dashboard # Generate static HTML ROI dashboard |
| 57 | +workflowx serve # Live dashboard server at localhost:7788 (Update button) |
| 58 | +workflowx demo # Full pipeline on synthetic data (no Screenpipe needed) |
| 59 | + |
| 60 | +# Daemon |
| 61 | +workflowx daemon start # Install launchd agent + start (auto-restarts on login) |
| 62 | +workflowx daemon stop # Stop daemon + remove launchd plist |
| 63 | +workflowx daemon status # Job history table + upcoming schedule |
| 64 | +workflowx daemon run # Internal: raw event loop (called by launchd) |
| 65 | +``` |
| 66 | + |
| 67 | +## Daemon Schedule |
| 68 | +``` |
| 69 | +health: every 5 min — Screenpipe liveness; notifies if frames drop |
| 70 | +capture: 12:55·17:55·22:55 — rolls up last 4h of Screenpipe events (every day) |
| 71 | +analyze: 13:00·18:00·23:00 — LLM inference; event-triggers propose on HIGH/CRITICAL |
| 72 | +measure: 07:00 daily — adaptive ROI (weekly ≤30 days, monthly after) |
| 73 | +brief: 08:30 weekdays — morning notification: friction summary + pending actions |
| 74 | +``` |
| 75 | + |
| 76 | +State: `~/.workflowx/daemon_state.json` |
| 77 | +PID: `~/.workflowx/daemon.pid` |
| 78 | +Log: `~/.workflowx/daemon.log` |
| 79 | + |
| 80 | +## Common Dev Commands |
| 81 | +```bash |
| 82 | +make install-dev # Install with all deps + dev tools |
| 83 | +make test # Run all tests with coverage |
| 84 | +make test-fast # Run unit tests only, stop on first failure |
| 85 | +make lint # Ruff + mypy |
| 86 | +make format # Auto-format |
| 87 | +make check # lint + test (run before PR) |
| 88 | +``` |
| 89 | + |
| 90 | +## Architecture Principles |
| 91 | +1. **Don't build capture** — use Screenpipe/ActivityWatch. Our value is intelligence. |
| 92 | +2. **Local-first** — all data stays on device. No cloud requirement. |
| 93 | +3. **Models are the contract** — everything flows through Pydantic models in models.py |
| 94 | +4. **LLM calls are isolated** — only intent.py and engine.py call LLMs |
| 95 | +5. **Daemon logic is pure** — scheduling/trigger functions (next_fire_time, should_measure, |
| 96 | + should_propose) have zero I/O and are 100% unit-testable without asyncio or mocking |
| 97 | +6. **Measure everything** — without before/after ROI, we're just another advice tool |
| 98 | + |
| 99 | +## Testing |
| 100 | +- 134 tests in `tests/unit/` — fast, no external deps, no LLM calls |
| 101 | +- `tests/integration/` — may require Screenpipe DB or LLM API key |
| 102 | +- Always run `make test-fast` before committing |
| 103 | +- Test files: test_models, test_clusterer, test_config, test_storage, test_storage_v2, |
| 104 | + test_reporter, test_patterns, test_measurement, test_export, test_dashboard, test_daemon |
| 105 | + |
| 106 | +## Key Design Decisions |
| 107 | +- **Screenpipe as primary capture**: MIT licensed, 12.6k stars, cross-platform |
| 108 | +- **Session gap = 5 min**: Configurable. >5 min between events = new session |
| 109 | +- **Friction = context switches / minute**: Simple heuristic, validated by user feedback |
| 110 | +- **Classification questions**: When inference confidence < 0.7, ask ONE question |
| 111 | +- **Agenticom integration**: Replacement engine generates workflow YAML |
| 112 | +- **Pattern detection**: Greedy clustering by intent similarity (SequenceMatcher ≥ 0.55) |
| 113 | +- **ROI measurement**: Compare pre-adoption vs post-adoption weekly minutes for same intent |
| 114 | +- **MCP server**: 5 tools (sessions, friction, patterns, trends, roi) via FastMCP |
| 115 | +- **Daemon scheduling**: next_fire_time() scans 8 days forward; weekdays_only=True for |
| 116 | + brief, False for capture/analyze (late-night work happens on weekends too) |
| 117 | +- **Adaptive measure cadence**: weeks_tracked < expected; weekly ≤30d, monthly >30d |
| 118 | +- **Propose dedup**: per session ID, pruned after 30 days |
| 119 | + |
| 120 | +## PR Workflow |
| 121 | +1. Branch from `main` |
| 122 | +2. `make check` must pass |
| 123 | +3. Add tests for new logic |
| 124 | +4. Atomic commits: one concern per commit |
0 commit comments