Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ These tags describe PowerContext integration maintenance and use. See the
<td align="center" width="120"><a href="integrations/minimax/README.md"><img src="assets/minimax-code.png" alt="MiniMax Code" width="48" height="48" /><br /><sub><b>MiniMax Code</b></sub></a></td>
<td align="center" width="120"><a href="docs/en/docs/integrations/dsh.md"><img src="assets/deepseek.png" alt="DeepSeek Harness" width="48" height="48" /><br /><sub><b>DeepSeek Harness</b></sub></a></td>
<td align="center" width="120"><a href="docs/en/docs/integrations/zcode.md"><img src="assets/zcode.png" alt="ZCode" width="48" height="48" /><br /><sub><b>ZCode</b></sub></a></td>
<td align="center" width="120"><a href="docs/en/docs/integrations/kimi-code.md"><img src="https://github.com/MoonshotAI.png?size=120" alt="Kimi Code" width="48" height="48" /><br /><sub><b>Kimi Code</b></sub></a></td>
<td align="center" width="120"><a href="integrations/hermes/README.md"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/hermes-dark.png"><img src="assets/hermes.png" alt="Hermes Agent" width="48" height="48" /></picture><br /><sub><b>Hermes Agent</b></sub></a></td>
<td align="center" width="120"><a href="docs/en/docs/integrations/pi.md"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/pi-dark.png"><img src="assets/pi.png" alt="Pi Coding Agent" width="48" height="48" /></picture><br /><sub><b>Pi Coding Agent</b></sub></a></td>
</tr>
Expand Down
1 change: 1 addition & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Codex 标为 `official`,其他宿主及 Python Agent 框架标为 `community`
<td align="center" width="120"><a href="integrations/minimax/README.md"><img src="assets/minimax-code.png" alt="MiniMax Code" width="48" height="48" /><br /><sub><b>MiniMax Code</b></sub></a></td>
<td align="center" width="120"><a href="docs/zh/docs/integrations/dsh.md"><img src="assets/deepseek.png" alt="DeepSeek Harness" width="48" height="48" /><br /><sub><b>DeepSeek Harness</b></sub></a></td>
<td align="center" width="120"><a href="docs/zh/docs/integrations/zcode.md"><img src="assets/zcode.png" alt="ZCode" width="48" height="48" /><br /><sub><b>ZCode</b></sub></a></td>
<td align="center" width="120"><a href="docs/zh/docs/integrations/kimi-code.md"><img src="https://github.com/MoonshotAI.png?size=120" alt="Kimi Code" width="48" height="48" /><br /><sub><b>Kimi Code</b></sub></a></td>
<td align="center" width="120"><a href="integrations/hermes/README.md"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/hermes-dark.png"><img src="assets/hermes.png" alt="Hermes Agent" width="48" height="48" /></picture><br /><sub><b>Hermes Agent</b></sub></a></td>
<td align="center" width="120"><a href="docs/zh/docs/integrations/pi.md"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/pi-dark.png"><img src="assets/pi.png" alt="Pi Coding Agent" width="48" height="48" /></picture><br /><sub><b>Pi Coding Agent</b></sub></a></td>
</tr>
Expand Down
1 change: 1 addition & 0 deletions README_JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Codex は `official`、他のホストと Python Agent フレームワークは
<td align="center" width="120"><a href="integrations/minimax/README.md"><img src="assets/minimax-code.png" alt="MiniMax Code" width="48" height="48" /><br /><sub><b>MiniMax Code</b></sub></a></td>
<td align="center" width="120"><a href="docs/en/docs/integrations/dsh.md"><img src="assets/deepseek.png" alt="DeepSeek Harness" width="48" height="48" /><br /><sub><b>DeepSeek Harness</b></sub></a></td>
<td align="center" width="120"><a href="docs/en/docs/integrations/zcode.md"><img src="assets/zcode.png" alt="ZCode" width="48" height="48" /><br /><sub><b>ZCode</b></sub></a></td>
<td align="center" width="120"><a href="docs/en/docs/integrations/kimi-code.md"><img src="https://github.com/MoonshotAI.png?size=120" alt="Kimi Code" width="48" height="48" /><br /><sub><b>Kimi Code</b></sub></a></td>
<td align="center" width="120"><a href="integrations/hermes/README.md"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/hermes-dark.png"><img src="assets/hermes.png" alt="Hermes Agent" width="48" height="48" /></picture><br /><sub><b>Hermes Agent</b></sub></a></td>
<td align="center" width="120"><a href="docs/en/docs/integrations/pi.md"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/pi-dark.png"><img src="assets/pi.png" alt="Pi Coding Agent" width="48" height="48" /></picture><br /><sub><b>Pi Coding Agent</b></sub></a></td>
</tr>
Expand Down
1 change: 1 addition & 0 deletions docs/en/docs/integrations/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ candidate_review permits listing and reading candidates only; it never grants de
| langgraph | Framework adapter | Master only | — | memory_read<br>memory_write<br>context_injection |
| bub | Evaluation harness | Master only | — | memory_read<br>memory_write<br>source_capture<br>context_injection<br>flush_or_checkpoint |
| dify | Framework adapter | Experimental | — | memory_read<br>memory_write<br>source_capture<br>context_injection<br>handoff<br>experience_read_or_generate<br>skill_read_or_generate<br>candidate_review |
| kimi-code | Agent host | Experimental | minimal | memory_read<br>memory_write<br>source_capture<br>context_injection |
77 changes: 77 additions & 0 deletions docs/en/docs/integrations/kimi-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
title: Kimi Code
description: Minimal project memory for Kimi Code through a native plugin, HTTP MCP and a prompt Hook.
status: community
---

