Simple command‑line assistant that uses the GitHub Copilot SDK and a custom tool (get_weather) to fetch real‑time weather for a city via the Open‑Meteo public API.
- Node.js 18+ (uses global
fetch) or any version that supports--importloader flags. - npm.
npm installTo run the assistant with the Copilot SDK, set either GH_TOKEN or GITHUB_TOKEN in your environment. See the official docs: https://docs.github.com/pt/copilot/how-tos/set-up/install-copilot-cli#authenticating-with-copilot-cli
export GH_TOKEN=your_token_here # or
export GITHUB_TOKEN=your_token_hereNote: The quick standalone check script does not require authentication because it calls Open‑Meteo directly.
npm start- Example: type “What’s the weather in Paris?” then press Enter.
- Type
exitto quit.
Guardrail: If you ask about non‑weather topics (e.g., jokes, finance, cooking), the assistant will refuse with a short message and will not engage.
$ npm start
> weather-assistant-cli@1.0.0 start
> tsx src/index.ts
🌤️ Weather Assistant (type 'exit' to quit)
Try: 'What's the weather in Paris?'
You: 'What's the weather in Paris?
Assistant: The weather in Paris is 4.7°C (feels like 2.9°C), overcast, with a wind speed of 8.1 m/s.
You: What about New York?
Assistant: The weather in New York is -9.4°C (feels like -15.2°C), overcast, with a wind speed of 8.6 m/s.
You: Compare Tokyo vs Lisbon temperatures.
Assistant: Tokyo is currently 3°C (feels like 1°C, clear sky), while Lisbon is 11.7°C (feels like 10.2°C, slight rain). Lisbon is warmer than Tokyo.
You: exit
Note: Values above are examples; actual results depend on current conditions.
npx tsx src/scripts/check-weather.ts "Paris"npm run test:unitnpm run test:integrationnpm testsrc/index.ts # CLI assistant + Copilot session and tool
src/lib/guardrail.ts # Guardrail for weather-related prompts
src/lib/weather.ts # Shared helpers: geocoding, current weather, mapping
src/scripts/check-weather.ts # Quick verification script without Copilot
test/unit/*.ts # Unit tests (Sinon stubs for fetch)
test/integration/*.ts # Integration tests (real Open‑Meteo calls)- Temperature is returned in °C.
- Uses Open‑Meteo’s free, keyless endpoints for geocoding and current weather.
- The
get_weathertool exposescityas a parameter and returns a normalized payload:city,temperature,feels_like,condition,wind_speed_mps,source. - The CLI includes a lightweight guardrail to only respond to weather‑related prompts.
MIT.