repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

config: add kimi coding model

b924295a3e2c1562026b65e87577ce04bce9422b

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (10)

nushell/gen-secrets.nu

Modified
33 33 secret ZAI_API_KEY
34 34 secret MINIMAX_WORK_API_KEY
35 35 secret ZAI_WORK_API_KEY
36 +secret KIMI_API_KEY

nushell/login.nu

Modified
15 15 use syncthing.nu
16 16 use minimax.nu
17 17 use zai.nu
18 +use kimi.nu
18 19 use shim.nu
20 21 use std/clip

nushell/modules/kimi.nu

Added
new file mode 100644
1 +# Kimi Code / Moonshot AI integration.
2 +# Set KIMI_API_KEY in secrets.nuon.
3 +# Override base URL with KIMI_API_BASE (default: https://api.kimi.com/coding/v1).
5 +export def main [] {
6 + print "Kimi Code / Moonshot AI integration"
7 + print " kimi usage — check subscription quota"
8 + print " kimi chat <message> — send a chat completion"
9 + print " kimi models — list available models"
10 + print ""
11 + print "Run a subcommand with --help for details."
14 +# ── Usage ─────────────────────────────────────────────────────────────────────
16 +# `kimi usage` — check Kimi Code subscription quota and usage.
17 +export def usage [] {
18 + let token = get-token
19 + let base = get-base
20 + let hs = {
21 + Authorization: $'Bearer ($token)'
22 + Accept: "application/json"
23 + }
25 + let res = try {
26 + http get --headers $hs $"($base)/usages"
27 + } catch { |e|
28 + error make {
29 + msg: "Failed to fetch usage"
30 + label: { text: "Check KIMI_API_KEY and network connection" }
31 + }
32 + }
34 + let c = (ansi c)
35 + let g = (ansi g)
36 + let y = (ansi y)
37 + let r = (ansi r)
38 + let d = (ansi d)
39 + let e = (ansi rst)
41 + print $"($c)KIMI CODE USAGE($e)"
42 + print ""
44 + # ── weekly / main usage ──
45 + let usage = $res | get --optional usage | default {}
46 + let limit = $usage | get --optional limit | default "0"
47 + let used = $usage | get --optional used | default "0"
48 + let remain = $usage | get --optional remaining | default "0"
49 + let reset = $usage | get --optional resetTime | default ""
51 + if ($limit | into int) > 0 {
52 + let pct = ($remain | into int) * 100 // ($limit | into int)
53 + let bar = bar $pct
54 + let color = if $pct <= 10 { $r } else if $pct <= 30 { $y } else { $g }
55 + let reset_hint = if $reset != "" { $" ($d)resets ($reset)($e)" } else { "" }
56 + print $" ($c)Weekly Quota($e)"
57 + print $" ($bar) ($color)($remain)/($limit) ($pct)% left($e)($reset_hint)"
58 + print ""
59 + }
61 + # ── total quota ──
62 + let total_quota = $res | get --optional totalQuota | default {}
63 + let tq_limit = $total_quota | get --optional limit | default "0"
64 + let tq_remain = $total_quota | get --optional remaining | default "0"
65 + if ($tq_limit | into int) > 0 {
66 + print $" ($c)Total Quota($e) ($tq_remain)/($tq_limit) remaining"
67 + print ""
68 + }
70 + # ── windowed limits ──
71 + let limits = $res | get --optional limits | default []
72 + if ($limits | length) > 0 {
73 + print $" ($c)Rate Limits($e)"
74 + for item in $limits {
75 + let window = $item | get --optional window | default {}
76 + let detail = $item | get --optional detail | default {}
77 + let w_dur = $window | get --optional duration | default 0
78 + let w_unit = $window | get --optional timeUnit | default ""
79 + let d_limit = $detail | get --optional limit | default "0"
80 + let d_used = $detail | get --optional used | default "0"
81 + let d_remain = $detail | get --optional remaining | default "0"
83 + let label = if ($w_unit | str contains "MINUTE") and $w_dur >= 60 and ($w_dur mod 60) == 0 {
84 + $"($w_dur / 60)h limit"
85 + } else if ($w_unit | str contains "MINUTE") {
86 + $"($w_dur)m limit"
87 + } else if ($w_unit | str contains "HOUR") {
88 + $"($w_dur)h limit"
89 + } else if ($w_unit | str contains "DAY") {
90 + $"($w_dur)d limit"
91 + } else {
92 + "Rate limit"
93 + }
95 + let pct = if ($d_limit | into int) > 0 {
96 + ($d_remain | into int) * 100 // ($d_limit | into int)
97 + } else { 0 }
98 + let bar = bar $pct
99 + print $" ($label) ($bar) ($d_remain)/($d_limit)"
101 + print ""
104 + # ── parallel / concurrency ──
105 + let parallel = $res | get --optional parallel | default {}
106 + let p_limit = $parallel | get --optional limit | default "0"
107 + if ($p_limit | into int) > 0 {
108 + print $" ($c)Concurrency($e) max ($p_limit) parallel requests"
109 + print ""
113 +def bar [pct: int] {
114 + let n = ($pct / 10 | math round | into int)
115 + let n = if $n > 10 { 10 } else if $n < 0 { 0 } else { $n }
116 + let g = (ansi g)
117 + let d = (ansi d)
118 + let y = (ansi y)
119 + let r = (ansi r)
120 + let e = (ansi rst)
121 + let color = if $pct < 50 { $g } else if $pct < 80 { $y } else { $r }
122 + let filled = 1..$n | each { $"($g)▓" } | str join
123 + let empty = 1..(10 - $n) | each { $"($d)░" } | str join
124 + $"($filled)($empty)($e)"
127 +# ── Private helpers ───────────────────────────────────────────────────────────
129 +def get-token [] {
130 + let token = $env | get --optional KIMI_API_KEY
131 + if ($token | is-empty) {
132 + error make {
133 + msg: "KIMI_API_KEY is not set"
134 + label: { text: "Set KIMI_API_KEY in secrets.nuon" }
137 + $token
140 +def get-base [] {
141 + $env | get --optional KIMI_API_BASE | default "https://api.kimi.com/coding/v1"
144 +def headers [] {
146 + Authorization: $'Bearer (get-token)'
147 + Content-Type: "application/json"
148 + Accept: "application/json"
152 +# ── Chat ──────────────────────────────────────────────────────────────────────
154 +# `kimi chat` — send a chat completion to kimi-for-coding.
156 +# # Parameters
157 +# `message` # The user message (required)
158 +# `--system` # Optional system prompt
159 +export def chat [
160 + message: string
161 + --system (-s): string = ""
162 +] {
163 + if ($message | str trim | is-empty) {
164 + error make {
165 + msg: "Message cannot be empty"
166 + label: { text: "Provide a non-empty message" }
170 + let base = get-base
171 + let hs = headers
173 + mut messages = []
174 + if ($system | str trim | is-not-empty) {
175 + $messages = $messages | append { role: "system", content: $system }
177 + $messages = $messages | append { role: "user", content: $message }
179 + let payload = {
180 + model: "kimi-for-coding"
181 + messages: $messages
184 + let resp = try {
185 + http post --headers $hs $"($base)/chat/completions" ($payload | to json)
186 + } catch { |e|
187 + let raw = $e.raw | default ""
188 + if ($raw | str contains "401") {
189 + error make {
190 + msg: "Authentication failed (401)"
191 + label: { text: "Check KIMI_API_KEY is correct and active" }
193 + } else if ($raw | str contains "403") {
194 + error make {
195 + msg: "Access forbidden (403)"
196 + label: { text: "Kimi Code API key may be restricted. Ensure subscription includes API access and key is active at https://www.kimi.com/code/console" }
198 + } else if ($raw | str contains "429") {
199 + error make {
200 + msg: "Rate limited (429)"
201 + label: { text: "Too many requests — wait and retry" }
204 + error make {
205 + msg: "Chat request failed"
206 + label: { text: ($e.msg | default "Check network and API base URL") }
210 + let choice = $resp | get --optional choices | default [] | get 0 | default {}
211 + let content = $choice | get --optional message.content | default ""
212 + let finish = $choice | get --optional finish_reason | default ""
214 + print $content
216 + if $finish != "stop" and ($finish | is-not-empty) {
217 + print $"(ansi d)[finish_reason: ($finish)](ansi rst)"
221 +# ── Models ────────────────────────────────────────────────────────────────────
223 +# `kimi models` — list models available on the current endpoint.
224 +export def models [] {
225 + let base = get-base
226 + let hs = headers
228 + let res = try {
229 + http get --headers $hs $"($base)/models"
230 + } catch { |e|
231 + error make {
232 + msg: "Failed to list models"
233 + label: { text: "Check KIMI_API_KEY and KIMI_API_BASE" }
237 + $res.data | each { |m|
239 + id: $m.id
240 + display_name: ($m | get --optional display_name | default "")
241 + context: ($m | get --optional context_length | default 0)
243 + } | table -e

pi/agent/extensions/free/index.ts

Deleted
deleted file mode 100644
1 -/**
2 - * Free Models Extension for pi
3 - *
4 - * Registers zero-cost models from Zen and Kilo.
5 - *
6 - * Zen: fetches free model list from opencode.ai/zen at startup (~100ms, no auth).
7 - * Two API types are needed:
8 - * - "zen" (anthropic-messages): big-pickle, minimax-m2.5-free
9 - * - "zen-free" (openai-completions): hy3-preview-free, ling-2.6-flash-free,
10 - * nemotron-3-super-free
11 - *
12 - * Kilo: hardcoded models, updated on `/free-refresh`.
13 - *
14 - * Installation:
15 - * Copy or symlink into ~/.pi/agent/extensions/, then /reload.
16 - */
18 -import type { ExtensionAPI, ProviderModelConfig } from "@mariozechner/pi-coding-agent";
20 -// ─── Zen ─────────────────────────────────────────────────────────────────
21 -// Zen's /zen/v1/models endpoint returns model IDs with no auth required.
22 -// Free models are identified by the "-free" suffix or the "big-pickle" name.
24 -const ZEN_BASE_URL = "https://opencode.ai/zen";
26 -// These use anthropic-messages API (thinking + text content blocks).
27 -const ZEN_AM_MODELS = ["big-pickle", "minimax-m2.5-free"];
29 -// These use openai-completions API (standard chat completions).
30 -const ZEN_OC_MODELS = ["hy3-preview-free", "ling-2.6-flash-free", "nemotron-3-super-free"];
32 -// Default specs for Zen free models (endpoint doesn't provide these).
33 -const ZEN_SPECS: Record<string, { contextWindow: number; maxTokens: number; reasoning: boolean }> = {
34 - "big-pickle": { contextWindow: 200_000, maxTokens: 128_000, reasoning: true },
35 - "minimax-m2.5-free": { contextWindow: 128_000, maxTokens: 32_000, reasoning: false },
36 - "hy3-preview-free": { contextWindow: 262_144, maxTokens: 262_144, reasoning: false },
37 - "ling-2.6-flash-free": { contextWindow: 262_144, maxTokens: 32_000, reasoning: false },
38 - "nemotron-3-super-free": { contextWindow: 262_144, maxTokens: 262_144, reasoning: false },
39 -};
41 -function zenSpec(id: string) {
42 - return ZEN_SPECS[id] ?? { contextWindow: 128_000, maxTokens: 32_000, reasoning: false };
45 -function zenModel(id: string, api: "anthropic-messages" | "openai-completions"): ProviderModelConfig {
46 - const s = zenSpec(id);
47 - const name = id.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
48 - const base = {
49 - id,
50 - name,
51 - reasoning: s.reasoning,
52 - input: ["text"] as ("text" | "image")[],
53 - cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
54 - contextWindow: s.contextWindow,
55 - maxTokens: s.maxTokens,
56 - };
57 - if (api === "openai-completions") {
58 - return {
59 - ...base,
60 - api: "openai-completions" as const,
61 - compat: {
62 - maxTokensField: "max_tokens",
63 - supportsStore: false,
64 - supportsDeveloperRole: false,
65 - supportsReasoningEffort: false,
66 - requiresThinkingAsText: false,
67 - },
68 - };
69 - }
70 - return { ...base, api: "anthropic-messages" as const };
73 -interface ZenModel { id: string; }
74 -interface ZenModelsResponse { data: ZenModel[]; }
76 -async function fetchZenModels(signal?: AbortSignal) {
77 - const res = await fetch("https://opencode.ai/zen/v1/models", { signal });
78 - if (!res.ok) throw new Error(`Zen returned ${res.status}`);
79 - const data = (await res.json()) as ZenModelsResponse;
80 - const ids = data.data.map((m) => m.id);
81 - return {
82 - am: ZEN_AM_MODELS.filter((id) => ids.includes(id)).map((id) => zenModel(id, "anthropic-messages")),
83 - oc: ZEN_OC_MODELS.filter((id) => ids.includes(id)).map((id) => zenModel(id, "openai-completions")),
84 - };
87 -// ─── Kilo ─────────────────────────────────────────────────────────────────
88 -// Kilo rotates free models periodically. Run /free-refresh to update.
89 -// Hardcoded models as of April 2026.
91 -interface KiloModelSpec {
92 - id: string;
93 - name: string;
94 - contextWindow: number;
95 - maxTokens: number;
96 - input: ("text" | "image")[];
99 -const KILO_MODELS: KiloModelSpec[] = [
100 - { id: "inclusionai/ling-2.6-1t:free", name: "Ling 2.6 1t", contextWindow: 262_144, maxTokens: 32_768, input: ["text"] },
101 - { id: "inclusionai/ling-2.6-flash:free", name: "Ling 2.6 Flash", contextWindow: 262_144, maxTokens: 32_768, input: ["text"] },
102 - { id: "nvidia/nemotron-3-super-120b-a12b:free", name: "Nemotron 3 Super", contextWindow: 262_144, maxTokens: 262_144, input: ["text"] },
103 - { id: "tencent/hy3-preview:free", name: "Hy3 Preview", contextWindow: 262_144, maxTokens: 262_144, input: ["text"] },
104 - { id: "kilo-auto/free", name: "Kilo Auto", contextWindow: 256_000, maxTokens: 10_000, input: ["text"] },
105 - { id: "openrouter/free", name: "OpenRouter Free", contextWindow: 200_000, maxTokens: 32_768, input: ["text"] },
106 - { id: "baidu/qianfan-ocr-fast:free", name: "Qianfan OCR Fast", contextWindow: 65_536, maxTokens: 28_672, input: ["text", "image"] },
107 -];
109 -function kiloModels(): ProviderModelConfig[] {
110 - return KILO_MODELS.map((m) => ({
111 - id: m.id,
112 - name: m.name,
113 - reasoning: false,
114 - input: m.input,
115 - cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
116 - contextWindow: m.contextWindow,
117 - maxTokens: m.maxTokens,
118 - compat: {
119 - maxTokensField: "max_tokens",
120 - supportsStore: false,
121 - supportsDeveloperRole: false,
122 - supportsReasoningEffort: false,
123 - requiresThinkingAsText: false,
124 - },
125 - }));
128 -// Live-fetched Kilo models (replaces hardcoded on /free-refresh)
129 -let liveKiloModels: ProviderModelConfig[] | null = null;
131 -interface KiloGatewayModel {
132 - id: string;
133 - pricing?: { prompt?: string; completion?: string };
134 - context_length?: number;
135 - top_provider?: { max_completion_tokens?: number };
136 - architecture?: { input_modalities?: string[]; output_modalities?: string[] };
138 -interface KiloGatewayResponse { data?: KiloGatewayModel[]; }
140 -async function fetchKiloModels(signal?: AbortSignal): Promise<ProviderModelConfig[]> {
141 - const res = await fetch("https://api.kilo.ai/api/gateway/models", { signal });
142 - if (!res.ok) throw new Error(`Kilo returned ${res.status}`);
143 - const data = (await res.json()) as KiloGatewayResponse;
145 - return (data.data ?? [])
146 - .filter((m) => m.pricing?.prompt === "0" && m.pricing?.completion === "0")
147 - .filter((m) => !m.architecture?.output_modalities?.includes("audio"))
148 - .map((m) => {
149 - const ctx = m.context_length ?? 128_000;
150 - const maxTok = m.top_provider?.max_completion_tokens ?? 32_768;
151 - const hasImage = m.architecture?.input_modalities?.includes("image") ?? false;
152 - const name = (m.id.includes("/") ? m.id.split("/")[1] : m.id)
153 - .replace(/:free$/, "").replace(/-/g, " ")
154 - .replace(/\b\w/g, (c: string) => c.toUpperCase());
155 - return {
156 - id: m.id,
157 - name,
158 - reasoning: false,
159 - input: hasImage ? (["text", "image"] as const) : (["text"] as const),
160 - cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
161 - contextWindow: ctx,
162 - maxTokens: maxTok,
163 - compat: {
164 - maxTokensField: "max_tokens",
165 - supportsStore: false,
166 - supportsDeveloperRole: false,
167 - supportsReasoningEffort: false,
168 - requiresThinkingAsText: false,
169 - },
170 - };
171 - });
174 -// ─── Registration ─────────────────────────────────────────────────────────────
176 -function registerKilo(pi: ExtensionAPI, models: ProviderModelConfig[]) {
177 - pi.registerProvider("free", {
178 - baseUrl: "https://api.kilo.ai/api/gateway/v1",
179 - apiKey: "-",
180 - authHeader: false,
181 - api: "openai-completions",
182 - models,
183 - });
186 -function registerZenAm(pi: ExtensionAPI, models: ProviderModelConfig[]) {
187 - pi.registerProvider("zen", {
188 - baseUrl: ZEN_BASE_URL,
189 - apiKey: "-",
190 - authHeader: false,
191 - api: "anthropic-messages",
192 - models,
193 - });
196 -function registerZenOc(pi: ExtensionAPI, models: ProviderModelConfig[]) {
197 - pi.registerProvider("zen-free", {
198 - baseUrl: `${ZEN_BASE_URL}/v1`,
199 - apiKey: "-",
200 - authHeader: false,
201 - api: "openai-completions",
202 - models,
203 - });
206 -// ─── Extension ──────────────────────────────────────────────────────────────
208 -export default async function freeExtension(pi: ExtensionAPI) {
209 - // ── Zen: fetch model list at startup (~100ms, no auth) ─────────────────
210 - let zenAm: ProviderModelConfig[] = [];
211 - let zenOc: ProviderModelConfig[] = [];
212 - try {
213 - const result = await fetchZenModels();
214 - zenAm = result.am;
215 - zenOc = result.oc;
216 - } catch (err) {
217 - console.warn("[free] Zen fetch failed:", err);
218 - }
220 - // ── Kilo: hardcoded, no startup fetch ─────────────────────────────────
221 - let kilo = liveKiloModels ?? kiloModels();
223 - if (kilo.length === 0 && zenAm.length === 0 && zenOc.length === 0) {
224 - console.error("[free] No free models available. Check network.");
225 - return;
226 - }
228 - if (kilo.length > 0) registerKilo(pi, kilo);
229 - if (zenAm.length > 0) registerZenAm(pi, zenAm);
230 - if (zenOc.length > 0) registerZenOc(pi, zenOc);
232 - // ── session_start: notify user once UI is available ─────────────────────
233 - pi.on("session_start", (_event, ctx) => {
234 - const parts: string[] = [];
235 - if (kilo.length > 0) parts.push(`${kilo.length} Kilo`);
236 - if (zenAm.length + zenOc.length > 0) parts.push(`${zenAm.length + zenOc.length} Zen`);
237 - if (parts.length > 0) {
238 - ctx.ui.notify(`free: ${parts.join(" + ")}. /free-refresh to update.`, "info");
239 - }
240 - });
242 - // ── /free-refresh ───────────────────────────────────────────────────────
243 - pi.registerCommand("free-refresh", {
244 - description: "Re-fetch free models from Kilo's gateway and Zen's model list.",
245 - async handler(_args, ctx) {
246 - try {
247 - const [kiloResult, zenResult] = await Promise.allSettled([
248 - fetchKiloModels(ctx.signal),
249 - fetchZenModels(ctx.signal),
250 - ]);
252 - if (kiloResult.status === "fulfilled" && kiloResult.value.length > 0) {
253 - registerKilo(pi, kiloResult.value);
254 - liveKiloModels = kiloResult.value;
255 - kilo = kiloResult.value; // update for session_start notification
256 - }
257 - if (zenResult.status === "fulfilled") {
258 - if (zenResult.value.am.length > 0) registerZenAm(pi, zenResult.value.am);
259 - if (zenResult.value.oc.length > 0) registerZenOc(pi, zenResult.value.oc);
260 - zenAm = zenResult.value.am;
261 - zenOc = zenResult.value.oc;
262 - }
264 - const k = kiloResult.status === "fulfilled" ? kiloResult.value.length : "?";
265 - const z = (zenResult.status === "fulfilled" ? zenResult.value.am.length + zenResult.value.oc.length : "?");
266 - const failed: string[] = [];
267 - if (kiloResult.status === "rejected") failed.push("Kilo");
268 - if (zenResult.status === "rejected") failed.push("Zen");
269 - const note = failed.length ? ` (${failed.join(", ")} failed)` : "";
270 - ctx.ui.notify(`free: ${k} Kilo + ${z} Zen model(s)${note}.`, "info");
271 - } catch (err) {
272 - ctx.ui.notify(`free refresh failed: ${(err as Error).message}`, "error");
273 - }
274 - },
275 - });

pi/agent/extensions/free/package.json

Deleted
deleted file mode 100644
1 -{
2 - "name": "@bugabinga/pi-ext-free",
3 - "version": "0.1.0",
4 - "private": true,
5 - "type": "module",
6 - "main": "index.ts",
7 - "peerDependencies": {
8 - "@mariozechner/pi-coding-agent": "*"
9 - }
10 -}

pi/agent/extensions/quota/index.ts

Modified
2 2 * /quota — subscription plan usage across providers.
3 3 * Emits quota summary into footer llm zone; /quota toggles detailed widget.
4 - * Supports: Anthropic, OpenAI Codex, MiniMax, Zai.
4 + * Supports: Anthropic, OpenAI Codex, MiniMax, Zai, Kimi.
5 5 * Providers without configured keys are silently skipped.
8 8 import { readFileSync } from "node:fs";
9 9 import { homedir } from "node:os";
10 10 import { join } from "node:path";
11 -import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
11 +import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
13 13 // ── Types ─────────────────────────────────────────────────────────────────
35 35 success: boolean;
38 +interface KimiUsage {
39 + limit: string;
40 + used: string;
41 + remaining: string;
42 + resetTime?: string;
45 +interface KimiLimit {
46 + window?: { duration?: number; timeUnit?: string };
47 + detail?: KimiUsage;
50 +interface KimiResponse {
51 + usage?: KimiUsage;
52 + limits?: KimiLimit[];
53 + totalQuota?: { limit: string; remaining: string };
38 56 interface Quota {
39 57 used: number;
40 58 total: number;
105 123 return d;
126 +async function fetchKimi(key: string) {
127 + const r = await fetch("https://api.kimi.com/coding/v1/usages", {
128 + headers: { Authorization: `Bearer ${key}`, Accept: "application/json" },
129 + signal: AbortSignal.timeout(10_000),
130 + });
131 + if (!r.ok) throw new Error(`${r.status}`);
132 + return r.json() as Promise<KimiResponse>;
108 135 // ── Parsing ────────────────────────────────────────────────────────────────
110 137 function parseDateish(value: unknown): number {
209 +function parseKimi(data: KimiResponse): ProviderUsage {
210 + const usage = data?.usage;
211 + const uLimit = Number(usage?.limit ?? 0);
212 + const uUsed = Number(usage?.used ?? 0);
213 + const uReset = usage?.resetTime ? new Date(usage.resetTime).getTime() : undefined;
215 + // 5h window is the first rate limit (duration=300, TIME_UNIT_MINUTE)
216 + const limits = data?.limits ?? [];
217 + const firstLimit = limits[0]?.detail;
218 + const wLimit = Number(firstLimit?.limit ?? 0);
219 + const wUsed = Number(firstLimit?.used ?? 0);
220 + const wReset = firstLimit?.resetTime ? new Date(firstLimit.resetTime).getTime() : undefined;
222 + return {
223 + name: "Kimi",
224 + fiveH: { used: wUsed, total: wLimit, remaining: wLimit - wUsed, resetAt: wReset },
225 + weekly: { used: uUsed, total: uLimit, remaining: uLimit - uUsed, resetAt: uReset },
226 + };
182 229 // ── Formatters ────────────────────────────────────────────────────────────
184 231 function bar(pct: number, w = 15): string {
213 260 "openai-codex": "OpenAI Codex",
214 261 minimax: "MiniMax",
215 262 zai: "Zai",
263 + "kimi-coding": "Kimi",
218 266 function emptyProvider(name: string): ProviderUsage {
265 313 catch { results.push(emptyProvider("Zai")); }
316 + // Kimi
317 + const kimiKey = await ctx.modelRegistry.getApiKeyForProvider("kimi-coding");
318 + if (kimiKey) {
319 + try { results.push(parseKimi(await fetchKimi(kimiKey))); }
320 + catch { results.push(emptyProvider("Kimi")); }
268 323 providers = results;
269 324 fetchedAt = Date.now();

pi/agent/extensions/quota/package.json

Modified
5 5 "type": "module",
6 6 "main": "index.ts",
7 7 "peerDependencies": {
8 - "@mariozechner/pi-coding-agent": "*"
8 + "@earendil-works/pi-coding-agent": "*"

pi/agent/models.json

Modified
2 - "providers": {
3 - "minimax": {
4 - "baseUrl": "https://api.minimax.io/anthropic",
5 - "api": "anthropic-messages",
6 - "models": [
7 - {
8 - "id": "MiniMax-M2.5-highspeed",
9 - "name": "MiniMax-M2.5-highspeed",
10 - "reasoning": true,
11 - "input": [
12 - "text"
13 - ],
14 - "contextWindow": 204800,
15 - "maxTokens": 32768,
16 - "cost": {
17 - "input": 0.6,
18 - "output": 2.4,
19 - "cacheRead": 0.03,
20 - "cacheWrite": 0.375
21 - }
22 - }
23 - ]
24 - }
25 - }
2 + "providers": {
3 + "minimax": {
4 + "baseUrl": "https://api.minimax.io/anthropic",
5 + "api": "anthropic-messages",
6 + "models": [
7 + {
8 + "id": "MiniMax-M2.5-highspeed",
9 + "name": "MiniMax-M2.5-highspeed",
10 + "reasoning": true,
11 + "input": [
12 + "text"
13 + ],
14 + "contextWindow": 204800,
15 + "maxTokens": 32768,
16 + "cost": {
17 + "input": 0.6,
18 + "output": 2.4,
19 + "cacheRead": 0.03,
20 + "cacheWrite": 0.375
21 + }
22 + }
23 + ]
24 + }
25 + }

pi/agent/prompts/brainstorm.md

Modified
12 12 1. **Read Context** - Load AGENTS.md and explore code base
13 13 2. **Diverge** - Generate many ideas wildly
14 -3. **Challenge** - Consult with the devil to find flaws
14 +3. **Challenge** - Consult subagent (pi --print) to find flaws
15 15 4. **Defend** - Strengthen surviving ideas
16 16 5. **Converge** - Pick best recommendations

pi/agent/settings.json

Modified
7 7 "zai/glm-5.1",
8 8 "zai/glm-5-turbo",
9 9 "openai-codex/gpt-5.5",
10 - "free/inclusionai/ling-2.6-1t:free",
11 - "free/tencent/hy3-preview:free"
10 + "kimi-coding/kimi-for-coding"
13 12 "defaultProvider": "openai-codex",
14 13 "defaultModel": "gpt-5.5",
40 + "skills": [
41 + "~/.claude/skills",
42 + "~/.codex/skills",
43 + "~/.agents/skills",
44 + ".claude/skills",
45 + ".codex/skills",
46 + ".agents/skills"
47 + ],
41 48 "packages": [
42 49 "git:github.com/pasky/chrome-cdp-skill"
44 - "mux": {
45 - "cooldownMs": 300000,
46 - "providers": {
47 - "minimax": {
48 - "keys": [
49 - "MINIMAX_WORK_API_KEY"
50 - ]
51 - },
52 - "zai": {
53 - "keys": [
54 - "ZAI_WORK_API_KEY"
55 - ]
56 - }
57 - }
58 - },
59 51 "sessionRecap": {
60 52 "model": "minimax/MiniMax-M2.5-highspeed"
65 57 "neko": {
66 58 "enabled": true
68 -}