this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add error handling, optional base URL, README

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

alice c8904999 d4d73a90

+46 -1
+38
README.md
··· 1 + # nlcmd 2 + 3 + Type natural language in your terminal, press Ctrl+G, get a shell command. 4 + 5 + ## Install 6 + 7 + ```bash 8 + bun install 9 + ``` 10 + 11 + ## Setup 12 + 13 + Add to your `~/.zshrc`: 14 + 15 + ```zsh 16 + source /path/to/widget.zsh 17 + export ANTHROPIC_API_KEY="sk-..." 18 + ``` 19 + 20 + ## Usage 21 + 22 + 1. Type a natural language description of what you want to do 23 + 2. Press `Ctrl+G` 24 + 3. Watch the command stream in 25 + 4. Press Enter to execute (or edit first) 26 + 27 + ## Examples 28 + 29 + ``` 30 + find all pdf files in downloads ⟶ find ~/Downloads -name "*.pdf" 31 + list git branches by date ⟶ git branch --sort=-committerdate 32 + disk usage top 10 folders ⟶ du -h --max-depth=1 | sort -hr | head -10 33 + ``` 34 + 35 + ## How it works 36 + 37 + - `cli.ts` - Bun script using Vercel AI SDK + Claude Haiku 4.5 38 + - `widget.zsh` - ZSH widget with streaming output via FIFO + animated spinner
+8 -1
cli.ts
··· 2 2 import { streamText } from "ai"; 3 3 4 4 const anthropic = createAnthropic({ 5 - baseURL: "http://localhost:4001/v1", 5 + ...(process.env.ANTHROPIC_BASE_URL && { baseURL: process.env.ANTHROPIC_BASE_URL }), 6 6 }); 7 7 8 8 const input = await Bun.stdin.text(); ··· 11 11 model: anthropic("claude-haiku-4-5-20251001"), 12 12 system: "Convert to shell command. Output ONLY the raw command. No markdown, no code fences, no explanation.", 13 13 prompt: input.trim(), 14 + onError({ error }: { error: any }) { 15 + const msg = error.statusCode === 401 ? "Invalid API key" 16 + : error.message?.includes("API key") ? "Missing API key" 17 + : error.message || "Unknown error"; 18 + console.log(`# Error: ${msg}`); 19 + process.exit(1); 20 + }, 14 21 }); 15 22 16 23 for await (const chunk of textStream) {