Skip to content

AI-enhanced Maccy: transforms, MCP server, insights, smart clipboard#1

Open
twitchyvr wants to merge 7 commits intomasterfrom
feat/performance-and-dedup
Open

AI-enhanced Maccy: transforms, MCP server, insights, smart clipboard#1
twitchyvr wants to merge 7 commits intomasterfrom
feat/performance-and-dedup

Conversation

@twitchyvr
Copy link
Copy Markdown
Owner

Summary

Comprehensive enhancement of Maccy from a simple clipboard history tool into an AI-powered clipboard processing platform.

Bug Fixes & Performance

  • Fix off-by-one crash in App Intents (Get, Select, Delete)
  • Fix data race in Vision OCR callback writing to SwiftData model from background thread
  • Graceful database recovery instead of fatalError on corrupt SQLite
  • Cache compiled regexes in clipboard ignore check (was recompiling every 0.5s)
  • Prompt user for accessibility permissions instead of silent no-op
  • SHA-256 content hashing for O(1) deduplication (replaces O(n*m) full table scan)

Paste Transforms (17 built-in)

Type : in search to access: :json, :trim, :upper, :lower, :title, :1line, :noutm (strip UTM tracking), :urlencode/:urldecode, :b64enc/:b64dec, :escape/:unescape, :sort, :uniq, :count, :rev, :md2txt

AI Transforms (Claude API)

Type :ai <instruction> for natural language clipboard transformation:

  • :ai summarize in 3 bullets
  • :ai translate to Spanish
  • :ai explain this code
  • :ai rewrite as professional email

Clipboard Intelligence

  • Auto-categorization: URL, Code, Email, Color, File Path, Phone, Number, Image, File, Text
  • Item metadata: category icons, copy count badges, relative timestamps in clipboard list
  • Smart suggestions: contextual banners ("You copied X 8 times. Pin it?")
  • Search by app/category: type "Chrome" or "URL" to filter

Insights Dashboard

New "Insights" tab in Preferences with Swift Charts:

  • Content type donut chart
  • App usage bar chart
  • Hourly activity chart
  • Most-copied items with counts

Multi-Select & Paste Stack

Enabled the fully-built but disabled multi-selection feature. Cmd+Click to select multiple items, paste sequentially.

MCP Server (10 tools)

Node.js MCP server exposing clipboard to AI agents via JSON-RPC 2.0:

  • clipboard_read/write — system clipboard access
  • clipboard_history/search/pinned/stats — Maccy database queries
  • clipboard_transform — 19 text transforms
  • clipboard_ai — Claude-powered transformation
  • clipboard_context — structured work context from clipboard history
  • clipboard_watch — monitor recent clipboard changes

Registered with Claude Code (~/.claude.json) and Overlord-v2 (mcp-servers.json).

Test plan

  • Copy various content types (URLs, code, text, images) — verify auto-categorization
  • Type :json with JSON on clipboard — verify pretty-print and paste
  • Type :ai summarize — verify Claude API call and result paste
  • Open Preferences > Insights — verify charts render
  • Cmd+Click multiple items — verify paste stack sequential paste
  • Search "Chrome" — verify app name search works
  • Verify MCP server responds: echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' | node mcp-server/dist/index.js
  • Restart Claude Code — verify clipboard_read tool works

Commits (7)

  1. fix: critical bugs and performance improvements
  2. feat: clipboard intelligence — auto-categorization, insights dashboard, filter chips
  3. feat: multi-select, item metadata, and app/category search
  4. feat: paste transforms, smart suggestions, and rich preview
  5. feat: MCP server for AI agent clipboard access
  6. feat: AI-powered clipboard transforms via Claude API
  7. docs: add FORK.md, MCP server README, and code documentation

Related

🤖 Generated with Claude Code

twitchyvr and others added 7 commits March 22, 2026 03:17
- Fix off-by-one crash in App Intents (Get, Select, Delete)
  that would crash when requesting the last item by index
- Add SHA-256 content hashing for O(1) dedup instead of O(n*m)
  full table scan on every clipboard copy
- Cache compiled regexes in Clipboard.shouldIgnore() to avoid
  recompilation on every 0.5s poll cycle
- Fix data race in Vision OCR callback writing to @model from
  background thread — dispatch to main queue
- Graceful database recovery instead of fatalError on corrupt
  SQLite — attempts re-creation before crashing
- Fix Accessibility.check() silent no-op — now prompts user for
  permissions and gates paste functionality on approval

Co-Authored-By: Claude <noreply@anthropic.com>
…d, filter chips

- Add ContentCategory enum with automatic detection of clipboard content
  types: URLs, code, emails, colors, file paths, phone numbers, images,
  files, and plain text. Uses heuristic pattern matching (regex + code
  structure analysis) with zero user effort required.

- Add InsightsView — a new "Insights" Settings pane with:
  - Overview cards: total items, total copies, duplicate rate, apps used
  - Content type donut chart (Swift Charts)
  - App usage horizontal bar chart (which apps you copy from most)
  - Hourly activity chart (when you copy most during the day)
  - Top 10 most-copied items with copy count badges