# Kimi Code

The integration is experimental and supports the minimal profile: Memory read/write, automatic Source capture and context injection. One configured Scope is shared across projects and sessions in the selected Kimi home. Use another Kimi home or explicitly reconfigure the Scope when work needs isolation.

## Install

Install Kimi Code and Node 24+, and install PowerContext with CLI/Server extras from the same checkout used for the plugin:

```text
uv pip install -e ".[cli,server]"
powercontext server run --env-file .env
```

For an authenticated Server, set POWERCONTEXT_KIMI_TOKEN before setup so native MCP authentication is enabled. For an unauthenticated Server, leave it unset. An existing endpoint keeps its established authentication mode; a missing runtime token reports an error.

In another terminal, create or select an existing Scope using the Server/CLI/Dashboard, then run:

```text
powercontext setup kimi-code --source /path/to/powercontext --server-url http://127.0.0.1:8000 --scope-id <existing-scope-id>
powercontext doctor kimi-code
kimi
```

The source must be a local checkout or the unconfigured plugin directory from it; the installed managed copy is not an update source. Kimi and Node must be on PATH; KIMI_CLI_BIN can point to a real binary or built main.mjs for diagnostics and acceptance. KIMI_CODE_HOME selects the Kimi home, defaulting to ~/.kimi-code.

Setup installs a managed copy at <Kimi home>/plugins/managed/powercontext and registers it in plugins/installed.json. It leaves model configuration and other plugins intact, preserves plugin/MCP disablement, and restores previous registration and plugin contents if publication fails. If rollback itself is denied, setup retains the previous plugin at plugins/managed/.powercontext-kimi-backup and reports the recovery path; restore it before retrying. Repeat setup to update; omitted endpoint, Scope and capture options preserve installed settings. Reinstall from the source to change files in the managed copy.

Open a **new session** after installation or reconfiguration; an existing session may retain its old Skill or MCP configuration. The plugin is user-wide, not repository-local. Setup does not create a Scope or modify bindings. HTTPS and loopback HTTP are supported; non-loopback plaintext HTTP is rejected.

## Authentication and first use

For an authenticated Server, export the raw token in the terminal that launches Kimi:

```powershell
$env:POWERCONTEXT_KIMI_TOKEN = '<raw-server-token>'
```

On Bash use export POWERCONTEXT_KIMI_TOKEN='<raw-server-token>'. Hook and MCP consume the same variable; no token is stored in the plugin. Omit it for an unauthenticated Server. Setup does not load a separate environment file for Kimi.

