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
30 changes: 16 additions & 14 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,21 @@ npx skynot [options]

The following command‑line flags are available:

| Flag | Alias | Description |
|--------------|--------|-----------------------------------------------------------------------------------|
|`--help` | `-h` | Show the help message with all available options. |
|`--auth` | `-a` | Prompt for AI model's credentials to add env var to script or cook auth.json file.|
|`--extensions`| `-e` | DEPRECATED: Use `spi install <extension>` instead, after install. |
|`--git ["id"]`| `-g[i]`| Set git `user.name`/`user.email` for `aidev`. No arg: copies from current user. |
| | | With arg (e.g. `"Name Surname <user@example.com>"`): uses that instead. |
|`--npm` | `-n` | Install Pi using npm instead of tarball (likely to be slower though). |
|`--paranoid` | `-p` | Refrain from caching the sudo password; ask for it every time it is needed. |
|`--ssh` | `-s` | Copy SSH keys to the `aidev` user for git+ssh (& add GitHub to `known_hosts`). |
|`--update` | `-u` | Wipe any previous existing install of Pi and reinstall, to get the latest version.|
|`--verbose` | `-v` | Show more output from install commands (useful for debugging/low-bandwidth). |
|`--version` | `-V` | Output the version number. |
|`--destroy` |`--BURN`| Delete the `aidev` user, all its data (in `$HOME`), and the `aiteam` group. |
| Flag | Alias | Description |
|----------------|--------|-----------------------------------------------------------------------------------|
|`--help` | `-h` | Show the help message with all available options. |
|`--auth` | `-a` | Prompt for AI model's credentials to add env var to script or cook auth.json file.|
|`--extensions` | `-e` | DEPRECATED: Use `spi install <extension>` instead, after install. |
|`--git ["id"]` | `-g[i]`| Set git `user.name`/`user.email` for `aidev`. No arg: copies from current user. |
| | | With arg (e.g. `"Name Surname <user@example.com>"`): uses that instead. |
|`--npm` | `-n` | Install Pi using npm instead of tarball (likely to be slower though). |
|`--context-lens`| `-c` | Install context-lens and wrapper script `cpi` for launching pi with context-lens. |
|`--paranoid` | `-p` | Refrain from caching the sudo password; ask for it every time it is needed. |
|`--ssh` | `-s` | Copy SSH keys to the `aidev` user for git+ssh (& add GitHub to `known_hosts`). |
|`--update` | `-u` | Wipe any previous existing install of Pi and reinstall, to get the latest version.|
|`--verbose` | `-v` | Show more output from install commands (useful for debugging/low-bandwidth). |
|`--version` | `-V` | Output the version number. |
|`--destroy` |`--BURN`| Delete the `aidev` user, all its data (in `$HOME`), and the `aiteam` group. |


Please note, `-u` would technically not wipe or reinstall extensions, as they normally live in a different place (`.pi` subdir under `aidev` user's $HOME, and/or $NPM_CONFIG_PREFIX dir).
Expand All @@ -80,3 +81,4 @@ Please note, `-u` would technically not wipe or reinstall extensions, as they no
* NPM's `npx` (install with `brew install npm` or `apt install npm`)
* git v2.46 or newer (required for wildcard support in `git config --global safe.directory`)
* `setfacl` command in Linux (to setup ACLs; in Ubuntu this command is provided by the `acl` APT package)
* mitmproxy for using with context-lens (`-c` or `--context-lens` option)
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
From ec9f52b5a09a18f90aeccde3e5e39284640e9cfc Mon Sep 17 00:00:00 2001
From: webwarrior-ws <reg@webwarrior.ws>
Date: Wed, 6 May 2026 14:48:07 +0200
Subject: [PATCH] When launching pi, add providers based on env. vars &
auth.json

Add provider configs to models.json in temp dir used by pi based
on defined env. vars & records in auth.json file.

Fixes https://github.com/larsderidder/context-lens/issues/55
---
src/cli.ts | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)

diff --git a/src/cli.ts b/src/cli.ts
index a761733..c479f07 100644
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -23,6 +23,37 @@ import { VERSION } from "./version.generated.js";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

