Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat([issue-2815]): add Kimi Code CLI + TUI process providers
[._.]/ Adam Eivy682411fa52dd
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 332bc9485b..a647624ba6 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -1,5 +1,9 @@# Unreleased Changes+## AI providers++- `[issue-2815]` Added **Kimi Code** (Moonshot AI's `kimi` binary) as a first-class agentic-coding provider in both CLI (headless one-shot) and TUI (interactive PTY) flavors — `kimi-cli` and `kimi-tui`, mirroring the Grok/Antigravity/Codex process providers. Both ship disabled (opt-in) and are harness-capable, so once enabled they're selectable as CoS-agent / reviewer / runner / TUI providers. The headless path runs `kimi --print` (which implies `--afk`, auto-approving tool calls) and delivers the prompt as the `--prompt <value>` argv; the TUI path runs `kimi --yolo`. Model selection uses a `kimi-configured-default` sentinel — PortOS omits `--model` so the local `kimi` binary uses your own configured default (set via `/model`), while a real model id you pin is passed through as `--model <id>`. The context window is mapped to Kimi K2's 256K. Existing installs pick the pair up on restart via migration `201-kimi-providers`. The pre-existing `nvidia-kimi` HTTP API entry is unchanged. (Prompt-delivery path defaults to the argv value and should be confirmed against a live `kimi` binary.)+## Enterprise GitHub support- [issue-2650] The CoS branch reconciler and issue reconciler now work on self-hosted GitHub Enterprise (`github.*`) repos, not just `github.com`. Both previously gated on the github.com-only `isGithub` origin flag (which drives PortOS's own fork/update flow), so their scans silently skipped enterprise repos even though the sibling PR-watcher already handled them. All three services now share an `isGithubHost(host)` classifier and target `gh` via a host-qualified `HOST/OWNER/REPO` selector, so enterprise repos reconcile correctly and detection stays deterministic on a fork+upstream checkout. Existing github.com behavior is unchanged.diff --git a/README.md b/README.mdindex a57fe1586d..42b3db8ec1 100644--- a/README.md+++ b/README.md@@ -60,7 +60,7 @@ Bring your entire portfolio of projects under one roof.An autonomous AI agent orchestrator that manages your development workflow. Submit a task, and CoS dispatches the right AI agent to handle it — then learns from the result. ([Full docs](./docs/features/chief-of-staff.md))-- **Multi-Agent Orchestration** — Run Claude Code, Codex, Antigravity CLI, Ollama, and LM Studio concurrently with global and per-project limits, capacity management, and fair scheduling ([Agent Runner docs](./docs/features/cos-agent-runner.md))+- **Multi-Agent Orchestration** — Run Claude Code, Codex, Antigravity CLI, Kimi Code, Ollama, and LM Studio concurrently with global and per-project limits, capacity management, and fair scheduling ([Agent Runner docs](./docs/features/cos-agent-runner.md))- **Intelligent Routing** — 6 agent skill templates (bug-fix, feature, security-audit, refactor, docs, mobile) route tasks to the best model based on complexity ([Agent Skills docs](./docs/features/agent-skills.md))- **Task Learning** — Tracks success rates, error patterns, and model performance to dynamically improve routing decisions ([Memory System docs](./docs/features/memory-system.md))- **Goal Tracking** — Define goals and track progress across hundreds of completed tasks with success rate metrics@@ -282,7 +282,7 @@ PortOS binds to `0.0.0.0` so you can access it from any device on your Tailscale| **Frontend** | React 18, Vite, Tailwind CSS, Three.js, xterm.js || **Backend** | Express.js, Socket.IO, PM2, Zod validation || **Data** | PostgreSQL + pgvector (primary datastore — mandatory), JSON files for binary assets and synced/ephemeral state ([storage contract](./docs/STORAGE.md)) |-| **AI** | Claude Code, Codex, Antigravity CLI, Ollama, LM Studio (via the in-tree AI toolkit, `server/lib/aiToolkit/`) |+| **AI** | Claude Code, Codex, Antigravity CLI, Kimi Code, Ollama, LM Studio (via the in-tree AI toolkit, `server/lib/aiToolkit/`) |## Project Structure@@ -321,7 +321,7 @@ Each registered app includes:### AI Providers (`data/providers.json`)Configure AI providers for the runner and Chief of Staff:-- **CLI-based**: Claude Code, Codex, Antigravity CLI+- **CLI-based**: Claude Code, Codex, Antigravity CLI, Kimi Code- **API-based**: OpenAI, Anthropic, Google (with model tier management)- **Local models**: Ollama, LM Studio (OpenAI-compatible endpoints)diff --git a/client/src/utils/providers.js b/client/src/utils/providers.jsindex ad432978ec..147cd65002 100644--- a/client/src/utils/providers.js+++ b/client/src/utils/providers.js@@ -8,11 +8,13 @@ import { formatContextLength } from './formatters.js';export const CODEX_CONFIGURED_DEFAULT = 'codex-configured-default';export const ANTIGRAVITY_CONFIGURED_DEFAULT = 'antigravity-configured-default';export const GROK_CONFIGURED_DEFAULT = 'grok-configured-default';+export const KIMI_CONFIGURED_DEFAULT = 'kimi-configured-default';const CONFIGURED_DEFAULT_SENTINELS = new Set([CODEX_CONFIGURED_DEFAULT,ANTIGRAVITY_CONFIGURED_DEFAULT,GROK_CONFIGURED_DEFAULT,+ KIMI_CONFIGURED_DEFAULT,]);/** True for any provider "use CLI's own default" sentinel. Mirror of server `isConfiguredDefaultModel`. */@@ -22,6 +24,7 @@ export const DEFAULT_LARGE_CONTEXT_WINDOW = 128_000;export const CODEX_CONTEXT_WINDOW = 1_000_000;export const GEMINI_CONTEXT_WINDOW = 1_048_576;export const GROK_CONTEXT_WINDOW = 256_000;+export const KIMI_CONTEXT_WINDOW = 256_000;// Keep in sync with server/lib/stageRunner.js.const KNOWN_MODEL_CONTEXT_WINDOWS = Object.freeze([@@ -65,6 +68,18 @@ export const isCodexProvider = (provider) => {return id === 'codex' || id === 'codex-tui' || commandBasename(provider?.command) === 'codex';};+/**+ * True when a provider is Kimi-Code-flavored — the shipped `kimi-cli`/`kimi-tui`+ * ids or any provider whose launch command basename is `kimi` (path/exe tolerant).+ * MIRROR of `isKimiProvider` in server/lib/providerModels.js — keep in lockstep.+ * @param {{id?:string, command?:string}|null|undefined} provider+ * @returns {boolean}+ */+export const isKimiProvider = (provider) => {+ const id = String(provider?.id || '').toLowerCase();+ return id === 'kimi-cli' || id === 'kimi-tui' || commandBasename(provider?.command) === 'kimi';+};+export const knownProviderContextWindow = (provider) => {if (!isProcessProvider(provider)) return null;const id = String(provider?.id || '').toLowerCase();@@ -72,6 +87,7 @@ export const knownProviderContextWindow = (provider) => {if (isCodexProvider(provider)) return CODEX_CONTEXT_WINDOW;if (id === 'antigravity-cli' || id === 'antigravity-tui' || command === 'agy') return GEMINI_CONTEXT_WINDOW;if (id === 'grok-cli' || id === 'grok-tui' || command === 'grok') return GROK_CONTEXT_WINDOW;+ if (id === 'kimi-cli' || id === 'kimi-tui' || command === 'kimi') return KIMI_CONTEXT_WINDOW;return null;};diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.jsindex 0bdb41d5b8..8a66de0bdf 100644--- a/client/src/utils/providers.test.js+++ b/client/src/utils/providers.test.js@@ -22,6 +22,8 @@ import {CODEX_CONTEXT_WINDOW,GEMINI_CONTEXT_WINDOW,GROK_CONTEXT_WINDOW,+ KIMI_CONTEXT_WINDOW,+ KIMI_CONFIGURED_DEFAULT,effectiveModelContextWindow,mergeModelLists,modelOptionLabel,@@ -31,6 +33,8 @@ import {isProcessProvider,isOllamaBackedProvider,isGrokBuildCli,+ isKimiProvider,+ isConfiguredDefaultModel,isLocalEndpoint,enabledApiProviderFilter,providerTypeClass,@@ -379,10 +383,13 @@ describe('knownProviderContextWindow (mirror of server stageRunner)', () => {expect(knownProviderContextWindow({ id: 'antigravity-cli', type: 'cli', command: 'agy' })).toBe(GEMINI_CONTEXT_WINDOW);expect(knownProviderContextWindow({ id: 'grok-cli', type: 'cli', command: 'grok' })).toBe(GROK_CONTEXT_WINDOW);expect(knownProviderContextWindow({ id: 'grok-tui', type: 'tui', command: 'grok' })).toBe(GROK_CONTEXT_WINDOW);+ expect(knownProviderContextWindow({ id: 'kimi-cli', type: 'cli', command: 'kimi' })).toBe(KIMI_CONTEXT_WINDOW);+ expect(knownProviderContextWindow({ id: 'kimi-tui', type: 'tui', command: 'kimi' })).toBe(KIMI_CONTEXT_WINDOW);});it('normalizes command paths to the basename for vendor windows (#2337)', () => {expect(knownProviderContextWindow({ id: 'custom', type: 'cli', command: '/opt/homebrew/bin/grok' })).toBe(GROK_CONTEXT_WINDOW);+ expect(knownProviderContextWindow({ id: 'custom', type: 'cli', command: '/opt/homebrew/bin/kimi' })).toBe(KIMI_CONTEXT_WINDOW);expect(knownProviderContextWindow({ id: 'custom', type: 'tui', command: '/usr/local/bin/codex' })).toBe(CODEX_CONTEXT_WINDOW);expect(knownProviderContextWindow({ id: 'custom', type: 'cli', command: '/opt/homebrew/bin/agy' })).toBe(GEMINI_CONTEXT_WINDOW);expect(knownProviderContextWindow({ id: 'custom', type: 'cli', command: './bin/codex' })).toBe(CODEX_CONTEXT_WINDOW);@@ -395,6 +402,22 @@ describe('knownProviderContextWindow (mirror of server stageRunner)', () => {});});+describe('isKimiProvider (mirror of server providerModels)', () => {+ it('matches the shipped ids and a path/exe command, rejects others', () => {+ expect(isKimiProvider({ id: 'kimi-cli' })).toBe(true);+ expect(isKimiProvider({ id: 'kimi-tui' })).toBe(true);+ expect(isKimiProvider({ id: 'custom', command: '/opt/homebrew/bin/kimi' })).toBe(true);+ expect(isKimiProvider({ id: 'custom', command: 'C:\\tools\\Kimi.exe' })).toBe(true);+ expect(isKimiProvider({ id: 'grok-cli', command: 'grok' })).toBe(false);+ expect(isKimiProvider(null)).toBe(false);+ });++ it('treats the kimi configured-default sentinel as a configured default', () => {+ expect(isConfiguredDefaultModel(KIMI_CONFIGURED_DEFAULT)).toBe(true);+ expect(filterSelectableModels([KIMI_CONFIGURED_DEFAULT, 'kimi-k2'])).toEqual(['kimi-k2']);+ });+});+describe('effectiveModelContextWindow', () => {it('matches known model windows before provider defaults', () => {expect(effectiveModelContextWindow({ type: 'tui' }, 'gpt-5.5')).toBe(1_000_000);diff --git a/data.reference/providers.json b/data.reference/providers.jsonindex 1552fdb724..78927a308a 100644--- a/data.reference/providers.json+++ b/data.reference/providers.json@@ -317,6 +317,42 @@"secretEnvVars": [],"tuiPromptDelayMs": 2500,"tuiIdleTimeoutMs": 180000+ },+ "kimi-cli": {+ "id": "kimi-cli",+ "name": "Kimi Code CLI",+ "type": "cli",+ "command": "kimi",+ "args": ["--print"],+ "models": ["kimi-configured-default"],+ "defaultModel": "kimi-configured-default",+ "lightModel": "kimi-configured-default",+ "mediumModel": "kimi-configured-default",+ "heavyModel": "kimi-configured-default",+ "contextWindow": 256000,+ "timeout": 300000,+ "enabled": false,+ "envVars": {},+ "secretEnvVars": []+ },+ "kimi-tui": {+ "id": "kimi-tui",+ "name": "Kimi Code TUI",+ "type": "tui",+ "command": "kimi",+ "args": ["--yolo"],+ "models": ["kimi-configured-default"],+ "defaultModel": "kimi-configured-default",+ "lightModel": "kimi-configured-default",+ "mediumModel": "kimi-configured-default",+ "heavyModel": "kimi-configured-default",+ "contextWindow": 256000,+ "timeout": 600000,+ "enabled": false,+ "envVars": {},+ "secretEnvVars": [],+ "tuiPromptDelayMs": 2500,+ "tuiIdleTimeoutMs": 180000}}}diff --git a/scripts/migrations/201-kimi-providers.js b/scripts/migrations/201-kimi-providers.jsnew file mode 100644index 0000000000..711d4155f5--- /dev/null+++ b/scripts/migrations/201-kimi-providers.js@@ -0,0 +1,111 @@+/**+ * Ship the Moonshot AI "Kimi Code" process-provider pair (CLI + TUI) to existing installs.+ *+ * Background: issue-2815. Moonshot AI's Kimi Code (MoonshotAI/kimi-cli, MIT) ships+ * a `kimi` binary that runs as a harness-capable coding agent. PortOS adds two+ * process-provider entries: `kimi-cli` (headless one-shot via `kimi --print`) and+ * `kimi-tui` (interactive PTY). The plain HTTP API entry already exists separately+ * as `nvidia-kimi`. The CLI/TUI argv conventions live in server/lib/kimi.js (kimi+ * reads its prompt as the `--prompt <value>` argv, not raw stdin; `--print` implies+ * `--afk` so headless runs auto-approve).+ *+ * `setup-data.js` merges *missing* provider entries from data.reference, but only+ * when an install re-runs setup. This migration delivers the providers on a plain+ * server restart too, and is the canonical path for deployed installs to pick them+ * up. Purely additive: brand-new ids, so there's no rename or pinned-id rewrite —+ * existing keys are left untouched (idempotent).+ *+ * Kept in lockstep with data.reference/providers.json and+ * server/lib/aiToolkit/defaults/providers.sample.json. Frozen here as the+ * historical record this migration installs; later default changes ride their own+ * migrations rather than mutating this one.+ */++import { readFile, writeFile } from 'fs/promises';+import { join } from 'path';++const PROVIDERS_REL_PATH = 'data/providers.json';++const KIMI_CLI = {+ id: 'kimi-cli',+ name: 'Kimi Code CLI',+ type: 'cli',+ command: 'kimi',+ args: ['--print'],+ models: ['kimi-configured-default'],+ defaultModel: 'kimi-configured-default',+ lightModel: 'kimi-configured-default',+ mediumModel: 'kimi-configured-default',+ heavyModel: 'kimi-configured-default',+ contextWindow: 256000,+ timeout: 300000,+ enabled: false,+ envVars: {},+ secretEnvVars: [],+};++const KIMI_TUI = {+ id: 'kimi-tui',+ name: 'Kimi Code TUI',+ type: 'tui',+ command: 'kimi',+ args: ['--yolo'],+ models: ['kimi-configured-default'],+ defaultModel: 'kimi-configured-default',+ lightModel: 'kimi-configured-default',+ mediumModel: 'kimi-configured-default',+ heavyModel: 'kimi-configured-default',+ contextWindow: 256000,+ timeout: 600000,+ enabled: false,+ envVars: {},+ secretEnvVars: [],+ tuiPromptDelayMs: 2500,+ tuiIdleTimeoutMs: 180000,+};++export default {+ async up({ rootDir }) {+ const providersPath = join(rootDir, PROVIDERS_REL_PATH);+ const raw = await readFile(providersPath, 'utf-8').catch((err) => {+ if (err.code === 'ENOENT') return null;+ throw err;+ });+ if (raw == null) {+ console.log(`📄 ${PROVIDERS_REL_PATH} not present — skipping (fresh install seeds Kimi from data.reference)`);+ return;+ }++ let config;+ try {+ config = JSON.parse(raw);+ } catch (err) {+ console.log(`⚠️ ${PROVIDERS_REL_PATH}: invalid JSON, skipping (${err.message})`);+ return;+ }++ if (!config || typeof config !== 'object' || !config.providers || typeof config.providers !== 'object') {+ console.log(`⚠️ ${PROVIDERS_REL_PATH}: unexpected shape, skipping`);+ return;+ }++ const providers = config.providers;+ let changed = false;++ for (const def of [KIMI_CLI, KIMI_TUI]) {+ if (!providers[def.id]) {+ // structuredClone fully detaches the frozen shipped def (nested arrays/+ // objects included) so a later mutation of the install can't corrupt it.+ providers[def.id] = structuredClone(def);+ changed = true;+ console.log(`📝 ${PROVIDERS_REL_PATH}: added ${def.id} provider`);+ }+ }++ if (changed) {+ await writeFile(providersPath, `${JSON.stringify(config, null, 2)}\n`);+ } else {+ console.log(`✅ ${PROVIDERS_REL_PATH}: Kimi providers already present — no change`);+ }+ },+};diff --git a/scripts/migrations/201-kimi-providers.test.js b/scripts/migrations/201-kimi-providers.test.jsnew file mode 100644index 0000000000..6b55d86cdd--- /dev/null+++ b/scripts/migrations/201-kimi-providers.test.js@@ -0,0 +1,117 @@+/**+ * Test for migration 201 — add the Moonshot AI Kimi Code process-provider pair+ * (CLI + TUI) to existing installs. Picked up by server/vitest.config.js's+ * `../scripts/**\/*.test.js` glob.+ */+import { describe, it, expect, beforeEach, afterEach } from 'vitest';+import { mkdtempSync, rmSync, writeFileSync, readFileSync, mkdirSync, existsSync } from 'fs';+import { tmpdir } from 'os';+import { join } from 'path';++import migration from './201-kimi-providers.js';++const writeJson = (path, value) => writeFileSync(path, JSON.stringify(value, null, 2) + '\n');+const readJson = (path) => JSON.parse(readFileSync(path, 'utf-8'));++describe('migration 201 — Kimi providers', () => {+ let rootDir;+ let providersPath;++ beforeEach(() => {+ rootDir = mkdtempSync(join(tmpdir(), 'migration-201-'));+ mkdirSync(join(rootDir, 'data'), { recursive: true });+ providersPath = join(rootDir, 'data/providers.json');+ });++ afterEach(() => {+ rmSync(rootDir, { recursive: true, force: true });+ });++ it('adds the cli and tui Kimi providers to an existing install', async () => {+ writeJson(providersPath, {+ activeProvider: 'claude-code',+ providers: { 'claude-code': { id: 'claude-code', type: 'cli', command: 'claude' } },+ });++ await migration.up({ rootDir });++ const out = readJson(providersPath);++ const cli = out.providers['kimi-cli'];+ expect(cli.type).toBe('cli');+ expect(cli.command).toBe('kimi');+ expect(cli.args).toEqual(['--print']);+ expect(cli.defaultModel).toBe('kimi-configured-default');+ expect(cli.contextWindow).toBe(256000);+ expect(cli.enabled).toBe(false);++ const tui = out.providers['kimi-tui'];+ expect(tui.type).toBe('tui');+ expect(tui.command).toBe('kimi');+ expect(tui.args).toEqual(['--yolo']);+ expect(tui.tuiPromptDelayMs).toBe(2500);+ expect(tui.tuiIdleTimeoutMs).toBe(180000);++ // unrelated providers + active provider untouched+ expect(out.providers['claude-code']).toBeDefined();+ expect(out.activeProvider).toBe('claude-code');+ });++ it('does not overwrite a user-customized kimi entry', async () => {+ writeJson(providersPath, {+ providers: {+ 'kimi-cli': { id: 'kimi-cli', type: 'cli', command: 'kimi', enabled: true, defaultModel: 'kimi-k2' },+ },+ });++ await migration.up({ rootDir });++ const out = readJson(providersPath);+ // existing entry preserved untouched+ expect(out.providers['kimi-cli'].enabled).toBe(true);+ expect(out.providers['kimi-cli'].defaultModel).toBe('kimi-k2');+ // the still-missing TUI sibling is added alongside it+ expect(out.providers['kimi-tui']).toBeDefined();+ });++ it('deep-copies shipped arrays/objects so mutating the install cannot corrupt the frozen defaults', async () => {+ writeJson(providersPath, { providers: {} });+ await migration.up({ rootDir });+ const first = readJson(providersPath);+ first.providers['kimi-cli'].models.push('mutated');++ // A second install run must still ship the pristine model list.+ const rootDir2 = mkdtempSync(join(tmpdir(), 'migration-201-b-'));+ mkdirSync(join(rootDir2, 'data'), { recursive: true });+ const providersPath2 = join(rootDir2, 'data/providers.json');+ writeJson(providersPath2, { providers: {} });+ await migration.up({ rootDir: rootDir2 });+ expect(readJson(providersPath2).providers['kimi-cli'].models).not.toContain('mutated');+ rmSync(rootDir2, { recursive: true, force: true });+ });++ it('is idempotent — a second run makes no changes', async () => {+ writeJson(providersPath, {+ providers: { 'claude-code': { id: 'claude-code', type: 'cli', command: 'claude' } },+ });++ await migration.up({ rootDir });+ const afterFirst = readFileSync(providersPath, 'utf-8');+ await migration.up({ rootDir });+ expect(readFileSync(providersPath, 'utf-8')).toBe(afterFirst);+ });++ it('is a no-op when data/providers.json does not exist (fresh install)', async () => {+ await migration.up({ rootDir });+ expect(existsSync(providersPath)).toBe(false);+ });++ it('does not modify the file on invalid JSON', async () => {+ writeFileSync(providersPath, '{ not valid json');+ const before = readFileSync(providersPath, 'utf-8');++ await migration.up({ rootDir });++ expect(readFileSync(providersPath, 'utf-8')).toBe(before);+ });+});diff --git a/server/lib/README.md b/server/lib/README.mdindex f7af38c904..c9312f1258 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -98,13 +98,14 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `promptTemplate.js` | Mustache-flavored, dot-notation-aware prompt template engine. || `promptPartials.js` | Mustache-style partial expansion. || `mediaModels.js` | Single source of truth for image/video model metadata. |-| `providerModels.js` | Provider model resolution sentinels + helpers (`CODEX_CONFIGURED_DEFAULT` / `ANTIGRAVITY_CONFIGURED_DEFAULT` / `GROK_CONFIGURED_DEFAULT`, `resolveCliModel`, `filterSelectableModels`, Bedrock/OpenCode model mappers, model-flag scan helpers, `isCodexProvider`) plus reasoning-effort helpers for the claude/codex CLIs (`CLAUDE_EFFORT_LEVELS` / `CODEX_EFFORT_LEVELS` / `EFFORT_LEVELS`, `effortLevelsForProvider`, `resolveCliEffort`, `hasEffortFlag`, and `buildEffortArgs` — the one emitter of `--effort <level>` / `-c model_reasoning_effort=<level>`) plus codex startup-arg helpers (`CODEX_UPDATE_CHECK_KEY`, `hasCodexUpdateCheckConfig`, `buildCodexStartupArgs` — the one emitter of `-c check_for_update_on_startup=false`, spread by every codex spawn builder to disable the blocking startup update modal). |+| `providerModels.js` | Provider model resolution sentinels + helpers (`CODEX_CONFIGURED_DEFAULT` / `ANTIGRAVITY_CONFIGURED_DEFAULT` / `GROK_CONFIGURED_DEFAULT` / `KIMI_CONFIGURED_DEFAULT`, `resolveCliModel`, `filterSelectableModels`, Bedrock/OpenCode model mappers, model-flag scan helpers, `isCodexProvider`, `isKimiProvider`) plus reasoning-effort helpers for the claude/codex CLIs (`CLAUDE_EFFORT_LEVELS` / `CODEX_EFFORT_LEVELS` / `EFFORT_LEVELS`, `effortLevelsForProvider`, `resolveCliEffort`, `hasEffortFlag`, and `buildEffortArgs` — the one emitter of `--effort <level>` / `-c model_reasoning_effort=<level>`) plus codex startup-arg helpers (`CODEX_UPDATE_CHECK_KEY`, `hasCodexUpdateCheckConfig`, `buildCodexStartupArgs` — the one emitter of `-c check_for_update_on_startup=false`, spread by every codex spawn builder to disable the blocking startup update modal). || `modelPricing.js` | Per-model API billing rates for the /devtools/usage cost estimates — `resolveModelRates(providerId, model)` (exact → family regex → provider default → blended fallback, with a `matched` tier), `isFreeProvider` (ollama/lmstudio/`ollamaBacked`/localhost = free), `estimateCostUsd`, `PRICING_AS_OF`. Informational only (PortOS runs on subscriptions); excludes cache/batch/tier discounts. || `usageRange.js` | `resolveUsageRange({ period, from, to })` — pure period→inclusive-YYYY-MM-DD range resolution for the usage cost report (explicit dates win; `all` unbounded; default 7d). || `opencodeConfig.js` | OpenCode config builder — `buildOpencodeEnvVars(provider, model)` builds dynamic `OPENCODE_CONFIG_CONTENT` declaring the models map under `provider.ollama.models` (bare ids) for Ollama-backed OpenCode providers. Fixes --model rejection. || `cliProviderArgs.js` | Per-CLI argv conventions (`buildCliArgs`) for stdin prompt delivery — dependency-light extraction from runner.js so out-of-process callers (autofixer) can import it. || `cliProviderRun.js` | One-shot CLI provider invocation (`pickCliProvider` + `runCliProviderPrompt`) — lightweight path for the autofixer + calendar MCP sync to honor the configured provider/model. || `grok.js` | xAI Grok Build (`grok`) provider helpers — id/endpoint constants (`GROK_API_ID`/`GROK_CLI_ID`/`GROK_TUI_ID`/`GROK_API_ENDPOINT`), `isGrokCommand`/`isGrokCliProvider`/`isGrokTuiProvider` predicates, `ensureGrokHeadlessArgs`/`ensureGrokTuiArgs` argv builders (grok reads its prompt from `--prompt-file /dev/stdin`, not raw stdin; model selection uses the `GROK_CONFIGURED_DEFAULT` sentinel in `providerModels.js` so PortOS omits `--model` like Antigravity), and `prepareGrokPromptFile` (Windows temp-file delivery fallback). |+| `kimi.js` | Moonshot AI Kimi Code (`kimi`) provider helpers — id constants (`KIMI_CLI_ID`/`KIMI_TUI_ID`), `isKimiCommand`/`isKimiCliProvider`/`isKimiTuiProvider` predicates, `ensureKimiHeadlessArgs` (`--print`, implies `--afk`) / `ensureKimiTuiArgs` (`--yolo`) argv builders (model selection uses the `KIMI_CONFIGURED_DEFAULT` sentinel in `providerModels.js` so PortOS omits `--model` like Grok/Antigravity), and `prepareKimiPrompt` (delivers the prompt as the `--prompt <value>` argv, not stdin). || `runners.js` | Image-runner family constants. || `codexAssistantExtract.js` | Strip Codex CLI banner + echoed metadata from session transcript. || `codexCliOutput.js` | Network/system error patterns for `agentErrorAnalysis.js`. |diff --git a/server/lib/aiToolkit/defaults/providers.sample.json b/server/lib/aiToolkit/defaults/providers.sample.jsonindex 3fe7d34c45..4c23ce303c 100644--- a/server/lib/aiToolkit/defaults/providers.sample.json+++ b/server/lib/aiToolkit/defaults/providers.sample.json@@ -332,6 +332,42 @@"secretEnvVars": [],"tuiPromptDelayMs": 2500,"tuiIdleTimeoutMs": 180000+ },+ "kimi-cli": {+ "id": "kimi-cli",+ "name": "Kimi Code CLI",+ "type": "cli",+ "command": "kimi",+ "args": ["--print"],+ "models": ["kimi-configured-default"],+ "defaultModel": "kimi-configured-default",+ "lightModel": "kimi-configured-default",+ "mediumModel": "kimi-configured-default",+ "heavyModel": "kimi-configured-default",+ "contextWindow": 256000,+ "timeout": 300000,+ "enabled": false,+ "envVars": {},+ "secretEnvVars": []+ },+ "kimi-tui": {+ "id": "kimi-tui",+ "name": "Kimi Code TUI",+ "type": "tui",+ "command": "kimi",+ "args": ["--yolo"],+ "models": ["kimi-configured-default"],+ "defaultModel": "kimi-configured-default",+ "lightModel": "kimi-configured-default",+ "mediumModel": "kimi-configured-default",+ "heavyModel": "kimi-configured-default",+ "contextWindow": 256000,+ "timeout": 600000,+ "enabled": false,+ "envVars": {},+ "secretEnvVars": [],+ "tuiPromptDelayMs": 2500,+ "tuiIdleTimeoutMs": 180000}}}diff --git a/server/lib/aiToolkit/providers.test.js b/server/lib/aiToolkit/providers.test.jsindex d1643090c0..7739fe2f16 100644--- a/server/lib/aiToolkit/providers.test.js+++ b/server/lib/aiToolkit/providers.test.js@@ -183,6 +183,9 @@ describe('Provider Service', () => {expect(bedrock.name).toBe('Claude Code CLI: Bedrock');expect(samples.find(p => p.id === 'codex-tui')?.contextWindow).toBe(1000000);expect(samples.find(p => p.id === 'antigravity-cli')?.contextWindow).toBe(1048576);+ // Kimi Code process providers ship disabled with the K2 256K window.+ expect(samples.find(p => p.id === 'kimi-cli')?.contextWindow).toBe(256000);+ expect(samples.find(p => p.id === 'kimi-tui')?.command).toBe('kimi');});it('should exclude providers already in user config', async () => {diff --git a/server/lib/cliProviderArgs.js b/server/lib/cliProviderArgs.jsindex 2429377b63..e4d6d4eefd 100644--- a/server/lib/cliProviderArgs.js+++ b/server/lib/cliProviderArgs.js@@ -14,12 +14,14 @@* - Antigravity: `agy --print` with prompt piped to stdin* - Gemini CLI: legacy prompt piped to stdin (+ `-m <model>`)* - Grok Build: `grok --prompt-file /dev/stdin` (+ `--model <id>`, see grok.js)+ * - Kimi Code: `kimi --print --prompt <value>` (argv value, not stdin; see kimi.js)* - Claude Code: `-p -` (+ `--model <id>`)*/import { resolveCliModel, hasModelFlag, resolveBedrockCliModel, prefixOpencodeModel, isOpencodeCommand, buildCodexStartupArgs } from './providerModels.js';import { ensureAntigravityPrintArgs, isAntigravityCliProvider, isAntigravityCommand, prepareAntigravityPrompt } from './antigravity.js';import { isGrokCommand, ensureGrokHeadlessArgs, prepareGrokPromptFile } from './grok.js';+import { isKimiCommand, ensureKimiHeadlessArgs, prepareKimiPrompt } from './kimi.js';/*** Build CLI args based on provider type. Each CLI provider has different@@ -77,6 +79,15 @@ export function buildCliArgs(provider) {return ensureGrokHeadlessArgs(baseArgs, effectiveDefaultModel);}+ // Kimi Code CLI (`kimi`): headless one-shot. `--print` runs non-interactive+ // print mode (implies `--afk`, so tool calls auto-approve). The prompt is NOT+ // over stdin — it's spliced in as the `--prompt <value>` at spawn time by+ // prepareKimiPrompt (see below). Model flag gated like the others; the+ // configured-default sentinel resolves to null so `--model` is omitted.+ if (isKimiCommand(provider?.command)) {+ return ensureKimiHeadlessArgs(baseArgs, effectiveDefaultModel);+ }+// OpenCode CLI (`opencode run`): the headless, non-interactive subcommand. It// reads the prompt from stdin (the runner's shell-pipeline delivery, same as// every other CLI here) and selects the model with `-m provider/model`. The@@ -133,6 +144,8 @@ export function buildCliArgs(provider) {** - Antigravity (`agy`): the prompt is spliced in as the VALUE of --print* (agy does NOT read stdin) → `useStdin: false`.+ * - Kimi (`kimi`): the prompt is spliced in as the VALUE of --prompt+ * (kimi does NOT read stdin in --print mode) → `useStdin: false`.* - Grok on Windows: the `/dev/stdin` prompt-file is rewritten to a temp file* → `useStdin: false` with a real `cleanup`.* - Every other provider (Claude Code `-p -`, Codex `exec -`, OpenCode `run`):@@ -147,6 +160,9 @@ export function prepareCliPrompt(command, args, prompt) {if (isAntigravityCommand(command)) {return prepareAntigravityPrompt(args, prompt);}+ if (isKimiCommand(command)) {+ return prepareKimiPrompt(args, prompt);+ }return prepareGrokPromptFile(args, prompt);}diff --git a/server/lib/cliProviderArgs.test.js b/server/lib/cliProviderArgs.test.jsindex 053e2e96c3..e5d86274f0 100644--- a/server/lib/cliProviderArgs.test.js+++ b/server/lib/cliProviderArgs.test.js@@ -1,5 +1,5 @@import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';-import { buildCliArgs, stripBrokenModelFlags } from './cliProviderArgs.js';+import { buildCliArgs, stripBrokenModelFlags, prepareCliPrompt } from './cliProviderArgs.js';describe('cliProviderArgs', () => {// buildCliArgs reads process.env for the Bedrock signal; isolate the tests@@ -161,6 +161,38 @@ describe('cliProviderArgs', () => {});});+ describe('buildCliArgs — Kimi Code CLI', () => {+ it('builds a headless --print invocation without --model for the sentinel (seeded args)', () => {+ const args = buildCliArgs({ id: 'kimi-cli', command: 'kimi', args: ['--print'], defaultModel: 'kimi-configured-default' });+ expect(args).toEqual(['--print']);+ expect(args).not.toContain('--model');+ expect(args).not.toContain('kimi-configured-default');+ });++ it('adds --print when the saved args omit it', () => {+ const args = buildCliArgs({ id: 'kimi-cli', command: 'kimi', args: [], defaultModel: 'kimi-configured-default' });+ expect(args).toEqual(['--print']);+ });++ it('injects --model when a concrete model id is set (path/exe tolerant)', () => {+ const args = buildCliArgs({ id: 'my-kimi', command: '/opt/homebrew/bin/kimi', args: ['--print'], defaultModel: 'kimi-k2' });+ expect(args).toEqual(['--print', '--model', 'kimi-k2']);+ });++ it('respects a user-baked --model and does not duplicate it', () => {+ const args = buildCliArgs({ id: 'kimi-cli', command: 'kimi', args: ['--print', '--model', 'mine'], defaultModel: 'kimi-configured-default' });+ expect(args.filter((a) => a === '--model')).toHaveLength(1);+ expect(args).toContain('mine');+ });++ it('delivers the prompt as the --prompt argv value (useStdin false)', () => {+ const built = buildCliArgs({ id: 'kimi-cli', command: 'kimi', args: ['--print'], defaultModel: 'kimi-configured-default' });+ const { args, useStdin } = prepareCliPrompt('kimi', built, 'write a haiku');+ expect(args).toEqual(['--print', '--prompt', 'write a haiku']);+ expect(useStdin).toBe(false);+ });+ });+describe('stripBrokenModelFlags', () => {it('drops dangling / empty model flags but keeps pinned ones', () => {expect(stripBrokenModelFlags(['--model'])).toEqual([]);diff --git a/server/lib/index.js b/server/lib/index.jsindex 322a50386b..8a8886f5fb 100644--- a/server/lib/index.js+++ b/server/lib/index.js@@ -97,6 +97,7 @@ export * from './hfDownload.js';export * from './sseDownload.js';export * from './sseHeaders.js';export * from './installLogger.js';+export * from './kimi.js';export * from './mediaModels.js';export * from './promptPartials.js';export * from './promptRunner.js';diff --git a/server/lib/kimi.js b/server/lib/kimi.jsnew file mode 100644index 0000000000..4325a0c979--- /dev/null+++ b/server/lib/kimi.js@@ -0,0 +1,142 @@+/**+ * Per-CLI conventions for Moonshot AI's "Kimi Code" coding agent (binary: `kimi`).+ *+ * Kimi Code (MoonshotAI/kimi-cli, MIT-licensed) ships two PortOS process-provider+ * shapes (the plain HTTP API entry already exists separately as `nvidia-kimi`):+ * - `kimi-cli` (type `cli`) — headless one-shot via `kimi --print`.+ * - `kimi-tui` (type `tui`) — the interactive Kimi Code TUI driven over a PTY.+ *+ * Prompt delivery (headless): unlike claude/codex (raw stdin), `kimi --print`+ * takes the prompt as the VALUE of its `--prompt`/`-p` flag and does NOT read+ * stdin. `--print` also implicitly enables `--afk` (away-from-keyboard: auto-+ * approve tool calls, auto-dismiss AskUserQuestion), so a headless run never+ * stalls on an approval prompt. `prepareKimiPrompt` splices the prompt in as the+ * `--prompt` value and reports `useStdin: false`, mirroring the antigravity+ * `{ args, useStdin, cleanup }` shape so the shared `prepareCliPrompt` dispatcher+ * can handle it uniformly.+ *+ * Model selection mirrors Antigravity/Grok Build: PortOS does not pick a model.+ * The stored sentinel lives in providerModels.js (`KIMI_CONFIGURED_DEFAULT`);+ * spawn paths omit `--model` (the sentinel resolves to null via `resolveCliModel`)+ * so the local `kimi` binary uses its own configured default (settable via+ * `/model`). A user who pins a real model id gets `--model <id>` injected.+ *+ * Dependency-light on purpose: imports only `providerModels.js` helpers, mirroring+ * `grok.js`/`antigravity.js` so it stays importable from the standalone autofixer.+ *+ * NOTE: `kimi` was not installed in the dev environment where this shipped, so the+ * argv-value prompt path (`--prompt <value>`, like `agy --print <value>`) was+ * chosen as the documented default and should be confirmed against a live binary.+ */++import { commandBasename, hasModelFlag } from './providerModels.js';++const NOOP_CLEANUP = () => {};++// True when argv contains any of `flags`, in either separated (`--flag`) or+// joined (`--flag=value`) form. The generic scan behind the kimi arg builders.+const argvHasFlag = (args = [], flags) =>+ args.some((a) => typeof a === 'string' && flags.some((f) => a === f || a.startsWith(`${f}=`)));++export const KIMI_CLI_ID = 'kimi-cli';+export const KIMI_TUI_ID = 'kimi-tui';++// `--print` puts kimi in non-interactive print mode (implies `--afk`).+const PRINT_FLAGS = ['--print'];+// The prompt-carrying flags — kimi reads the prompt as this flag's VALUE.+const PROMPT_FLAGS = ['--prompt', '-p'];+// Auto-approval postures for the unattended PTY: `--yolo`/`-y` auto-approve all+// tool calls; `--afk` also auto-dismisses AskUserQuestion. Any one already+// present means the user pinned their own posture — don't add another.+const APPROVAL_FLAGS = ['--yolo', '-y', '--afk'];++/**+ * True when a provider command points at the Kimi Code binary — the bare `kimi`+ * on PATH, an absolute/relative path to it, or an optional Windows `.exe` suffix+ * (same matching rules as `isGrokCommand`/`isOpencodeCommand`).+ * @param {string|null|undefined} command+ * @returns {boolean}+ */+export function isKimiCommand(command) {+ return commandBasename(command) === 'kimi';+}++/** True for the CLI (headless) Kimi provider. */+export function isKimiCliProvider(provider) {+ return provider?.id === KIMI_CLI_ID+ || (provider?.type === 'cli' && isKimiCommand(provider?.command));+}++/** True for the TUI (interactive) Kimi provider. */+export function isKimiTuiProvider(provider) {+ return provider?.id === KIMI_TUI_ID+ || (provider?.type === 'tui' && isKimiCommand(provider?.command));+}++/**+ * Build the headless (one-shot) argv for the Kimi Code CLI. Ensures, when not+ * already pinned by the user's saved `args`:+ * - `--print` — non-interactive print mode (implies `--afk`, so tool calls+ * auto-approve; PortOS parses stdout as plain text).+ * - `--model <id>` — gated on `model` being a real id (the sentinel already+ * resolved to null upstream) AND no user-baked model flag.+ * The prompt itself is NOT added here — it's spliced in as the `--prompt` value+ * at spawn time by `prepareKimiPrompt`.+ * @param {string[]} baseArgs - user/legacy args (already model-flag-sanitized)+ * @param {string|null|undefined} model - defaultModel to pin, or null to omit+ * @returns {string[]}+ */+export function ensureKimiHeadlessArgs(baseArgs = [], model) {+ const out = [...baseArgs];+ if (!argvHasFlag(out, PRINT_FLAGS)) {+ out.push('--print');+ }+ if (model && !hasModelFlag(out)) {+ out.push('--model', model);+ }+ return out;+}++/**+ * Ensure the interactive Kimi TUI argv auto-approves tool executions so a+ * file-writing agent isn't stranded on an approval prompt (mirrors the codex+ * `--dangerously-bypass-approvals-and-sandbox` / claude-code-tui+ * `--dangerously-skip-permissions` / grok `--permission-mode bypassPermissions`+ * TUI defaults). Idempotent when the user already pinned an approval posture.+ * @param {string[]} args+ * @returns {string[]}+ */+export function ensureKimiTuiArgs(args = []) {+ const out = [...args];+ if (!argvHasFlag(out, APPROVAL_FLAGS)) {+ out.push('--yolo');+ }+ return out;+}++/**+ * Spawn-time prompt delivery for the Kimi Code CLI: splice the prompt in as the+ * VALUE of the `--prompt` flag (kimi does NOT read stdin in `--print` mode).+ * Mirrors the `{ args, useStdin, cleanup }` shape of+ * `antigravity.js#prepareAntigravityPrompt` / `grok.js#prepareGrokPromptFile` so+ * the spawn sites can dispatch through the single `prepareCliPrompt` helper.+ *+ * @param {string[]} args - argv as built by ensureKimiHeadlessArgs+ * @param {string} prompt - the full prompt text+ * @returns {{ args: string[], useStdin: false, cleanup: () => void }}+ */+export function prepareKimiPrompt(args = [], prompt = '') {+ const out = [...args];+ // Find the LAST prompt flag so the value lands correctly even if a user baked+ // one into provider.args; otherwise append a fresh `--prompt <value>` pair.+ let idx = -1;+ for (let i = out.length - 1; i >= 0; i--) {+ if (PROMPT_FLAGS.includes(out[i])) { idx = i; break; }+ }+ if (idx === -1) {+ out.push('--prompt', typeof prompt === 'string' ? prompt : '');+ } else {+ out.splice(idx + 1, 0, typeof prompt === 'string' ? prompt : '');+ }+ return { args: out, useStdin: false, cleanup: NOOP_CLEANUP };+}diff --git a/server/lib/kimi.test.js b/server/lib/kimi.test.jsnew file mode 100644index 0000000000..28570c7c28--- /dev/null+++ b/server/lib/kimi.test.js@@ -0,0 +1,94 @@+import { describe, it, expect } from 'vitest';+import {+ KIMI_CLI_ID,+ KIMI_TUI_ID,+ isKimiCommand,+ isKimiCliProvider,+ isKimiTuiProvider,+ ensureKimiHeadlessArgs,+ ensureKimiTuiArgs,+ prepareKimiPrompt,+} from './kimi.js';++describe('kimi.js', () => {+ describe('isKimiCommand', () => {+ it('matches the bare binary, a path, and a Windows .exe', () => {+ expect(isKimiCommand('kimi')).toBe(true);+ expect(isKimiCommand('/opt/homebrew/bin/kimi')).toBe(true);+ expect(isKimiCommand('C:\\tools\\Kimi.exe')).toBe(true);+ });+ it('rejects other binaries and empty input', () => {+ expect(isKimiCommand('grok')).toBe(false);+ expect(isKimiCommand('claude')).toBe(false);+ expect(isKimiCommand('')).toBe(false);+ expect(isKimiCommand(null)).toBe(false);+ expect(isKimiCommand(undefined)).toBe(false);+ });+ });++ describe('provider predicates', () => {+ it('detects the CLI provider by id or type+command', () => {+ expect(isKimiCliProvider({ id: KIMI_CLI_ID })).toBe(true);+ expect(isKimiCliProvider({ type: 'cli', command: '/usr/local/bin/kimi' })).toBe(true);+ expect(isKimiCliProvider({ type: 'tui', command: 'kimi' })).toBe(false);+ expect(isKimiCliProvider({ id: 'grok-cli', type: 'cli', command: 'grok' })).toBe(false);+ });+ it('detects the TUI provider by id or type+command', () => {+ expect(isKimiTuiProvider({ id: KIMI_TUI_ID })).toBe(true);+ expect(isKimiTuiProvider({ type: 'tui', command: 'kimi' })).toBe(true);+ expect(isKimiTuiProvider({ type: 'cli', command: 'kimi' })).toBe(false);+ });+ });++ describe('ensureKimiHeadlessArgs', () => {+ it('adds --print when absent', () => {+ expect(ensureKimiHeadlessArgs([])).toEqual(['--print']);+ });+ it('does not double-add --print when already present (seeded default)', () => {+ expect(ensureKimiHeadlessArgs(['--print'])).toEqual(['--print']);+ });+ it('injects --model only for a real (non-null) model id', () => {+ expect(ensureKimiHeadlessArgs(['--print'], 'kimi-k2')).toEqual(['--print', '--model', 'kimi-k2']);+ expect(ensureKimiHeadlessArgs(['--print'], null)).toEqual(['--print']);+ expect(ensureKimiHeadlessArgs(['--print'], '')).toEqual(['--print']);+ });+ it('does not duplicate a user-baked model flag', () => {+ expect(ensureKimiHeadlessArgs(['--print', '--model', 'mine'], 'other')).toEqual(['--print', '--model', 'mine']);+ expect(ensureKimiHeadlessArgs(['-m', 'mine'], 'other')).toEqual(['-m', 'mine', '--print']);+ });+ });++ describe('ensureKimiTuiArgs', () => {+ it('adds --yolo when no approval posture is pinned', () => {+ expect(ensureKimiTuiArgs([])).toEqual(['--yolo']);+ });+ it('is idempotent when --yolo is already present (seeded default)', () => {+ expect(ensureKimiTuiArgs(['--yolo'])).toEqual(['--yolo']);+ });+ it('respects a user-pinned approval posture (-y / --afk)', () => {+ expect(ensureKimiTuiArgs(['-y'])).toEqual(['-y']);+ expect(ensureKimiTuiArgs(['--afk'])).toEqual(['--afk']);+ });+ });++ describe('prepareKimiPrompt', () => {+ it('appends the prompt as the --prompt value, useStdin false', () => {+ const { args, useStdin, cleanup } = prepareKimiPrompt(['--print'], 'do the thing');+ expect(args).toEqual(['--print', '--prompt', 'do the thing']);+ expect(useStdin).toBe(false);+ expect(typeof cleanup).toBe('function');+ });+ it('splices the value after a user-baked prompt flag', () => {+ const { args } = prepareKimiPrompt(['--print', '--prompt'], 'task');+ expect(args).toEqual(['--print', '--prompt', 'task']);+ });+ it('splices after the short -p flag', () => {+ const { args } = prepareKimiPrompt(['-p'], 'task');+ expect(args).toEqual(['-p', 'task']);+ });+ it('coerces a non-string prompt to empty', () => {+ const { args } = prepareKimiPrompt(['--print'], undefined);+ expect(args).toEqual(['--print', '--prompt', '']);+ });+ });+});diff --git a/server/lib/providerModels.js b/server/lib/providerModels.jsindex 0c60eaa94f..ba77ba7e1f 100644--- a/server/lib/providerModels.js+++ b/server/lib/providerModels.js@@ -9,11 +9,16 @@ export const ANTIGRAVITY_CONFIGURED_DEFAULT = 'antigravity-configured-default';// uses its own latest default. Stored as a sentinel so pickers hide the model// dropdown (same UX as Codex / Antigravity).export const GROK_CONFIGURED_DEFAULT = 'grok-configured-default';+// Kimi Code CLI/TUI: same posture as Grok/Antigravity — PortOS does not select a+// model; the local `kimi` binary uses its own configured default. Stored as a+// sentinel so pickers hide the model dropdown.+export const KIMI_CONFIGURED_DEFAULT = 'kimi-configured-default';const CONFIGURED_DEFAULT_SENTINELS = new Set([CODEX_CONFIGURED_DEFAULT,ANTIGRAVITY_CONFIGURED_DEFAULT,GROK_CONFIGURED_DEFAULT,+ KIMI_CONFIGURED_DEFAULT,]);export const isCodexConfiguredDefault = (model) => model === CODEX_CONFIGURED_DEFAULT;@@ -73,6 +78,19 @@ export function isCodexProvider(provider) {return id === 'codex' || id === 'codex-tui' || commandBasename(provider?.command) === 'codex';}+/**+ * True when a provider is Kimi-Code-flavored — the shipped `kimi-cli`/`kimi-tui`+ * ids or any provider whose launch command basename is `kimi` (path/exe tolerant).+ * The single home for the kimi signature, same posture as `isCodexProvider`.+ * Mirrored in client/src/utils/providers.js — keep in lockstep.+ * @param {{id?:string, command?:string}|null|undefined} provider+ * @returns {boolean}+ */+export function isKimiProvider(provider) {+ const id = String(provider?.id || '').toLowerCase();+ return id === 'kimi-cli' || id === 'kimi-tui' || commandBasename(provider?.command) === 'kimi';+}+/*** The effort levels a provider's CLI accepts, or null when the provider has no* effort control (antigravity, opencode, grok, HTTP API providers). Keyed on thediff --git a/server/lib/providerModels.test.js b/server/lib/providerModels.test.jsindex 1002bf2b0b..ce97b0a5fc 100644--- a/server/lib/providerModels.test.js+++ b/server/lib/providerModels.test.js@@ -3,6 +3,7 @@ import {ANTIGRAVITY_CONFIGURED_DEFAULT,CODEX_CONFIGURED_DEFAULT,GROK_CONFIGURED_DEFAULT,+ KIMI_CONFIGURED_DEFAULT,isCodexConfiguredDefault,isConfiguredDefaultModel,resolveCliModel,@@ -31,7 +32,8 @@ import {CODEX_UPDATE_CHECK_KEY,hasCodexUpdateCheckConfig,buildCodexStartupArgs,- isCodexProvider+ isCodexProvider,+ isKimiProvider} from './providerModels.js';describe('providerModels', () => {@@ -146,6 +148,7 @@ describe('providerModels', () => {expect(resolveCliModel(CODEX_CONFIGURED_DEFAULT)).toBeNull();expect(resolveCliModel(ANTIGRAVITY_CONFIGURED_DEFAULT)).toBeNull();expect(resolveCliModel(GROK_CONFIGURED_DEFAULT)).toBeNull();+ expect(resolveCliModel(KIMI_CONFIGURED_DEFAULT)).toBeNull();});it('returns null for empty / nullish values', () => {@@ -194,6 +197,17 @@ describe('providerModels', () => {});});+ describe('isKimiProvider', () => {+ it('matches the shipped ids and a path/exe command, rejects others', () => {+ expect(isKimiProvider({ id: 'kimi-cli' })).toBe(true);+ expect(isKimiProvider({ id: 'kimi-tui' })).toBe(true);+ expect(isKimiProvider({ id: 'custom', command: '/opt/homebrew/bin/kimi' })).toBe(true);+ expect(isKimiProvider({ id: 'custom', command: 'C:\\tools\\Kimi.exe' })).toBe(true);+ expect(isKimiProvider({ id: 'grok-cli', command: 'grok' })).toBe(false);+ expect(isKimiProvider(null)).toBe(false);+ });+ });+describe('buildEffortArgs', () => {it('emits --effort for claude and a -c config pair for codex', () => {expect(buildEffortArgs('high', { id: 'claude-code', command: 'claude' })).toEqual(['--effort', 'high']);@@ -287,6 +301,7 @@ describe('providerModels', () => {expect(isConfiguredDefaultModel(CODEX_CONFIGURED_DEFAULT)).toBe(true);expect(isConfiguredDefaultModel(ANTIGRAVITY_CONFIGURED_DEFAULT)).toBe(true);expect(isConfiguredDefaultModel(GROK_CONFIGURED_DEFAULT)).toBe(true);+ expect(isConfiguredDefaultModel(KIMI_CONFIGURED_DEFAULT)).toBe(true);expect(isConfiguredDefaultModel('gpt-5')).toBe(false);});});diff --git a/server/lib/stageRunner.js b/server/lib/stageRunner.jsindex e527a2c7f0..7617d96f8a 100644--- a/server/lib/stageRunner.js+++ b/server/lib/stageRunner.js@@ -121,6 +121,7 @@ export const DEFAULT_LARGE_CONTEXT_WINDOW = 128_000;export const CODEX_CONTEXT_WINDOW = 1_000_000;export const GEMINI_CONTEXT_WINDOW = 1_048_576;export const GROK_CONTEXT_WINDOW = 256_000;+export const KIMI_CONTEXT_WINDOW = 256_000;// Keep in sync with client/src/utils/providers.js.const KNOWN_MODEL_CONTEXT_WINDOWS = Object.freeze([@@ -153,6 +154,7 @@ export function knownProviderContextWindow(provider) {if (isCodexProvider(provider)) return CODEX_CONTEXT_WINDOW;if (id === 'antigravity-cli' || id === 'antigravity-tui' || command === 'agy') return GEMINI_CONTEXT_WINDOW;if (id === 'grok-cli' || id === 'grok-tui' || command === 'grok') return GROK_CONTEXT_WINDOW;+ if (id === 'kimi-cli' || id === 'kimi-tui' || command === 'kimi') return KIMI_CONTEXT_WINDOW;return null;}diff --git a/server/lib/stageRunner.test.js b/server/lib/stageRunner.test.jsindex 4a12a8340e..c2f95bd0a1 100644--- a/server/lib/stageRunner.test.js+++ b/server/lib/stageRunner.test.js@@ -31,6 +31,7 @@ const {CODEX_CONTEXT_WINDOW,GEMINI_CONTEXT_WINDOW,GROK_CONTEXT_WINDOW,+ KIMI_CONTEXT_WINDOW,effectiveContextWindow,knownModelContextWindow,knownProviderContextWindow,@@ -109,6 +110,9 @@ describe('stageRunner — context windows', () => {// explicit contextWindow must resolve the same 256K on both sides.expect(knownProviderContextWindow({ id: 'grok-cli', type: 'cli', command: 'grok' })).toBe(GROK_CONTEXT_WINDOW);expect(knownProviderContextWindow({ id: 'grok-tui', type: 'tui', command: 'grok' })).toBe(GROK_CONTEXT_WINDOW);+ // Kimi Code (K2's 256K window) — same on both server + client mirrors.+ expect(knownProviderContextWindow({ id: 'kimi-cli', type: 'cli', command: 'kimi' })).toBe(KIMI_CONTEXT_WINDOW);+ expect(knownProviderContextWindow({ id: 'kimi-tui', type: 'tui', command: 'kimi' })).toBe(KIMI_CONTEXT_WINDOW);});it('normalizes command paths to the basename for vendor windows (#2337)', () => {@@ -120,6 +124,7 @@ describe('stageRunner — context windows', () => {expect(knownProviderContextWindow({ id: 'custom', type: 'cli', command: './bin/codex' })).toBe(CODEX_CONTEXT_WINDOW);// Windows .exe suffix + backslash separators.expect(knownProviderContextWindow({ id: 'custom', type: 'cli', command: 'C:\\tools\\grok.exe' })).toBe(GROK_CONTEXT_WINDOW);+ expect(knownProviderContextWindow({ id: 'custom', type: 'cli', command: '/opt/homebrew/bin/kimi' })).toBe(KIMI_CONTEXT_WINDOW);// Unrelated custom command still falls through to null.expect(knownProviderContextWindow({ id: 'custom', type: 'cli', command: '/opt/homebrew/bin/mycli' })).toBeNull();});diff --git a/server/lib/tuiHandshake.js b/server/lib/tuiHandshake.jsindex 312a9c178f..c8480f75da 100644--- a/server/lib/tuiHandshake.js+++ b/server/lib/tuiHandshake.js@@ -15,6 +15,7 @@import { resolveCliModel, hasModelFlag, resolveBedrockCliModel, prefixOpencodeModel, isOpencodeCommand, buildCodexStartupArgs, commandBasename } from './providerModels.js';import { ensureAntigravityTuiArgs, isAntigravityCommand } from './antigravity.js';import { ensureGrokTuiArgs, isGrokCommand } from './grok.js';+import { ensureKimiTuiArgs, isKimiCommand } from './kimi.js';// ─── Paste handshake constants ────────────────────────────────────────────@@ -765,6 +766,7 @@ export function inferTuiCommand(id) {if (id.includes('codex')) return 'codex';if (id.includes('antigravity')) return 'agy';if (id.includes('gemini')) return 'gemini';+ if (id.includes('kimi')) return 'kimi';return 'claude';}@@ -813,6 +815,9 @@ export function applyCommandDefaults(command, args) {if (isGrokCommand(command)) {return ensureGrokTuiArgs(args);}+ if (isKimiCommand(command)) {+ return ensureKimiTuiArgs(args);+ }return args;}diff --git a/server/services/agentCliSpawning.js b/server/services/agentCliSpawning.jsindex 04ab210fb9..f2b22ccd88 100644--- a/server/services/agentCliSpawning.js+++ b/server/services/agentCliSpawning.js@@ -28,6 +28,7 @@ import { createImmediateFallbackSignalDetector } from '../lib/aiToolkit/errorDetimport { ensureAntigravityPrintArgs, isAntigravityCliProvider } from '../lib/antigravity.js';import { prepareCliPrompt } from '../lib/cliProviderArgs.js';import { isGrokCommand, ensureGrokHeadlessArgs } from '../lib/grok.js';+import { isKimiCommand, ensureKimiHeadlessArgs } from '../lib/kimi.js';import { resolveCliModel, buildEffortArgs, buildCodexStartupArgs, resolveBedrockCliModel, prefixOpencodeModel, hasModelFlag, isOpencodeCommand, applyLeanClaudeArgs, providerSuppliesGithubToken } from '../lib/providerModels.js';import { agentGuardEnv } from '../lib/agentGuard/index.js';import { resolveForgeTokenEnv } from './git.js';@@ -334,6 +335,22 @@ export function buildCliSpawnConfig(provider, model, settingsEnv = {}, { systemP};}+ // Kimi Code CLI (`kimi`): headless one-shot agent. `--print` runs non-+ // interactive print mode (implies `--afk`, so tool calls auto-approve). The+ // combined contract+task prompt is delivered as the `--prompt <value>` argv+ // (kimi does NOT read stdin in print mode) — spliced in at the spawn site via+ // prepareCliPrompt. Emits plain text (the live-output handler falls through to+ // its default text path, like grok/opencode). A non-Claude command, so+ // agentLifecycle keeps the operating contract in the prompt (no system-prompt-+ // file split) — matching codex/antigravity/grok/opencode.+ if (isKimiCommand(provider?.command)) {+ return {+ command: provider?.command || 'kimi',+ args: ensureKimiHeadlessArgs(provider?.args || [], effectiveModel),+ stdinMode: 'prompt',+ };+ }+// Default: Claude Code CLI. applyLeanClaudeArgs adds `--bare// --strict-mcp-config` for Ollama-backed claude sessions (no-op otherwise,// idempotent against user-baked flags); the system-prompt contract file@@ -480,8 +497,9 @@ export async function spawnDirectly({// working "Run Prompt" path (server/services/runner.js); resolved against// childEnv so a provider PATH override is honored. See issue #2243.// Deliver the prompt per provider convention: antigravity as the --print- // VALUE (no stdin); grok's `--prompt-file /dev/stdin` via stdin (POSIX) / temp- // file (Windows); every other provider via stdin (writePromptToStdin=true).+ // VALUE and kimi as the --prompt VALUE (no stdin); grok's `--prompt-file+ // /dev/stdin` via stdin (POSIX) / temp file (Windows); every other provider via+ // stdin (writePromptToStdin=true).const { args: deliveredArgs, useStdin: writePromptToStdin, cleanup: cleanupPromptFile } = prepareCliPrompt(cliConfig.command, cliConfig.args, prompt);const { command: spawnCommand, args: spawnArgs } = prepareCliSpawn(cliConfig.command, deliveredArgs, childEnv);