Ask Kimi to save a project decision, then search it in a fresh session. The plugin exposes search_memory, remember_memory and get_artifact_revision. Current Memory results carry Atomic Memory Artifact references; exact readback uses the returned family, artifact_id and revision. Automatic Source capture is separate from an explicit save.

Ordinary text prompts attempt context preparation and Source capture. Mixed prompts retain text only; unsupported or pure-media input is skipped. Capture skips oversize/sensitive input and can be disabled:

```text
powercontext setup kimi-code --source /path/to/powercontext --no-capture-prompts
```

The Hook has a 4-second total budget and returns context through Kimi's message field. Failures continue ordinary work and emit redacted stderr diagnostics. A capture response lost after sending is unknown and is not retried automatically. Separate submissions, including identical text, get separate Source IDs.

Explicit Memory operations need no Generation API. Automatic Memory requires the Server's Generation configuration and scheduled processing; Source acceptance alone does not prove Memory creation, and the plugin does not flush. Kimi credentials do not supply Server Generation credentials.

## Diagnose and remove

doctor is readonly: it checks registration/enablement, Node, MCP/Hook declarations, Server readiness and Scope access. It does not prove that a real MCP call or model injection succeeded. Missing/wrong tokens surface as authentication_failed; a disabled plugin/MCP stays disabled after setup. Incorrect endpoints or inaccessible Scopes require explicit correction and a new session.

Use Kimi's /plugins remove powercontext to remove registration. Kimi keeps the managed copy on disk. Delete only the PowerContext-owned managed directory after verifying its .powercontext-owned marker and removal of its registration. No global Hook or project configuration is added.

## Verification

Windows, Kimi 2.1.1 (npm CLI), Node 24.15.0 passed the real CLI + real Server + SQLite chain, including native MCP save/read/search, actual prompt injection, scheduler worker Generation with exact Source evidence, capture disablement, incorrect credentials and Server outage. Both model services in this repeatable acceptance test used controlled inference.

The same Windows, Kimi 2.1.1 and Node 24.15.0 environment also passed a manual live acceptance run against the official DeepSeek OpenAI Chat Completions API (model = deepseek-v4-flash): the live model called native MCP to save, read the exact revision and search in a fresh session; live Generation created Memory from Hook-captured Source with provenance; a fresh session answered from automatically injected Memory without calling tools. This run used an isolated Kimi home, Scope and SQLite database. It is separate from the automated tests and does not establish correct tool selection for arbitrary prompts. Other versions/platforms, HTTPS ingress and TUI reload remain unverified.

Run the focused checks from the checkout:

```text
node --test integrations/kimi-code/plugins/powercontext/tests/plugin.test.mjs
uv run pytest tests/test_cli_kimi_code.py
```

Set KIMI_CLI_BIN to the installed real binary or built main.mjs, then run uv run pytest tests/e2e/test_kimi_code_host.py. This opt-in test uses disposable Kimi homes, workspaces, Server database and local inference; it needs no live model key and does not modify the user's Kimi profile. An unset variable skips host acceptance and is not a passing qualification.
1 change: 1 addition & 0 deletions docs/en/docs/integrations/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"codex",
"claude-code",
"dsh",
"kimi-code",
"hermes",
"openclaw",
"opencode",
Expand Down
1 change: 1 addition & 0 deletions docs/zh/docs/integrations/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ candidate_review 仅可列举和读取候选材料,不授予决策权限。
| langgraph | 框架适配器 | 仅 master | — | memory_read<br>memory_write<br>context_injection |
| bub | 评测 harness | 仅 master | — | memory_read<br>memory_write<br>source_capture<br>context_injection<br>flush_or_checkpoint |
| dify | 框架适配器 | 实验性 | — | memory_read<br>memory_write<br>source_capture<br>context_injection<br>handoff<br>experience_read_or_generate<br>skill_read_or_generate<br>candidate_review |
| kimi-code | Agent 宿主 | 实验性 | minimal | memory_read<br>memory_write<br>source_capture<br>context_injection |
77 changes: 77 additions & 0 deletions docs/zh/docs/integrations/kimi-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
title: Kimi Code
description: 通过原生插件、HTTP MCP 和提示词 Hook 为 Kimi Code 接入最小项目记忆。
status: community
---

