davybot-market-cli 0.1.1
CLI and SDK for DavyBot Market - AI Agent Resources
Requires Python: >=3.12

# DavyBot Market - CLI & SDK

Unified CLI and Python SDK for DavyBot Market - AI Agent Resources.

## Installation

### Using uv (Recommended)

```bash
# Install from source
cd davybot-market-cli
uv sync

# Run CLI
uv run python -m davybot_market_cli.cli --help
```

### Using pip

```bash
pip install davybot-market-cli
```

Or install from source:

```bash
cd davybot-market-cli
pip install -e .
```

## Configuration

### Environment Variables

- `DAVYBOT_API_URL`: API base URL (default: `http://localhost:8000/api/v1`)
- `DAVYBOT_API_KEY`: API key for authentication

### Example Configuration

```bash
# For local development
export DAVYBOT_API_URL="http://localhost:9410/api/v1"

# For production server
export DAVYBOT_API_URL="http://www.davybot.com/market/api/v1"
```

## CLI Usage

> **Note:** The CLI is available as both `davy-market` (primary command) and `dawei-market` (alias). Both commands work identically.

### Search Resources

```bash
# Search all resources
davy-market search "web scraping"

# Filter by type (skill, agent, mcp, knowledge)
davy-market search "agent" --type agent

# Limit results
davy-market search "data" --limit 10

# JSON output
davy-market search "ml" --output json
```

### View Resource Info

```bash
# Get resource details (must use full resource URI)
davy-market info skill://github.com/anthropics/skills/skills/webapp-testing

# JSON output
davy-market info skill://github.com/user/repo/skill-name --output json
```

**Important:** Resource URIs must use the full format:
- `skill://<full-resource-id>`
- `agent://<full-resource-id>`
- `mcp://<full-resource-id>`
- `knowledge://<full-resource-id>`

Example full resource IDs:
- `skill://github.com/anthropics/skills/skills/webapp-testing`
- `agent://davybot.com/patent-team/patent-engineer`
- `mcp://github.com/modelcontextprotocol/servers/git`

### Install Resources

```bash
# Install from marketplace (must use full resource URI)
davy-market install skill://github.com/anthropics/skills/skills/webapp-testing

# Install to specific directory
davy-market install agent://davybot.com/patent-team --output ./my-agents

# Install by full resource ID
davy-market install github.com/anthropics/skills/skills/webapp-testing
```

#### External Protocol Support

The CLI supports multiple installation protocols beyond the marketplace:

```bash
# Local filesystem path
davy-market install skill@/path/to/skill --output ./my-skills

# HTTP/HTTPS URL (downloads and extracts zip files)
davy-market install skill@http://server_url/skill.zip --output ./skills
davy-market install agent@https://example.com/agent.zip

# Git repository (clones and installs)
davy-market install plugin@git@github.com:user/repo.git/plugin_dir --output ./plugins

# Git repository with specific branch
davy-market install skill@git@github.com:user/repo.git --branch main

# File protocol (local or network file shares)
davy-market install agent@file://server/share/agent_dir --output ./agents
```

**Supported Protocols:**
- `local` - Local filesystem paths
- `http`/`https` - Download from web servers
- `git` - Clone from Git repositories
- `file` - File protocol for network shares

### Publish Resources

```bash
# Publish a skill
davy-market publish skill ./my-skill --name "web-scraper" --description "Scrapes web data"

# Publish with tags
davy-market publish agent ./my-agent --name "data-analyst" --tag data --tag ml

# Publish with metadata
davy-market publish skill ./skill --name "my-skill" --metadata metadata.json
```

### Plugin Management

```bash
# List installed plugins in workspace
davy-market plugin list --workspace /path/to/workspace

# Filter by type
davy-market plugin list --workspace /path/to/workspace --type plugin

# Table output format
davy-market plugin list --workspace /path/to/workspace --output table
```

### Health Check

```bash
# Check API status
davy-market health
```

## Python SDK Usage

### Basic Usage

```python
from davybot_market_cli import DavybotMarketClient

# Initialize client
with DavybotMarketClient() as client:
    # Check API health
    health = client.health()
    print(f"API Status: {health['status']}")

    # Search for resources
    results = client.search("web scraping")
    print(f"Found {results['total']} resources")

    # List all skills
    skills = client.list_skills()
    for skill in skills['items']:
        print(f"- {skill['name']}: {skill['description']}")

    # Get specific resource
    skill = client.get_skill("skill-id-here")
    print(f"Skill: {skill['name']} v{skill['version']}")

    # Download a resource
    client.download("skill", "skill-id", "./downloads")
```

### Async Usage

```python
import asyncio
from davybot_market_cli import DavybotMarketClient

async def main():
    async with DavybotMarketClient() as client:
        # Search resources
        results = await client.search("machine learning")
        print(f"Found {results['total']} results")

asyncio.run(main())
```

