AI Newsletter Digest improvements: fixed QP soft line break decoding, URL extraction, and content cleaning
This commit is contained in:
Submodule
+1
Submodule skills/LobsterBoard added at 1169358570
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"version": 1,
|
||||
"registry": "https://clawhub.ai",
|
||||
"slug": "accli",
|
||||
"installedVersion": "1.0.0",
|
||||
"installedAt": 1770184131517
|
||||
}
|
||||
@@ -1,209 +0,0 @@
|
||||
---
|
||||
name: accli
|
||||
description: This skill should be used when interacting with Apple Calendar on macOS. Use it for listing calendars, viewing events, creating/updating/deleting calendar events, and checking availability/free-busy times. Triggers on requests like "check my calendar", "schedule a meeting", "what's on my schedule", "am I free tomorrow", or any calendar-related operations.
|
||||
---
|
||||
|
||||
# Apple Calendar CLI (accli)
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install -g @joargp/accli
|
||||
```
|
||||
|
||||
**Requirements:** macOS only (uses JavaScript for Automation)
|
||||
|
||||
## Overview
|
||||
|
||||
The accli tool provides command-line access to macOS Apple Calendar. It enables listing calendars, querying events, creating/updating/deleting events, and checking availability across calendars.
|
||||
|
||||
## Quick Reference
|
||||
|
||||
### DateTime Formats
|
||||
- Timed events: YYYY-MM-DDTHH:mm or YYYY-MM-DDTHH:mm:ss
|
||||
- All-day events: YYYY-MM-DD
|
||||
|
||||
### Global Options
|
||||
- --json - Output as JSON (recommended for parsing)
|
||||
- --help - Show help for any command
|
||||
|
||||
## Commands
|
||||
|
||||
### List Calendars
|
||||
|
||||
```
|
||||
accli calendars [--json]
|
||||
```
|
||||
|
||||
Lists all available calendars with names and persistent IDs. Run this first to discover available calendars and their IDs.
|
||||
|
||||
### List Events
|
||||
|
||||
```
|
||||
accli events <calendarName> [options]
|
||||
```
|
||||
|
||||
Options:
|
||||
- --calendar-id <id> - Persistent calendar ID (recommended over name)
|
||||
- --from <datetime> - Start of range (default: now)
|
||||
- --to <datetime> - End of range (default: from + 7 days)
|
||||
- --max <n> - Maximum events to return (default: 50)
|
||||
- --query <q> - Case-insensitive filter on summary/location/description
|
||||
- --json - Output JSON
|
||||
|
||||
Examples:
|
||||
|
||||
```bash
|
||||
# Events from Work calendar for this week
|
||||
accli events Work --json
|
||||
|
||||
# Events in January
|
||||
accli events Work --from 2025-01-01 --to 2025-01-31 --json
|
||||
|
||||
# Search for specific events
|
||||
accli events Work --query "standup" --max 10 --json
|
||||
```
|
||||
|
||||
### Get Single Event
|
||||
|
||||
```
|
||||
accli event <calendarName> <eventId> [--json]
|
||||
```
|
||||
|
||||
Retrieves details for a specific event by its ID.
|
||||
|
||||
### Create Event
|
||||
|
||||
```
|
||||
accli create <calendarName> --summary <s> --start <datetime> --end <datetime> [options]
|
||||
```
|
||||
|
||||
Required Options:
|
||||
- --summary <s> - Event title
|
||||
- --start <datetime> - Start time
|
||||
- --end <datetime> - End time
|
||||
|
||||
Optional:
|
||||
- --location <l> - Event location
|
||||
- --description <d> - Event description
|
||||
- --all-day - Create an all-day event
|
||||
- --json - Output JSON
|
||||
|
||||
Examples:
|
||||
|
||||
```bash
|
||||
# Create a timed meeting
|
||||
accli create Work --summary "Team Standup" --start 2025-01-15T09:00 --end 2025-01-15T09:30 --json
|
||||
|
||||
# Create an all-day event
|
||||
accli create Personal --summary "Vacation" --start 2025-07-01 --end 2025-07-05 --all-day --json
|
||||
|
||||
# Create with location and description
|
||||
accli create Work --summary "Client Meeting" --start 2025-01-15T14:00 --end 2025-01-15T15:00 \
|
||||
--location "Conference Room A" --description "Q1 planning discussion" --json
|
||||
```
|
||||
|
||||
### Update Event
|
||||
|
||||
```
|
||||
accli update <calendarName> <eventId> [options]
|
||||
```
|
||||
|
||||
Options (all optional - only provide what to change):
|
||||
- --summary <s> - New title
|
||||
- --start <datetime> - New start time
|
||||
- --end <datetime> - New end time
|
||||
- --location <l> - New location
|
||||
- --description <d> - New description
|
||||
- --all-day - Convert to all-day event
|
||||
- --no-all-day - Convert to timed event
|
||||
- --json - Output JSON
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
accli update Work event-id-123 --summary "Updated Meeting Title" --start 2025-01-15T15:00 --end 2025-01-15T16:00 --json
|
||||
```
|
||||
|
||||
### Delete Event
|
||||
|
||||
```
|
||||
accli delete <calendarName> <eventId> [--json]
|
||||
```
|
||||
|
||||
Permanently deletes an event. Confirm with user before executing.
|
||||
|
||||
### Check Free/Busy
|
||||
|
||||
```
|
||||
accli freebusy --calendar <name> --from <datetime> --to <datetime> [options]
|
||||
```
|
||||
|
||||
Options:
|
||||
- --calendar <name> - Calendar name (can repeat for multiple calendars)
|
||||
- --calendar-id <id> - Persistent calendar ID (can repeat)
|
||||
- --from <datetime> - Start of range (required)
|
||||
- --to <datetime> - End of range (required)
|
||||
- --json - Output JSON
|
||||
|
||||
Shows busy time slots, excluding cancelled, declined, and transparent events.
|
||||
|
||||
Examples:
|
||||
|
||||
```bash
|
||||
# Check availability across calendars
|
||||
accli freebusy --calendar Work --calendar Personal --from 2025-01-15 --to 2025-01-16 --json
|
||||
|
||||
# Check specific hours
|
||||
accli freebusy --calendar Work --from 2025-01-15T09:00 --to 2025-01-15T18:00 --json
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
```bash
|
||||
# Set default calendar (interactive)
|
||||
accli config set-default
|
||||
|
||||
# Set default by name
|
||||
accli config set-default --calendar Work
|
||||
|
||||
# Show current config
|
||||
accli config show
|
||||
|
||||
# Clear default
|
||||
accli config clear
|
||||
```
|
||||
|
||||
When a default calendar is set, commands automatically use it if no calendar is specified.
|
||||
|
||||
## Workflow Guidelines
|
||||
|
||||
### Before Creating Events
|
||||
1. List calendars to get available calendar names/IDs
|
||||
2. Check free/busy to find available time slots
|
||||
3. Confirm event details with user before creating
|
||||
|
||||
### Best Practices
|
||||
- Always use --json flag for programmatic parsing
|
||||
- Prefer --calendar-id over calendar names for reliability
|
||||
- When querying events, start with reasonable date ranges
|
||||
- Confirm with user before delete operations
|
||||
- Use ISO 8601 datetime format consistently
|
||||
|
||||
### Common Patterns
|
||||
|
||||
Find a free slot and schedule:
|
||||
|
||||
```bash
|
||||
# 1. Check availability
|
||||
accli freebusy --calendar Work --from 2025-01-15T09:00 --to 2025-01-15T18:00 --json
|
||||
|
||||
# 2. Create event in available slot
|
||||
accli create Work --summary "Meeting" --start 2025-01-15T14:00 --end 2025-01-15T15:00 --json
|
||||
```
|
||||
|
||||
View today's schedule:
|
||||
|
||||
```bash
|
||||
accli events Work --from $(date +%Y-%m-%d) --to $(date -v+1d +%Y-%m-%d) --json
|
||||
```
|
||||
@@ -3,5 +3,5 @@
|
||||
"registry": "https://clawhub.ai",
|
||||
"slug": "agent-browser",
|
||||
"installedVersion": "0.2.0",
|
||||
"installedAt": 1771339837990
|
||||
"installedAt": 1772222687519
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
"registry": "https://clawhub.ai",
|
||||
"slug": "agentmail",
|
||||
"installedVersion": "1.1.1",
|
||||
"installedAt": 1771402307962
|
||||
"installedAt": 1772222702246
|
||||
}
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
---
|
||||
name: web-scraper
|
||||
description: Scrape web pages, search the internet, and extract structured content using Python. Use when the user wants to fetch a webpage, search for information online, extract links, or crawl JavaScript-rendered dynamic pages.
|
||||
compatibility: Requires Python 3. Lightweight mode needs requests, beautifulsoup4, readability-lxml, html2text. Dynamic mode needs crawl4ai. Search needs duckduckgo-search.
|
||||
---
|
||||
|
||||
# Web Scraper
|
||||
|
||||
Fetch, search, and extract content from websites.
|
||||
|
||||
## When to use this skill
|
||||
|
||||
- User asks to fetch or read a webpage / URL
|
||||
- User wants to search the internet for information
|
||||
- User needs to extract links, tables, or structured data from a website
|
||||
- User asks to crawl a JavaScript-rendered (dynamic) page
|
||||
- User wants web content converted to clean Markdown for analysis
|
||||
|
||||
## Scripts overview
|
||||
|
||||
| Script | Purpose | Dependencies |
|
||||
|---|---|---|
|
||||
| `fetch_page.py` | Fetch a URL and extract readable content as Markdown | `requests`, `beautifulsoup4`, `readability-lxml`, `html2text` |
|
||||
| `search_web.py` | Search the web via DuckDuckGo | `ddgs` |
|
||||
| `crawl_dynamic.py` | Crawl JS-rendered pages with a headless browser | `crawl4ai` |
|
||||
| `extract_links.py` | Extract and categorize all links from a page | `requests`, `beautifulsoup4` |
|
||||
|
||||
## Steps
|
||||
|
||||
### 1. Install dependencies (first time only)
|
||||
|
||||
For lightweight scraping (static pages, search, link extraction):
|
||||
```bash
|
||||
pip install requests beautifulsoup4 readability-lxml html2text ddgs
|
||||
```
|
||||
|
||||
For dynamic / JavaScript-rendered pages (heavier, installs Playwright + Chromium):
|
||||
```bash
|
||||
pip install crawl4ai
|
||||
crawl4ai-setup
|
||||
```
|
||||
|
||||
> **Note**: `crawl4ai-setup` downloads a Chromium browser (~150 MB). Only install if you actually need dynamic page support.
|
||||
|
||||
> **CRITICAL — Dependency Error Recovery**: If ANY script below fails with an `ImportError` or "module not found" error, install the missing dependencies using the command above, then **re-run the EXACT SAME script command that failed**. Do NOT write inline Python code (`python -c "..."`) or your own ad-hoc scripts as a substitute. These scripts handle encoding, error handling, and output formatting that inline code will miss.
|
||||
|
||||
### 2. Fetch a web page (static — recommended first choice)
|
||||
|
||||
Use this for most websites. It's fast, lightweight, and works for articles, docs, blogs, etc.
|
||||
|
||||
```bash
|
||||
python scripts/fetch_page.py "URL"
|
||||
```
|
||||
|
||||
Options:
|
||||
- `--raw` — Output full page Markdown instead of extracted article content
|
||||
- `--selector "CSS_SELECTOR"` — Extract only elements matching the CSS selector (e.g. `".article-body"`, `"table"`, `"#content"`)
|
||||
- `--save OUTPUT_PATH` — Also save output to a file
|
||||
- `--max-length N` — Truncate output to N characters (default: no limit)
|
||||
|
||||
Examples:
|
||||
```bash
|
||||
# Fetch an article
|
||||
python fetch_page.py "https://example.com/article"
|
||||
|
||||
# Extract only tables
|
||||
python fetch_page.py "https://example.com/data" --selector "table"
|
||||
|
||||
# Fetch raw full-page markdown, limit to 5000 chars
|
||||
python fetch_page.py "https://example.com" --raw --max-length 5000
|
||||
```
|
||||
|
||||
### 3. Search the web
|
||||
|
||||
Search using DuckDuckGo (no API key required).
|
||||
|
||||
```bash
|
||||
python scripts/search_web.py "search query"
|
||||
```
|
||||
|
||||
Options:
|
||||
- `--max-results N` — Number of results to return (default: 10)
|
||||
- `--region REGION` — Region code, e.g. `cn-zh`, `us-en`, `jp-jp` (default: `wt-wt` for worldwide)
|
||||
- `--news` — Search news instead of general web
|
||||
|
||||
Examples:
|
||||
```bash
|
||||
# General search
|
||||
python search_web.py "Python web scraping best practices 2025"
|
||||
|
||||
# News search, Chinese region, 5 results
|
||||
python search_web.py "AI 最新进展" --news --region cn-zh --max-results 5
|
||||
```
|
||||
|
||||
### 4. Crawl a dynamic / JavaScript-rendered page
|
||||
|
||||
Use this only when `fetch_page.py` returns empty or incomplete content (SPA, React/Vue apps, pages that load content via JS).
|
||||
|
||||
```bash
|
||||
python scripts/crawl_dynamic.py "URL"
|
||||
```
|
||||
|
||||
Options:
|
||||
- `--wait N` — Wait N seconds after page load for JS to finish (default: 3)
|
||||
- `--selector "CSS_SELECTOR"` — Wait for a specific element to appear before extracting
|
||||
- `--scroll` — Scroll to bottom of page to trigger lazy loading
|
||||
- `--save OUTPUT_PATH` — Also save output to a file
|
||||
- `--max-length N` — Truncate output to N characters
|
||||
|
||||
### 5. Extract links from a page
|
||||
|
||||
Extract all links with their text labels, categorized by type (internal, external, resource).
|
||||
|
||||
```bash
|
||||
python scripts/extract_links.py "URL"
|
||||
```
|
||||
|
||||
Options:
|
||||
- `--filter PATTERN` — Only show links matching a regex pattern (applied to URL)
|
||||
- `--external-only` — Only show external links
|
||||
- `--json` — Output as JSON instead of Markdown
|
||||
|
||||
## Decision guide: which script to use
|
||||
|
||||
1. **Start with `fetch_page.py`** — handles 90% of websites (articles, docs, blogs, wikis).
|
||||
2. If `fetch_page.py` returns empty/garbled content → try **`crawl_dynamic.py`** (the page likely needs JavaScript).
|
||||
3. Need to find URLs first? → Use **`search_web.py`** to discover relevant pages.
|
||||
4. Need to navigate a site structure? → Use **`extract_links.py`** to map out links, then fetch individual pages.
|
||||
|
||||
## Common workflows
|
||||
|
||||
### Research a topic
|
||||
1. `search_web.py "topic"` → get relevant URLs
|
||||
2. `fetch_page.py "best_url"` → read the content
|
||||
3. Repeat for multiple sources, then synthesize
|
||||
|
||||
### Scrape structured data from a page
|
||||
1. `fetch_page.py "url" --selector "table"` → extract tables
|
||||
2. Or `fetch_page.py "url" --selector ".product-card"` → extract specific elements
|
||||
|
||||
### Crawl a modern web app (SPA)
|
||||
1. `crawl_dynamic.py "url" --wait 5 --scroll` → full JS-rendered content
|
||||
|
||||
## Edge cases
|
||||
|
||||
- **Paywalled sites**: May return partial content or login pages. Inform the user.
|
||||
- **Rate limiting / CAPTCHAs**: If requests fail with 403/429, wait and retry or inform the user.
|
||||
- **Very large pages**: Use `--max-length` to truncate output and avoid overwhelming the context window.
|
||||
- **Encoding issues**: Scripts handle UTF-8 by default. Exotic encodings may need manual adjustment.
|
||||
- **Robots.txt**: These scripts do not check robots.txt. Use responsibly and respect website terms of service.
|
||||
|
||||
## Scripts
|
||||
|
||||
- [fetch_page.py](scripts/fetch_page.py) — Fetch and extract readable content as Markdown
|
||||
- [search_web.py](scripts/search_web.py) — Search the web via DuckDuckGo
|
||||
- [crawl_dynamic.py](scripts/crawl_dynamic.py) — Crawl JavaScript-rendered pages
|
||||
- [extract_links.py](scripts/extract_links.py) — Extract and categorize page links
|
||||
Binary file not shown.
@@ -0,0 +1,254 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Crawl JavaScript-rendered (dynamic) web pages using Crawl4AI.
|
||||
|
||||
Uses a headless Chromium browser to render pages that require JavaScript,
|
||||
then extracts clean Markdown content. Use this when fetch_page.py returns
|
||||
empty or incomplete content (SPAs, React/Vue apps, etc.).
|
||||
|
||||
Dependencies: pip install crawl4ai && crawl4ai-setup
|
||||
"""
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
import asyncio
|
||||
|
||||
|
||||
def setup_encoding():
|
||||
"""Setup proper encoding for Windows console output."""
|
||||
if sys.platform == "win32":
|
||||
import io
|
||||
try:
|
||||
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
||||
sys.stderr.reconfigure(encoding='utf-8', errors='replace')
|
||||
except (AttributeError, io.UnsupportedOperation):
|
||||
sys.stdout = io.TextIOWrapper(
|
||||
sys.stdout.buffer, encoding='utf-8', errors='replace', line_buffering=True
|
||||
)
|
||||
sys.stderr = io.TextIOWrapper(
|
||||
sys.stderr.buffer, encoding='utf-8', errors='replace', line_buffering=True
|
||||
)
|
||||
|
||||
|
||||
def check_dependencies():
|
||||
"""Check that Crawl4AI is installed."""
|
||||
try:
|
||||
import crawl4ai # noqa: F401
|
||||
except ImportError:
|
||||
print("Error: crawl4ai not installed.", file=sys.stderr)
|
||||
print("Install with:", file=sys.stderr)
|
||||
print(" pip install crawl4ai", file=sys.stderr)
|
||||
print(" crawl4ai-setup", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
async def crawl_page(url, wait_seconds=3, css_selector=None, scroll=False):
|
||||
"""Crawl a page with headless browser and return Markdown content."""
|
||||
from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, CacheMode
|
||||
from crawl4ai.content_filter_strategy import PruningContentFilter
|
||||
from crawl4ai.markdown_generation_strategy import DefaultMarkdownGenerator
|
||||
|
||||
browser_conf = BrowserConfig(
|
||||
headless=True,
|
||||
verbose=False,
|
||||
)
|
||||
|
||||
md_generator = DefaultMarkdownGenerator(
|
||||
content_filter=PruningContentFilter(threshold=0.4, threshold_type="fixed")
|
||||
)
|
||||
|
||||
run_conf = CrawlerRunConfig(
|
||||
cache_mode=CacheMode.BYPASS,
|
||||
markdown_generator=md_generator,
|
||||
page_timeout=60000, # 60s
|
||||
wait_until="networkidle",
|
||||
)
|
||||
|
||||
# Add wait time if specified
|
||||
if wait_seconds > 0:
|
||||
run_conf.delay_before_return_html = wait_seconds
|
||||
|
||||
# Wait for specific CSS selector
|
||||
if css_selector:
|
||||
run_conf.wait_for = f"css:{css_selector}"
|
||||
|
||||
async with AsyncWebCrawler(config=browser_conf) as crawler:
|
||||
result = await crawler.arun(url=url, config=run_conf)
|
||||
|
||||
if not result.success:
|
||||
return None, result.error_message or "Unknown error"
|
||||
|
||||
# Get the best available markdown
|
||||
md = ""
|
||||
if result.markdown:
|
||||
if hasattr(result.markdown, 'fit_markdown') and result.markdown.fit_markdown:
|
||||
md = result.markdown.fit_markdown
|
||||
elif hasattr(result.markdown, 'raw_markdown') and result.markdown.raw_markdown:
|
||||
md = result.markdown.raw_markdown
|
||||
elif isinstance(result.markdown, str):
|
||||
md = result.markdown
|
||||
|
||||
title = ""
|
||||
if hasattr(result, 'metadata') and result.metadata:
|
||||
title = result.metadata.get('title', '')
|
||||
|
||||
return {
|
||||
"title": title,
|
||||
"url": result.url or url,
|
||||
"markdown": md,
|
||||
"status_code": getattr(result, 'status_code', None),
|
||||
}, None
|
||||
|
||||
|
||||
async def crawl_with_scroll(url, wait_seconds=3, css_selector=None):
|
||||
"""Crawl with infinite scroll support."""
|
||||
from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, CacheMode
|
||||
from crawl4ai.markdown_generation_strategy import DefaultMarkdownGenerator
|
||||
from crawl4ai.content_filter_strategy import PruningContentFilter
|
||||
|
||||
browser_conf = BrowserConfig(
|
||||
headless=True,
|
||||
verbose=False,
|
||||
)
|
||||
|
||||
# JavaScript to scroll to bottom
|
||||
scroll_js = """
|
||||
async () => {
|
||||
await new Promise((resolve) => {
|
||||
let totalHeight = 0;
|
||||
const distance = 500;
|
||||
const timer = setInterval(() => {
|
||||
const scrollHeight = document.body.scrollHeight;
|
||||
window.scrollBy(0, distance);
|
||||
totalHeight += distance;
|
||||
if (totalHeight >= scrollHeight) {
|
||||
clearInterval(timer);
|
||||
resolve();
|
||||
}
|
||||
}, 300);
|
||||
// Safety timeout
|
||||
setTimeout(() => { clearInterval(timer); resolve(); }, 15000);
|
||||
});
|
||||
}
|
||||
"""
|
||||
|
||||
md_generator = DefaultMarkdownGenerator(
|
||||
content_filter=PruningContentFilter(threshold=0.4, threshold_type="fixed")
|
||||
)
|
||||
|
||||
run_conf = CrawlerRunConfig(
|
||||
cache_mode=CacheMode.BYPASS,
|
||||
markdown_generator=md_generator,
|
||||
page_timeout=60000,
|
||||
js_code=scroll_js,
|
||||
wait_until="networkidle",
|
||||
)
|
||||
|
||||
if wait_seconds > 0:
|
||||
run_conf.delay_before_return_html = wait_seconds
|
||||
|
||||
if css_selector:
|
||||
run_conf.wait_for = f"css:{css_selector}"
|
||||
|
||||
async with AsyncWebCrawler(config=browser_conf) as crawler:
|
||||
result = await crawler.arun(url=url, config=run_conf)
|
||||
|
||||
if not result.success:
|
||||
return None, result.error_message or "Unknown error"
|
||||
|
||||
md = ""
|
||||
if result.markdown:
|
||||
if hasattr(result.markdown, 'fit_markdown') and result.markdown.fit_markdown:
|
||||
md = result.markdown.fit_markdown
|
||||
elif hasattr(result.markdown, 'raw_markdown') and result.markdown.raw_markdown:
|
||||
md = result.markdown.raw_markdown
|
||||
elif isinstance(result.markdown, str):
|
||||
md = result.markdown
|
||||
|
||||
title = ""
|
||||
if hasattr(result, 'metadata') and result.metadata:
|
||||
title = result.metadata.get('title', '')
|
||||
|
||||
return {
|
||||
"title": title,
|
||||
"url": result.url or url,
|
||||
"markdown": md,
|
||||
"status_code": getattr(result, 'status_code', None),
|
||||
}, None
|
||||
|
||||
|
||||
def main():
|
||||
setup_encoding()
|
||||
check_dependencies()
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Crawl JavaScript-rendered pages with headless browser"
|
||||
)
|
||||
parser.add_argument("url", help="URL to crawl")
|
||||
parser.add_argument("--wait", type=int, default=3,
|
||||
help="Seconds to wait after page load (default: 3)")
|
||||
parser.add_argument("--selector", type=str, default=None,
|
||||
help="CSS selector to wait for before extracting")
|
||||
parser.add_argument("--scroll", action="store_true",
|
||||
help="Scroll to bottom to trigger lazy loading")
|
||||
parser.add_argument("--save", type=str, default=None,
|
||||
help="Also save output to this file path")
|
||||
parser.add_argument("--max-length", type=int, default=None,
|
||||
help="Truncate output to N characters")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
url = args.url.strip()
|
||||
if not url.startswith(("http://", "https://")):
|
||||
url = "https://" + url
|
||||
|
||||
print(f"Crawling (dynamic): {url}", file=sys.stderr)
|
||||
print(f"Options: wait={args.wait}s, selector={args.selector}, scroll={args.scroll}", file=sys.stderr)
|
||||
|
||||
# Run async crawl
|
||||
if args.scroll:
|
||||
data, error = asyncio.run(crawl_with_scroll(url, args.wait, args.selector))
|
||||
else:
|
||||
data, error = asyncio.run(crawl_page(url, args.wait, args.selector))
|
||||
|
||||
if error:
|
||||
print(f"Error: crawl failed: {error}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if not data or not data["markdown"]:
|
||||
print("Warning: no content extracted from page", file=sys.stderr)
|
||||
print("[No content could be extracted from this page]")
|
||||
sys.exit(0)
|
||||
|
||||
# Build output
|
||||
parts = []
|
||||
if data["title"]:
|
||||
parts.append(f"# {data['title']}\n")
|
||||
parts.append(f"**Source**: {data['url']}")
|
||||
if data.get("status_code"):
|
||||
parts.append(f"**Status**: {data['status_code']}")
|
||||
parts.append("\n---\n")
|
||||
parts.append(data["markdown"])
|
||||
|
||||
output = "\n".join(parts)
|
||||
|
||||
# Truncate if requested
|
||||
if args.max_length and len(output) > args.max_length:
|
||||
output = output[:args.max_length] + f"\n\n[... truncated at {args.max_length} characters, total {len(output)}]"
|
||||
|
||||
print(output)
|
||||
|
||||
content_len = len(data["markdown"])
|
||||
print(f"\nExtracted: {content_len} characters (dynamic crawl)", file=sys.stderr)
|
||||
|
||||
# Save to file if requested
|
||||
if args.save:
|
||||
try:
|
||||
with open(args.save, "w", encoding="utf-8") as f:
|
||||
f.write(output)
|
||||
print(f"Saved to: {args.save}", file=sys.stderr)
|
||||
except Exception as e:
|
||||
print(f"Error saving file: {e}", file=sys.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,236 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Extract and categorize all links from a web page.
|
||||
|
||||
Fetches the page and extracts all <a> tags, categorizing them as
|
||||
internal, external, or resource links. Useful for site navigation
|
||||
and discovery before deeper scraping.
|
||||
|
||||
Dependencies: pip install requests beautifulsoup4
|
||||
"""
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
import json
|
||||
import re
|
||||
from urllib.parse import urlparse, urljoin
|
||||
|
||||
|
||||
def setup_encoding():
|
||||
"""Setup proper encoding for Windows console output."""
|
||||
if sys.platform == "win32":
|
||||
import io
|
||||
try:
|
||||
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
||||
sys.stderr.reconfigure(encoding='utf-8', errors='replace')
|
||||
except (AttributeError, io.UnsupportedOperation):
|
||||
sys.stdout = io.TextIOWrapper(
|
||||
sys.stdout.buffer, encoding='utf-8', errors='replace', line_buffering=True
|
||||
)
|
||||
sys.stderr = io.TextIOWrapper(
|
||||
sys.stderr.buffer, encoding='utf-8', errors='replace', line_buffering=True
|
||||
)
|
||||
|
||||
|
||||
def check_dependencies():
|
||||
"""Check that required packages are installed."""
|
||||
missing = []
|
||||
try:
|
||||
import requests # noqa: F401
|
||||
except ImportError:
|
||||
missing.append("requests")
|
||||
try:
|
||||
from bs4 import BeautifulSoup # noqa: F401
|
||||
except ImportError:
|
||||
missing.append("beautifulsoup4")
|
||||
if missing:
|
||||
print(f"Error: missing dependencies: {', '.join(missing)}", file=sys.stderr)
|
||||
print(f"Install with: pip install {' '.join(missing)}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
RESOURCE_EXTENSIONS = {
|
||||
'.pdf', '.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx',
|
||||
'.zip', '.rar', '.tar', '.gz', '.7z',
|
||||
'.jpg', '.jpeg', '.png', '.gif', '.svg', '.webp', '.ico',
|
||||
'.mp3', '.mp4', '.avi', '.mov', '.webm',
|
||||
'.css', '.js', '.woff', '.woff2', '.ttf', '.eot',
|
||||
}
|
||||
|
||||
|
||||
def classify_link(href, base_domain):
|
||||
"""Classify a link as internal, external, or resource."""
|
||||
parsed = urlparse(href)
|
||||
|
||||
# Check for resource files
|
||||
path_lower = parsed.path.lower()
|
||||
for ext in RESOURCE_EXTENSIONS:
|
||||
if path_lower.endswith(ext):
|
||||
return "resource"
|
||||
|
||||
# Check domain
|
||||
link_domain = parsed.netloc.lower()
|
||||
if not link_domain or link_domain == base_domain:
|
||||
return "internal"
|
||||
|
||||
# Check for common CDN / same-org subdomains
|
||||
base_parts = base_domain.split(".")
|
||||
link_parts = link_domain.split(".")
|
||||
if len(base_parts) >= 2 and len(link_parts) >= 2:
|
||||
if base_parts[-2:] == link_parts[-2:]:
|
||||
return "internal"
|
||||
|
||||
return "external"
|
||||
|
||||
|
||||
def extract_links(html, base_url):
|
||||
"""Extract all links from HTML."""
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
soup = BeautifulSoup(html, "html.parser")
|
||||
base_domain = urlparse(base_url).netloc.lower()
|
||||
links = []
|
||||
seen = set()
|
||||
|
||||
for a_tag in soup.find_all("a", href=True):
|
||||
href = a_tag["href"].strip()
|
||||
|
||||
# Skip anchors, javascript:, mailto:, tel:
|
||||
if not href or href.startswith(("#", "javascript:", "mailto:", "tel:")):
|
||||
continue
|
||||
|
||||
# Resolve relative URLs
|
||||
full_url = urljoin(base_url, href)
|
||||
|
||||
# Deduplicate
|
||||
if full_url in seen:
|
||||
continue
|
||||
seen.add(full_url)
|
||||
|
||||
# Extract link text
|
||||
text = a_tag.get_text(strip=True) or ""
|
||||
text = re.sub(r'\s+', ' ', text) # normalize whitespace
|
||||
if len(text) > 100:
|
||||
text = text[:100] + "..."
|
||||
|
||||
link_type = classify_link(full_url, base_domain)
|
||||
|
||||
links.append({
|
||||
"url": full_url,
|
||||
"text": text,
|
||||
"type": link_type,
|
||||
})
|
||||
|
||||
return links
|
||||
|
||||
|
||||
def format_markdown(links, url, filter_pattern=None, external_only=False):
|
||||
"""Format links as Markdown."""
|
||||
# Apply filters
|
||||
filtered = links
|
||||
if external_only:
|
||||
filtered = [link for link in filtered if link["type"] == "external"]
|
||||
if filter_pattern:
|
||||
try:
|
||||
pattern = re.compile(filter_pattern, re.IGNORECASE)
|
||||
filtered = [link for link in filtered if pattern.search(link["url"])]
|
||||
except re.error as e:
|
||||
print(f"Warning: invalid regex pattern '{filter_pattern}': {e}", file=sys.stderr)
|
||||
|
||||
# Group by type
|
||||
internal = [link for link in filtered if link["type"] == "internal"]
|
||||
external = [link for link in filtered if link["type"] == "external"]
|
||||
resources = [link for link in filtered if link["type"] == "resource"]
|
||||
|
||||
parts = [f"# Links from {url}\n"]
|
||||
parts.append(f"Total: **{len(filtered)}** links ({len(internal)} internal, {len(external)} external, {len(resources)} resource)\n")
|
||||
|
||||
if internal:
|
||||
parts.append("## Internal Links\n")
|
||||
for lk in internal:
|
||||
text = f" — {lk['text']}" if lk['text'] else ""
|
||||
parts.append(f"- {lk['url']}{text}")
|
||||
parts.append("")
|
||||
|
||||
if external:
|
||||
parts.append("## External Links\n")
|
||||
for lk in external:
|
||||
text = f" — {lk['text']}" if lk['text'] else ""
|
||||
parts.append(f"- {lk['url']}{text}")
|
||||
parts.append("")
|
||||
|
||||
if resources:
|
||||
parts.append("## Resource Links\n")
|
||||
for lk in resources:
|
||||
text = f" — {lk['text']}" if lk['text'] else ""
|
||||
parts.append(f"- {lk['url']}{text}")
|
||||
parts.append("")
|
||||
|
||||
return "\n".join(parts)
|
||||
|
||||
|
||||
def main():
|
||||
setup_encoding()
|
||||
check_dependencies()
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Extract and categorize links from a web page"
|
||||
)
|
||||
parser.add_argument("url", help="URL to extract links from")
|
||||
parser.add_argument("--filter", type=str, default=None,
|
||||
help="Regex pattern to filter URLs")
|
||||
parser.add_argument("--external-only", action="store_true",
|
||||
help="Only show external links")
|
||||
parser.add_argument("--json", action="store_true",
|
||||
help="Output as JSON instead of Markdown")
|
||||
parser.add_argument("--timeout", type=int, default=30,
|
||||
help="Request timeout in seconds (default: 30)")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
import requests
|
||||
|
||||
url = args.url.strip()
|
||||
if not url.startswith(("http://", "https://")):
|
||||
url = "https://" + url
|
||||
|
||||
print(f"Extracting links from: {url}", file=sys.stderr)
|
||||
|
||||
headers = {
|
||||
"User-Agent": (
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
|
||||
"(KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
||||
),
|
||||
}
|
||||
|
||||
try:
|
||||
resp = requests.get(url, headers=headers, timeout=args.timeout, allow_redirects=True)
|
||||
resp.raise_for_status()
|
||||
if resp.encoding and resp.encoding.lower() != 'utf-8':
|
||||
resp.encoding = resp.apparent_encoding or resp.encoding
|
||||
html = resp.text
|
||||
final_url = resp.url
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"Error: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
links = extract_links(html, final_url)
|
||||
print(f"Found {len(links)} unique links", file=sys.stderr)
|
||||
|
||||
if args.json:
|
||||
# Apply filters for JSON output too
|
||||
filtered = links
|
||||
if args.external_only:
|
||||
filtered = [lk for lk in filtered if lk["type"] == "external"]
|
||||
if args.filter:
|
||||
try:
|
||||
pattern = re.compile(args.filter, re.IGNORECASE)
|
||||
filtered = [lk for lk in filtered if pattern.search(lk["url"])]
|
||||
except re.error:
|
||||
pass
|
||||
print(json.dumps(filtered, indent=2, ensure_ascii=False))
|
||||
else:
|
||||
print(format_markdown(links, final_url, args.filter, args.external_only))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,284 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Fetch a web page and extract readable content as clean Markdown.
|
||||
|
||||
Uses requests + BeautifulSoup + readability-lxml + html2text for lightweight,
|
||||
fast extraction without a headless browser. Works well for articles, docs,
|
||||
blogs, wikis, and most static websites.
|
||||
|
||||
Dependencies: pip install requests beautifulsoup4 readability-lxml html2text
|
||||
"""
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
|
||||
def setup_encoding():
|
||||
"""Setup proper encoding for Windows console output."""
|
||||
if sys.platform == "win32":
|
||||
import io
|
||||
try:
|
||||
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
||||
sys.stderr.reconfigure(encoding='utf-8', errors='replace')
|
||||
except (AttributeError, io.UnsupportedOperation):
|
||||
sys.stdout = io.TextIOWrapper(
|
||||
sys.stdout.buffer, encoding='utf-8', errors='replace', line_buffering=True
|
||||
)
|
||||
sys.stderr = io.TextIOWrapper(
|
||||
sys.stderr.buffer, encoding='utf-8', errors='replace', line_buffering=True
|
||||
)
|
||||
|
||||
|
||||
def check_dependencies():
|
||||
"""Check that required packages are installed."""
|
||||
missing = []
|
||||
try:
|
||||
import requests # noqa: F401
|
||||
except ImportError:
|
||||
missing.append("requests")
|
||||
try:
|
||||
from bs4 import BeautifulSoup # noqa: F401
|
||||
except ImportError:
|
||||
missing.append("beautifulsoup4")
|
||||
try:
|
||||
from readability import Document # noqa: F401
|
||||
except ImportError:
|
||||
missing.append("readability-lxml")
|
||||
try:
|
||||
import html2text # noqa: F401
|
||||
except ImportError:
|
||||
missing.append("html2text")
|
||||
|
||||
if missing:
|
||||
print(f"Error: missing dependencies: {', '.join(missing)}", file=sys.stderr)
|
||||
print(f"Install with: pip install {' '.join(missing)}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def fetch_url(url, timeout=30):
|
||||
"""Fetch URL content with proper headers."""
|
||||
import requests
|
||||
|
||||
headers = {
|
||||
"User-Agent": (
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
|
||||
"(KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
||||
),
|
||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
||||
"Accept-Language": "en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7",
|
||||
"Accept-Encoding": "gzip, deflate, br",
|
||||
}
|
||||
|
||||
try:
|
||||
resp = requests.get(url, headers=headers, timeout=timeout, allow_redirects=True)
|
||||
resp.raise_for_status()
|
||||
|
||||
# Detect encoding
|
||||
if resp.encoding and resp.encoding.lower() != 'utf-8':
|
||||
resp.encoding = resp.apparent_encoding or resp.encoding
|
||||
|
||||
return resp.text, resp.url, resp.status_code
|
||||
except requests.exceptions.Timeout:
|
||||
print(f"Error: request timed out after {timeout}s", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
except requests.exceptions.ConnectionError as e:
|
||||
print(f"Error: connection failed: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
except requests.exceptions.HTTPError as e:
|
||||
print(f"Error: HTTP {e.response.status_code}: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(f"Error: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def extract_with_readability(html, url):
|
||||
"""Extract main article content using readability-lxml."""
|
||||
from readability import Document
|
||||
|
||||
doc = Document(html, url=url)
|
||||
title = doc.short_title()
|
||||
content_html = doc.summary()
|
||||
return title, content_html
|
||||
|
||||
|
||||
def extract_with_selector(html, selector):
|
||||
"""Extract content matching a CSS selector."""
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
soup = BeautifulSoup(html, "html.parser")
|
||||
elements = soup.select(selector)
|
||||
if not elements:
|
||||
return None
|
||||
|
||||
# Combine all matching elements
|
||||
parts = []
|
||||
for el in elements:
|
||||
parts.append(str(el))
|
||||
return "\n".join(parts)
|
||||
|
||||
|
||||
def html_to_markdown(html, base_url=None):
|
||||
"""Convert HTML to clean Markdown."""
|
||||
import html2text
|
||||
|
||||
converter = html2text.HTML2Text()
|
||||
converter.body_width = 0 # Don't wrap lines
|
||||
converter.ignore_images = False
|
||||
converter.ignore_links = False
|
||||
converter.ignore_emphasis = False
|
||||
converter.protect_links = True
|
||||
converter.unicode_snob = True
|
||||
converter.mark_code = True
|
||||
converter.wrap_links = False
|
||||
converter.single_line_break = False
|
||||
|
||||
if base_url:
|
||||
converter.baseurl = base_url
|
||||
|
||||
md = converter.handle(html)
|
||||
|
||||
# Clean up excessive blank lines
|
||||
import re
|
||||
md = re.sub(r'\n{3,}', '\n\n', md)
|
||||
return md.strip()
|
||||
|
||||
|
||||
def extract_metadata(html):
|
||||
"""Extract page metadata (title, description, etc.)."""
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
soup = BeautifulSoup(html, "html.parser")
|
||||
meta = {}
|
||||
|
||||
# Title
|
||||
title_tag = soup.find("title")
|
||||
if title_tag:
|
||||
meta["title"] = title_tag.get_text(strip=True)
|
||||
|
||||
# Meta description
|
||||
desc_tag = soup.find("meta", attrs={"name": "description"})
|
||||
if desc_tag and desc_tag.get("content"):
|
||||
meta["description"] = desc_tag["content"].strip()
|
||||
|
||||
# OG tags
|
||||
for prop in ["og:title", "og:description", "og:type", "og:site_name"]:
|
||||
tag = soup.find("meta", attrs={"property": prop})
|
||||
if tag and tag.get("content"):
|
||||
meta[prop.replace("og:", "og_")] = tag["content"].strip()
|
||||
|
||||
# Author
|
||||
author_tag = soup.find("meta", attrs={"name": "author"})
|
||||
if author_tag and author_tag.get("content"):
|
||||
meta["author"] = author_tag["content"].strip()
|
||||
|
||||
# Published date
|
||||
for attr in ["article:published_time", "datePublished", "date"]:
|
||||
date_tag = soup.find("meta", attrs={"property": attr}) or soup.find("meta", attrs={"name": attr})
|
||||
if date_tag and date_tag.get("content"):
|
||||
meta["published"] = date_tag["content"].strip()
|
||||
break
|
||||
|
||||
return meta
|
||||
|
||||
|
||||
def main():
|
||||
setup_encoding()
|
||||
check_dependencies()
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Fetch a web page and extract content as Markdown"
|
||||
)
|
||||
parser.add_argument("url", help="URL to fetch")
|
||||
parser.add_argument("--raw", action="store_true",
|
||||
help="Output full page Markdown (no readability extraction)")
|
||||
parser.add_argument("--selector", type=str, default=None,
|
||||
help="CSS selector to extract specific elements")
|
||||
parser.add_argument("--save", type=str, default=None,
|
||||
help="Also save output to this file path")
|
||||
parser.add_argument("--max-length", type=int, default=None,
|
||||
help="Truncate output to N characters")
|
||||
parser.add_argument("--timeout", type=int, default=30,
|
||||
help="Request timeout in seconds (default: 30)")
|
||||
parser.add_argument("--no-metadata", action="store_true",
|
||||
help="Skip metadata header in output")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Normalize URL
|
||||
url = args.url.strip()
|
||||
if not url.startswith(("http://", "https://")):
|
||||
url = "https://" + url
|
||||
|
||||
print(f"Fetching: {url}", file=sys.stderr)
|
||||
|
||||
# Fetch
|
||||
html, final_url, status = fetch_url(url, timeout=args.timeout)
|
||||
print(f"Status: {status}, Size: {len(html)} bytes", file=sys.stderr)
|
||||
|
||||
if final_url != url:
|
||||
print(f"Redirected to: {final_url}", file=sys.stderr)
|
||||
|
||||
# Extract metadata
|
||||
meta = extract_metadata(html) if not args.no_metadata else {}
|
||||
|
||||
# Extract content
|
||||
if args.selector:
|
||||
# CSS selector mode
|
||||
selected_html = extract_with_selector(html, args.selector)
|
||||
if not selected_html:
|
||||
print(f"Warning: no elements matched selector '{args.selector}'", file=sys.stderr)
|
||||
print(f"[No elements matched CSS selector: {args.selector}]")
|
||||
sys.exit(0)
|
||||
title = meta.get("title", "")
|
||||
content_md = html_to_markdown(selected_html, base_url=final_url)
|
||||
elif args.raw:
|
||||
# Raw full-page mode
|
||||
title = meta.get("title", "")
|
||||
content_md = html_to_markdown(html, base_url=final_url)
|
||||
else:
|
||||
# Readability extraction mode (default)
|
||||
title, article_html = extract_with_readability(html, final_url)
|
||||
content_md = html_to_markdown(article_html, base_url=final_url)
|
||||
|
||||
# Build output
|
||||
parts = []
|
||||
|
||||
if not args.no_metadata and meta:
|
||||
parts.append(f"# {title or meta.get('title', 'Untitled')}")
|
||||
parts.append(f"\n**Source**: {final_url}")
|
||||
if meta.get("author"):
|
||||
parts.append(f"**Author**: {meta['author']}")
|
||||
if meta.get("published"):
|
||||
parts.append(f"**Published**: {meta['published']}")
|
||||
if meta.get("description"):
|
||||
parts.append(f"**Description**: {meta['description']}")
|
||||
parts.append("\n---\n")
|
||||
elif title and not args.no_metadata:
|
||||
parts.append(f"# {title}\n")
|
||||
|
||||
parts.append(content_md)
|
||||
|
||||
output = "\n".join(parts)
|
||||
|
||||
# Truncate if requested
|
||||
if args.max_length and len(output) > args.max_length:
|
||||
output = output[:args.max_length] + f"\n\n[... truncated at {args.max_length} characters, total {len(output)}]"
|
||||
|
||||
# Print to stdout
|
||||
print(output)
|
||||
|
||||
content_length = len(content_md)
|
||||
print(f"\nExtracted: {content_length} characters", file=sys.stderr)
|
||||
|
||||
# Save to file if requested
|
||||
if args.save:
|
||||
try:
|
||||
with open(args.save, "w", encoding="utf-8") as f:
|
||||
f.write(output)
|
||||
print(f"Saved to: {args.save}", file=sys.stderr)
|
||||
except Exception as e:
|
||||
print(f"Error saving file: {e}", file=sys.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,155 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Search the web using DuckDuckGo and return structured results.
|
||||
|
||||
No API key required. Returns results with title, URL, and snippet.
|
||||
|
||||
Dependencies: pip install ddgs
|
||||
"""
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
import json
|
||||
|
||||
|
||||
def setup_encoding():
|
||||
"""Setup proper encoding for Windows console output."""
|
||||
if sys.platform == "win32":
|
||||
import io
|
||||
try:
|
||||
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
||||
sys.stderr.reconfigure(encoding='utf-8', errors='replace')
|
||||
except (AttributeError, io.UnsupportedOperation):
|
||||
sys.stdout = io.TextIOWrapper(
|
||||
sys.stdout.buffer, encoding='utf-8', errors='replace', line_buffering=True
|
||||
)
|
||||
sys.stderr = io.TextIOWrapper(
|
||||
sys.stderr.buffer, encoding='utf-8', errors='replace', line_buffering=True
|
||||
)
|
||||
|
||||
|
||||
def check_dependencies():
|
||||
"""Check that required packages are installed."""
|
||||
try:
|
||||
from ddgs import DDGS # noqa: F401
|
||||
except ImportError:
|
||||
try:
|
||||
from duckduckgo_search import DDGS # noqa: F401
|
||||
except ImportError:
|
||||
print("Error: ddgs not installed.", file=sys.stderr)
|
||||
print("Install with: pip install ddgs", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def _get_ddgs_class():
|
||||
"""Import DDGS from ddgs (new) or duckduckgo_search (legacy)."""
|
||||
try:
|
||||
from ddgs import DDGS
|
||||
return DDGS
|
||||
except ImportError:
|
||||
from duckduckgo_search import DDGS
|
||||
return DDGS
|
||||
|
||||
|
||||
def search_text(query, max_results=10, region="wt-wt"):
|
||||
"""Perform a text search."""
|
||||
DDGS = _get_ddgs_class()
|
||||
ddgs = DDGS()
|
||||
try:
|
||||
# New ddgs package: positional 'query' arg
|
||||
results = list(ddgs.text(query, region=region, max_results=max_results))
|
||||
except TypeError:
|
||||
# Legacy duckduckgo_search: 'keywords' kwarg + context manager
|
||||
with DDGS() as d:
|
||||
results = list(d.text(keywords=query, region=region, max_results=max_results))
|
||||
return results
|
||||
|
||||
|
||||
def search_news(query, max_results=10, region="wt-wt"):
|
||||
"""Perform a news search."""
|
||||
DDGS = _get_ddgs_class()
|
||||
ddgs = DDGS()
|
||||
try:
|
||||
results = list(ddgs.news(query, region=region, max_results=max_results))
|
||||
except TypeError:
|
||||
with DDGS() as d:
|
||||
results = list(d.news(keywords=query, region=region, max_results=max_results))
|
||||
return results
|
||||
|
||||
|
||||
def format_results_markdown(results, query, is_news=False):
|
||||
"""Format search results as Markdown."""
|
||||
search_type = "News" if is_news else "Web"
|
||||
parts = [f"# {search_type} Search Results: {query}\n"]
|
||||
parts.append(f"Found **{len(results)}** results.\n")
|
||||
|
||||
for i, r in enumerate(results, 1):
|
||||
title = r.get("title", "Untitled")
|
||||
url = r.get("href") or r.get("url") or r.get("link", "")
|
||||
body = r.get("body") or r.get("snippet", "")
|
||||
date = r.get("date", "")
|
||||
|
||||
parts.append(f"## {i}. {title}")
|
||||
parts.append(f"**URL**: {url}")
|
||||
if date:
|
||||
parts.append(f"**Date**: {date}")
|
||||
if body:
|
||||
parts.append(f"\n{body}")
|
||||
parts.append("") # blank line
|
||||
|
||||
return "\n".join(parts)
|
||||
|
||||
|
||||
def format_results_json(results):
|
||||
"""Format search results as JSON."""
|
||||
return json.dumps(results, indent=2, ensure_ascii=False)
|
||||
|
||||
|
||||
def main():
|
||||
setup_encoding()
|
||||
check_dependencies()
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Search the web via DuckDuckGo"
|
||||
)
|
||||
parser.add_argument("query", help="Search query")
|
||||
parser.add_argument("--max-results", type=int, default=10,
|
||||
help="Number of results (default: 10)")
|
||||
parser.add_argument("--region", type=str, default="wt-wt",
|
||||
help="Region code, e.g. cn-zh, us-en, jp-jp (default: wt-wt)")
|
||||
parser.add_argument("--news", action="store_true",
|
||||
help="Search news instead of general web")
|
||||
parser.add_argument("--json", action="store_true",
|
||||
help="Output as JSON instead of Markdown")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
query = args.query.strip()
|
||||
if not query:
|
||||
print("Error: empty query", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
print(f"Searching: {query} (region={args.region}, max={args.max_results})", file=sys.stderr)
|
||||
|
||||
try:
|
||||
if args.news:
|
||||
results = search_news(query, args.max_results, args.region)
|
||||
else:
|
||||
results = search_text(query, args.max_results, args.region)
|
||||
except Exception as e:
|
||||
print(f"Error: search failed: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if not results:
|
||||
print(f"No results found for: {query}")
|
||||
sys.exit(0)
|
||||
|
||||
print(f"Got {len(results)} results", file=sys.stderr)
|
||||
|
||||
if args.json:
|
||||
print(format_results_json(results))
|
||||
else:
|
||||
print(format_results_markdown(results, query, is_news=args.news))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 1,
|
||||
"registry": "https://clawhub.ai",
|
||||
"slug": "answeroverflow",
|
||||
"installedVersion": "1.0.2",
|
||||
"installedAt": 1772222757019
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
---
|
||||
name: answeroverflow
|
||||
description: Search indexed Discord community discussions via Answer Overflow. Find solutions to coding problems, library issues, and community Q&A that only exist in Discord conversations.
|
||||
---
|
||||
|
||||
# Answer Overflow Skill
|
||||
|
||||
Search indexed Discord community discussions via Answer Overflow. Great for finding solutions to coding problems, library issues, and community Q&A.
|
||||
|
||||
## What is Answer Overflow?
|
||||
|
||||
Answer Overflow indexes public Discord support channels and makes them searchable via Google and direct API access. Perfect for finding answers that only exist in Discord conversations.
|
||||
|
||||
## Quick Search
|
||||
|
||||
Use web_search to find Answer Overflow results:
|
||||
```bash
|
||||
# Search for a topic (Answer Overflow results often appear in Google)
|
||||
web_search "site:answeroverflow.com prisma connection pooling"
|
||||
```
|
||||
|
||||
## Fetching Thread Content
|
||||
|
||||
### Markdown URLs
|
||||
Add `/m/` prefix or `.md` suffix to get markdown-formatted content:
|
||||
|
||||
```
|
||||
# Standard URL
|
||||
https://www.answeroverflow.com/m/1234567890123456789
|
||||
|
||||
# With .md suffix (alternative)
|
||||
https://www.answeroverflow.com/m/1234567890123456789.md
|
||||
```
|
||||
|
||||
### Using web_fetch
|
||||
```bash
|
||||
# Fetch a thread in markdown format
|
||||
web_fetch url="https://www.answeroverflow.com/m/<message-id>"
|
||||
```
|
||||
|
||||
### Accept Header
|
||||
When making requests, the API checks for `Accept: text/markdown` header to return markdown format.
|
||||
|
||||
## MCP Server (Reference)
|
||||
|
||||
Answer Overflow has an MCP server at `https://www.answeroverflow.com/mcp` with these tools:
|
||||
|
||||
| Tool | Description |
|
||||
|------|-------------|
|
||||
| `search_answeroverflow` | Search across all indexed Discord communities. Can filter by server or channel ID. |
|
||||
| `search_servers` | Discover Discord servers indexed on Answer Overflow. Returns server IDs for filtered searching. |
|
||||
| `get_thread_messages` | Get all messages from a specific thread/discussion. |
|
||||
| `find_similar_threads` | Find threads similar to a given thread. |
|
||||
|
||||
## URL Patterns
|
||||
|
||||
| Pattern | Example |
|
||||
|---------|---------|
|
||||
| Thread | `https://www.answeroverflow.com/m/<message-id>` |
|
||||
| Server | `https://www.answeroverflow.com/c/<server-slug>` |
|
||||
| Channel | `https://www.answeroverflow.com/c/<server-slug>/<channel-slug>` |
|
||||
|
||||
## Common Searches
|
||||
|
||||
```bash
|
||||
# Find Discord.js help
|
||||
web_search "site:answeroverflow.com discord.js slash commands"
|
||||
|
||||
# Find Next.js solutions
|
||||
web_search "site:answeroverflow.com nextjs app router error"
|
||||
|
||||
# Find Prisma answers
|
||||
web_search "site:answeroverflow.com prisma many-to-many"
|
||||
```
|
||||
|
||||
## Tips
|
||||
|
||||
- Results are real Discord conversations, so context may be informal
|
||||
- Threads often have back-and-forth discussion before the solution
|
||||
- Check the server/channel name to understand the context (e.g., official support vs community)
|
||||
- Many open source projects index their Discord support channels here
|
||||
|
||||
## Links
|
||||
|
||||
- **Website:** https://www.answeroverflow.com
|
||||
- **Docs:** https://docs.answeroverflow.com
|
||||
- **MCP:** https://www.answeroverflow.com/mcp
|
||||
- **Discord:** https://discord.answeroverflow.com
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ownerId": "kn7ehk5erw07et6p0vq4k451ws802vgd",
|
||||
"slug": "answeroverflow",
|
||||
"version": "1.0.2",
|
||||
"publishedAt": 1769561820919
|
||||
}
|
||||
@@ -2,6 +2,6 @@
|
||||
"version": 1,
|
||||
"registry": "https://clawhub.ai",
|
||||
"slug": "api-gateway",
|
||||
"installedVersion": "1.0.35",
|
||||
"installedAt": 1771418208448
|
||||
"installedVersion": "1.0.51",
|
||||
"installedAt": 1772222728871
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
---
|
||||
name: api-gateway
|
||||
description: |
|
||||
API gateway for calling third-party APIs with managed OAuth connections, provided by Maton (https://maton.ai).
|
||||
Use this skill when users want to interact with external services like Slack, HubSpot, Salesforce, Google Workspace, Stripe, and more.
|
||||
Access is scoped to connections you explicitly authorize via OAuth - the API key alone does not grant access to any third-party service.
|
||||
Requires network access and valid Maton API key.
|
||||
Connect to 100+ APIs (Google Workspace, Microsoft 365, Notion, Slack, Airtable, HubSpot, etc.) with managed OAuth.
|
||||
Use this skill when users want to interact with external services.
|
||||
Security: The MATON_API_KEY authenticates with Maton.ai but grants NO access to third-party services by itself. Each service requires explicit OAuth authorization by the user through Maton's connect flow. Access is strictly scoped to connections the user has authorized. Provided by Maton (https://maton.ai).
|
||||
compatibility: Requires network access and valid Maton API key
|
||||
metadata:
|
||||
author: maton
|
||||
version: "1.0"
|
||||
@@ -210,6 +210,7 @@ If omitted, the gateway uses the default (oldest) active connection for that app
|
||||
| GetResponse | `getresponse` | `api.getresponse.com` |
|
||||
| GitHub | `github` | `api.github.com` |
|
||||
| Gumroad | `gumroad` | `api.gumroad.com` |
|
||||
| Granola | `granola` | `mcp.granola.ai` (MCP) |
|
||||
| Google Ads | `google-ads` | `googleads.googleapis.com` |
|
||||
| Google BigQuery | `google-bigquery` | `bigquery.googleapis.com` |
|
||||
| Google Analytics Admin | `google-analytics-admin` | `analyticsadmin.googleapis.com` |
|
||||
@@ -245,6 +246,7 @@ If omitted, the gateway uses the default (oldest) active connection for that app
|
||||
| Mailgun | `mailgun` | `api.mailgun.net` |
|
||||
| ManyChat | `manychat` | `api.manychat.com` |
|
||||
| Microsoft Excel | `microsoft-excel` | `graph.microsoft.com` |
|
||||
| Microsoft Teams | `microsoft-teams` | `graph.microsoft.com` |
|
||||
| Microsoft To Do | `microsoft-to-do` | `graph.microsoft.com` |
|
||||
| Monday.com | `monday` | `api.monday.com` |
|
||||
| Motion | `motion` | `api.usemotion.com` |
|
||||
@@ -255,13 +257,16 @@ If omitted, the gateway uses the default (oldest) active connection for that app
|
||||
| PDF.co | `pdf-co` | `api.pdf.co` |
|
||||
| Pipedrive | `pipedrive` | `api.pipedrive.com` |
|
||||
| Podio | `podio` | `api.podio.com` |
|
||||
| PostHog | `posthog` | `{subdomain}.posthog.com` |
|
||||
| QuickBooks | `quickbooks` | `quickbooks.api.intuit.com` |
|
||||
| Quo | `quo` | `api.openphone.com` |
|
||||
| Salesforce | `salesforce` | `{instance}.salesforce.com` |
|
||||
| Sentry | `sentry` | `{subdomain}.sentry.io` |
|
||||
| SignNow | `signnow` | `api.signnow.com` |
|
||||
| Slack | `slack` | `slack.com` |
|
||||
| Snapchat | `snapchat` | `adsapi.snapchat.com` |
|
||||
| Square | `squareup` | `connect.squareup.com` |
|
||||
| Squarespace | `squarespace` | `api.squarespace.com` |
|
||||
| Stripe | `stripe` | `api.stripe.com` |
|
||||
| Systeme.io | `systeme` | `api.systeme.io` |
|
||||
| Tally | `tally` | `api.tally.so` |
|
||||
@@ -322,6 +327,7 @@ See [references/](references/) for detailed routing guides per provider:
|
||||
- [GetResponse](references/getresponse.md) - Campaigns, contacts, newsletters, autoresponders, tags, segments
|
||||
- [GitHub](references/github.md) - Repositories, issues, pull requests, commits
|
||||
- [Gumroad](references/gumroad.md) - Products, sales, subscribers, licenses, webhooks
|
||||
- [Granola](references/granola.md) - Meeting notes, transcripts, queries (MCP)
|
||||
- [Google Ads](references/google-ads.md) - Campaigns, ad groups, GAQL queries
|
||||
- [Google Analytics Admin](references/google-analytics-admin.md) - Reports, dimensions, metrics
|
||||
- [Google Analytics Data](references/google-analytics-data.md) - Reports, dimensions, metrics
|
||||
@@ -357,6 +363,7 @@ See [references/](references/) for detailed routing guides per provider:
|
||||
- [Mailgun](references/mailgun.md) - Email sending, domains, routes, templates, mailing lists, suppressions
|
||||
- [ManyChat](references/manychat.md) - Subscribers, tags, flows, messaging
|
||||
- [Microsoft Excel](references/microsoft-excel.md) - Workbooks, worksheets, ranges, tables, charts
|
||||
- [Microsoft Teams](references/microsoft-teams.md) - Teams, channels, messages, members, chats
|
||||
- [Microsoft To Do](references/microsoft-to-do.md) - Task lists, tasks, checklist items, linked resources
|
||||
- [Monday.com](references/monday.md) - Boards, items, columns, groups (GraphQL)
|
||||
- [Motion](references/motion.md) - Tasks, projects, workspaces, schedules
|
||||
@@ -367,14 +374,17 @@ See [references/](references/) for detailed routing guides per provider:
|
||||
- [PDF.co](references/pdf-co.md) - PDF conversion, merge, split, edit, text extraction, barcodes
|
||||
- [Pipedrive](references/pipedrive.md) - Deals, persons, organizations, activities
|
||||
- [Podio](references/podio.md) - Organizations, workspaces, apps, items, tasks, comments
|
||||
- [PostHog](references/posthog.md) - Product analytics, feature flags, session recordings, experiments, HogQL queries
|
||||
- [QuickBooks](references/quickbooks.md) - Customers, invoices, reports
|
||||
- [Quo](references/quo.md) - Calls, messages, contacts, conversations, webhooks
|
||||
- [Salesforce](references/salesforce.md) - SOQL, sObjects, CRUD
|
||||
- [SignNow](references/signnow.md) - Documents, templates, invites, e-signatures
|
||||
- [SendGrid](references/sendgrid.md) - Email sending, contacts, templates, suppressions, statistics
|
||||
- [Sentry](references/sentry.md) - Issues, events, projects, teams, releases
|
||||
- [Slack](references/slack.md) - Messages, channels, users
|
||||
- [Snapchat](references/snapchat.md) - Ad accounts, campaigns, ad squads, ads, creatives, audiences
|
||||
- [Square](references/squareup.md) - Payments, customers, orders, catalog, inventory, invoices
|
||||
- [Squarespace](references/squarespace.md) - Products, inventory, orders, profiles, transactions
|
||||
- [Stripe](references/stripe.md) - Customers, subscriptions, payments
|
||||
- [Systeme.io](references/systeme.md) - Contacts, tags, courses, communities, webhooks
|
||||
- [Tally](references/tally.md) - Forms, submissions, workspaces, webhooks
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"ownerId": "kn75240wq8bnv2qm2xgry748jd80b9r0",
|
||||
"slug": "api-gateway",
|
||||
"version": "1.0.35",
|
||||
"publishedAt": 1771398200201
|
||||
"version": "1.0.51",
|
||||
"publishedAt": 1772102946067
|
||||
}
|
||||
@@ -90,6 +90,7 @@ Content-Type: application/json
|
||||
"data": {
|
||||
"content": "Task description",
|
||||
"format": "plaintext",
|
||||
"deadline_at": null,
|
||||
"assignees": [],
|
||||
"linked_records": []
|
||||
}
|
||||
@@ -106,14 +107,182 @@ GET /attio/v2/workspace_members
|
||||
GET /attio/v2/self
|
||||
```
|
||||
|
||||
## Notes
|
||||
### Notes
|
||||
|
||||
#### List Notes
|
||||
```bash
|
||||
GET /attio/v2/notes?limit=50&parent_object={object}&parent_record_id={record_id}
|
||||
```
|
||||
|
||||
#### Get Note
|
||||
```bash
|
||||
GET /attio/v2/notes/{note_id}
|
||||
```
|
||||
|
||||
#### Create Note
|
||||
```bash
|
||||
POST /attio/v2/notes
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"data": {
|
||||
"format": "plaintext",
|
||||
"title": "Meeting Summary",
|
||||
"content": "Note content here",
|
||||
"parent_object": "companies",
|
||||
"parent_record_id": "{record_id}",
|
||||
"created_by_actor": {
|
||||
"type": "workspace-member",
|
||||
"id": "{workspace_member_id}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Delete Note
|
||||
```bash
|
||||
DELETE /attio/v2/notes/{note_id}
|
||||
```
|
||||
|
||||
### Comments
|
||||
|
||||
#### Create Comment on Record
|
||||
```bash
|
||||
POST /attio/v2/comments
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"data": {
|
||||
"format": "plaintext",
|
||||
"content": "Comment text",
|
||||
"author": {
|
||||
"type": "workspace-member",
|
||||
"id": "{workspace_member_id}"
|
||||
},
|
||||
"record": {
|
||||
"object": "companies",
|
||||
"record_id": "{record_id}"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Reply to Comment Thread
|
||||
```bash
|
||||
POST /attio/v2/comments
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"data": {
|
||||
"format": "plaintext",
|
||||
"content": "This is a reply",
|
||||
"author": {
|
||||
"type": "workspace-member",
|
||||
"id": "{workspace_member_id}"
|
||||
},
|
||||
"thread_id": "{thread_id}"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Lists
|
||||
|
||||
#### List All Lists
|
||||
```bash
|
||||
GET /attio/v2/lists
|
||||
```
|
||||
|
||||
#### Get List
|
||||
```bash
|
||||
GET /attio/v2/lists/{list_id}
|
||||
```
|
||||
|
||||
### List Entries
|
||||
|
||||
#### Query List Entries
|
||||
```bash
|
||||
POST /attio/v2/lists/{list}/entries/query
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"limit": 50,
|
||||
"offset": 0
|
||||
}
|
||||
```
|
||||
|
||||
#### Create List Entry
|
||||
```bash
|
||||
POST /attio/v2/lists/{list}/entries
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"data": {
|
||||
"parent_record_id": "{record_id}",
|
||||
"parent_object": "companies",
|
||||
"entry_values": {}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Get List Entry
|
||||
```bash
|
||||
GET /attio/v2/lists/{list}/entries/{entry_id}
|
||||
```
|
||||
|
||||
#### Update List Entry
|
||||
```bash
|
||||
PATCH /attio/v2/lists/{list}/entries/{entry_id}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"data": {
|
||||
"entry_values": {
|
||||
"status": "Active"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Delete List Entry
|
||||
```bash
|
||||
DELETE /attio/v2/lists/{list}/entries/{entry_id}
|
||||
```
|
||||
|
||||
### Meetings
|
||||
|
||||
#### List Meetings
|
||||
```bash
|
||||
GET /attio/v2/meetings?limit=50
|
||||
```
|
||||
|
||||
#### Get Meeting
|
||||
```bash
|
||||
GET /attio/v2/meetings/{meeting_id}
|
||||
```
|
||||
|
||||
### Call Recordings
|
||||
|
||||
#### List Call Recordings for Meeting
|
||||
```bash
|
||||
GET /attio/v2/meetings/{meeting_id}/call_recordings?limit=50
|
||||
```
|
||||
|
||||
#### Get Call Recording
|
||||
```bash
|
||||
GET /attio/v2/meetings/{meeting_id}/call_recordings/{call_recording_id}
|
||||
```
|
||||
|
||||
## Usage Notes
|
||||
|
||||
- Object slugs are lowercase snake_case (e.g., `people`, `companies`)
|
||||
- Record IDs are UUIDs
|
||||
- For personal-name attributes, include `full_name` when creating records
|
||||
- Task creation requires `format` and `assignees` fields
|
||||
- Task creation requires `format`, `deadline_at`, `assignees`, and `linked_records` fields
|
||||
- Note creation requires `format`, `content`, `parent_object`, and `parent_record_id`
|
||||
- Comment creation requires `format`, `content`, `author`, plus one of `record`, `entry`, or `thread_id`
|
||||
- Meetings use cursor-based pagination
|
||||
- Rate limits: 100 read/sec, 25 write/sec
|
||||
- Pagination uses `limit` and `offset` parameters
|
||||
- Pagination uses `limit` and `offset` parameters (or `cursor` for meetings)
|
||||
|
||||
## Resources
|
||||
|
||||
|
||||
@@ -11,11 +11,9 @@
|
||||
|
||||
**Note:** Dropbox Business API uses POST for almost all endpoints, including read operations. Request bodies should be JSON (use `null` for endpoints with no parameters).
|
||||
|
||||
## Common Endpoints
|
||||
## Team Information
|
||||
|
||||
### Team Information
|
||||
|
||||
#### Get Team Info
|
||||
### Get Team Info
|
||||
```bash
|
||||
POST /dropbox-business/2/team/get_info
|
||||
Content-Type: application/json
|
||||
@@ -23,39 +21,72 @@ Content-Type: application/json
|
||||
null
|
||||
```
|
||||
|
||||
#### Get Team Features
|
||||
### Get Team Features
|
||||
```bash
|
||||
POST /dropbox-business/2/team/features/get_values
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"features": [{".tag": "upload_api_rate_limit"}]
|
||||
"features": [
|
||||
{".tag": "upload_api_rate_limit"},
|
||||
{".tag": "has_team_shared_dropbox"},
|
||||
{".tag": "has_team_file_events"},
|
||||
{".tag": "has_team_selective_sync"}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Team Members
|
||||
### Get Authenticated Admin
|
||||
```bash
|
||||
POST /dropbox-business/2/team/token/get_authenticated_admin
|
||||
Content-Type: application/json
|
||||
|
||||
#### List Members
|
||||
null
|
||||
```
|
||||
|
||||
## Team Members
|
||||
|
||||
### List Members
|
||||
```bash
|
||||
POST /dropbox-business/2/team/members/list
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"limit": 100
|
||||
}
|
||||
{"limit": 100}
|
||||
```
|
||||
|
||||
#### Get Member Info
|
||||
### List Members (V2) - Recommended
|
||||
```bash
|
||||
POST /dropbox-business/2/team/members/list_v2
|
||||
Content-Type: application/json
|
||||
|
||||
{"limit": 100, "include_removed": false}
|
||||
```
|
||||
|
||||
### Continue Listing Members
|
||||
```bash
|
||||
POST /dropbox-business/2/team/members/list/continue
|
||||
Content-Type: application/json
|
||||
|
||||
{"cursor": "..."}
|
||||
```
|
||||
|
||||
### Get Member Info
|
||||
```bash
|
||||
POST /dropbox-business/2/team/members/get_info
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"members": [{".tag": "email", "email": "user@company.com"}]
|
||||
}
|
||||
{"members": [{".tag": "email", "email": "user@company.com"}]}
|
||||
```
|
||||
|
||||
#### Add Member
|
||||
### Get Member Info (V2) - Recommended
|
||||
```bash
|
||||
POST /dropbox-business/2/team/members/get_info_v2
|
||||
Content-Type: application/json
|
||||
|
||||
{"members": [{".tag": "email", "email": "user@company.com"}]}
|
||||
```
|
||||
|
||||
### Add Member
|
||||
```bash
|
||||
POST /dropbox-business/2/team/members/add
|
||||
Content-Type: application/json
|
||||
@@ -64,24 +95,152 @@ Content-Type: application/json
|
||||
"new_members": [{
|
||||
"member_email": "user@company.com",
|
||||
"member_given_name": "John",
|
||||
"member_surname": "Doe"
|
||||
"member_surname": "Doe",
|
||||
"send_welcome_email": true
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
### Groups
|
||||
### Suspend Member
|
||||
```bash
|
||||
POST /dropbox-business/2/team/members/suspend
|
||||
Content-Type: application/json
|
||||
|
||||
#### List Groups
|
||||
{"user": {".tag": "email", "email": "user@company.com"}, "wipe_data": false}
|
||||
```
|
||||
|
||||
### Unsuspend Member
|
||||
```bash
|
||||
POST /dropbox-business/2/team/members/unsuspend
|
||||
Content-Type: application/json
|
||||
|
||||
{"user": {".tag": "email", "email": "user@company.com"}}
|
||||
```
|
||||
|
||||
### Remove Member
|
||||
```bash
|
||||
POST /dropbox-business/2/team/members/remove
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"user": {".tag": "email", "email": "user@company.com"},
|
||||
"wipe_data": true,
|
||||
"transfer_dest_id": {".tag": "email", "email": "admin@company.com"},
|
||||
"transfer_admin_id": {".tag": "email", "email": "admin@company.com"},
|
||||
"keep_account": false
|
||||
}
|
||||
```
|
||||
|
||||
### Send Welcome Email
|
||||
```bash
|
||||
POST /dropbox-business/2/team/members/send_welcome_email
|
||||
Content-Type: application/json
|
||||
|
||||
{".tag": "email", "email": "pending@company.com"}
|
||||
```
|
||||
|
||||
### Set Member Profile (V2)
|
||||
```bash
|
||||
POST /dropbox-business/2/team/members/set_profile_v2
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"user": {".tag": "team_member_id", "team_member_id": "dbmid:AAA..."},
|
||||
"new_given_name": "John",
|
||||
"new_surname": "Smith"
|
||||
}
|
||||
```
|
||||
|
||||
### Set Admin Permissions (V2)
|
||||
```bash
|
||||
POST /dropbox-business/2/team/members/set_admin_permissions_v2
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"user": {".tag": "email", "email": "user@company.com"},
|
||||
"new_roles": ["pid_dbtmr:..."]
|
||||
}
|
||||
```
|
||||
|
||||
### Delete Profile Photo (V2)
|
||||
```bash
|
||||
POST /dropbox-business/2/team/members/delete_profile_photo_v2
|
||||
Content-Type: application/json
|
||||
|
||||
{"user": {".tag": "team_member_id", "team_member_id": "dbmid:AAA..."}}
|
||||
```
|
||||
|
||||
## Secondary Emails
|
||||
|
||||
### Add Secondary Emails
|
||||
```bash
|
||||
POST /dropbox-business/2/team/members/secondary_emails/add
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"new_secondary_emails": [{
|
||||
"user": {".tag": "email", "email": "user@company.com"},
|
||||
"secondary_emails": ["alias@company.com"]
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
### Delete Secondary Emails
|
||||
```bash
|
||||
POST /dropbox-business/2/team/members/secondary_emails/delete
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"emails_to_delete": [{
|
||||
"user": {".tag": "email", "email": "user@company.com"},
|
||||
"secondary_emails": ["alias@company.com"]
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
### Resend Verification Emails
|
||||
```bash
|
||||
POST /dropbox-business/2/team/members/secondary_emails/resend_verification_emails
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"emails_to_resend": [{
|
||||
"user": {".tag": "email", "email": "user@company.com"},
|
||||
"secondary_emails": ["alias@company.com"]
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
## Groups
|
||||
|
||||
### List Groups
|
||||
```bash
|
||||
POST /dropbox-business/2/team/groups/list
|
||||
Content-Type: application/json
|
||||
|
||||
{"limit": 100}
|
||||
```
|
||||
|
||||
### Get Group Info
|
||||
```bash
|
||||
POST /dropbox-business/2/team/groups/get_info
|
||||
Content-Type: application/json
|
||||
|
||||
{".tag": "group_ids", "group_ids": ["g:1d31f47b..."]}
|
||||
```
|
||||
|
||||
### List Group Members
|
||||
```bash
|
||||
POST /dropbox-business/2/team/groups/members/list
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"group": {".tag": "group_id", "group_id": "g:1d31f47b..."},
|
||||
"limit": 100
|
||||
}
|
||||
```
|
||||
|
||||
#### Create Group
|
||||
### Create Group
|
||||
```bash
|
||||
POST /dropbox-business/2/team/groups/create
|
||||
Content-Type: application/json
|
||||
@@ -92,43 +251,136 @@ Content-Type: application/json
|
||||
}
|
||||
```
|
||||
|
||||
### Team Folders
|
||||
### Update Group
|
||||
```bash
|
||||
POST /dropbox-business/2/team/groups/update
|
||||
Content-Type: application/json
|
||||
|
||||
#### List Team Folders
|
||||
{
|
||||
"group": {".tag": "group_id", "group_id": "g:1d31f47b..."},
|
||||
"new_group_name": "New Name"
|
||||
}
|
||||
```
|
||||
|
||||
### Add Members to Group
|
||||
```bash
|
||||
POST /dropbox-business/2/team/groups/members/add
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"group": {".tag": "group_id", "group_id": "g:1d31f47b..."},
|
||||
"members": [{"user": {".tag": "email", "email": "user@company.com"}, "access_type": {".tag": "member"}}],
|
||||
"return_members": true
|
||||
}
|
||||
```
|
||||
|
||||
### Remove Members from Group
|
||||
```bash
|
||||
POST /dropbox-business/2/team/groups/members/remove
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"group": {".tag": "group_id", "group_id": "g:1d31f47b..."},
|
||||
"users": [{".tag": "email", "email": "user@company.com"}],
|
||||
"return_members": true
|
||||
}
|
||||
```
|
||||
|
||||
### Delete Group
|
||||
```bash
|
||||
POST /dropbox-business/2/team/groups/delete
|
||||
Content-Type: application/json
|
||||
|
||||
{".tag": "group_id", "group_id": "g:1d31f47b..."}
|
||||
```
|
||||
|
||||
### Check Group Job Status
|
||||
```bash
|
||||
POST /dropbox-business/2/team/groups/job_status/get
|
||||
Content-Type: application/json
|
||||
|
||||
{"async_job_id": "dbjid:..."}
|
||||
```
|
||||
|
||||
## Team Folders
|
||||
|
||||
### List Team Folders
|
||||
```bash
|
||||
POST /dropbox-business/2/team/team_folder/list
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"limit": 100
|
||||
}
|
||||
{"limit": 100}
|
||||
```
|
||||
|
||||
#### Create Team Folder
|
||||
### Get Team Folder Info
|
||||
```bash
|
||||
POST /dropbox-business/2/team/team_folder/get_info
|
||||
Content-Type: application/json
|
||||
|
||||
{"team_folder_ids": ["13646676387"]}
|
||||
```
|
||||
|
||||
### Create Team Folder
|
||||
```bash
|
||||
POST /dropbox-business/2/team/team_folder/create
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "Folder Name"
|
||||
}
|
||||
{"name": "Folder Name", "sync_setting": {".tag": "default"}}
|
||||
```
|
||||
|
||||
### Namespaces
|
||||
### Rename Team Folder
|
||||
```bash
|
||||
POST /dropbox-business/2/team/team_folder/rename
|
||||
Content-Type: application/json
|
||||
|
||||
#### List Namespaces
|
||||
{"team_folder_id": "13646676387", "name": "New Name"}
|
||||
```
|
||||
|
||||
### Archive Team Folder
|
||||
```bash
|
||||
POST /dropbox-business/2/team/team_folder/archive
|
||||
Content-Type: application/json
|
||||
|
||||
{"team_folder_id": "13646676387", "force_async_off": false}
|
||||
```
|
||||
|
||||
### Activate Team Folder
|
||||
```bash
|
||||
POST /dropbox-business/2/team/team_folder/activate
|
||||
Content-Type: application/json
|
||||
|
||||
{"team_folder_id": "13646676387"}
|
||||
```
|
||||
|
||||
### Update Sync Settings
|
||||
```bash
|
||||
POST /dropbox-business/2/team/team_folder/update_sync_settings
|
||||
Content-Type: application/json
|
||||
|
||||
{"team_folder_id": "13646676387", "sync_setting": {".tag": "default"}}
|
||||
```
|
||||
|
||||
### Permanently Delete Team Folder
|
||||
```bash
|
||||
POST /dropbox-business/2/team/team_folder/permanently_delete
|
||||
Content-Type: application/json
|
||||
|
||||
{"team_folder_id": "13646676387"}
|
||||
```
|
||||
|
||||
## Namespaces
|
||||
|
||||
### List Namespaces
|
||||
```bash
|
||||
POST /dropbox-business/2/team/namespaces/list
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"limit": 100
|
||||
}
|
||||
{"limit": 100}
|
||||
```
|
||||
|
||||
### Devices
|
||||
## Devices
|
||||
|
||||
#### List Members' Devices
|
||||
### List Members' Devices
|
||||
```bash
|
||||
POST /dropbox-business/2/team/devices/list_members_devices
|
||||
Content-Type: application/json
|
||||
@@ -136,16 +388,147 @@ Content-Type: application/json
|
||||
{}
|
||||
```
|
||||
|
||||
### Audit Log
|
||||
### List Member Devices
|
||||
```bash
|
||||
POST /dropbox-business/2/team/devices/list_member_devices
|
||||
Content-Type: application/json
|
||||
|
||||
#### Get Events
|
||||
{"team_member_id": "dbmid:AAA..."}
|
||||
```
|
||||
|
||||
### Revoke Device Session
|
||||
```bash
|
||||
POST /dropbox-business/2/team/devices/revoke_device_session
|
||||
Content-Type: application/json
|
||||
|
||||
{".tag": "web_session", "session_id": "dbwsid:...", "team_member_id": "dbmid:AAA..."}
|
||||
```
|
||||
|
||||
### Revoke Device Sessions (Batch)
|
||||
```bash
|
||||
POST /dropbox-business/2/team/devices/revoke_device_session_batch
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"revoke_devices": [
|
||||
{".tag": "web_session", "session_id": "dbwsid:...", "team_member_id": "dbmid:AAA..."}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Linked Apps
|
||||
|
||||
### List Members' Linked Apps
|
||||
```bash
|
||||
POST /dropbox-business/2/team/linked_apps/list_members_linked_apps
|
||||
Content-Type: application/json
|
||||
|
||||
{}
|
||||
```
|
||||
|
||||
### List Team Linked Apps
|
||||
```bash
|
||||
POST /dropbox-business/2/team/linked_apps/list_team_linked_apps
|
||||
Content-Type: application/json
|
||||
|
||||
{}
|
||||
```
|
||||
|
||||
### Revoke Linked App
|
||||
```bash
|
||||
POST /dropbox-business/2/team/linked_apps/revoke_linked_app
|
||||
Content-Type: application/json
|
||||
|
||||
{"app_id": "...", "team_member_id": "dbmid:AAA..."}
|
||||
```
|
||||
|
||||
## Member Space Limits
|
||||
|
||||
### Get Custom Quotas
|
||||
```bash
|
||||
POST /dropbox-business/2/team/member_space_limits/get_custom_quota
|
||||
Content-Type: application/json
|
||||
|
||||
{"users": [{".tag": "email", "email": "user@company.com"}]}
|
||||
```
|
||||
|
||||
### Set Custom Quotas
|
||||
```bash
|
||||
POST /dropbox-business/2/team/member_space_limits/set_custom_quota
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"users_and_quotas": [{
|
||||
"user": {".tag": "email", "email": "user@company.com"},
|
||||
"quota_gb": 100
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
### List Excluded Users
|
||||
```bash
|
||||
POST /dropbox-business/2/team/member_space_limits/excluded_users/list
|
||||
Content-Type: application/json
|
||||
|
||||
{}
|
||||
```
|
||||
|
||||
## Sharing Allowlist
|
||||
|
||||
### List Sharing Allowlist
|
||||
```bash
|
||||
POST /dropbox-business/2/team/sharing_allowlist/list
|
||||
Content-Type: application/json
|
||||
|
||||
{}
|
||||
```
|
||||
|
||||
### Add to Sharing Allowlist
|
||||
```bash
|
||||
POST /dropbox-business/2/team/sharing_allowlist/add
|
||||
Content-Type: application/json
|
||||
|
||||
{"domains": ["partner.com"], "emails": ["external@client.com"]}
|
||||
```
|
||||
|
||||
## Audit Log (Team Log)
|
||||
|
||||
### Get Events
|
||||
```bash
|
||||
POST /dropbox-business/2/team_log/get_events
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"limit": 100
|
||||
}
|
||||
{"limit": 100, "category": {".tag": "members"}}
|
||||
```
|
||||
|
||||
### Continue Getting Events
|
||||
```bash
|
||||
POST /dropbox-business/2/team_log/get_events/continue
|
||||
Content-Type: application/json
|
||||
|
||||
{"cursor": "..."}
|
||||
```
|
||||
|
||||
## Member File Access
|
||||
|
||||
Use the `Dropbox-API-Select-User` header with a team_member_id to access files on behalf of a member.
|
||||
|
||||
### List Member's Files
|
||||
```bash
|
||||
POST /dropbox-business/2/files/list_folder
|
||||
Content-Type: application/json
|
||||
Dropbox-API-Select-User: dbmid:AAA...
|
||||
|
||||
{"path": ""}
|
||||
```
|
||||
|
||||
### List Member's Shared Folders
|
||||
```bash
|
||||
POST /dropbox-business/2/sharing/list_folders
|
||||
Content-Type: application/json
|
||||
Dropbox-API-Select-User: dbmid:AAA...
|
||||
|
||||
{}
|
||||
```
|
||||
|
||||
## Notes
|
||||
@@ -154,9 +537,28 @@ Content-Type: application/json
|
||||
- Request bodies must be JSON (use `null` for no-parameter endpoints)
|
||||
- Many fields use `.tag` format for type indication
|
||||
- Pagination uses `cursor` and `has_more` fields
|
||||
- Requires team admin OAuth authorization
|
||||
- Use V2 endpoints for enhanced responses with roles info
|
||||
- `Dropbox-API-Select-User` header enables member file access
|
||||
- System-managed groups cannot be modified
|
||||
- Reports endpoints (`team/reports/*`) are deprecated
|
||||
|
||||
## OAuth Scopes
|
||||
|
||||
| Scope | Usage |
|
||||
|-------|-------|
|
||||
| `team_info.read` | Team info, features |
|
||||
| `members.read` | List/get members |
|
||||
| `members.write` | Add/modify members |
|
||||
| `members.delete` | Remove members |
|
||||
| `groups.read` | List/get groups |
|
||||
| `groups.write` | Create/modify groups |
|
||||
| `sessions.list` | List devices/sessions |
|
||||
| `sessions.modify` | Revoke sessions |
|
||||
| `events.read` | Team audit log |
|
||||
| `team_data.member` | Select-User header |
|
||||
|
||||
## Resources
|
||||
|
||||
- [Dropbox Business API Documentation](https://www.dropbox.com/developers/documentation/http/teams)
|
||||
- [Team Administration Guide](https://developers.dropbox.com/dbx-team-administration-guide)
|
||||
- [Team Files Guide](https://developers.dropbox.com/dbx-team-files-guide)
|
||||
|
||||
@@ -9,10 +9,80 @@
|
||||
/google-merchant/{sub-api}/{version}/accounts/{accountId}/{resource}
|
||||
```
|
||||
|
||||
The Merchant API uses sub-APIs: `products`, `accounts`, `datasources`, `reports`, `promotions`, `inventories`, `notifications`, `conversions`, `lfp`
|
||||
The Merchant API uses sub-APIs: `products`, `accounts`, `datasources`, `reports`, `promotions`, `inventories`, `notifications`, `conversions`
|
||||
|
||||
**Important:** The v1 API requires one-time developer registration per Merchant Center account. Complete the registration steps below before using any endpoints.
|
||||
|
||||
## Developer Registration
|
||||
|
||||
Before using v1 endpoints, you must complete a one-time registration:
|
||||
|
||||
### Step 1: Get Your Account ID
|
||||
|
||||
**Option A: Try fetching via API first**
|
||||
|
||||
Try listing accounts using the v1beta endpoint. If this works, you can get your account ID automatically:
|
||||
|
||||
```bash
|
||||
GET /google-merchant/accounts/v1beta/accounts
|
||||
```
|
||||
|
||||
Response (if successful):
|
||||
```json
|
||||
{
|
||||
"accounts": [
|
||||
{"accountId": "123456789", "accountName": "My Store"}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**Option B: From Merchant Center UI (if Option A fails)**
|
||||
|
||||
If the v1beta endpoint is unavailable or returns an error:
|
||||
|
||||
1. Log in to [Google Merchant Center](https://merchants.google.com/)
|
||||
2. Your account ID is in the URL: `https://merchants.google.com/mc/overview?a=YOUR_ACCOUNT_ID`
|
||||
|
||||
For example, if your URL is `https://merchants.google.com/mc/overview?a=123456789`, your account ID is `123456789`.
|
||||
|
||||
### Step 2: Register for API Access
|
||||
|
||||
```bash
|
||||
POST /google-merchant/accounts/v1/accounts/{accountId}/developerRegistration:registerGcp
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"developerEmail": "your-email@example.com"
|
||||
}
|
||||
```
|
||||
|
||||
Replace `{accountId}` with your account ID from Step 1, and use the email associated with your Google account.
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"name": "accounts/123456789/developerRegistration",
|
||||
"gcpIds": ["..."]
|
||||
}
|
||||
```
|
||||
|
||||
### Step 3: Verify Registration
|
||||
|
||||
After registration, test that v1 endpoints work:
|
||||
|
||||
```bash
|
||||
GET /google-merchant/accounts/v1/accounts/{accountId}
|
||||
```
|
||||
|
||||
**Note:** Registration only needs to be done once per Merchant Center account. After successful registration, all v1 endpoints will work for that account.
|
||||
|
||||
## Common Endpoints
|
||||
|
||||
### List Accounts
|
||||
```bash
|
||||
GET /google-merchant/accounts/v1/accounts
|
||||
```
|
||||
|
||||
### List Products
|
||||
```bash
|
||||
GET /google-merchant/products/v1/accounts/{accountId}/products
|
||||
@@ -34,7 +104,7 @@ Content-Type: application/json
|
||||
"offerId": "sku123",
|
||||
"contentLanguage": "en",
|
||||
"feedLabel": "US",
|
||||
"attributes": {
|
||||
"productAttributes": {
|
||||
"title": "Product Title",
|
||||
"link": "https://example.com/product",
|
||||
"imageLink": "https://example.com/image.jpg",
|
||||
@@ -60,33 +130,47 @@ POST /google-merchant/reports/v1/accounts/{accountId}/reports:search
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"query": "SELECT offer_id, title, clicks FROM product_performance_view WHERE date BETWEEN '2026-01-01' AND '2026-01-31'"
|
||||
"query": "SELECT id, offer_id, title FROM product_view LIMIT 10"
|
||||
}
|
||||
```
|
||||
|
||||
Note: The `product_view` table requires the `id` field in SELECT clause.
|
||||
|
||||
### List Promotions
|
||||
```bash
|
||||
GET /google-merchant/promotions/v1/accounts/{accountId}/promotions
|
||||
```
|
||||
|
||||
Note: Requires Promotions program enrollment.
|
||||
|
||||
### Get Account
|
||||
```bash
|
||||
GET /google-merchant/accounts/v1/accounts/{accountId}
|
||||
```
|
||||
|
||||
### List Regional Inventories
|
||||
```bash
|
||||
GET /google-merchant/inventories/v1/accounts/{accountId}/products/{productId}/regionalInventories
|
||||
```
|
||||
|
||||
### List Local Inventories
|
||||
```bash
|
||||
GET /google-merchant/inventories/v1/accounts/{accountId}/products/{productId}/localInventories
|
||||
```
|
||||
|
||||
Note: Local inventories only work for products with LOCAL channel.
|
||||
|
||||
## Notes
|
||||
|
||||
- **Developer registration required** - Complete registration before using v1 endpoints
|
||||
- Authentication is automatic - the router injects the OAuth token
|
||||
- Account ID is your Merchant Center numeric ID (visible in MC URL)
|
||||
- Product IDs use format `contentLanguage~feedLabel~offerId`
|
||||
- Monetary values use micros (divide by 1,000,000)
|
||||
- Products can only be inserted in data sources of type `API`
|
||||
- Products can only be inserted in data sources with `input: "API"` type
|
||||
- Uses token-based pagination with `pageSize` and `pageToken`
|
||||
- Promotions require account enrollment in Promotions program
|
||||
- Local inventories only work for LOCAL channel products
|
||||
|
||||
## Resources
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
# Granola Routing Reference
|
||||
|
||||
**App name:** `granola`
|
||||
**Base URL proxied:** `mcp.granola.ai` (MCP Server)
|
||||
|
||||
## API Path Pattern
|
||||
|
||||
Granola uses the Model Context Protocol (MCP). All requests are POST requests to tool endpoints:
|
||||
|
||||
```
|
||||
/granola/{tool_name}
|
||||
```
|
||||
|
||||
## MCP Tools
|
||||
|
||||
### Query Meeting Notes
|
||||
```bash
|
||||
POST /granola/query_granola_meetings
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"query": "What action items came from my last meeting?"
|
||||
}
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
- `query` (string, required): Natural language query about meetings
|
||||
|
||||
### List Meetings
|
||||
```bash
|
||||
POST /granola/list_meetings
|
||||
Content-Type: application/json
|
||||
|
||||
{}
|
||||
```
|
||||
|
||||
**Parameters:** None required. Returns recent meetings with metadata.
|
||||
|
||||
### Get Meetings
|
||||
```bash
|
||||
POST /granola/get_meetings
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"meeting_ids": ["0dba4400-50f1-4262-9ac7-89cd27b79371"]
|
||||
}
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
- `meeting_ids` (array of strings, required): Meeting IDs to retrieve
|
||||
|
||||
### Get Meeting Transcript
|
||||
```bash
|
||||
POST /granola/get_meeting_transcript
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"meeting_id": "0dba4400-50f1-4262-9ac7-89cd27b79371"
|
||||
}
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
- `meeting_id` (string, required): Meeting ID to get transcript for
|
||||
|
||||
**Note:** Only available on paid Granola tiers.
|
||||
|
||||
## Response Format
|
||||
|
||||
All responses follow MCP format:
|
||||
|
||||
```json
|
||||
{
|
||||
"content": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": "Response content here..."
|
||||
}
|
||||
],
|
||||
"isError": false
|
||||
}
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- All tool calls are POST requests with JSON body
|
||||
- Meeting IDs are UUIDs (e.g., `0dba4400-50f1-4262-9ac7-89cd27b79371`)
|
||||
- Users can only access their own meeting notes
|
||||
- Free tier users limited to notes from last 30 days
|
||||
- Transcripts require paid Granola tier
|
||||
- Rate limit: ~100 requests/minute
|
||||
|
||||
## Resources
|
||||
|
||||
- [Granola MCP Documentation](https://docs.granola.ai/help-center/sharing/integrations/mcp)
|
||||
- [Granola Help Center](https://docs.granola.ai)
|
||||
@@ -0,0 +1,306 @@
|
||||
# Microsoft Teams Routing Reference
|
||||
|
||||
**App name:** `microsoft-teams`
|
||||
**Base URL proxied:** `graph.microsoft.com`
|
||||
|
||||
## API Path Pattern
|
||||
|
||||
```
|
||||
/microsoft-teams/v1.0/{resource}
|
||||
```
|
||||
|
||||
## Common Endpoints
|
||||
|
||||
### Teams
|
||||
|
||||
#### List Joined Teams
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/me/joinedTeams
|
||||
```
|
||||
|
||||
#### Get Team
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/teams/{team-id}
|
||||
```
|
||||
|
||||
### Channels
|
||||
|
||||
#### List Channels
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/teams/{team-id}/channels
|
||||
```
|
||||
|
||||
#### List Private Channels
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/teams/{team-id}/channels?$filter=membershipType eq 'private'
|
||||
```
|
||||
|
||||
#### Get Channel
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/teams/{team-id}/channels/{channel-id}
|
||||
```
|
||||
|
||||
#### Create Channel
|
||||
```bash
|
||||
POST /microsoft-teams/v1.0/teams/{team-id}/channels
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"displayName": "Channel Name",
|
||||
"description": "Description",
|
||||
"membershipType": "standard"
|
||||
}
|
||||
```
|
||||
|
||||
#### Update Channel
|
||||
```bash
|
||||
PATCH /microsoft-teams/v1.0/teams/{team-id}/channels/{channel-id}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"description": "Updated description"
|
||||
}
|
||||
```
|
||||
|
||||
#### Delete Channel
|
||||
```bash
|
||||
DELETE /microsoft-teams/v1.0/teams/{team-id}/channels/{channel-id}
|
||||
```
|
||||
|
||||
### Channel Members
|
||||
|
||||
#### List Channel Members
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/teams/{team-id}/channels/{channel-id}/members
|
||||
```
|
||||
|
||||
### Messages
|
||||
|
||||
#### List Channel Messages
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/teams/{team-id}/channels/{channel-id}/messages
|
||||
```
|
||||
|
||||
#### Send Message
|
||||
```bash
|
||||
POST /microsoft-teams/v1.0/teams/{team-id}/channels/{channel-id}/messages
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"body": {
|
||||
"content": "Hello World"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Send HTML Message
|
||||
```bash
|
||||
POST /microsoft-teams/v1.0/teams/{team-id}/channels/{channel-id}/messages
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"body": {
|
||||
"contentType": "html",
|
||||
"content": "<p>Formatted message</p>"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Reply to Message
|
||||
```bash
|
||||
POST /microsoft-teams/v1.0/teams/{team-id}/channels/{channel-id}/messages/{message-id}/replies
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"body": {
|
||||
"content": "Reply content"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### List Message Replies
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/teams/{team-id}/channels/{channel-id}/messages/{message-id}/replies
|
||||
```
|
||||
|
||||
#### Edit Message
|
||||
```bash
|
||||
PATCH /microsoft-teams/v1.0/teams/{team-id}/channels/{channel-id}/messages/{message-id}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"body": {
|
||||
"content": "Updated message content"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Team Members
|
||||
|
||||
#### List Members
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/teams/{team-id}/members
|
||||
```
|
||||
|
||||
### Presence
|
||||
|
||||
#### Get User Presence
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/me/presence
|
||||
```
|
||||
|
||||
#### Get User Presence by ID
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/users/{user-id}/presence
|
||||
```
|
||||
|
||||
### Tabs
|
||||
|
||||
#### List Channel Tabs
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/teams/{team-id}/channels/{channel-id}/tabs
|
||||
```
|
||||
|
||||
### Apps
|
||||
|
||||
#### List Installed Apps
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/teams/{team-id}/installedApps
|
||||
```
|
||||
|
||||
### Online Meetings
|
||||
|
||||
#### Create Meeting
|
||||
```bash
|
||||
POST /microsoft-teams/v1.0/me/onlineMeetings
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"subject": "Team Sync",
|
||||
"startDateTime": "2026-02-18T10:00:00Z",
|
||||
"endDateTime": "2026-02-18T11:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
#### Create Meeting with Attendees
|
||||
```bash
|
||||
POST /microsoft-teams/v1.0/me/onlineMeetings
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"subject": "Project Review",
|
||||
"startDateTime": "2026-02-18T14:00:00Z",
|
||||
"endDateTime": "2026-02-18T15:00:00Z",
|
||||
"participants": {
|
||||
"attendees": [
|
||||
{
|
||||
"upn": "attendee@example.com",
|
||||
"role": "attendee"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Get Meeting
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/me/onlineMeetings/{meeting-id}
|
||||
```
|
||||
|
||||
#### Find Meeting by Join URL
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/me/onlineMeetings?$filter=JoinWebUrl eq '{encoded-join-url}'
|
||||
```
|
||||
|
||||
#### Delete Meeting
|
||||
```bash
|
||||
DELETE /microsoft-teams/v1.0/me/onlineMeetings/{meeting-id}
|
||||
```
|
||||
|
||||
#### List Calendar Events
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/me/calendar/events?$top=10
|
||||
```
|
||||
|
||||
#### List Meeting Recordings
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/me/onlineMeetings/{meeting-id}/recordings
|
||||
```
|
||||
|
||||
#### Get Meeting Recording
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/me/onlineMeetings/{meeting-id}/recordings/{recording-id}
|
||||
```
|
||||
|
||||
#### List Meeting Transcripts
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/me/onlineMeetings/{meeting-id}/transcripts
|
||||
```
|
||||
|
||||
#### Get Meeting Transcript
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/me/onlineMeetings/{meeting-id}/transcripts/{transcript-id}
|
||||
```
|
||||
|
||||
#### List Attendance Reports
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/me/onlineMeetings/{meeting-id}/attendanceReports
|
||||
```
|
||||
|
||||
#### Get Attendance Report
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/me/onlineMeetings/{meeting-id}/attendanceReports/{report-id}
|
||||
```
|
||||
|
||||
### Chats
|
||||
|
||||
#### List Chats
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/me/chats
|
||||
```
|
||||
|
||||
#### Get Chat
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/chats/{chat-id}
|
||||
```
|
||||
|
||||
#### List Chat Messages
|
||||
```bash
|
||||
GET /microsoft-teams/v1.0/chats/{chat-id}/messages
|
||||
```
|
||||
|
||||
#### Send Chat Message
|
||||
```bash
|
||||
POST /microsoft-teams/v1.0/chats/{chat-id}/messages
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"body": {
|
||||
"content": "Hello"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## OData Query Parameters
|
||||
|
||||
- `$top=10` - Limit results
|
||||
- `$skip=20` - Skip results
|
||||
- `$select=id,displayName` - Select specific fields
|
||||
- `$filter=membershipType eq 'private'` - Filter results
|
||||
- `$orderby=displayName` - Sort results
|
||||
|
||||
## Notes
|
||||
|
||||
- Uses Microsoft Graph API (`graph.microsoft.com`)
|
||||
- Channel IDs include thread suffix: `19:xxx@thread.tacv2`
|
||||
- Message body content types: `text` or `html`
|
||||
- Channel membership types: `standard`, `private`, `shared`
|
||||
- Supports OData query parameters for filtering and pagination
|
||||
- Meeting recordings/transcripts available after meeting ends
|
||||
|
||||
## Resources
|
||||
|
||||
- [Microsoft Teams API Overview](https://learn.microsoft.com/en-us/graph/api/resources/teams-api-overview)
|
||||
- [Microsoft Graph API Reference](https://learn.microsoft.com/en-us/graph/api/overview)
|
||||
- [Channel Resource](https://learn.microsoft.com/en-us/graph/api/resources/channel)
|
||||
- [ChatMessage Resource](https://learn.microsoft.com/en-us/graph/api/resources/chatmessage)
|
||||
@@ -0,0 +1,166 @@
|
||||
# PostHog Routing Reference
|
||||
|
||||
**App name:** `posthog`
|
||||
**Base URL proxied:** `{subdomain}.posthog.com`
|
||||
|
||||
## API Path Pattern
|
||||
|
||||
```
|
||||
/posthog/api/{resource}
|
||||
/posthog/api/projects/{project_id}/{resource}
|
||||
```
|
||||
|
||||
## Common Endpoints
|
||||
|
||||
### Get Current User
|
||||
```bash
|
||||
GET /posthog/api/users/@me/
|
||||
```
|
||||
|
||||
### Get Current Organization
|
||||
```bash
|
||||
GET /posthog/api/organizations/@current/
|
||||
```
|
||||
|
||||
### List Projects
|
||||
```bash
|
||||
GET /posthog/api/projects/
|
||||
```
|
||||
|
||||
### Get Current Project
|
||||
```bash
|
||||
GET /posthog/api/projects/@current/
|
||||
```
|
||||
|
||||
### Run HogQL Query
|
||||
```bash
|
||||
POST /posthog/api/projects/{project_id}/query/
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"query": {
|
||||
"kind": "HogQLQuery",
|
||||
"query": "SELECT event, count() FROM events GROUP BY event LIMIT 10"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### List Persons
|
||||
```bash
|
||||
GET /posthog/api/projects/{project_id}/persons/?limit=10
|
||||
```
|
||||
|
||||
### Get Person
|
||||
```bash
|
||||
GET /posthog/api/projects/{project_id}/persons/{person_uuid}/
|
||||
```
|
||||
|
||||
### List Dashboards
|
||||
```bash
|
||||
GET /posthog/api/projects/{project_id}/dashboards/
|
||||
```
|
||||
|
||||
### Get Dashboard
|
||||
```bash
|
||||
GET /posthog/api/projects/{project_id}/dashboards/{dashboard_id}/
|
||||
```
|
||||
|
||||
### Create Dashboard
|
||||
```bash
|
||||
POST /posthog/api/projects/{project_id}/dashboards/
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "My Dashboard",
|
||||
"description": "Analytics overview"
|
||||
}
|
||||
```
|
||||
|
||||
### List Insights
|
||||
```bash
|
||||
GET /posthog/api/projects/{project_id}/insights/?limit=10
|
||||
```
|
||||
|
||||
### List Feature Flags
|
||||
```bash
|
||||
GET /posthog/api/projects/{project_id}/feature_flags/
|
||||
```
|
||||
|
||||
### Create Feature Flag
|
||||
```bash
|
||||
POST /posthog/api/projects/{project_id}/feature_flags/
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"key": "my-feature-flag",
|
||||
"name": "My Feature Flag",
|
||||
"active": true,
|
||||
"filters": {
|
||||
"groups": [{"rollout_percentage": 100}]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Delete Feature Flag
|
||||
Use soft delete by setting `deleted: true`:
|
||||
```bash
|
||||
PATCH /posthog/api/projects/{project_id}/feature_flags/{flag_id}/
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"deleted": true
|
||||
}
|
||||
```
|
||||
|
||||
### List Session Recordings
|
||||
```bash
|
||||
GET /posthog/api/projects/{project_id}/session_recordings/?limit=10
|
||||
```
|
||||
|
||||
### List Cohorts
|
||||
```bash
|
||||
GET /posthog/api/projects/{project_id}/cohorts/
|
||||
```
|
||||
|
||||
### List Actions
|
||||
```bash
|
||||
GET /posthog/api/projects/{project_id}/actions/
|
||||
```
|
||||
|
||||
### List Experiments
|
||||
```bash
|
||||
GET /posthog/api/projects/{project_id}/experiments/
|
||||
```
|
||||
|
||||
### List Surveys
|
||||
```bash
|
||||
GET /posthog/api/projects/{project_id}/surveys/
|
||||
```
|
||||
|
||||
### List Event Definitions
|
||||
```bash
|
||||
GET /posthog/api/projects/{project_id}/event_definitions/?limit=10
|
||||
```
|
||||
|
||||
### List Property Definitions
|
||||
```bash
|
||||
GET /posthog/api/projects/{project_id}/property_definitions/?limit=10
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- Use `@current` as a shortcut for the current project ID (e.g., `/api/projects/@current/dashboards/`)
|
||||
- Project IDs are integers (e.g., `136209`)
|
||||
- Person UUIDs are in standard UUID format
|
||||
- The Events endpoint is deprecated; use the Query endpoint with HogQL instead
|
||||
- All project-scoped endpoints require `{project_id}` or `@current`
|
||||
- Pagination uses `limit` and `offset` query parameters
|
||||
- PostHog uses soft delete: use `PATCH` with `{"deleted": true}` instead of HTTP DELETE
|
||||
|
||||
## Resources
|
||||
|
||||
- [PostHog API Overview](https://posthog.com/docs/api)
|
||||
- [HogQL Documentation](https://posthog.com/docs/hogql)
|
||||
- [Feature Flags](https://posthog.com/docs/feature-flags)
|
||||
- [Session Replay](https://posthog.com/docs/session-replay)
|
||||
- [Experiments](https://posthog.com/docs/experiments)
|
||||
@@ -0,0 +1,155 @@
|
||||
# Sentry Routing Reference
|
||||
|
||||
**App name:** `sentry`
|
||||
**Base URL proxied:** `{subdomain}.sentry.io`
|
||||
|
||||
## API Path Pattern
|
||||
|
||||
```
|
||||
/sentry/api/0/{resource}
|
||||
```
|
||||
|
||||
Sentry API uses version `0` prefix in all paths.
|
||||
|
||||
## Common Endpoints
|
||||
|
||||
### List Organizations
|
||||
```bash
|
||||
GET /sentry/api/0/organizations/
|
||||
```
|
||||
|
||||
### Retrieve Organization
|
||||
```bash
|
||||
GET /sentry/api/0/organizations/{organization_slug}/
|
||||
```
|
||||
|
||||
### List Organization Projects
|
||||
```bash
|
||||
GET /sentry/api/0/organizations/{organization_slug}/projects/
|
||||
```
|
||||
|
||||
### List Organization Members
|
||||
```bash
|
||||
GET /sentry/api/0/organizations/{organization_slug}/members/
|
||||
```
|
||||
|
||||
### Retrieve Project
|
||||
```bash
|
||||
GET /sentry/api/0/projects/{organization_slug}/{project_slug}/
|
||||
```
|
||||
|
||||
### List Project Issues
|
||||
```bash
|
||||
GET /sentry/api/0/projects/{organization_slug}/{project_slug}/issues/
|
||||
```
|
||||
|
||||
Query parameters:
|
||||
- `statsPeriod` - Stats period: `24h`, `14d`, or empty
|
||||
- `query` - Sentry search query (default: `is:unresolved`)
|
||||
- `cursor` - Pagination cursor
|
||||
|
||||
### List Organization Issues
|
||||
```bash
|
||||
GET /sentry/api/0/organizations/{organization_slug}/issues/
|
||||
```
|
||||
|
||||
### Retrieve Issue
|
||||
```bash
|
||||
GET /sentry/api/0/issues/{issue_id}/
|
||||
```
|
||||
|
||||
### Update Issue
|
||||
```bash
|
||||
PUT /sentry/api/0/issues/{issue_id}/
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"status": "resolved"
|
||||
}
|
||||
```
|
||||
|
||||
Status values: `resolved`, `unresolved`, `ignored`
|
||||
|
||||
### Delete Issue
|
||||
```bash
|
||||
DELETE /sentry/api/0/issues/{issue_id}/
|
||||
```
|
||||
|
||||
### List Issue Events
|
||||
```bash
|
||||
GET /sentry/api/0/issues/{issue_id}/events/
|
||||
```
|
||||
|
||||
### List Project Events
|
||||
```bash
|
||||
GET /sentry/api/0/projects/{organization_slug}/{project_slug}/events/
|
||||
```
|
||||
|
||||
### List Organization Teams
|
||||
```bash
|
||||
GET /sentry/api/0/organizations/{organization_slug}/teams/
|
||||
```
|
||||
|
||||
### Create Team
|
||||
```bash
|
||||
POST /sentry/api/0/organizations/{organization_slug}/teams/
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "New Team",
|
||||
"slug": "new-team"
|
||||
}
|
||||
```
|
||||
|
||||
### Retrieve Team
|
||||
```bash
|
||||
GET /sentry/api/0/teams/{organization_slug}/{team_slug}/
|
||||
```
|
||||
|
||||
### List Organization Releases
|
||||
```bash
|
||||
GET /sentry/api/0/organizations/{organization_slug}/releases/
|
||||
```
|
||||
|
||||
### Create Release
|
||||
```bash
|
||||
POST /sentry/api/0/organizations/{organization_slug}/releases/
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"projects": ["project-slug"]
|
||||
}
|
||||
```
|
||||
|
||||
### Retrieve Release
|
||||
```bash
|
||||
GET /sentry/api/0/organizations/{organization_slug}/releases/{version}/
|
||||
```
|
||||
|
||||
### Create Deploy
|
||||
```bash
|
||||
POST /sentry/api/0/organizations/{organization_slug}/releases/{version}/deploys/
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"environment": "production"
|
||||
}
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- Organization and project identifiers use slugs (lowercase, hyphenated)
|
||||
- Issue IDs are numeric
|
||||
- Release versions can contain special characters (URL encode as needed)
|
||||
- Uses cursor-based pagination via Link header
|
||||
- Most endpoints require OAuth scopes like `event:read`, `project:read`, `org:read`
|
||||
|
||||
## Resources
|
||||
|
||||
- [Sentry API Documentation](https://docs.sentry.io/api/)
|
||||
- [Events API](https://docs.sentry.io/api/events/)
|
||||
- [Projects API](https://docs.sentry.io/api/projects/)
|
||||
- [Organizations API](https://docs.sentry.io/api/organizations/)
|
||||
- [Teams API](https://docs.sentry.io/api/teams/)
|
||||
- [Releases API](https://docs.sentry.io/api/releases/)
|
||||
@@ -0,0 +1,325 @@
|
||||
# Squarespace Routing Reference
|
||||
|
||||
**App name:** `squarespace`
|
||||
**Base URL proxied:** `api.squarespace.com`
|
||||
|
||||
## API Path Pattern
|
||||
|
||||
```
|
||||
/squarespace/v2/commerce/products # Products API (v2)
|
||||
/squarespace/1.0/commerce/store_pages # Store Pages (1.0 only)
|
||||
/squarespace/1.0/commerce/inventory # Inventory API
|
||||
/squarespace/1.0/commerce/orders # Orders API
|
||||
/squarespace/1.0/commerce/transactions # Transactions API
|
||||
/squarespace/1.0/profiles # Profiles API
|
||||
```
|
||||
|
||||
## Important Notes
|
||||
|
||||
- All requests require a `User-Agent` header describing your application
|
||||
- Requests without a custom User-Agent are subject to stricter rate limits
|
||||
- Maximum 50 items per batch request
|
||||
- Idempotency-Key header is required for stock adjustments and order creation
|
||||
- Rate limit: 300 requests per minute (5 per second)
|
||||
- Create Order has a stricter rate limit: 100 requests per hour per website
|
||||
|
||||
## Common Endpoints
|
||||
|
||||
### Inventory
|
||||
|
||||
#### List All Inventory
|
||||
```bash
|
||||
GET /squarespace/1.0/commerce/inventory
|
||||
GET /squarespace/1.0/commerce/inventory?cursor={cursor}
|
||||
```
|
||||
|
||||
#### Get Specific Inventory
|
||||
```bash
|
||||
GET /squarespace/1.0/commerce/inventory/{variantId1},{variantId2}
|
||||
```
|
||||
Max 50 variant IDs per request.
|
||||
|
||||
#### Adjust Stock Quantities
|
||||
```bash
|
||||
POST /squarespace/1.0/commerce/inventory/adjustments
|
||||
Content-Type: application/json
|
||||
Idempotency-Key: unique-key-here
|
||||
|
||||
{
|
||||
"incrementOperations": [{"variantId": "variant-id", "quantity": 5}],
|
||||
"decrementOperations": [{"variantId": "variant-id", "quantity": 2}],
|
||||
"setFiniteOperations": [{"variantId": "variant-id", "quantity": 100}],
|
||||
"setUnlimitedOperations": ["variant-id"]
|
||||
}
|
||||
```
|
||||
|
||||
### Orders
|
||||
|
||||
#### List All Orders
|
||||
```bash
|
||||
GET /squarespace/1.0/commerce/orders
|
||||
GET /squarespace/1.0/commerce/orders?fulfillmentStatus=PENDING
|
||||
GET /squarespace/1.0/commerce/orders?modifiedAfter=2024-01-01T00:00:00Z&modifiedBefore=2024-12-31T23:59:59Z
|
||||
GET /squarespace/1.0/commerce/orders?customerId={customerId}
|
||||
```
|
||||
|
||||
Note: Cannot combine `cursor` with date range parameters.
|
||||
|
||||
#### Get Specific Order
|
||||
```bash
|
||||
GET /squarespace/1.0/commerce/orders/{orderId}
|
||||
```
|
||||
|
||||
#### Create Order
|
||||
```bash
|
||||
POST /squarespace/1.0/commerce/orders
|
||||
Content-Type: application/json
|
||||
Idempotency-Key: unique-key-here
|
||||
|
||||
{
|
||||
"channelName": "External Store",
|
||||
"externalOrderReference": "ORDER-12345",
|
||||
"customerEmail": "customer@example.com",
|
||||
"lineItems": [
|
||||
{
|
||||
"lineItemType": "PHYSICAL_PRODUCT",
|
||||
"variantId": "variant-id",
|
||||
"quantity": 2,
|
||||
"unitPricePaid": {"currency": "USD", "value": "29.99"}
|
||||
}
|
||||
],
|
||||
"subtotal": {"currency": "USD", "value": "59.98"},
|
||||
"priceTaxInterpretation": "EXCLUSIVE",
|
||||
"grandTotal": {"currency": "USD", "value": "59.98"},
|
||||
"createdOn": "2024-01-15T10:30:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
Note: `subtotal` must equal sum of `lineItems.unitPricePaid.value * quantity`.
|
||||
|
||||
#### Fulfill Order
|
||||
```bash
|
||||
POST /squarespace/1.0/commerce/orders/{orderId}/fulfillments
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"shouldSendNotification": true,
|
||||
"shipments": [
|
||||
{
|
||||
"shipDate": "2024-01-16T08:00:00Z",
|
||||
"carrierName": "USPS",
|
||||
"service": "Priority Mail",
|
||||
"trackingNumber": "9400111899223456789012",
|
||||
"trackingUrl": "https://tools.usps.com/go/TrackConfirmAction?tLabels=9400111899223456789012"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Products (v2 API)
|
||||
|
||||
#### List Store Pages
|
||||
```bash
|
||||
GET /squarespace/1.0/commerce/store_pages
|
||||
```
|
||||
Note: Store Pages endpoint uses v1.0 (no v2 available).
|
||||
|
||||
#### List All Products
|
||||
```bash
|
||||
GET /squarespace/v2/commerce/products
|
||||
GET /squarespace/v2/commerce/products?type=PHYSICAL,SERVICE,GIFT_CARD,DIGITAL
|
||||
GET /squarespace/v2/commerce/products?modifiedAfter=2024-01-01T00:00:00Z
|
||||
```
|
||||
|
||||
Note: Cannot combine `cursor` with date/type filters.
|
||||
|
||||
#### Get Specific Products
|
||||
```bash
|
||||
GET /squarespace/v2/commerce/products/{productId1},{productId2}
|
||||
```
|
||||
Max 50 product IDs per request.
|
||||
|
||||
#### Create Product
|
||||
```bash
|
||||
POST /squarespace/v2/commerce/products
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"type": "PHYSICAL",
|
||||
"storePageId": "store-page-id",
|
||||
"name": "New Product",
|
||||
"description": "<p>Product description</p>",
|
||||
"urlSlug": "new-product",
|
||||
"isVisible": true,
|
||||
"variants": [
|
||||
{
|
||||
"sku": "SKU-001",
|
||||
"pricing": {"basePrice": {"currency": "USD", "value": "49.99"}},
|
||||
"stock": {"quantity": 100, "unlimited": false}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### Update Product
|
||||
```bash
|
||||
POST /squarespace/v2/commerce/products/{productId}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "Updated Product Name",
|
||||
"isVisible": true
|
||||
}
|
||||
```
|
||||
|
||||
#### Delete Product
|
||||
```bash
|
||||
DELETE /squarespace/v2/commerce/products/{productId}
|
||||
```
|
||||
|
||||
### Product Variants (v2 API)
|
||||
|
||||
#### Create Variant
|
||||
```bash
|
||||
POST /squarespace/v2/commerce/products/{productId}/variants
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"sku": "SKU-002",
|
||||
"pricing": {"basePrice": {"currency": "USD", "value": "59.99"}},
|
||||
"stock": {"quantity": 50, "unlimited": false},
|
||||
"attributes": {"Size": "Large"}
|
||||
}
|
||||
```
|
||||
|
||||
Note: To use `attributes`, product must have matching `variantAttributes` set first via Update Product.
|
||||
|
||||
#### Update Variant
|
||||
```bash
|
||||
POST /squarespace/v2/commerce/products/{productId}/variants/{variantId}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"sku": "SKU-002-UPDATED",
|
||||
"pricing": {"basePrice": {"currency": "USD", "value": "64.99"}}
|
||||
}
|
||||
```
|
||||
|
||||
#### Delete Variant
|
||||
```bash
|
||||
DELETE /squarespace/v2/commerce/products/{productId}/variants/{variantId}
|
||||
```
|
||||
|
||||
### Product Images (v2 API)
|
||||
|
||||
#### Upload Image
|
||||
```bash
|
||||
POST /squarespace/v2/commerce/products/{productId}/images
|
||||
Content-Type: multipart/form-data
|
||||
|
||||
curl "https://gateway.maton.ai/squarespace/v2/commerce/products/{productId}/images" \
|
||||
-H "Authorization: Bearer $MATON_API_KEY" \
|
||||
-H "User-Agent: MyClaude/1.0" \
|
||||
-X POST \
|
||||
-F file=@image.png
|
||||
```
|
||||
|
||||
#### Check Upload Status
|
||||
```bash
|
||||
GET /squarespace/v2/commerce/products/{productId}/images/{imageId}/status
|
||||
```
|
||||
|
||||
#### Update Image Alt Text
|
||||
```bash
|
||||
POST /squarespace/v2/commerce/products/{productId}/images/{imageId}
|
||||
Content-Type: application/json
|
||||
|
||||
{"altText": "Product image description"}
|
||||
```
|
||||
|
||||
#### Reorder Image
|
||||
```bash
|
||||
POST /squarespace/v2/commerce/products/{productId}/images/{imageId}/order
|
||||
Content-Type: application/json
|
||||
|
||||
{"afterImageId": "other-image-id"}
|
||||
```
|
||||
|
||||
#### Assign Image to Variant
|
||||
```bash
|
||||
POST /squarespace/v2/commerce/products/{productId}/variants/{variantId}/image
|
||||
Content-Type: application/json
|
||||
|
||||
{"imageId": "image-id"}
|
||||
```
|
||||
|
||||
#### Delete Image
|
||||
```bash
|
||||
DELETE /squarespace/v2/commerce/products/{productId}/images/{imageId}
|
||||
```
|
||||
|
||||
### Profiles (Customers)
|
||||
|
||||
#### List All Profiles
|
||||
```bash
|
||||
GET /squarespace/1.0/profiles
|
||||
GET /squarespace/1.0/profiles?filter=isCustomer,true
|
||||
GET /squarespace/1.0/profiles?sortField=email&sortDirection=asc
|
||||
```
|
||||
|
||||
Filters (semicolon-separated):
|
||||
- `isCustomer,true` or `isCustomer,false`
|
||||
- `hasAccount,true` or `hasAccount,false`
|
||||
- `email,customer@example.com`
|
||||
|
||||
Sort fields: `createdOn`, `id`, `email`, `lastName`
|
||||
|
||||
#### Get Specific Profiles
|
||||
```bash
|
||||
GET /squarespace/1.0/profiles/{profileId1},{profileId2}
|
||||
```
|
||||
Max 50 profile IDs per request.
|
||||
|
||||
### Transactions
|
||||
|
||||
#### List All Transactions
|
||||
```bash
|
||||
GET /squarespace/1.0/commerce/transactions
|
||||
GET /squarespace/1.0/commerce/transactions?modifiedAfter=2024-01-01T00:00:00Z&modifiedBefore=2024-12-31T23:59:59Z
|
||||
```
|
||||
|
||||
Note: Date filters must be used together (both `modifiedAfter` and `modifiedBefore` required).
|
||||
|
||||
#### Get Specific Transactions
|
||||
```bash
|
||||
GET /squarespace/1.0/commerce/transactions/{documentId1},{documentId2}
|
||||
```
|
||||
Max 50 document IDs per request.
|
||||
|
||||
## Pagination
|
||||
|
||||
Squarespace uses cursor-based pagination:
|
||||
|
||||
```json
|
||||
{
|
||||
"pagination": {
|
||||
"hasNextPage": true,
|
||||
"nextPageCursor": "cursor-value",
|
||||
"nextPageUrl": "https://api.squarespace.com/..."
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Use the `cursor` parameter to get the next page:
|
||||
```bash
|
||||
GET /squarespace/v2/commerce/products?cursor=cursor-value
|
||||
```
|
||||
|
||||
## Resources
|
||||
|
||||
- [Squarespace Commerce APIs Overview](https://developers.squarespace.com/commerce-apis/overview)
|
||||
- [Inventory API](https://developers.squarespace.com/commerce-apis/inventory-overview)
|
||||
- [Orders API](https://developers.squarespace.com/commerce-apis/orders-overview)
|
||||
- [Products API](https://developers.squarespace.com/commerce-apis/products-overview)
|
||||
- [Profiles API](https://developers.squarespace.com/commerce-apis/profiles-overview)
|
||||
- [Transactions API](https://developers.squarespace.com/commerce-apis/transactions-overview)
|
||||
@@ -6,24 +6,24 @@
|
||||
## API Path Pattern
|
||||
|
||||
```
|
||||
/todoist/rest/v2/{resource}
|
||||
/todoist/api/v1/{resource}
|
||||
```
|
||||
|
||||
## Common Endpoints
|
||||
|
||||
### List Projects
|
||||
```bash
|
||||
GET /todoist/rest/v2/projects
|
||||
GET /todoist/api/v1/projects
|
||||
```
|
||||
|
||||
### Get Project
|
||||
```bash
|
||||
GET /todoist/rest/v2/projects/{id}
|
||||
GET /todoist/api/v1/projects/{id}
|
||||
```
|
||||
|
||||
### Create Project
|
||||
```bash
|
||||
POST /todoist/rest/v2/projects
|
||||
POST /todoist/api/v1/projects
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
@@ -34,7 +34,7 @@ Content-Type: application/json
|
||||
|
||||
### Update Project
|
||||
```bash
|
||||
POST /todoist/rest/v2/projects/{id}
|
||||
POST /todoist/api/v1/projects/{id}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
@@ -44,24 +44,24 @@ Content-Type: application/json
|
||||
|
||||
### Delete Project
|
||||
```bash
|
||||
DELETE /todoist/rest/v2/projects/{id}
|
||||
DELETE /todoist/api/v1/projects/{id}
|
||||
```
|
||||
|
||||
### List Tasks
|
||||
```bash
|
||||
GET /todoist/rest/v2/tasks
|
||||
GET /todoist/rest/v2/tasks?project_id={project_id}
|
||||
GET /todoist/rest/v2/tasks?filter={filter}
|
||||
GET /todoist/api/v1/tasks
|
||||
GET /todoist/api/v1/tasks?project_id={project_id}
|
||||
GET /todoist/api/v1/tasks?filter={filter}
|
||||
```
|
||||
|
||||
### Get Task
|
||||
```bash
|
||||
GET /todoist/rest/v2/tasks/{id}
|
||||
GET /todoist/api/v1/tasks/{id}
|
||||
```
|
||||
|
||||
### Create Task
|
||||
```bash
|
||||
POST /todoist/rest/v2/tasks
|
||||
POST /todoist/api/v1/tasks
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
@@ -73,7 +73,7 @@ Content-Type: application/json
|
||||
|
||||
### Update Task
|
||||
```bash
|
||||
POST /todoist/rest/v2/tasks/{id}
|
||||
POST /todoist/api/v1/tasks/{id}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
@@ -84,28 +84,28 @@ Content-Type: application/json
|
||||
|
||||
### Close Task (Complete)
|
||||
```bash
|
||||
POST /todoist/rest/v2/tasks/{id}/close
|
||||
POST /todoist/api/v1/tasks/{id}/close
|
||||
```
|
||||
|
||||
### Reopen Task
|
||||
```bash
|
||||
POST /todoist/rest/v2/tasks/{id}/reopen
|
||||
POST /todoist/api/v1/tasks/{id}/reopen
|
||||
```
|
||||
|
||||
### Delete Task
|
||||
```bash
|
||||
DELETE /todoist/rest/v2/tasks/{id}
|
||||
DELETE /todoist/api/v1/tasks/{id}
|
||||
```
|
||||
|
||||
### List Sections
|
||||
```bash
|
||||
GET /todoist/rest/v2/sections
|
||||
GET /todoist/rest/v2/sections?project_id={project_id}
|
||||
GET /todoist/api/v1/sections
|
||||
GET /todoist/api/v1/sections?project_id={project_id}
|
||||
```
|
||||
|
||||
### Create Section
|
||||
```bash
|
||||
POST /todoist/rest/v2/sections
|
||||
POST /todoist/api/v1/sections
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
@@ -116,17 +116,17 @@ Content-Type: application/json
|
||||
|
||||
### Delete Section
|
||||
```bash
|
||||
DELETE /todoist/rest/v2/sections/{id}
|
||||
DELETE /todoist/api/v1/sections/{id}
|
||||
```
|
||||
|
||||
### List Labels
|
||||
```bash
|
||||
GET /todoist/rest/v2/labels
|
||||
GET /todoist/api/v1/labels
|
||||
```
|
||||
|
||||
### Create Label
|
||||
```bash
|
||||
POST /todoist/rest/v2/labels
|
||||
POST /todoist/api/v1/labels
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
@@ -137,18 +137,18 @@ Content-Type: application/json
|
||||
|
||||
### Delete Label
|
||||
```bash
|
||||
DELETE /todoist/rest/v2/labels/{id}
|
||||
DELETE /todoist/api/v1/labels/{id}
|
||||
```
|
||||
|
||||
### List Comments
|
||||
```bash
|
||||
GET /todoist/rest/v2/comments?task_id={task_id}
|
||||
GET /todoist/rest/v2/comments?project_id={project_id}
|
||||
GET /todoist/api/v1/comments?task_id={task_id}
|
||||
GET /todoist/api/v1/comments?project_id={project_id}
|
||||
```
|
||||
|
||||
### Create Comment
|
||||
```bash
|
||||
POST /todoist/rest/v2/comments
|
||||
POST /todoist/api/v1/comments
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
@@ -159,7 +159,7 @@ Content-Type: application/json
|
||||
|
||||
### Delete Comment
|
||||
```bash
|
||||
DELETE /todoist/rest/v2/comments/{id}
|
||||
DELETE /todoist/api/v1/comments/{id}
|
||||
```
|
||||
|
||||
## Notes
|
||||
@@ -172,5 +172,5 @@ DELETE /todoist/rest/v2/comments/{id}
|
||||
|
||||
## Resources
|
||||
|
||||
- [Todoist REST API v2 Documentation](https://developer.todoist.com/rest/v2)
|
||||
- [Todoist API v1 Documentation](https://developer.todoist.com/api/v1)
|
||||
- [Todoist Filter Syntax](https://todoist.com/help/articles/introduction-to-filters)
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
---
|
||||
name: api-setup
|
||||
description: Set up API integration with configuration and helper scripts
|
||||
metadata:
|
||||
{
|
||||
"openclaw": { "requires": { "bins": ["curl", "jq"] } },
|
||||
}
|
||||
---
|
||||
|
||||
# API Setup Skill
|
||||
|
||||
This skill helps you set up a new API integration with our standard configuration.
|
||||
|
||||
## Steps
|
||||
|
||||
1. Run `setup.sh <api-name>` to create the integration directory
|
||||
2. Copy `templates/config.template.json` to your integration directory
|
||||
3. Update the config with your API credentials
|
||||
4. Test the connection
|
||||
|
||||
## Configuration
|
||||
|
||||
The config template includes:
|
||||
- `api_key`: Your API key (get from the provider's dashboard)
|
||||
- `endpoint`: API endpoint URL
|
||||
- `timeout`: Request timeout in seconds (default: 30)
|
||||
|
||||
## Verification
|
||||
|
||||
After setup, verify:
|
||||
- [ ] Config file is valid JSON
|
||||
- [ ] API key is set and not a placeholder
|
||||
- [ ] Test connection succeeds
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Create new API integration
|
||||
setup.sh my-api
|
||||
|
||||
# Test connection
|
||||
test-api.sh my-api
|
||||
```
|
||||
@@ -1,63 +0,0 @@
|
||||
#!/bin/bash
|
||||
# API Setup Script
|
||||
# Creates a new API integration directory with templates
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: $0 <api-name>"
|
||||
echo "Example: $0 stripe"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
API_NAME="$1"
|
||||
WORKSPACE_DIR="/home/openclaw/.openclaw/workspace"
|
||||
API_DIR="$WORKSPACE_DIR/apis/$API_NAME"
|
||||
|
||||
# Create directory
|
||||
mkdir -p "$API_DIR"
|
||||
|
||||
# Create config template
|
||||
cat > "$API_DIR/config.json" << 'EOF'
|
||||
{
|
||||
"api_key": "YOUR_API_KEY_HERE",
|
||||
"endpoint": "https://api.example.com/v1",
|
||||
"timeout": 30,
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
# Create test script
|
||||
cat > "$API_DIR/test.sh" << EOF
|
||||
#!/bin/bash
|
||||
# Test API connection
|
||||
|
||||
CONFIG_FILE="\$(dirname "\$0")/config.json"
|
||||
|
||||
# Check config exists
|
||||
if [ ! -f "\$CONFIG_FILE" ]; then
|
||||
echo "Error: config.json not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract values (requires jq)
|
||||
API_KEY=\$(jq -r '.api_key' "\$CONFIG_FILE")
|
||||
ENDPOINT=\$(jq -r '.endpoint' "\$CONFIG_FILE")
|
||||
|
||||
if [ "\$API_KEY" = "YOUR_API_KEY_HERE" ]; then
|
||||
echo "Error: Please set your API key in config.json"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Testing \$ENDPOINT..."
|
||||
curl -s -H "Authorization: Bearer \$API_KEY" "\$ENDPOINT" || echo "Connection test complete"
|
||||
EOF
|
||||
|
||||
chmod +x "$API_DIR/test.sh"
|
||||
|
||||
echo "✅ Created API integration: $API_NAME"
|
||||
echo "📁 Location: $API_DIR"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo "1. Edit $API_DIR/config.json with your credentials"
|
||||
echo "2. Run $API_DIR/test.sh to verify connection"
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"api_key": "YOUR_API_KEY_HERE",
|
||||
"endpoint": "https://api.example.com/v1",
|
||||
"timeout": 30,
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"version": 1,
|
||||
"registry": "https://clawhub.ai",
|
||||
"slug": "apple-calendar",
|
||||
"installedVersion": "1.0.0",
|
||||
"installedAt": 1770184128729
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
---
|
||||
name: apple-calendar
|
||||
description: Apple Calendar.app integration for macOS. CRUD operations for events, search, and multi-calendar support.
|
||||
metadata: {"clawdbot":{"emoji":"📅","os":["darwin"]}}
|
||||
---
|
||||
|
||||
# Apple Calendar
|
||||
|
||||
Interact with Calendar.app via AppleScript. Run scripts from: `cd {baseDir}`
|
||||
|
||||
## Commands
|
||||
|
||||
| Command | Usage |
|
||||
|---------|-------|
|
||||
| List calendars | `scripts/cal-list.sh` |
|
||||
| List events | `scripts/cal-events.sh [days_ahead] [calendar_name]` |
|
||||
| Read event | `scripts/cal-read.sh <event-uid> [calendar_name]` |
|
||||
| Create event | `scripts/cal-create.sh <calendar> <summary> <start> <end> [location] [description] [allday] [recurrence]` |
|
||||
| Update event | `scripts/cal-update.sh <event-uid> [--summary X] [--start X] [--end X] [--location X] [--description X]` |
|
||||
| Delete event | `scripts/cal-delete.sh <event-uid> [calendar_name]` |
|
||||
| Search events | `scripts/cal-search.sh <query> [days_ahead] [calendar_name]` |
|
||||
|
||||
## Date Format
|
||||
|
||||
- Timed: `YYYY-MM-DD HH:MM`
|
||||
- All-day: `YYYY-MM-DD`
|
||||
|
||||
## Recurrence
|
||||
|
||||
| Pattern | RRULE |
|
||||
|---------|-------|
|
||||
| Daily 10x | `FREQ=DAILY;COUNT=10` |
|
||||
| Weekly M/W/F | `FREQ=WEEKLY;BYDAY=MO,WE,FR` |
|
||||
| Monthly 15th | `FREQ=MONTHLY;BYMONTHDAY=15` |
|
||||
|
||||
## Output
|
||||
|
||||
- Events/search: `UID | Summary | Start | End | AllDay | Location | Calendar`
|
||||
- Read: Full details with description, URL, recurrence
|
||||
|
||||
## Notes
|
||||
|
||||
- Read-only calendars (Birthdays, Holidays) can't be modified
|
||||
- Calendar names are case-sensitive
|
||||
- Deleting recurring events removes entire series
|
||||
@@ -1,105 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Create a new calendar event
|
||||
# Usage: cal-create.sh <calendar> <summary> <start_date> <end_date> [location] [description] [allday] [recurrence]
|
||||
# Date format: "YYYY-MM-DD HH:MM" or "YYYY-MM-DD" for all-day events
|
||||
# Recurrence format: iCalendar RRULE (e.g., "FREQ=WEEKLY;COUNT=4" or "FREQ=DAILY;UNTIL=20260201")
|
||||
# Examples:
|
||||
# cal-create.sh Personal "Meeting" "2026-01-15 10:00" "2026-01-15 11:00"
|
||||
# cal-create.sh Personal "Vacation" "2026-02-01" "2026-02-05" "" "Beach trip" true
|
||||
# cal-create.sh Personal "Weekly Standup" "2026-01-20 09:00" "2026-01-20 09:30" "Zoom" "" false "FREQ=WEEKLY;COUNT=10"
|
||||
|
||||
CALENDAR="${1:-}"
|
||||
SUMMARY="${2:-}"
|
||||
START_DATE="${3:-}"
|
||||
END_DATE="${4:-}"
|
||||
LOCATION="${5:-}"
|
||||
DESCRIPTION="${6:-}"
|
||||
ALL_DAY="${7:-false}"
|
||||
RECURRENCE="${8:-}"
|
||||
|
||||
if [ -z "$CALENDAR" ] || [ -z "$SUMMARY" ] || [ -z "$START_DATE" ] || [ -z "$END_DATE" ]; then
|
||||
echo "Usage: cal-create.sh <calendar> <summary> <start_date> <end_date> [location] [description] [allday] [recurrence]"
|
||||
echo "Date format: 'YYYY-MM-DD HH:MM' or 'YYYY-MM-DD' for all-day"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
osascript - "$CALENDAR" "$SUMMARY" "$START_DATE" "$END_DATE" "$LOCATION" "$DESCRIPTION" "$ALL_DAY" "$RECURRENCE" <<'EOF'
|
||||
on splitString(theString, theDelimiter)
|
||||
set oldDelimiters to AppleScript's text item delimiters
|
||||
set AppleScript's text item delimiters to theDelimiter
|
||||
set theArray to every text item of theString
|
||||
set AppleScript's text item delimiters to oldDelimiters
|
||||
return theArray
|
||||
end splitString
|
||||
|
||||
on parseDate(dateStr)
|
||||
set dateParts to my splitString(dateStr, " ")
|
||||
set ymdParts to my splitString(item 1 of dateParts, "-")
|
||||
|
||||
set theDate to current date
|
||||
set year of theDate to (item 1 of ymdParts) as integer
|
||||
set month of theDate to (item 2 of ymdParts) as integer
|
||||
set day of theDate to (item 3 of ymdParts) as integer
|
||||
|
||||
if (count of dateParts) > 1 then
|
||||
set timeParts to my splitString(item 2 of dateParts, ":")
|
||||
set hours of theDate to (item 1 of timeParts) as integer
|
||||
set minutes of theDate to (item 2 of timeParts) as integer
|
||||
set seconds of theDate to 0
|
||||
else
|
||||
set hours of theDate to 0
|
||||
set minutes of theDate to 0
|
||||
set seconds of theDate to 0
|
||||
end if
|
||||
|
||||
return theDate
|
||||
end parseDate
|
||||
|
||||
on run argv
|
||||
set calendarName to item 1 of argv as string
|
||||
set eventSummary to item 2 of argv as string
|
||||
set startDateStr to item 3 of argv as string
|
||||
set endDateStr to item 4 of argv as string
|
||||
set eventLocation to item 5 of argv as string
|
||||
set eventDescription to item 6 of argv as string
|
||||
set isAllDay to item 7 of argv as string
|
||||
set eventRecurrence to item 8 of argv as string
|
||||
|
||||
set startDate to my parseDate(startDateStr)
|
||||
set endDate to my parseDate(endDateStr)
|
||||
|
||||
tell application "Calendar"
|
||||
try
|
||||
set cal to calendar calendarName
|
||||
on error
|
||||
return "Error: Calendar '" & calendarName & "' not found"
|
||||
end try
|
||||
|
||||
if not (writable of cal) then
|
||||
return "Error: Calendar '" & calendarName & "' is read-only"
|
||||
end if
|
||||
|
||||
set eventProps to {summary:eventSummary, start date:startDate, end date:endDate}
|
||||
|
||||
if isAllDay is "true" then
|
||||
set eventProps to eventProps & {allday event:true}
|
||||
end if
|
||||
|
||||
set newEvent to make new event at end of events of cal with properties eventProps
|
||||
|
||||
if eventLocation is not "" then
|
||||
set location of newEvent to eventLocation
|
||||
end if
|
||||
|
||||
if eventDescription is not "" then
|
||||
set description of newEvent to eventDescription
|
||||
end if
|
||||
|
||||
if eventRecurrence is not "" then
|
||||
set recurrence of newEvent to eventRecurrence
|
||||
end if
|
||||
|
||||
return "Created event: " & (uid of newEvent)
|
||||
end tell
|
||||
end run
|
||||
EOF
|
||||
@@ -1,50 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Delete a calendar event by UID
|
||||
# Usage: cal-delete.sh <event-uid> [calendar_name]
|
||||
# If calendar not specified, searches all calendars
|
||||
|
||||
EVENT_UID="${1:-}"
|
||||
CALENDAR_NAME="${2:-}"
|
||||
|
||||
if [ -z "$EVENT_UID" ]; then
|
||||
echo "Usage: cal-delete.sh <event-uid> [calendar_name]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
osascript - "$EVENT_UID" "$CALENDAR_NAME" <<'EOF'
|
||||
on run argv
|
||||
set eventUID to item 1 of argv as string
|
||||
set calendarName to item 2 of argv as string
|
||||
|
||||
tell application "Calendar"
|
||||
if calendarName is not "" then
|
||||
try
|
||||
set cals to {calendar calendarName}
|
||||
on error
|
||||
return "Error: Calendar '" & calendarName & "' not found"
|
||||
end try
|
||||
else
|
||||
set cals to calendars
|
||||
end if
|
||||
|
||||
repeat with cal in cals
|
||||
try
|
||||
set matchingEvents to (every event of cal whose uid is eventUID)
|
||||
if (count of matchingEvents) > 0 then
|
||||
set e to item 1 of matchingEvents
|
||||
set eventName to summary of e
|
||||
|
||||
if not (writable of cal) then
|
||||
return "Error: Calendar '" & (name of cal) & "' is read-only"
|
||||
end if
|
||||
|
||||
delete e
|
||||
return "Deleted event: " & eventName & " (" & eventUID & ")"
|
||||
end if
|
||||
end try
|
||||
end repeat
|
||||
|
||||
return "Error: Event with UID '" & eventUID & "' not found"
|
||||
end tell
|
||||
end run
|
||||
EOF
|
||||
@@ -1,66 +0,0 @@
|
||||
#!/bin/bash
|
||||
# List events in a date range
|
||||
# Usage: cal-events.sh [days_ahead] [calendar_name]
|
||||
# Examples:
|
||||
# cal-events.sh # Today's events from all calendars
|
||||
# cal-events.sh 7 # Next 7 days from all calendars
|
||||
# cal-events.sh 7 Personal # Next 7 days from Personal calendar only
|
||||
|
||||
DAYS_AHEAD="${1:-0}"
|
||||
CALENDAR_NAME="${2:-}"
|
||||
|
||||
osascript - "$DAYS_AHEAD" "$CALENDAR_NAME" <<'EOF'
|
||||
on run argv
|
||||
set daysAhead to item 1 of argv as integer
|
||||
set calendarName to item 2 of argv as string
|
||||
|
||||
tell application "Calendar"
|
||||
set today to current date
|
||||
set startOfDay to today - (time of today)
|
||||
|
||||
if daysAhead = 0 then
|
||||
set endDate to startOfDay + (24 * 60 * 60)
|
||||
else
|
||||
set endDate to startOfDay + ((daysAhead + 1) * 24 * 60 * 60)
|
||||
end if
|
||||
|
||||
set results to {}
|
||||
|
||||
if calendarName is not "" then
|
||||
try
|
||||
set cals to {calendar calendarName}
|
||||
on error
|
||||
return "Error: Calendar '" & calendarName & "' not found"
|
||||
end try
|
||||
else
|
||||
set cals to calendars
|
||||
end if
|
||||
|
||||
repeat with cal in cals
|
||||
try
|
||||
set calEvents to (every event of cal whose start date ≥ startOfDay and start date < endDate)
|
||||
repeat with e in calEvents
|
||||
set eventStart to start date of e
|
||||
set eventEnd to end date of e
|
||||
set isAllDay to allday event of e
|
||||
set eventLoc to location of e
|
||||
if eventLoc is missing value then set eventLoc to ""
|
||||
|
||||
set eventLine to (uid of e) & " | " & (summary of e) & " | " & (eventStart as string) & " | " & (eventEnd as string) & " | " & (isAllDay as string) & " | " & eventLoc & " | " & (name of cal)
|
||||
set end of results to eventLine
|
||||
end repeat
|
||||
end try
|
||||
end repeat
|
||||
|
||||
if (count of results) = 0 then
|
||||
return "No events found"
|
||||
end if
|
||||
|
||||
set output to ""
|
||||
repeat with r in results
|
||||
set output to output & r & linefeed
|
||||
end repeat
|
||||
return output
|
||||
end tell
|
||||
end run
|
||||
EOF
|
||||
@@ -1,22 +0,0 @@
|
||||
#!/bin/bash
|
||||
# List all calendars with their properties
|
||||
# Usage: cal-list.sh
|
||||
|
||||
osascript <<'EOF'
|
||||
tell application "Calendar"
|
||||
set calNames to name of every calendar
|
||||
set calWritable to writable of every calendar
|
||||
set output to ""
|
||||
repeat with i from 1 to count of calNames
|
||||
set calName to item i of calNames
|
||||
set isWritable to item i of calWritable
|
||||
if isWritable then
|
||||
set writeStatus to "writable"
|
||||
else
|
||||
set writeStatus to "read-only"
|
||||
end if
|
||||
set output to output & calName & " | " & writeStatus & linefeed
|
||||
end repeat
|
||||
return output
|
||||
end tell
|
||||
EOF
|
||||
@@ -1,69 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Read a single event by UID
|
||||
# Usage: cal-read.sh <event-uid> [calendar_name]
|
||||
# If calendar not specified, searches all calendars
|
||||
|
||||
EVENT_UID="${1:-}"
|
||||
CALENDAR_NAME="${2:-}"
|
||||
|
||||
if [ -z "$EVENT_UID" ]; then
|
||||
echo "Usage: cal-read.sh <event-uid> [calendar_name]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
osascript - "$EVENT_UID" "$CALENDAR_NAME" <<'EOF'
|
||||
on run argv
|
||||
set eventUID to item 1 of argv as string
|
||||
set calendarName to item 2 of argv as string
|
||||
|
||||
tell application "Calendar"
|
||||
if calendarName is not "" then
|
||||
try
|
||||
set cals to {calendar calendarName}
|
||||
on error
|
||||
return "Error: Calendar '" & calendarName & "' not found"
|
||||
end try
|
||||
else
|
||||
set cals to calendars
|
||||
end if
|
||||
|
||||
repeat with cal in cals
|
||||
try
|
||||
set matchingEvents to (every event of cal whose uid is eventUID)
|
||||
if (count of matchingEvents) > 0 then
|
||||
set e to item 1 of matchingEvents
|
||||
|
||||
set eventSummary to summary of e
|
||||
set eventStart to start date of e
|
||||
set eventEnd to end date of e
|
||||
set isAllDay to allday event of e
|
||||
set eventLoc to location of e
|
||||
set eventDesc to description of e
|
||||
set eventURL to url of e
|
||||
set eventRecur to recurrence of e
|
||||
|
||||
if eventLoc is missing value then set eventLoc to ""
|
||||
if eventDesc is missing value then set eventDesc to ""
|
||||
if eventURL is missing value then set eventURL to ""
|
||||
if eventRecur is missing value then set eventRecur to ""
|
||||
|
||||
set output to "UID: " & eventUID & linefeed
|
||||
set output to output & "Calendar: " & (name of cal) & linefeed
|
||||
set output to output & "Summary: " & eventSummary & linefeed
|
||||
set output to output & "Start: " & (eventStart as string) & linefeed
|
||||
set output to output & "End: " & (eventEnd as string) & linefeed
|
||||
set output to output & "All Day: " & (isAllDay as string) & linefeed
|
||||
set output to output & "Location: " & eventLoc & linefeed
|
||||
set output to output & "Description: " & eventDesc & linefeed
|
||||
set output to output & "URL: " & eventURL & linefeed
|
||||
set output to output & "Recurrence: " & eventRecur
|
||||
|
||||
return output
|
||||
end if
|
||||
end try
|
||||
end repeat
|
||||
|
||||
return "Error: Event with UID '" & eventUID & "' not found"
|
||||
end tell
|
||||
end run
|
||||
EOF
|
||||
@@ -1,100 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Search events by text (summary, location, or description)
|
||||
# Usage: cal-search.sh <query> [days_ahead] [calendar_name]
|
||||
# Examples:
|
||||
# cal-search.sh "meeting" # Search all calendars, next 30 days
|
||||
# cal-search.sh "dentist" 90 # Search next 90 days
|
||||
# cal-search.sh "standup" 14 Work # Search Work calendar, next 14 days
|
||||
|
||||
QUERY="${1:-}"
|
||||
DAYS_AHEAD="${2:-30}"
|
||||
CALENDAR_NAME="${3:-}"
|
||||
|
||||
if [ -z "$QUERY" ]; then
|
||||
echo "Usage: cal-search.sh <query> [days_ahead] [calendar_name]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
osascript - "$QUERY" "$DAYS_AHEAD" "$CALENDAR_NAME" <<'EOF'
|
||||
on run argv
|
||||
set searchQuery to item 1 of argv as string
|
||||
set daysAhead to item 2 of argv as integer
|
||||
set calendarName to item 3 of argv as string
|
||||
|
||||
tell application "Calendar"
|
||||
set today to current date
|
||||
set startOfDay to today - (time of today)
|
||||
set endDate to startOfDay + (daysAhead * 24 * 60 * 60)
|
||||
|
||||
set results to {}
|
||||
|
||||
if calendarName is not "" then
|
||||
try
|
||||
set cals to {calendar calendarName}
|
||||
on error
|
||||
return "Error: Calendar '" & calendarName & "' not found"
|
||||
end try
|
||||
else
|
||||
set cals to calendars
|
||||
end if
|
||||
|
||||
repeat with cal in cals
|
||||
try
|
||||
set calEvents to (every event of cal whose start date ≥ startOfDay and start date < endDate)
|
||||
repeat with e in calEvents
|
||||
set eventSummary to summary of e
|
||||
set eventLoc to location of e
|
||||
set eventDesc to description of e
|
||||
|
||||
if eventLoc is missing value then set eventLoc to ""
|
||||
if eventDesc is missing value then set eventDesc to ""
|
||||
|
||||
-- Case-insensitive search in summary, location, or description
|
||||
set lowerQuery to my toLowerCase(searchQuery)
|
||||
set matchFound to false
|
||||
|
||||
if my toLowerCase(eventSummary) contains lowerQuery then
|
||||
set matchFound to true
|
||||
else if my toLowerCase(eventLoc) contains lowerQuery then
|
||||
set matchFound to true
|
||||
else if my toLowerCase(eventDesc) contains lowerQuery then
|
||||
set matchFound to true
|
||||
end if
|
||||
|
||||
if matchFound then
|
||||
set eventStart to start date of e
|
||||
set isAllDay to allday event of e
|
||||
set eventLine to (uid of e) & " | " & eventSummary & " | " & (eventStart as string) & " | " & (isAllDay as string) & " | " & eventLoc & " | " & (name of cal)
|
||||
set end of results to eventLine
|
||||
end if
|
||||
end repeat
|
||||
end try
|
||||
end repeat
|
||||
|
||||
if (count of results) = 0 then
|
||||
return "No events found matching: " & searchQuery
|
||||
end if
|
||||
|
||||
set output to ""
|
||||
repeat with r in results
|
||||
set output to output & r & linefeed
|
||||
end repeat
|
||||
return output
|
||||
end tell
|
||||
end run
|
||||
|
||||
on toLowerCase(theString)
|
||||
set lowercaseChars to "abcdefghijklmnopqrstuvwxyz"
|
||||
set uppercaseChars to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
set resultString to ""
|
||||
repeat with c in theString
|
||||
set charIndex to offset of c in uppercaseChars
|
||||
if charIndex > 0 then
|
||||
set resultString to resultString & character charIndex of lowercaseChars
|
||||
else
|
||||
set resultString to resultString & c
|
||||
end if
|
||||
end repeat
|
||||
return resultString
|
||||
end toLowerCase
|
||||
EOF
|
||||
@@ -1,148 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Update an existing calendar event
|
||||
# Usage: cal-update.sh <event-uid> [--calendar <name>] [--summary <text>] [--start <date>] [--end <date>] [--location <text>] [--description <text>] [--allday <true/false>] [--recurrence <rrule>]
|
||||
# Date format: "YYYY-MM-DD HH:MM" or "YYYY-MM-DD" for all-day events
|
||||
# Examples:
|
||||
# cal-update.sh ABC123 --summary "Updated Meeting"
|
||||
# cal-update.sh ABC123 --calendar Personal --start "2026-01-16 14:00" --end "2026-01-16 15:00"
|
||||
# cal-update.sh ABC123 --location "Room 101" --description "Bring laptop"
|
||||
|
||||
EVENT_UID=""
|
||||
CALENDAR_NAME=""
|
||||
SUMMARY=""
|
||||
START_DATE=""
|
||||
END_DATE=""
|
||||
LOCATION=""
|
||||
DESCRIPTION=""
|
||||
ALL_DAY=""
|
||||
RECURRENCE=""
|
||||
|
||||
# Parse arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--calendar) CALENDAR_NAME="$2"; shift 2 ;;
|
||||
--summary) SUMMARY="$2"; shift 2 ;;
|
||||
--start) START_DATE="$2"; shift 2 ;;
|
||||
--end) END_DATE="$2"; shift 2 ;;
|
||||
--location) LOCATION="$2"; shift 2 ;;
|
||||
--description) DESCRIPTION="$2"; shift 2 ;;
|
||||
--allday) ALL_DAY="$2"; shift 2 ;;
|
||||
--recurrence) RECURRENCE="$2"; shift 2 ;;
|
||||
*)
|
||||
if [ -z "$EVENT_UID" ]; then
|
||||
EVENT_UID="$1"
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$EVENT_UID" ]; then
|
||||
echo "Usage: cal-update.sh <event-uid> [--calendar <name>] [--summary <text>] [--start <date>] [--end <date>] [--location <text>] [--description <text>] [--allday <true/false>] [--recurrence <rrule>]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
osascript - "$EVENT_UID" "$CALENDAR_NAME" "$SUMMARY" "$START_DATE" "$END_DATE" "$LOCATION" "$DESCRIPTION" "$ALL_DAY" "$RECURRENCE" <<'EOF'
|
||||
on splitString(theString, theDelimiter)
|
||||
set oldDelimiters to AppleScript's text item delimiters
|
||||
set AppleScript's text item delimiters to theDelimiter
|
||||
set theArray to every text item of theString
|
||||
set AppleScript's text item delimiters to oldDelimiters
|
||||
return theArray
|
||||
end splitString
|
||||
|
||||
on parseDate(dateStr)
|
||||
if dateStr is "" then return missing value
|
||||
set dateParts to my splitString(dateStr, " ")
|
||||
set ymdParts to my splitString(item 1 of dateParts, "-")
|
||||
|
||||
set theDate to current date
|
||||
set year of theDate to (item 1 of ymdParts) as integer
|
||||
set month of theDate to (item 2 of ymdParts) as integer
|
||||
set day of theDate to (item 3 of ymdParts) as integer
|
||||
|
||||
if (count of dateParts) > 1 then
|
||||
set timeParts to my splitString(item 2 of dateParts, ":")
|
||||
set hours of theDate to (item 1 of timeParts) as integer
|
||||
set minutes of theDate to (item 2 of timeParts) as integer
|
||||
set seconds of theDate to 0
|
||||
else
|
||||
set hours of theDate to 0
|
||||
set minutes of theDate to 0
|
||||
set seconds of theDate to 0
|
||||
end if
|
||||
|
||||
return theDate
|
||||
end parseDate
|
||||
|
||||
on run argv
|
||||
set eventUID to item 1 of argv as string
|
||||
set calendarName to item 2 of argv as string
|
||||
set newSummary to item 3 of argv as string
|
||||
set newStartStr to item 4 of argv as string
|
||||
set newEndStr to item 5 of argv as string
|
||||
set newLocation to item 6 of argv as string
|
||||
set newDescription to item 7 of argv as string
|
||||
set newAllDay to item 8 of argv as string
|
||||
set newRecurrence to item 9 of argv as string
|
||||
|
||||
tell application "Calendar"
|
||||
if calendarName is not "" then
|
||||
try
|
||||
set cals to {calendar calendarName}
|
||||
on error
|
||||
return "Error: Calendar '" & calendarName & "' not found"
|
||||
end try
|
||||
else
|
||||
set cals to calendars
|
||||
end if
|
||||
|
||||
repeat with cal in cals
|
||||
try
|
||||
set matchingEvents to (every event of cal whose uid is eventUID)
|
||||
if (count of matchingEvents) > 0 then
|
||||
set e to item 1 of matchingEvents
|
||||
|
||||
if not (writable of cal) then
|
||||
return "Error: Calendar '" & (name of cal) & "' is read-only"
|
||||
end if
|
||||
|
||||
if newSummary is not "" then
|
||||
set summary of e to newSummary
|
||||
end if
|
||||
|
||||
if newStartStr is not "" then
|
||||
set start date of e to my parseDate(newStartStr)
|
||||
end if
|
||||
|
||||
if newEndStr is not "" then
|
||||
set end date of e to my parseDate(newEndStr)
|
||||
end if
|
||||
|
||||
if newLocation is not "" then
|
||||
set location of e to newLocation
|
||||
end if
|
||||
|
||||
if newDescription is not "" then
|
||||
set description of e to newDescription
|
||||
end if
|
||||
|
||||
if newAllDay is "true" then
|
||||
set allday event of e to true
|
||||
else if newAllDay is "false" then
|
||||
set allday event of e to false
|
||||
end if
|
||||
|
||||
if newRecurrence is not "" then
|
||||
set recurrence of e to newRecurrence
|
||||
end if
|
||||
|
||||
return "Updated event: " & eventUID
|
||||
end if
|
||||
end try
|
||||
end repeat
|
||||
|
||||
return "Error: Event with UID '" & eventUID & "' not found"
|
||||
end tell
|
||||
end run
|
||||
EOF
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"version": 1,
|
||||
"registry": "https://clawhub.ai",
|
||||
"slug": "apple-mail",
|
||||
"installedVersion": "1.2.0",
|
||||
"installedAt": 1770184142890
|
||||
}
|
||||
@@ -1,165 +0,0 @@
|
||||
---
|
||||
name: apple-mail
|
||||
description: Apple Mail.app integration for macOS. Read inbox, search emails, send emails, reply, and manage messages with fast direct access (no enumeration).
|
||||
metadata: {"clawdbot":{"emoji":"📧","os":["darwin"],"requires":{"bins":["sqlite3"]}}}
|
||||
---
|
||||
|
||||
# Apple Mail
|
||||
|
||||
Interact with Mail.app via AppleScript and SQLite. Run scripts from: `cd {baseDir}`
|
||||
|
||||
## Commands
|
||||
|
||||
| Command | Usage |
|
||||
|---------|-------|
|
||||
| **Refresh** | `scripts/mail-refresh.sh [account] [wait_seconds]` |
|
||||
| List recent | `scripts/mail-list.sh [mailbox] [account] [limit]` |
|
||||
| Search | `scripts/mail-search.sh "query" [mailbox] [limit]` |
|
||||
| Fast search | `scripts/mail-fast-search.sh "query" [limit]` |
|
||||
| Read email | `scripts/mail-read.sh <message-id> [message-id...]` |
|
||||
| Delete | `scripts/mail-delete.sh <message-id> [message-id...]` |
|
||||
| Mark read | `scripts/mail-mark-read.sh <message-id> [message-id...]` |
|
||||
| Mark unread | `scripts/mail-mark-unread.sh <message-id> [message-id...]` |
|
||||
| Send | `scripts/mail-send.sh "to@email.com" "Subject" "Body" [from-account] [attachment]` ¹ |
|
||||
| Reply | `scripts/mail-reply.sh <message-id> "body" [reply-all]` |
|
||||
| List accounts | `scripts/mail-accounts.sh` |
|
||||
| List mailboxes | `scripts/mail-mailboxes.sh [account]` |
|
||||
|
||||
## Refreshing Mail
|
||||
|
||||
Force Mail.app to check for new messages:
|
||||
|
||||
```bash
|
||||
scripts/mail-refresh.sh # All accounts, wait up to 10s
|
||||
scripts/mail-refresh.sh Google # Specific account only
|
||||
scripts/mail-refresh.sh "" 5 # All accounts, max 5 seconds
|
||||
scripts/mail-refresh.sh Google 0 # Google account, no wait
|
||||
```
|
||||
|
||||
**Smart sync detection:**
|
||||
- Script monitors database message count
|
||||
- Returns early when sync completes (no changes for 2s)
|
||||
- Reports new message count: `Sync complete in 2s (+3 messages)`
|
||||
|
||||
**Notes:**
|
||||
- Mail.app must be running (script will error if not)
|
||||
- `mail-list.sh` does NOT auto-refresh — call `mail-refresh.sh` first if you need fresh data
|
||||
|
||||
## Output Format
|
||||
|
||||
List/search returns: `ID | ReadStatus | Date | Sender | Subject`
|
||||
- `●` = unread, blank = read
|
||||
|
||||
## Gmail Mailboxes
|
||||
|
||||
⚠️ Gmail special folders need `[Gmail]/` prefix:
|
||||
|
||||
| Shows as | Use |
|
||||
|----------|-----|
|
||||
| `Spam` | `[Gmail]/Spam` |
|
||||
| `Sent Mail` | `[Gmail]/Sent Mail` |
|
||||
| `All Mail` | `[Gmail]/All Mail` |
|
||||
| `Trash` | `[Gmail]/Trash` |
|
||||
|
||||
Custom labels work without prefix.
|
||||
|
||||
## Fast Search (SQLite)
|
||||
|
||||
✨ **Now safe even if Mail.app is running** — copies database to temp file first.
|
||||
|
||||
```bash
|
||||
scripts/mail-fast-search.sh "query" [limit] # ~50ms vs minutes
|
||||
```
|
||||
|
||||
Previously required Mail.app to be quit. Now works anytime by copying the database to a temp file before querying.
|
||||
|
||||
## Performance Notes
|
||||
|
||||
**Speed by operation:**
|
||||
| Operation | Speed | Notes |
|
||||
|-----------|-------|-------|
|
||||
| `mail-fast-search.sh` | ~50ms | SQLite query, fastest |
|
||||
| `mail-accounts.sh` | <1s | Simple AppleScript |
|
||||
| `mail-list.sh` | 1-3s | AppleScript, direct mailbox access |
|
||||
| `mail-send.sh` | 1-2s | Creates and sends message |
|
||||
| `mail-read.sh` | ~2s | Position-optimized lookup |
|
||||
| `mail-delete.sh` | ~0.5s | Position-optimized lookup |
|
||||
| `mail-mark-*.sh` | ~1.5s | Position-optimized lookup |
|
||||
|
||||
**Optimization technique:**
|
||||
SQLite provides account UUID and approximate message position. AppleScript jumps directly to that position instead of iterating from the start.
|
||||
|
||||
**Batch operations supported:**
|
||||
- `mail-read.sh 123 456 789` - Read multiple (separator between each)
|
||||
- `mail-delete.sh 123 456 789` - Delete multiple
|
||||
- `mail-mark-read.sh 123 456` - Mark multiple as read
|
||||
- `mail-mark-unread.sh 123 456` - Mark multiple as unread
|
||||
|
||||
**⚠️ No auto-refresh:** Scripts read cached data. Call `mail-refresh.sh` first if you need latest emails.
|
||||
|
||||
## Managing Emails
|
||||
|
||||
**Delete emails:**
|
||||
```bash
|
||||
scripts/mail-delete.sh 12345 # Delete one
|
||||
scripts/mail-delete.sh 12345 12346 12347 # Delete multiple
|
||||
```
|
||||
|
||||
**Mark as read/unread:**
|
||||
```bash
|
||||
scripts/mail-mark-read.sh 12345 12346 # Mark as read
|
||||
scripts/mail-mark-unread.sh 12345 # Mark as unread
|
||||
```
|
||||
|
||||
**Bulk operations example:**
|
||||
```bash
|
||||
# Find spam emails
|
||||
scripts/mail-fast-search.sh "spam" 50 > spam.txt
|
||||
|
||||
# Extract IDs and delete them
|
||||
grep "^[0-9]" spam.txt | cut -d'|' -f1 | xargs scripts/mail-delete.sh
|
||||
```
|
||||
|
||||
## Reading Email Bodies
|
||||
|
||||
```bash
|
||||
scripts/mail-read.sh 12345 # Single email
|
||||
scripts/mail-read.sh 12345 12346 12347 # Multiple emails (separated output)
|
||||
```
|
||||
|
||||
Uses position-optimized lookup (~2s per message). Multiple emails are separated by `========` with a summary at the end.
|
||||
|
||||
## Errors
|
||||
|
||||
| Error | Cause |
|
||||
|-------|-------|
|
||||
| `Mail.app is not running` | Open Mail.app before running scripts |
|
||||
| `Account not found` | Invalid account — check mail-accounts.sh |
|
||||
| `Message not found` | Invalid/deleted ID — get fresh from mail-list.sh |
|
||||
| `Can't get mailbox` | Invalid name — check mail-mailboxes.sh |
|
||||
| `Mail database not found` | SQLite DB missing — check ~/Library/Mail/V{9,10,11}/MailData/ |
|
||||
|
||||
## Technical Details
|
||||
|
||||
**Database:** `~/Library/Mail/V{9,10,11}/MailData/Envelope Index`
|
||||
|
||||
**Message lookup method (optimized):**
|
||||
1. Query SQLite for account UUID, mailbox path, and approximate position
|
||||
2. AppleScript accesses the specific account directly (no iteration)
|
||||
3. Search starts at the approximate position (±5 messages buffer)
|
||||
4. Falls back to full mailbox search only if position hint fails
|
||||
|
||||
**Safety:**
|
||||
- Fast search copies database to temp file before querying
|
||||
- Safe to use even if Mail.app is running
|
||||
- Delete/read/mark operations query live database but access is minimal
|
||||
|
||||
## Notes
|
||||
|
||||
- Message IDs are internal, get fresh ones from list/search
|
||||
- Confirm recipient before sending
|
||||
- AppleScript search is slow but comprehensive; SQLite is fast for metadata
|
||||
- Delete/mark operations support bulk actions (pass multiple IDs)
|
||||
- Always refresh before listing if you need the absolute latest emails
|
||||
|
||||
¹ **Known limitation:** Mail.app adds a leading blank line to sent emails. This is an AppleScript/Mail.app behavior that cannot be bypassed.
|
||||
@@ -1,22 +0,0 @@
|
||||
#!/bin/bash
|
||||
# List configured email accounts
|
||||
# Usage: mail-accounts.sh
|
||||
|
||||
osascript <<EOF
|
||||
tell application "Mail"
|
||||
set output to ""
|
||||
repeat with acct in every account
|
||||
set acctName to name of acct
|
||||
set acctType to account type of acct as string
|
||||
set acctEmail to ""
|
||||
try
|
||||
set acctEmail to email addresses of acct
|
||||
if class of acctEmail is list then
|
||||
set acctEmail to item 1 of acctEmail
|
||||
end if
|
||||
end try
|
||||
set output to output & acctName & " (" & acctType & ") - " & acctEmail & linefeed
|
||||
end repeat
|
||||
return output
|
||||
end tell
|
||||
EOF
|
||||
@@ -1,110 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Delete emails by message ID (optimized with position hints)
|
||||
# Usage: mail-delete.sh <message-id> [message-id...]
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "Usage: mail-delete.sh <message-id> [message-id...]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find the Mail database
|
||||
find_db() {
|
||||
local db
|
||||
for v in 11 10 9; do
|
||||
db="$HOME/Library/Mail/V$v/MailData/Envelope Index"
|
||||
if [[ -f "$db" ]]; then
|
||||
echo "$db"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
DB_PATH=$(find_db)
|
||||
|
||||
if [[ -z "$DB_PATH" ]]; then
|
||||
echo "Error: Mail database not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DELETED=0
|
||||
FAILED=0
|
||||
|
||||
for MSG_ID in "$@"; do
|
||||
# Get account UUID, mailbox path, and approximate position
|
||||
MSG_INFO=$(sqlite3 "$DB_PATH" "
|
||||
SELECT
|
||||
substr(mb.url, 8, instr(substr(mb.url, 8), '/') - 1) as account_uuid,
|
||||
replace(replace(substr(mb.url, 8 + instr(substr(mb.url, 8), '/')), '%5B', '['), '%5D', ']') as mailbox_path,
|
||||
(SELECT COUNT(*) FROM messages m2 WHERE m2.mailbox = m.mailbox AND m2.date_received >= m.date_received) as approx_pos
|
||||
FROM messages m
|
||||
JOIN mailboxes mb ON m.mailbox = mb.ROWID
|
||||
WHERE m.ROWID = $MSG_ID;" 2>/dev/null)
|
||||
|
||||
if [[ -z "$MSG_INFO" ]]; then
|
||||
echo "Message $MSG_ID not found in database" >&2
|
||||
FAILED=$((FAILED + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
IFS='|' read -r ACCOUNT_UUID MAILBOX_PATH APPROX_POS <<< "$MSG_INFO"
|
||||
MAILBOX_PATH=$(python3 -c "import urllib.parse; print(urllib.parse.unquote('$MAILBOX_PATH'))")
|
||||
|
||||
START_POS=$((APPROX_POS > 5 ? APPROX_POS - 5 : 1))
|
||||
END_POS=$((APPROX_POS + 20))
|
||||
|
||||
RESULT=$(osascript << EOF
|
||||
tell application "Mail"
|
||||
try
|
||||
set targetId to $MSG_ID
|
||||
set targetAccount to first account whose id is "$ACCOUNT_UUID"
|
||||
set mbx to mailbox "$MAILBOX_PATH" of targetAccount
|
||||
set msgCount to count of messages of mbx
|
||||
|
||||
if $END_POS > msgCount then
|
||||
set endPos to msgCount
|
||||
else
|
||||
set endPos to $END_POS
|
||||
end if
|
||||
|
||||
-- Search in expected range first
|
||||
repeat with i from $START_POS to endPos
|
||||
try
|
||||
set msg to message i of mbx
|
||||
if id of msg = targetId then
|
||||
delete msg
|
||||
return "OK"
|
||||
end if
|
||||
end try
|
||||
end repeat
|
||||
|
||||
-- Expand search if not found
|
||||
repeat with i from 1 to msgCount
|
||||
try
|
||||
set msg to message i of mbx
|
||||
if id of msg = targetId then
|
||||
delete msg
|
||||
return "OK"
|
||||
end if
|
||||
end try
|
||||
end repeat
|
||||
|
||||
return "ERROR: Message not found"
|
||||
on error errMsg
|
||||
return "ERROR: " & errMsg
|
||||
end try
|
||||
end tell
|
||||
EOF
|
||||
)
|
||||
|
||||
if [[ "$RESULT" == "OK" ]]; then
|
||||
echo "Deleted message $MSG_ID"
|
||||
DELETED=$((DELETED + 1))
|
||||
else
|
||||
echo "Failed to delete message $MSG_ID: $RESULT" >&2
|
||||
FAILED=$((FAILED + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "Summary: $DELETED deleted, $FAILED failed"
|
||||
@@ -1,59 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Fast SQLite-based email search (~50ms vs minutes with AppleScript)
|
||||
# Safe to use even if Mail.app is running (copies DB to temp file)
|
||||
# Usage: mail-fast-search.sh <query> [limit]
|
||||
|
||||
set -e
|
||||
|
||||
QUERY="${1:?Usage: mail-fast-search.sh <query> [limit]}"
|
||||
LIMIT="${2:-20}"
|
||||
|
||||
# Find the Mail envelope index database
|
||||
find_db() {
|
||||
local db
|
||||
for v in 11 10 9; do
|
||||
db="$HOME/Library/Mail/V$v/MailData/Envelope Index"
|
||||
if [[ -f "$db" ]]; then
|
||||
# Verify this DB has the messages table
|
||||
if sqlite3 "$db" "SELECT 1 FROM messages LIMIT 1" &>/dev/null; then
|
||||
echo "$db"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
SOURCE_DB=$(find_db)
|
||||
|
||||
if [[ -z "$SOURCE_DB" ]]; then
|
||||
echo "Error: Mail database not found or schema incompatible" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Copy to temp file to avoid corrupting the live DB while Mail.app is running
|
||||
TEMP_DB=$(mktemp -t mail-search.XXXXXX)
|
||||
cleanup() {
|
||||
rm -f "$TEMP_DB" 2>/dev/null || true
|
||||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
cp "$SOURCE_DB" "$TEMP_DB"
|
||||
|
||||
# Search by subject, sender address, or sender name
|
||||
sqlite3 -header -separator ' | ' "$TEMP_DB" "
|
||||
SELECT
|
||||
m.ROWID as id,
|
||||
CASE WHEN (m.flags & 1) = 0 THEN '●' ELSE ' ' END as unread,
|
||||
datetime(m.date_sent, 'unixepoch', 'localtime') as date,
|
||||
COALESCE(a.comment, a.address, 'Unknown') as sender,
|
||||
COALESCE(s.subject, '(no subject)') as subject
|
||||
FROM messages m
|
||||
LEFT JOIN subjects s ON m.subject = s.ROWID
|
||||
LEFT JOIN addresses a ON m.sender = a.ROWID
|
||||
WHERE s.subject LIKE '%${QUERY}%'
|
||||
OR a.address LIKE '%${QUERY}%'
|
||||
OR a.comment LIKE '%${QUERY}%'
|
||||
ORDER BY m.date_sent DESC
|
||||
LIMIT ${LIMIT};
|
||||
"
|
||||
@@ -1,60 +0,0 @@
|
||||
#!/bin/bash
|
||||
# List recent emails from a mailbox
|
||||
# Usage: mail-list.sh [mailbox] [account] [limit]
|
||||
|
||||
MAILBOX="${1:-INBOX}"
|
||||
ACCOUNT="${2:-}"
|
||||
LIMIT="${3:-10}"
|
||||
|
||||
if [ -n "$ACCOUNT" ]; then
|
||||
osascript <<EOF
|
||||
tell application "Mail"
|
||||
set output to ""
|
||||
set targetMailbox to mailbox "$MAILBOX" of account "$ACCOUNT"
|
||||
set msgs to messages 1 through $LIMIT of targetMailbox
|
||||
repeat with m in msgs
|
||||
set mid to id of m
|
||||
set msubject to subject of m
|
||||
set msender to sender of m
|
||||
set mdate to date received of m
|
||||
set mread to read status of m
|
||||
set readFlag to "●"
|
||||
if mread then set readFlag to " "
|
||||
set output to output & mid & " | " & readFlag & " | " & mdate & " | " & msender & " | " & msubject & linefeed
|
||||
end repeat
|
||||
return output
|
||||
end tell
|
||||
EOF
|
||||
else
|
||||
osascript <<EOF
|
||||
tell application "Mail"
|
||||
set output to ""
|
||||
set allAccounts to every account
|
||||
set foundMsgs to {}
|
||||
repeat with acct in allAccounts
|
||||
try
|
||||
set targetMailbox to mailbox "$MAILBOX" of acct
|
||||
set msgs to messages 1 through $LIMIT of targetMailbox
|
||||
repeat with m in msgs
|
||||
set end of foundMsgs to m
|
||||
end repeat
|
||||
end try
|
||||
end repeat
|
||||
set sortedMsgs to foundMsgs
|
||||
set countLimit to $LIMIT
|
||||
if (count of sortedMsgs) < countLimit then set countLimit to (count of sortedMsgs)
|
||||
repeat with i from 1 to countLimit
|
||||
set m to item i of sortedMsgs
|
||||
set mid to id of m
|
||||
set msubject to subject of m
|
||||
set msender to sender of m
|
||||
set mdate to date received of m
|
||||
set mread to read status of m
|
||||
set readFlag to "●"
|
||||
if mread then set readFlag to " "
|
||||
set output to output & mid & " | " & readFlag & " | " & mdate & " | " & msender & " | " & msubject & linefeed
|
||||
end repeat
|
||||
return output
|
||||
end tell
|
||||
EOF
|
||||
fi
|
||||
@@ -1,41 +0,0 @@
|
||||
#!/bin/bash
|
||||
# List mailboxes for an account
|
||||
# Usage: mail-mailboxes.sh [account]
|
||||
|
||||
ACCOUNT="${1:-}"
|
||||
|
||||
if [ -n "$ACCOUNT" ]; then
|
||||
osascript <<EOF
|
||||
tell application "Mail"
|
||||
set output to ""
|
||||
set acct to account "$ACCOUNT"
|
||||
repeat with mbox in every mailbox of acct
|
||||
set mboxName to name of mbox
|
||||
set msgCount to count of messages of mbox
|
||||
set output to output & mboxName & " (" & msgCount & " messages)" & linefeed
|
||||
end repeat
|
||||
return output
|
||||
end tell
|
||||
EOF
|
||||
else
|
||||
osascript <<EOF
|
||||
tell application "Mail"
|
||||
set output to ""
|
||||
repeat with acct in every account
|
||||
set acctName to name of acct
|
||||
set output to output & "=== " & acctName & " ===" & linefeed
|
||||
repeat with mbox in every mailbox of acct
|
||||
set mboxName to name of mbox
|
||||
try
|
||||
set msgCount to count of messages of mbox
|
||||
set output to output & " " & mboxName & " (" & msgCount & " messages)" & linefeed
|
||||
on error
|
||||
set output to output & " " & mboxName & linefeed
|
||||
end try
|
||||
end repeat
|
||||
set output to output & linefeed
|
||||
end repeat
|
||||
return output
|
||||
end tell
|
||||
EOF
|
||||
fi
|
||||
@@ -1,110 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Mark emails as read by message ID (optimized with position hints)
|
||||
# Usage: mail-mark-read.sh <message-id> [message-id...]
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "Usage: mail-mark-read.sh <message-id> [message-id...]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find the Mail database
|
||||
find_db() {
|
||||
local db
|
||||
for v in 11 10 9; do
|
||||
db="$HOME/Library/Mail/V$v/MailData/Envelope Index"
|
||||
if [[ -f "$db" ]]; then
|
||||
echo "$db"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
DB_PATH=$(find_db)
|
||||
|
||||
if [[ -z "$DB_PATH" ]]; then
|
||||
echo "Error: Mail database not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MARKED=0
|
||||
FAILED=0
|
||||
|
||||
for MSG_ID in "$@"; do
|
||||
# Get account UUID, mailbox path, and approximate position
|
||||
MSG_INFO=$(sqlite3 "$DB_PATH" "
|
||||
SELECT
|
||||
substr(mb.url, 8, instr(substr(mb.url, 8), '/') - 1) as account_uuid,
|
||||
replace(replace(substr(mb.url, 8 + instr(substr(mb.url, 8), '/')), '%5B', '['), '%5D', ']') as mailbox_path,
|
||||
(SELECT COUNT(*) FROM messages m2 WHERE m2.mailbox = m.mailbox AND m2.date_received >= m.date_received) as approx_pos
|
||||
FROM messages m
|
||||
JOIN mailboxes mb ON m.mailbox = mb.ROWID
|
||||
WHERE m.ROWID = $MSG_ID;" 2>/dev/null)
|
||||
|
||||
if [[ -z "$MSG_INFO" ]]; then
|
||||
echo "Message $MSG_ID not found in database" >&2
|
||||
FAILED=$((FAILED + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
IFS='|' read -r ACCOUNT_UUID MAILBOX_PATH APPROX_POS <<< "$MSG_INFO"
|
||||
MAILBOX_PATH=$(python3 -c "import urllib.parse; print(urllib.parse.unquote('$MAILBOX_PATH'))")
|
||||
|
||||
START_POS=$((APPROX_POS > 5 ? APPROX_POS - 5 : 1))
|
||||
END_POS=$((APPROX_POS + 20))
|
||||
|
||||
RESULT=$(osascript << EOF
|
||||
tell application "Mail"
|
||||
try
|
||||
set targetId to $MSG_ID
|
||||
set targetAccount to first account whose id is "$ACCOUNT_UUID"
|
||||
set mbx to mailbox "$MAILBOX_PATH" of targetAccount
|
||||
set msgCount to count of messages of mbx
|
||||
|
||||
if $END_POS > msgCount then
|
||||
set endPos to msgCount
|
||||
else
|
||||
set endPos to $END_POS
|
||||
end if
|
||||
|
||||
-- Search in expected range first
|
||||
repeat with i from $START_POS to endPos
|
||||
try
|
||||
set msg to message i of mbx
|
||||
if id of msg = targetId then
|
||||
set read status of msg to true
|
||||
return "OK"
|
||||
end if
|
||||
end try
|
||||
end repeat
|
||||
|
||||
-- Expand search if not found
|
||||
repeat with i from 1 to msgCount
|
||||
try
|
||||
set msg to message i of mbx
|
||||
if id of msg = targetId then
|
||||
set read status of msg to true
|
||||
return "OK"
|
||||
end if
|
||||
end try
|
||||
end repeat
|
||||
|
||||
return "ERROR: Message not found"
|
||||
on error errMsg
|
||||
return "ERROR: " & errMsg
|
||||
end try
|
||||
end tell
|
||||
EOF
|
||||
)
|
||||
|
||||
if [[ "$RESULT" == "OK" ]]; then
|
||||
echo "Marked message $MSG_ID as read"
|
||||
MARKED=$((MARKED + 1))
|
||||
else
|
||||
echo "Failed to mark message $MSG_ID: $RESULT" >&2
|
||||
FAILED=$((FAILED + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "Summary: $MARKED marked, $FAILED failed"
|
||||
@@ -1,110 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Mark emails as unread by message ID (optimized with position hints)
|
||||
# Usage: mail-mark-unread.sh <message-id> [message-id...]
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "Usage: mail-mark-unread.sh <message-id> [message-id...]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find the Mail database
|
||||
find_db() {
|
||||
local db
|
||||
for v in 11 10 9; do
|
||||
db="$HOME/Library/Mail/V$v/MailData/Envelope Index"
|
||||
if [[ -f "$db" ]]; then
|
||||
echo "$db"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
DB_PATH=$(find_db)
|
||||
|
||||
if [[ -z "$DB_PATH" ]]; then
|
||||
echo "Error: Mail database not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MARKED=0
|
||||
FAILED=0
|
||||
|
||||
for MSG_ID in "$@"; do
|
||||
# Get account UUID, mailbox path, and approximate position
|
||||
MSG_INFO=$(sqlite3 "$DB_PATH" "
|
||||
SELECT
|
||||
substr(mb.url, 8, instr(substr(mb.url, 8), '/') - 1) as account_uuid,
|
||||
replace(replace(substr(mb.url, 8 + instr(substr(mb.url, 8), '/')), '%5B', '['), '%5D', ']') as mailbox_path,
|
||||
(SELECT COUNT(*) FROM messages m2 WHERE m2.mailbox = m.mailbox AND m2.date_received >= m.date_received) as approx_pos
|
||||
FROM messages m
|
||||
JOIN mailboxes mb ON m.mailbox = mb.ROWID
|
||||
WHERE m.ROWID = $MSG_ID;" 2>/dev/null)
|
||||
|
||||
if [[ -z "$MSG_INFO" ]]; then
|
||||
echo "Message $MSG_ID not found in database" >&2
|
||||
FAILED=$((FAILED + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
IFS='|' read -r ACCOUNT_UUID MAILBOX_PATH APPROX_POS <<< "$MSG_INFO"
|
||||
MAILBOX_PATH=$(python3 -c "import urllib.parse; print(urllib.parse.unquote('$MAILBOX_PATH'))")
|
||||
|
||||
START_POS=$((APPROX_POS > 5 ? APPROX_POS - 5 : 1))
|
||||
END_POS=$((APPROX_POS + 20))
|
||||
|
||||
RESULT=$(osascript << EOF
|
||||
tell application "Mail"
|
||||
try
|
||||
set targetId to $MSG_ID
|
||||
set targetAccount to first account whose id is "$ACCOUNT_UUID"
|
||||
set mbx to mailbox "$MAILBOX_PATH" of targetAccount
|
||||
set msgCount to count of messages of mbx
|
||||
|
||||
if $END_POS > msgCount then
|
||||
set endPos to msgCount
|
||||
else
|
||||
set endPos to $END_POS
|
||||
end if
|
||||
|
||||
-- Search in expected range first
|
||||
repeat with i from $START_POS to endPos
|
||||
try
|
||||
set msg to message i of mbx
|
||||
if id of msg = targetId then
|
||||
set read status of msg to false
|
||||
return "OK"
|
||||
end if
|
||||
end try
|
||||
end repeat
|
||||
|
||||
-- Expand search if not found
|
||||
repeat with i from 1 to msgCount
|
||||
try
|
||||
set msg to message i of mbx
|
||||
if id of msg = targetId then
|
||||
set read status of msg to false
|
||||
return "OK"
|
||||
end if
|
||||
end try
|
||||
end repeat
|
||||
|
||||
return "ERROR: Message not found"
|
||||
on error errMsg
|
||||
return "ERROR: " & errMsg
|
||||
end try
|
||||
end tell
|
||||
EOF
|
||||
)
|
||||
|
||||
if [[ "$RESULT" == "OK" ]]; then
|
||||
echo "Marked message $MSG_ID as unread"
|
||||
MARKED=$((MARKED + 1))
|
||||
else
|
||||
echo "Failed to mark message $MSG_ID: $RESULT" >&2
|
||||
FAILED=$((FAILED + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "Summary: $MARKED marked, $FAILED failed"
|
||||
@@ -1,163 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Read email content from Apple Mail's database and emlx files
|
||||
Usage: mail-read-emlx.py <message-row-id>
|
||||
"""
|
||||
|
||||
import sys
|
||||
import sqlite3
|
||||
import os
|
||||
import email
|
||||
from email import policy
|
||||
from pathlib import Path
|
||||
|
||||
def find_mail_db():
|
||||
"""Find the Apple Mail database"""
|
||||
for v in [11, 10, 9]:
|
||||
db_path = Path.home() / "Library" / "Mail" / f"V{v}" / "MailData" / "Envelope Index"
|
||||
if db_path.exists():
|
||||
return str(db_path)
|
||||
return None
|
||||
|
||||
def find_emlx_file(mail_dir, account_id, mailbox_path, remote_id):
|
||||
"""Try to find the emlx file for a message"""
|
||||
# Common locations to search
|
||||
mail_v_dir = Path(mail_dir)
|
||||
account_dir = mail_v_dir / account_id
|
||||
|
||||
if not account_dir.exists():
|
||||
return None
|
||||
|
||||
# Search for emlx files with the remote_id as filename
|
||||
for emlx_file in account_dir.rglob(f"{remote_id}.emlx"):
|
||||
return str(emlx_file)
|
||||
|
||||
return None
|
||||
|
||||
def parse_emlx(emlx_path):
|
||||
"""Parse an emlx file and return the email message"""
|
||||
with open(emlx_path, 'rb') as f:
|
||||
# First line is the byte count, skip it
|
||||
first_line = f.readline()
|
||||
# Rest is the raw email
|
||||
raw_email = f.read()
|
||||
|
||||
msg = email.message_from_bytes(raw_email, policy=policy.default)
|
||||
return msg
|
||||
|
||||
def get_message_info(db_path, msg_id):
|
||||
"""Get message information from the database"""
|
||||
conn = sqlite3.connect(db_path)
|
||||
cursor = conn.cursor()
|
||||
|
||||
query = """
|
||||
SELECT
|
||||
mgd.message_id_header,
|
||||
s.subject,
|
||||
a.comment as sender,
|
||||
datetime(m.date_received, 'unixepoch', '31 years', 'localtime') as date_received,
|
||||
m.remote_id,
|
||||
mb.url
|
||||
FROM messages m
|
||||
LEFT JOIN message_global_data mgd ON m.global_message_id = mgd.ROWID
|
||||
LEFT JOIN subjects s ON m.subject = s.ROWID
|
||||
LEFT JOIN addresses a ON m.sender = a.ROWID
|
||||
LEFT JOIN mailboxes mb ON m.mailbox = mb.ROWID
|
||||
WHERE m.ROWID = ?
|
||||
"""
|
||||
|
||||
cursor.execute(query, (msg_id,))
|
||||
result = cursor.fetchone()
|
||||
conn.close()
|
||||
|
||||
if not result:
|
||||
return None
|
||||
|
||||
return {
|
||||
'message_id_header': result[0],
|
||||
'subject': result[1],
|
||||
'sender': result[2],
|
||||
'date_received': result[3],
|
||||
'remote_id': result[4],
|
||||
'mailbox_url': result[5]
|
||||
}
|
||||
|
||||
def format_email_output(msg_info, email_msg=None):
|
||||
"""Format email information for output"""
|
||||
output = []
|
||||
output.append(f"From: {msg_info['sender']}")
|
||||
|
||||
if email_msg:
|
||||
if email_msg.get('To'):
|
||||
output.append(f"To: {email_msg.get('To')}")
|
||||
if email_msg.get('Cc'):
|
||||
output.append(f"Cc: {email_msg.get('Cc')}")
|
||||
|
||||
output.append(f"Date: {msg_info['date_received']}")
|
||||
output.append(f"Subject: {msg_info['subject']}")
|
||||
output.append("")
|
||||
output.append("---")
|
||||
output.append("")
|
||||
|
||||
if email_msg:
|
||||
# Get the email body
|
||||
if email_msg.is_multipart():
|
||||
for part in email_msg.walk():
|
||||
if part.get_content_type() == "text/plain":
|
||||
body = part.get_content()
|
||||
output.append(body)
|
||||
break
|
||||
elif part.get_content_type() == "text/html":
|
||||
# Fallback to HTML if no plain text
|
||||
body = part.get_content()
|
||||
output.append(body)
|
||||
else:
|
||||
body = email_msg.get_content()
|
||||
output.append(body)
|
||||
else:
|
||||
output.append("(Message body not available - emlx file not found)")
|
||||
|
||||
return "\n".join(output)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: mail-read-emlx.py <message-row-id>", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
msg_id = sys.argv[1]
|
||||
|
||||
# Find the database
|
||||
db_path = find_mail_db()
|
||||
if not db_path:
|
||||
print("Error: Mail database not found", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
# Get message info from database
|
||||
msg_info = get_message_info(db_path, msg_id)
|
||||
if not msg_info:
|
||||
print(f"Message not found with ID: {msg_id}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
# Try to find and parse the emlx file
|
||||
email_msg = None
|
||||
if msg_info['remote_id'] and msg_info['mailbox_url']:
|
||||
# Parse account ID from mailbox URL
|
||||
# Format: imap://ACCOUNT-ID/MAILBOX-PATH
|
||||
if msg_info['mailbox_url'].startswith('imap://'):
|
||||
parts = msg_info['mailbox_url'][7:].split('/', 1)
|
||||
if len(parts) >= 1:
|
||||
account_id = parts[0]
|
||||
mail_dir = Path(db_path).parent.parent
|
||||
emlx_file = find_emlx_file(mail_dir, account_id, None, msg_info['remote_id'])
|
||||
|
||||
if emlx_file:
|
||||
try:
|
||||
email_msg = parse_emlx(emlx_file)
|
||||
except Exception as e:
|
||||
print(f"Warning: Could not parse emlx file: {e}", file=sys.stderr)
|
||||
|
||||
# Output the formatted message
|
||||
print(format_email_output(msg_info, email_msg))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,149 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Read full email content by message ID (supports multiple IDs)
|
||||
# Usage: mail-read.sh <message-id> [message-id...]
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: mail-read.sh <message-id> [message-id...]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find the Mail database
|
||||
find_db() {
|
||||
local db
|
||||
for v in 11 10 9; do
|
||||
db="$HOME/Library/Mail/V$v/MailData/Envelope Index"
|
||||
if [[ -f "$db" ]]; then
|
||||
echo "$db"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
DB_PATH=$(find_db)
|
||||
|
||||
if [[ -z "$DB_PATH" ]]; then
|
||||
echo "Error: Mail database not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
READ_COUNT=0
|
||||
FAILED_COUNT=0
|
||||
FIRST=true
|
||||
|
||||
for MSG_ID in "$@"; do
|
||||
# Add separator between messages
|
||||
if [ "$FIRST" = true ]; then
|
||||
FIRST=false
|
||||
else
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Get account UUID, mailbox path, and approximate position from database
|
||||
MSG_INFO=$(sqlite3 "$DB_PATH" "
|
||||
SELECT
|
||||
substr(mb.url, 8, instr(substr(mb.url, 8), '/') - 1) as account_uuid,
|
||||
replace(replace(substr(mb.url, 8 + instr(substr(mb.url, 8), '/')), '%5B', '['), '%5D', ']') as mailbox_path,
|
||||
(SELECT COUNT(*) FROM messages m2 WHERE m2.mailbox = m.mailbox AND m2.date_received >= m.date_received) as approx_pos
|
||||
FROM messages m
|
||||
JOIN mailboxes mb ON m.mailbox = mb.ROWID
|
||||
WHERE m.ROWID = $MSG_ID;" 2>/dev/null)
|
||||
|
||||
if [[ -z "$MSG_INFO" ]]; then
|
||||
echo "Error: Message $MSG_ID not found in database" >&2
|
||||
FAILED_COUNT=$((FAILED_COUNT + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
IFS='|' read -r ACCOUNT_UUID MAILBOX_PATH APPROX_POS <<< "$MSG_INFO"
|
||||
MAILBOX_PATH=$(python3 -c "import urllib.parse; print(urllib.parse.unquote('$MAILBOX_PATH'))")
|
||||
|
||||
START_POS=$((APPROX_POS > 5 ? APPROX_POS - 5 : 1))
|
||||
END_POS=$((APPROX_POS + 20))
|
||||
|
||||
# Use AppleScript with direct account and position access
|
||||
RESULT=$(osascript <<EOF
|
||||
tell application "Mail"
|
||||
try
|
||||
set targetId to $MSG_ID
|
||||
set targetAccountId to "$ACCOUNT_UUID"
|
||||
set targetMailboxPath to "$MAILBOX_PATH"
|
||||
set startPos to $START_POS
|
||||
set endPos to $END_POS
|
||||
set foundMsg to missing value
|
||||
|
||||
set targetAccount to first account whose id is targetAccountId
|
||||
set mbx to mailbox targetMailboxPath of targetAccount
|
||||
set msgCount to count of messages of mbx
|
||||
|
||||
if endPos > msgCount then set endPos to msgCount
|
||||
if startPos < 1 then set startPos to 1
|
||||
|
||||
repeat with i from startPos to endPos
|
||||
try
|
||||
set msg to message i of mbx
|
||||
if id of msg = targetId then
|
||||
set foundMsg to msg
|
||||
exit repeat
|
||||
end if
|
||||
end try
|
||||
end repeat
|
||||
|
||||
if foundMsg is missing value then
|
||||
repeat with i from 1 to msgCount
|
||||
try
|
||||
set msg to message i of mbx
|
||||
if id of msg = targetId then
|
||||
set foundMsg to msg
|
||||
exit repeat
|
||||
end if
|
||||
end try
|
||||
end repeat
|
||||
end if
|
||||
|
||||
if foundMsg is missing value then
|
||||
return "ERROR:Message not found with ID: $MSG_ID"
|
||||
end if
|
||||
|
||||
set output to "From: " & sender of foundMsg & linefeed
|
||||
|
||||
set mto to ""
|
||||
try
|
||||
set recipList to to recipients of foundMsg
|
||||
repeat with r in recipList
|
||||
set mto to mto & address of r & ", "
|
||||
end repeat
|
||||
if mto ends with ", " then set mto to text 1 thru -3 of mto
|
||||
end try
|
||||
set output to output & "To: " & mto & linefeed
|
||||
|
||||
set output to output & "Date: " & date received of foundMsg & linefeed
|
||||
set output to output & "Subject: " & subject of foundMsg & linefeed
|
||||
set output to output & linefeed & "---" & linefeed & linefeed
|
||||
set output to output & content of foundMsg
|
||||
|
||||
return output
|
||||
on error errMsg
|
||||
return "ERROR:" & errMsg
|
||||
end try
|
||||
end tell
|
||||
EOF
|
||||
)
|
||||
|
||||
if [[ "$RESULT" == ERROR:* ]]; then
|
||||
echo "${RESULT#ERROR:}" >&2
|
||||
FAILED_COUNT=$((FAILED_COUNT + 1))
|
||||
else
|
||||
echo "$RESULT"
|
||||
READ_COUNT=$((READ_COUNT + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
# Print summary if multiple messages
|
||||
if [ $# -gt 1 ]; then
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "Summary: $READ_COUNT read, $FAILED_COUNT failed"
|
||||
fi
|
||||
@@ -1,126 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Force Mail.app to check for new mail across all accounts (or a specific account)
|
||||
# Usage: mail-refresh.sh [account] [wait_seconds]
|
||||
#
|
||||
# Arguments:
|
||||
# account - Optional: specific account name (from mail-accounts.sh)
|
||||
# wait_seconds - Optional: max seconds to wait for sync (default: 10, 0 = no wait)
|
||||
#
|
||||
# Examples:
|
||||
# mail-refresh.sh # Refresh all accounts, wait up to 10s
|
||||
# mail-refresh.sh Google # Refresh only Google account
|
||||
# mail-refresh.sh "" 5 # Refresh all, wait up to 5 seconds
|
||||
# mail-refresh.sh Google 0 # Refresh Google, return immediately
|
||||
#
|
||||
# The script will return early if sync appears complete (database stops updating).
|
||||
|
||||
set -e
|
||||
|
||||
ACCOUNT="${1:-}"
|
||||
MAX_WAIT="${2:-10}"
|
||||
|
||||
# Ensure wait is a number
|
||||
if ! [[ "$MAX_WAIT" =~ ^[0-9]+$ ]]; then
|
||||
echo "ERROR: wait_seconds must be a non-negative integer" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if Mail.app is running
|
||||
if ! pgrep -q "Mail"; then
|
||||
echo "ERROR: Mail.app is not running. Please open Mail.app first." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find the database
|
||||
find_db() {
|
||||
for v in 11 10 9; do
|
||||
local db="$HOME/Library/Mail/V$v/MailData/Envelope Index"
|
||||
if [[ -f "$db" ]]; then
|
||||
echo "$db"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
DB_PATH=$(find_db)
|
||||
|
||||
# Get initial message count
|
||||
get_msg_count() {
|
||||
if [[ -n "$DB_PATH" ]]; then
|
||||
sqlite3 "$DB_PATH" "SELECT COUNT(*) FROM messages;" 2>/dev/null || echo "0"
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
}
|
||||
|
||||
INITIAL_COUNT=$(get_msg_count)
|
||||
|
||||
if [ -n "$ACCOUNT" ]; then
|
||||
# Refresh specific account
|
||||
ACCOUNT_EXISTS=$(osascript -e "tell application \"Mail\" to exists account \"$ACCOUNT\"" 2>/dev/null || echo "false")
|
||||
|
||||
if [ "$ACCOUNT_EXISTS" != "true" ]; then
|
||||
echo "ERROR: Account '$ACCOUNT' not found. Run mail-accounts.sh to see available accounts." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
osascript <<EOF
|
||||
tell application "Mail"
|
||||
check for new mail in account "$ACCOUNT"
|
||||
end tell
|
||||
EOF
|
||||
|
||||
echo "Refresh triggered for account: $ACCOUNT"
|
||||
else
|
||||
# Refresh all accounts
|
||||
osascript <<EOF
|
||||
tell application "Mail"
|
||||
check for new mail
|
||||
end tell
|
||||
EOF
|
||||
|
||||
echo "Refresh triggered for all accounts"
|
||||
fi
|
||||
|
||||
# Wait for sync with smart detection
|
||||
if [ "$MAX_WAIT" -gt 0 ]; then
|
||||
echo "Waiting for sync (max ${MAX_WAIT}s)..."
|
||||
|
||||
STABLE_COUNT=0
|
||||
LAST_COUNT=$INITIAL_COUNT
|
||||
|
||||
for ((i=1; i<=MAX_WAIT; i++)); do
|
||||
sleep 1
|
||||
CURRENT_COUNT=$(get_msg_count)
|
||||
|
||||
if [ "$CURRENT_COUNT" != "$LAST_COUNT" ]; then
|
||||
# Database changed, reset stability counter
|
||||
STABLE_COUNT=0
|
||||
LAST_COUNT=$CURRENT_COUNT
|
||||
else
|
||||
# No change, increment stability counter
|
||||
STABLE_COUNT=$((STABLE_COUNT + 1))
|
||||
fi
|
||||
|
||||
# Consider stable after 2 seconds of no changes
|
||||
if [ "$STABLE_COUNT" -ge 2 ]; then
|
||||
NEW_MSGS=$((CURRENT_COUNT - INITIAL_COUNT))
|
||||
if [ "$NEW_MSGS" -gt 0 ]; then
|
||||
echo "Sync complete in ${i}s (+${NEW_MSGS} messages)"
|
||||
else
|
||||
echo "Sync complete in ${i}s (no new messages)"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Timeout reached
|
||||
FINAL_COUNT=$(get_msg_count)
|
||||
NEW_MSGS=$((FINAL_COUNT - INITIAL_COUNT))
|
||||
if [ "$NEW_MSGS" -gt 0 ]; then
|
||||
echo "Timeout reached (+${NEW_MSGS} messages, sync may still be in progress)"
|
||||
else
|
||||
echo "Timeout reached (no new messages detected)"
|
||||
fi
|
||||
fi
|
||||
@@ -1,50 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Reply to an email by message ID
|
||||
# Usage: mail-reply.sh <message-id> "Reply body" [reply-all]
|
||||
|
||||
MSG_ID="${1:-}"
|
||||
REPLY_BODY="${2:-}"
|
||||
REPLY_ALL="${3:-false}"
|
||||
|
||||
if [ -z "$MSG_ID" ] || [ -z "$REPLY_BODY" ]; then
|
||||
echo "Usage: mail-reply.sh <message-id> \"Reply body\" [reply-all]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
REPLY_BODY_ESCAPED=$(echo "$REPLY_BODY" | sed 's/"/\\"/g')
|
||||
|
||||
osascript <<EOF
|
||||
tell application "Mail"
|
||||
set foundMsg to missing value
|
||||
|
||||
-- Search all accounts for the message
|
||||
repeat with acct in every account
|
||||
repeat with mbox in every mailbox of acct
|
||||
try
|
||||
set msgs to (messages of mbox whose id is $MSG_ID)
|
||||
if (count of msgs) > 0 then
|
||||
set foundMsg to item 1 of msgs
|
||||
exit repeat
|
||||
end if
|
||||
end try
|
||||
end repeat
|
||||
if foundMsg is not missing value then exit repeat
|
||||
end repeat
|
||||
|
||||
if foundMsg is missing value then
|
||||
return "Message not found with ID: $MSG_ID"
|
||||
end if
|
||||
|
||||
if "$REPLY_ALL" is "true" then
|
||||
set replyMsg to reply foundMsg with opening window and reply to all
|
||||
else
|
||||
set replyMsg to reply foundMsg with opening window
|
||||
end if
|
||||
|
||||
set oldContent to content of replyMsg
|
||||
set content of replyMsg to "$REPLY_BODY_ESCAPED" & return & return & oldContent
|
||||
send replyMsg
|
||||
|
||||
return "Reply sent"
|
||||
end tell
|
||||
EOF
|
||||
@@ -1,65 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Search emails by subject/sender/content
|
||||
# Usage: mail-search.sh "query" [mailbox] [limit]
|
||||
|
||||
QUERY="${1:-}"
|
||||
MAILBOX="${2:-}"
|
||||
LIMIT="${3:-20}"
|
||||
|
||||
if [ -z "$QUERY" ]; then
|
||||
echo "Usage: mail-search.sh \"query\" [mailbox] [limit]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
osascript <<EOF
|
||||
tell application "Mail"
|
||||
set output to ""
|
||||
set foundMsgs to {}
|
||||
set searchQuery to "$QUERY"
|
||||
set limitCount to $LIMIT
|
||||
|
||||
if "$MAILBOX" is not "" then
|
||||
-- Search specific mailbox across accounts
|
||||
repeat with acct in every account
|
||||
try
|
||||
set targetMailbox to mailbox "$MAILBOX" of acct
|
||||
set msgs to (messages of targetMailbox whose subject contains searchQuery or sender contains searchQuery)
|
||||
repeat with m in msgs
|
||||
set end of foundMsgs to m
|
||||
end repeat
|
||||
end try
|
||||
end repeat
|
||||
else
|
||||
-- Search all mailboxes
|
||||
repeat with acct in every account
|
||||
repeat with mbox in every mailbox of acct
|
||||
try
|
||||
set msgs to (messages of mbox whose subject contains searchQuery or sender contains searchQuery)
|
||||
repeat with m in msgs
|
||||
set end of foundMsgs to m
|
||||
end repeat
|
||||
end try
|
||||
end repeat
|
||||
end repeat
|
||||
end if
|
||||
|
||||
if (count of foundMsgs) < limitCount then set limitCount to (count of foundMsgs)
|
||||
|
||||
repeat with i from 1 to limitCount
|
||||
set m to item i of foundMsgs
|
||||
set mid to id of m
|
||||
set msubject to subject of m
|
||||
set msender to sender of m
|
||||
set mdate to date received of m
|
||||
set mread to read status of m
|
||||
set readFlag to "●"
|
||||
if mread then set readFlag to " "
|
||||
set output to output & mid & " | " & readFlag & " | " & mdate & " | " & msender & " | " & msubject & linefeed
|
||||
end repeat
|
||||
|
||||
if output is "" then
|
||||
return "No emails found matching: " & searchQuery
|
||||
end if
|
||||
return output
|
||||
end tell
|
||||
EOF
|
||||
@@ -1,73 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Send an email via Mail.app
|
||||
# Usage: mail-send.sh "to@email.com" "Subject" "Body" [from-account] [attachment]
|
||||
|
||||
TO="${1:-}"
|
||||
SUBJECT="${2:-}"
|
||||
BODY="${3:-}"
|
||||
FROM_ACCOUNT="${4:-}"
|
||||
ATTACHMENT="${5:-}"
|
||||
|
||||
if [ -z "$TO" ] || [ -z "$SUBJECT" ] || [ -z "$BODY" ]; then
|
||||
echo "Usage: mail-send.sh \"to@email.com\" \"Subject\" \"Body\" [from-account] [attachment]"
|
||||
echo " All three arguments (to, subject, body) are required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Escape quotes in body and trim whitespace
|
||||
BODY_ESCAPED=$(printf '%s' "$BODY" | sed 's/"/\\"/g')
|
||||
SUBJECT_ESCAPED=$(printf '%s' "$SUBJECT" | sed 's/"/\\"/g')
|
||||
|
||||
if [ -n "$FROM_ACCOUNT" ] && [ -n "$ATTACHMENT" ]; then
|
||||
osascript <<EOF
|
||||
tell application "Mail"
|
||||
set newMessage to make new outgoing message with properties {subject:"$SUBJECT_ESCAPED", content:"$BODY_ESCAPED", visible:false}
|
||||
tell newMessage
|
||||
make new to recipient at end of to recipients with properties {address:"$TO"}
|
||||
set sender to "$FROM_ACCOUNT"
|
||||
tell content
|
||||
make new attachment with properties {file name:POSIX file "$ATTACHMENT"} at after last paragraph
|
||||
end tell
|
||||
end tell
|
||||
send newMessage
|
||||
return "Email sent to $TO"
|
||||
end tell
|
||||
EOF
|
||||
elif [ -n "$FROM_ACCOUNT" ]; then
|
||||
osascript <<EOF
|
||||
tell application "Mail"
|
||||
set newMessage to make new outgoing message with properties {subject:"$SUBJECT_ESCAPED", content:"$BODY_ESCAPED", visible:false}
|
||||
tell newMessage
|
||||
make new to recipient at end of to recipients with properties {address:"$TO"}
|
||||
set sender to "$FROM_ACCOUNT"
|
||||
end tell
|
||||
send newMessage
|
||||
return "Email sent to $TO"
|
||||
end tell
|
||||
EOF
|
||||
elif [ -n "$ATTACHMENT" ]; then
|
||||
osascript <<EOF
|
||||
tell application "Mail"
|
||||
set newMessage to make new outgoing message with properties {subject:"$SUBJECT_ESCAPED", content:"$BODY_ESCAPED", visible:false}
|
||||
tell newMessage
|
||||
make new to recipient at end of to recipients with properties {address:"$TO"}
|
||||
tell content
|
||||
make new attachment with properties {file name:POSIX file "$ATTACHMENT"} at after last paragraph
|
||||
end tell
|
||||
end tell
|
||||
send newMessage
|
||||
return "Email sent to $TO"
|
||||
end tell
|
||||
EOF
|
||||
else
|
||||
osascript <<EOF
|
||||
tell application "Mail"
|
||||
set newMessage to make new outgoing message with properties {subject:"$SUBJECT_ESCAPED", content:"$BODY_ESCAPED", visible:false}
|
||||
tell newMessage
|
||||
make new to recipient at end of to recipients with properties {address:"$TO"}
|
||||
end tell
|
||||
send newMessage
|
||||
return "Email sent to $TO"
|
||||
end tell
|
||||
EOF
|
||||
fi
|
||||
@@ -1,132 +0,0 @@
|
||||
---
|
||||
name: apple-shortcuts
|
||||
description: Generate Apple Shortcuts (.shortcut files) and create URL scheme integrations for iOS/macOS automation. Bridge Apple Shortcuts with OpenClaw, Home Assistant, Notion, n8n, and more.
|
||||
metadata: {"version": "1.0.0", "author": "OpenClaw Community", "requires": ["python3"]}
|
||||
---
|
||||
|
||||
# Apple Shortcuts Generator
|
||||
|
||||
Generate custom Apple Shortcuts (.shortcut files) and create URL scheme integrations for seamless iOS/macOS automation.
|
||||
|
||||
## Features
|
||||
|
||||
1. **Generate .shortcut files** - Download and install directly on iPhone/Mac
|
||||
2. **URL Scheme integrations** - Shortcuts that communicate back to OpenClaw
|
||||
3. **Pre-built templates** - Common automations ready to use
|
||||
4. **Custom shortcut builder** - Describe what you want, get a working shortcut
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Generate a Shortcut
|
||||
|
||||
```bash
|
||||
python3 skills/apple-shortcuts/scripts/generate.py \
|
||||
--name "Quick Notion Note" \
|
||||
--type voice-to-notion \
|
||||
--output ~/Downloads/
|
||||
```
|
||||
|
||||
### Create URL Scheme Integration
|
||||
|
||||
```bash
|
||||
python3 skills/apple-shortcuts/scripts/url-scheme.py \
|
||||
--action send-telegram \
|
||||
--message "Hello from Shortcuts!"
|
||||
```
|
||||
|
||||
## Pre-built Templates
|
||||
|
||||
### 1. Voice to Notion
|
||||
Records audio → Transcribes → Adds to Notion inbox
|
||||
|
||||
```bash
|
||||
python3 skills/apple-shortcuts/scripts/generate.py --template voice-to-notion
|
||||
```
|
||||
|
||||
### 2. Quick Expense Logger
|
||||
Amount + Category → Logs to Notion database
|
||||
|
||||
```bash
|
||||
python3 skills/apple-shortcuts/scripts/generate.py --template expense-logger
|
||||
```
|
||||
|
||||
### 3. Home Assistant Scene Trigger
|
||||
One-tap scene activation
|
||||
|
||||
```bash
|
||||
python3 skills/apple-shortcuts/scripts/generate.py --template ha-scene \
|
||||
--scene "Movie Night"
|
||||
```
|
||||
|
||||
### 4. Morning Briefing Trigger
|
||||
Manually trigger your Morning Intelligence Briefing
|
||||
|
||||
```bash
|
||||
python3 skills/apple-shortcuts/scripts/generate.py --template morning-briefing
|
||||
```
|
||||
|
||||
### 5. Send to OpenClaw
|
||||
Send any text/data to OpenClaw via Telegram
|
||||
|
||||
```bash
|
||||
python3 skills/apple-shortcuts/scripts/generate.py --template send-to-openclaw
|
||||
```
|
||||
|
||||
## URL Scheme Reference
|
||||
|
||||
### Open Telegram
|
||||
```
|
||||
shortcuts://run-shortcut?name=Send%20to%20OpenClaw&input=text&text=Hello
|
||||
```
|
||||
|
||||
### Trigger n8n Webhook
|
||||
```
|
||||
https://n8n.kangaroo-eel.ts.net/webhook/trigger-morning-briefing
|
||||
```
|
||||
|
||||
### Call OpenClaw Directly
|
||||
```
|
||||
https://t.me/clawdbot?start=shortcut_<encoded_message>
|
||||
```
|
||||
|
||||
## Custom Shortcuts
|
||||
|
||||
Describe what you want, and I'll generate it:
|
||||
|
||||
**Example:**
|
||||
> "I want a shortcut that takes a photo of a receipt, extracts the total, and logs it to my Notion expenses database with today's date"
|
||||
|
||||
**Result:** Generated .shortcut file ready to install!
|
||||
|
||||
## Installation
|
||||
|
||||
1. Generate the shortcut file
|
||||
2. AirDrop or save to Files app
|
||||
3. Tap the file → "Add Shortcut"
|
||||
4. Done!
|
||||
|
||||
## Advanced: Two-Way Communication
|
||||
|
||||
Shortcuts can send data TO OpenClaw and receive responses:
|
||||
|
||||
### From Shortcut → OpenClaw
|
||||
1. Shortcut collects data (text, photo, location, etc.)
|
||||
2. Sends via Telegram bot API or webhook
|
||||
3. OpenClaw processes and responds
|
||||
|
||||
### From OpenClaw → Shortcut
|
||||
1. OpenClaw generates a shortcut file
|
||||
2. Sends download link via Telegram
|
||||
3. User installs on device
|
||||
|
||||
## Security Notes
|
||||
|
||||
- API keys are embedded in shortcuts (keep them private!)
|
||||
- Use webhook endpoints that don't expose sensitive data
|
||||
- Shortcuts run locally on your device
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**Shortcut won't install:** Check iOS version (requires iOS 14+)
|
||||
**Webhook fails:** Verify URL is accessible from your network
|
||||
**Notion auth fails:** Check API key has correct permissions
|
||||
@@ -1,107 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>WFWorkflowActions</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.ask</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFAskActionAnswerType</key>
|
||||
<string>Number</string>
|
||||
<key>WFAskActionPrompt</key>
|
||||
<string>Amount?</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.choosefromlist</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFChooseFromListActionItems</key>
|
||||
<array>
|
||||
<string>Food</string>
|
||||
<string>Transport</string>
|
||||
<string>Entertainment</string>
|
||||
<string>Shopping</string>
|
||||
<string>Bills</string>
|
||||
</array>
|
||||
<key>WFChooseFromListActionPrompt</key>
|
||||
<string>Category?</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.gettext</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFTextActionText</key>
|
||||
<dict>
|
||||
<key>Value</key>
|
||||
<dict>
|
||||
<key>string</key>
|
||||
<string>Logged: $amount$ for $category$ on $date$</string>
|
||||
</dict>
|
||||
<key>WFSerializationType</key>
|
||||
<string>WFTextTokenString</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.openurl</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFURLActionURL</key>
|
||||
<string>https://t.me/clawdbot?start=expense_</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
<key>WFWorkflowClientRelease</key>
|
||||
<string>4.0</string>
|
||||
<key>WFWorkflowClientVersion</key>
|
||||
<string>1092.0.2</string>
|
||||
<key>WFWorkflowIcon</key>
|
||||
<dict>
|
||||
<key>WFWorkflowIconGlyphNumber</key>
|
||||
<integer>61456</integer>
|
||||
<key>WFWorkflowIconStartColor</key>
|
||||
<integer>4292093695</integer>
|
||||
</dict>
|
||||
<key>WFWorkflowImportQuestions</key>
|
||||
<array/>
|
||||
<key>WFWorkflowInputContentItemClasses</key>
|
||||
<array>
|
||||
<string>WFAppStoreAppContentItem</string>
|
||||
<string>WFArticleContentItem</string>
|
||||
<string>WFContactContentItem</string>
|
||||
<string>WFDateContentItem</string>
|
||||
<string>WFEmailAddressContentItem</string>
|
||||
<string>WFGenericFileContentItem</string>
|
||||
<string>WFImageContentItem</string>
|
||||
<string>WFiTunesProductContentItem</string>
|
||||
<string>WFLocationContentItem</string>
|
||||
<string>WFDCMapsLinkContentItem</string>
|
||||
<string>WFAVAssetContentItem</string>
|
||||
<string>WFPDFContentItem</string>
|
||||
<string>WFPhoneNumberContentItem</string>
|
||||
<string>WFRichTextContentItem</string>
|
||||
<string>WFSafariWebPageContentItem</string>
|
||||
<string>WFStringContentItem</string>
|
||||
<string>WFURLContentItem</string>
|
||||
</array>
|
||||
<key>WFWorkflowMinimumClientVersion</key>
|
||||
<integer>900</integer>
|
||||
<key>WFWorkflowMinimumClientVersionString</key>
|
||||
<string>900</string>
|
||||
<key>WFWorkflowName</key>
|
||||
<string>Quick Expense</string>
|
||||
<key>WFWorkflowTypes</key>
|
||||
<array>
|
||||
<string>NCWidget</string>
|
||||
<string>WatchKit</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,95 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>WFWorkflowActions</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.ask</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFAskActionPrompt</key>
|
||||
<string>Task name?</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.choosefromlist</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFChooseFromListActionItems</key>
|
||||
<array>
|
||||
<string>High</string>
|
||||
<string>Medium</string>
|
||||
<string>Low</string>
|
||||
</array>
|
||||
<key>WFChooseFromListActionPrompt</key>
|
||||
<string>Priority?</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.openurl</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFURLActionURL</key>
|
||||
<string>https://t.me/clawdbot?start=task_</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.showresult</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>Text</key>
|
||||
<string>Task sent to OpenClaw!</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
<key>WFWorkflowClientRelease</key>
|
||||
<string>4.0</string>
|
||||
<key>WFWorkflowClientVersion</key>
|
||||
<string>1092.0.2</string>
|
||||
<key>WFWorkflowIcon</key>
|
||||
<dict>
|
||||
<key>WFWorkflowIconGlyphNumber</key>
|
||||
<integer>61456</integer>
|
||||
<key>WFWorkflowIconStartColor</key>
|
||||
<integer>4292093695</integer>
|
||||
</dict>
|
||||
<key>WFWorkflowImportQuestions</key>
|
||||
<array/>
|
||||
<key>WFWorkflowInputContentItemClasses</key>
|
||||
<array>
|
||||
<string>WFAppStoreAppContentItem</string>
|
||||
<string>WFArticleContentItem</string>
|
||||
<string>WFContactContentItem</string>
|
||||
<string>WFDateContentItem</string>
|
||||
<string>WFEmailAddressContentItem</string>
|
||||
<string>WFGenericFileContentItem</string>
|
||||
<string>WFImageContentItem</string>
|
||||
<string>WFiTunesProductContentItem</string>
|
||||
<string>WFLocationContentItem</string>
|
||||
<string>WFDCMapsLinkContentItem</string>
|
||||
<string>WFAVAssetContentItem</string>
|
||||
<string>WFPDFContentItem</string>
|
||||
<string>WFPhoneNumberContentItem</string>
|
||||
<string>WFRichTextContentItem</string>
|
||||
<string>WFSafariWebPageContentItem</string>
|
||||
<string>WFStringContentItem</string>
|
||||
<string>WFURLContentItem</string>
|
||||
</array>
|
||||
<key>WFWorkflowMinimumClientVersion</key>
|
||||
<integer>900</integer>
|
||||
<key>WFWorkflowMinimumClientVersionString</key>
|
||||
<string>900</string>
|
||||
<key>WFWorkflowName</key>
|
||||
<string>Quick Task to Notion</string>
|
||||
<key>WFWorkflowTypes</key>
|
||||
<array>
|
||||
<string>NCWidget</string>
|
||||
<string>WatchKit</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,105 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>WFWorkflowActions</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.gettext</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFTextActionText</key>
|
||||
<dict>
|
||||
<key>Value</key>
|
||||
<dict>
|
||||
<key>attachmentsByRange</key>
|
||||
<dict>
|
||||
<key>{0, 1}</key>
|
||||
<dict>
|
||||
<key>Aggrandizements</key>
|
||||
<array/>
|
||||
<key>Type</key>
|
||||
<string>Clipboard</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>string</key>
|
||||
<string>$0</string>
|
||||
</dict>
|
||||
<key>WFSerializationType</key>
|
||||
<string>WFTextTokenString</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.urlencode</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.openurl</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFURLActionURL</key>
|
||||
<dict>
|
||||
<key>Value</key>
|
||||
<dict>
|
||||
<key>attachmentsByRange</key>
|
||||
<dict/>
|
||||
<key>string</key>
|
||||
<string>https://t.me/clawdbot?start=shortcut_</string>
|
||||
</dict>
|
||||
<key>WFSerializationType</key>
|
||||
<string>WFTextTokenString</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
<key>WFWorkflowClientRelease</key>
|
||||
<string>4.0</string>
|
||||
<key>WFWorkflowClientVersion</key>
|
||||
<string>1092.0.2</string>
|
||||
<key>WFWorkflowIcon</key>
|
||||
<dict>
|
||||
<key>WFWorkflowIconGlyphNumber</key>
|
||||
<integer>61456</integer>
|
||||
<key>WFWorkflowIconStartColor</key>
|
||||
<integer>4292093695</integer>
|
||||
</dict>
|
||||
<key>WFWorkflowImportQuestions</key>
|
||||
<array/>
|
||||
<key>WFWorkflowInputContentItemClasses</key>
|
||||
<array>
|
||||
<string>WFAppStoreAppContentItem</string>
|
||||
<string>WFArticleContentItem</string>
|
||||
<string>WFContactContentItem</string>
|
||||
<string>WFDateContentItem</string>
|
||||
<string>WFEmailAddressContentItem</string>
|
||||
<string>WFGenericFileContentItem</string>
|
||||
<string>WFImageContentItem</string>
|
||||
<string>WFiTunesProductContentItem</string>
|
||||
<string>WFLocationContentItem</string>
|
||||
<string>WFDCMapsLinkContentItem</string>
|
||||
<string>WFAVAssetContentItem</string>
|
||||
<string>WFPDFContentItem</string>
|
||||
<string>WFPhoneNumberContentItem</string>
|
||||
<string>WFRichTextContentItem</string>
|
||||
<string>WFSafariWebPageContentItem</string>
|
||||
<string>WFStringContentItem</string>
|
||||
<string>WFURLContentItem</string>
|
||||
</array>
|
||||
<key>WFWorkflowMinimumClientVersion</key>
|
||||
<integer>900</integer>
|
||||
<key>WFWorkflowMinimumClientVersionString</key>
|
||||
<string>900</string>
|
||||
<key>WFWorkflowName</key>
|
||||
<string>Send to OpenClaw</string>
|
||||
<key>WFWorkflowTypes</key>
|
||||
<array>
|
||||
<string>NCWidget</string>
|
||||
<string>WatchKit</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,71 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>WFWorkflowActions</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.openurl</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFURLActionURL</key>
|
||||
<string>https://t.me/clawdbot?start=morning_briefing_now</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.showresult</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>Text</key>
|
||||
<string>Morning briefing requested! Check Telegram in a moment.</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
<key>WFWorkflowClientRelease</key>
|
||||
<string>4.0</string>
|
||||
<key>WFWorkflowClientVersion</key>
|
||||
<string>1092.0.2</string>
|
||||
<key>WFWorkflowIcon</key>
|
||||
<dict>
|
||||
<key>WFWorkflowIconGlyphNumber</key>
|
||||
<integer>61456</integer>
|
||||
<key>WFWorkflowIconStartColor</key>
|
||||
<integer>4292093695</integer>
|
||||
</dict>
|
||||
<key>WFWorkflowImportQuestions</key>
|
||||
<array/>
|
||||
<key>WFWorkflowInputContentItemClasses</key>
|
||||
<array>
|
||||
<string>WFAppStoreAppContentItem</string>
|
||||
<string>WFArticleContentItem</string>
|
||||
<string>WFContactContentItem</string>
|
||||
<string>WFDateContentItem</string>
|
||||
<string>WFEmailAddressContentItem</string>
|
||||
<string>WFGenericFileContentItem</string>
|
||||
<string>WFImageContentItem</string>
|
||||
<string>WFiTunesProductContentItem</string>
|
||||
<string>WFLocationContentItem</string>
|
||||
<string>WFDCMapsLinkContentItem</string>
|
||||
<string>WFAVAssetContentItem</string>
|
||||
<string>WFPDFContentItem</string>
|
||||
<string>WFPhoneNumberContentItem</string>
|
||||
<string>WFRichTextContentItem</string>
|
||||
<string>WFSafariWebPageContentItem</string>
|
||||
<string>WFStringContentItem</string>
|
||||
<string>WFURLContentItem</string>
|
||||
</array>
|
||||
<key>WFWorkflowMinimumClientVersion</key>
|
||||
<integer>900</integer>
|
||||
<key>WFWorkflowMinimumClientVersionString</key>
|
||||
<string>900</string>
|
||||
<key>WFWorkflowName</key>
|
||||
<string>Trigger Morning Briefing</string>
|
||||
<key>WFWorkflowTypes</key>
|
||||
<array>
|
||||
<string>NCWidget</string>
|
||||
<string>WatchKit</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 784 B |
Binary file not shown.
|
Before Width: | Height: | Size: 794 B |
Binary file not shown.
|
Before Width: | Height: | Size: 544 B |
Binary file not shown.
|
Before Width: | Height: | Size: 754 B |
@@ -1,47 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
import qrcode
|
||||
from pathlib import Path
|
||||
|
||||
# Create shortcuts directory
|
||||
Path('qr-codes').mkdir(exist_ok=True)
|
||||
|
||||
shortcuts = [
|
||||
{
|
||||
'name': 'Trigger_Morning_Briefing',
|
||||
'url': 'https://t.me/clawdbot?start=morning_briefing_now',
|
||||
'desc': 'Trigger your Morning Intelligence Briefing'
|
||||
},
|
||||
{
|
||||
'name': 'Quick_Task',
|
||||
'url': 'https://t.me/clawdbot?start=task_new_medium',
|
||||
'desc': 'Add task to Notion'
|
||||
},
|
||||
{
|
||||
'name': 'Quick_Expense',
|
||||
'url': 'https://t.me/clawdbot?start=expense_0_general',
|
||||
'desc': 'Log expense'
|
||||
},
|
||||
{
|
||||
'name': 'Send_to_OpenClaw',
|
||||
'url': 'https://t.me/clawdbot',
|
||||
'desc': 'Open chat with OpenClaw'
|
||||
}
|
||||
]
|
||||
|
||||
for s in shortcuts:
|
||||
qr = qrcode.QRCode(
|
||||
version=1,
|
||||
box_size=10,
|
||||
border=5
|
||||
)
|
||||
qr.add_data(s['url'])
|
||||
qr.make(fit=True)
|
||||
|
||||
img = qr.make_image(fill_color='black', back_color='white')
|
||||
img.save(f"qr-codes/{s['name']}.png")
|
||||
print(f"✅ Generated: {s['name']}.png")
|
||||
print(f" URL: {s['url']}")
|
||||
print(f" Desc: {s['desc']}")
|
||||
print()
|
||||
|
||||
print('All QR codes generated in qr-codes/ directory')
|
||||
@@ -1,342 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Apple Shortcuts Generator
|
||||
Generates .shortcut files compatible with iOS/macOS Shortcuts app
|
||||
"""
|
||||
import json
|
||||
import sys
|
||||
import argparse
|
||||
import base64
|
||||
import plistlib
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
|
||||
TEMPLATES = {
|
||||
"voice-to-notion": {
|
||||
"name": "Voice to Notion",
|
||||
"description": "Record voice, transcribe, and add to Notion inbox",
|
||||
"actions": [
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.recordaudio",
|
||||
"WFWorkflowActionParameters": {}
|
||||
},
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.transcribeaudio",
|
||||
"WFWorkflowActionParameters": {}
|
||||
},
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.gettext",
|
||||
"WFWorkflowActionParameters": {
|
||||
"WFTextActionText": "Add to Notion Inbox:"
|
||||
}
|
||||
},
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.openapp",
|
||||
"WFWorkflowActionParameters": {
|
||||
"WFAppIdentifier": "com.philipyoungg.notione"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"expense-logger": {
|
||||
"name": "Quick Expense",
|
||||
"description": "Log expense to Notion database",
|
||||
"actions": [
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.ask",
|
||||
"WFWorkflowActionParameters": {
|
||||
"WFAskActionPrompt": "Amount?",
|
||||
"WFAskActionAnswerType": "Number"
|
||||
}
|
||||
},
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.choosefromlist",
|
||||
"WFWorkflowActionParameters": {
|
||||
"WFChooseFromListActionPrompt": "Category?",
|
||||
"WFChooseFromListActionItems": ["Food", "Transport", "Entertainment", "Shopping", "Bills"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.gettext",
|
||||
"WFWorkflowActionParameters": {
|
||||
"WFTextActionText": {
|
||||
"Value": {
|
||||
"string": "Logged: $amount$ for $category$ on $date$"
|
||||
},
|
||||
"WFSerializationType": "WFTextTokenString"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.openurl",
|
||||
"WFWorkflowActionParameters": {
|
||||
"WFURLActionURL": "https://t.me/clawdbot?start=expense_"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"ha-scene": {
|
||||
"name": "Home Assistant Scene",
|
||||
"description": "Trigger Home Assistant scene",
|
||||
"actions": [
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.openurl",
|
||||
"WFWorkflowActionParameters": {
|
||||
"WFURLActionURL": "https://t.me/clawdbot?start=ha_scene_"
|
||||
}
|
||||
},
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.showresult",
|
||||
"WFWorkflowActionParameters": {
|
||||
"Text": "Scene activated!"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"morning-briefing": {
|
||||
"name": "Trigger Morning Briefing",
|
||||
"description": "Manually trigger your Morning Intelligence Briefing",
|
||||
"actions": [
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.openurl",
|
||||
"WFWorkflowActionParameters": {
|
||||
"WFURLActionURL": "https://t.me/clawdbot?start=morning_briefing_now"
|
||||
}
|
||||
},
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.showresult",
|
||||
"WFWorkflowActionParameters": {
|
||||
"Text": "Morning briefing requested! Check Telegram in a moment."
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"send-to-openclaw": {
|
||||
"name": "Send to OpenClaw",
|
||||
"description": "Send text, clipboard, or input to OpenClaw",
|
||||
"actions": [
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.gettext",
|
||||
"WFWorkflowActionParameters": {
|
||||
"WFTextActionText": {
|
||||
"Value": {
|
||||
"attachmentsByRange": {
|
||||
"{0, 1}": {
|
||||
"Type": "Clipboard",
|
||||
"Aggrandizements": []
|
||||
}
|
||||
},
|
||||
"string": "$0"
|
||||
},
|
||||
"WFSerializationType": "WFTextTokenString"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.urlencode",
|
||||
"WFWorkflowActionParameters": {}
|
||||
},
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.openurl",
|
||||
"WFWorkflowActionParameters": {
|
||||
"WFURLActionURL": {
|
||||
"Value": {
|
||||
"string": "https://t.me/clawdbot?start=shortcut_",
|
||||
"attachmentsByRange": {}
|
||||
},
|
||||
"WFSerializationType": "WFTextTokenString"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"quick-task": {
|
||||
"name": "Quick Task to Notion",
|
||||
"description": "Add a quick task to your Work To-do list",
|
||||
"actions": [
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.ask",
|
||||
"WFWorkflowActionParameters": {
|
||||
"WFAskActionPrompt": "Task name?"
|
||||
}
|
||||
},
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.choosefromlist",
|
||||
"WFWorkflowActionParameters": {
|
||||
"WFChooseFromListActionPrompt": "Priority?",
|
||||
"WFChooseFromListActionItems": ["High", "Medium", "Low"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.openurl",
|
||||
"WFWorkflowActionParameters": {
|
||||
"WFURLActionURL": "https://t.me/clawdbot?start=task_"
|
||||
}
|
||||
},
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.showresult",
|
||||
"WFWorkflowActionParameters": {
|
||||
"Text": "Task sent to OpenClaw!"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"log-to-notion": {
|
||||
"name": "Log to Notion",
|
||||
"description": "Quick log entry to Notion journal/daily notes",
|
||||
"actions": [
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.ask",
|
||||
"WFWorkflowActionParameters": {
|
||||
"WFAskActionPrompt": "What happened?"
|
||||
}
|
||||
},
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.getcurrentdatetime",
|
||||
"WFWorkflowActionParameters": {
|
||||
"WFCurrentDateFormat": "Short"
|
||||
}
|
||||
},
|
||||
{
|
||||
"WFWorkflowActionIdentifier": "is.workflow.actions.openurl",
|
||||
"WFWorkflowActionParameters": {
|
||||
"WFURLActionURL": "https://t.me/clawdbot?start=log_"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
def create_shortcut_json(name, actions, description=""):
|
||||
"""Create the JSON structure for a .shortcut file"""
|
||||
shortcut = {
|
||||
"WFWorkflowClientVersion": "1092.0.2",
|
||||
"WFWorkflowClientRelease": "4.0",
|
||||
"WFWorkflowMinimumClientVersion": 900,
|
||||
"WFWorkflowMinimumClientVersionString": "900",
|
||||
"WFWorkflowIcon": {
|
||||
"WFWorkflowIconStartColor": 4292093695,
|
||||
"WFWorkflowIconGlyphNumber": 61456
|
||||
},
|
||||
"WFWorkflowImportQuestions": [],
|
||||
"WFWorkflowTypes": ["NCWidget", "WatchKit"],
|
||||
"WFWorkflowInputContentItemClasses": [
|
||||
"WFAppStoreAppContentItem",
|
||||
"WFArticleContentItem",
|
||||
"WFContactContentItem",
|
||||
"WFDateContentItem",
|
||||
"WFEmailAddressContentItem",
|
||||
"WFGenericFileContentItem",
|
||||
"WFImageContentItem",
|
||||
"WFiTunesProductContentItem",
|
||||
"WFLocationContentItem",
|
||||
"WFDCMapsLinkContentItem",
|
||||
"WFAVAssetContentItem",
|
||||
"WFPDFContentItem",
|
||||
"WFPhoneNumberContentItem",
|
||||
"WFRichTextContentItem",
|
||||
"WFSafariWebPageContentItem",
|
||||
"WFStringContentItem",
|
||||
"WFURLContentItem"
|
||||
],
|
||||
"WFWorkflowActions": actions,
|
||||
"WFWorkflowName": name
|
||||
}
|
||||
return shortcut
|
||||
|
||||
def generate_shortcut_file(template_name, output_dir="~/Downloads", custom_name=None):
|
||||
"""Generate a .shortcut file from template"""
|
||||
if template_name not in TEMPLATES:
|
||||
print(f"❌ Template '{template_name}' not found!")
|
||||
print(f"Available: {', '.join(TEMPLATES.keys())}")
|
||||
return None
|
||||
|
||||
template = TEMPLATES[template_name]
|
||||
name = custom_name or template["name"]
|
||||
|
||||
shortcut_data = create_shortcut_json(name, template["actions"], template["description"])
|
||||
|
||||
# Create output path
|
||||
output_path = Path(output_dir).expanduser() / f"{name.replace(' ', '_')}.shortcut"
|
||||
|
||||
# Write as plist (binary format that Shortcuts app expects)
|
||||
with open(output_path, 'wb') as f:
|
||||
plistlib.dump(shortcut_data, f)
|
||||
|
||||
print(f"✅ Generated: {output_path}")
|
||||
print(f" Description: {template['description']}")
|
||||
print(f" Actions: {len(template['actions'])}")
|
||||
print(f"\n📱 To install:")
|
||||
print(f" 1. AirDrop to your iPhone/Mac, or")
|
||||
print(f" 2. Open in Files app")
|
||||
print(f" 3. Tap 'Add Shortcut'")
|
||||
|
||||
return output_path
|
||||
|
||||
def list_templates():
|
||||
"""List all available templates"""
|
||||
print("📋 Available Shortcut Templates:")
|
||||
print("=" * 50)
|
||||
for key, template in TEMPLATES.items():
|
||||
print(f"\n🔹 {key}")
|
||||
print(f" Name: {template['name']}")
|
||||
print(f" Description: {template['description']}")
|
||||
print(f" Actions: {len(template['actions'])}")
|
||||
|
||||
def generate_custom_shortcut(description, output_dir="~/Downloads"):
|
||||
"""Generate a custom shortcut based on description"""
|
||||
print(f"🎯 Generating custom shortcut...")
|
||||
print(f" Description: {description}")
|
||||
print()
|
||||
print("⚠️ Custom shortcut generation requires AI processing.")
|
||||
print(" In a full implementation, this would:")
|
||||
print(" 1. Parse your description")
|
||||
print(" 2. Generate appropriate Shortcuts actions")
|
||||
print(" 3. Output a working .shortcut file")
|
||||
print()
|
||||
print(" For now, use --template with one of the pre-built options!")
|
||||
print()
|
||||
list_templates()
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Generate Apple Shortcuts (.shortcut files)")
|
||||
parser.add_argument("--template", "-t", help="Template name to use")
|
||||
parser.add_argument("--list", "-l", action="store_true", help="List available templates")
|
||||
parser.add_argument("--output", "-o", default="~/Downloads", help="Output directory")
|
||||
parser.add_argument("--name", "-n", help="Custom name for the shortcut")
|
||||
parser.add_argument("--custom", "-c", help="Custom description for AI-generated shortcut")
|
||||
parser.add_argument("--scene", "-s", help="Scene name (for ha-scene template)")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.list:
|
||||
list_templates()
|
||||
return
|
||||
|
||||
if args.custom:
|
||||
generate_custom_shortcut(args.custom, args.output)
|
||||
return
|
||||
|
||||
if args.template:
|
||||
# Handle scene parameter for ha-scene template
|
||||
custom_name = args.name
|
||||
if args.template == "ha-scene" and args.scene:
|
||||
custom_name = f"Scene: {args.scene}"
|
||||
|
||||
generate_shortcut_file(args.template, args.output, custom_name)
|
||||
return
|
||||
|
||||
# No arguments - show help
|
||||
parser.print_help()
|
||||
print("\n")
|
||||
list_templates()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,191 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
URL Scheme Integration for Apple Shortcuts
|
||||
Creates URL schemes that Shortcuts can use to communicate with OpenClaw
|
||||
"""
|
||||
import argparse
|
||||
import urllib.parse
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
BASE_URL = "https://t.me/clawdbot"
|
||||
|
||||
def create_url_scheme(action, **params):
|
||||
"""Create a URL scheme for OpenClaw"""
|
||||
|
||||
# Build the start parameter
|
||||
param_str = "_".join([f"{k}:{v}" for k, v in params.items()])
|
||||
start_param = f"{action}_{param_str}"
|
||||
|
||||
# URL encode
|
||||
encoded = urllib.parse.quote(start_param, safe='')
|
||||
|
||||
return f"{BASE_URL}?start={encoded}"
|
||||
|
||||
def create_shortcut_url(name, input_type="text", input_value=""):
|
||||
"""Create a shortcuts:// URL to run a shortcut"""
|
||||
encoded_name = urllib.parse.quote(name, safe='')
|
||||
url = f"shortcuts://run-shortcut?name={encoded_name}"
|
||||
|
||||
if input_type and input_value:
|
||||
encoded_input = urllib.parse.quote(input_value, safe='')
|
||||
url += f"&input={input_type}&text={encoded_input}"
|
||||
|
||||
return url
|
||||
|
||||
def generate_n8n_webhook_url(webhook_id, data=None):
|
||||
"""Generate n8n webhook URL"""
|
||||
base = f"https://n8n.kangaroo-eel.ts.net/webhook/{webhook_id}"
|
||||
if data:
|
||||
params = urllib.parse.urlencode(data)
|
||||
return f"{base}?{params}"
|
||||
return base
|
||||
|
||||
def create_send_to_openclaw_url(message):
|
||||
"""Create URL to send message to OpenClaw via Telegram"""
|
||||
return create_url_scheme("msg", text=message[:100]) # Limit length
|
||||
|
||||
def create_home_assistant_url(entity_id, action="turn_on"):
|
||||
"""Create Home Assistant webhook URL"""
|
||||
return f"http://homeassistant.kangaroo-eel.ts.net:8123/api/webhook/{entity_id}_{action}"
|
||||
|
||||
def list_integrations():
|
||||
"""List available URL scheme integrations"""
|
||||
integrations = {
|
||||
"send-telegram": {
|
||||
"description": "Send text to OpenClaw via Telegram",
|
||||
"url": "https://t.me/clawdbot?start=msg_<text>",
|
||||
"example": "python3 url-scheme.py --action send-telegram --message 'Hello'"
|
||||
},
|
||||
"trigger-morning-briefing": {
|
||||
"description": "Manually trigger Morning Intelligence Briefing",
|
||||
"url": "https://t.me/clawdbot?start=morning_briefing_now",
|
||||
"example": "python3 url-scheme.py --action trigger-morning-briefing"
|
||||
},
|
||||
"log-expense": {
|
||||
"description": "Quick expense log",
|
||||
"url": "https://t.me/clawdbot?start=expense_<amount>_<category>",
|
||||
"example": "python3 url-scheme.py --action log-expense --amount 25.50 --category Food"
|
||||
},
|
||||
"add-task": {
|
||||
"description": "Add task to Notion",
|
||||
"url": "https://t.me/clawdbot?start=task_<name>_<priority>",
|
||||
"example": "python3 url-scheme.py --action add-task --task 'Buy milk' --priority High"
|
||||
},
|
||||
"trigger-n8n": {
|
||||
"description": "Trigger n8n workflow",
|
||||
"url": "https://n8n.kangaroo-eel.ts.net/webhook/<webhook-id>",
|
||||
"example": "python3 url-scheme.py --action trigger-n8n --webhook my-workflow"
|
||||
}
|
||||
}
|
||||
|
||||
print("🔗 Available URL Scheme Integrations:")
|
||||
print("=" * 60)
|
||||
for key, info in integrations.items():
|
||||
print(f"\n🔹 {key}")
|
||||
print(f" {info['description']}")
|
||||
print(f" URL: {info['url']}")
|
||||
print(f" Usage: {info['example']}")
|
||||
|
||||
def generate_qr_code(url, output_file=None):
|
||||
"""Generate QR code for URL (requires qrcode package)"""
|
||||
try:
|
||||
import qrcode
|
||||
qr = qrcode.QRCode(version=1, box_size=10, border=5)
|
||||
qr.add_data(url)
|
||||
qr.make(fit=True)
|
||||
|
||||
img = qr.make_image(fill_color="black", back_color="white")
|
||||
|
||||
if output_file:
|
||||
img.save(output_file)
|
||||
print(f"📱 QR Code saved: {output_file}")
|
||||
else:
|
||||
print(f"📱 QR Code generated for: {url}")
|
||||
print(" (Install 'qrcode' and 'pillow' packages to save as image)")
|
||||
|
||||
except ImportError:
|
||||
print(f"📱 URL: {url}")
|
||||
print(" (Install 'qrcode' package to generate QR codes)")
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="URL Scheme Integration for Apple Shortcuts")
|
||||
parser.add_argument("--action", "-a", help="Action type")
|
||||
parser.add_argument("--message", "-m", help="Message text")
|
||||
parser.add_argument("--amount", help="Expense amount")
|
||||
parser.add_argument("--category", help="Expense category")
|
||||
parser.add_argument("--task", help="Task name")
|
||||
parser.add_argument("--priority", default="Medium", help="Task priority")
|
||||
parser.add_argument("--webhook", help="n8n webhook ID")
|
||||
parser.add_argument("--list", "-l", action="store_true", help="List available integrations")
|
||||
parser.add_argument("--qr", "-q", action="store_true", help="Generate QR code")
|
||||
parser.add_argument("--output", "-o", help="Output file for QR code")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.list:
|
||||
list_integrations()
|
||||
return
|
||||
|
||||
url = None
|
||||
|
||||
if args.action == "send-telegram":
|
||||
if not args.message:
|
||||
print("❌ --message required for send-telegram")
|
||||
return
|
||||
url = create_send_to_openclaw_url(args.message)
|
||||
print(f"📱 URL Scheme created:")
|
||||
print(f" {url}")
|
||||
print(f"\n Use in Shortcuts with 'Open URL' action")
|
||||
|
||||
elif args.action == "trigger-morning-briefing":
|
||||
url = f"{BASE_URL}?start=morning_briefing_now"
|
||||
print(f"📱 Morning Briefing trigger:")
|
||||
print(f" {url}")
|
||||
|
||||
elif args.action == "log-expense":
|
||||
if not args.amount or not args.category:
|
||||
print("❌ --amount and --category required for log-expense")
|
||||
return
|
||||
url = create_url_scheme("expense", amount=args.amount, category=args.category)
|
||||
print(f"📱 Expense logger URL:")
|
||||
print(f" {url}")
|
||||
|
||||
elif args.action == "add-task":
|
||||
if not args.task:
|
||||
print("❌ --task required for add-task")
|
||||
return
|
||||
url = create_url_scheme("task", name=args.task.replace(" ", "_"), priority=args.priority)
|
||||
print(f"📱 Task adder URL:")
|
||||
print(f" {url}")
|
||||
|
||||
elif args.action == "trigger-n8n":
|
||||
if not args.webhook:
|
||||
print("❌ --webhook required for trigger-n8n")
|
||||
return
|
||||
url = generate_n8n_webhook_url(args.webhook)
|
||||
print(f"📱 n8n Webhook URL:")
|
||||
print(f" {url}")
|
||||
|
||||
elif args.action == "run-shortcut":
|
||||
if not args.message:
|
||||
print("❌ --message (shortcut name) required")
|
||||
return
|
||||
url = create_shortcut_url(args.message)
|
||||
print(f"📱 Run Shortcut URL:")
|
||||
print(f" {url}")
|
||||
|
||||
else:
|
||||
print("❌ Unknown action. Use --list to see available options.")
|
||||
list_integrations()
|
||||
return
|
||||
|
||||
# Generate QR code if requested
|
||||
if args.qr and url:
|
||||
generate_qr_code(url, args.output)
|
||||
|
||||
# Copy to clipboard hint
|
||||
print(f"\n💡 Tip: This URL can be used in Shortcuts 'Open URLs' action")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,107 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>WFWorkflowActions</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.ask</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFAskActionAnswerType</key>
|
||||
<string>Number</string>
|
||||
<key>WFAskActionPrompt</key>
|
||||
<string>Amount?</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.choosefromlist</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFChooseFromListActionItems</key>
|
||||
<array>
|
||||
<string>Food</string>
|
||||
<string>Transport</string>
|
||||
<string>Entertainment</string>
|
||||
<string>Shopping</string>
|
||||
<string>Bills</string>
|
||||
</array>
|
||||
<key>WFChooseFromListActionPrompt</key>
|
||||
<string>Category?</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.gettext</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFTextActionText</key>
|
||||
<dict>
|
||||
<key>Value</key>
|
||||
<dict>
|
||||
<key>string</key>
|
||||
<string>Logged: $amount$ for $category$ on $date$</string>
|
||||
</dict>
|
||||
<key>WFSerializationType</key>
|
||||
<string>WFTextTokenString</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.openurl</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFURLActionURL</key>
|
||||
<string>https://t.me/clawdbot?start=expense_</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
<key>WFWorkflowClientRelease</key>
|
||||
<string>4.0</string>
|
||||
<key>WFWorkflowClientVersion</key>
|
||||
<string>1092.0.2</string>
|
||||
<key>WFWorkflowIcon</key>
|
||||
<dict>
|
||||
<key>WFWorkflowIconGlyphNumber</key>
|
||||
<integer>61456</integer>
|
||||
<key>WFWorkflowIconStartColor</key>
|
||||
<integer>4292093695</integer>
|
||||
</dict>
|
||||
<key>WFWorkflowImportQuestions</key>
|
||||
<array/>
|
||||
<key>WFWorkflowInputContentItemClasses</key>
|
||||
<array>
|
||||
<string>WFAppStoreAppContentItem</string>
|
||||
<string>WFArticleContentItem</string>
|
||||
<string>WFContactContentItem</string>
|
||||
<string>WFDateContentItem</string>
|
||||
<string>WFEmailAddressContentItem</string>
|
||||
<string>WFGenericFileContentItem</string>
|
||||
<string>WFImageContentItem</string>
|
||||
<string>WFiTunesProductContentItem</string>
|
||||
<string>WFLocationContentItem</string>
|
||||
<string>WFDCMapsLinkContentItem</string>
|
||||
<string>WFAVAssetContentItem</string>
|
||||
<string>WFPDFContentItem</string>
|
||||
<string>WFPhoneNumberContentItem</string>
|
||||
<string>WFRichTextContentItem</string>
|
||||
<string>WFSafariWebPageContentItem</string>
|
||||
<string>WFStringContentItem</string>
|
||||
<string>WFURLContentItem</string>
|
||||
</array>
|
||||
<key>WFWorkflowMinimumClientVersion</key>
|
||||
<integer>900</integer>
|
||||
<key>WFWorkflowMinimumClientVersionString</key>
|
||||
<string>900</string>
|
||||
<key>WFWorkflowName</key>
|
||||
<string>Quick Expense</string>
|
||||
<key>WFWorkflowTypes</key>
|
||||
<array>
|
||||
<string>NCWidget</string>
|
||||
<string>WatchKit</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,95 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>WFWorkflowActions</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.ask</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFAskActionPrompt</key>
|
||||
<string>Task name?</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.choosefromlist</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFChooseFromListActionItems</key>
|
||||
<array>
|
||||
<string>High</string>
|
||||
<string>Medium</string>
|
||||
<string>Low</string>
|
||||
</array>
|
||||
<key>WFChooseFromListActionPrompt</key>
|
||||
<string>Priority?</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.openurl</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFURLActionURL</key>
|
||||
<string>https://t.me/clawdbot?start=task_</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.showresult</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>Text</key>
|
||||
<string>Task sent to OpenClaw!</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
<key>WFWorkflowClientRelease</key>
|
||||
<string>4.0</string>
|
||||
<key>WFWorkflowClientVersion</key>
|
||||
<string>1092.0.2</string>
|
||||
<key>WFWorkflowIcon</key>
|
||||
<dict>
|
||||
<key>WFWorkflowIconGlyphNumber</key>
|
||||
<integer>61456</integer>
|
||||
<key>WFWorkflowIconStartColor</key>
|
||||
<integer>4292093695</integer>
|
||||
</dict>
|
||||
<key>WFWorkflowImportQuestions</key>
|
||||
<array/>
|
||||
<key>WFWorkflowInputContentItemClasses</key>
|
||||
<array>
|
||||
<string>WFAppStoreAppContentItem</string>
|
||||
<string>WFArticleContentItem</string>
|
||||
<string>WFContactContentItem</string>
|
||||
<string>WFDateContentItem</string>
|
||||
<string>WFEmailAddressContentItem</string>
|
||||
<string>WFGenericFileContentItem</string>
|
||||
<string>WFImageContentItem</string>
|
||||
<string>WFiTunesProductContentItem</string>
|
||||
<string>WFLocationContentItem</string>
|
||||
<string>WFDCMapsLinkContentItem</string>
|
||||
<string>WFAVAssetContentItem</string>
|
||||
<string>WFPDFContentItem</string>
|
||||
<string>WFPhoneNumberContentItem</string>
|
||||
<string>WFRichTextContentItem</string>
|
||||
<string>WFSafariWebPageContentItem</string>
|
||||
<string>WFStringContentItem</string>
|
||||
<string>WFURLContentItem</string>
|
||||
</array>
|
||||
<key>WFWorkflowMinimumClientVersion</key>
|
||||
<integer>900</integer>
|
||||
<key>WFWorkflowMinimumClientVersionString</key>
|
||||
<string>900</string>
|
||||
<key>WFWorkflowName</key>
|
||||
<string>Quick Task to Notion</string>
|
||||
<key>WFWorkflowTypes</key>
|
||||
<array>
|
||||
<string>NCWidget</string>
|
||||
<string>WatchKit</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,105 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>WFWorkflowActions</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.gettext</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFTextActionText</key>
|
||||
<dict>
|
||||
<key>Value</key>
|
||||
<dict>
|
||||
<key>attachmentsByRange</key>
|
||||
<dict>
|
||||
<key>{0, 1}</key>
|
||||
<dict>
|
||||
<key>Aggrandizements</key>
|
||||
<array/>
|
||||
<key>Type</key>
|
||||
<string>Clipboard</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>string</key>
|
||||
<string>$0</string>
|
||||
</dict>
|
||||
<key>WFSerializationType</key>
|
||||
<string>WFTextTokenString</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.urlencode</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.openurl</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFURLActionURL</key>
|
||||
<dict>
|
||||
<key>Value</key>
|
||||
<dict>
|
||||
<key>attachmentsByRange</key>
|
||||
<dict/>
|
||||
<key>string</key>
|
||||
<string>https://t.me/clawdbot?start=shortcut_</string>
|
||||
</dict>
|
||||
<key>WFSerializationType</key>
|
||||
<string>WFTextTokenString</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
<key>WFWorkflowClientRelease</key>
|
||||
<string>4.0</string>
|
||||
<key>WFWorkflowClientVersion</key>
|
||||
<string>1092.0.2</string>
|
||||
<key>WFWorkflowIcon</key>
|
||||
<dict>
|
||||
<key>WFWorkflowIconGlyphNumber</key>
|
||||
<integer>61456</integer>
|
||||
<key>WFWorkflowIconStartColor</key>
|
||||
<integer>4292093695</integer>
|
||||
</dict>
|
||||
<key>WFWorkflowImportQuestions</key>
|
||||
<array/>
|
||||
<key>WFWorkflowInputContentItemClasses</key>
|
||||
<array>
|
||||
<string>WFAppStoreAppContentItem</string>
|
||||
<string>WFArticleContentItem</string>
|
||||
<string>WFContactContentItem</string>
|
||||
<string>WFDateContentItem</string>
|
||||
<string>WFEmailAddressContentItem</string>
|
||||
<string>WFGenericFileContentItem</string>
|
||||
<string>WFImageContentItem</string>
|
||||
<string>WFiTunesProductContentItem</string>
|
||||
<string>WFLocationContentItem</string>
|
||||
<string>WFDCMapsLinkContentItem</string>
|
||||
<string>WFAVAssetContentItem</string>
|
||||
<string>WFPDFContentItem</string>
|
||||
<string>WFPhoneNumberContentItem</string>
|
||||
<string>WFRichTextContentItem</string>
|
||||
<string>WFSafariWebPageContentItem</string>
|
||||
<string>WFStringContentItem</string>
|
||||
<string>WFURLContentItem</string>
|
||||
</array>
|
||||
<key>WFWorkflowMinimumClientVersion</key>
|
||||
<integer>900</integer>
|
||||
<key>WFWorkflowMinimumClientVersionString</key>
|
||||
<string>900</string>
|
||||
<key>WFWorkflowName</key>
|
||||
<string>Send to OpenClaw</string>
|
||||
<key>WFWorkflowTypes</key>
|
||||
<array>
|
||||
<string>NCWidget</string>
|
||||
<string>WatchKit</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,71 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>WFWorkflowActions</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.openurl</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>WFURLActionURL</key>
|
||||
<string>https://t.me/clawdbot?start=morning_briefing_now</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>WFWorkflowActionIdentifier</key>
|
||||
<string>is.workflow.actions.showresult</string>
|
||||
<key>WFWorkflowActionParameters</key>
|
||||
<dict>
|
||||
<key>Text</key>
|
||||
<string>Morning briefing requested! Check Telegram in a moment.</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
<key>WFWorkflowClientRelease</key>
|
||||
<string>4.0</string>
|
||||
<key>WFWorkflowClientVersion</key>
|
||||
<string>1092.0.2</string>
|
||||
<key>WFWorkflowIcon</key>
|
||||
<dict>
|
||||
<key>WFWorkflowIconGlyphNumber</key>
|
||||
<integer>61456</integer>
|
||||
<key>WFWorkflowIconStartColor</key>
|
||||
<integer>4292093695</integer>
|
||||
</dict>
|
||||
<key>WFWorkflowImportQuestions</key>
|
||||
<array/>
|
||||
<key>WFWorkflowInputContentItemClasses</key>
|
||||
<array>
|
||||
<string>WFAppStoreAppContentItem</string>
|
||||
<string>WFArticleContentItem</string>
|
||||
<string>WFContactContentItem</string>
|
||||
<string>WFDateContentItem</string>
|
||||
<string>WFEmailAddressContentItem</string>
|
||||
<string>WFGenericFileContentItem</string>
|
||||
<string>WFImageContentItem</string>
|
||||
<string>WFiTunesProductContentItem</string>
|
||||
<string>WFLocationContentItem</string>
|
||||
<string>WFDCMapsLinkContentItem</string>
|
||||
<string>WFAVAssetContentItem</string>
|
||||
<string>WFPDFContentItem</string>
|
||||
<string>WFPhoneNumberContentItem</string>
|
||||
<string>WFRichTextContentItem</string>
|
||||
<string>WFSafariWebPageContentItem</string>
|
||||
<string>WFStringContentItem</string>
|
||||
<string>WFURLContentItem</string>
|
||||
</array>
|
||||
<key>WFWorkflowMinimumClientVersion</key>
|
||||
<integer>900</integer>
|
||||
<key>WFWorkflowMinimumClientVersionString</key>
|
||||
<string>900</string>
|
||||
<key>WFWorkflowName</key>
|
||||
<string>Trigger Morning Briefing</string>
|
||||
<key>WFWorkflowTypes</key>
|
||||
<array>
|
||||
<string>NCWidget</string>
|
||||
<string>WatchKit</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
name: app-builder
|
||||
description: Main application building orchestrator. Creates full-stack applications from natural language requests. Determines project type, selects tech stack, coordinates agents.
|
||||
allowed-tools: Read, Write, Edit, Glob, Grep, Bash, Agent
|
||||
---
|
||||
|
||||
# App Builder - Application Building Orchestrator
|
||||
|
||||
> Analyzes user's requests, determines tech stack, plans structure, and coordinates agents.
|
||||
|
||||
## 🎯 Selective Reading Rule
|
||||
|
||||
**Read ONLY files relevant to the request!** Check the content map, find what you need.
|
||||
|
||||
| File | Description | When to Read |
|
||||
|------|-------------|--------------|
|
||||
| `project-detection.md` | Keyword matrix, project type detection | Starting new project |
|
||||
| `tech-stack.md` | 2025 default stack, alternatives | Choosing technologies |
|
||||
| `agent-coordination.md` | Agent pipeline, execution order | Coordinating multi-agent work |
|
||||
| `scaffolding.md` | Directory structure, core files | Creating project structure |
|
||||
| `feature-building.md` | Feature analysis, error handling | Adding features to existing project |
|
||||
| `templates/SKILL.md` | **Project templates** | Scaffolding new project |
|
||||
|
||||
---
|
||||
|
||||
## 📦 Templates (13)
|
||||
|
||||
Quick-start scaffolding for new projects. **Read the matching template only!**
|
||||
|
||||
| Template | Tech Stack | When to Use |
|
||||
|----------|------------|-------------|
|
||||
| [nextjs-fullstack](templates/nextjs-fullstack/TEMPLATE.md) | Next.js + Prisma | Full-stack web app |
|
||||
| [nextjs-saas](templates/nextjs-saas/TEMPLATE.md) | Next.js + Stripe | SaaS product |
|
||||
| [nextjs-static](templates/nextjs-static/TEMPLATE.md) | Next.js + Framer | Landing page |
|
||||
| [nuxt-app](templates/nuxt-app/TEMPLATE.md) | Nuxt 3 + Pinia | Vue full-stack app |
|
||||
| [express-api](templates/express-api/TEMPLATE.md) | Express + JWT | REST API |
|
||||
| [python-fastapi](templates/python-fastapi/TEMPLATE.md) | FastAPI | Python API |
|
||||
| [react-native-app](templates/react-native-app/TEMPLATE.md) | Expo + Zustand | Mobile app |
|
||||
| [flutter-app](templates/flutter-app/TEMPLATE.md) | Flutter + Riverpod | Cross-platform mobile |
|
||||
| [electron-desktop](templates/electron-desktop/TEMPLATE.md) | Electron + React | Desktop app |
|
||||
| [chrome-extension](templates/chrome-extension/TEMPLATE.md) | Chrome MV3 | Browser extension |
|
||||
| [cli-tool](templates/cli-tool/TEMPLATE.md) | Node.js + Commander | CLI app |
|
||||
| [monorepo-turborepo](templates/monorepo-turborepo/TEMPLATE.md) | Turborepo + pnpm | Monorepo |
|
||||
|
||||
---
|
||||
|
||||
## 🔗 Related Agents
|
||||
|
||||
| Agent | Role |
|
||||
|-------|------|
|
||||
| `project-planner` | Task breakdown, dependency graph |
|
||||
| `frontend-specialist` | UI components, pages |
|
||||
| `backend-specialist` | API, business logic |
|
||||
| `database-architect` | Schema, migrations |
|
||||
| `devops-engineer` | Deployment, preview |
|
||||
|
||||
---
|
||||
|
||||
## Usage Example
|
||||
|
||||
```
|
||||
User: "Make an Instagram clone with photo sharing and likes"
|
||||
|
||||
App Builder Process:
|
||||
1. Project type: Social Media App
|
||||
2. Tech stack: Next.js + Prisma + Cloudinary + Clerk
|
||||
3. Create plan:
|
||||
├─ Database schema (users, posts, likes, follows)
|
||||
├─ API routes (12 endpoints)
|
||||
├─ Pages (feed, profile, upload)
|
||||
└─ Components (PostCard, Feed, LikeButton)
|
||||
4. Coordinate agents
|
||||
5. Report progress
|
||||
6. Start preview
|
||||
```
|
||||
Binary file not shown.
@@ -0,0 +1,71 @@
|
||||
# Agent Coordination
|
||||
|
||||
> How App Builder orchestrates specialist agents.
|
||||
|
||||
## Agent Pipeline
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ APP BUILDER (Orchestrator) │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ PROJECT PLANNER │
|
||||
│ • Task breakdown │
|
||||
│ • Dependency graph │
|
||||
│ • File structure planning │
|
||||
│ • Create {task-slug}.md in project root (MANDATORY) │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ CHECKPOINT: PLAN VERIFICATION │
|
||||
│ 🔴 VERIFY: Does {task-slug}.md exist in project root? │
|
||||
│ 🔴 If NO → STOP → Create plan file first │
|
||||
│ 🔴 If YES → Proceed to specialist agents │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
┌───────────────────┼───────────────────┐
|
||||
▼ ▼ ▼
|
||||
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
|
||||
│ DATABASE │ │ BACKEND │ │ FRONTEND │
|
||||
│ ARCHITECT │ │ SPECIALIST │ │ SPECIALIST │
|
||||
│ │ │ │ │ │
|
||||
│ • Schema design │ │ • API routes │ │ • Components │
|
||||
│ • Migrations │ │ • Controllers │ │ • Pages │
|
||||
│ • Seed data │ │ • Middleware │ │ • Styling │
|
||||
└─────────────────┘ └─────────────────┘ └─────────────────┘
|
||||
│ │ │
|
||||
└───────────────────┼───────────────────┘
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ PARALLEL PHASE (Optional) │
|
||||
│ • Security Auditor → Vulnerability check │
|
||||
│ • Test Engineer → Unit tests │
|
||||
│ • Performance Optimizer → Bundle analysis │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ DEVOPS ENGINEER │
|
||||
│ • Environment setup │
|
||||
│ • Preview deployment │
|
||||
│ • Health check │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Execution Order
|
||||
|
||||
| Phase | Agent(s) | Parallel? | Prerequisite | CHECKPOINT |
|
||||
|-------|----------|-----------|--------------|------------|
|
||||
| 0 | Socratic Gate | ❌ | - | ✅ Ask 3 questions |
|
||||
| 1 | Project Planner | ❌ | Questions answered | ✅ **PLAN.md created** |
|
||||
| 1.5 | **PLAN VERIFICATION** | ❌ | PLAN.md exists | ✅ **File exists in root** |
|
||||
| 2 | Database Architect | ❌ | Plan ready | Schema defined |
|
||||
| 3 | Backend Specialist | ❌ | Schema ready | API routes created |
|
||||
| 4 | Frontend Specialist | ✅ | API ready (partial) | UI components ready |
|
||||
| 5 | Security Auditor, Test Engineer | ✅ | Code ready | Tests & audit pass |
|
||||
| 6 | DevOps Engineer | ❌ | All code ready | Deployment ready |
|
||||
|
||||
> 🔴 **CRITICAL:** Phase 1.5 is MANDATORY. No specialist agents proceed without PLAN.md verification.
|
||||
Binary file not shown.
@@ -0,0 +1,53 @@
|
||||
# Feature Building
|
||||
|
||||
> How to analyze and implement new features.
|
||||
|
||||
## Feature Analysis
|
||||
|
||||
```
|
||||
Request: "add payment system"
|
||||
|
||||
Analysis:
|
||||
├── Required Changes:
|
||||
│ ├── Database: orders, payments tables
|
||||
│ ├── Backend: /api/checkout, /api/webhooks/stripe
|
||||
│ ├── Frontend: CheckoutForm, PaymentSuccess
|
||||
│ └── Config: Stripe API keys
|
||||
│
|
||||
├── Dependencies:
|
||||
│ ├── stripe package
|
||||
│ └── Existing user authentication
|
||||
│
|
||||
└── Estimated Time: 15-20 minutes
|
||||
```
|
||||
|
||||
## Iterative Enhancement Process
|
||||
|
||||
```
|
||||
1. Analyze existing project
|
||||
2. Create change plan
|
||||
3. Present plan to user
|
||||
4. Get approval
|
||||
5. Apply changes
|
||||
6. Test
|
||||
7. Show preview
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error Type | Solution Strategy |
|
||||
|------------|-------------------|
|
||||
| TypeScript Error | Fix type, add missing import |
|
||||
| Missing Dependency | Run npm install |
|
||||
| Port Conflict | Suggest alternative port |
|
||||
| Database Error | Check migration, validate connection |
|
||||
|
||||
## Recovery Strategy
|
||||
|
||||
```
|
||||
1. Detect error
|
||||
2. Try automatic fix
|
||||
3. If failed, report to user
|
||||
4. Suggest alternative
|
||||
5. Rollback if necessary
|
||||
```
|
||||
Binary file not shown.
@@ -0,0 +1,34 @@
|
||||
# Project Type Detection
|
||||
|
||||
> Analyze user requests to determine project type and template.
|
||||
|
||||
## Keyword Matrix
|
||||
|
||||
| Keywords | Project Type | Template |
|
||||
|----------|--------------|----------|
|
||||
| blog, post, article | Blog | astro-static |
|
||||
| e-commerce, product, cart, payment | E-commerce | nextjs-saas |
|
||||
| dashboard, panel, management | Admin Dashboard | nextjs-fullstack |
|
||||
| api, backend, service, rest | API Service | express-api |
|
||||
| python, fastapi, django | Python API | python-fastapi |
|
||||
| mobile, android, ios, react native | Mobile App (RN) | react-native-app |
|
||||
| flutter, dart | Mobile App (Flutter) | flutter-app |
|
||||
| portfolio, personal, cv | Portfolio | nextjs-static |
|
||||
| crm, customer, sales | CRM | nextjs-fullstack |
|
||||
| saas, subscription, stripe | SaaS | nextjs-saas |
|
||||
| landing, promotional, marketing | Landing Page | nextjs-static |
|
||||
| docs, documentation | Documentation | astro-static |
|
||||
| extension, plugin, chrome | Browser Extension | chrome-extension |
|
||||
| desktop, electron | Desktop App | electron-desktop |
|
||||
| cli, command line, terminal | CLI Tool | cli-tool |
|
||||
| monorepo, workspace | Monorepo | monorepo-turborepo |
|
||||
|
||||
## Detection Process
|
||||
|
||||
```
|
||||
1. Tokenize user request
|
||||
2. Extract keywords
|
||||
3. Determine project type
|
||||
4. Detect missing information → forward to conversation-manager
|
||||
5. Suggest tech stack
|
||||
```
|
||||
Binary file not shown.
@@ -0,0 +1,118 @@
|
||||
# Project Scaffolding
|
||||
|
||||
> Directory structure and core files for new projects.
|
||||
|
||||
---
|
||||
|
||||
## Next.js Full-Stack Structure (2025 Optimized)
|
||||
|
||||
```
|
||||
project-name/
|
||||
├── src/
|
||||
│ ├── app/ # Routes only (thin layer)
|
||||
│ │ ├── layout.tsx
|
||||
│ │ ├── page.tsx
|
||||
│ │ ├── globals.css
|
||||
│ │ ├── (auth)/ # Route group - auth pages
|
||||
│ │ │ ├── login/page.tsx
|
||||
│ │ │ └── register/page.tsx
|
||||
│ │ ├── (dashboard)/ # Route group - dashboard layout
|
||||
│ │ │ ├── layout.tsx
|
||||
│ │ │ └── page.tsx
|
||||
│ │ └── api/
|
||||
│ │ └── [resource]/route.ts
|
||||
│ │
|
||||
│ ├── features/ # Feature-based modules
|
||||
│ │ ├── auth/
|
||||
│ │ │ ├── components/
|
||||
│ │ │ ├── hooks/
|
||||
│ │ │ ├── actions.ts # Server Actions
|
||||
│ │ │ ├── queries.ts # Data fetching
|
||||
│ │ │ └── types.ts
|
||||
│ │ ├── products/
|
||||
│ │ │ ├── components/
|
||||
│ │ │ ├── actions.ts
|
||||
│ │ │ └── queries.ts
|
||||
│ │ └── cart/
|
||||
│ │ └── ...
|
||||
│ │
|
||||
│ ├── shared/ # Shared utilities
|
||||
│ │ ├── components/ui/ # Reusable UI components
|
||||
│ │ ├── lib/ # Utils, helpers
|
||||
│ │ └── hooks/ # Global hooks
|
||||
│ │
|
||||
│ └── server/ # Server-only code
|
||||
│ ├── db/ # Database client (Prisma)
|
||||
│ ├── auth/ # Auth config
|
||||
│ └── services/ # External API integrations
|
||||
│
|
||||
├── prisma/
|
||||
│ ├── schema.prisma
|
||||
│ ├── migrations/
|
||||
│ └── seed.ts
|
||||
│
|
||||
├── public/
|
||||
├── .env.example
|
||||
├── .env.local
|
||||
├── package.json
|
||||
├── tailwind.config.ts
|
||||
├── tsconfig.json
|
||||
└── README.md
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Structure Principles
|
||||
|
||||
| Principle | Implementation |
|
||||
|-----------|----------------|
|
||||
| **Feature isolation** | Each feature in `features/` with its own components, hooks, actions |
|
||||
| **Server/Client separation** | Server-only code in `server/`, prevents accidental client imports |
|
||||
| **Thin routes** | `app/` only for routing, logic lives in `features/` |
|
||||
| **Route groups** | `(groupName)/` for layout sharing without URL impact |
|
||||
| **Shared code** | `shared/` for truly reusable UI and utilities |
|
||||
|
||||
---
|
||||
|
||||
## Core Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `package.json` | Dependencies |
|
||||
| `tsconfig.json` | TypeScript + path aliases (`@/features/*`) |
|
||||
| `tailwind.config.ts` | Tailwind config |
|
||||
| `.env.example` | Environment template |
|
||||
| `README.md` | Project documentation |
|
||||
| `.gitignore` | Git ignore rules |
|
||||
| `prisma/schema.prisma` | Database schema |
|
||||
|
||||
---
|
||||
|
||||
## Path Aliases (tsconfig.json)
|
||||
|
||||
```json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"@/*": ["./src/*"],
|
||||
"@/features/*": ["./src/features/*"],
|
||||
"@/shared/*": ["./src/shared/*"],
|
||||
"@/server/*": ["./src/server/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## When to Use What
|
||||
|
||||
| Need | Location |
|
||||
|------|----------|
|
||||
| New page/route | `app/(group)/page.tsx` |
|
||||
| Feature component | `features/[name]/components/` |
|
||||
| Server action | `features/[name]/actions.ts` |
|
||||
| Data fetching | `features/[name]/queries.ts` |
|
||||
| Reusable button/input | `shared/components/ui/` |
|
||||
| Database query | `server/db/` |
|
||||
| External API call | `server/services/` |
|
||||
Binary file not shown.
@@ -0,0 +1,40 @@
|
||||
# Tech Stack Selection (2025)
|
||||
|
||||
> Default and alternative technology choices for web applications.
|
||||
|
||||
## Default Stack (Web App - 2025)
|
||||
|
||||
```yaml
|
||||
Frontend:
|
||||
framework: Next.js 16 (Stable)
|
||||
language: TypeScript 5.7+
|
||||
styling: Tailwind CSS v4
|
||||
state: React 19 Actions / Server Components
|
||||
bundler: Turbopack (Stable for Dev)
|
||||
|
||||
Backend:
|
||||
runtime: Node.js 23
|
||||
framework: Next.js API Routes / Hono (for Edge)
|
||||
validation: Zod / TypeBox
|
||||
|
||||
Database:
|
||||
primary: PostgreSQL
|
||||
orm: Prisma / Drizzle
|
||||
hosting: Supabase / Neon
|
||||
|
||||
Auth:
|
||||
provider: Auth.js (v5) / Clerk
|
||||
|
||||
Monorepo:
|
||||
tool: Turborepo 2.0
|
||||
```
|
||||
|
||||
## Alternative Options
|
||||
|
||||
| Need | Default | Alternative |
|
||||
|------|---------|-------------|
|
||||
| Real-time | - | Supabase Realtime, Socket.io |
|
||||
| File storage | - | Cloudinary, S3 |
|
||||
| Payment | Stripe | LemonSqueezy, Paddle |
|
||||
| Email | - | Resend, SendGrid |
|
||||
| Search | - | Algolia, Typesense |
|
||||
Binary file not shown.
@@ -0,0 +1,39 @@
|
||||
---
|
||||
name: templates
|
||||
description: Project scaffolding templates for new applications. Use when creating new projects from scratch. Contains 12 templates for various tech stacks.
|
||||
allowed-tools: Read, Glob, Grep
|
||||
---
|
||||
|
||||
# Project Templates
|
||||
|
||||
> Quick-start templates for scaffolding new projects.
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Selective Reading Rule
|
||||
|
||||
**Read ONLY the template matching user's project type!**
|
||||
|
||||
| Template | Tech Stack | When to Use |
|
||||
|----------|------------|-------------|
|
||||
| [nextjs-fullstack](nextjs-fullstack/TEMPLATE.md) | Next.js + Prisma | Full-stack web app |
|
||||
| [nextjs-saas](nextjs-saas/TEMPLATE.md) | Next.js + Stripe | SaaS product |
|
||||
| [nextjs-static](nextjs-static/TEMPLATE.md) | Next.js + Framer | Landing page |
|
||||
| [express-api](express-api/TEMPLATE.md) | Express + JWT | REST API |
|
||||
| [python-fastapi](python-fastapi/TEMPLATE.md) | FastAPI | Python API |
|
||||
| [react-native-app](react-native-app/TEMPLATE.md) | Expo + Zustand | Mobile app |
|
||||
| [flutter-app](flutter-app/TEMPLATE.md) | Flutter + Riverpod | Cross-platform |
|
||||
| [electron-desktop](electron-desktop/TEMPLATE.md) | Electron + React | Desktop app |
|
||||
| [chrome-extension](chrome-extension/TEMPLATE.md) | Chrome MV3 | Browser extension |
|
||||
| [cli-tool](cli-tool/TEMPLATE.md) | Node.js + Commander | CLI app |
|
||||
| [monorepo-turborepo](monorepo-turborepo/TEMPLATE.md) | Turborepo + pnpm | Monorepo |
|
||||
| [astro-static](astro-static/TEMPLATE.md) | Astro + MDX | Blog / Docs |
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
1. User says "create [type] app"
|
||||
2. Match to appropriate template
|
||||
3. Read ONLY that template's TEMPLATE.md
|
||||
4. Follow its tech stack and structure
|
||||
Binary file not shown.
@@ -0,0 +1,76 @@
|
||||
---
|
||||
name: astro-static
|
||||
description: Astro static site template principles. Content-focused websites, blogs, documentation.
|
||||
---
|
||||
|
||||
# Astro Static Site Template
|
||||
|
||||
## Tech Stack
|
||||
|
||||
| Component | Technology |
|
||||
|-----------|------------|
|
||||
| Framework | Astro 4.x |
|
||||
| Content | MDX + Content Collections |
|
||||
| Styling | Tailwind CSS |
|
||||
| Integrations | Sitemap, RSS, SEO |
|
||||
| Output | Static/SSG |
|
||||
|
||||
---
|
||||
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
project-name/
|
||||
├── src/
|
||||
│ ├── components/ # .astro components
|
||||
│ ├── content/ # MDX content
|
||||
│ │ ├── blog/
|
||||
│ │ └── config.ts # Collection schemas
|
||||
│ ├── layouts/ # Page layouts
|
||||
│ ├── pages/ # File-based routing
|
||||
│ └── styles/
|
||||
├── public/ # Static assets
|
||||
├── astro.config.mjs
|
||||
└── package.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Key Concepts
|
||||
|
||||
| Concept | Description |
|
||||
|---------|-------------|
|
||||
| Content Collections | Type-safe content with Zod schemas |
|
||||
| Islands Architecture | Partial hydration for interactivity |
|
||||
| Zero JS by default | Static HTML unless needed |
|
||||
| MDX Support | Markdown with components |
|
||||
|
||||
---
|
||||
|
||||
## Setup Steps
|
||||
|
||||
1. `npm create astro@latest {{name}}`
|
||||
2. Add integrations: `npx astro add mdx tailwind sitemap`
|
||||
3. Configure `astro.config.mjs`
|
||||
4. Create content collections
|
||||
5. `npm run dev`
|
||||
|
||||
---
|
||||
|
||||
## Deployment
|
||||
|
||||
| Platform | Method |
|
||||
|----------|--------|
|
||||
| Vercel | Auto-detected |
|
||||
| Netlify | Auto-detected |
|
||||
| Cloudflare Pages | Auto-detected |
|
||||
| GitHub Pages | Build + deploy action |
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Use Content Collections for type safety
|
||||
- Leverage static generation
|
||||
- Add islands only where needed
|
||||
- Optimize images with Astro Image
|
||||
Binary file not shown.
@@ -0,0 +1,92 @@
|
||||
---
|
||||
name: chrome-extension
|
||||
description: Chrome Extension template principles. Manifest V3, React, TypeScript.
|
||||
---
|
||||
|
||||
# Chrome Extension Template
|
||||
|
||||
## Tech Stack
|
||||
|
||||
| Component | Technology |
|
||||
|-----------|------------|
|
||||
| Manifest | V3 |
|
||||
| UI | React 18 |
|
||||
| Language | TypeScript |
|
||||
| Styling | Tailwind CSS |
|
||||
| Bundler | Vite |
|
||||
| Storage | Chrome Storage API |
|
||||
|
||||
---
|
||||
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
project-name/
|
||||
├── src/
|
||||
│ ├── popup/ # Extension popup
|
||||
│ ├── options/ # Options page
|
||||
│ ├── background/ # Service worker
|
||||
│ ├── content/ # Content scripts
|
||||
│ ├── components/
|
||||
│ ├── hooks/
|
||||
│ └── lib/
|
||||
│ ├── storage.ts # Chrome storage helpers
|
||||
│ └── messaging.ts # Message passing
|
||||
├── public/
|
||||
│ ├── icons/
|
||||
│ └── manifest.json
|
||||
└── package.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Manifest V3 Concepts
|
||||
|
||||
| Component | Purpose |
|
||||
|-----------|---------|
|
||||
| Service Worker | Background processing |
|
||||
| Content Scripts | Page injection |
|
||||
| Popup | User interface |
|
||||
| Options Page | Settings |
|
||||
|
||||
---
|
||||
|
||||
## Permissions
|
||||
|
||||
| Permission | Use |
|
||||
|------------|-----|
|
||||
| storage | Save user data |
|
||||
| activeTab | Current tab access |
|
||||
| scripting | Inject scripts |
|
||||
| host_permissions | Site access |
|
||||
|
||||
---
|
||||
|
||||
## Setup Steps
|
||||
|
||||
1. `npm create vite {{name}} -- --template react-ts`
|
||||
2. Add Chrome types: `npm install -D @types/chrome`
|
||||
3. Configure Vite for multi-entry
|
||||
4. Create manifest.json
|
||||
5. `npm run dev` (watch mode)
|
||||
6. Load in Chrome: `chrome://extensions` → Load unpacked
|
||||
|
||||
---
|
||||
|
||||
## Development Tips
|
||||
|
||||
| Task | Method |
|
||||
|------|--------|
|
||||
| Debug Popup | Right-click icon → Inspect |
|
||||
| Debug Background | Extensions page → Service worker |
|
||||
| Debug Content | DevTools console on page |
|
||||
| Hot Reload | `npm run dev` with watch |
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Use type-safe messaging
|
||||
- Wrap Chrome APIs in promises
|
||||
- Minimize permissions
|
||||
- Handle offline gracefully
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,88 @@
|
||||
---
|
||||
name: cli-tool
|
||||
description: Node.js CLI tool template principles. Commander.js, interactive prompts.
|
||||
---
|
||||
|
||||
# CLI Tool Template
|
||||
|
||||
## Tech Stack
|
||||
|
||||
| Component | Technology |
|
||||
|-----------|------------|
|
||||
| Runtime | Node.js 20+ |
|
||||
| Language | TypeScript |
|
||||
| CLI Framework | Commander.js |
|
||||
| Prompts | Inquirer.js |
|
||||
| Output | chalk + ora |
|
||||
| Config | cosmiconfig |
|
||||
|
||||
---
|
||||
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
project-name/
|
||||
├── src/
|
||||
│ ├── index.ts # Entry point
|
||||
│ ├── cli.ts # CLI setup
|
||||
│ ├── commands/ # Command handlers
|
||||
│ ├── lib/
|
||||
│ │ ├── config.ts # Config loader
|
||||
│ │ └── logger.ts # Styled output
|
||||
│ └── types/
|
||||
├── bin/
|
||||
│ └── cli.js # Executable
|
||||
└── package.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## CLI Design Principles
|
||||
|
||||
| Principle | Description |
|
||||
|-----------|-------------|
|
||||
| Subcommands | Group related actions |
|
||||
| Options | Flags with defaults |
|
||||
| Interactive | Prompts when needed |
|
||||
| Non-interactive | Support --yes flags |
|
||||
|
||||
---
|
||||
|
||||
## Key Components
|
||||
|
||||
| Component | Purpose |
|
||||
|-----------|---------|
|
||||
| Commander | Command parsing |
|
||||
| Inquirer | Interactive prompts |
|
||||
| Chalk | Colored output |
|
||||
| Ora | Spinners/loading |
|
||||
| Cosmiconfig | Config file discovery |
|
||||
|
||||
---
|
||||
|
||||
## Setup Steps
|
||||
|
||||
1. Create project directory
|
||||
2. `npm init -y`
|
||||
3. Install deps: `npm install commander @inquirer/prompts chalk ora cosmiconfig`
|
||||
4. Configure bin in package.json
|
||||
5. `npm link` for local testing
|
||||
|
||||
---
|
||||
|
||||
## Publishing
|
||||
|
||||
```bash
|
||||
npm login
|
||||
npm publish
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Provide helpful error messages
|
||||
- Support both interactive and non-interactive modes
|
||||
- Use consistent output styling
|
||||
- Validate inputs with Zod
|
||||
- Exit with proper codes (0 success, 1 error)
|
||||
Binary file not shown.
@@ -0,0 +1,88 @@
|
||||
---
|
||||
name: electron-desktop
|
||||
description: Electron desktop app template principles. Cross-platform, React, TypeScript.
|
||||
---
|
||||
|
||||
# Electron Desktop App Template
|
||||
|
||||
## Tech Stack
|
||||
|
||||
| Component | Technology |
|
||||
|-----------|------------|
|
||||
| Framework | Electron 28+ |
|
||||
| UI | React 18 |
|
||||
| Language | TypeScript |
|
||||
| Styling | Tailwind CSS |
|
||||
| Bundler | Vite + electron-builder |
|
||||
| IPC | Type-safe communication |
|
||||
|
||||
---
|
||||
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
project-name/
|
||||
├── electron/
|
||||
│ ├── main.ts # Main process
|
||||
│ ├── preload.ts # Preload script
|
||||
│ └── ipc/ # IPC handlers
|
||||
├── src/
|
||||
│ ├── App.tsx
|
||||
│ ├── components/
|
||||
│ │ ├── TitleBar.tsx # Custom title bar
|
||||
│ │ └── ...
|
||||
│ └── hooks/
|
||||
├── public/
|
||||
└── package.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Process Model
|
||||
|
||||
| Process | Role |
|
||||
|---------|------|
|
||||
| Main | Node.js, system access |
|
||||
| Renderer | Chromium, React UI |
|
||||
| Preload | Bridge, context isolation |
|
||||
|
||||
---
|
||||
|
||||
## Key Concepts
|
||||
|
||||
| Concept | Purpose |
|
||||
|---------|---------|
|
||||
| contextBridge | Safe API exposure |
|
||||
| ipcMain/ipcRenderer | Process communication |
|
||||
| nodeIntegration: false | Security |
|
||||
| contextIsolation: true | Security |
|
||||
|
||||
---
|
||||
|
||||
## Setup Steps
|
||||
|
||||
1. `npm create vite {{name}} -- --template react-ts`
|
||||
2. Install: `npm install -D electron electron-builder vite-plugin-electron`
|
||||
3. Create electron/ directory
|
||||
4. Configure main process
|
||||
5. `npm run electron:dev`
|
||||
|
||||
---
|
||||
|
||||
## Build Targets
|
||||
|
||||
| Platform | Output |
|
||||
|----------|--------|
|
||||
| Windows | NSIS, Portable |
|
||||
| macOS | DMG, ZIP |
|
||||
| Linux | AppImage, DEB |
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Use preload script for main/renderer bridge
|
||||
- Type-safe IPC with typed handlers
|
||||
- Custom title bar for native feel
|
||||
- Handle window state (maximize, minimize)
|
||||
- Auto-updates with electron-updater
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,83 @@
|
||||
---
|
||||
name: express-api
|
||||
description: Express.js REST API template principles. TypeScript, Prisma, JWT.
|
||||
---
|
||||
|
||||
# Express.js API Template
|
||||
|
||||
## Tech Stack
|
||||
|
||||
| Component | Technology |
|
||||
|-----------|------------|
|
||||
| Runtime | Node.js 20+ |
|
||||
| Framework | Express.js |
|
||||
| Language | TypeScript |
|
||||
| Database | PostgreSQL + Prisma |
|
||||
| Validation | Zod |
|
||||
| Auth | JWT + bcrypt |
|
||||
|
||||
---
|
||||
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
project-name/
|
||||
├── prisma/
|
||||
│ └── schema.prisma
|
||||
├── src/
|
||||
│ ├── app.ts # Express setup
|
||||
│ ├── config/ # Environment
|
||||
│ ├── routes/ # Route handlers
|
||||
│ ├── controllers/ # Business logic
|
||||
│ ├── services/ # Data access
|
||||
│ ├── middleware/
|
||||
│ │ ├── auth.ts # JWT verify
|
||||
│ │ ├── error.ts # Error handler
|
||||
│ │ └── validate.ts # Zod validation
|
||||
│ ├── schemas/ # Zod schemas
|
||||
│ └── utils/
|
||||
└── package.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Middleware Stack
|
||||
|
||||
| Order | Middleware |
|
||||
|-------|------------|
|
||||
| 1 | helmet (security) |
|
||||
| 2 | cors |
|
||||
| 3 | morgan (logging) |
|
||||
| 4 | body parsing |
|
||||
| 5 | routes |
|
||||
| 6 | error handler |
|
||||
|
||||
---
|
||||
|
||||
## API Response Format
|
||||
|
||||
| Type | Structure |
|
||||
|------|-----------|
|
||||
| Success | `{ success: true, data: {...} }` |
|
||||
| Error | `{ error: "message", details: [...] }` |
|
||||
|
||||
---
|
||||
|
||||
## Setup Steps
|
||||
|
||||
1. Create project directory
|
||||
2. `npm init -y`
|
||||
3. Install deps: `npm install express prisma zod bcrypt jsonwebtoken`
|
||||
4. Configure Prisma
|
||||
5. `npm run db:push`
|
||||
6. `npm run dev`
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Layer architecture (routes → controllers → services)
|
||||
- Validate all inputs with Zod
|
||||
- Centralized error handling
|
||||
- Environment-based config
|
||||
- Use Prisma for type-safe DB access
|
||||
Binary file not shown.
@@ -0,0 +1,90 @@
|
||||
---
|
||||
name: flutter-app
|
||||
description: Flutter mobile app template principles. Riverpod, Go Router, clean architecture.
|
||||
---
|
||||
|
||||
# Flutter App Template
|
||||
|
||||
## Tech Stack
|
||||
|
||||
| Component | Technology |
|
||||
|-----------|------------|
|
||||
| Framework | Flutter 3.x |
|
||||
| Language | Dart 3.x |
|
||||
| State | Riverpod 2.0 |
|
||||
| Navigation | Go Router |
|
||||
| HTTP | Dio |
|
||||
| Storage | Hive |
|
||||
|
||||
---
|
||||
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
project_name/
|
||||
├── lib/
|
||||
│ ├── main.dart
|
||||
│ ├── app.dart
|
||||
│ ├── core/
|
||||
│ │ ├── constants/
|
||||
│ │ ├── theme/
|
||||
│ │ ├── router/
|
||||
│ │ └── utils/
|
||||
│ ├── features/
|
||||
│ │ ├── auth/
|
||||
│ │ │ ├── data/
|
||||
│ │ │ ├── domain/
|
||||
│ │ │ └── presentation/
|
||||
│ │ └── home/
|
||||
│ ├── shared/
|
||||
│ │ ├── widgets/
|
||||
│ │ └── providers/
|
||||
│ └── services/
|
||||
│ ├── api/
|
||||
│ └── storage/
|
||||
├── test/
|
||||
└── pubspec.yaml
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Architecture Layers
|
||||
|
||||
| Layer | Contents |
|
||||
|-------|----------|
|
||||
| Presentation | Screens, Widgets, Providers |
|
||||
| Domain | Entities, Use Cases |
|
||||
| Data | Repositories, Models |
|
||||
|
||||
---
|
||||
|
||||
## Key Packages
|
||||
|
||||
| Package | Purpose |
|
||||
|---------|---------|
|
||||
| flutter_riverpod | State management |
|
||||
| riverpod_annotation | Code generation |
|
||||
| go_router | Navigation |
|
||||
| dio | HTTP client |
|
||||
| freezed | Immutable models |
|
||||
| hive | Local storage |
|
||||
|
||||
---
|
||||
|
||||
## Setup Steps
|
||||
|
||||
1. `flutter create {{name}} --org com.{{bundle}}`
|
||||
2. Update `pubspec.yaml`
|
||||
3. `flutter pub get`
|
||||
4. Run code generation: `dart run build_runner build`
|
||||
5. `flutter run`
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Feature-first folder structure
|
||||
- Riverpod for state, React Query pattern for server state
|
||||
- Freezed for immutable data classes
|
||||
- Go Router for declarative navigation
|
||||
- Material 3 theming
|
||||
Binary file not shown.
@@ -0,0 +1,90 @@
|
||||
---
|
||||
name: monorepo-turborepo
|
||||
description: Turborepo monorepo template principles. pnpm workspaces, shared packages.
|
||||
---
|
||||
|
||||
# Turborepo Monorepo Template
|
||||
|
||||
## Tech Stack
|
||||
|
||||
| Component | Technology |
|
||||
|-----------|------------|
|
||||
| Build System | Turborepo |
|
||||
| Package Manager | pnpm |
|
||||
| Apps | Next.js, Express |
|
||||
| Packages | Shared UI, Config, Types |
|
||||
| Language | TypeScript |
|
||||
|
||||
---
|
||||
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
project-name/
|
||||
├── apps/
|
||||
│ ├── web/ # Next.js app
|
||||
│ ├── api/ # Express API
|
||||
│ └── docs/ # Documentation
|
||||
├── packages/
|
||||
│ ├── ui/ # Shared components
|
||||
│ ├── config/ # ESLint, TS, Tailwind
|
||||
│ ├── types/ # Shared types
|
||||
│ └── utils/ # Shared utilities
|
||||
├── turbo.json
|
||||
├── pnpm-workspace.yaml
|
||||
└── package.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Key Concepts
|
||||
|
||||
| Concept | Description |
|
||||
|---------|-------------|
|
||||
| Workspaces | pnpm-workspace.yaml |
|
||||
| Pipeline | turbo.json task graph |
|
||||
| Caching | Remote/local task caching |
|
||||
| Dependencies | `workspace:*` protocol |
|
||||
|
||||
---
|
||||
|
||||
## Turbo Pipeline
|
||||
|
||||
| Task | Depends On |
|
||||
|------|------------|
|
||||
| build | ^build (dependencies first) |
|
||||
| dev | cache: false, persistent |
|
||||
| lint | ^build |
|
||||
| test | ^build |
|
||||
|
||||
---
|
||||
|
||||
## Setup Steps
|
||||
|
||||
1. Create root directory
|
||||
2. `pnpm init`
|
||||
3. Create pnpm-workspace.yaml
|
||||
4. Create turbo.json
|
||||
5. Add apps and packages
|
||||
6. `pnpm install`
|
||||
7. `pnpm dev`
|
||||
|
||||
---
|
||||
|
||||
## Common Commands
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `pnpm dev` | Run all apps |
|
||||
| `pnpm build` | Build all |
|
||||
| `pnpm --filter @name/web dev` | Run specific app |
|
||||
| `pnpm --filter @name/web add axios` | Add dep to app |
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Shared configs in packages/config
|
||||
- Shared types in packages/types
|
||||
- Internal packages with `workspace:*`
|
||||
- Use Turbo remote caching for CI
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,82 @@
|
||||
---
|
||||
name: nextjs-fullstack
|
||||
description: Next.js full-stack template principles. App Router, Prisma, Tailwind.
|
||||
---
|
||||
|
||||
# Next.js Full-Stack Template
|
||||
|
||||
## Tech Stack
|
||||
|
||||
| Component | Technology |
|
||||
|-----------|------------|
|
||||
| Framework | Next.js 14 (App Router) |
|
||||
| Language | TypeScript |
|
||||
| Database | PostgreSQL + Prisma |
|
||||
| Styling | Tailwind CSS |
|
||||
| Auth | Clerk (optional) |
|
||||
| Validation | Zod |
|
||||
|
||||
---
|
||||
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
project-name/
|
||||
├── prisma/
|
||||
│ └── schema.prisma
|
||||
├── src/
|
||||
│ ├── app/
|
||||
│ │ ├── layout.tsx
|
||||
│ │ ├── page.tsx
|
||||
│ │ ├── globals.css
|
||||
│ │ └── api/
|
||||
│ ├── components/
|
||||
│ │ └── ui/
|
||||
│ ├── lib/
|
||||
│ │ ├── db.ts # Prisma client
|
||||
│ │ └── utils.ts
|
||||
│ └── types/
|
||||
├── .env.example
|
||||
└── package.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Key Concepts
|
||||
|
||||
| Concept | Description |
|
||||
|---------|-------------|
|
||||
| Server Components | Default, fetch data |
|
||||
| Server Actions | Form mutations |
|
||||
| Route Handlers | API endpoints |
|
||||
| Prisma | Type-safe ORM |
|
||||
|
||||
---
|
||||
|
||||
## Environment Variables
|
||||
|
||||
| Variable | Purpose |
|
||||
|----------|---------|
|
||||
| DATABASE_URL | Prisma connection |
|
||||
| NEXT_PUBLIC_APP_URL | Public URL |
|
||||
|
||||
---
|
||||
|
||||
## Setup Steps
|
||||
|
||||
1. `npx create-next-app {{name}} --typescript --tailwind --app`
|
||||
2. `npm install prisma @prisma/client zod`
|
||||
3. `npx prisma init`
|
||||
4. Configure schema
|
||||
5. `npm run db:push`
|
||||
6. `npm run dev`
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Server Components by default
|
||||
- Server Actions for mutations
|
||||
- Prisma for type-safe DB
|
||||
- Zod for validation
|
||||
- Edge runtime where possible
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,100 @@
|
||||
---
|
||||
name: nextjs-saas
|
||||
description: Next.js SaaS template principles. Auth, payments, email.
|
||||
---
|
||||
|
||||
# Next.js SaaS Template
|
||||
|
||||
## Tech Stack
|
||||
|
||||
| Component | Technology |
|
||||
|-----------|------------|
|
||||
| Framework | Next.js 14 (App Router) |
|
||||
| Auth | NextAuth.js v5 |
|
||||
| Payments | Stripe |
|
||||
| Database | PostgreSQL + Prisma |
|
||||
| Email | Resend |
|
||||
| UI | Tailwind (ASK USER: shadcn/Headless UI/Custom?) |
|
||||
|
||||
---
|
||||
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
project-name/
|
||||
├── prisma/
|
||||
├── src/
|
||||
│ ├── app/
|
||||
│ │ ├── (auth)/ # Login, register
|
||||
│ │ ├── (dashboard)/ # Protected routes
|
||||
│ │ ├── (marketing)/ # Landing, pricing
|
||||
│ │ └── api/
|
||||
│ │ ├── auth/[...nextauth]/
|
||||
│ │ └── webhooks/stripe/
|
||||
│ ├── components/
|
||||
│ │ ├── auth/
|
||||
│ │ ├── billing/
|
||||
│ │ └── dashboard/
|
||||
│ ├── lib/
|
||||
│ │ ├── auth.ts # NextAuth config
|
||||
│ │ ├── stripe.ts # Stripe client
|
||||
│ │ └── email.ts # Resend client
|
||||
│ └── config/
|
||||
│ └── subscriptions.ts
|
||||
└── package.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## SaaS Features
|
||||
|
||||
| Feature | Implementation |
|
||||
|---------|---------------|
|
||||
| Auth | NextAuth + OAuth |
|
||||
| Subscriptions | Stripe Checkout |
|
||||
| Billing Portal | Stripe Portal |
|
||||
| Webhooks | Stripe events |
|
||||
| Email | Transactional via Resend |
|
||||
|
||||
---
|
||||
|
||||
## Database Schema
|
||||
|
||||
| Model | Fields |
|
||||
|-------|--------|
|
||||
| User | id, email, stripeCustomerId, subscriptionId |
|
||||
| Account | OAuth provider data |
|
||||
| Session | User sessions |
|
||||
|
||||
---
|
||||
|
||||
## Environment Variables
|
||||
|
||||
| Variable | Purpose |
|
||||
|----------|---------|
|
||||
| DATABASE_URL | Prisma |
|
||||
| NEXTAUTH_SECRET | Auth |
|
||||
| STRIPE_SECRET_KEY | Payments |
|
||||
| STRIPE_WEBHOOK_SECRET | Webhooks |
|
||||
| RESEND_API_KEY | Email |
|
||||
|
||||
---
|
||||
|
||||
## Setup Steps
|
||||
|
||||
1. `npx create-next-app {{name}} --typescript --tailwind --app`
|
||||
2. Install: `npm install next-auth @auth/prisma-adapter stripe resend`
|
||||
3. Setup Stripe products/prices
|
||||
4. Configure environment
|
||||
5. `npm run db:push`
|
||||
6. `npm run stripe:listen` (webhooks)
|
||||
7. `npm run dev`
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Route groups for layout separation
|
||||
- Stripe webhooks for subscription sync
|
||||
- NextAuth with Prisma adapter
|
||||
- Email templates with React Email
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user