From 372e549ea6de8bade8626fc9af8e45ed667302aa Mon Sep 17 00:00:00 2001 From: Rehaan Ahmad <34905129+rehaanahmad2013@users.noreply.github.com> Date: Tue, 7 Jul 2026 22:53:23 -0700 Subject: [PATCH] chore: hf (#34) * hf * cargo --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/local/skills.rs | 47 ++++++++++++++++++++++++++++++++++++++------- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a5d66936..0cbfccac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -917,7 +917,7 @@ checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] name = "openresearch-cli" -version = "0.1.41" +version = "0.1.42" dependencies = [ "anyhow", "axum", diff --git a/Cargo.toml b/Cargo.toml index cc3d6214..0d4a4af9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "openresearch-cli" -version = "0.1.41" +version = "0.1.42" edition = "2021" description = "OpenResearch CLI (orx) — Rust port" repository = "https://github.com/alphaXiv/openresearch-cli" diff --git a/src/local/skills.rs b/src/local/skills.rs index 284f061a..3b9488a4 100644 --- a/src/local/skills.rs +++ b/src/local/skills.rs @@ -38,13 +38,37 @@ Then write the review: - End with a short "start here" reading list of the 3-5 most load-bearing papers. "#; -pub const CATALOG: &[Skill] = &[Skill { - name: "lit-review", - description: "Multi-hop literature review via alphaXiv search", - arg_hint: "", - template: LIT_REVIEW_TEMPLATE, - no_args: "(none given — ask the user what topic to review before searching)", -}]; +const HF_TEMPLATE: &str = r#"Work with the Hugging Face Hub using the `hf` CLI. + +Task: {args} + +Setup — verify before anything else: +1. `hf version` — if missing, install with `curl -LsSf https://hf.co/cli/install.sh | sh` (or `pip install -U "huggingface_hub[cli]"`), then re-check. +2. `hf auth whoami` — HF_TOKEN is usually already in the environment (synced from the orx up settings). If unauthenticated, ask the user to add their token in the orx up settings (Hugging Face section) or run `hf auth login`. + +Using the CLI: +- Discover flags with `hf --help` and `hf --help`; don't guess. +- Key families: `hf download` / `hf upload` (models, datasets, spaces), `hf jobs` (run compute on HF infra), `hf repo` (create/manage repos), `hf cache` (inspect/clean local cache). +- Prefer `--repo-type dataset|space` flags over guessing repo id formats. +- For anything destructive (deleting repos/files, overwriting), confirm with the user first. +"#; + +pub const CATALOG: &[Skill] = &[ + Skill { + name: "lit-review", + description: "Multi-hop literature review via alphaXiv search", + arg_hint: "", + template: LIT_REVIEW_TEMPLATE, + no_args: "(none given — ask the user what topic to review before searching)", + }, + Skill { + name: "hf", + description: "Hugging Face Hub via the hf CLI (installs it if missing)", + arg_hint: "", + template: HF_TEMPLATE, + no_args: "(none given — ask the user what they want to do on the Hugging Face Hub)", + }, +]; /// Expand a leading `/name [args]` into the skill's full prompt. `None` when /// the text is not a known slash-skill (sent to the harness untouched). @@ -76,6 +100,15 @@ mod tests { assert!(out.contains("ask the user")); } + #[test] + fn expands_hf_skill() { + let out = expand("/hf download llama-3 weights").unwrap(); + assert!(out.contains("Task: download llama-3 weights")); + assert!(out.contains("hf version")); + let bare = expand("/hf").unwrap(); + assert!(bare.contains("ask the user")); + } + #[test] fn passes_through_unknown_or_plain_text() { assert!(expand("/unknown thing").is_none());