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
2 changes: 1 addition & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ jobs:
run: uv run pytest tests/test_dsh_transport.py --require-dsh-runtime

- name: Verify DSH guidance adapter requests and results
run: uv run pytest "tests/test_integration_guidance_evaluation.py::test_native_adapter_handoff_uses_real_request_mapping_and_response_envelopes[dsh]"
run: uv run pytest tests/test_integration_guidance_evaluation.py::test_dsh_controlled_native_handoff_uses_only_mcp_tools_and_preserves_complete_carriers

pi-package:
timeout-minutes: 20
Expand Down
2 changes: 1 addition & 1 deletion docs/en/docs/integrations/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ candidate_review permits listing and reading candidates only; it never grants de
| --- | --- | --- | --- | --- |
| codex | Agent host | Master only | minimal, recommended, full | memory_read<br>memory_write<br>source_capture<br>context_injection<br>flush_or_checkpoint<br>work_contract<br>handoff<br>acknowledge<br>task_outcome<br>candidate_review<br>experience_read_or_generate<br>skill_read_or_generate<br>external_skill<br>scope_organization<br>artifact_publication<br>persistent_scope_binding |
| claude-code | Agent host | Master only | minimal, recommended, full | memory_read<br>memory_write<br>source_capture<br>context_injection<br>flush_or_checkpoint<br>work_contract<br>handoff<br>acknowledge<br>task_outcome<br>candidate_review<br>experience_read_or_generate<br>skill_read_or_generate<br>external_skill<br>scope_organization<br>artifact_publication<br>persistent_scope_binding |
| dsh | Agent host | Master only | minimal | memory_read<br>memory_write<br>source_capture<br>context_injection<br>flush_or_checkpoint<br>handoff<br>experience_read_or_generate<br>skill_read_or_generate<br>candidate_review<br>external_skill<br>slash_command |
| dsh | Agent host | Master only | minimal, recommended, full | memory_read<br>memory_write<br>source_capture<br>context_injection<br>flush_or_checkpoint<br>work_contract<br>handoff<br>acknowledge<br>task_outcome<br>experience_read_or_generate<br>skill_read_or_generate<br>candidate_review<br>external_skill<br>scope_organization<br>artifact_publication<br>persistent_scope_binding<br>slash_command |
| hermes | Agent host | Master only | minimal, recommended, full | memory_read<br>memory_write<br>source_capture<br>context_injection<br>flush_or_checkpoint<br>work_contract<br>handoff<br>acknowledge<br>task_outcome<br>experience_read_or_generate<br>skill_read_or_generate<br>candidate_review<br>external_skill<br>slash_command<br>persistent_scope_binding |
| openclaw | Agent host | Master only | minimal | memory_read<br>memory_write<br>source_capture<br>context_injection<br>flush_or_checkpoint<br>pre_compaction_capture |
| opencode | Agent host | Master only | minimal | 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 |
Expand Down
53 changes: 43 additions & 10 deletions docs/en/docs/integrations/dsh.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ and unverifiable group children fail before connection settings or credentials a
An unset, empty, or whitespace-only `DSH_HOME` selects `~/.dsh`. A nonblank path keeps its leading and trailing
spaces. These rules apply to configuration inspection, stored credentials, and plugin dependency lookup.

Setup does not start the Server. Restart DSH after installation.
The model-facing PowerContext surface is registered through DSH's native `@deepseek-ai/dsh-mcp-client`.

## Start the Server and the host

For automatic Source-to-Memory extraction, generate and validate a Server configuration:
Expand Down Expand Up @@ -119,9 +122,11 @@ liveness, readiness, capabilities, declared routes, the current Scope, and a rea
A Scope failure leaves health results available. The endpoint summary shows only its origin, configuration source
and whether a path prefix exists; credentials, prefix text, query strings and fragments are not printed.

