@danvic712/pi-context-depot0.1.1
Automatic ContextDepot session memory capture for Pi and Pi-based agents
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
ContextDepot Pi Session Memory
简体中文
@danvic712/pi-context-depot 为独立 Pi 和 ThinkRail 主聊天提供自动会话捕获。包内附带 ContextDepot Skill,并复用宿主中已配置的 MCP 连接。
安装
支持安装即启用的 npm 版本发布后,在 Pi 中运行以下命令。
pi install npm:@danvic712/pi-context-depot@latest
在 ThinkRail 中,打开 Settings → Extensions & skills → Install package…,输入 npm:@danvic712/pi-context-depot@latest,然后启用 ContextDepot Session Memory。
如需固定版本,将 @latest 换成已发布的版本号。如果之前使用的是本地扩展,先移除 Pi 的文件入口或 ThinkRail 的目录入口,再安装 npm 包。若曾单独安装 ContextDepot Skill,宿主中保留一份即可。
自动启用
如果 Pi 或 ThinkRail 已配置 ContextDepot MCP,宿主加载扩展后即可自动捕获。扩展从宿主用户级 mcp.json 中识别唯一启用了 X-ContextDepot-Key 请求头的连接,并复用它的地址和请求头。连接别名可自定义,无需另建配置文件或维护项目列表。ContextDepot 服务端需启用会话记忆,访问密钥需获得目标 Workspace 授权。
连接使用 Streamable HTTP 和以 /mcp 结尾的 HTTPS 地址。回环地址可用 HTTP。请求头支持静态值和环境变量引用,例如 "${CONTEXTDEPOT_MCP_TOKEN}"。当连接有多个候选、密钥不可用、宿主未提供 session_capture 或可信项目覆盖同名连接时,扩展跳过捕获。修改连接后重启或重载宿主。
停止自动捕获时,在 Pi 移除该包,或在 ThinkRail 的扩展管理中禁用 ContextDepot Session Memory。从 npm 0.1.0 升级后,宿主中仍启用的扩展也会自动捕获,旧版的启用开关和项目清单会失效。
捕获行为
- 扩展在符合条件的对话回合结束后后台提交,聊天无需等待。
- 请求仅包含用户可见的提问原文和最终回复原文,由 ContextDepot 根据当轮主题和密钥权限自动路由 Workspace。
- 独立 Pi 记录
agent: "pi",ThinkRail 记录agent: "thinkrail"。 - 跳过命令、模板、非交互输入、中断的回合、分支不明确或正文超限的回合。配置无效时,扩展会给出原因,提示中不包含凭据或对话正文。
- 请求重试次数有限,同一回合的重试使用相同标识。提交结果不明时,用户仍可继续对话。
- 扩展会提示 AI 避免重复捕获。同一宿主的 MCP 工具仍可用来检索知识或查询已有收据的状态。
English
@danvic712/pi-context-depot adds automatic Session Memory capture to standalone Pi and ThinkRail's main chat. The package includes the ContextDepot Skill and reuses the MCP connection you already configured in your host.
Install
Once a version with automatic activation is available on npm, run the following in Pi.
pi install npm:@danvic712/pi-context-depot@latest
In ThinkRail, open Settings → Extensions & skills → Install package…, enter npm:@danvic712/pi-context-depot@latest, then enable ContextDepot Session Memory.
To pin either installation, replace @latest with a published version. If you previously used a local build, remove its Pi file entry or ThinkRail directory entry before installing. The package already includes the ContextDepot Skill. If you installed that Skill separately, keep one copy in the host.
Automatic activation
If Pi or ThinkRail already has a ContextDepot MCP connection, capture starts once the host loads the extension. It looks for a single enabled entry with an X-ContextDepot-Key header in the host's user-level mcp.json and reuses that entry's endpoint and headers. You can use any valid alias. No separate configuration file or project list is required. Enable Session Memory on the ContextDepot server and grant the key access to the intended Workspaces.
Use a Streamable HTTP endpoint with an HTTPS URL ending in /mcp. HTTP works on loopback. Headers support literal values and environment variable references such as "${CONTEXTDEPOT_MCP_TOKEN}". Capture is skipped if there are multiple candidates, the key is unavailable, the host does not expose session_capture, or a trusted project overrides the same alias. Restart or reload the host after changing the connection.
To stop automatic capture, remove the package in Pi or disable ContextDepot Session Memory in ThinkRail's extension settings. Upgrading from npm 0.1.0 also starts automatic capture if the extension is still enabled. The old enable switch and project list no longer apply.
Capture behavior
- Each eligible completed user turn is sent after Pi's
agent_settledevent, without waiting in the chat. - The request contains the exact visible user text and final assistant text only, and ContextDepot routes each turn to a Workspace based on its topic and the key’s permissions.
- Standalone Pi records
agent: "pi"; ThinkRail recordsagent: "thinkrail". - Commands, templates, non-interactive input, interrupted turns, ambiguous branches and over-limit messages are skipped. If capture is enabled but its configuration is invalid, the extension reports the reason without printing credentials or chat content.
- Retries are bounded and use the same deterministic idempotency identity. An uncertain timeout does not block the next chat turn.
- The extension adds a short system-prompt note so the AI does not duplicate the automatic capture. It can use the existing host MCP tools and connection name for user-requested reads or status checks.