### Create Resources

```python
with DavybotMarketClient() as client:
    # Create a skill
    skill = client.create_skill(
        name="web-scraper",
        description="Scrapes web data efficiently",
        files={
            "scraper.py": "# Your scraper code here",
            "config.json": '{"timeout": 30}',
        },
        tags=["web", "scraping", "data"],
        author="Your Name"
    )
    print(f"Created skill with ID: {skill['id']}")
```

### Download Resources

```python
with DavybotMarketClient() as client:
    # Download to specific directory
    client.download("skill", "skill-id", "./my-skills")

    # Download with specific format
    client.download("agent", "agent-id", "./agents", format="python")

    # Download specific version
    client.download("skill", "skill-id", "./skills", version="2.0.0")
```

### Ratings and Reviews

```python
with DavybotMarketClient() as client:
    # Rate a resource
    client.rate_resource("resource-id", score=5, comment="Excellent!")

    # Get all ratings
    ratings = client.get_resource_ratings("resource-id")

    # Get average rating
    avg = client.get_average_rating("resource-id")
    print(f"Average: {avg['average_rating']} ({avg['total_ratings']} ratings)")
```

## Client Options

```python
# Custom API URL
client = DavybotMarketClient(base_url="https://api.market.davybot.ai/api/v1")

# With API key
client = DavybotMarketClient(api_key="your-api-key")

# With custom timeout
client = DavybotMarketClient(timeout=60.0)

# Disable SSL verification (not recommended for production)
client = DavybotMarketClient(verify_ssl=False)
```

## Commands Reference

| Command | Description |
|---------|-------------|
| `davy-market search QUERY` | Search for resources |
| `davy-market info RESOURCE_URI` | View resource details |
| `davy-market install RESOURCE_URI` | Install a resource |
| `davy-market publish TYPE PATH` | Publish a new resource |
| `davy-market plugin list --workspace PATH` | List installed plugins |
| `davy-market health` | Check API health |
| `davy-market --help` | Show help message |
| `davy-market --version` | Show version |

## Examples

### Complete CLI Workflow

```bash
# Configure API URL
export DAVYBOT_API_URL="http://www.davybot.com/market/api/v1"

# Search for a skill
davy-market search "web testing" --type skill

# View details
davy-market info skill://github.com/anthropics/skills/skills/webapp-testing

# Install
davy-market install skill://github.com/anthropics/skills/skills/webapp-testing --output ./skills
```

### Publishing a New Skill

```bash
# Create your skill
mkdir my-skill
cd my-skill

# Create skill.py
cat > skill.py << 'EOF'
def execute(input_data):
    """Execute the skill."""
    return {"result": "success"}
EOF

# Publish to market
davy-market publish skill . --name "my-skill" --description "My awesome skill"
```

### Python SDK Integration

```python
from davybot_market_cli import DavybotMarketClient

# Integrate into your application
def find_and_download_skill(query: str, output_dir: str):
    with DavybotMarketClient() as client:
        # Search
        results = client.search(query, resource_type="skill", limit=1)
        if not results['results']:
            print("No skills found")
            return

        skill = results['results'][0]
        print(f"Found: {skill['name']}")

        # Download
        client.download("skill", skill['id'], output_dir)
        print(f"Downloaded to {output_dir}")
```

### Managing Workspace Plugins

```bash
# Create a workspace
mkdir my-workspace && cd my-workspace

# Install a plugin
davy-market install plugin@git@github.com:user/plugin.git --output .dawei/plugins

# List installed plugins
davy-market plugin list --workspace . --output json

# List only plugins (not skills/agents)
davy-market plugin list --workspace . --type plugin
```

## Error Handling

```python
from davybot_market_cli import (
    DavybotMarketClient,
    AuthenticationError,
    NotFoundError,
    ValidationError,
    APIError
)

with DavybotMarketClient() as client:
    try:
        skill = client.get_skill("invalid-id")
    except NotFoundError:
        print("Resource not found!")
    except AuthenticationError:
        print("Invalid API key!")
    except APIError as e:
        print(f"API error: {e}")
```

## Common Issues

### Invalid Resource URI Format

If you see this error:
```
Invalid resource URI format: 'skill-name'

Please use one of the following formats:
  - skill://<resource-id>
  - agent://<resource-id>
  - mcp://<resource-id>
  - knowledge://<resource-id>
```

**Solution:** Always use the full resource ID format:
```bash
# ❌ Wrong
davy-market install skill-name

# ✅ Correct
davy-market install skill://github.com/user/repo/skill-name
```

### Finding Resource IDs

Use the `search` command to find full resource IDs:
```bash
davy-market search "query" --output json | jq '.results[].id'
```

Or use the `info` command to copy the installation command from the output.

## License

MIT