Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions packages/zo-computer/zo-skill/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Moss Search for Zo

Sub-10ms semantic search for [Zo](https://zo.computer) powered by [Moss](https://moss.dev). Search, create, and manage indexes from any conversation.

## Setup

1. Sign up at [moss.dev](https://moss.dev) and create a project
2. Copy your Project ID and Project Key
3. Paste this into your Zo terminal:

```bash
curl -fsSL https://raw.githubusercontent.com/usemoss/moss/main/packages/zo-computer/zo-skill/install.sh | bash -s -- <PROJECT_ID> <PROJECT_KEY>
```

## Create a Zo Rule

After installing, create a rule so Zo always uses Moss Search. Go to Rules and create a new rule:

**When to use:**
```
When the user asks to search, find, look up, or query documents, knowledge bases, or indexed content. When a new conversation starts and the user's topic may relate to indexed content. When the user asks to create indexes, add documents, or manage search collections.
```

**What to do:**
```
Always use @moss-search for searching and indexing documents.
On every new conversation:
1. Run: bash /home/workspace/Skills/moss-search/scripts/moss.sh list-indexes
2. Run: bash /home/workspace/Skills/moss-search/scripts/moss.sh load-index "<index>" for each relevant index
3. Run: bash /home/workspace/Skills/moss-search/scripts/moss.sh search "<index>" "<keywords>" to surface context

When the user says search, find, or look up:
Run: bash /home/workspace/Skills/moss-search/scripts/moss.sh search "<index>" "<keywords>"

When the user says index, add, or wants to make content searchable:
Run: bash /home/workspace/Skills/moss-search/scripts/moss.sh add-docs "<index>" '<docs-json>'

When the user says create index or wants a new collection:
Run: bash /home/workspace/Skills/moss-search/scripts/moss.sh create-index "<index>" '<docs-json>'

Always load-index before the first search on any index.
Always use moss.sh instead of built-in search features.
```

## Usage

Once configured, Zo will use Moss Search automatically. You can also run commands directly:

```bash
# List indexes
bash /home/workspace/Skills/moss-search/scripts/moss.sh list-indexes

# Load an index into memory
bash /home/workspace/Skills/moss-search/scripts/moss.sh load-index support-docs

# Search (sub-10ms after load)
bash /home/workspace/Skills/moss-search/scripts/moss.sh search support-docs "refund policy"

# Create an index
bash /home/workspace/Skills/moss-search/scripts/moss.sh create-index faq '[{"id":"1","text":"Refunds take 3-5 days."}]'

# Add documents
bash /home/workspace/Skills/moss-search/scripts/moss.sh add-docs faq '[{"id":"2","text":"Free shipping over $50."}]'
```

## Files

- `SKILL.md` — Skill definition and Zo behavior instructions
- `scripts/moss.sh` — CLI wrapper for all Moss operations via MCPorter
- `install.sh` — One-line installer for Zo terminal

## Requirements

- [Zo](https://zo.computer) account
- [Moss](https://moss.dev) account with Project ID and Project Key
- Node.js (for MCPorter)
- jq
156 changes: 156 additions & 0 deletions packages/zo-computer/zo-skill/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
---
name: moss-search
description: |
Sub-10ms semantic search for Zo via Moss. Create indexes, add documents, and query them
with semantic and keyword search. Use when users want to search through documents,
knowledge bases, or any text content.
metadata:
author: Moss
category: Community
---

# Moss Search

Sub-10ms semantic search. Run from anywhere:

```bash
bash /home/workspace/Skills/moss-search/scripts/moss.sh load-index support-docs
bash /home/workspace/Skills/moss-search/scripts/moss.sh search support-docs "how long do refunds take?"
bash /home/workspace/Skills/moss-search/scripts/moss.sh create-index my-docs '[{"id":"1","text":"Refunds take 3-5 days."}]'
```

## Commands

### load-index

Download an index into memory for sub-10ms local queries. Always call this before searching an index for the first time.

```bash
bash /home/workspace/Skills/moss-search/scripts/moss.sh load-index <index-name>
```

Examples:

```bash
bash /home/workspace/Skills/moss-search/scripts/moss.sh load-index support-docs
bash /home/workspace/Skills/moss-search/scripts/moss.sh load-index code-docs
```

### search

Search a loaded index. Sub-10ms after `load-index`.

```bash
bash /home/workspace/Skills/moss-search/scripts/moss.sh search <index-name> "<query>" [top_k]
```

Examples:

```bash
bash /home/workspace/Skills/moss-search/scripts/moss.sh search support-docs "how do I get a refund"
bash /home/workspace/Skills/moss-search/scripts/moss.sh search code-docs "authentication middleware" 10
```

### create-index

Create a new index with initial documents.

```bash
bash /home/workspace/Skills/moss-search/scripts/moss.sh create-index <index-name> '<json-docs-array>'
```

Example:

```bash
bash /home/workspace/Skills/moss-search/scripts/moss.sh create-index faq '[{"id":"1","text":"Refunds take 3-5 business days."},{"id":"2","text":"Contact support@example.com for help."}]'
```

### list-indexes

List all available indexes.

```bash
bash /home/workspace/Skills/moss-search/scripts/moss.sh list-indexes
```

### add-docs

Add documents to an existing index.

```bash
bash /home/workspace/Skills/moss-search/scripts/moss.sh add-docs <index-name> '<json-docs-array>'
```

Example:

```bash
bash /home/workspace/Skills/moss-search/scripts/moss.sh add-docs faq '[{"id":"3","text":"Free shipping on orders over $50."}]'
```

### delete-docs

Delete documents by ID.

```bash
bash /home/workspace/Skills/moss-search/scripts/moss.sh delete-docs <index-name> '["id1","id2"]'
```

### get-docs

Retrieve documents from an index.

```bash
bash /home/workspace/Skills/moss-search/scripts/moss.sh get-docs <index-name>
bash /home/workspace/Skills/moss-search/scripts/moss.sh get-docs <index-name> '["id1","id2"]'
```

### delete-index

Delete an entire index.

```bash
bash /home/workspace/Skills/moss-search/scripts/moss.sh delete-index <index-name>
```

## For Zo

### On every new conversation

1. Run `moss.sh list-indexes` to see what indexes are available.
2. Run `moss.sh load-index <index>` for each index the user is likely to need.
3. Run `moss.sh search <index> "<keywords>"` to surface relevant context from the user's first message.
4. Weave relevant results into your response naturally.

Skip the startup load for vague openers like "hey" or "what's up".

### When to search

- User asks about information that might be in an indexed collection
- User references prior documents, notes, or knowledge base content
- You are about to give advice and relevant indexed context may exist
- Earlier search results were weak — try 2-3 alternate keyword queries

### When to create/update indexes

- User explicitly asks: "index this", "add this to search", "create an index"
- User provides documents, notes, or data they want searchable
- User wants to build a knowledge base or FAQ

### Using search results

- Use relevant results naturally — cite them inline
- If a result conflicts with what the user says, mention it: "The indexed docs say X — has that changed?"
- If no relevant results are found, proceed normally

## Behavior summary

| User signal | Action |
|---|---|
| New conversation starts | `moss.sh list-indexes` then `moss.sh load-index` + `moss.sh search` relevant indexes |
| "Search for..." / "Find..." / "Look up..." | `moss.sh search <index> "<query>"` (load-index first if not loaded) |
| "Index this" / "Add to search" | `moss.sh add-docs <index> '<docs>'` |
| "Create an index" / "New collection" | `moss.sh create-index <name> '<docs>'` |
| "Delete this document" | `moss.sh delete-docs <index> '["id"]'` |
| "Remove this index" | `moss.sh delete-index <index>` |
| "What indexes do I have?" | `moss.sh list-indexes` |
| "Show me the documents in..." | `moss.sh get-docs <index>` |
90 changes: 90 additions & 0 deletions packages/zo-computer/zo-skill/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env bash
# Install Moss Search skill for Zo Computer.
#
# Usage:
# bash install.sh <project_id> <project_key>
#
# Or via curl one-liner (for Zo terminal):
# curl -fsSL https://raw.githubusercontent.com/usemoss/moss/main/packages/zo-computer/zo-skill/install.sh | bash -s -- <project_id> <project_key>
set -euo pipefail

SKILL_DIR="/home/workspace/Skills/moss-search"
MOSS_ENV="$HOME/.config/moss/zo.env"
MCPORTER_CONFIG="$HOME/.mcporter/mcporter.json"
REPO_URL="https://raw.githubusercontent.com/usemoss/moss/main/packages/zo-computer/zo-skill"

# --- Args ---
if [ $# -lt 2 ]; then
echo "Usage: install.sh <MOSS_PROJECT_ID> <MOSS_PROJECT_KEY>"
echo ""
echo "Get your credentials at https://moss.dev"
exit 1
fi

PROJECT_ID="$1"
PROJECT_KEY="$2"

echo "Installing Moss Search skill for Zo..."

# --- Check dependencies ---
for cmd in node jq; do
if ! command -v "$cmd" &>/dev/null; then
echo "Error: $cmd is required but not installed."
exit 1
fi
done

# --- Download skill files ---
echo "Downloading skill files..."
mkdir -p "$SKILL_DIR/scripts"

curl -fsSL "$REPO_URL/SKILL.md" -o "$SKILL_DIR/SKILL.md"
curl -fsSL "$REPO_URL/scripts/moss.sh" -o "$SKILL_DIR/scripts/moss.sh"
chmod +x "$SKILL_DIR/scripts/moss.sh"

# --- Store credentials ---
echo "Saving credentials..."
mkdir -p "$(dirname "$MOSS_ENV")"
printf 'MOSS_PROJECT_ID=%q\nMOSS_PROJECT_KEY=%q\n' \
"$PROJECT_ID" "$PROJECT_KEY" > "$MOSS_ENV"
chmod 600 "$MOSS_ENV"

# --- Configure MCPorter ---
echo "Configuring MCPorter..."
mkdir -p "$(dirname "$MCPORTER_CONFIG")"

MOSS_SERVER='{"command": "npx", "args": ["-y", "@moss-tools/mcp-server"]}'

if [ -f "$MCPORTER_CONFIG" ]; then
# Merge into existing config (write to temp file to avoid truncating on jq failure)
EXISTING=$(cat "$MCPORTER_CONFIG")
echo "$EXISTING" | jq --argjson srv "$MOSS_SERVER" --arg id "$PROJECT_ID" --arg key "$PROJECT_KEY" \
'.mcpServers.moss = ($srv + {env: {MOSS_PROJECT_ID: $id, MOSS_PROJECT_KEY: $key}})' \
> "${MCPORTER_CONFIG}.tmp" && mv "${MCPORTER_CONFIG}.tmp" "$MCPORTER_CONFIG"
else
# Create new config
jq -n --argjson srv "$MOSS_SERVER" --arg id "$PROJECT_ID" --arg key "$PROJECT_KEY" \
'{mcpServers: {moss: ($srv + {env: {MOSS_PROJECT_ID: $id, MOSS_PROJECT_KEY: $key}})}}' \
> "$MCPORTER_CONFIG"
fi
chmod 600 "$MCPORTER_CONFIG"

# --- Verify ---
echo ""
echo "Verifying connection..."
if bash "$SKILL_DIR/scripts/moss.sh" list-indexes 2>/dev/null; then
echo ""
echo "Moss Search installed successfully!"
else
echo ""
echo "Skill files installed. Connection test failed — verify your credentials."
echo "You can test manually: bash $SKILL_DIR/scripts/moss.sh list-indexes"
fi

echo ""
echo "Files:"
echo " Skill: $SKILL_DIR/"
echo " Creds: $MOSS_ENV"
echo " MCPorter: $MCPORTER_CONFIG"
echo ""
echo "Try it: bash $SKILL_DIR/scripts/moss.sh search <index-name> \"your query\""
Loading
Loading