# Kimi Code

本接入为 experimental,支持 minimal profile:记忆读写、自动 Source 采集和上下文注入。同一 Kimi home 内所有项目和会话共用一个配置好的 Scope;需要隔离工作时,使用另一 Kimi home 或显式修改 Scope。

## 安装

安装 Kimi Code 和 Node 24+,从与插件相同的 PowerContext checkout 安装 CLI/Server 并启动 Server:

```text
uv pip install -e ".[cli,server]"
powercontext server run --env-file .env
```

Server 开启鉴权时,先设置 POWERCONTEXT_KIMI_TOKEN 再运行 setup,才能为原生 MCP 配置鉴权;无鉴权 Server 保持变量未设置。已有 endpoint 保留既定鉴权模式,缺失运行时 token 会报错。

在另一终端,通过 Server、CLI 或 Dashboard 创建或选择已有 Scope,然后执行:

```text
powercontext setup kimi-code --source /path/to/powercontext --server-url http://127.0.0.1:8000 --scope-id <已有 Scope ID>
powercontext doctor kimi-code
kimi
```

source 仅支持本地 checkout 或其中未配置的插件目录,不能将已配置的受管理副本当作更新源。Kimi 和 Node 需在 PATH;KIMI_CLI_BIN 可指向真实二进制或构建后的 main.mjs,用于诊断和验收。KIMI_CODE_HOME 指定宿主目录,默认 ~/.kimi-code。

安装器将副本放到 <Kimi home>/plugins/managed/powercontext,注册到 plugins/installed.json;保留模型配置、其他插件和已有插件/MCP 禁用状态,发布失败时恢复原插件与注册记录。回滚本身被拒绝时,会将原插件保留在 plugins/managed/.powercontext-kimi-backup 并报告恢复路径,需先恢复再重试。重复 setup 更新插件,省略的 endpoint、Scope 和采集参数保留已安装设置。修改源文件后需要重新安装,宿主运行的是受管理副本。

安装或改配置后开启**新会话**;现有会话可能保留旧 Skill/MCP 配置。插件对用户全局生效,不限当前仓库。setup 不创建 Scope、不修改绑定。支持 HTTPS 和环回 HTTP,拒绝非环回明文 HTTP。

## 鉴权与使用

Server 开启鉴权时,在启动 Kimi 的终端设置原始 token:

```powershell
$env:POWERCONTEXT_KIMI_TOKEN = '<原始 Server token>'
```

Bash 使用 export POWERCONTEXT_KIMI_TOKEN='<原始 Server token>'。Hook 与 MCP 共用此变量,不将 token 写入插件;无鉴权 Server 可以不设置。setup 不替 Kimi 加载环境文件。

让 Kimi 保存一条项目决策,然后在新会话中搜索。插件开放 search_memory、remember_memory 和 get_artifact_revision。当前记忆返回 Atomic Memory Artifact 引用,读回时使用实际返回的 family、artifact_id、revision。自动采集 Source 不等于完成显式保存。

普通文本请求自动尝试准备上下文、采集 Source;混合输入仅提取文本,纯媒体或不支持的输入跳过。过长或敏感内容不采集,也可关闭采集:

```text
powercontext setup kimi-code --source /path/to/powercontext --no-capture-prompts
```

Hook 总预算 4 秒,通过 Kimi 的 message 字段注入。失败时普通对话继续,stderr 输出脱敏诊断。已发送采集请求但丢失响应时,结果为 unknown,不自动重试;独立提交即使文字相同,也分配独立 Source ID。

显式记忆读写不需要 Generation API。自动生成记忆需要 Server 配置 Generation 和定时处理;Source 接受不证明记忆已生成,插件不调用 flush。Kimi 登录凭据不等于 Server 的模型凭据。

## 诊断与移除

doctor 只读检查注册/启用状态、Node、MCP/Hook 声明、Server readiness 和 Scope 可访问性,不证明真实 MCP 调用或模型注入已成功。缺失/错误 token 显示 authentication_failed,已禁用的插件/MCP 不会被 setup 自动开启。错误 endpoint 或不可访问的 Scope 需显式修正后开启新会话。