+// copied from https://github.com/badlogic/pi-mono/blob/main/packages/ai/src/env-api-keys.ts
+const piEnvMap: Record<string, string> = {
+ openai: "OPENAI_API_KEY",
+ "azure-openai-responses": "AZURE_OPENAI_API_KEY",
+ deepseek: "DEEPSEEK_API_KEY",
+ google: "GEMINI_API_KEY",
+ "google-vertex": "GOOGLE_CLOUD_API_KEY",
+ groq: "GROQ_API_KEY",
+ cerebras: "CEREBRAS_API_KEY",
+ xai: "XAI_API_KEY",
+ openrouter: "OPENROUTER_API_KEY",
+ "vercel-ai-gateway": "AI_GATEWAY_API_KEY",
+ zai: "ZAI_API_KEY",
+ mistral: "MISTRAL_API_KEY",
+ minimax: "MINIMAX_API_KEY",
+ "minimax-cn": "MINIMAX_CN_API_KEY",
+ moonshotai: "MOONSHOT_API_KEY",
+ "moonshotai-cn": "MOONSHOT_API_KEY",
+ huggingface: "HF_TOKEN",
+ fireworks: "FIREWORKS_API_KEY",
+ opencode: "OPENCODE_API_KEY",
+ "opencode-go": "OPENCODE_API_KEY",
+ "kimi-coding": "KIMI_API_KEY",
+ "cloudflare-workers-ai": "CLOUDFLARE_API_KEY",
+ "cloudflare-ai-gateway": "CLOUDFLARE_API_KEY",
+ xiaomi: "XIAOMI_API_KEY",
+ "xiaomi-token-plan-cn": "XIAOMI_TOKEN_PLAN_CN_API_KEY",
+ "xiaomi-token-plan-ams": "XIAOMI_TOKEN_PLAN_AMS_API_KEY",
+ "xiaomi-token-plan-sgp": "XIAOMI_TOKEN_PLAN_SGP_API_KEY",
+};
+
// Known tool config: env vars for the child process, extra CLI args, server env vars, and whether mitmproxy is needed
// Note: actual tool config lives in cli-utils.ts so it can be unit-tested without importing this entrypoint.

@@ -842,6 +873,36 @@ if (parsedArgs.commandName === "analyze") {
"https://us-central1-aiplatform.googleapis.com",
]);

+ // Add providers based on env. vars
+ for (const [providerName, envVarName] of Object.entries(piEnvMap)) {
+ if (
+ Object.hasOwn(process.env, envVarName) &&
+ !Object.hasOwn(providers, providerName)
+ ) {
+ providers[providerName] = { baseUrl: proxyBaseUrl };
+ }
+ }
+
+ // Add providers based on auth.json
+ const authJsonPath = join(sourceDir, "auth.json");
+ if (fs.existsSync(authJsonPath)) {
+ let authConfig: Record<string, unknown> = {};
+ try {
+ authConfig = JSON.parse(fs.readFileSync(authJsonPath, "utf8"));
+ } catch {
+ console.error(
+ "Warning: ~/.pi/agent/auth.json is not valid JSON; ignoring",
+ );
+ }
+ if (authConfig && typeof authConfig === "object") {
+ for (const providerName in Object.keys(authConfig)) {
+ if (!Object.hasOwn(providers, providerName)) {
+ providers[providerName] = { baseUrl: proxyBaseUrl };
+ }
+ }
+ }
+ }
+
// Rewrite every provider that has an external baseUrl, regardless of its
// key name. For providers whose upstream isn't natively known to the proxy,
// stash the real URL as x-target-url so the proxy forwards correctly.
--
2.54.0

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"bin": {
"skynot": "bin/skynot"
},
"files": [
"dist/",
"context-lens-patches/"
],
"scripts": {
"dist": "mkdir -p bin && echo '#!/usr/bin/env node' > bin/skynot && echo \"require('../dist/index.js');\" >> bin/skynot && chmod +x bin/skynot",
"build": "npm install && npx tsc && npm run dist",
Expand Down
Loading