- Add CategoryFilterView with filter chips UI component for future
  integration into the main clipboard popup (All, URLs, Code, etc.)

- Wire auto-categorization into Clipboard.checkForChangesInPasteboard()
  so every new clipboard entry is categorized on capture

- Add category field to HistoryItem SwiftData model

Co-Authored-By: Claude <noreply@anthropic.com>
Enable multi-selection + paste stack:
- Flip multiSelectionEnabled to true — the entire feature was already
  built but permanently disabled. Cmd+click to select multiple items,
  then paste them sequentially as a stack.

Add item metadata display in clipboard list:
- Category icons (link, code, envelope, etc.) shown inline
- Copy count badges ("3×") for items copied more than once
- Relative timestamps ("2m", "1h", "3d") showing when last copied
- All gated behind new "Show item metadata" toggle in Appearance settings

Expand search to match app names and categories:
- Typing "Chrome" now finds all items copied from Chrome
- Typing "URL" or "Code" finds items by auto-detected category
- Falls through to title search first, then app, then category

Co-Authored-By: Claude <noreply@anthropic.com>
Paste Transforms — type ":" in search to access 17 built-in transforms:
- :json / :json1 — pretty-print or minify JSON
- :upper / :lower / :title — case conversion
- :trim / :1line — whitespace cleanup
- :noutm — strip UTM tracking params from URLs
- :urlencode / :urldecode — URL encoding
- :b64enc / :b64dec — Base64 encode/decode
- :escape / :unescape — escape special characters
- :sort / :uniq — sort or deduplicate lines
- :count — character/word/line count
- :rev — reverse text
- :md2txt — strip Markdown formatting

Transform suggestions appear as a visual menu when typing ":"
with icons, commands, and descriptions. Selecting a transform
applies it to the currently selected clipboard item and pastes.

Smart Suggestions — contextual banners shown at popup open:
- Pin suggestions: "You've copied X 8 times. Pin it?" with action
- Rotating tips about paste transforms, multi-select, search features
- Dismissable with X button, regenerates each popup open

Rich Preview enhancements:
- Category badge with icon (purple capsule) in preview sidebar
- Color swatch for color entries (rendered as 20x20 block)
- Content stats: character count, word count, line count
- All shown above the existing metadata

Co-Authored-By: Claude <noreply@anthropic.com>
Add a full MCP (Model Context Protocol) server that exposes Maccy's
clipboard history to AI agents over stdio JSON-RPC 2.0.

Tools exposed:
  - clipboard_read      — Read current system clipboard (pbpaste)
  - clipboard_write     — Write to system clipboard (pbcopy)
  - clipboard_history   — Get recent history with metadata
  - clipboard_search    — Search by title, app name, or category
  - clipboard_pinned    — Get all pinned items
  - clipboard_stats     — Usage statistics (totals, app breakdown,
                          category distribution, most-copied items)
  - clipboard_transform — Apply 17 paste transforms server-side
                          (json, trim, upper, strip_utm, b64, etc.)

The server reads Maccy's SwiftData SQLite database directly
(~/Library/Application Support/Maccy/Storage.sqlite) in read-only
mode. Write operations use /usr/bin/pbcopy and /usr/bin/pbpaste
via execFileSync (no shell, no injection risk).

Handles SwiftData schema detection (Z-prefixed vs plain columns)
and NSDate epoch conversion (2001-01-01 reference).

Registered with:
  - Claude Code (~/.claude.json mcpServers)
  - Overlord-v2 (mcp-servers.json)

Co-Authored-By: Claude <noreply@anthropic.com>
In-app AI transforms (Swift):
- Type `:ai <instruction>` in the Maccy search field
- Works with any natural language instruction:
  ":ai summarize in 3 bullets"
  ":ai translate to Spanish"
  ":ai explain this code"
  ":ai rewrite as professional email"
  ":ai fix grammar"
  ":ai add TypeScript types"
- Shows processing indicator while Claude responds
- Result is copied to clipboard and pasted automatically
- API key from ANTHROPIC_API_KEY env var or ~/.anthropic/api_key

Regular transforms now triggered from Return key:
- Typing `:json` and pressing Return applies the transform directly
- No need to click the suggestion — keyboard-first workflow

MCP server AI tools (Node.js):
- clipboard_ai: AI transform with copy_result option for agents
- clipboard_context: Structured context digest from clipboard
  history (grouped by app, category, with pinned items)
- clipboard_watch: Monitor clipboard changes since timestamp

Total MCP tools now: 10 (was 7)

Co-Authored-By: Claude <noreply@anthropic.com>
- FORK.md: comprehensive overview of all custom features, build
  instructions, and differences from upstream
- mcp-server/README.md: tool reference, setup guide for Claude Code
  and Overlord-v2, architecture diagram, usage examples
- ContentCategory.swift: docstring explaining the auto-categorization
  system and where categories are consumed

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant