personal-bot 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +2 -2
- package/docs/architecture/extensibility.md +3 -3
- package/docs/architecture/model-context.md +6 -3
- package/docs/guides/cross-harness-workers.md +1 -1
- package/docs/guides/workspace-configuration.md +1 -1
- package/docs/hosts/claude-code.md +1 -1
- package/docs/hosts/codex-qoder.md +3 -1
- package/hooks/hooks.json +3 -0
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +3 -3
- package/lib/antigravity-plugin/lib/extension/cli.js +33 -34
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +1 -1
- package/lib/antigravity-plugin/lib/extension/mcp.js +70 -105
- package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +2 -2
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +3 -3
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.js +0 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/claude/adapter.js +1 -2
- package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.d.ts +1 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.js +4 -7
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.js +1 -1
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.js +6 -3
- package/lib/antigravity-plugin/lib/services/history/summary-runner.js +3 -3
- package/lib/antigravity-plugin/lib/storage/history-files.js +3 -2
- package/lib/antigravity-plugin/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +2 -2
- package/lib/antigravity-plugin/resources/agents/coordinator.md +2 -4
- package/lib/antigravity-plugin/resources/agents/general-purpose.md +2 -4
- package/lib/antigravity-plugin/resources/prompts/history-monthly-summary.md +6 -11
- package/lib/antigravity-plugin/resources/prompts/history-summary.md +6 -11
- package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -1
- package/lib/antigravity-plugin/resources/prompts/workspace.md +16 -23
- package/lib/antigravity-plugin/resources/skills/project-maintenance/SKILL.md +14 -21
- package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +23 -36
- package/lib/antigravity-plugin/resources/templates/workspace-agents.md +5 -13
- package/lib/antigravity-plugin/skills/pbot/SKILL.md +6 -23
- package/lib/antigravity-plugin/skills/project-maintenance/SKILL.md +14 -21
- package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +23 -36
- package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +2 -2
- package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +2 -2
- package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +3 -3
- package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +11 -3
- package/lib/extension/acp-worker.js +3 -3
- package/lib/extension/cli.js +33 -34
- package/lib/extension/hosts/dsh/command.js +1 -1
- package/lib/extension/hosts/dsh/workspace.js +4 -2
- package/lib/extension/hosts/plugin-runtime.js +1 -1
- package/lib/extension/mcp/tool-contract.js +61 -99
- package/lib/extension/mcp/workers.js +5 -7
- package/lib/extension/mcp.js +70 -105
- package/lib/integrations/agent-resources.d.ts +2 -2
- package/lib/integrations/agent-resources.js +3 -3
- package/lib/integrations/hosts/antigravity/adapter.js +0 -1
- package/lib/integrations/hosts/claude/adapter.js +1 -2
- package/lib/integrations/hosts/dsh/resources.d.ts +1 -1
- package/lib/integrations/hosts/prompt-hooks.js +4 -7
- package/lib/qoder-plugin/.mcp.json +2 -2
- package/lib/qoder-plugin/.qoder-plugin/plugin.json +2 -2
- package/lib/qoder-plugin/hooks/hooks.json +3 -3
- package/lib/qoder-plugin/skills/pbot/SKILL.md +11 -3
- package/lib/services/agents/agent-service.js +2 -2
- package/lib/services/history/summary-dimensions/monthly.js +1 -1
- package/lib/services/history/summary-dimensions/session.js +6 -3
- package/lib/services/history/summary-runner.js +3 -3
- package/lib/storage/history-files.js +3 -2
- package/lib/tools/history/contract.d.ts +1 -1
- package/lib/tools/history/contract.js +14 -16
- package/package.json +2 -2
- package/resources/agents/coordinator.md +2 -4
- package/resources/agents/general-purpose.md +2 -4
- package/resources/antigravity/skills/pbot/SKILL.md +6 -23
- package/resources/claude/skills/pbot/SKILL.md +6 -23
- package/resources/plugin/skills/pbot/SKILL.md +11 -3
- package/resources/prompts/history-coordinator.md +1 -1
- package/resources/prompts/history-monthly-summary.md +6 -11
- package/resources/prompts/history-summary.md +6 -11
- package/resources/prompts/plugin-coordinator.md +1 -1
- package/resources/prompts/workspace.md +16 -23
- package/resources/skills/project-maintenance/SKILL.md +14 -21
- package/resources/skills/provider-connections/SKILL.md +23 -36
- package/resources/templates/workspace-agents.md +5 -13
- package/src/extension/cli/commands/mcp.ts +1 -1
- package/src/extension/hosts/dsh/command.ts +1 -1
- package/src/extension/hosts/dsh/workspace.ts +4 -1
- package/src/extension/hosts/pi/command.ts +1 -1
- package/src/extension/hosts/pi/events.ts +1 -1
- package/src/extension/hosts/plugin-runtime.ts +1 -1
- package/src/extension/mcp/tool-contract.ts +61 -100
- package/src/extension/mcp/workers.ts +5 -7
- package/src/integrations/agent-resources.ts +5 -5
- package/src/integrations/hosts/antigravity/adapter.ts +0 -1
- package/src/integrations/hosts/claude/adapter.ts +1 -2
- package/src/integrations/hosts/dsh/resources.ts +1 -1
- package/src/integrations/hosts/prompt-hooks.ts +3 -6
- package/src/pbot.ts +2 -2
- package/src/services/agents/agent-service.ts +2 -2
- package/src/services/history/summary-dimensions/monthly.ts +1 -1
- package/src/services/history/summary-dimensions/session.ts +6 -3
- package/src/services/history/summary-runner.ts +3 -3
- package/src/storage/history-files.ts +3 -2
- package/src/tools/history/contract.ts +14 -16
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 工作区导航
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 项目速查
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
./
|
|
7
|
-
├── areas/ # 长期目标、约束、建议、决策与复盘
|
|
8
|
-
├── projects/ # 任务定义、结论、交付物与源码
|
|
9
|
-
├── knowledge/ # 可复用的概念、方法与口径
|
|
10
|
-
├── providers/ # 能力提供方导航与手册
|
|
11
|
-
├── scratch/ # 临时脚本、查询与计算数据、下载及运行环境
|
|
12
|
-
└── agents/ # coordinator.md 与 general-purpose.md 的职责补充
|
|
13
|
-
```
|
|
5
|
+
用项目目录名和常用称呼登记项目。默认入口为 `projects/<目录名>/README.md`,其他项目链接到实际入口。
|
|
14
6
|
|
|
15
|
-
##
|
|
7
|
+
## 资料目录
|
|
16
8
|
|
|
17
|
-
|
|
9
|
+
[项目](projects/) · [长期事务](areas/) · [可复用知识](knowledge/) · [工具手册](providers/) · [临时文件](scratch/) · [角色补充](agents/)
|
|
@@ -19,7 +19,7 @@ const mcpUsage =
|
|
|
19
19
|
" pbot mcp add <name> --url <url> [--header K=V]... [--description <说明>] [--timeout <秒>] [--disabled] [--workspace <目录>]\n" +
|
|
20
20
|
" pbot mcp add <name> [--env K=V]... [--cwd <目录>] [--description <说明>] [--timeout <秒>] [--disabled] [--workspace <目录>] -- <command> [args...]\n" +
|
|
21
21
|
" pbot mcp remove <name> [--workspace <目录>]\n\n" +
|
|
22
|
-
"
|
|
22
|
+
"不带子命令时启动 stdio MCP 服务。用 list、add、remove 管理工作区的 .pbot/mcp.json。";
|
|
23
23
|
|
|
24
24
|
async function runMcpServer(): Promise<number> {
|
|
25
25
|
const entry = join(packageRoot, "lib/extension/mcp.js");
|
|
@@ -10,7 +10,7 @@ const usage = '用法:/pbot status | init | history [summary [维度] [--force
|
|
|
10
10
|
export function registerDshCommand(ctx: Context, workspaces: DshWorkspaces) {
|
|
11
11
|
ctx.commands.register({
|
|
12
12
|
name: "pbot",
|
|
13
|
-
description: "
|
|
13
|
+
description: "初始化或检查工作区,查询历史、更新摘要、管理委派的助手。",
|
|
14
14
|
recordInput: false,
|
|
15
15
|
input: { hint: "status | init | history ... | worker ...", attachments: false },
|
|
16
16
|
async handler({ agent, rawInput, signal }) {
|
|
@@ -44,7 +44,10 @@ export class DshWorkspace {
|
|
|
44
44
|
inject: dshDependencies,
|
|
45
45
|
apply: async ctx => {
|
|
46
46
|
if (this.features.skills) registerDshSkills(ctx, this.agent, { workspaceRoot: this.root });
|
|
47
|
-
if (this.features.prompts)
|
|
47
|
+
if (this.features.prompts) {
|
|
48
|
+
const historyPrompt = this.features.history ? "history-coordinator.md" : null;
|
|
49
|
+
await dshResources(ctx, this.agent, this.root, "coordinator", this.check, historyPrompt);
|
|
50
|
+
}
|
|
48
51
|
registerDshFileEvents(ctx, this.agent, this.root, false, this.check);
|
|
49
52
|
if (this.features.history) {
|
|
50
53
|
registerDshHistoryTool(ctx, this.agent, this.root, this.lifetime.signal, this.check);
|
|
@@ -23,7 +23,7 @@ function formatHistoryStatusLine(root: string): string[] {
|
|
|
23
23
|
|
|
24
24
|
export function registerCommand(pi: ExtensionAPI, lifecycle: Lifecycle, confirmations: Confirmations) {
|
|
25
25
|
pi.registerCommand("pbot", {
|
|
26
|
-
description: "
|
|
26
|
+
description: "初始化或检查工作区,查询历史、更新摘要、管理委派的助手。",
|
|
27
27
|
getArgumentCompletions: prefix => {
|
|
28
28
|
if (/\s/.test(prefix)) return null;
|
|
29
29
|
return ["init", "status", "history", "worker"]
|
|
@@ -42,7 +42,7 @@ export function registerEvents(pi: ExtensionAPI, lifecycle: Lifecycle, confirmat
|
|
|
42
42
|
host: "pi",
|
|
43
43
|
root: instance.root,
|
|
44
44
|
role: "coordinator",
|
|
45
|
-
coordinatorPrompt: "history-coordinator.md",
|
|
45
|
+
coordinatorPrompt: instance.features.history ? "history-coordinator.md" : null,
|
|
46
46
|
});
|
|
47
47
|
instance.check();
|
|
48
48
|
Object.assign(event.systemPromptOptions.sections, {
|
|
@@ -82,7 +82,7 @@ export async function pluginHook(adapter: PluginHostAdapter, payload: unknown, r
|
|
|
82
82
|
host: adapter.host,
|
|
83
83
|
root,
|
|
84
84
|
role: event.role,
|
|
85
|
-
|
|
85
|
+
coordinatorPrompt: adapter.coordinatorPrompt ?? (features.history ? "plugin-coordinator.md" : null),
|
|
86
86
|
includePrompts,
|
|
87
87
|
includeRootAgents: includePrompts && !adapter.nativeRootAgents,
|
|
88
88
|
...(event.localRoleOnly ? { localRoleOnly: true } : {}),
|
|
@@ -15,42 +15,34 @@ function formatBackendItem(entry: ReturnType<typeof inspectAcpBackends>[number],
|
|
|
15
15
|
return tags.length ? `${entry.backend}(${tags.join(",")})` : entry.backend;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function summarizeBackends(commands: AcpCommands = {}, defaultBackend?: string) {
|
|
19
|
-
const entries = inspectAcpBackends(commands);
|
|
20
|
-
const available = entries.filter(item => item.available);
|
|
21
|
-
const unavailable = entries.filter(item => !item.available);
|
|
22
|
-
const availableText = available.map(item => formatBackendItem(item, defaultBackend)).join("、");
|
|
23
|
-
const unavailableText = unavailable.map(item => formatBackendItem(item, defaultBackend)).join("、");
|
|
24
|
-
const overview = available.length
|
|
25
|
-
? unavailable.length
|
|
26
|
-
? `当前可用助手:${availableText};暂不可用:${unavailableText}。`
|
|
27
|
-
: `当前可用助手:${availableText}。`
|
|
28
|
-
: `当前无可用外部助手(暂不可用:${unavailableText})。`;
|
|
29
|
-
const availableIds = available.map(item => item.backend).join("、");
|
|
30
|
-
return { overview, availableIds };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
18
|
function workspaceProperty(workspaceBound: boolean) {
|
|
34
19
|
return {
|
|
35
20
|
type: "string",
|
|
36
21
|
description: workspaceBound
|
|
37
|
-
? "
|
|
38
|
-
: "
|
|
22
|
+
? "工作区根目录的绝对路径,默认当前绑定的工作区。"
|
|
23
|
+
: "传目标工作区的绝对路径(workspaceRoot)。省略时使用服务的当前目录。",
|
|
39
24
|
};
|
|
40
25
|
}
|
|
41
26
|
|
|
42
27
|
export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?: string, workspaceBound = false) {
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
?
|
|
46
|
-
: "
|
|
28
|
+
const available = inspectAcpBackends(commands).filter(item => item.available);
|
|
29
|
+
const overview = available.length
|
|
30
|
+
? "可用助手:" + available.map(item => formatBackendItem(item, defaultBackend)).join("、") + "。"
|
|
31
|
+
: "当前没有可用助手。用 worker_discover 的 backends 查看接入状态。";
|
|
47
32
|
const workspace = workspaceProperty(workspaceBound);
|
|
33
|
+
const workerId = { type: "string", description: "助手会话 ID。" };
|
|
34
|
+
const waitMs = {
|
|
35
|
+
type: "integer",
|
|
36
|
+
minimum: 0,
|
|
37
|
+
maximum: maxWaitMs,
|
|
38
|
+
description: `等待本轮结果的毫秒数,默认 ${defaultWaitMs}。0 表示不等待结果。`,
|
|
39
|
+
};
|
|
48
40
|
|
|
49
41
|
return [
|
|
50
42
|
{
|
|
51
43
|
name: "worker_create" as const,
|
|
52
44
|
description:
|
|
53
|
-
"
|
|
45
|
+
"新建独立助手会话,返回 workerId。用 worker_request 发送首个任务。\n" +
|
|
54
46
|
overview,
|
|
55
47
|
annotations: {
|
|
56
48
|
title: "Create Worker",
|
|
@@ -66,15 +58,15 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
66
58
|
properties: {
|
|
67
59
|
backend: {
|
|
68
60
|
type: "string",
|
|
69
|
-
description: "
|
|
61
|
+
description: "助手标识或别名,如 claude-code、agy。",
|
|
70
62
|
},
|
|
71
63
|
model: {
|
|
72
64
|
type: "string",
|
|
73
|
-
description: "
|
|
65
|
+
description: "模型 ID、显示名或 provider/model。未指定模型时省略,使用助手默认模型。",
|
|
74
66
|
},
|
|
75
67
|
thinking: {
|
|
76
68
|
type: "string",
|
|
77
|
-
description: "
|
|
69
|
+
description: "思考深度,如 high。未指定时省略,使用助手默认设置。",
|
|
78
70
|
},
|
|
79
71
|
workspace,
|
|
80
72
|
},
|
|
@@ -83,7 +75,7 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
83
75
|
{
|
|
84
76
|
name: "worker_close" as const,
|
|
85
77
|
description:
|
|
86
|
-
"
|
|
78
|
+
"任务结束后关闭助手。提前关闭会中断执行。创建结果中 resume 为 true 时,可用原 workerId 续接。",
|
|
87
79
|
annotations: {
|
|
88
80
|
title: "Close Worker",
|
|
89
81
|
readOnlyHint: false,
|
|
@@ -96,18 +88,14 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
96
88
|
additionalProperties: false,
|
|
97
89
|
required: ["workerId"],
|
|
98
90
|
properties: {
|
|
99
|
-
workerId
|
|
100
|
-
type: "string",
|
|
101
|
-
description: "助手会话 ID(来自 worker_create 或 worker_discover)。",
|
|
102
|
-
},
|
|
91
|
+
workerId,
|
|
103
92
|
},
|
|
104
93
|
},
|
|
105
94
|
},
|
|
106
95
|
{
|
|
107
96
|
name: "worker_request" as const,
|
|
108
97
|
description:
|
|
109
|
-
"
|
|
110
|
-
`默认最多等待 ${defaultWaitMs / 1000} 秒(waitMs 设为 0 可立即转后台并行);返回 timedOut 或 nextOffset 用 worker_output,返回 needsResponse 先向用户确认再用 worker_response。`,
|
|
98
|
+
"向助手派发任务或在同一会话追问。后台结果用 worker_output 收取。",
|
|
111
99
|
annotations: {
|
|
112
100
|
title: "Send Request to Worker",
|
|
113
101
|
readOnlyHint: false,
|
|
@@ -120,28 +108,19 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
120
108
|
additionalProperties: false,
|
|
121
109
|
required: ["workerId", "message"],
|
|
122
110
|
properties: {
|
|
123
|
-
workerId
|
|
124
|
-
type: "string",
|
|
125
|
-
description: "助手会话 ID(来自 worker_create 或 worker_discover)。",
|
|
126
|
-
},
|
|
111
|
+
workerId,
|
|
127
112
|
message: {
|
|
128
113
|
type: "string",
|
|
129
|
-
description: "
|
|
130
|
-
},
|
|
131
|
-
waitMs: {
|
|
132
|
-
type: "integer",
|
|
133
|
-
minimum: 0,
|
|
134
|
-
maximum: maxWaitMs,
|
|
135
|
-
description: `最多等待毫秒数(默认 ${defaultWaitMs});0 表示立即返回转后台执行。`,
|
|
114
|
+
description: "任务或追问。助手看不到主会话历史,首次派发时写明背景、目标、文件路径、约束和交付要求。",
|
|
136
115
|
},
|
|
116
|
+
waitMs,
|
|
137
117
|
},
|
|
138
118
|
},
|
|
139
119
|
},
|
|
140
120
|
{
|
|
141
121
|
name: "worker_response" as const,
|
|
142
122
|
description:
|
|
143
|
-
"
|
|
144
|
-
`提交前先向用户确认;提交后默认等待最多 ${defaultWaitMs / 1000} 秒返回后续结果。`,
|
|
123
|
+
"收到 needsResponse 时,将权限选项、表单问题或链接交给用户确认,再提交用户的决定。",
|
|
145
124
|
annotations: {
|
|
146
125
|
title: "Respond to Worker Request",
|
|
147
126
|
readOnlyHint: false,
|
|
@@ -154,41 +133,33 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
154
133
|
additionalProperties: false,
|
|
155
134
|
required: ["workerId", "action"],
|
|
156
135
|
properties: {
|
|
157
|
-
workerId
|
|
158
|
-
type: "string",
|
|
159
|
-
description: "等待回复的助手会话 ID。",
|
|
160
|
-
},
|
|
136
|
+
workerId,
|
|
161
137
|
action: {
|
|
162
138
|
type: "string",
|
|
163
139
|
enum: [...acpElicitationActions],
|
|
164
|
-
description: "accept
|
|
140
|
+
description: "accept 同意或提交答案,decline 拒绝,cancel 取消请求。",
|
|
165
141
|
},
|
|
166
142
|
requestId: {
|
|
167
143
|
type: "string",
|
|
168
|
-
description: "
|
|
144
|
+
description: "待回复的请求 ID。仅有一条待处理请求时可省略。",
|
|
169
145
|
},
|
|
170
146
|
optionId: {
|
|
171
147
|
type: "string",
|
|
172
|
-
description: "
|
|
148
|
+
description: "允许或拒绝操作时填用户所选权限的 ID。省略时优先单次,缺少单次选项时可能采用长期选项。",
|
|
173
149
|
},
|
|
174
150
|
content: {
|
|
175
151
|
type: "object",
|
|
176
152
|
additionalProperties: true,
|
|
177
|
-
description: "
|
|
178
|
-
},
|
|
179
|
-
waitMs: {
|
|
180
|
-
type: "integer",
|
|
181
|
-
minimum: 0,
|
|
182
|
-
maximum: maxWaitMs,
|
|
183
|
-
description: `提交后最多等待毫秒数(默认 ${defaultWaitMs});0 表示立即返回。`,
|
|
153
|
+
description: "接受表单时,按表单字段填写答案。值可为字符串、数字、布尔值或字符串数组。",
|
|
184
154
|
},
|
|
155
|
+
waitMs,
|
|
185
156
|
},
|
|
186
157
|
},
|
|
187
158
|
},
|
|
188
159
|
{
|
|
189
160
|
name: "worker_output" as const,
|
|
190
161
|
description:
|
|
191
|
-
"
|
|
162
|
+
"读取助手最近一轮的结果。后台执行或返回 timedOut 时,用原 workerId 继续等待。",
|
|
192
163
|
annotations: {
|
|
193
164
|
title: "Get Worker Output",
|
|
194
165
|
readOnlyHint: true,
|
|
@@ -201,28 +172,20 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
201
172
|
additionalProperties: false,
|
|
202
173
|
required: ["workerId"],
|
|
203
174
|
properties: {
|
|
204
|
-
workerId
|
|
205
|
-
type: "string",
|
|
206
|
-
description: "助手会话 ID。",
|
|
207
|
-
},
|
|
175
|
+
workerId,
|
|
208
176
|
offset: {
|
|
209
177
|
type: "integer",
|
|
210
178
|
minimum: 0,
|
|
211
|
-
description: "
|
|
212
|
-
},
|
|
213
|
-
waitMs: {
|
|
214
|
-
type: "integer",
|
|
215
|
-
minimum: 0,
|
|
216
|
-
maximum: maxWaitMs,
|
|
217
|
-
description: `运行中最多等待毫秒数(默认 ${defaultWaitMs});已结束或翻页时立即返回。`,
|
|
179
|
+
description: "续读传上页的 nextOffset,默认从 0 开始。",
|
|
218
180
|
},
|
|
181
|
+
waitMs,
|
|
219
182
|
},
|
|
220
183
|
},
|
|
221
184
|
},
|
|
222
185
|
{
|
|
223
186
|
name: "worker_discover" as const,
|
|
224
187
|
description:
|
|
225
|
-
"
|
|
188
|
+
"查找可复用的会话、查看助手状态或核对模型选项。查询模型会临时启动目标助手。",
|
|
226
189
|
annotations: {
|
|
227
190
|
title: "Discover Workers, Backends & Models",
|
|
228
191
|
readOnlyHint: true,
|
|
@@ -238,21 +201,19 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
238
201
|
target: {
|
|
239
202
|
type: "string",
|
|
240
203
|
enum: [...discoverTargets],
|
|
241
|
-
description: "overview
|
|
204
|
+
description: "overview(默认)列助手及当前会话拥有的 worker,workers 只查会话,backends 只查助手可用情况,models 查模型与思考深度。",
|
|
242
205
|
},
|
|
243
206
|
workerId: {
|
|
244
207
|
type: "string",
|
|
245
|
-
description: "
|
|
208
|
+
description: "查 workers 时可指定单个会话,省略列出全部所属会话。",
|
|
246
209
|
},
|
|
247
210
|
backend: {
|
|
248
211
|
type: "string",
|
|
249
|
-
description:
|
|
250
|
-
? `仅 target="models" 可用(${modelsBackendHint}):目标助手标识,支持别名;当前可用:${availableIds}。`
|
|
251
|
-
: `仅 target="models" 可用(${modelsBackendHint}):目标助手标识,支持别名。`,
|
|
212
|
+
description: defaultBackend ? `查 models 时选择助手,默认 ${defaultBackend}。` : "查 models 时必填助手标识。",
|
|
252
213
|
},
|
|
253
214
|
model: {
|
|
254
215
|
type: "string",
|
|
255
|
-
description: "
|
|
216
|
+
description: "查 models 时可指定模型以查看它支持的思考深度。",
|
|
256
217
|
},
|
|
257
218
|
workspace,
|
|
258
219
|
},
|
|
@@ -267,7 +228,7 @@ export function buildWorkspaceMcpTools(workspaceBound = false) {
|
|
|
267
228
|
{
|
|
268
229
|
name: "workspace_mcp_discover" as const,
|
|
269
230
|
description:
|
|
270
|
-
"
|
|
231
|
+
"查找工作区共享的 MCP 服务,以及服务提供的工具和参数。",
|
|
271
232
|
annotations: {
|
|
272
233
|
title: "Discover Workspace MCP Servers & Tools",
|
|
273
234
|
readOnlyHint: true,
|
|
@@ -282,7 +243,7 @@ export function buildWorkspaceMcpTools(workspaceBound = false) {
|
|
|
282
243
|
properties: {
|
|
283
244
|
server: {
|
|
284
245
|
type: "string",
|
|
285
|
-
description: "
|
|
246
|
+
description: "填服务名列出其工具,省略则列出已配置的服务。",
|
|
286
247
|
},
|
|
287
248
|
workspace,
|
|
288
249
|
},
|
|
@@ -291,11 +252,11 @@ export function buildWorkspaceMcpTools(workspaceBound = false) {
|
|
|
291
252
|
{
|
|
292
253
|
name: "workspace_mcp_call" as const,
|
|
293
254
|
description:
|
|
294
|
-
"
|
|
255
|
+
"执行工作区共享 MCP 服务的工具,读写效果取决于所选工具。工具名和参数可用 workspace_mcp_discover 查询。",
|
|
295
256
|
annotations: {
|
|
296
257
|
title: "Call Workspace MCP Tool",
|
|
297
258
|
readOnlyHint: false,
|
|
298
|
-
destructiveHint:
|
|
259
|
+
destructiveHint: true,
|
|
299
260
|
idempotentHint: false,
|
|
300
261
|
openWorldHint: true,
|
|
301
262
|
},
|
|
@@ -306,16 +267,16 @@ export function buildWorkspaceMcpTools(workspaceBound = false) {
|
|
|
306
267
|
properties: {
|
|
307
268
|
server: {
|
|
308
269
|
type: "string",
|
|
309
|
-
description: "
|
|
270
|
+
description: "工作区中登记的服务名。",
|
|
310
271
|
},
|
|
311
272
|
tool: {
|
|
312
273
|
type: "string",
|
|
313
|
-
description: "
|
|
274
|
+
description: "该服务提供的工具名。",
|
|
314
275
|
},
|
|
315
276
|
arguments: {
|
|
316
277
|
type: "object",
|
|
317
278
|
additionalProperties: true,
|
|
318
|
-
description: "
|
|
279
|
+
description: "按所选工具的参数定义填写,默认 {}。",
|
|
319
280
|
},
|
|
320
281
|
workspace,
|
|
321
282
|
},
|
|
@@ -330,7 +291,7 @@ export function buildHistoryMcpTools(workspaceBound = false) {
|
|
|
330
291
|
{
|
|
331
292
|
name: "history_search" as const,
|
|
332
293
|
description:
|
|
333
|
-
"
|
|
294
|
+
"查找工作区各宿主归档的问答或摘要。用命中项的 id 调用 history_read 可读全文。",
|
|
334
295
|
annotations: {
|
|
335
296
|
title: "Search Workspace History",
|
|
336
297
|
readOnlyHint: true,
|
|
@@ -345,38 +306,38 @@ export function buildHistoryMcpTools(workspaceBound = false) {
|
|
|
345
306
|
properties: {
|
|
346
307
|
host: {
|
|
347
308
|
type: "string",
|
|
348
|
-
description: "
|
|
309
|
+
description: "按来源宿主筛选,如 pi 或 claude。默认查全部来源。",
|
|
349
310
|
},
|
|
350
311
|
dimension: {
|
|
351
312
|
type: "string",
|
|
352
|
-
description: "
|
|
313
|
+
description: "raw 为原始问答,session、monthly 等为摘要维度。关键词搜索默认查全部。",
|
|
353
314
|
},
|
|
354
315
|
query: {
|
|
355
316
|
type: "string",
|
|
356
|
-
description: "
|
|
317
|
+
description: "匹配连续文本,忽略大小写。省略时列会话,指定摘要维度则列该维度的摘要。",
|
|
357
318
|
},
|
|
358
319
|
sessionId: {
|
|
359
320
|
type: "string",
|
|
360
|
-
description: "
|
|
321
|
+
description: "按原始会话 ID 筛选。",
|
|
361
322
|
},
|
|
362
323
|
from: {
|
|
363
324
|
type: "string",
|
|
364
|
-
description: "ISO
|
|
325
|
+
description: "时间区间起点(含),用 ISO 日期或时间。",
|
|
365
326
|
},
|
|
366
327
|
to: {
|
|
367
328
|
type: "string",
|
|
368
|
-
description: "ISO
|
|
329
|
+
description: "时间区间终点(含),仅填 ISO 日期表示该日 UTC 零点。",
|
|
369
330
|
},
|
|
370
331
|
offset: {
|
|
371
332
|
type: "integer",
|
|
372
333
|
minimum: 0,
|
|
373
|
-
description: "
|
|
334
|
+
description: "结果起点,默认 0。翻页传上页的 nextOffset。",
|
|
374
335
|
},
|
|
375
336
|
limit: {
|
|
376
337
|
type: "integer",
|
|
377
338
|
minimum: 1,
|
|
378
339
|
maximum: historyPageLimits.search.max,
|
|
379
|
-
description:
|
|
340
|
+
description: `每页条数,默认 ${historyPageLimits.search.default}。`,
|
|
380
341
|
},
|
|
381
342
|
workspace,
|
|
382
343
|
},
|
|
@@ -385,7 +346,7 @@ export function buildHistoryMcpTools(workspaceBound = false) {
|
|
|
385
346
|
{
|
|
386
347
|
name: "history_read" as const,
|
|
387
348
|
description:
|
|
388
|
-
"
|
|
349
|
+
"读取历史节点的正文和上下级。沿子节点可从月度汇总找到会话摘要和原始问答。",
|
|
389
350
|
annotations: {
|
|
390
351
|
title: "Read Workspace History Node",
|
|
391
352
|
readOnlyHint: true,
|
|
@@ -400,27 +361,27 @@ export function buildHistoryMcpTools(workspaceBound = false) {
|
|
|
400
361
|
properties: {
|
|
401
362
|
id: {
|
|
402
363
|
type: "string",
|
|
403
|
-
description: "
|
|
364
|
+
description: "搜索结果、父节点或子节点的 id。",
|
|
404
365
|
},
|
|
405
366
|
host: {
|
|
406
367
|
type: "string",
|
|
407
|
-
description: "
|
|
368
|
+
description: "节点 id 重名时填来源宿主。",
|
|
408
369
|
},
|
|
409
370
|
offset: {
|
|
410
371
|
type: "integer",
|
|
411
372
|
minimum: 0,
|
|
412
|
-
description: "正文字符偏移,默认 0
|
|
373
|
+
description: "正文字符偏移,默认 0。续读传上页的 nextOffset。",
|
|
413
374
|
},
|
|
414
375
|
limit: {
|
|
415
376
|
type: "integer",
|
|
416
377
|
minimum: 1,
|
|
417
378
|
maximum: historyPageLimits.read.max,
|
|
418
|
-
description:
|
|
379
|
+
description: `每页正文字符数,默认 ${historyPageLimits.read.default}。`,
|
|
419
380
|
},
|
|
420
381
|
childrenOffset: {
|
|
421
382
|
type: "integer",
|
|
422
383
|
minimum: 0,
|
|
423
|
-
description: "
|
|
384
|
+
description: "子节点起点,默认 0。翻页传上页的 nextChildrenOffset。",
|
|
424
385
|
},
|
|
425
386
|
workspace,
|
|
426
387
|
},
|
|
@@ -40,21 +40,19 @@ const progressIntervalMs = 5_000;
|
|
|
40
40
|
export type ProgressReporter = (message: string) => void;
|
|
41
41
|
|
|
42
42
|
const workerCapabilityInstruction =
|
|
43
|
-
"
|
|
44
|
-
"流程:worker_create 启动(或 worker_discover 复用)→ worker_request 派发/追问 → 完成后 worker_close;" +
|
|
45
|
-
"后台取结果、超时续等(timedOut)或翻页(nextOffset)用 worker_output;返回 needsResponse 时先向用户确认,再用 worker_response 回复。";
|
|
43
|
+
"用户或工作区分工指定其他助手或特定模型时,可在当前工作区委派任务。常规任务优先自行处理或使用宿主内置子代理。";
|
|
46
44
|
|
|
47
45
|
const workspaceMcpCapabilityInstruction =
|
|
48
|
-
"
|
|
46
|
+
"可调用本工作区 .pbot/mcp.json 中登记的 MCP 工具。";
|
|
49
47
|
|
|
50
48
|
const historyCapabilityInstruction =
|
|
51
|
-
"
|
|
49
|
+
"可检索本工作区各宿主归档的问答和摘要。";
|
|
52
50
|
|
|
53
51
|
export function buildMcpInstructions(options: { workspaceMcp: boolean; history: boolean }): string {
|
|
54
52
|
const parts = [workerCapabilityInstruction];
|
|
55
53
|
if (options.workspaceMcp) parts.push(workspaceMcpCapabilityInstruction);
|
|
56
54
|
if (options.history) parts.push(historyCapabilityInstruction);
|
|
57
|
-
return parts.
|
|
55
|
+
return parts.join("\n");
|
|
58
56
|
}
|
|
59
57
|
|
|
60
58
|
export const mcpWorkerOnlyInstructions = buildMcpInstructions({ workspaceMcp: false, history: false });
|
|
@@ -401,7 +399,7 @@ export class McpWorkerRuntime {
|
|
|
401
399
|
switch (name) {
|
|
402
400
|
case "workspace_mcp_discover":
|
|
403
401
|
case "workspace_mcp_call": {
|
|
404
|
-
requireThat(!this.#nativeWorkspaceMcp, "当前宿主已原生挂载工作区
|
|
402
|
+
requireThat(!this.#nativeWorkspaceMcp, "当前宿主已原生挂载工作区 MCP 服务,请直接调用对应工具。");
|
|
405
403
|
requireThat(workspaceFeatures(configuration).mcp, `工作区统一 MCP 功能已在 ${configuration.path} 中停用(features.mcp: false)。`);
|
|
406
404
|
if (name === "workspace_mcp_discover") return this.#bridge.discover(root, asString(rawArgs, "server"));
|
|
407
405
|
const server = asString(rawArgs, "server", true)!;
|
|
@@ -21,11 +21,11 @@ export async function readLocalRole(agent: WorkspaceRole, root: string): Promise
|
|
|
21
21
|
export async function agentText(
|
|
22
22
|
agent: WorkspaceRole,
|
|
23
23
|
root: string,
|
|
24
|
-
coordinatorPrompt = "plugin-coordinator.md",
|
|
24
|
+
coordinatorPrompt: string | null = "plugin-coordinator.md",
|
|
25
25
|
): Promise<string> {
|
|
26
26
|
requireThat(agent === "coordinator" || agent === "general-purpose", "未知职责。");
|
|
27
27
|
let text = await readFile(join(resourceRoot, "agents", agent + ".md"), "utf8");
|
|
28
|
-
if (agent === "coordinator") {
|
|
28
|
+
if (agent === "coordinator" && coordinatorPrompt) {
|
|
29
29
|
text += "\n\n" + await readFile(join(resourceRoot, "prompts", coordinatorPrompt), "utf8");
|
|
30
30
|
}
|
|
31
31
|
const local = await readLocalRole(agent, root);
|
|
@@ -37,14 +37,14 @@ export async function agentText(
|
|
|
37
37
|
export function formatWorkspaceSkills(skills: readonly WorkspaceSkillMeta[]): string {
|
|
38
38
|
if (!skills.length) return "";
|
|
39
39
|
const lines = skills.map(skill => `- **${skill.name}**(\`${skill.path}\`):${skill.description}`);
|
|
40
|
-
return "##
|
|
40
|
+
return "## 按需读取的技能\n\n" + lines.join("\n");
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export async function loadWorkspaceContext(options: {
|
|
44
44
|
host: HostId;
|
|
45
45
|
root: string;
|
|
46
46
|
role: WorkspaceRole;
|
|
47
|
-
coordinatorPrompt?: string;
|
|
47
|
+
coordinatorPrompt?: string | null;
|
|
48
48
|
includePrompts?: boolean;
|
|
49
49
|
includeRootAgents?: boolean;
|
|
50
50
|
localRoleOnly?: boolean;
|
|
@@ -71,7 +71,7 @@ export async function loadWorkspaceContext(options: {
|
|
|
71
71
|
: ["", "", ""];
|
|
72
72
|
const skillsSection = formatWorkspaceSkills(workspaceSkills);
|
|
73
73
|
const noticesSection = notices.length
|
|
74
|
-
? "##
|
|
74
|
+
? "## 维护提醒\n\n告知用户,按用户要求执行。\n\n" + notices.map(item => `- ${item}`).join("\n")
|
|
75
75
|
: "";
|
|
76
76
|
const environment = { host, workspaceRoot: root, resourceRoot };
|
|
77
77
|
const text = [
|
|
@@ -98,7 +98,6 @@ export const antigravityAdapter: PluginHostAdapter = {
|
|
|
98
98
|
host: "antigravity",
|
|
99
99
|
nativeRootAgents: true,
|
|
100
100
|
nativeWorkspaceSkills: true,
|
|
101
|
-
coordinatorPrompt: "plugin-coordinator.md",
|
|
102
101
|
initCommandHint: "/pbot init",
|
|
103
102
|
usage: "用法:node <插件目录>/lib/plugin.js antigravity init|status",
|
|
104
103
|
resolveRoot(cwd, rawPayload) {
|
|
@@ -3,7 +3,7 @@ import { requireThat } from "../../../common/validation.js";
|
|
|
3
3
|
import type { HostEvent, PluginHostAdapter } from "../../../model/plugin-host.js";
|
|
4
4
|
import { parsePromptEvent, pluginWorkspaceRoot, promptHooks } from "../prompt-hooks.js";
|
|
5
5
|
|
|
6
|
-
const supportedEvents = ["UserPromptSubmit", "PreToolUse", "UserPromptExpansion", "Stop"];
|
|
6
|
+
const supportedEvents = ["SessionStart", "UserPromptSubmit", "PreToolUse", "UserPromptExpansion", "Stop"];
|
|
7
7
|
const boundWorkspaceRoot = () => process.env.CLAUDE_PROJECT_DIR;
|
|
8
8
|
|
|
9
9
|
export async function claudeWorkspaceRoot(cwd: string, projectDirectory = boundWorkspaceRoot()): Promise<string> {
|
|
@@ -14,7 +14,6 @@ export const claudeAdapter: PluginHostAdapter = {
|
|
|
14
14
|
host: "claude",
|
|
15
15
|
nativeRootAgents: false,
|
|
16
16
|
nativeWorkspaceSkills: false,
|
|
17
|
-
coordinatorPrompt: "plugin-coordinator.md",
|
|
18
17
|
initCommandHint: "/personal-bot:pbot init",
|
|
19
18
|
usage: "用法:node <插件目录>/lib/claude.js init|status",
|
|
20
19
|
boundWorkspaceRoot,
|
|
@@ -17,7 +17,7 @@ export async function dshResources(
|
|
|
17
17
|
root: string,
|
|
18
18
|
role: "coordinator" | "general-purpose",
|
|
19
19
|
check: () => void,
|
|
20
|
-
coordinatorPrompt = "history-coordinator.md",
|
|
20
|
+
coordinatorPrompt: string | null = "history-coordinator.md",
|
|
21
21
|
) {
|
|
22
22
|
const read = () => Promise.all([agentText(role, root, coordinatorPrompt), readFile(join(resourceRoot, "prompts/workspace.md"), "utf8")]);
|
|
23
23
|
const [text, workspace] = await read();
|
|
@@ -18,12 +18,9 @@ export function parsePromptEvent(value: unknown): HostEvent {
|
|
|
18
18
|
if (name !== "Stop" && name !== "UserPromptSubmit" && name !== "SessionStart") return { kind: "ignore" };
|
|
19
19
|
if (typeof value.agent_id === "string") return { kind: "ignore" };
|
|
20
20
|
requireThat(typeof value.cwd === "string", "插件 hook 缺少工作目录。");
|
|
21
|
-
if (name
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
return { kind: "inject-context", role: "coordinator", isSessionStart: true, noticesOnly: true, cwd: value.cwd, raw: value };
|
|
25
|
-
}
|
|
26
|
-
return { kind: "inject-context", role: "coordinator", cwd: value.cwd, raw: value };
|
|
21
|
+
if (name !== "SessionStart") return { kind: "record-history", cwd: value.cwd, raw: value };
|
|
22
|
+
if (value.source === "resume" || value.source === "compact") return { kind: "ignore" };
|
|
23
|
+
return { kind: "inject-context", role: "coordinator", isSessionStart: true, cwd: value.cwd, raw: value };
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
export const promptHooks = {
|
package/src/pbot.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Lifecycle, WorkspaceInstance } from "./extension/hosts/pi/lifecycle.js"
|
|
|
5
5
|
import { registerCommand } from "./extension/hosts/pi/command.js";
|
|
6
6
|
import { registerEvents } from "./extension/hosts/pi/events.js";
|
|
7
7
|
import { registerHistoryEvents } from "./extension/hosts/pi/history.js";
|
|
8
|
-
import { McpWorkerRuntime, defaultWorkerDirectory } from "./extension/mcp/workers.js";
|
|
8
|
+
import { McpWorkerRuntime, defaultWorkerDirectory, mcpWorkerOnlyInstructions } from "./extension/mcp/workers.js";
|
|
9
9
|
import { workspaceFeatures } from "./services/workspace/workspace-config.js";
|
|
10
10
|
import { loadNativeWorkspaceServers } from "./extension/hosts/workspace-mcp.js";
|
|
11
11
|
import { toPiMcpConfig } from "./integrations/hosts/pi/mcp.js";
|
|
@@ -34,7 +34,7 @@ export default function pbot(pi: ExtensionAPI) {
|
|
|
34
34
|
...server,
|
|
35
35
|
exposure: "direct",
|
|
36
36
|
timeout: 600,
|
|
37
|
-
description:
|
|
37
|
+
description: mcpWorkerOnlyInstructions,
|
|
38
38
|
});
|
|
39
39
|
registeredMcpServers.push(mcpServerName);
|
|
40
40
|
}
|