Skip to content
Open
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
68 changes: 68 additions & 0 deletions Community/huggingface-hub/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
name: huggingface-hub
description: Access Hugging Face Hub models, datasets, and spaces via the huggingface_hub Python library. Use when you need to list, search, download, or upload HF assets.
compatibility: Created for Zo Computer
metadata:
author: jaknyfe.zo.computer
---

# Hugging Face Hub Skill

Interact with Hugging Face Hub — browse models/datasets/spaces, download files, upload artifacts, and more.

## Prerequisites

Install the library:
```bash
pip install huggingface_hub
```

Save your HF token to [Settings > Advanced](/?t=settings&s=advanced) as `HF_TOKEN` (get one at https://huggingface.co/settings/tokens).

## Usage

```bash
python3 /home/workspace/Skills/huggingface-hub/scripts/hf_hub.py <command> [options]
```

### Commands

| Command | Description |
|---------|-------------|
| `list-models` | List models. Options: `--search`, `--sort`, `--direction`, `--limit` |
| `list-datasets` | List datasets. Options: `--search`, `--sort`, `--direction`, `--limit` |
| `list-spaces` | List spaces. Options: `--search`, `--sort`, `--direction`, `--limit` |
| `model-info` | Get model info. Options: `--model` |
| `dataset-info` | Get dataset info. Options: `--dataset` |
| `download-file` | Download a file from a repo. Options: `--repo-id`, `--filename`, `--revision` |
| `upload-file` | Upload a file. Options: `--local-path`, `--repo-id`, `--repo-type`, `--path-in-repo` |
| `whoami` | Show authenticated user info |

### Examples

```bash
# Search for text-to-image models
python3 .../hf_hub.py list-models --search "text-to-image" --limit 10

# Download a model file
python3 .../hf_hub.py download-file --repo-id "stabilityai/stable-diffusion-xl-base-1.0" --filename "pytorch_model.bin"

# Upload a file
python3 .../hf_hub.py upload-file --local-path ./model.pt --repo-id "your-username/my-model" --repo-type "model"

# List top-rated datasets
python3 .../hf_hub.py list-datasets --sort "likes" --direction desc --limit 5
```

## API Reference

This skill wraps `huggingface_hub`. Key functions:
- `list_models`, `list_datasets`, `list_spaces` — browse hub
- `huggingface_hub` — authentication and file ops
- `InferenceClient` — run inference on hosted models/spaces

## Notes

- Downloads cache to `~/.cache/huggingface/`
- `repo-type` values: `model`, `dataset`, `space`
- Default revision is `main`
168 changes: 168 additions & 0 deletions Community/huggingface-hub/scripts/hf_hub.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
#!/usr/bin/env /usr/local/bin/python3
"""Hugging Face Hub CLI tool. Usage: python3 hf_hub.py <command> [options]"""

import argparse
import os
import sys
from pathlib import Path

try:
from huggingface_hub import (
HfApi, hf_hub_download,
list_models, list_datasets, list_spaces,
model_info, dataset_info,
)
except ImportError:
sys.stderr.write("ERROR: huggingface_hub not installed. Run: pip install huggingface_hub\n")
sys.exit(1)


def get_token() -> str:
token = os.environ.get("HF_TOKEN", "")
if not token:
try:
with open("/etc/secrets/HF_TOKEN", "r") as f:
token = f.read().strip()
except Exception:
pass
return token


def get_api() -> HfApi:
token = get_token()
return HfApi(token=token if token else None)


def cmd_whoami(args):
api = get_api()
info = api.whoami()
print(f"Username: {info['name']}")
print(f"Full name: {info.get('fullname', 'N/A')}")
print(f"Email: {info.get('email', 'N/A')}")
print(f"Organizations: {', '.join(info.get('orgs', []))}")


def cmd_list_models(args):
kwargs = {"sort": args.sort, "direction": args.direction, "limit": args.limit}
if args.search:
kwargs["search"] = args.search
kwargs = {k: v for k, v in kwargs.items() if v is not None}
for m in list_models(**kwargs):
print(f"{m.id} likes={m.likes}")


def cmd_list_datasets(args):
kwargs = {"sort": args.sort, "direction": args.direction, "limit": args.limit}
if args.search:
kwargs["search"] = args.search
kwargs = {k: v for k, v in kwargs.items() if v is not None}
for d in list_datasets(**kwargs):
print(f"{d.id} likes={d.likes}")


def cmd_list_spaces(args):
kwargs = {"sort": args.sort, "direction": args.direction, "limit": args.limit}
if args.search:
kwargs["search"] = args.search
kwargs = {k: v for k, v in kwargs.items() if v is not None}
for s in list_spaces(**kwargs):
print(f"{s.id} likes={s.likes}")


def cmd_model_info(args):
info = model_info(args.model)
print(f"Model ID: {info.id}")
print(f"Downloads: {getattr(info, 'downloads', 'N/A')}")
print(f"Likes: {info.likes}")
print(f"Tags: {', '.join(info.tags)}")
print(f"Pipeline tag: {getattr(info, 'pipeline_tag', 'N/A')}")
print(f"Created at: {info.created_at}")
print(f"Last modified: {info.last_modified}")


def cmd_dataset_info(args):
info = dataset_info(args.dataset)
print(f"Dataset ID: {info.id}")
print(f"Downloads: {getattr(info, 'downloads', 'N/A')}")
print(f"Likes: {info.likes}")
print(f"Tags: {', '.join(info.tags)}")
print(f"Created at: {info.created_at}")
print(f"Last modified: {info.last_modified}")


def cmd_download_file(args):
path = hf_hub_download(
repo_id=args.repo_id,
filename=args.filename,
revision=args.revision or "main",
token=get_token() or None,
)
print(path)


def cmd_upload_file(args):
api = get_api()
api.upload_file(
path_or_fileobj=args.local_path,
path_in_repo=args.path_in_repo or Path(args.local_path).name,
repo_id=args.repo_id,
repo_type=args.repo_type or "model",
token=get_token() or None,
)
print(f"Uploaded {args.local_path} to {args.repo_id}/{args.path_in_repo}")


def build_parser():
parser = argparse.ArgumentParser(description="Hugging Face Hub CLI")
sub = parser.add_subparsers(dest="command")
sub.add_parser("whoami", help="Show authenticated user info")
p = sub.add_parser("list-models", help="List models")
p.add_argument("--search")
p.add_argument("--sort", default=None)
p.add_argument("--direction", default=None)
p.add_argument("--limit", type=int, default=20)
p = sub.add_parser("list-datasets", help="List datasets")
p.add_argument("--search")
p.add_argument("--sort", default=None)
p.add_argument("--direction", default=None)
p.add_argument("--limit", type=int, default=20)
p = sub.add_parser("list-spaces", help="List spaces")
p.add_argument("--search")
p.add_argument("--sort", default=None)
p.add_argument("--direction", default=None)
p.add_argument("--limit", type=int, default=20)
p = sub.add_parser("model-info", help="Get model info")
p.add_argument("--model", required=True)
p = sub.add_parser("dataset-info", help="Get dataset info")
p.add_argument("--dataset", required=True)
p = sub.add_parser("download-file", help="Download a file from a repo")
p.add_argument("--repo-id", required=True)
p.add_argument("--filename", required=True)
p.add_argument("--revision", default=None)
p = sub.add_parser("upload-file", help="Upload a file")
p.add_argument("--local-path", required=True)
p.add_argument("--repo-id", required=True)
p.add_argument("--repo-type", default="model")
p.add_argument("--path-in-repo", default=None)
return parser


COMMANDS = {
"whoami": cmd_whoami,
"list-models": cmd_list_models,
"list-datasets": cmd_list_datasets,
"list-spaces": cmd_list_spaces,
"model-info": cmd_model_info,
"dataset-info": cmd_dataset_info,
"download-file": cmd_download_file,
"upload-file": cmd_upload_file,
}


if __name__ == "__main__":
parser = build_parser()
args = parser.parse_args()
if args.command is None:
parser.print_help()
sys.exit(1)
COMMANDS[args.command](args)
11 changes: 11 additions & 0 deletions Community/zo-goal-loop/DISPLAY.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "zo-goal-loop",
"displayName": "Zo Goal Loop",
"description": "Recreates Claude's /goal and /loop for autonomous task execution",
"category": "Utility",
"version": "1.0.0",
"scripts": {
"goal": "bun run /home/workspace/Skills/zo-goal-loop/scripts/goal.ts",
"loop": "bun run /home/workspace/Skills/zo-goal-loop/scripts/loop.ts"
}
}
59 changes: 59 additions & 0 deletions Community/zo-goal-loop/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
name: zo-goal-loop
description: Recreates Claude Code's /goal and /loop commands — define a completion condition and let Zo work autonomously until it's achieved. Supports iterative task execution with evaluator model checking for completion.
metadata:
author: jaknyfe.zo.computer
category: Utility
display-name: Zo Goal Loop
compatibility: Created for Zo Computer. Requires ZO_CLIENT_IDENTITY_TOKEN environment variable.
---