Doctor reports the active host's native MCP catalog separately. The documented DSH installation is HTTP-only, so
`native_mcp_unconfigured` does not fail an otherwise healthy HTTP plugin. If other native MCP tools are visible
but `mcp__powercontext__*` is absent, Doctor reports `native_mcp_powercontext_missing` with a recovery action.
Doctor reports the active host's native MCP catalog separately, including the exact visible tool names.
`native_mcp_unconfigured` means no native MCP tools are visible; initialization may still be pending or have failed.
If other native MCP tools are visible but `mcp__powercontext__*` is absent, Doctor reports
`native_mcp_powercontext_missing`. These results do not fail otherwise healthy lifecycle HTTP checks, but HTTP
health alone does not establish that model-facing MCP operations are available.

Each failed check identifies the operation, a stable code, HTTP status/request ID when available, and a recovery
action. Protocol errors also include `protocol_issue`, identifying the violated JSON, status or PreparedContext field rule.
Expand Down Expand Up @@ -221,22 +226,50 @@ See the [runtime test procedure](https://github.com/oceanbase/powercontext/blob/

## Understand what the plugin does

The plugin has two paths to the same Server:
The plugin has three deliberately different paths to the same Server:

- before each model step it asks the Runtime to prepare one final, bounded context value, then independently captures the user's prompt as Source evidence;
- named `pc_*` tools call the public HTTP API to remember, search, revise, retire, and audit Memory.
- DSH's native MCP client connects to `/mcp/` and exposes the Server tools as `mcp__powercontext__<operation>`;
- `/pc` commands and automatic lifecycle stages use the bounded HTTP client for host control and diagnostics.

The MCP surface covers the full PowerContext profile: Memory read/write, Source capture, Work Contract, Handoff and
acknowledgement, task outcome, Experience, managed and external Skill workflows, candidate inspection, Scope
organization, persistent Scope binding, and artifact publication. It also exposes the Server's additional MCP tools that
are outside the profile contract. The plugin does not register Pi/Hermes-style direct HTTP operation tools.

Scope-dependent MCP operations, including those with a path `scope_id`, must use the exact host-resolved Scope
exposed in the current-turn routing metadata. Do not select a different Scope using
`mcp__powercontext__resolve_scope_binding` with `allow_default: true`. The plugin refuses another Scope instead of
rewriting MCP arguments; automatic lifecycle hooks and model operations use the same project context.

Optional native MCP initialization waits at most five seconds during plugin startup. Ordinary DSH conversations
continue if the handshake stalls, and the same client may finish connecting later. Tools are unavailable until
registration completes; check the current tool catalog before selecting an MCP operation.

Native MCP frames pass through a process-local streaming boundary to the fixed configured endpoint; all redirects
are rejected, including during initialization and tool calls. The native client still owns discovery and sessions.
HTTP failures expose controlled status/code information without upstream response bodies or diagnostic headers.
The plugin rejects likely secret content, including nested Handoff state, Drafts and prepared carriers, with
`secret_rejected` before write approval or dispatch. Its MCP catalog and mutation approval classification are generated
from the Server's public `tools/list`, not the HTTP tool table.

`mcp__powercontext__handoff_current_work` captures its own boundary and returns `{boundary, handoff}`. Transfer only
the complete `handoff` member, then pass that exact value to `mcp__powercontext__continue_handoff` with
`selection: "prepared"`. No preliminary Source capture is needed. In the separate low-level capture/activate/finalize
flow, pass activation's top-level `draft` to finalization and transfer the complete native finalization result unchanged.

The plugin resolves one Server-owned Scope in this order: `POWERCONTEXT_DSH_SCOPE_ID`, a durable binding for the
session workspace, then the Server default. The workspace path is hashed only as an external binding key. A missing
workspace therefore uses the Server default instead of the Harness process directory.

The plugin calls `POST /v1/context/prepare` once before the model analyzes the prompt. Explicit `remember_memory` calls do not require a model.

## Diagnose direct tool and command failures
## Diagnose MCP and command failures

Named tools and Scope-dependent `/pc` commands return a controlled failure if Scope resolution fails. They stop before
the requested operation, without creating a binding or retrying with another Scope. Cancellation and the existing
per-request timeout also apply to Scope resolution.
Scope-dependent native MCP tools and `/pc` commands return a controlled failure before dispatch if host Scope
resolution fails or returns no Scope. A failed refresh invalidates the session's cached Scope; MCP calls cannot use
a previous turn's value to bypass the failure. Ordinary conversation continues without selecting another Scope or
creating a binding. Cancellation and the existing per-request timeout also apply to lifecycle Scope resolution.

Inside DeepSeek Harness:

Expand Down Expand Up @@ -359,7 +392,7 @@ powercontext doctor dsh
| `POWERCONTEXT_DSH_BASE_URL` | `http://127.0.0.1:8000` | Server base URL used by the plugin |
| `POWERCONTEXT_DSH_ALLOW_INSECURE_HTTP` | `false` | Explicitly permit non-loopback plaintext HTTP |
| `POWERCONTEXT_DSH_SCOPE_ID` | unset | Explicit existing Scope before workspace binding and Server default |
| `POWERCONTEXT_DSH_AUTHORIZATION` | unset | Complete `Bearer <token>` header for plugin HTTP requests |
| `POWERCONTEXT_DSH_AUTHORIZATION` | unset | Complete `Bearer <token>` header for MCP and lifecycle HTTP requests |
| `POWERCONTEXT_DSH_CAPTURE_PROMPTS` | `true` | Capture user prompts as Source evidence |
| `POWERCONTEXT_DSH_FLUSH_ON_CAPTURE` | `false` | Wait for Source processing after capture |

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/docs/integrations/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ candidate_review 仅可列举和读取候选材料,不授予决策权限。
| --- | --- | --- | --- | --- |
| codex | Agent 宿主 | 仅 master | minimal, recommended, full | memory_read<br>memory_write<br>source_capture<br>context_injection<br>flush_or_checkpoint<br>work_contract<br>handoff<br>acknowledge<br>task_outcome<br>candidate_review<br>experience_read_or_generate<br>skill_read_or_generate<br>external_skill<br>scope_organization<br>artifact_publication<br>persistent_scope_binding |
| claude-code | Agent 宿主 | 仅 master | minimal, recommended, full | memory_read<br>memory_write<br>source_capture<br>context_injection<br>flush_or_checkpoint<br>work_contract<br>handoff<br>acknowledge<br>task_outcome<br>candidate_review<br>experience_read_or_generate<br>skill_read_or_generate<br>external_skill<br>scope_organization<br>artifact_publication<br>persistent_scope_binding |
| dsh | Agent 宿主 | 仅 master | minimal | memory_read<br>memory_write<br>source_capture<br>context_injection<br>flush_or_checkpoint<br>handoff<br>experience_read_or_generate<br>skill_read_or_generate<br>candidate_review<br>external_skill<br>slash_command |
| dsh | Agent 宿主 | 仅 master | minimal, recommended, full | memory_read<br>memory_write<br>source_capture<br>context_injection<br>flush_or_checkpoint<br>work_contract<br>handoff<br>acknowledge<br>task_outcome<br>experience_read_or_generate<br>skill_read_or_generate<br>candidate_review<br>external_skill<br>scope_organization<br>artifact_publication<br>persistent_scope_binding<br>slash_command |
| hermes | Agent 宿主 | 仅 master | minimal, recommended, full | memory_read<br>memory_write<br>source_capture<br>context_injection<br>flush_or_checkpoint<br>work_contract<br>handoff<br>acknowledge<br>task_outcome<br>experience_read_or_generate<br>skill_read_or_generate<br>candidate_review<br>external_skill<br>slash_command<br>persistent_scope_binding |
| openclaw | Agent 宿主 | 仅 master | minimal | memory_read<br>memory_write<br>source_capture<br>context_injection<br>flush_or_checkpoint<br>pre_compaction_capture |
| opencode | Agent 宿主 | 仅 master | minimal | 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 |
Expand Down
45 changes: 36 additions & 9 deletions docs/zh/docs/integrations/dsh.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ setup 不求值无关的界面和模型表达式。启用的 include 文件必
`DSH_HOME` 未设置、为空或仅包含空白时使用 `~/.dsh`;非空路径保留开头和末尾的空格。
配置检查、凭据保存与读取、插件依赖查找都遵循这两条规则。

Setup 不会启动 Server。安装完成后重启 DSH。
面向模型的 PowerContext 能力通过 DSH 原生的 `@deepseek-ai/dsh-mcp-client` 注册。

## 启动 Server 和宿主

需要自动将 Source 提取为 Memory 时,生成并校验 Server 配置:
Expand Down Expand Up @@ -115,9 +118,10 @@ Server 使用其他监听地址时同步修改 URL。鉴权使用 `POWERCONTEXT_
路由声明、当前 Scope 和只读 prepare 操作。Scope 失败不会遮蔽健康检查。
端点摘要仅显示 origin、配置来源和是否存在路径前缀,不打印凭据、前缀正文、查询参数或 fragment。

Doctor 会单独报告当前宿主的原生 MCP 工具目录。文档中的 DSH 安装仍是仅 HTTP 的插件,因此
`native_mcp_unconfigured` 不会使原本健康的 HTTP 插件检查失败。若已发现其他原生 MCP 工具但没有
`mcp__powercontext__*`,Doctor 会报告 `native_mcp_powercontext_missing` 并给出恢复操作。
Doctor 会单独报告当前宿主的原生 MCP 工具目录及实际可见的工具名称。`native_mcp_unconfigured` 表示当前
没有可见的原生 MCP 工具,初始化可能仍在等待或已经失败。若已发现其他原生 MCP 工具但没有
`mcp__powercontext__*`,Doctor 会报告 `native_mcp_powercontext_missing`。这些结果不会使原本健康的
生命周期 HTTP 检查失败,但 HTTP 健康不代表面向模型的 MCP 操作已经可用。

失败项提供操作名、稳定 code、可用的 HTTP status/request ID 和具体恢复操作。
协议错误还提供 `protocol_issue`,指出 JSON、状态码或 PreparedContext 字段违反的具体规则。
Expand Down Expand Up @@ -212,21 +216,44 @@ flush 或修改绑定。Doctor 探测和手动操作也不会覆盖自动执行

## 理解插件行为

插件通过两条路径访问同一个 Server:
插件通过三条有明确边界的路径访问同一个 Server:

- 每轮模型开口前,先请求 Runtime 准备一个最终、有界的上下文值,再把用户输入采集为 Source 证据;
- 具名 `pc_*` 工具通过公开 HTTP API 记忆、检索、修订、停用和审计 Memory。
- DSH 原生 MCP client 连接 `/mcp/`,并将 Server 工具以 `mcp__powercontext__<operation>` 暴露给模型;
- `/pc` 命令和自动生命周期阶段使用有界 HTTP client 执行宿主控制与诊断。

MCP 面覆盖完整 PowerContext profile:Memory 读写、Source 采集、Work Contract、Handoff 与确认、任务结果、
Experience、托管和外部 Skill、候选审查、Scope 管理、持久 Scope binding 以及 Artifact 发布;同时还暴露
profile 契约之外的 Server MCP 工具。插件不会注册 Pi/Hermes 风格的直接 HTTP 操作工具。

依赖 Scope 的 MCP 操作(包括路径参数中的 `scope_id`)必须使用本轮路由元数据中暴露的宿主解析结果。
不要通过 `mcp__powercontext__resolve_scope_binding` 和 `allow_default: true` 另选 Server 默认 Scope。
插件会拒绝其他 Scope,而不会重写 MCP 参数;自动生命周期 hook 与模型操作使用相同的项目上下文。

插件启动时,对可选的原生 MCP 初始化最多等待五秒。握手停滞不会阻止普通 DSH 对话,同一个 client 可以在后台
完成连接。工具注册完成前不可用;选择 MCP 操作前应检查当前工具目录。

原生 MCP 消息经过本进程内的流式转发边界,只能发往配置的固定端点;初始化和工具调用中的所有重定向都会被拒绝。
工具发现和 session 仍由原生 client 管理。HTTP 失败仅返回受控的状态码和错误码,不转发上游响应正文或诊断头。
包含疑似秘密的内容写入(包括嵌套的 Handoff 状态、Draft 和准备载体)会在审批和发送前以 `secret_rejected` 拒绝。
插件的 MCP 目录和写操作审批分类由 Server 公开的 `tools/list` 生成,不使用 HTTP 工具表冒充 MCP 目录。

`mcp__powercontext__handoff_current_work` 自行采集边界并返回 `{boundary, handoff}`,不需要预先采集 Source。
只传递完整的 `handoff` 成员,再以 `selection: "prepared"` 将该原值交给 `mcp__powercontext__continue_handoff`。
独立的底层 capture/activate/finalize 流程则把 activation 顶层的 `draft` 交给 finalization,完整保留并传递原生
finalization 结果,不额外包装或只提取其中的内容。

插件按 `POWERCONTEXT_DSH_SCOPE_ID`、session workspace 持久 binding、Server 默认 Scope 的顺序解析一个由
Server 管理的 Scope。workspace 路径只会哈希为外部 binding key。缺少 workspace 时使用 Server 默认 Scope,
不会把 Harness 进程目录作为 Scope。

插件在模型分析提示词前只调用一次 `POST /v1/context/prepare`。显式 `remember_memory` 不需要模型。

## 排查工具和命令的直接调用失败
## 排查 MCP 和命令的直接调用失败

Scope 解析失败时,具名工具和依赖 Scope 的 `/pc` 命令会返回受控失败,并在执行请求的操作前停止。
插件不会因此创建 binding 或换用其他 Scope 重试。取消信号和现有的单请求超时也适用于 Scope 解析。
宿主 Scope 解析失败或未返回 Scope 时,依赖 Scope 的原生 MCP 工具和 `/pc` 命令会在发送操作前返回受控失败。
刷新失败会清除该会话缓存的 Scope,MCP 调用不能通过上一轮的值绕过失败。普通对话继续,不会因此创建 binding
或切换其他 Scope。取消信号和现有的单请求超时也适用于生命周期 Scope 解析。

在 DeepSeek Harness 内:

Expand Down Expand Up @@ -341,7 +368,7 @@ powercontext doctor dsh
| `POWERCONTEXT_DSH_BASE_URL` | `http://127.0.0.1:8000` | 插件使用的 Server 地址 |
| `POWERCONTEXT_DSH_ALLOW_INSECURE_HTTP` | `false` | 显式允许非环回明文 HTTP |
| `POWERCONTEXT_DSH_SCOPE_ID` | 未设置 | 在 workspace binding 和 Server 默认值之前显式选择已有 Scope |
| `POWERCONTEXT_DSH_AUTHORIZATION` | 未设置 | 插件 HTTP 请求使用的完整 `Bearer <token>` header |
| `POWERCONTEXT_DSH_AUTHORIZATION` | 未设置 | MCP 与生命周期 HTTP 请求使用的完整 `Bearer <token>` header |
| `POWERCONTEXT_DSH_CAPTURE_PROMPTS` | `true` | 把用户提示词采集为 Source 证据 |
| `POWERCONTEXT_DSH_FLUSH_ON_CAPTURE` | `false` | 采集后等待 Source 处理 |

Expand Down
Loading
Loading