skills/pi-gateway-plugin-dev/SKILL.md
为 pi-gateway 开发 Gateway 插件的实战技能。当需求涉及通过 pi SDK/RPC 扩展网关能力(如模型列表、模型切换、WS 方法、命令、Hook、后台服务)且要求"每个插件独立目录 + plugin.json + src 多文件结构"时使用。
npx skillsauth add dwsy/agent pi-gateway-plugin-devInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
用于在 gateway 模式 开发插件,不是 pi extension。
pi-gateway 的连接层能力(消息通道、HTTP/WS、命令、服务)~/.pi/gateway/plugins/ 或 plugins.dirs[] 指定目录plugin.json,并通过 main 指向入口文件以下场景不要用本技能:
~/.pi/agent/extensions 的职责)<plugins-root>/<plugin-id>/)。index.ts 就结束。src/commands.ts、src/rpc-methods.ts、src/hooks.ts、src/services.ts、src/types.ts。~/.pi/agent/extensions/。<plugins-root>/<plugin-id>/
plugin.json
src/
index.ts
types.ts
commands.ts
rpc-methods.ts
hooks.ts
services.ts
references/plugin-directory-architecture.mdreferences/sdk-capabilities.mdreferences/rpc-capabilities.mdreferences/model-control-pattern.mdpi-gateway.json 里配置 plugins.dirs[] 并启动验证。bash skills/pi-gateway-plugin-dev/scripts/new-plugin.sh ~/.pi/gateway/plugins model-control "Model Control"
生成后会得到完整多文件插件目录,不会退化为单 index.ts。
GatewayPluginApi.setModel(sessionKey, provider, modelId)。GatewayPluginApi.setThinkingLevel(sessionKey, level)。GatewayPluginApi 不直接暴露 getAvailableModels,推荐复用网关内置 models.list / /api/models。GatewayPluginApi + createPluginApi + RpcClient 映射,见 references/rpc-capabilities.md 的"扩展路径"。pi-gateway 工具支持流式执行,通过 onPartialResult 回调实时更新进度:
async execute(
toolCallId: string,
args: unknown,
signal: AbortSignal,
onPartialResult?: (partial: ToolResult) => void
): Promise<ToolResult>
// src/tools/my-streaming-tool.ts
export function createMyStreamingTool() {
return {
name: "my_streaming_tool",
parameters: Type.Object({
text: Type.String(),
stream: Type.Optional(Type.Boolean({ default: true })),
}),
async execute(
_toolCallId: string,
params: unknown,
signal: AbortSignal,
onPartialResult?: (partial: ToolResult) => void
) {
const { text, stream } = params as { text: string; stream?: boolean };
if (!stream) {
// 非流式:直接返回结果
return { content: [{ type: "text", text }] };
}
// 流式:分块处理,每块调用 onPartialResult
const chunks = splitIntoChunks(text, 80);
let accumulated = "";
for (let i = 0; i < chunks.length; i++) {
if (signal?.aborted) {
return { content: [{ type: "text", text: "Aborted" }], details: { error: true } };
}
accumulated += chunks[i];
// 报告进度
if (onPartialResult) {
onPartialResult({
content: [{ type: "text", text: accumulated + (i < chunks.length - 1 ? "…" : "") }],
details: { progress: i + 1, total: chunks.length },
});
}
// 模拟处理延迟
await new Promise((resolve) => setTimeout(resolve, 100));
}
return {
content: [{ type: "text", text: accumulated }],
details: { completed: true, chunks: chunks.length },
};
},
};
}
signal.aborted 支持取消操作content 数组和可选的 details 元数据… 或其他指示符表示还有更多内容onPartialResult,不要等全部完成查看 send_message 工具的流式实现:
extensions/gateway-tools/send-message.tsplugin.json 和关键源文件plugins.dirs[])testing
Best practices for writing and maintaining high-quality role memories.
documentation
工作文档枢纽,强制执行 SSOT(Single Source of Truth)原则,管理 `docs/` 目录下的架构决策、设计文档、Issues(任务规划)、PRs(变更记录)。支持 GitHub 协作开发模式。
tools
Allows to interact with web pages by performing actions such as clicking buttons, filling out forms, and navigating links. It works by remote controlling Google Chrome or Chromium browsers using the Chrome DevTools Protocol (CDP). When Claude needs to browse the web, it can use this skill to do so.
development
Vercel 设计指南 - 构建高质量 Web 应用的最佳实践,包含现代 UI/UX 原则、性能优化和无障碍标准。