chore: Pi 开发依赖跟随最新版并去掉测试里的固定版本号

- pi-hermes-memory / pi-notify / pi-permission-system / pi-subagents 的
  @earendil-works/* devDependencies 改为 latest,pi-rtk-optimizer 放开
  peer 范围;各子包锁文件刷新到 Pi 1.3.0,测试改为验证当前宿主 API。
- 新增 scripts/update-pi-devdeps.sh,统一刷新根与子包锁文件中的 Pi 版本。
- pi-subagents 适配 Pi 1.3:mention clone 改走 systemPromptOverride、
  BOM frontmatter、e2e 读取规范化后的 system 消息与工具列表。
- 根测试不再写死 ssh2 / jiti / better-sqlite3 / context-mode 版本号,
  改为精确版本格式与锁文件一致性断言;新增 latest 约束测试。

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
云服务部-叶林立
2026-10-20 19:38:54 -07:00
co-authored by Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent ba164896d2
commit b817d66a11
23 changed files with 4994 additions and 9784 deletions
+41 -1
View File
@@ -195,6 +195,46 @@ function resolveReply(
return typeof reply === "function" ? (reply as (c: Context) => FauxReply)(ctx) : reply;
}
/**
* Names of the tools the session offered the model for this call. Pi ≥1.3
* normalizes `Context.tools` into the transcript's system messages
* (`toolsAdded`/`toolsRemoved`) before the provider sees the request, so read
* both shapes.
*/
export function contextToolNames(context: Context): string[] {
const names = new Set<string>((context.tools ?? []).map((t) => t.name));
for (const m of context.messages) {
if (m.role !== "system") continue;
for (const t of m.toolsAdded ?? []) names.add(t.name);
for (const t of m.toolsRemoved ?? []) names.delete(t.name);
}
return [...names];
}
/**
* The system-prompt text the session offered for this call. Pi ≥1.3 normalizes
* `Context.systemPrompt` into the transcript's system messages, so read both
* shapes: `context.systemPrompt` plus every system message's `content` and
* named `sections` values.
*/
export function contextSystemPrompt(context: Context): string {
const parts: string[] = [];
if (context.systemPrompt) parts.push(context.systemPrompt);
for (const m of context.messages) {
if (m.role !== "system") continue;
const content = m.content;
if (typeof content === "string") {
parts.push(content);
} else if (Array.isArray(content)) {
for (const b of content) if (b.type === "text" && b.text) parts.push(b.text);
}
for (const v of Object.values(m.sections ?? {})) {
if (typeof v === "string") parts.push(v);
}
}
return parts.join("\n");
}
/**
* The common single-spawn flow as a responder. Routes by inspecting the calling
* session's own context:
@@ -210,7 +250,7 @@ export function routeBySession(routes: {
subagent: FauxReply | ((ctx: Context) => FauxReply);
}): FauxResponder {
return (context) => {
const isParent = (context.tools ?? []).some((t) => t.name === "Agent");
const isParent = contextToolNames(context).includes("Agent");
if (!isParent) return resolveReply(routes.subagent, context);
const spawned = context.messages.some(
(m) => m.role === "toolResult" && (m as { toolName?: string }).toolName === "Agent",