Skill: poiley/findmy-location (version 1.1.1)

--- name: findmy-location description: Track a shared contact's location via Apple Find My with street-level accuracy. Returns address, city, and context (home/work/out) by reading map landmarks. Supports configurable known locations and vision fallback for unknown places. --- # Find My Location Track shared contacts via Apple Find My with street-corner accuracy. ## Requirements - **macOS** 13+ with Find My app - **Python** 3.9+ - **iCloud account** signed in on your Mac (for Find My access) - **Location sharing** enabled from the contact you want to track - **peekaboo** - screen reading CLI ([GitHub](https://github.com/steipete/peekaboo)) - **Hammerspoon** (optional) - for reliable UI clicking ([hammerspoon.org](https://www.hammerspoon.org/)) ## Prerequisites ### 1. iCloud & Find My Setup Your Mac must be signed into an iCloud account with Find My enabled: - System Settings → Apple ID → iCloud → Find My Mac (enabled) - The person you want to track must share their location with this iCloud account via Find My ### 2. Install peekaboo ```bash brew install steipete/tap/peekaboo ``` Grant **Accessibility** and **Screen Recording** permissions when prompted (System Settings → Privacy & Security). ### 3. Install Hammerspoon (optional but recommended) Hammerspoon provides reliable clicking that works across all apps. Without it, clicks may occasionally go to the wrong window. ```bash brew install hammerspoon open -a Hammerspoon ``` Add to `~/.hammerspoon/init.lua`: ```lua local server = hs.httpserver.new(false, false) server:setPort(9090) server:setCallback(function(method, path, headers, body) local data = body and hs.json.decode(body) or {} if path == "/click" then hs.eventtap.leftClick({x=data.x, y=data.y}) return hs.json.encode({status="clicked", x=data.x, y=data.y}), 200, {} end return hs.json.encode({error="not found"}), 404, {} end) server:start() ``` Reload config (Hammerspoon menu → Reload Config), then create `~/.local/bin/hsclick`: ```bash #!/bin/bash curl -s -X POST localhost:9090/click -d "{\"x\":$2,\"y\":$3}" chmod +x ~/.local/bin/hsclick ``` ## Installation ```bash git clone https://github.com/poiley/findmy-location.git cd findmy-location ./install.sh ``` Or via ClawdHub: ```bash clawdhub install findmy-location ``` ## Configuration Create `~/.config/findmy-location/config.json`: ```json { "target": "John", "known_locations": [ { "name": "home", "address": "123 Main St, City, ST", "markers": ["landmark near home"] }, { "name": "work", "address": "456 Office Blvd, City, ST", "markers": ["landmark near work"] } ] } ``` | Field | Description | |-------|-------------| | `target` | Contact name to track (optional - defaults to first shared contact) | | `known_locations` | Array of places you want labeled with addresses | | `markers` | Landmarks visible on the Find My map when at that location | ## Usage ```bash findmy-location # Human-readable output findmy-location --json # JSON output ``` ### Example Output ``` 123 Main St, City, ST (home) - Now ``` ```json { "person": "[REDACTED_SECRET]", "address": "Main St & 1st Ave", "city": "Anytown", "state": "WA", "status": "Now", "context": "out", "screenshot": "/tmp/findmy-12345.png", "needs_vision": false } ``` | Field | Description | |-------|-------------| | `context` | `home`, `work`, `out`, or `unknown` | | `needs_vision` | If `true`, use AI vision on screenshot to read street names | | `screenshot` | Path to captured map image | ## How It Works 1. Opens Find My app and selects target contact 2. Captures map and reads accessibility data 3. Matches visible landmarks against configured known locations 4. Returns address and context, or flags for vision analysis ## Troubleshooting | Issue | Solution | |-------|----------| | Clicks go to wrong window | Install Hammerspoon (see prerequisites) | | "No person found" | Ensure location sharing is enabled in Find My | | Always shows `needs_vision: true` | Add markers for frequently visited places | | Permission errors | Grant peekaboo Accessibility + Screen Recording access | ## License MIT

path: README.md
content: ---
name: findmy-location
description: Track a shared contact's location via Apple Find My with street-level accuracy. Returns address, city, and context (home/work/out) by reading map landmarks. Supports configurable known locations and vision fallback for unknown places.
---

# Find My Location

Track shared contacts via Apple Find My with street-corner accuracy.

## Requirements

- **macOS** 13+ with Find My app
- **Python** 3.9+
- **iCloud account** signed in on your Mac (for Find My access)
- **Location sharing** enabled from the contact you want to track
- **peekaboo** - screen reading CLI ([GitHub](https://github.com/steipete/peekaboo))
- **Hammerspoon** (optional) - for reliable UI clicking ([hammerspoon.org](https://www.hammerspoon.org/))

## Prerequisites

### 1. iCloud & Find My Setup

Your Mac must be signed into an iCloud account with Find My enabled:
- System Settings → Apple ID → iCloud → Find My Mac (enabled)
- The person you want to track must share their location with this iCloud account via Find My

### 2. Install peekaboo

```bash
brew install steipete/tap/peekaboo
```

Grant **Accessibility** and **Screen Recording** permissions when prompted (System Settings → Privacy & Security).

### 3. Install Hammerspoon (optional but recommended)

Hammerspoon provides reliable clicking that works across all apps. Without it, clicks may occasionally go to the wrong window.

```bash
brew install hammerspoon
open -a Hammerspoon
```

Add to `~/.hammerspoon/init.lua`:
```lua
local server = hs.httpserver.new(false, false)
server:setPort(9090)
server:setCallback(function(method, path, headers, body)
    local data = body and hs.json.decode(body) or {}
    if path == "/click" then
        hs.eventtap.leftClick({x=data.x, y=data.y})
        return hs.json.encode({status="clicked", x=data.x, y=data.y}), 200, {}
    end
    return hs.json.encode({error="not found"}), 404, {}
end)
server:start()
```

Reload config (Hammerspoon menu → Reload Config), then create `~/.local/bin/hsclick`:
```bash
#!/bin/bash
curl -s -X POST localhost:9090/click -d "{\"x\":$2,\"y\":$3}"
chmod +x ~/.local/bin/hsclick
```

## Installation

```bash
git clone https://github.com/poiley/findmy-location.git
cd findmy-location
./install.sh
```

Or via ClawdHub:
```bash
clawdhub install findmy-location
```

## Configuration

Create `~/.config/findmy-location/config.json`:
```json
{
  "target": "John",
  "known_locations": [
    {
      "name": "home",
      "address": "123 Main St, City, ST",
      "markers": ["landmark near home"]
    },
    {
      "name": "work",
      "address": "456 Office Blvd, City, ST",
      "markers": ["landmark near work"]
    }
  ]
}
```

| Field | Description |
|-------|-------------|
| `target` | Contact name to track (optional - defaults to first shared contact) |
| `known_locations` | Array of places you want labeled with addresses |
| `markers` | Landmarks visible on the Find My map when at that location |

## Usage

```bash
findmy-location          # Human-readable output
findmy-location --json   # JSON output
```

### Example Output

```
123 Main St, City, ST (home) - Now
```

```json
{
  "person": "[REDACTED_SECRET]",
  "address": "Main St & 1st Ave",
  "city": "Anytown",
  "state": "WA",
  "status": "Now",
  "context": "out",
  "screenshot": "/tmp/findmy-12345.png",
  "needs_vision": false
}
```

| Field | Description |
|-------|-------------|
| `context` | `home`, `work`, `out`, or `unknown` |
| `needs_vision` | If `true`, use AI vision on screenshot to read street names |
| `screenshot` | Path to captured map image |

## How It Works

1. Opens Find My app and selects target contact
2. Captures map and reads accessibility data
3. Matches visible landmarks against configured known locations
4. Returns address and context, or flags for vision analysis

## Troubleshooting

| Issue | Solution |
|-------|----------|
| Clicks go to wrong window | Install Hammerspoon (see prerequisites) |
| "No person found" | Ensure location sharing is enabled in Find My |
| Always shows `needs_vision: true` | Add markers for frequently visited places |
| Permission errors | Grant peekaboo Accessibility + Screen Recording access |

## License

MIT


path: findmy-location.py
content: #!/usr/bin/env python3
"""Find My location tracker with street-corner accuracy."""
import subprocess
import json
import re
import os
import sys

CONFIG_PATH = os.path.expanduser("~/.config/findmy-location/config.json")
DEFAULT_CONFIG = {
    "target": None,
    "known_locations": []
}

def run(cmd):
    return subprocess.run(cmd, shell=True, capture_output=True, text=True).stdout.strip()

def load_config():
    if os.path.exists(CONFIG_PATH):
        with open(CONFIG_PATH) as f:
            return {**DEFAULT_CONFIG, **json.load(f)}
    return DEFAULT_CONFIG

def get_target_name(config):
    """Get target name from config or USER.md."""
    if config.get("target"):
        return config["target"]
    
    # Try common USER.md locations
    for path in ["~/clawd/USER.md", "~/USER.md", "./USER.md"]:
        user_md = os.path.expanduser(path)
        if os.path.exists(user_md):
            with open(user_md) as f:
                content = f.read()
                m = re.search(r'\*\*(?:Name|What to call them)\*\*:\s*(\w+)', content)
                if m:
                    return m.group(1)
    return None

def find_hsclick():
    """Find hsclick script in common locations."""
    for path in ["~/clawd/scripts/hsclick", "~/.local/bin/hsclick", "/usr/local/bin/hsclick"]:
        expanded = os.path.expanduser(path)
        if os.path.exists(expanded):
            return expanded
    return None

def find_location(config):
    target = get_target_name(config)
    
    # Start Find My
    run('open -a "Find My"')
    run('sleep 0.5')
    run('osascript -e \'tell app "System Events" to set frontmost of process "Find My" to true\'')
    run('sleep 0.3')
    
    # Get window position
    win_json = run('peekaboo list windows --app "Find My" --json 2>/dev/null')
    try:
        win = json.loads(win_json)
        bounds = win.get('data', {}).get('windows', [{}])[0].get('bounds', [[0, 0]])[0]
        wx, wy = bounds[0], bounds[1]
    except:
        wx, wy = 0, 0
    
    # Click on second row (first shared contact)
    hsclick = find_hsclick()
    click_x, click_y = wx + 120, wy + 173
    
    if hsclick:
        run(f'{hsclick} click {click_x} {click_y}')
    else:
        run(f'peekaboo click --coords {click_x},{click_y} --app "Find My" 2>/dev/null')
    run('sleep 1')
    
    # Get accessibility data
    see = run('peekaboo see --app "Find My" --json 2>/dev/null')
    img = f"/tmp/findmy-{os.getpid()}.png"
    run(f'peekaboo image --mode screen --screen-index 0 --path {img} 2>/dev/null')
    
    result = {
        "person": None,
        "address": None,
        "city": None,
        "state": None,
        "status": None,
        "context": "unknown",
        "screenshot": img,
        "needs_vision": False
    }
    
    try:
        data = json.loads(see).get('data', {}) if see else {}
    except:
        data = {}
    
    landmarks = []
    
    def extract(obj):
        if isinstance(obj, dict):
            desc = (obj.get('description', '') or obj.get('label', '')).lower()
            landmarks.append(desc)
            
            # Extract person info
            raw = obj.get('description', '') or ''
            m = re.search(r'([\w.@]+@[\w.]+),\s*([^,]+),\s*(\w{2})\s*[,•]\s*(\w+)', raw)
            if m and not result['person']:
                result['person'] = m.group(1)
                result['city'] = m.group(2).strip()
                result['state'] = m.group(3)
                result['status'] = m.group(4).strip()
            
            for v in obj.values():
                extract(v)
        elif isinstance(obj, list):
            for i in obj:
                extract(i)
    
    extract(data)
    all_text = ' '.join(landmarks)
    
    # Check known locations from config
    for loc in config.get('known_locations', []):
        markers = [m.lower() for m in loc.get('markers', [])]
        if any(m in all_text for m in markers):
            result['address'] = loc.get('address')
            result['context'] = loc.get('name', 'known')
            break
    
    # If no known location matched, flag for vision analysis
    if not result['address']:
        result['needs_vision'] = True
        result['context'] = 'out'
    
    return result

def main():
    config = load_config()
    result = find_location(config)
    
    if '--json' in sys.argv:
        print(json.dumps(result))
    elif result.get('needs_vision'):
        print(f"VISION_NEEDED:{result['screenshot']}")
    else:
        addr = result.get('address') or f"{result['city']}, {result['state']}"
        ctx = result.get('context', 'unknown')
        status = result.get('status', '')
        print(f"{addr} ({ctx}) - {status}")

if __name__ == '__main__':
    main()


path: install.sh
content: #!/bin/bash
set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BIN_DIR="$HOME/.local/bin"

mkdir -p "$BIN_DIR"
mkdir -p "$HOME/.config/findmy-location"

# Link the script
ln -sf "$SCRIPT_DIR/findmy-location.py" "$BIN_DIR/findmy-location"

# Create default config if not exists
if [ ! -f "$HOME/.config/findmy-location/config.json" ]; then
    cat > "$HOME/.config/findmy-location/config.json" << 'CONFIG'
{
  "target": null,
  "known_locations": []
}
CONFIG
    echo "Created default config at ~/.config/findmy-location/config.json"
    echo "Edit it to add your target contact and known locations."
fi

echo "Installed findmy-location to $BIN_DIR"
echo "Make sure $BIN_DIR is in your PATH"


Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: suspicious | SkillSpector: suspicious (CRITICAL)