# Kcoder

> KCoder — agentic AI coding platform by KunlunMeta: model providers, tool system, permissions & sandbox, long-term memory, skills, MCP, sub-agents, terminal TUI and KCoder Studio desktop app. Source snapshots and Windows installers are published under Releases.

- **Type:** MCP server
- **Install:** `agentstack add mcp-kunlunmeta-dev-kcoder`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [KunlunMeta-dev](https://agentstack.voostack.com/s/kunlunmeta-dev)
- **Installs:** 0
- **Category:** [AI & ML](https://agentstack.voostack.com/c/ai-and-ml)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [KunlunMeta-dev](https://github.com/KunlunMeta-dev)
- **Source:** https://github.com/KunlunMeta-dev/Kcoder
- **Website:** https://github.com/KunlunMeta-dev/Kcoder/releases

## Install

```sh
agentstack add mcp-kunlunmeta-dev-kcoder
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# KCoder

KCoder is an agentic AI coding platform built by **KunlunMeta Artificial Intelligence Technology (Shanghai) Co., Ltd.** It is an engineering-grade agent runtime rather than a wrapper that prints model output to the terminal: model providers, the agent loop, the tool system, permissions and sandboxing, structured long-term memory, Skills, spec-driven workflows, plugin hooks, MCP, sub-agents, session state, a terminal TUI, background daemons, Goal Pro long-objective verification, and desktop/Web/mobile access through KCoder Studio.

This repository is the public source snapshot of KCoder and the home of its installer releases.

What is inside:

- `crates/` — the Rust workspace: cross-crate contracts (`kcoder_types`), configuration (`kcoder_config`), provider transports (`kcoder_api`), session state (`kcoder_state`), orchestration (`kcoder_engine`), tools (`kcoder_tools`), permissions (`kcoder_permissions`), hooks and plugins (`kcoder_hooks`, `kcoder_plugins`), MCP (`kcoder_mcp`), specs (`kcoder_specs`), workflows (`kcoder_workflow`), memory and skills (`kcoder_memory`, `kcoder_skills`), the TUI (`kcoder_repl`), the binary and app-server (`kcoder_cli`), and the app-server wire contract (`kcoder_app_protocol`). The [Repository Layout](#repository-layout) section lists every crate.
- `apps/kcoder-studio/` — KCoder Studio: a Tauri desktop shell with a React renderer, speaking the same app-server JSON-RPC contract used by Web and mobile clients.
- `scripts/` and `tools/` — build, installer and verification helpers used by the release flow.

The single canonical entry point is `kcoder`: the installer, docs, scripts, and everyday usage all standardize on it. `kcoder --help` or `-h` is a read-only probe and does not initialize any user configuration.

## Screenshots

Terminal TUI:

KCoder Studio (desktop app):

## Current Positioning

KCoder aims to be more than a wrapper that simply prints model output to the terminal — it is an auditable, extensible, locally runnable engineering-grade agent runtime:

- Clear boundaries between providers, engine, tools, TUI, memory, permissions, specs, hooks, workflows, etc. through modular crate splits.
- Unified `Tool` trait managing built-in tools, MCP tools, and future plugin contributions.
- Permission modes, Landlock sandbox, hook events, audit logs, and tool output truncation reduce automation risk.
- Structured SQLite (+FTS5) memory, observer, privacy policy, and `/memories status` support long-term context.
- A spec-driven workflow turns engineering discipline, change planning, TDD, verification, and archival flows into tool-executable workflows.
- TUI queue, real-time rendering, tool status, background sub-agents, `/goal` objective progression, and `/goal-pro` strict verification support long tasks.
- app-server (JSON-RPC over stdio) and Gateway act as a machine-readable backend for desktop/Web/mobile clients, enabling KCoder Studio multi-platform access.

## Quick Start

Windows users can install the packaged **KCoder Studio** (desktop app with the bundled CLI and browser resource) from
[Releases](https://github.com/KunlunMeta-dev/Kcoder/releases): download `KCoder-Studio-Setup--win-x64.exe` and verify it
against the matching `SHA256SUMS.txt` published with every build. The rest of this section builds from source.

The local release installer builds `kcoder` from the current checkout without contacting GitHub Releases or cloud CI,
nor invoking `sudo`, reading source `.env`, or importing any credentials. Prepare a Rust toolchain (Rust 1.95) first and enter the repo:

```bash
git clone https://github.com/KunlunMeta-dev/Kcoder.git
cd Kcoder
scripts/install/installers/cli-release.sh
export PATH="$HOME/.local/bin:$PATH"
kcoder --version
```

On Linux the build needs the Secret Service client library used by the OS credential store:
`sudo apt install libdbus-1-dev` (or the equivalent for your distribution).

By default it executes `cargo build --release --locked`; if a local release binary already exists, use
`KCODER_RELEASE_BIN=` to skip the build. The first run will create the missing
`~/.config/kcoder/settings.json`; existing files will not be overwritten. See the complete boundary between installer local builds and server deployments in
`scripts/install/README.md`.

Windows PowerShell users run a local MSVC release build inside the checkout:

```powershell
git clone https://github.com/KunlunMeta-dev/Kcoder.git
Set-Location Kcoder
.\scripts\install\installers\cli-release.ps1
$env:Path += ";$env:LOCALAPPDATA\Programs\KCoder\bin"
kcoder.exe --version
```

Uninstall by running `scripts/install/installers/uninstall.ps1` (or `uninstall.sh`); user configuration, credentials, and history are preserved.

To install system-wide commands from source, use `scripts/install/installers/cli-release-server.sh` (release) and
`cli-dev-server.sh` (debug). Both must run as root and only update `/usr/local/bin` system entries.
The release entry uses the formal `~/.config/kcoder`, and does not import dev configuration or repo credentials; the debug entry uses an isolated
`~/.config/kcoder-dev` and syncs dev configuration and provider credentials.

The Linux system release installer also prepares a pinned version of Google Chrome for Testing; the complete
Studio package for Windows/Linux also ships this resource. For offline input, SHA-256 verification, and uncovered CLI package boundaries, see
`scripts/release/README.md` (Chrome packaging notes). Browser dependency download failures will be flagged explicitly and do not affect CLI installation.

First-time configuration:

```bash
kcoder config init
kcoder auth login --provider kunlunmeta

# Launch TUI in any project directory.
cd /path/to/project
kcoder
```

You can also use `kcoder auth import --env-file .env` to import credentials for all configured Providers from dotenv at once.
API keys are always written to `credentials.json` with permission `0600`, not `settings.json`.

If you only need standalone release attachments, use `scripts/release/package_release.sh` / `package_release.ps1` to generate
CLI tar.gz or ZIP (including the `lib/kcoder/rg` bundled for the target platform); the CLI release installer does not download these cloud attachments by default.
On Linux hosts, you can use `scripts/release/package_windows_release.sh` to cross-build a Windows GNU CLI ZIP.

KCoder Studio (desktop/Web/mobile) launch:

```bash
scripts/install/installers/studio-client.sh  # first-time user-level install of the kcoder-studio command
kcoder-studio --dev                            # start Electron directly, no systemd dependency
```

For a managed mode that survives terminal exit:

```bash
scripts/launch/kcoder-studio-web-dev.sh            # default systemd-managed dev profile
scripts/launch/kcoder-studio-web-release.sh        # default systemd-managed release profile
scripts/launch/kcoder-studio-web-dev.sh --direct   # optional: foreground Electron
```

The managed mode installs and starts four systemd units: Gateway 4173 only listens on loopback, Studio Web 4174 and Mobile Web 4175
default to listening on all local network interfaces on the corresponding ports, and the Expo bundler 14175 listens only on loopback.
`kcoder-studio --dev` or `--direct` is launched by Electron which spawns a loopback Gateway; the Gateway manages a profile-matching `kcoder app-server` on demand and cleans up child processes on exit. Plain CLI installation only provides the terminal command and does not configure systemd. See the Studio
Gateway security model and app-server protocol details in the [KCoder Studio](#kcoder-studio) section below.

After installation you can run directly in any project directory:

```bash
kcoder
kcoder "run the tests and fix failures"
```

## First run

```bash
kcoder config path                      # where settings live
kcoder auth login --provider  # API keys go to credentials, never to settings
kcoder "summarize this repository"
```

Providers, endpoints, models and runtime knobs belong to `settings.json`; API keys belong to `credentials.json` and are written by `kcoder auth`. JSONC comments and trailing commas are supported, and `settings.schema.jsonc` in the same directory provides editor validation.

## Configuration

KCoder uses layered configuration; later-loaded files override earlier-loaded scalars and arrays; nested objects are merged field by field,
so the project layer can either change a single subfield or use an empty array to clear user-layer lists:

| File | Scope | Git | Suitable for |
|------|------|-----|----------|
| `~/.config/kcoder/settings.json` | User | N/A | Models and personal preferences common to all projects |
| `/settings.json` | Executable directory | Managed with the release package or deployment directory | Runtime configuration from release packages, portable deployments, or administrator |
| `.kcoder/settings.json` | Project | Recommended to commit | Team-shared permissions, MCP, and project model settings |
| `.kcoder/settings.local.json` | Project personal | Auto-ignored by `.kcoder/.gitignore` | Per-user override for the current project |

The full priority from low to high: embedded defaults (`settting_inline.jsonc` → schema) → user configuration →
executable directory configuration → project configuration → project local configuration → explicit `--settings-file` overlay (repeatable, later has higher priority) →
environment variables → CLI arguments. When launched from a project subdirectory, it walks upward to find the nearest `.kcoder` configuration; the program does not auto-scan the workspace `.env`,
and `.env` under the user profile only supplements missing environment variables.

Each launch atomically replaces the bundled `settings.schema.jsonc` into the user configuration directory for editor validation and completion;
the configuration metadata `meta.config_version` is currently `1`; future versions will explicitly reject old files at load time. The only Provider bundled
is `kunlunmeta`; when `providers` is declared in any explicit configuration file, only the union of names declared by these files is kept; removed configurations must not be re-added via
defaults, imports, or bootstrap packages.

Common commands:

```bash
kcoder config path
kcoder config init --scope user
kcoder config list --sources
kcoder config get model --source
kcoder config set model MiniMax-M3
kcoder config set permission_mode auto --scope project
kcoder config unset permission_mode --scope project
kcoder config import --file team-settings.jsonc --scope project
kcoder config migrate
kcoder config validate
```

`config set` first parses the value as JSON (`true`/`false`/numbers/arrays/objects use valid JSON, others are treated as strings),
and after each modification it reloads and validates the merged result; `config set/unset` triggers the `ConfigChange` lifecycle hook and rejects
secret fields like `*_api_key`. Write scopes are only `user`, `project`, `local`; the program directory configuration belongs to the deployment environment and should not be modified via command.

Model services use the centralized `providers` configuration. Object keys are Provider IDs, and also determine the endpoint, authentication namespace, default model,
and model capabilities. `config migrate` only fills missing fields, does not overwrite user values, and value-preserving migrates the legacy top-level provider/model/endpoint/token
fields into the current Provider to prevent them from continuing to override new configuration under a new Provider:

```json
{
  "active_provider": "kunlunmeta",
  "providers": {
    "kunlunmeta": {
      "api_format": "anthropic_messages",
      "endpoint": "http://127.0.0.1:8000",
      "default_model": "MiniMax-M3",
      "reasoning_effort": "high",
      "context_window_tokens": 1048576,
      "output_headroom_tokens": 100000,
      "max_output_tokens": 100000,
      "request_timeout_secs": 300,
      "no_proxy": true,
      "extra_body": {}
    }
  }
}
```

The `kunlunmeta` endpoint defaults to `http://127.0.0.1:8000` (example environment, please override based on actual deployment), and the default model is `MiniMax-M3`; can be overridden by
`KUNLUNMETA_BASE_URL` and `KUNLUNMETA_BASE_MODEL` respectively. `api_format` supports `anthropic_messages`,
`openai_responses`, `openai_chat_completions`, and `gemini_generate_content`. API keys do not belong to Provider
configuration and continue to be saved independently by `auth` to `credentials.json`. `extra_body` can configure provider extension request fields such as `temperature`, `top_p`,
thinking budget, etc.; internal or local endpoints can set `"no_proxy": true` to ignore process HTTP proxies.
Summary models can reference a full profile via `summary_profile`; MoA's reference/aggregator model slots can add
`"profile": "profile-name"` to avoid inheriting the main model's protocol and endpoint. Other Providers like local, OpenAI-compatible, etc. must fully declare
endpoint, protocol, default model, and model capabilities; Provider IDs are case-sensitive and must exactly match the `auth login --provider`
and `credentials.json` root key.

`KCODER_CONFIG_DIR` (or the compatible `KCODER_HOME`) can override the user configuration directory, suitable for containers, tests, and multiple
account isolation. Credential management:

```bash
kcoder auth login --provider kunlunmeta
kcoder auth import --env-file .env
kcoder auth status
kcoder auth logout --provider kunlunmeta
```

`credentials.json` uses an authentication map with Provider IDs as root keys:

```json
{
  "kunlunmeta": { "type": "api", "key": "..." }
}
```

Environment variables still apply for CI or ad hoc runs, e.g. `KUNLUNMETA_BASE_API_KEY`, `KCODER_PROVIDER`,
`KCODER_MODEL`, and `KCODER_PERMISSION_MODE`. `--credential-env-file` can supply a dotenv credential file for a single process.
The final credential priority: explicit CLI credential argument > `credentials.json` > legacy compat-period settings
credential fields > KunlunMeta environment variables.

### Trust and Skill Preflight

When unattended tasks depend on project Skills, explicitly declare and only trust the target root before starting:

```bash
kcoder trust status --path /srv/project
kcoder trust add --path /srv/project
kcoder trust never --path /srv/project
kcoder trust revoke --path /srv/project
kcoder --cwd /srv/project --require-skill ci-triage --json "execute CI triage"
```

`trust` reads and writes `FolderTrustStore` (located in the configuration directory); `--require-skill` is repeatable and preflights before the first model request:
when the Skill is not installed, the project is not trusted, the tool profile does not expose `skill`, or permissions deny, KCoder first returns a structured `blocked`
(`preflight_failed` + `termination_reason=required_skill_unavailable`, `resume_safe=true`),
without first consuming model turns. When the directory is not trusted, project-layer MCP servers are stripped, project skills load with a trust flag,
and the TUI prompts interactively about projects with extension surfaces before starting.

## Provider Configuration

Model provider, endpoint, model, and runtime parameters live in `settings.json`; API keys live in
`credentials.json`; you can also use environment variables or `auth login` to import credentials:

```bash
kcoder auth login --provider kunlunmeta
kcoder auth login --provider anthropic
```

For development debugging, use `KCODER_BINARY_POLICY` (`debug`, `build`, or `latest`) and
`KCODER_RELEASE_BIN_DIRS` to control binary sources; shared launch logic lives in
`scripts/install/lib/launcher.sh` (binary policy, config migrate/import, credential import).

## Architecture Overview

Rough data flow for a conversation:

```text
CLI / TUI
  -> Settings + provider selection + MCP/plugin discovery + trust gate
  -> QueryEngine
  -> system prompt: project instructions + active skills + memory + tool definitions
  -> Provider streaming response (SSE, retry, incremental tool_use p

…

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [KunlunMeta-dev](https://github.com/KunlunMeta-dev)
- **Source:** [KunlunMeta-dev/Kcoder](https://github.com/KunlunMeta-dev/Kcoder)
- **License:** MIT
- **Homepage:** https://github.com/KunlunMeta-dev/Kcoder/releases

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** yes
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** yes
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-kunlunmeta-dev-kcoder
- Seller: https://agentstack.voostack.com/s/kunlunmeta-dev
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
