Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

Simplify supabase read skill to single markdown

Louis Beaumontc67e18a460bc
diff --git a/.pi/skills/supabase-read.md b/.pi/skills/supabase-read.md
new file mode 100644
index 000000000..0408fd3fa
--- /dev/null
+++ b/.pi/skills/supabase-read.md
@@ -0,0 +1,113 @@
+---
+name: supabase-read
+description: "Read-only Supabase agent. Single-file TS agent doc using dotenv env vars."
+allowed-tools: Read
+---
+
+# Supabase Read-Only Agent (TypeScript, Single-File)
+
+**Goal:** Read public Supabase tables only using environment variables loaded from `.env` via `dotenv`.
+
+## ✅ Safety Rules
+
+- **Read-only**: no inserts/updates/deletes.
+- **Public tables only**: do not query private tables (users, sessions, logs, api_keys, etc.).
+- **No secrets in repo**: never commit keys, only read from `.env`.
+
+## Environment
+
+Create `.env` (gitignored):
+
+```env
+SUPABASE_URL=https://your-project.supabase.co
+SUPABASE_PUBLIC_KEY=your_public_anon_key
+```
+
+Load with dotenv:
+
+```bash
+bun add dotenv @supabase/supabase-js
+```
+
+## Agent (TypeScript)
+
+```ts
+// supabase-read-agent.ts
+import "dotenv/config";
+import { createClient } from "@supabase/supabase-js";
+
+const supabaseUrl = process.env.SUPABASE_URL;
+const supabaseKey = process.env.SUPABASE_PUBLIC_KEY;
+
+if (!supabaseUrl || !supabaseKey) {
+ throw new Error("Missing SUPABASE_URL or SUPABASE_PUBLIC_KEY in .env");
+}
+
+const supabase = createClient(supabaseUrl, supabaseKey);
+
+export async function getActiveFeatures() {
+ const { data, error } = await supabase
+ .from("features")
+ .select("id, name, enabled, description, created_at, updated_at")
+ .eq("enabled", true)
+ .order("created_at", { ascending: false });
+
+ if (error) throw new Error(error.message);
+ return data ?? [];
+}
+
+export async function getPricingTiers() {
+ const { data, error } = await supabase
+ .from("pricing_tiers")
+ .select(
+ "id, name, monthly_price, features, storage_gb, api_calls_month, created_at"
+ )
+ .order("monthly_price", { ascending: true });
+
+ if (error) throw new Error(error.message);
+ return data ?? [];
+}
+
+export async function getAnalytics({
+ eventType,
+ startDate,
+ endDate,
+ limit = 100,
+}: {
+ eventType?: string;
+ startDate?: Date;
+ endDate?: Date;
+ limit?: number;
+}) {
+ let query = supabase
+ .from("user_analytics")
+ .select("id, event_type, event_count, date, created_at");
+
+ if (eventType) query = query.eq("event_type", eventType);
+ if (startDate)
+ query = query.gte("date", startDate.toISOString().split("T")[0]);
+ if (endDate) query = query.lte("date", endDate.toISOString().split("T")[0]);
+
+ query = query.limit(Math.min(limit, 1000));
+
+ const { data, error } = await query;
+ if (error) throw new Error(error.message);
+ return data ?? [];
+}
+```
+
+## Safe Tables (Public)
+
+- `features`
+- `pricing_tiers`
+- `user_analytics`
+
+## Blocked Tables (Do Not Touch)
+
+`users`, `sessions`, `api_keys`, `logs`, `audit_trail`, `payment_info`, `support_tickets`, `error_logs`
+
+## Notes
+
+- This agent **must** use `SUPABASE_PUBLIC_KEY` only.
+- **Never** hardcode keys or commit `.env` files.
+- If data is missing, it likely means RLS blocks the table.
diff --git a/.pi/skills/supabase-read/INDEX.md b/.pi/skills/supabase-read/INDEX.md
deleted file mode 100644
index 0bf2bf67a..000000000
--- a/.pi/skills/supabase-read/INDEX.md
+++ /dev/null
@@ -1,189 +0,0 @@
-# Supabase Read-Only Agent Skill - File Index
-
-## 📁 Skill Directory Structure
-
-```
-.pi/skills/supabase-read/
-├── SKILL.md ← Main documentation (read this first)
-├── README.md ← Overview and quick reference
-├── SETUP.md ← Installation & troubleshooting
-├── supabase-agent.ts ← Implementation (TypeScript)
-├── PROMPT_TEMPLATE.md ← Prompts for skills using this agent
-├── INDEX.md ← This file
-└── .gitignore ← What not to commit (see root)
-```
-
-## 📖 Reading Guide
-
-### 👤 If You're...
-
-**A User/End User:**
-1. Start with `README.md` (overview)
-2. Follow `SETUP.md` (installation)
-3. Jump to examples in `SKILL.md`
-
-**A Skill Developer:**
-1. Read `SKILL.md` entirely (schema & safety)
-2. Check `supabase-agent.ts` for API
-3. Use `PROMPT_TEMPLATE.md` for prompts in your skill
-4. Reference `SKILL.md` "Safe Tables" when writing queries
-
-**A Maintainer/Admin:**
-1. Review `SKILL.md` (comprehensive documentation)
-2. Check `supabase-agent.ts` (implementation)
-3. Update "Safe Tables" or "Blocked Tables" sections as needed
-4. Review `PROMPT_TEMPLATE.md` safety guardrails
-5. Update `SETUP.md` if dependencies or steps change
-
-**An AI/Agent:**
-1. Load `PROMPT_TEMPLATE.md` for context
-2. Reference `SKILL.md` for schema details
-3. Use `supabase-agent.ts` as implementation guide
-4. Follow safety guidelines in all files
-
-## 🎯 By Purpose
-
-### Need to Query the Database?
-→ `SKILL.md` (Schema section) + `supabase-agent.ts` (Examples)
-
-### Getting "Environment Variables" Error?
-→ `SETUP.md` (Step 2: Fetch Environment Variables)
-
-### Writing a Skill That Uses This?
-→ `PROMPT_TEMPLATE.md` + `supabase-agent.ts`
-
-### Understanding What's Safe/Unsafe?
-→ `SKILL.md` (Safe Tables vs Blocked Tables)
-
-### Troubleshooting Errors?
-→ `SETUP.md` (Troubleshooting section)
-
-### Rate Limiting Issues?
-→ `SKILL.md` (Rate Limiting section) + `PROMPT_TEMPLATE.md`
-
-### Security Review?
-→ `SKILL.md` (Safety Guidelines) + `PROMPT_TEMPLATE.md` (Safety Guardrails)
-
-## 📋 File Purposes
-
-| File | Purpose | Audience | Read Time |
-|------|---------|----------|-----------|
-| **SKILL.md** | Complete documentation: schema, safety, usage | Everyone | 15 min |
-| **README.md** | Quick overview and reference | Everyone | 5 min |
-| **SETUP.md** | Installation, environment, troubleshooting | Users, Devs | 8 min |
-| **supabase-agent.ts** | Working implementation with examples | Devs | 10 min |
-| **PROMPT_TEMPLATE.md** | Prompt patterns and error handling | Skill writers | 12 min |
-| **INDEX.md** | This navigation guide | Everyone | 3 min |
-
-## 🔒 Security Features
-
-All files include safety information:
-
-- **SKILL.md**: "Safety Guidelines" + "Unsafe Tables (Blocked)"
-- **supabase-agent.ts**: Inline comments about what NOT to do
-- **SETUP.md**: "Safety Checklist" section
-- **PROMPT_TEMPLATE.md**: "Safety Guardrails in Prompts" + examples
-- **README.md**: "What NOT to Do" vs "What to Do"
-
-## 🚀 Quick Reference
-
-### Setup (Copy-Paste Ready)
-
-```bash
-# 1. Pull environment
-vercel env pull
-
-# 2. Install package
-bun add @supabase/supabase-js
-
-# 3. Import in code
-import { SupabaseReadAgent } from "./.pi/skills/supabase-read/supabase-agent"
-
-# 4. Use it
-const features = await SupabaseReadAgent.getActiveFeatures()
-```
-
-### Safe Tables (Always OK to Query)
-
-```
-✅ user_analytics (aggregate stats)
-✅ features (feature flags)
-✅ pricing_tiers (pricing info)
-```
-
-### Blocked Tables (RLS Prevents Access)
-
-```
-❌ users (personal data)
-❌ sessions (auth tokens)
-❌ api_keys (credentials)
-❌ logs (internals)
-❌ audit_trail (user tracking)
-❌ payment_info (financial data)
-❌ support_tickets (private messages)
-❌ error_logs (system details)
-```
-
-## 📚 Cross-References
-
-From any file, you can jump to:
-
-- **SKILL.md** → Schema definitions, safety guidelines, RLS explanation
-- **SETUP.md** → Environment variables, installation, error solutions
-- **supabase-agent.ts** → API functions, implementation details
-- **PROMPT_TEMPLATE.md** → Prompt patterns, error messages, guardrails
-- **README.md** → Overview, quick start, architecture
-
-## ✅ Checklist for Skill Writers
-
-Before publishing a skill using this agent:
-
-- [ ] Read `SKILL.md` completely
-- [ ] Only query tables in "Safe Tables" list
-- [ ] Review `PROMPT_TEMPLATE.md` for error handling
-- [ ] Add safety disclaimers to your skill's docs
-- [ ] Test with `SUPABASE_PUBLIC_KEY` (never private)
-- [ ] Verify `.env.local` is `.gitignored`
-- [ ] Document what tables you query
-- [ ] Never hardcode any credentials
-- [ ] Include "Rate Limiting" note if you do repeated queries
-- [ ] Test error cases (network issues, missing env, invalid queries)
-
-## 🆘 Help & Support
-
-| Issue | Resource |
-|-------|----------|
-| Blank stare at Supabase? | Start with `README.md` |
-| "How do I install?" | Follow `SETUP.md` |
-| "What tables exist?" | Check `SKILL.md` schema section |
-| "Is this table safe?" | See "Safe Tables" in `SKILL.md` |
-| "How do I write prompts?" | Use `PROMPT_TEMPLATE.md` |
-| "Getting errors?" | Troubleshoot in `SETUP.md` |
-| "Is this operation allowed?" | Check safety in `SKILL.md` |
-| "Need implementation example?" | Review `supabase-agent.ts` |
-
-## 📝 Notes
-
-- **No secrets in files**: All code files use environment variables
-- **All documentation public**: Safe to share on GitHub
-- **Maintained by**: Screenpipe maintainers
-- **Last updated**: February 3, 2026
-- **Version**: Matches Supabase SDK @latest
-
-## 🔄 How to Stay Current
-
-If documentation changes:
-
-1. Check git history: `git log -- .pi/skills/supabase-read/`
-2. Review changes: `git diff HEAD~1 .pi/skills/supabase-read/`
-3. Update local `.env.local` if needed: `vercel env pull`
-4. Reinstall package if major version: `bun install @supabase/supabase-js@latest`
-
----
-
-**TL;DR:**
-- New here? Read `README.md` then `SETUP.md`
-- Want schema? Go to `SKILL.md`
-- Writing a skill? Use `PROMPT_TEMPLATE.md`
-- Need code? Check `supabase-agent.ts`
-- Got errors? See `SETUP.md` troubleshooting
diff --git a/.pi/skills/supabase-read/PROMPT_TEMPLATE.md b/.pi/skills/supabase-read/PROMPT_TEMPLATE.md
deleted file mode 100644
index 3cac6faea..000000000
--- a/.pi/skills/supabase-read/PROMPT_TEMPLATE.md
+++ /dev/null
@@ -1,356 +0,0 @@
-# Supabase Read-Only Agent - Prompt Template
-
-Use this template when creating skills or agents that need to query the Screenpipe database.
-
-## System Prompt for Supabase Queries
-
-```
-You are a read-only database assistant for the Screenpipe application.
-
-Your responsibilities:
-1. Query the public Supabase database for information
-2. Only query documented public tables
-3. Never attempt private operations
-4. Explain what data you're retrieving and why
-
-Available public tables:
-- user_analytics: Anonymous event statistics
-- features: Feature flag information
-- pricing_tiers: Subscription pricing
-
-Forbidden tables (RLS blocks these):
-- users, sessions, api_keys, logs, audit_trail, payment_info, support_tickets, error_logs
-
-When a user asks a question:
-1. Identify if it requires database access
-2. Check if the required data exists in public tables
-3. If yes: Query using the SupabaseReadAgent
-4. If no: Explain what data is unavailable and why
-
-Always be transparent about:
-- What data you're accessing
-- Which tables you're querying
-- Whether the query succeeded or failed
-- If data is incomplete or missing
-```
-
-## Prompt Examples
-
-### Example 1: Feature Status Query
-
-**User:** "Is the OCR beta feature available yet?"
-
-**Agent Response:**
-```
-I'll check the feature status for you.
-
-Querying: features table for "ocr_beta"
-Result: ocr_beta is currently [ENABLED/DISABLED] as of [date]
-
-The OCR beta feature...
-```
-
-### Example 2: Pricing Information
-
-**User:** "What are the current pricing tiers?"
-
-**Agent Response:**
-```
-I'll retrieve the current pricing information.
-
-Querying: pricing_tiers table
-Found 3 tiers:
-
-1. Free - $0/month
- - Features: [list]
- - Storage: 1 GB
- - API calls: 1,000/month
-
-2. Pro - $29/month
- - Features: [list]
- - Storage: 100 GB
- - API calls: 100,000/month
-
-3. Enterprise - Custom pricing
- - Features: [list]
- - Storage: Unlimited
- - API calls: Unlimited
-```
-
-### Example 3: Analytics Query
-
-**User:** "How many people used the capture feature last month?"
-
-**Agent Response:**
-```
-I'll check the analytics for capture events.
-
-Querying: user_analytics table
-Filter: event_type = 'capture', date >= [30 days ago]
-Result: 15,432 capture events recorded
-
-This represents [X] unique users engaging with the capture feature.
-Note: This is aggregated, anonymous data - no individual users identified.
-```
-
-## Error Handling Template
-
-When queries fail, use this template:
-
-```
-Query failed: [table name]
-Reason: [error details]
-
-Possible causes:
-1. [cause 1]
-2. [cause 2]
-3. [cause 3]
-
-What to try:
-- [suggestion 1]
-- [suggestion 2]
-- [suggestion 3]
-```
-
-### Common Errors
-
-**"403 Forbidden"**
-```
-This table is not accessible via the public API key.
-
-Tables you CAN query:
-- user_analytics (aggregate event data)
-- features (feature status)
-- pricing_tiers (subscription info)
-
-If you need different data, please clarify what you're looking for.
-```
-
-**"401 Unauthorized"**
-```
-The API key is invalid or expired.
-
-Try refreshing the environment:
-1. Run: vercel env pull
-2. Restart the application
-
-If the problem persists, contact the maintainers.
-```
-
-**"Column not found"**
-```
-That column doesn't exist in the table schema.
-
-Available columns in [table]:
-- [column 1]
-- [column 2]
-- [column 3]
-
-Which column did you want to access?
-```
-
-## Integration with Skills
-
-When writing a skill that uses this agent:
-
-```markdown
----
-name: my-feature-skill
-description: "Query Screenpipe feature status from the database"
-allowed-tools: Read, Write
----
-
-# My Feature Skill
-
-This skill queries the read-only Screenpipe Supabase database.
-
-## What It Can Do
-
-- Check feature availability
-- Retrieve pricing information
-- View usage statistics (anonymized)
-- Search public announcements
-
-## What It CANNOT Do
-
-- Access user information
-- View debug logs or error traces
-- Modify pricing or features
-- Access API keys or sessions
-- Query private user data
-
-## Example Usage
-
-"What features are currently enabled?"
-→ Queries `features` table, returns enabled features
-
-"How much does the Pro tier cost?"
-→ Queries `pricing_tiers` table, returns pricing
-
-"Show me capture event statistics"
-→ Queries `user_analytics` table, returns aggregated counts
-```
-
-## Safety Guardrails in Prompts
-
-Always include these safety notes:
-
-```
-IMPORTANT SAFETY GUIDELINES:
-
-1. Only query documented public tables
-2. Never attempt to access user data
-3. All queries are read-only
-4. Don't share raw API keys
-5. Respect user privacy
-6. Report suspicious queries to maintainers
-7. Cache results to respect rate limits
-8. Never hardcode credentials
-```
-
-## Data Anonymization Template
-
-When discussing query results:
-
-```
-The database provides [X] records.
-
-I can tell you:
-✅ Aggregate counts (e.g., "500 events total")
-✅ Feature status (e.g., "OCR beta is enabled")
-✅ Pricing info (e.g., "Pro tier costs $29/month")
-
-I cannot tell you:
-❌ Who used what features
-❌ Individual user activities
-❌ Private user information
-❌ System internals or debug data
-❌ API credentials or secrets
-```
-
-## Rejection Template
-
-For requests that violate safety guidelines:
-
-```
-I can't help with that request.
-
-Reason: [specific reason]
-
-What I can help with instead:
-1. [alternative 1]
-2. [alternative 2]
-3. [alternative 3]
-
-If you believe this restriction is incorrect, please contact the maintainers.
-```
-
-### Examples
-
-```
-Request: "Show me user sessions for [email protected]"
-Response:
-"I can't help with that request.
-
-Reason: The sessions table contains private authentication data and is not accessible.
-
-What I can help with instead:
-1. Feature availability information
-2. Pricing tier details
-3. Aggregate usage statistics (anonymized)
-4. Feature status and rollout dates
-
-If you need user-specific information, please contact support directly."
-```
-
-```
-Request: "Get all error logs for debugging"
-Response:
-"I can't help with that request.
-
-Reason: Error logs contain system internals and are restricted to administrators.
-
-What I can help with instead:
-1. Check feature status
-2. View aggregate analytics
-3. Review pricing information
-4. Check feature availability
-
-For debugging access, contact the technical team."
-```
-
-## Rate Limiting Messaging
-
-When approaching rate limits:
-
-```
-⚠️ Approaching rate limit
-
-Your queries are being cached to respect Supabase limits (100 req/min).
-
-Recent queries cached:
-- Features list (expires in 55 min)
-- Pricing tiers (expires in 58 min)
-- Analytics summary (expires in 45 min)
-
-To see fresh data, wait for cache expiration or ask a new question.
-```
-
-## Debugging Template (for developers)
-
-```
-[DEBUG: Query execution]
-Table: [table_name]
-Filters: [filter_conditions]
-Selected columns: [col1, col2, col3]
-Limit: [number]
-
-Query execution time: [ms]
-Rows returned: [number]
-Cache: [HIT/MISS]
-```
-
----
-
-## Reference: Safe vs Unsafe Operations
-
-### ✅ SAFE Queries
-
-```typescript
-// Query feature status
-await supabase.from("features")
- .select("name, enabled, description")
- .eq("enabled", true);
-
-// Get pricing
-await supabase.from("pricing_tiers")
- .select("name, monthly_price, features");
-
-// Analytics aggregates
-await supabase.from("user_analytics")
- .select("event_type, COUNT(*) as count")
- .group_by("event_type");
-```
-
-### ❌ UNSAFE Queries
-
-```typescript
-// Accessing user data
-await supabase.from("users").select("*");
-
-// Viewing sessions/auth
-await supabase.from("sessions").select("*");
-
-// Accessing logs
-await supabase.from("logs").select("error, stack_trace");
-
-// Accessing credentials
-await supabase.from("api_keys").select("secret");
-
-// Modifying data
-await supabase.from("features").update({ enabled: false });
-
-// Deleting data
-await supabase.from("pricing_tiers").delete().eq("id", "xxx");
-```
-
diff --git a/.pi/skills/supabase-read/README.md b/.pi/skills/supabase-read/README.md
deleted file mode 100644
index 4b7ffcc04..000000000
--- a/.pi/skills/supabase-read/README.md
+++ /dev/null
@@ -1,267 +0,0 @@
-# Supabase Read-Only Agent Skill
-
-Safe, read-only access to the Screenpipe Supabase database for skills and agents.
-
-## 📋 What's Here
-
-| File | Purpose |
-|------|---------|
-| **SKILL.md** | Main skill documentation - schema, safety guidelines, and usage |
-| **SETUP.md** | Quick start guide and troubleshooting |
-| **supabase-agent.ts** | Ready-to-use TypeScript/JavaScript agent implementation |
-| **PROMPT_TEMPLATE.md** | Prompt templates for skills that use this agent |
-| **README.md** | This file |
-
-## 🚀 Quick Start
-
-```bash
-# 1. Pull environment variables (never hardcode!)
-vercel env pull
-
-# 2. Install dependency
-bun add @supabase/supabase-js
-
-# 3. Use in your code
-import { SupabaseReadAgent } from "./.pi/skills/supabase-read/supabase-agent"
-
-const features = await SupabaseReadAgent.getActiveFeatures()
-```
-
-## 🔒 Safety First
-
-This skill is designed with security in mind:
-
-- **Read-only access** - no writes, deletes, or modifications
-- **Public key only** - private keys never in code
-- **RLS protection** - blocked tables can't be accessed even with public key
-- **Schema documentation** - clear what's safe to query
-- **No hardcoded secrets** - uses Vercel CLI or environment variables
-- **Rate limiting** - respects Supabase API limits
-
-## 🗂️ Safe Tables
-
-```
-user_analytics → Anonymous event statistics
-features → Feature flag status
-pricing_tiers → Subscription information
-```
-
-## 🚫 Blocked Tables
-
-These tables are protected by Supabase Row-Level Security:
-
-```
-users, sessions, api_keys, logs, audit_trail
-payment_info, support_tickets, error_logs
-```
-
-Even if attempted, RLS policies will deny access.
-
-## 📚 Documentation
-
-### For End Users
-- Start with **SETUP.md** for installation
-- Read **SKILL.md** for what tables exist and how to query them
-
-### For Skill Developers
-- Use **supabase-agent.ts** as a reference implementation
-- Check **PROMPT_TEMPLATE.md** for how to write prompts
-- Review **SKILL.md** for safety guidelines
-
-### For Maintainers
-- All three main sections (Setup, Schema, Troubleshooting) in **SKILL.md**
-- Add new safe tables in "Safe Tables for Querying" section
-- Update blocked tables list if access changes
-
-## 💡 Example Usage
-
-### Get Active Features
-```typescript
-const agent = SupabaseReadAgent
-const features = await agent.getActiveFeatures()
-
-// Output:
-// [
-// { id: "uuid", name: "ocr_beta", enabled: true, ... },
-// { id: "uuid", name: "advanced_search", enabled: false, ... }
-// ]
-```
-
-### Check Feature Status
-```typescript
-const isEnabled = await agent.getFeatureStatus("ocr_beta")
-console.log(`OCR Beta: ${isEnabled ? "enabled" : "disabled"}`)
-```
-
-### Get Pricing Information
-```typescript
-const tiers = await agent.getPricingTiers()
-tiers.forEach(tier => {
- console.log(`${tier.name}: $${tier.monthly_price / 100}/month`)
-})
-```
-
-### Query Analytics with Filters
-```typescript
-const events = await agent.queryPublicAnalytics({
- eventType: "capture",
- startDate: new Date("2025-01-01"),
- endDate: new Date("2025-02-01"),
- limit: 100
-})
-```
-
-## 🔑 Environment Variables
-
-The agent reads from `.env.local` (never committed):
-
-```env
-SUPABASE_URL=https://[project-id].supabase.co
-SUPABASE_PUBLIC_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
-```
-
-**To get these:**
-```bash
-vercel env pull
-```
-
-## ⚙️ How It Works
-
-1. **Public Key Only** - The agent uses only the Supabase public key
-2. **RLS Policies** - Supabase database enforces row-level security
-3. **Limited Tables** - Public key can only access documented tables
-4. **Read-Only** - Supabase policies block writes/deletes
-5. **Rate Limited** - 100 req/min per IP, 10k/day per project
-
-```
-┌─────────────────────────────────────────────────────┐
-│ Your Agent/Skill │
-└──────────────────────┬──────────────────────────────┘
- │
- │ (read-only query)
- ▼
-┌─────────────────────────────────────────────────────┐
-│ SupabaseReadAgent (public key only) │
-└──────────────────────┬──────────────────────────────┘
- │
- │ (public_key + SELECT query)
- ▼
-┌─────────────────────────────────────────────────────┐
-│ Supabase (eu.i.posthog.com) │
-│ ┌─────────────────────────────────────────────────┐ │
-│ │ Row-Level Security │ │
-│ │ ✅ Allow: SELECT from user_analytics │ │
-│ │ ✅ Allow: SELECT from features │ │
-│ │ ✅ Allow: SELECT from pricing_tiers │ │
-│ │ ❌ Block: users, sessions, logs, api_keys │ │
-│ │ ❌ Block: Any write/delete operations │ │
-│ └─────────────────────────────────────────────────┘ │
-└─────────────────────────────────────────────────────┘
-```
-
-## 🚨 What NOT to Do
-
-```typescript
-// ❌ Never hardcode keys
-const client = createClient(
- "https://...",
- "eyJ...hardcoded"
-)
-
-// ❌ Never commit .env.local
-git add .env.local // NO! It's .gitignored
-
-// ❌ Never query blocked tables
-await supabase.from("users").select("*")
-await supabase.from("sessions").select("*")
-await supabase.from("logs").select("*")
-
-// ❌ Never attempt writes
-await supabase.from("features").insert({ ... })
-await supabase.from("pricing_tiers").update({ ... })
-```
-
-## ✅ What to Do
-
-```typescript
-// ✅ Use environment variables
-const client = createClient(
- process.env.SUPABASE_URL!,
- process.env.SUPABASE_PUBLIC_KEY!
-)
-
-// ✅ Keep .env.local in .gitignore
-// (It already is - verified in root .gitignore)
-
-// ✅ Only query safe tables
-await supabase.from("features").select("name, enabled")
-await supabase.from("pricing_tiers").select("name, price")
-
-// ✅ Read-only operations only
-// (Supabase RLS blocks writes automatically)
-```
-
-## 🐛 Troubleshooting
-
-| Problem | Solution |
-|---------|----------|
-| "Missing Supabase environment variables" | Run `vercel env pull` |
-| "401 Unauthorized" | Check public key is correct (not private) |
-| "403 Forbidden" | Table is blocked by RLS - check SKILL.md |
-| "Column not found" | Verify column exists in schema |
-| "Rate limit exceeded" | Cache results, wait 1 minute, try again |
-
-See **SETUP.md** for detailed troubleshooting.
-
-## 🔗 Related Resources
-
-- **Supabase Docs:** https://supabase.com/docs
-- **Row-Level Security:** https://supabase.com/docs/guides/auth/row-level-security
-- **API Limits:** https://supabase.com/docs/guides/platform/api-limits
-- **Main skill file:** See `SKILL.md` in this directory
-
-## 📖 For Skill Writers
-
-Want to create a skill that uses this agent?
-
-1. Read `SKILL.md` to understand the schema
-2. Import `SupabaseReadAgent` from `supabase-agent.ts`
-3. Use `PROMPT_TEMPLATE.md` for your prompts
-4. Document what tables you're querying and why
-5. Include safety notes in your skill docs
-
-Example skill header:
-```markdown
----
-name: my-skill
-description: "Query Screenpipe feature availability"
-allowed-tools: Read, Write
----
-
-This skill queries read-only Supabase tables:
-- features (feature status)
-- pricing_tiers (pricing information)
-
-No private data is accessed.
-```
-
-## 📝 License & Privacy
-
-- **Code:** Licensed under Screenpipe project license
-- **Data:** Only public, anonymized data is accessible
-- **Privacy:** User data is never exposed via this agent
-- **Transparency:** All tables and columns are documented
-
-## ❓ Questions?
-
-If you need to:
-- Query a different table
-- Access currently blocked data
-- Understand a specific column
-- Add new tables
-
-Contact the maintainers with a clear use case.
-
----
-
-**Remember:** With great data access comes great responsibility. Use this agent wisely and respect user privacy. 🔒
diff --git a/.pi/skills/supabase-read/SETUP.md b/.pi/skills/supabase-read/SETUP.md
deleted file mode 100644
index 44753f5cf..000000000
--- a/.pi/skills/supabase-read/SETUP.md
+++ /dev/null
@@ -1,197 +0,0 @@
-# Supabase Read-Only Agent - Setup Guide
-
-## Quick Start
-
-### 1. Install Dependencies
-
-```bash
-# In your project root
-bun add @supabase/supabase-js
-```
-
-### 2. Fetch Environment Variables (Secure)
-
-```bash
-# Install Vercel CLI if you don't have it
-npm i -g vercel
-
-# Pull environment from Vercel (never commit .env.local!)
-vercel env pull
-
-# Verify keys are loaded
-cat .env.local | grep SUPABASE
-```
-
-Your `.env.local` should now have:
-```env
-SUPABASE_URL=https://[project-id].supabase.co
-SUPABASE_PUBLIC_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
-```
-
-### 3. Use the Agent
-
-```typescript
-import { SupabaseReadAgent } from "./.pi/skills/supabase-read/supabase-agent";
-
-async function example() {
- // List active features
- const features = await SupabaseReadAgent.getActiveFeatures();
- console.log("Features:", features);
-
- // Check pricing
- const pricing = await SupabaseReadAgent.getPricingTiers();
- console.log("Pricing tiers:", pricing);
-
- // Query analytics with filters
- const analytics = await SupabaseReadAgent.queryPublicAnalytics({
- eventType: "capture",
- startDate: new Date("2025-01-01"),
- limit: 100,
- });
- console.log("Events:", analytics);
-}
-
-example().catch(console.error);
-```
-
-## Safety Checklist
-
-- [ ] Using **public key** only (never private keys)
-- [ ] `.env.local` is in `.gitignore` (never commit secrets)
-- [ ] Only querying tables in the documented schema
-- [ ] Not attempting to modify/delete data (read-only)
-- [ ] Not trying to access blocked tables (users, sessions, logs, etc.)
-- [ ] Caching results to respect rate limits (100 req/min)
-
-## Troubleshooting
-
-### "Missing Supabase environment variables"
-
-```bash
-# Re-pull environment
-vercel env pull
-
-# Or manually set (temporary only!)
-export SUPABASE_URL=https://[project-id].supabase.co
-export SUPABASE_PUBLIC_KEY=your_public_key
-```
-
-### "401 Unauthorized"
-
-Your key is invalid or expired:
-```bash
-# Get fresh key from Vercel
-vercel env pull --force
-
-# Verify it's the PUBLIC key, not private
-grep SUPABASE_PUBLIC_KEY .env.local
-```
-
-### "403 Forbidden"
-
-RLS policy blocks this table for your key:
-- Check the table is in the "Safe Tables" section of `SKILL.md`
-- Contact maintainers if you need access to a public table
-
-### "Column not found"
-
-Verify the column exists in the schema:
-- Check `SKILL.md` for the table definition
-- Use specific columns: `.select("id, name")` instead of `.select("*")`
-
-## Integration with Pi Skills
-
-In your Pi skill that uses Supabase:
-
-```markdown
----
-name: my-custom-skill
-description: "My skill that queries Supabase public data"
-allowed-tools: Read, Bash, Write
----
-
-# My Custom Skill
-
-This skill integrates with the Supabase read-only agent...
-
-## Usage
-
-When this skill runs, it reads from public Supabase tables:
-- `user_analytics` - Feature usage statistics
-- `features` - Feature availability
-- `pricing_tiers` - Pricing information
-
-No private data is accessed.
-```
-
-## Rate Limiting
-
-Supabase public key has limits:
-- **100 requests/minute** per IP
-- **10,000 requests/day** per project
-
-**Optimization tips:**
-1. Cache frequently accessed data
-2. Batch multiple queries
-3. Use pagination: `.range(0, 99)`
-4. Filter early: `.eq("event_type", "capture")`
-
-## Never Do This
-
-```typescript
-// ❌ WRONG: Hardcoding keys
-const client = createClient(
- "https://project.supabase.co",
- "eyJ...hardcoded_key"
-);
-
-// ❌ WRONG: Committing .env.local
-git add .env.local // No! It's in .gitignore for a reason
-
-// ❌ WRONG: Fetching private tables
-await supabase.from("users").select("*");
-await supabase.from("api_keys").select("*");
-await supabase.from("sessions").select("*");
-
-// ❌ WRONG: Attempting writes
-await supabase.from("features").insert({ name: "test" });
-await supabase.from("pricing_tiers").update({ price: 99 });
-```
-
-## Always Do This
-
-```typescript
-// ✅ RIGHT: Use environment variables
-const client = createClient(
- process.env.SUPABASE_URL!,
- process.env.SUPABASE_PUBLIC_KEY!
-);
-
-// ✅ RIGHT: Keep .env.local in .gitignore
-// Verified in .gitignore - never commit secrets
-
-// ✅ RIGHT: Only query documented public tables
-await supabase.from("features").select("name, enabled");
-await supabase.from("pricing_tiers").select("name, monthly_price");
-
-// ✅ RIGHT: Read-only operations only
-// Supabase RLS blocks writes via public key automatically
-```
-
-## References
-
-- **Supabase Docs:** https://supabase.com/docs
-- **Row-Level Security:** https://supabase.com/docs/guides/auth/row-level-security
-- **Public Keys:** Never expose private keys, only public keys are safe to share
-- **Rate Limits:** https://supabase.com/docs/guides/platform/api-limits
-
-## Questions?
-
-If you need to query a different table or require different permissions, check:
-1. Is the table in the "Safe Tables" section of `SKILL.md`?
-2. Do you need data that's currently blocked (users, logs, etc.)?
-3. Contact maintainers for approval before expanding access
-
----
-
-**Remember:** Public ≠ Unsafe. Just because we can query a table doesn't mean we should. Always respect user privacy.
diff --git a/.pi/skills/supabase-read/SKILL.md b/.pi/skills/supabase-read/SKILL.md
deleted file mode 100644
index b71276ee4..000000000
--- a/.pi/skills/supabase-read/SKILL.md
+++ /dev/null
@@ -1,313 +0,0 @@
----
-name: supabase-read
-description: "Read-only Supabase agent. Query public database tables with schema documentation. Secure key retrieval via Vercel CLI."
-allowed-tools: Bash, Read, Write
----
-
-# Screenpipe Supabase Read-Only Agent
-
-Safe, read-only access to the Screenpipe Supabase database for querying public data.
-
-## Overview
-
-This agent provides:
-- **Read-only database queries** - no writes, deletes, or admin operations
-- **Secure key management** - retrieves API key from Vercel CLI (never hardcoded)
-- **Schema documentation** - public table structures without operational details
-- **Safety guardrails** - blocks dangerous operations and sensitive data access
-
-## Database Schema (Public)
-
-### Safe Tables for Querying
-
-#### `user_analytics` (Public Aggregate Data)
-Purpose: User engagement metrics (anonymized)
-
-```sql
--- Public columns only
-id UUID PRIMARY KEY
-user_id UUID (hashed/anonymized in public view)
-event_type TEXT 'capture', 'query', 'export'
-event_count INT Daily aggregate count
-date DATE Event date
-created_at TIMESTAMP Record creation
-```
-
-**Allowed Queries:**
-- Count events by type
-- Trending event types over time
-- Regional statistics (if available)
-- Feature adoption rates
-
-**Forbidden:**
-- User identification
-- Session logs
-- Debug/error information
-- Performance metrics that expose infrastructure
-
----
-
-#### `features` (Public Feature Metadata)
-Purpose: Feature flags and availability
-
-```sql
-id UUID PRIMARY KEY
-name TEXT Feature name (e.g., 'ocr_beta')
-enabled BOOLEAN Active/inactive
-description TEXT Feature description
-created_at TIMESTAMP Creation date
-updated_at TIMESTAMP Last update
-```
-
-**Allowed Queries:**
-- List active features
-- Feature availability status
-- Feature rollout dates
-
----
-
-#### `pricing_tiers` (Public Pricing Info)
-Purpose: Subscription tier definitions
-
-```sql
-id UUID PRIMARY KEY
-name TEXT 'free', 'pro', 'enterprise'
-monthly_price INT Price in cents USD
-features JSONB Feature set included
-storage_gb INT Storage limit
-api_calls_month INT API quota
-created_at TIMESTAMP Tier creation date
-```
-
-**Allowed Queries:**
-- Current pricing information
-- Tier comparisons
-- Feature availability by tier
-
----
-
-## Unsafe Tables (Blocked)
-
-**NEVER query these tables:**
-
-| Table | Reason |
-|-------|--------|
-| `users` | Contains personal identifiable information |
-| `sessions` | Session tokens, authentication data |
-| `api_keys` | Private credentials |
-| `logs` | System internals, debug information |
-| `audit_trail` | User behavior history (privacy violation) |
-| `payment_info` | Financial records |
-| `support_tickets` | Private user communications |
-| `error_logs` | Stack traces, configuration details |
-
----
-
-## Environment Setup
-
-### Getting the Supabase Key
-
-**DO NOT** commit the key to git. Retrieve it securely:
-
-```bash
-# Using Vercel CLI (recommended)
-vercel env pull
-
-# This reads from Vercel project environment and creates .env.local
-# Then fetch the public key:
-grep SUPABASE_PUBLIC_KEY .env.local
-```
-
-If you don't have Vercel CLI:
-```bash
-# Install it
-npm i -g vercel
-
-# Login
-vercel login
-
-# Pull environment
-vercel env pull
-
-# View key (it's public, safe to share)
-cat .env.local | grep SUPABASE_PUBLIC_KEY
-```
-
-### .env.local (GitIgnored)
-
-Add to `.env.local` (never commit):
-
-```env
-SUPABASE_URL=https://[project-id].supabase.co
-SUPABASE_PUBLIC_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
-```
-
-The **public key** is safe to use in queries. Private keys should NEVER be in repos.
-
----
-
-## Query Examples
-
-### TypeScript/JavaScript Agent
-
-```typescript
-// supabase-agent.ts
-import { createClient } from "@supabase/supabase-js";
-
-const supabase = createClient(
- process.env.SUPABASE_URL!,
- process.env.SUPABASE_PUBLIC_KEY!
-);
-
-// ✅ SAFE: Query public analytics
-async function getEventStats() {
- const { data, error } = await supabase
- .from("user_analytics")
- .select("event_type, event_count, date")
- .gte("date", new Date(Date.now() - 30 * 24 * 60 * 60 * 1000)); // Last 30 days
-
- if (error) throw error;
- return data;
-}
-
-// ✅ SAFE: List features
-async function getActiveFeatures() {
- const { data, error } = await supabase
- .from("features")
- .select("name, description, enabled")
- .eq("enabled", true);
-
- if (error) throw error;
- return data;
-}
-
-// ❌ BLOCKED: Don't query user sessions
-// async function getUserSessions(userId) {
-// // This will fail - table access denied
-// const { data } = await supabase
-// .from("sessions")
-// .select("*")
-// .eq("user_id", userId);
-// }
-
-// ❌ BLOCKED: Don't fetch private API keys
-// async function getApiKeys() {
-// // This will fail - table access denied
-// const { data } = await supabase.from("api_keys").select("*");
-// }
-```
-
-### Row-Level Security (RLS)
-
-All tables have RLS policies enforced:
-
-```sql
--- Public tables only allow SELECT
-CREATE POLICY "public_read_only" ON user_analytics
- FOR SELECT
- USING (true);
-
--- Private tables deny all access via public key
-CREATE POLICY "deny_public_access" ON users
- FOR ALL
- USING (false);
-```
-
-The Supabase public key is restricted to these policies at the database level.
-
----
-
-## Safety Guidelines
-
-### ✅ DO
-
-- Query only documented public tables
-- Use `.select("col1, col2")` to specify columns
-- Filter data with `.eq()`, `.gte()`, `.lte()`
-- Aggregate with COUNT, SUM (computed)
-- Cache results to reduce queries
-- Document why you're querying
-
-### ❌ DON'T
-
-- Try to query undocumented tables
-- Select `*` without knowing the schema
-- Use `.select("*")` from unknown sources
-- Attempt to bypass RLS policies
-- Include raw SQL with `rpc()` calls
-- Store or expose API keys in code
-- Log sensitive data from responses
-
----
-
-## Rate Limiting
-
-Supabase has rate limits on public key access:
-- 100 requests/minute per IP
-- 10,000 requests/day per project
-
-**Mitigation:**
-- Batch queries where possible
-- Cache frequently accessed data
-- Use pagination for large result sets
-
----
-
-## Usage in Skills/Agents
-
-When writing agents that use this skill:
-
-```typescript
-import { createClient } from "@supabase/supabase-js";
-
-interface SupabaseAgent {
- queryPublicAnalytics(filters: {
- eventType?: string;
- startDate?: Date;
- endDate?: Date;
- }): Promise<any[]>;
-
- getFeatureStatus(featureName: string): Promise<boolean>;
-
- getPricingTiers(): Promise<any[]>;
-}
-```
-
-Document:
-- What tables you're querying
-- Why you need the data
-- What you do with the results
-- Any caching strategy
-
----
-
-## Troubleshooting
-
-### "401 Unauthorized"
-- Check `SUPABASE_PUBLIC_KEY` is set correctly
-- Verify key hasn't expired
-- Confirm key is the **public** key, not private
-
-### "403 Forbidden"
-- Table has RLS policies that deny your key
-- Check if table is in the "Unsafe Tables" list
-- Contact maintainers if you need access to a public table
-
-### "Connection timeout"
-- Check network connectivity
-- Verify `SUPABASE_URL` is correct
-- Check rate limiting (100 req/min)
-
-### "Column not found"
-- Verify column name matches schema
-- Use `.select("col1, col2")` to list available columns
-- Check if column exists in the Supabase dashboard
-
----
-
-## Related Files
-
-- **Supabase Dashboard:** https://supabase.com/dashboard
-- **Project ID:** Check `.env.local` or Vercel project settings
-- **Row-Level Security:** Supabase console → Authentication → Policies
-- **API Limits:** Supabase console → Settings → API
diff --git a/.pi/skills/supabase-read/supabase-agent.ts b/.pi/skills/supabase-read/supabase-agent.ts
deleted file mode 100644
index 578169220..000000000
--- a/.pi/skills/supabase-read/supabase-agent.ts
+++ /dev/null
@@ -1,266 +0,0 @@
-/**
- * Screenpipe Supabase Read-Only Agent
- *
- * Safe database queries for public data only.
- * Never commit API keys - use Vercel CLI to pull .env.local
- *
- * Usage:
- * vercel env pull
- * const agent = new SupabaseAgent()
- * await agent.getActiveFeatures()
- */
-
-import { createClient } from "@supabase/supabase-js";
-
-interface SupabaseAgent {
- queryPublicAnalytics(filters: {
- eventType?: string;
- startDate?: Date;
- endDate?: Date;
- limit?: number;
- }): Promise<any[]>;
-
- getActiveFeatures(): Promise<Feature[]>;
-
- getPricingTiers(): Promise<PricingTier[]>;
-
- getFeatureStatus(featureName: string): Promise<boolean>;
-}
-
-interface Feature {
- id: string;
- name: string;
- enabled: boolean;
- description: string;
- created_at: string;
- updated_at: string;
-}
-
-interface PricingTier {
- id: string;
- name: string;
- monthly_price: number;
- features: Record<string, boolean>;
- storage_gb: number;
- api_calls_month: number;
- created_at: string;
-}
-
-interface AnalyticsEvent {
- id: string;
- event_type: string;
- event_count: number;
- date: string;
- created_at: string;
-}
-
-/**
- * Initialize Supabase client with public key only.
- * Private keys should NEVER be used in agents/published code.
- */
-function getSupabaseClient() {
- const url = process.env.SUPABASE_URL;
- const publicKey = process.env.SUPABASE_PUBLIC_KEY;
-
- if (!url || !publicKey) {
- throw new Error(
- "Missing Supabase environment variables. Run: vercel env pull"
- );
- }
-
- return createClient(url, publicKey);
-}
-
-/**
- * Query public analytics data with optional filters.
- *
- * Safe example usage:
- * ```
- * const agent = new SupabaseReadAgent()
- * const stats = await agent.queryPublicAnalytics({
- * eventType: 'capture',
- * startDate: new Date('2025-01-01'),
- * endDate: new Date('2025-02-01'),
- * limit: 100
- * })
- * ```
- */
-async function queryPublicAnalytics(filters: {
- eventType?: string;
- startDate?: Date;
- endDate?: Date;
- limit?: number;
-}): Promise<AnalyticsEvent[]> {
- const supabase = getSupabaseClient();
-
- let query = supabase
- .from("user_analytics")
- .select("id, event_type, event_count, date, created_at");
-
- // Build filter conditions
- if (filters.eventType) {
- query = query.eq("event_type", filters.eventType);
- }
-
- if (filters.startDate) {
- query = query.gte("date", filters.startDate.toISOString().split("T")[0]);
- }
-
- if (filters.endDate) {
- query = query.lte("date", filters.endDate.toISOString().split("T")[0]);
- }
-
- // Limit results (default 100, max 1000)
- const limit = Math.min(filters.limit || 100, 1000);
- query = query.limit(limit);
-
- const { data, error } = await query;
-
- if (error) {
- console.error("Supabase query error:", error.message);
- throw new Error(`Failed to fetch analytics: ${error.message}`);
- }
-
- return data || [];
-}
-
-/**
- * Get all active features.
- *
- * Safe example:
- * ```
- * const features = await agent.getActiveFeatures()
- * features.forEach(f => console.log(`${f.name}: ${f.description}`))
- * ```
- */
-async function getActiveFeatures(): Promise<Feature[]> {
- const supabase = getSupabaseClient();
-
- const { data, error } = await supabase
- .from("features")
- .select("id, name, enabled, description, created_at, updated_at")
- .eq("enabled", true)
- .order("created_at", { ascending: false });
-
- if (error) {
- console.error("Supabase query error:", error.message);
- throw new Error(`Failed to fetch features: ${error.message}`);
- }
-
- return data || [];
-}
-
-/**
- * Get all pricing tiers.
- *
- * Safe example:
- * ```
- * const tiers = await agent.getPricingTiers()
- * tiers.forEach(t => console.log(`${t.name}: $${t.monthly_price / 100}`))
- * ```
- */
-async function getPricingTiers(): Promise<PricingTier[]> {
- const supabase = getSupabaseClient();
-
- const { data, error } = await supabase
- .from("pricing_tiers")
- .select(
- "id, name, monthly_price, features, storage_gb, api_calls_month, created_at"
- )
- .order("monthly_price", { ascending: true });
-
- if (error) {
- console.error("Supabase query error:", error.message);
- throw new Error(`Failed to fetch pricing: ${error.message}`);
- }
-
- return data || [];
-}
-
-/**
- * Check if a specific feature is enabled.
- *
- * Safe example:
- * ```
- * const isOcrBetaEnabled = await agent.getFeatureStatus('ocr_beta')
- * if (isOcrBetaEnabled) { console.log('OCR beta is available') }
- * ```
- */
-async function getFeatureStatus(featureName: string): Promise<boolean> {
- const supabase = getSupabaseClient();
-
- const { data, error } = await supabase
- .from("features")
- .select("enabled")
- .eq("name", featureName)
- .single();
-
- if (error) {
- console.warn(`Feature "${featureName}" not found`);
- return false;
- }
-
- return data?.enabled ?? false;
-}
-
-/**
- * ❌ BLOCKED: Example of what NOT to do
- *
- * These operations will FAIL due to Row-Level Security policies:
- */
-
-// ❌ Attempting to query user sessions (private data)
-// async function getUserSessions(userId: string) {
-// const supabase = getSupabaseClient()
-// const { data, error } = await supabase
-// .from('sessions')
-// .select('*')
-// .eq('user_id', userId)
-// // Result: 403 Forbidden - RLS policy blocks access
-// }
-
-// ❌ Attempting to access API keys
-// async function getApiKeys() {
-// const supabase = getSupabaseClient()
-// const { data, error } = await supabase.from('api_keys').select('*')
-// // Result: 403 Forbidden - RLS policy blocks access
-// }
-
-// ❌ Attempting to fetch user logs
-// async function getUserLogs(userId: string) {
-// const supabase = getSupabaseClient()
-// const { data, error } = await supabase
-// .from('logs')
-// .select('*')
-// .eq('user_id', userId)
-// // Result: 403 Forbidden - RLS policy blocks access
-// }
-
-export const SupabaseReadAgent = {
- queryPublicAnalytics,
- getActiveFeatures,
- getPricingTiers,
- getFeatureStatus,
-};
-
-// Example usage (comment out in production)
-if (require.main === module) {
- (async () => {
- console.log("Supabase Read-Only Agent\n");
-
- try {
- const features = await getActiveFeatures();
- console.log("Active features:", features.length);
- features.slice(0, 3).forEach((f) => console.log(` - ${f.name}`));
-
- const tiers = await getPricingTiers();
- console.log("\nPricing tiers:", tiers.length);
- tiers.forEach((t) => console.log(` - ${t.name}: $${t.monthly_price / 100}`));
-
- const analytics = await queryPublicAnalytics({ limit: 5 });
- console.log("\nRecent analytics:", analytics.length, "records");
- } catch (error) {
- console.error("Error:", (error as Error).message);
- }
- })();
-}