使用 Kimi 的 /plugins remove powercontext 移除注册。宿主保留受管理副本;确认注册已移除并检查 .powercontext-owned 标记后,才删除 PowerContext 管理目录。接入不添加全局 Hook 或项目配置。

## 验证

Windows 上 Kimi 2.1.1(npm CLI)、Node 24.15.0 已通过真实 CLI + 真实 Server + SQLite 验收,覆盖原生 MCP 保存/读回/搜索、实际模型请求注入、后台 Worker 生成记忆及精确 Source 证据、关闭采集、错误 token 和 Server 停机。该可重复验收的两处推理服务均为受控模型边界。

同一 Windows、Kimi 2.1.1 和 Node 24.15.0 环境还通过了 DeepSeek 官方 OpenAI Chat Completions 接口的人工在线验收(model = deepseek-v4-flash):真实模型调用原生 MCP 保存、精确读回及新会话搜索;真实 Generation 从 Hook 采集的 Source 生成记忆并保留来源证据;新会话在不调用工具的情况下使用自动注入的记忆回答。测试使用独立 Kimi home、Scope 和 SQLite 数据库。该单次在线验收不属于自动化测试,也不证明模型在任意提示词下都能正确选择工具。其他版本/平台、HTTPS 入口和 TUI reload 尚未验证。

在 checkout 执行:

```text
node --test integrations/kimi-code/plugins/powercontext/tests/plugin.test.mjs
uv run pytest tests/test_cli_kimi_code.py
```

设置 KIMI_CLI_BIN 指向真实二进制或构建后的 main.mjs,再运行 uv run pytest tests/e2e/test_kimi_code_host.py。该 opt-in 验收使用隔离 Kimi home、workspace、Server 数据库与本地推理,不需要线上模型 key,也不修改用户宿主配置。未设置变量时跳过宿主验收,跳过不代表通过。
1 change: 1 addition & 0 deletions docs/zh/docs/integrations/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"codex",
"claude-code",
"dsh",
"kimi-code",
"hermes",
"openclaw",
"opencode",
Expand Down
32 changes: 32 additions & 0 deletions integrations/capabilities.toml
Original file line number Diff line number Diff line change
Expand Up @@ -927,3 +927,35 @@ toolsets = ["dify-tools"]
implementation = ["integrations/dify/plugin/provider/powercontext.yaml", "integrations/dify/plugin/powercontext_dify/tool.py", "integrations/dify/plugin/powercontext_dify/client.py"]
documentation = ["docs/en/docs/integrations/dify.md", "docs/zh/docs/integrations/dify.md"]
tests = ["integrations/dify/tests/test_plugin_contract.py", "tests/e2e/test_dify_tools_http.py"]

[[toolsets]]
id = "kimi-code-mcp"
probe = "kimi_code_mcp"
[[toolsets.tools]]
id = "search_memory"
capabilities = ["memory_read"]
[[toolsets.tools]]
id = "remember_memory"
capabilities = ["memory_write"]
[[toolsets.tools]]
id = "get_artifact_revision"
capabilities = ["memory_read"]

[[toolsets]]
id = "kimi-code-prompt-hook"
probe = "kimi_code_prompt_hook"
[[toolsets.tools]]
id = "kimi-code:UserPromptSubmit"
capabilities = ["source_capture", "context_injection"]

[[integrations]]
id = "kimi-code"
kind = "agent_host"
availability = "experimental"
capabilities = ["memory_read", "memory_write", "source_capture", "context_injection"]
profiles = ["minimal"]
toolsets = ["kimi-code-mcp", "kimi-code-prompt-hook"]
[integrations.evidence]
implementation = ["integrations/kimi-code/plugins/powercontext/kimi.plugin.json", "integrations/kimi-code/plugins/powercontext/hooks/user_prompt_submit.mjs", "src/powercontext/cli/kimi_code.py"]
documentation = ["docs/en/docs/integrations/kimi-code.md", "docs/zh/docs/integrations/kimi-code.md"]
tests = ["tests/test_cli_kimi_code.py", "integrations/kimi-code/plugins/powercontext/tests/plugin.test.mjs", "tests/e2e/test_kimi_code_host.py"]
Loading
Loading