test-repo/skills/mission-control-docs/SKILL.md

268 lines
5.9 KiB
Markdown

---
name: mission-control-docs
description: Full CRUD operations for Mission Control Documents. Create, read, update, delete documents. Uses Mission Control API with machine token authentication.
---
# mission-control-docs
**Module Skill** - Complete document management for Mission Control via API.
## Purpose
Provides all operations needed to work with Mission Control documents: create, read, update, delete, list, and search. Uses Mission Control API (not direct Supabase).
## Authentication
Uses **machine token** for server-to-server API calls:
```bash
export MC_MACHINE_TOKEN="50cd5e8fe3f895353f97c9ee64052c0b689b4eedf79259746413734d0a163cf8"
export MC_API_URL="https://mission-control.twisteddevices.com/api"
```
**Architecture:** Skills → API (with machine token) → Database
This follows the API-centric pattern where all business logic lives in API routes.
## Usage
```bash
source ~/.agents/skills/mission-control-docs/lib/docs.sh
# Create document
DOC_ID=$(mc_doc_create \
--title "Article Title" \
--content "$CONTENT" \
--folder "Research/AI & Agents/")
# Get document
mc_doc_get "$DOC_ID"
# List documents
mc_doc_list --folder "Research/"
```
## Functions
### Document CRUD
#### `mc_doc_create([options])`
Create a new document.
**Options:**
- `--title` - Document title (required)
- `--content` - Document content (required)
- `--folder` - Folder path (default: auto-detected)
- `--tags` - Tags as JSON array string (default: auto-detected)
- `--type` - Document type (default: markdown)
- `--description` - Description (optional)
**Returns:** Document ID on success
**Example:**
```bash
DOC_ID=$(mc_doc_create \
--title "API Design Patterns" \
--content "$SUMMARY_CONTENT" \
--folder "Research/Tools & Tech/" \
--tags '["api", "design", "reference"]')
```
**Auto-categorization:** If folder not specified, detects based on content keywords:
- `Research/AI & Agents/` - AI, agent, LLM, Claude, OpenClaw, GPT
- `Research/iOS Development/` - Swift, iOS, Xcode, Apple, SwiftUI
- `Research/Business & Marketing/` - SaaS, business, startup, marketing
- `Research/Tools & Tech/` - tool, library, API, SDK, framework
- `Research/Tutorials/` - tutorial, guide, how-to, walkthrough
- `Research/` - Default
#### `mc_doc_get(DOC_ID)`
Get document by ID.
**Returns:** Document JSON
**Example:**
```bash
DOC=$(mc_doc_get "a1b2c3d4-...")
echo "$DOC" | jq -r '.title'
```
#### `mc_doc_list([filters])`
List documents with optional filters.
**Filters:**
- `--folder` - Filter by folder path
- `--tags` - Filter by tag
- `--search` - Search in title/content
- `--limit` - Max results (default: 50)
- `--json` - Output as JSON
**Example:**
```bash
# List all in folder
mc_doc_list --folder "Research/AI & Agents/"
# Search
mc_doc_list --search "OpenClaw"
# Get JSON for processing
mc_doc_list --folder "Research/" --json
```
#### `mc_doc_update(DOC_ID, [options])`
Update document fields.
**Parameters:**
- `DOC_ID` - Document UUID
- `--title` - New title
- `--content` - New content
- `--folder` - New folder
- `--tags` - New tags (JSON array)
- `--description` - New description
**Example:**
```bash
mc_doc_update "$DOC_ID" \
--title "Updated Title" \
--tags '["research", "ai", "updated"]'
```
#### `mc_doc_delete(DOC_ID)`
Delete document permanently.
**Example:**
```bash
mc_doc_delete "$DOC_ID"
```
### Search & Discovery
#### `mc_doc_search(QUERY, [LIMIT])`
Search documents by title or content.
**Parameters:**
- `QUERY` - Search term
- `LIMIT` - Max results (default: 20)
**Example:**
```bash
# Search for OpenClaw
mc_doc_search "OpenClaw" 10
```
#### `mc_doc_folder_list()`
List all unique folders.
**Example:**
```bash
mc_doc_folder_list
```
### Auto-detection
#### `_detect_folder(CONTENT)`
Auto-detect folder based on content keywords.
**Example:**
```bash
FOLDER=$(_detect_folder "$CONTENT")
echo "Detected folder: $FOLDER"
```
#### `_detect_tags(CONTENT)`
Auto-detect tags based on content keywords.
**Returns:** JSON array of tags
**Example:**
```bash
TAGS=$(_detect_tags "$CONTENT")
echo "Detected tags: $TAGS"
```
## File Structure
```
~/.agents/skills/mission-control-docs/
├── SKILL.md # This documentation
└── lib/
└── docs.sh # All document functions
```
## Integration Example
Complete workflow:
```bash
# Set authentication
export MC_MACHINE_TOKEN="50cd5e8fe3f895353f97c9ee64052c0b689b4eedf79259746413734d0a163cf8"
export MC_API_URL="https://mission-control.twisteddevices.com/api"
source ~/.agents/skills/mission-control-docs/lib/docs.sh
# Research summary from URL
SUMMARY=$(cat << 'EOF'
## Scrapling: Modern Web Scraping Framework
Scrapling is a Python web scraping framework with:
- Adaptive parsing
- Anti-bot bypass
- Full crawling capabilities
**Use Cases:**
- E-commerce monitoring
- Content aggregation
- SEO auditing
**Links:**
- GitHub: https://github.com/D4Vinci/Scrapling
- Docs: https://scrapling.readthedocs.io
EOF
)
# Create document with auto-detection
DOC_ID=$(mc_doc_create \
--title "Scrapling: Web Scraping Framework" \
--content "$SUMMARY" \
--description "Auto-research from URL: https://github.com/D4Vinci/Scrapling")
echo "Document created: $DOC_ID"
# Verify
echo "=== Document Created ==="
mc_doc_get "$DOC_ID" | jq -r '.title, .folder, .tags'
```
## CLI Alternative
For interactive/command-line use, use the Mission Control CLI:
```bash
# Set auth for CLI
export MC_MACHINE_TOKEN="50cd5e8fe3f895353f97c9ee64052c0b689b4eedf79259746413734d0a163cf8"
export MC_API_URL="https://mission-control.twisteddevices.com/api"
cd /Users/mattbruce/Documents/Projects/OpenClaw/Web/mission-control
# List documents
./scripts/mc.sh document list
# Get specific document
./scripts/mc.sh document get $DOC_ID
```
**Note:** The skill library and CLI both use the same API endpoints with machine token authentication.
---
**Note:** This is a low-level module skill. Used by orchestrator skills like `url-research-to-documents-and-tasks`, not directly by users.