# Zo Goal Loop

Run Zo autonomously until a goal is achieved.

## Usage

### /goal — Work until condition met

```bash
bun run /home/workspace/Skills/zo-goal-loop/scripts/goal.ts "completion condition here"
```

Examples:
- `"All tests pass and lint is clean"`
- `"Build completes successfully"`
- `"Find 3 working solutions to the problem"`

Optional args:
- `--max-turns=<n>` — Stop after N turns (default: unlimited)
- `--save-to=<file.md>` — Log progress to file

### /loop — Run prompt repeatedly

```bash
bun run /home/workspace/Skills/zo-goal-loop/scripts/loop.ts "prompt" [options]
```

Options:
- `--interval=<ms>` — Wait between iterations (default: 5000)
- `--max-iterations=<n>` — Stop after N loops (default: unlimited)
- `--until="<condition>"` — Stop when condition is met (file check, output match, etc.)

## How it works

1. `/goal` calls the Zo `/zo/ask` API with the task
2. Each turn runs the task model
3. After each turn, an evaluator model (Haiku) checks if the condition is met
4. If not met, generates next action and continues
5. If met, reports completion and any artifacts

## Verification commands

- Check progress: `cat /tmp/zo-goal-progress.log`
- View current goal: `cat /tmp/current-goal.txt`
- Force stop: `rm /tmp/current-goal.txt`

## Requirements

- `ZO_CLIENT_IDENTITY_TOKEN` must be available in environment
Loading