Skip to content

KrushedKnight/Anchor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License


Logo

Anchor

A local-only macOS app that monitors your behavior during focus sessions, detects distraction in real-time, and nudges you back on track.

Website (Coming Soon)
Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Architecture
  5. Roadmap
  6. Contributing
  7. License
  8. Contact
  9. Acknowledgments

About The Project

Most productivity tools just block websites. Anchor takes a different approach — it watches how you work and intervenes only when you're actually drifting.

It tracks your foreground apps, browser tabs, idle state, and window titles to build a real-time picture of your focus quality. When it detects you're slipping — bouncing between apps, lingering on Twitter, passively scrolling — it sends escalating nudges to pull you back.

Key features:

  • Real-time focus scoring — continuously evaluates your work state (deep focus, productive switching, novelty seeking, passive drift, etc.)
  • Smart distraction detection — tracks app switching rates, browser domain hopping, idle time, and off-task dwell with compound signal analysis
  • AI-powered task classification — optionally uses Anthropic, OpenAI, or local Ollama models to classify apps/domains as on-task or off-task for your specific session
  • Works without AI too — ships with 100+ built-in heuristic rules for common apps and domains
  • Escalating interventions — gentle nudges that get firmer the longer you stay off-task, with smart cooldowns and recovery detection
  • Pomodoro & freeform modes — structured timed sessions or flexible open-ended focus blocks with manual breaks
  • Adaptive learning — builds a user profile over time and tunes thresholds to your work style
  • Session analytics — post-session summaries and historical analytics to track your focus trends
  • 100% local — all data stays on your machine. No accounts, no telemetry, no cloud sync.

This is a personal project I built as a student to solve my own focus problems. I'm open-sourcing it because I think others might find it useful too.

(back to top)

How It Works

Observers → EventStore → BehaviorAnalyzer → DriftEngine → InterventionEngine → Notifications
  1. Observers monitor your foreground app, browser tabs, idle state, and window titles
  2. EventStore buffers events in a ring buffer (10k max)
  3. BehaviorAnalyzer consumes events and builds behavioral snapshots (switch rates, dwell times, bouncing patterns)
  4. DriftEngine ticks every 2 seconds, classifying your work state and computing a focus score (0–1)
  5. InterventionEngine applies cooldowns and escalation logic, sending nudges via macOS notifications when you drift

The engine doesn't just look at what app you're in — it tracks how you're using it. Rapidly bouncing between apps? That's stuckCycling. Lingering on Reddit? That's passiveDrift. A quick glance at Discord then back to Xcode? That's fine.

(back to top)

Built With

  • Swift
  • SwiftUI
  • Xcode

(back to top)

Getting Started

Prerequisites

  • macOS 15.0 or later
  • Xcode 16.0 or later

Installation

  1. Clone the repo
    git clone https://github.com/KrushedKnight/Anchor.git
  2. Open the project in Xcode
    cd Anchor
    open Anchor.xcodeproj
  3. Build and run (Cmd + R)

No external dependencies, no package managers, no configuration files. Just clone and build.

Permissions

Anchor needs a few macOS permissions to function — it asks on first launch:

Permission Why
Accessibility Reading window titles via the Accessibility API
Automation (Chrome) Reading the active tab URL from Chrome via AppleScript
Notifications Delivering focus nudges

Anchor's App Sandbox is disabled because CGEventSource (idle detection) and the Accessibility API require it. All data stays local.

(back to top)

Usage

  1. Start a session — give it a task name (e.g., "Finish the auth module") and optionally mark specific apps/domains as on-task or off-task
  2. Work normally — Anchor watches silently, scoring your focus in the floating widget
  3. Get nudged — if you drift, you'll get a gentle notification that escalates if you stay off-task
  4. Review your session — when you end the session, you'll see a summary of your focus score, time on-task, distractions, and more

Modes:

  • Freeform — open-ended session, take manual breaks whenever
  • Pomodoro — timed work/break cycles (configurable durations)

AI classification (optional):

Go to Settings → API and add a key for Anthropic, OpenAI, or configure a local Ollama instance. The app will then classify unfamiliar apps and domains for your specific task context. Without AI, it falls back to 100+ built-in heuristic rules.

(back to top)

Architecture

Data Flow

┌─────────────┐     ┌────────────┐     ┌──────────────────┐     ┌─────────────┐     ┌────────────────────┐
│  Observers   │────▶│ EventStore │────▶│ BehaviorAnalyzer │────▶│ DriftEngine │────▶│ InterventionEngine │
│              │     │            │     │                  │     │             │     │                    │
│ • App        │     │ Ring buffer│     │ Switch rates     │     │ WorkState   │     │ Cooldowns          │
│ • Browser    │     │ (10k max)  │     │ Dwell times      │     │ Focus score │     │ Escalation         │
│ • Idle       │     │            │     │ Idle ratio       │     │ Risk level  │     │ Recovery detection │
│ • Window     │     │            │     │ Bounce detection │     │             │     │                    │
└─────────────┘     └────────────┘     └──────────────────┘     └─────────────┘     └────────┬───────────┘
                                                                                             │
                                                                       ┌─────────────────────┘
                                                                       ▼
                                                              ┌──────────────────┐
                                                              │  Notifications   │
                                                              │  (macOS native)  │
                                                              └──────────────────┘

Module Layout

Anchor/
├── Core/            # Event store, sessions, task classification, user profiles, break/pomodoro
├── Observers/       # App monitor, Chrome tab tracker, idle detector, window title reader
├── Engine/          # Drift detection, behavior analysis, work state machine, risk assessment
├── Intervention/    # Escalation logic, cooldowns, notification delivery, nudge templates
└── Views/           # SwiftUI tabs (Home/Analytics/Settings), floating widget, session summary

Work States

The engine classifies your behavior into one of six states every 2 seconds:

State What it means
Deep Focus Sustained on-task, low switching
Productive Switching On-task with healthy context switching
Stuck Cycling Rapidly bouncing between apps
Novelty Seeking High tab switching, off-task browsing
Passive Drift Lingering off-task without switching
Idle User away

(back to top)

Roadmap

  • Real-time focus scoring and work state detection
  • Escalating intervention pipeline with smart cooldowns
  • AI-powered task classification (Anthropic, OpenAI, Ollama)
  • Heuristic fallback for 100+ apps and domains
  • Pomodoro timer with configurable cycles
  • Session analytics and historical tracking
  • Adaptive user profile tuning
  • Safari and Arc browser support
  • Session tagging and filtering
  • Focus score trends and weekly reports
  • Keyboard shortcut for quick break/resume
  • Exportable session data

See the open issues for a full list of proposed features and known issues.

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Contact

Krishiv Manyam - krishivmanyam@gmail.com

Project Link: https://github.com/KrushedKnight/Anchor

(back to top)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages