Skip to content
amroessamPublic

About

macOS menu bar app for capturing text snippets and generating AI summaries using local LLM (Ollama). Privacy-first, fully local, with multiple context management.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Cntxtr - macOS AI Workflow Assistant

A native Swift/SwiftUI menu bar app for capturing text snippets from any application and using a local LLM (Ollama) for context-aware summarization. Organize snippets into multiple contexts, edit them, and generate AI summaries—all running locally on your machine with no cloud dependencies.

Features

  • Text Capture: Capture text snippets from any app using global keyboard shortcuts
    • Capture Selection (⌥⌘E): Captures selected text without modifying clipboard
    • Copy & Capture (⌥⌘T): Copies to clipboard AND adds to context
  • Multiple Contexts: Organize snippets into named contexts (e.g., "Feature PR", "Research Notes", "Meeting Notes")
  • Context Management:
    • Switch between contexts with keyboard shortcut
    • Context menu actions: Save to file, Summarize & Copy, Clear snippets
    • Menu bar icon shows current context number
  • Local AI Integration:
    • Uses Ollama for local LLM inference
    • Generate structured summaries of captured snippets
    • Customizable system prompts
    • Configurable response length limits
  • Snippet Management:
    • Edit snippets inline
    • Delete individual snippets
    • Clear all snippets from a context
    • Auto-delete empty snippets
  • Privacy-First: All data stays on your machine, no cloud services

Requirements

  • macOS 13.0+ (Ventura)
  • Xcode 14.0+
  • Swift 5.9+
  • Ollama installed and running locally

Installation

Prerequisites

  1. Install Ollama:

    brew install ollama
    # or download from https://ollama.ai
  2. Start Ollama service:

    ollama serve
  3. Download a model (optional, can be done through the app):

    ollama pull phi3:mini
    # or any other model you prefer

Building from Source

  1. Clone the repository:

    git clone <repository-url>
    cd cntxtr
  2. Open the project in Xcode:

    open cntxtr.xcodeproj
  3. Build and run:

    • Select the Cntxtr scheme
    • Press ⌘R to build and run
  4. On first launch:

    • Grant Accessibility permissions when prompted
    • Configure keyboard shortcuts
    • Download a model through the Preferences panel

Usage

First Launch

  1. Complete the onboarding flow to:
    • Grant Accessibility permissions (required for text capture)
    • Configure keyboard shortcuts
    • Download your first LLM model

Capturing Text

  1. Select text in any application
  2. Press ⌥⌘E to capture selected text (doesn't modify clipboard)
    • OR press ⌥⌘T to copy to clipboard AND capture
  3. The snippet is added to your current context with metadata (source app, timestamp)

Managing Contexts

  • Switch Contexts: Press ⌥⌘[ to cycle to the next context
  • Create New Context: Click the menu bar icon → "New Context..."
  • Context Menu: Right-click any context in the menu for:
    • Save to File: Export all snippets to a text file
    • Summarize & Copy: Generate AI summary and copy to clipboard
    • Clear Snippets: Remove all snippets (with confirmation)

AI Features

  1. Open AI Panel: Click menu bar icon → "Open Cntxtr..."
  2. View Snippets: See all captured snippets for the current context
  3. Generate Summary: Click "Generate Summary" to create an AI-powered summary
  4. Edit Snippets: Click any snippet to edit its content
  5. Delete Snippets: Click the delete button on any snippet

Keyboard Shortcuts

Shortcut Action
⌥⌘E Capture selected text (without clipboard)
⌥⌘T Copy & Capture (copies to clipboard AND adds to context)
⌥⌘[ Cycle to next context
⌥⌘S Summarize current context & copy to clipboard

All shortcuts can be customized in Preferences.

Configuration

System Prompt

Customize the AI's behavior by setting a custom system prompt in Preferences → AI Settings. The default prompt is optimized for context summarization.

Response Length

Limit AI response length by setting "Max Response Tokens" in Preferences → AI Settings. Default: 500 tokens.

Model Management

  • Add Models: Enter any Ollama model name in Preferences → Model Settings
  • Pull Models: Download new models directly from the app
  • Switch Models: Select from downloaded models in the dropdown

Permissions

Cntxtr requires Accessibility permissions to capture text from other applications. This permission is:

  • Requested during onboarding
  • Required for the "Capture Selection" shortcut
  • Can be granted in System Settings → Privacy & Security → Accessibility

Project Structure

Cntxtr/
├── Cntxtr/                    # App target
│   ├── App/
│   │   ├── CntxtrApp.swift
│   │   ├── MenuBarController.swift
│   │   └── WindowManager.swift
│   ├── Assets.xcassets/       # App icon and logo assets
│   ├── UI/
│   │   ├── MenuBarView.swift
│   │   ├── ContextListView.swift
│   │   ├── AIPanelView.swift
│   │   ├── PreferencesView.swift
│   │   ├── OnboardingView.swift
│   │   └── ToastView.swift
│   └── Shortcuts/
│       └── ShortcutManager.swift
├── CntxtrCore/                # Swift Package
│   ├── Models/
│   │   ├── Context.swift
│   │   └── Snippet.swift
│   ├── Persistence/
│   │   ├── PersistenceController.swift
│   │   └── CntxtrModel.xcdatamodeld/
│   ├── Services/
│   │   ├── ContextService.swift
│   │   ├── SnippetService.swift
│   │   ├── ClipboardManager.swift
│   │   └── AccessibilityService.swift
│   └── Llm/
│       ├── OllamaService.swift
│       ├── ModelManager.swift
│       └── PromptTemplates.swift
└── Scripts/
    ├── build_dmg.sh
    └── sign_and_notarize.sh

Architecture

  • SwiftUI + AppKit: Native macOS UI with menu bar integration
  • Core Data: Local persistence for contexts and snippets
  • Ollama API: HTTP-based integration with local Ollama service
  • Accessibility API: Direct text selection capture from any app
  • Swift Package Manager: Modular architecture with CntxtrCore package

Development

Running Tests

# Run all tests
xcodebuild test -scheme Cntxtr -destination 'platform=macOS'

# Or use Xcode: ⌘U

Distribution

Signing and Notarization

  1. Archive the app in Xcode (Product > Archive)
  2. Export the archive
  3. Run the signing script:
    ./Scripts/sign_and_notarize.sh path/to/Cntxtr.app

Creating DMG

./Scripts/build_dmg.sh 1.0.0

Troubleshooting

Text Capture Not Working

  1. Ensure Accessibility permissions are granted in System Settings
  2. Restart the app after granting permissions
  3. Check that Ollama is running: ollama list

AI Summary Not Generating

  1. Verify Ollama is running: ollama serve
  2. Check that a model is downloaded: ollama list
  3. Verify model name in Preferences matches downloaded model
  4. Check Console.app for error logs

App Not Appearing in App Switcher

The app appears in the app switcher (⌘⇥) when windows are open. If no windows are open, it runs as a menu bar-only app.

License

See LICENSE.md for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Acknowledgments

About

macOS menu bar app for capturing text snippets and generating AI summaries using local LLM (Ollama). Privacy-first, fully local, with multiple context management.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages