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
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,38 @@ Once added, your coding agent will automatically:
- Always put `import kalibr` first
- Include outcome reporting in every agent it builds

## OpenClaw / Hermes Agent Setup

If you're running an [OpenClaw](https://openclaw.ai) or Hermes orchestrator agent, use the `--openclaw` flag to get a **fully autonomous onboarding prompt** — zero human steps required after pasting it in.

```bash
kalibr prompt --openclaw
```

This outputs (and copies to your clipboard) a complete setup sequence that instructs the agent to:

1. `pip install kalibr huggingface_hub`
2. Run `kalibr auth --agent --email <your-email>` — headless account provisioning, no browser required
3. Source credentials into `~/.zshrc` or `~/.bashrc`
4. `openclaw plugin install kalibr && openclaw plugin configure kalibr`
5. Scaffold `~/clawd/` workspace: `SOUL.md`, `USER.md`, `HEARTBEAT.md`, `AGENTS.md` with routing table
6. Create `~/clawd/kalibr-integration/` — downloads `kalibr_pipeline.py`, `kalibr_taxonomy.py`, `kalibr_eval.py` from this repo's `examples/`
7. `kalibr init && kalibr verify`
8. Smoke-test `classify_and_route()`
9. Report done with dashboard link, claim URL, and optional provider key prompts

**Usage:**

```bash
# Standard prompt (Claude Code / Cursor integration)
kalibr prompt

# Full autonomous onboarding for OpenClaw / Hermes
kalibr prompt --openclaw
```

Once set up, your OpenClaw agent will automatically call `classify_and_route()` per task, route to the cheapest model that succeeds, and report outcomes back to Kalibr — all without manual intervention.

## Agent Starter Template

Need a production-ready agent scaffold with Kalibr already wired in?
Expand Down
93 changes: 82 additions & 11 deletions kalibr/cli/prompt_cmd.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""kalibr prompt - Output a ready-to-paste integration prompt."""

import subprocess
from typing import Optional

import typer
from rich.console import Console

console = Console()
Expand All @@ -13,27 +15,87 @@
"Set KALIBR_API_KEY and KALIBR_TENANT_ID from dashboard.kalibr.systems/settings."
)

OPENCLAW_PROMPT_TEXT = """\
Read https://kalibr.systems/llms.txt then https://kalibr.systems/setup.txt

def prompt() -> None:
"""Output a ready-to-paste Claude Code / Cursor prompt."""
# Print to stdout
console.print(PROMPT_TEXT)
Then run autonomously — zero human steps:

1. pip install kalibr huggingface_hub

2. kalibr auth --agent --email <ASK_USER_FOR_EMAIL>
Ask the user: "What email should I use to provision your Kalibr account?"
Then run: kalibr auth --agent --email <that_email>

3. Source credentials into shell:
- If ~/.zshrc exists: append KALIBR_API_KEY and KALIBR_TENANT_ID exports
- Else if ~/.bashrc exists: append to ~/.bashrc
- Run: source ~/.zshrc (or ~/.bashrc)

4. openclaw plugin install kalibr && openclaw plugin configure kalibr

5. Create ~/clawd workspace scaffold:
- ~/clawd/SOUL.md — ask the user: "What does your agent do in one sentence?"
Write: # SOUL.md\\n\\n<their answer>
- ~/clawd/USER.md — ask: "What is your role and timezone?"
Write: # USER.md\\n\\nRole: <role>\\nTimezone: <timezone>
- ~/clawd/HEARTBEAT.md — write a minimal heartbeat file:
# HEARTBEAT.md\\n\\nLast checked: <current datetime>\\nStatus: active
- ~/clawd/AGENTS.md — write a routing table:
# AGENTS.md\\n\\n## Routing Table\\n\\n| Task Type | Load | Route |\\n|-----------|------|-------|\\n| code_generation / code_review / system_design | high | Sonnet → GPT-4o |\\n| research / outreach_generation | medium | Llama → DeepSeek |\\n| web_scraping / classification / summarization / data_pipeline | low | DeepSeek → Llama |

6. Create ~/clawd/kalibr-integration/ directory and download pipeline files:
- https://raw.githubusercontent.com/kalibr-ai/kalibr-sdk-python/main/examples/kalibr_pipeline.py
- https://raw.githubusercontent.com/kalibr-ai/kalibr-sdk-python/main/examples/kalibr_taxonomy.py
- https://raw.githubusercontent.com/kalibr-ai/kalibr-sdk-python/main/examples/kalibr_eval.py
- Create an empty ~/clawd/kalibr-integration/__init__.py

7. kalibr init && kalibr verify

8. Smoke test — run in Python:
from kalibr_integration.kalibr_pipeline import classify_and_route
result = classify_and_route("Summarize this document")
print(result)

9. Report done:
- Print: "✅ Kalibr + OpenClaw setup complete."
- Print: "Dashboard: https://dashboard.kalibr.systems"
- Print the claim email confirmation URL returned by `kalibr auth --agent`
- Ask: "Do you have any provider API keys to add? (OPENAI_API_KEY, ANTHROPIC_API_KEY, DEEPSEEK_API_KEY, HF_TOKEN)"
If yes, append them to ~/.zshrc and source it.
"""


def prompt(
openclaw: bool = typer.Option(
False,
"--openclaw",
help="Output the full autonomous OpenClaw / Hermes agent onboarding prompt.",
),
) -> None:
"""Output a ready-to-paste Claude Code / Cursor integration prompt.

With --openclaw: outputs the full autonomous onboarding sequence for
OpenClaw / Hermes agent orchestrators. Zero human steps after pasting.
"""
text = OPENCLAW_PROMPT_TEXT if openclaw else PROMPT_TEXT

console.print(text)
console.print()

# Try to copy to clipboard
copied = False
clipboard_commands = [
["pbcopy"], # macOS
["xclip", "-selection", "clipboard"], # Linux (X11)
["xsel", "--clipboard", "--input"], # Linux (X11 alt)
["wl-copy"], # Linux (Wayland)
["pbcopy"], # macOS
["xclip", "-selection", "clipboard"], # Linux (X11)
["xsel", "--clipboard", "--input"], # Linux (X11 alt)
["wl-copy"], # Linux (Wayland)
]

for cmd in clipboard_commands:
try:
proc = subprocess.run(
cmd,
input=PROMPT_TEXT,
input=text,
capture_output=True,
text=True,
timeout=5,
Expand All @@ -44,7 +106,16 @@ def prompt() -> None:
except (FileNotFoundError, subprocess.TimeoutExpired):
continue

if openclaw:
label = "OpenClaw / Hermes agent"
else:
label = "Claude Code or Cursor"

if copied:
console.print("[green]Prompt copied to clipboard. Paste into Claude Code or Cursor.[/green]")
console.print(
f"[green]Prompt copied to clipboard. Paste into {label}.[/green]"
)
else:
console.print("[yellow]Could not copy to clipboard. Copy the text above manually.[/yellow]")
console.print(
f"[yellow]Could not copy to clipboard. Copy the text above and paste into {label}.[/yellow]"
)
Loading