personal-bot 0.3.7 → 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.
Files changed (172) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +2 -2
  3. package/README.md +5 -8
  4. package/README.zh-CN.md +5 -8
  5. package/bin/pbot-pi-acp.mjs +1 -1
  6. package/docs/architecture/design.md +2 -2
  7. package/docs/architecture/extensibility.md +4 -4
  8. package/docs/architecture/model-context.md +6 -3
  9. package/docs/guides/cross-harness-workers.md +5 -5
  10. package/docs/guides/history.md +1 -3
  11. package/docs/guides/workspace-configuration.md +5 -5
  12. package/docs/hosts/claude-code.md +3 -3
  13. package/docs/hosts/codex-qoder.md +4 -2
  14. package/hooks/hooks.json +3 -0
  15. package/lib/antigravity-plugin/bin/pbot-pi-acp.mjs +1 -1
  16. package/lib/antigravity-plugin/lib/extension/acp/member.d.ts +1 -1
  17. package/lib/antigravity-plugin/lib/extension/acp/member.js +11 -10
  18. package/lib/antigravity-plugin/lib/extension/acp-worker.js +349 -204
  19. package/lib/antigravity-plugin/lib/extension/cli.js +596 -572
  20. package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-member.js +1 -1
  21. package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.js +3 -4
  22. package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +1 -12
  23. package/lib/antigravity-plugin/lib/extension/mcp.js +463 -379
  24. package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +2 -2
  25. package/lib/antigravity-plugin/lib/integrations/agent-resources.js +3 -3
  26. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.js +0 -1
  27. package/lib/antigravity-plugin/lib/integrations/hosts/claude/adapter.js +1 -2
  28. package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.d.ts +1 -1
  29. package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.js +4 -7
  30. package/lib/antigravity-plugin/lib/model/acp.d.ts +29 -35
  31. package/lib/antigravity-plugin/lib/model/agent.d.ts +33 -17
  32. package/lib/antigravity-plugin/lib/model/agent.js +0 -1
  33. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.js +1 -1
  34. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.js +6 -3
  35. package/lib/antigravity-plugin/lib/services/history/summary-runner.js +3 -3
  36. package/lib/antigravity-plugin/lib/storage/acp-files.d.ts +5 -8
  37. package/lib/antigravity-plugin/lib/storage/acp-files.js +34 -40
  38. package/lib/antigravity-plugin/lib/storage/agent-files.d.ts +19 -10
  39. package/lib/antigravity-plugin/lib/storage/agent-files.js +147 -43
  40. package/lib/antigravity-plugin/lib/storage/history-files.js +3 -2
  41. package/lib/antigravity-plugin/package.json +1 -1
  42. package/lib/antigravity-plugin/plugin.json +2 -2
  43. package/lib/antigravity-plugin/resources/agents/coordinator.md +2 -4
  44. package/lib/antigravity-plugin/resources/agents/general-purpose.md +2 -4
  45. package/lib/antigravity-plugin/resources/prompts/history-monthly-summary.md +6 -11
  46. package/lib/antigravity-plugin/resources/prompts/history-summary.md +6 -11
  47. package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -1
  48. package/lib/antigravity-plugin/resources/prompts/workspace.md +16 -23
  49. package/lib/antigravity-plugin/resources/skills/project-maintenance/SKILL.md +14 -21
  50. package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +23 -36
  51. package/lib/antigravity-plugin/resources/templates/workspace-agents.md +5 -13
  52. package/lib/antigravity-plugin/skills/pbot/SKILL.md +6 -23
  53. package/lib/antigravity-plugin/skills/project-maintenance/SKILL.md +14 -21
  54. package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +23 -36
  55. package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +2 -2
  56. package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +2 -2
  57. package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +3 -3
  58. package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +11 -3
  59. package/lib/extension/acp/member.d.ts +1 -1
  60. package/lib/extension/acp/member.js +11 -10
  61. package/lib/extension/acp/worker.js +34 -33
  62. package/lib/extension/acp-worker.js +349 -204
  63. package/lib/extension/cli.js +596 -572
  64. package/lib/extension/hosts/dsh/acp-member.js +1 -1
  65. package/lib/extension/hosts/dsh/command.js +2 -2
  66. package/lib/extension/hosts/dsh/workspace.js +5 -5
  67. package/lib/extension/hosts/pi/acp-member.js +3 -4
  68. package/lib/extension/hosts/plugin-runtime.js +1 -12
  69. package/lib/extension/mcp/tool-contract.d.ts +8 -50
  70. package/lib/extension/mcp/tool-contract.js +61 -107
  71. package/lib/extension/mcp/workers.d.ts +7 -27
  72. package/lib/extension/mcp/workers.js +40 -24
  73. package/lib/extension/mcp.js +463 -379
  74. package/lib/integrations/acp/agents.d.ts +2 -3
  75. package/lib/integrations/acp/agents.js +22 -22
  76. package/lib/integrations/acp/harnesses/claude.js +1 -1
  77. package/lib/integrations/agent-resources.d.ts +2 -2
  78. package/lib/integrations/agent-resources.js +3 -3
  79. package/lib/integrations/hosts/antigravity/adapter.js +0 -1
  80. package/lib/integrations/hosts/claude/adapter.js +1 -2
  81. package/lib/integrations/hosts/dsh/resources.d.ts +1 -1
  82. package/lib/integrations/hosts/prompt-hooks.js +4 -7
  83. package/lib/model/acp.d.ts +29 -35
  84. package/lib/model/agent.d.ts +33 -17
  85. package/lib/model/agent.js +0 -1
  86. package/lib/qoder-plugin/.mcp.json +2 -2
  87. package/lib/qoder-plugin/.qoder-plugin/plugin.json +2 -2
  88. package/lib/qoder-plugin/hooks/hooks.json +3 -3
  89. package/lib/qoder-plugin/skills/pbot/SKILL.md +11 -3
  90. package/lib/services/agents/acp-run.d.ts +6 -4
  91. package/lib/services/agents/acp-run.js +62 -43
  92. package/lib/services/agents/agent-run.d.ts +10 -6
  93. package/lib/services/agents/agent-run.js +142 -65
  94. package/lib/services/agents/agent-service.d.ts +3 -21
  95. package/lib/services/agents/agent-service.js +182 -128
  96. package/lib/services/history/summary-dimensions/monthly.js +1 -1
  97. package/lib/services/history/summary-dimensions/session.js +6 -3
  98. package/lib/services/history/summary-runner.js +3 -3
  99. package/lib/storage/acp-files.d.ts +5 -8
  100. package/lib/storage/acp-files.js +34 -40
  101. package/lib/storage/agent-files.d.ts +19 -10
  102. package/lib/storage/agent-files.js +147 -43
  103. package/lib/storage/history-files.js +3 -2
  104. package/lib/tools/history/contract.d.ts +1 -1
  105. package/lib/tools/history/contract.js +14 -16
  106. package/package.json +2 -2
  107. package/resources/agents/coordinator.md +2 -4
  108. package/resources/agents/general-purpose.md +2 -4
  109. package/resources/antigravity/skills/pbot/SKILL.md +6 -23
  110. package/resources/claude/skills/pbot/SKILL.md +6 -23
  111. package/resources/plugin/skills/pbot/SKILL.md +11 -3
  112. package/resources/prompts/history-coordinator.md +1 -1
  113. package/resources/prompts/history-monthly-summary.md +6 -11
  114. package/resources/prompts/history-summary.md +6 -11
  115. package/resources/prompts/plugin-coordinator.md +1 -1
  116. package/resources/prompts/workspace.md +16 -23
  117. package/resources/skills/project-maintenance/SKILL.md +14 -21
  118. package/resources/skills/provider-connections/SKILL.md +23 -36
  119. package/resources/templates/workspace-agents.md +5 -13
  120. package/src/extension/acp/member.ts +14 -11
  121. package/src/extension/acp/worker.ts +31 -28
  122. package/src/extension/cli/commands/mcp.ts +1 -1
  123. package/src/extension/cli/commands/upgrade.ts +8 -36
  124. package/src/extension/cli/commands/workspace.ts +3 -8
  125. package/src/extension/cli/index.ts +1 -2
  126. package/src/extension/hosts/dsh/acp-member.ts +1 -1
  127. package/src/extension/hosts/dsh/command.ts +2 -2
  128. package/src/extension/hosts/dsh/workspace.ts +5 -4
  129. package/src/extension/hosts/pi/acp-member.ts +3 -4
  130. package/src/extension/hosts/pi/command.ts +2 -2
  131. package/src/extension/hosts/pi/events.ts +1 -1
  132. package/src/extension/hosts/pi/lifecycle.ts +0 -2
  133. package/src/extension/hosts/plugin-runtime.ts +1 -11
  134. package/src/extension/mcp/tool-contract.ts +61 -108
  135. package/src/extension/mcp/workers.ts +39 -24
  136. package/src/integrations/acp/agents.ts +28 -27
  137. package/src/integrations/acp/harnesses/claude.ts +1 -1
  138. package/src/integrations/agent-resources.ts +5 -5
  139. package/src/integrations/hosts/antigravity/adapter.ts +0 -1
  140. package/src/integrations/hosts/claude/adapter.ts +1 -2
  141. package/src/integrations/hosts/dsh/resources.ts +1 -1
  142. package/src/integrations/hosts/dsh/session.ts +2 -2
  143. package/src/integrations/hosts/prompt-hooks.ts +3 -6
  144. package/src/integrations/installation/cli-update.ts +2 -2
  145. package/src/integrations/installation/installers/claude.ts +4 -4
  146. package/src/integrations/installation/installers/qoder.ts +5 -5
  147. package/src/integrations/installation/upgraders/antigravity.ts +57 -15
  148. package/src/integrations/installation/upgraders/claude.ts +1 -4
  149. package/src/integrations/installation/upgraders/codex.ts +85 -15
  150. package/src/integrations/installation/upgraders/dsh.ts +46 -24
  151. package/src/integrations/installation/upgraders/pi.ts +18 -11
  152. package/src/integrations/installation/upgraders/qoder.ts +95 -20
  153. package/src/model/acp.ts +27 -29
  154. package/src/model/agent.ts +80 -16
  155. package/src/model/installation.ts +0 -2
  156. package/src/pbot.ts +3 -3
  157. package/src/services/agents/acp-run.ts +81 -49
  158. package/src/services/agents/agent-run.ts +154 -56
  159. package/src/services/agents/agent-service.ts +206 -135
  160. package/src/services/history/summary-dimensions/monthly.ts +1 -1
  161. package/src/services/history/summary-dimensions/session.ts +6 -3
  162. package/src/services/history/summary-runner.ts +3 -3
  163. package/src/services/installation/upgrade-service.ts +1 -5
  164. package/src/storage/acp-files.ts +50 -45
  165. package/src/storage/agent-files.ts +159 -46
  166. package/src/storage/history-files.ts +3 -2
  167. package/src/tools/history/contract.ts +14 -16
  168. package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +0 -15
  169. package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +0 -126
  170. package/lib/services/workspace/plugin-releases.d.ts +0 -15
  171. package/lib/services/workspace/plugin-releases.js +0 -126
  172. package/src/services/workspace/plugin-releases.ts +0 -121
@@ -3,7 +3,6 @@ import { pathToFileURL } from "node:url";
3
3
  import { gte, valid } from "semver";
4
4
  import { packageVersion } from "../../common/version.js";
5
5
  import { minimumCliRelease, runUpdatedCli } from "../../integrations/installation/cli-update.js";
6
- import { workspacePluginReleases } from "../../services/workspace/plugin-releases.js";
7
6
  import { readWorkspaceConfig } from "../../services/workspace/workspace-config.js";
8
7
  import { CliError, extractCommonFlags, resolveCliWorkspace } from "./args.js";
9
8
  import { historyCommand } from "./commands/history.js";
@@ -63,7 +62,7 @@ export function formatRootHelp(): string {
63
62
  }
64
63
 
65
64
  export async function updateForWorkspace(root: string, args: readonly string[], input?: string): Promise<number | undefined> {
66
- return runUpdatedCli(await minimumCliRelease(root, workspacePluginReleases(root)), args, input);
65
+ return runUpdatedCli(await minimumCliRelease(root), args, input);
67
66
  }
68
67
 
69
68
  export async function updateForCommand(args: readonly string[]): Promise<number | undefined> {
@@ -24,7 +24,7 @@ export async function apply(ctx: Context) {
24
24
  if (!rootAgents(ctx.agents).includes(agent)) return;
25
25
  if (source === "resume") agent.inbox.clear();
26
26
  const reference = member.files.reference(member.id);
27
- requireThat(reference.host === "acp" && reference.backend === "dsh" && agent.session.header.cwd === member.d.cwd &&
27
+ requireThat(reference.host === "acp" && reference.backend === "dsh" && agent.session.header.cwd === member.d.workspace &&
28
28
  (reference.sessionId === null || reference.sessionId === agent.id), "dsh ACP 会话身份或工作目录不匹配。");
29
29
  await agent.ctx.plugin({ name: "pbot-acp-expert", inject, apply: async scope => {
30
30
  if (member.features.skills) registerDshSkills(scope, agent, { workspaceRoot: member.d.workspace });
@@ -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: "Personal Bot 工作区、历史摘要与跨 Harness worker 管理",
13
+ description: "初始化或检查工作区,查询历史、更新摘要、管理委派的助手。",
14
14
  recordInput: false,
15
15
  input: { hint: "status | init | history ... | worker ...", attachments: false },
16
16
  async handler({ agent, rawInput, signal }) {
@@ -33,7 +33,7 @@ export function registerDshCommand(ctx: Context, workspaces: DshWorkspaces) {
33
33
  switch (verb) {
34
34
  case "worker": {
35
35
  const { tool, args } = parseWorkerCommand(rest);
36
- result = await workspace.workers.callTool(tool, { workspace: workspace.root, ...args });
36
+ result = await workspace.workers.callTool(tool, args, undefined, workspace.root);
37
37
  break;
38
38
  }
39
39
  case "history": {
@@ -10,7 +10,6 @@ import { registerDshHistoryTool } from "../../../tools/history/dsh-tool.js";
10
10
  import { requireThat } from "../../../common/validation.js";
11
11
  import { toDshMcpConfig } from "../../../integrations/hosts/dsh/mcp.js";
12
12
  import { registerDshSkills } from "../../../integrations/hosts/dsh/skills.js";
13
- import { bindWorkspacePlugin } from "../../../services/workspace/plugin-releases.js";
14
13
  import { readWorkspaceConfig, workspaceDisabledMessage, workspaceFeatures } from "../../../services/workspace/workspace-config.js";
15
14
  import { loadNativeWorkspaceServers } from "../workspace-mcp.js";
16
15
  import type { ResolvedWorkspaceFeatures, WorkspaceConfiguration } from "../../../model/workspace-config.js";
@@ -33,7 +32,7 @@ export class DshWorkspace {
33
32
  readonly component: AbortSignal,
34
33
  readonly features: ResolvedWorkspaceFeatures = workspaceFeatures(),
35
34
  ) {
36
- this.workers = new McpWorkerRuntime(defaultWorkerDirectory(), agent.id, "dsh");
35
+ this.workers = new McpWorkerRuntime(defaultWorkerDirectory(root), agent.id, "dsh");
37
36
  }
38
37
 
39
38
  check = () => { this.component.throwIfAborted(); this.lifetime.signal.throwIfAborted(); };
@@ -45,7 +44,10 @@ export class DshWorkspace {
45
44
  inject: dshDependencies,
46
45
  apply: async ctx => {
47
46
  if (this.features.skills) registerDshSkills(ctx, this.agent, { workspaceRoot: this.root });
48
- if (this.features.prompts) await dshResources(ctx, this.agent, this.root, "coordinator", this.check, "history-coordinator.md");
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
+ }
49
51
  registerDshFileEvents(ctx, this.agent, this.root, false, this.check);
50
52
  if (this.features.history) {
51
53
  registerDshHistoryTool(ctx, this.agent, this.root, this.lifetime.signal, this.check);
@@ -122,7 +124,6 @@ export class DshWorkspaces {
122
124
  }
123
125
  let workspace: DshWorkspace | undefined;
124
126
  try {
125
- bindWorkspacePlugin(root, "dsh");
126
127
  workspace = new DshWorkspace(this.ctx, root, agent, this.#lifetime.signal, workspaceFeatures(configuration));
127
128
  const owned = workspace;
128
129
  const dispose = agent.ctx.effect(() => async () => {
@@ -10,7 +10,6 @@ import { toPiMcpConfig } from "../../../integrations/hosts/pi/mcp.js";
10
10
  import { authorizeMutation } from "../../../services/workspace/workspace-files.js";
11
11
  import { loadNativeWorkspaceServers } from "../workspace-mcp.js";
12
12
  import { resourceRoot } from "../../../common/paths.js";
13
- import { launch } from "../../../storage/agent-files.js";
14
13
  import { requireThat } from "../../../common/validation.js";
15
14
 
16
15
  const isBlockedTool = (name: string) => name === "pbot_history" || isMcpWorkerTool(name);
@@ -22,7 +21,7 @@ export default async function piAcpMember(pi: ExtensionAPI) {
22
21
  let input: AcpInput | undefined, startLeaf: string | null = null;
23
22
  const checkSession = (ctx: ExtensionContext) => {
24
23
  const reference = member.files.reference(member.id);
25
- requireThat(reference.host === "acp" && reference.backend === "pi" && realpathSync(ctx.cwd) === member.d.cwd &&
24
+ requireThat(reference.host === "acp" && reference.backend === "pi" && realpathSync(ctx.cwd) === member.d.workspace &&
26
25
  (reference.sessionId === null || reference.sessionId === ctx.sessionManager.getSessionId()), "Pi ACP 会话身份或工作目录不匹配。");
27
26
  };
28
27
  const workspaceMcpServers: ResolvedWorkspaceMcpServer[] = [];
@@ -39,7 +38,7 @@ export default async function piAcpMember(pi: ExtensionAPI) {
39
38
  pi.on("session_start", (_event, ctx) => {
40
39
  checkSession(ctx);
41
40
  const active = pi.getActiveTools();
42
- for (const tool of agentFileTools(member.d.cwd, lifetime.signal, async (path, change, signal) => {
41
+ for (const tool of agentFileTools(member.d.workspace, lifetime.signal, async (path, change, signal) => {
43
42
  member.check(); await authorizeMutation(member.d.workspace, path, change, async () => false, signal); member.check();
44
43
  })) pi.registerTool(tool);
45
44
  for (const server of workspaceMcpServers) {
@@ -47,7 +46,7 @@ export default async function piAcpMember(pi: ExtensionAPI) {
47
46
  registeredMcp.push(server.name);
48
47
  }
49
48
  pi.setActiveTools(active.filter(name => !isBlockedTool(name)));
50
- pi.setSessionName(member.files.read(member.id, "launch.json", launch).name);
49
+ pi.setSessionName(member.id.slice(0, 8));
51
50
  startLeaf = ctx.sessionManager.getLeafId();
52
51
  });
53
52
  pi.on("before_agent_start", async (event, ctx) => {
@@ -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: "工作区初始化、状态、历史摘要与跨 Harness worker 管理",
26
+ description: "初始化或检查工作区,查询历史、更新摘要、管理委派的助手。",
27
27
  getArgumentCompletions: prefix => {
28
28
  if (/\s/.test(prefix)) return null;
29
29
  return ["init", "status", "history", "worker"]
@@ -96,7 +96,7 @@ export function registerCommand(pi: ExtensionAPI, lifecycle: Lifecycle, confirma
96
96
  if (command === "worker") {
97
97
  try {
98
98
  const { tool, args: payload } = parseWorkerCommand(argument);
99
- const result = await instance.workers.callTool(tool, { workspace: instance.root, ...payload });
99
+ const result = await instance.workers.callTool(tool, payload, undefined, instance.root);
100
100
  ctx.ui.notify(JSON.stringify(result, null, 2), "info");
101
101
  } catch (error) {
102
102
  ctx.ui.notify(error instanceof Error ? error.message : String(error), "error");
@@ -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, {
@@ -1,6 +1,5 @@
1
1
  import { realpath } from "node:fs/promises";
2
2
  import { requireThat } from "../../../common/validation.js";
3
- import { bindWorkspacePlugin } from "../../../services/workspace/plugin-releases.js";
4
3
  import { authorizeMutation } from "../../../services/workspace/workspace-files.js";
5
4
  import { readWorkspaceConfig, workspaceDisabledMessage, workspaceFeatures } from "../../../services/workspace/workspace-config.js";
6
5
  import type { ResolvedWorkspaceFeatures, WorkspaceConfiguration } from "../../../model/workspace-config.js";
@@ -73,7 +72,6 @@ export class Lifecycle {
73
72
  this.root = await realpath(root);
74
73
  this.configuration = await readWorkspaceConfig(this.root);
75
74
  if (!this.configuration.enabled) return;
76
- bindWorkspacePlugin(this.root, "pi");
77
75
  const instance = this.create(this.root, sessionId, this.configuration);
78
76
  this.#active = instance;
79
77
  try { await this.register(instance); }
@@ -6,7 +6,6 @@ import { loadWorkspaceContext } from "../../integrations/agent-resources.js";
6
6
  import type { PluginHostAdapter } from "../../model/plugin-host.js";
7
7
  import { recordHistoryCapture } from "../../services/history/history-capture.js";
8
8
  import { historyStartupNotices } from "../../services/history/summary-runner.js";
9
- import { bindWorkspacePlugin, workspacePluginDrift, workspacePluginReleases } from "../../services/workspace/plugin-releases.js";
10
9
  import { readWorkspaceConfig, workspaceFeatures } from "../../services/workspace/workspace-config.js";
11
10
  import { initializeWorkspace } from "../../services/workspace/workspace-preparation.js";
12
11
  import { discoverSkills, discoverWorkspaceSkills } from "../../services/workspace/workspace-skills.js";
@@ -21,7 +20,6 @@ export async function pluginCommand(adapter: PluginHostAdapter, args: readonly s
21
20
  requireThat(["init", "status"].includes(action), adapter.usage);
22
21
  if (action === "init") {
23
22
  await initializeWorkspace(root);
24
- bindWorkspacePlugin(root, adapter.host, process.env.PBOT_PLUGIN_MANIFEST || process.env.PBOT_PLUGIN_VERSION);
25
23
  }
26
24
  const configuration = await readWorkspaceConfig(root);
27
25
  return { version: packageVersion, workspaceRoot: root, resourceRoot, configuration };
@@ -62,7 +60,6 @@ export async function pluginHook(adapter: PluginHostAdapter, payload: unknown, r
62
60
  return adapter.formatPass(payload);
63
61
  }
64
62
  if (!configuration.enabled) return adapter.formatPass(payload);
65
- if (event.kind === "inject-context") bindWorkspacePlugin(root, adapter.host, process.env.PBOT_PLUGIN_MANIFEST || process.env.PBOT_PLUGIN_VERSION);
66
63
  if (features.history && adapter.extractHistory) {
67
64
  try {
68
65
  const capture = await adapter.extractHistory(event);
@@ -80,19 +77,12 @@ export async function pluginHook(adapter: PluginHostAdapter, payload: unknown, r
80
77
  workspaceSkills.push(...await discoverSkills(directory, directory));
81
78
  }
82
79
  const notices = event.isSessionStart && features.history ? [...historyStartupNotices(root)] : [];
83
- if (event.isSessionStart) {
84
- const drift = workspacePluginDrift(workspacePluginReleases(root));
85
- if (drift.outOfSync) {
86
- const summary = Object.entries(drift.versions).map(([host, version]) => `${host}=${version}`).join(", ");
87
- notices.push(`检测到当前工作区各宿主 Personal Bot 插件版本不一致(${summary}),可在终端运行 pbot upgrade 统一升级。`);
88
- }
89
- }
90
80
  if (!includePrompts && !workspaceSkills.length && !notices.length) return adapter.formatPass(payload);
91
81
  const context = await loadWorkspaceContext({
92
82
  host: adapter.host,
93
83
  root,
94
84
  role: event.role,
95
- ...(adapter.coordinatorPrompt ? { coordinatorPrompt: adapter.coordinatorPrompt } : {}),
85
+ coordinatorPrompt: adapter.coordinatorPrompt ?? (features.history ? "plugin-coordinator.md" : null),
96
86
  includePrompts,
97
87
  includeRootAgents: includePrompts && !adapter.nativeRootAgents,
98
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
- : "目标工作区根目录绝对路径;请传入环境中的 workspaceRoot。",
22
+ ? "工作区根目录的绝对路径,默认当前绑定的工作区。"
23
+ : "传目标工作区的绝对路径(workspaceRoot)。省略时使用服务的当前目录。",
39
24
  };
40
25
  }
41
26
 
42
27
  export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?: string, workspaceBound = false) {
43
- const { overview, availableIds } = summarizeBackends(commands, defaultBackend);
44
- const modelsBackendHint = defaultBackend
45
- ? `省略时默认查 ${defaultBackend}`
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
- "启动独立的外部助手会话并返回 workerId(不发送任务,随后用 worker_request 派发)。未指定其他助手或特定模型时,优先自行完成或使用当前内置子代理。\n" +
45
+ "新建独立助手会话,返回 workerId。用 worker_request 发送首个任务。\n" +
54
46
  overview,
55
47
  annotations: {
56
48
  title: "Create Worker",
@@ -66,19 +58,15 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
66
58
  properties: {
67
59
  backend: {
68
60
  type: "string",
69
- description: "目标外部助手标识(不区分大小写,支持常见别名如 claude-code、agy)。",
61
+ description: "助手标识或别名,如 claude-code、agy。",
70
62
  },
71
63
  model: {
72
64
  type: "string",
73
- description: "目标模型(模型 ID、显示名或 provider/model,不区分大小写);未明确指定时省略以用默认模型,不确定可选值时先查 worker_discover(target=\"models\")。",
65
+ description: "模型 ID、显示名或 provider/model。未指定模型时省略,使用助手默认模型。",
74
66
  },
75
67
  thinking: {
76
68
  type: "string",
77
- description: "思考深度(如 low / medium / high / xhigh / max,不区分大小写);未明确指定时省略以用默认设置。",
78
- },
79
- cwd: {
80
- type: "string",
81
- description: "执行目录(绝对路径或相对工作区路径),默认工作区根目录。",
69
+ description: "思考深度,如 high。未指定时省略,使用助手默认设置。",
82
70
  },
83
71
  workspace,
84
72
  },
@@ -87,7 +75,7 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
87
75
  {
88
76
  name: "worker_close" as const,
89
77
  description:
90
- "结束外部助手会话并释放进程。若该会话支持恢复(capabilities.resume),后续仍可直接用 worker_request 续接。",
78
+ "任务结束后关闭助手。提前关闭会中断执行。创建结果中 resume 为 true 时,可用原 workerId 续接。",
91
79
  annotations: {
92
80
  title: "Close Worker",
93
81
  readOnlyHint: false,
@@ -100,19 +88,14 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
100
88
  additionalProperties: false,
101
89
  required: ["workerId"],
102
90
  properties: {
103
- workerId: {
104
- type: "string",
105
- description: "助手会话 ID(来自 worker_create 或 worker_discover)。",
106
- },
107
- workspace,
91
+ workerId,
108
92
  },
109
93
  },
110
94
  },
111
95
  {
112
96
  name: "worker_request" as const,
113
97
  description:
114
- "向外部助手派发任务或在同一上下文中追问(已关闭且支持恢复的会话会自动续接)。" +
115
- `默认最多等待 ${defaultWaitMs / 1000} 秒(waitMs 设为 0 可立即转后台并行);返回 timedOut 或 nextOffset 用 worker_output,返回 needsResponse 先向用户确认再用 worker_response。`,
98
+ "向助手派发任务或在同一会话追问。后台结果用 worker_output 收取。",
116
99
  annotations: {
117
100
  title: "Send Request to Worker",
118
101
  readOnlyHint: false,
@@ -125,29 +108,19 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
125
108
  additionalProperties: false,
126
109
  required: ["workerId", "message"],
127
110
  properties: {
128
- workerId: {
129
- type: "string",
130
- description: "助手会话 ID(来自 worker_create 或 worker_discover)。",
131
- },
111
+ workerId,
132
112
  message: {
133
113
  type: "string",
134
- description: "任务说明或追问内容。外部助手看不到当前会话历史,首次派发需写清背景、目标、相关文件路径、约束和期望产出。",
135
- },
136
- waitMs: {
137
- type: "integer",
138
- minimum: 0,
139
- maximum: maxWaitMs,
140
- description: `最多等待毫秒数(默认 ${defaultWaitMs});0 表示立即返回转后台执行。`,
114
+ description: "任务或追问。助手看不到主会话历史,首次派发时写明背景、目标、文件路径、约束和交付要求。",
141
115
  },
142
- workspace,
116
+ waitMs,
143
117
  },
144
118
  },
145
119
  },
146
120
  {
147
121
  name: "worker_response" as const,
148
122
  description:
149
- "回复外部助手暂停时发出的待处理请求(needsResponse: true),支持操作授权、表单问答与链接确认。" +
150
- `提交前先向用户确认;提交后默认等待最多 ${defaultWaitMs / 1000} 秒返回后续结果。`,
123
+ "收到 needsResponse 时,将权限选项、表单问题或链接交给用户确认,再提交用户的决定。",
151
124
  annotations: {
152
125
  title: "Respond to Worker Request",
153
126
  readOnlyHint: false,
@@ -160,42 +133,33 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
160
133
  additionalProperties: false,
161
134
  required: ["workerId", "action"],
162
135
  properties: {
163
- workerId: {
164
- type: "string",
165
- description: "等待回复的助手会话 ID。",
166
- },
136
+ workerId,
167
137
  action: {
168
138
  type: "string",
169
139
  enum: [...acpElicitationActions],
170
- description: "accept 同意/提交表单/确认链接;decline 拒绝;cancel 取消请求。",
140
+ description: "accept 同意或提交答案,decline 拒绝,cancel 取消请求。",
171
141
  },
172
142
  requestId: {
173
143
  type: "string",
174
- description: "请求 ID(pendingRequests[].requestId);仅一条待处理请求时可省略,多条时必填。",
144
+ description: "待回复的请求 ID。仅有一条待处理请求时可省略。",
175
145
  },
176
146
  optionId: {
177
147
  type: "string",
178
- description: "仅 permission 请求且 action≠cancel 时可用:指定 pendingRequests[].options[].optionId,省略则按 action 单次允许或拒绝。",
148
+ description: "允许或拒绝操作时填用户所选权限的 ID。省略时优先单次,缺少单次选项时可能采用长期选项。",
179
149
  },
180
150
  content: {
181
151
  type: "object",
182
152
  additionalProperties: true,
183
- description: "仅 form 请求且 action=\"accept\" 时可用:按 pendingRequests[].schema.properties 填写回答对象(值为字符串、数字、布尔值或字符串数组)。",
153
+ description: "接受表单时,按表单字段填写答案。值可为字符串、数字、布尔值或字符串数组。",
184
154
  },
185
- waitMs: {
186
- type: "integer",
187
- minimum: 0,
188
- maximum: maxWaitMs,
189
- description: `提交后最多等待毫秒数(默认 ${defaultWaitMs});0 表示立即返回。`,
190
- },
191
- workspace,
155
+ waitMs,
192
156
  },
193
157
  },
194
158
  },
195
159
  {
196
160
  name: "worker_output" as const,
197
161
  description:
198
- "获取或等待外部助手的最新结果,用于收取后台产出、timedOut 后继续等待,或按 nextOffset 分页续读。任务已结束时立即返回,运行中最多等待 waitMs。",
162
+ "读取助手最近一轮的结果。后台执行或返回 timedOut 时,用原 workerId 继续等待。",
199
163
  annotations: {
200
164
  title: "Get Worker Output",
201
165
  readOnlyHint: true,
@@ -208,29 +172,20 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
208
172
  additionalProperties: false,
209
173
  required: ["workerId"],
210
174
  properties: {
211
- workerId: {
212
- type: "string",
213
- description: "助手会话 ID。",
214
- },
175
+ workerId,
215
176
  offset: {
216
177
  type: "integer",
217
178
  minimum: 0,
218
- description: "读取起始位置(默认 0);翻页续读时传上次返回的 nextOffset。",
219
- },
220
- waitMs: {
221
- type: "integer",
222
- minimum: 0,
223
- maximum: maxWaitMs,
224
- description: `运行中最多等待毫秒数(默认 ${defaultWaitMs});已结束或翻页时立即返回。`,
179
+ description: "续读传上页的 nextOffset,默认从 0 开始。",
225
180
  },
226
- workspace,
181
+ waitMs,
227
182
  },
228
183
  },
229
184
  },
230
185
  {
231
186
  name: "worker_discover" as const,
232
187
  description:
233
- "查询可用外部助手、已有会话状态,或某个助手支持的模型与思考深度。默认(overview)返回可用助手与已有会话;仅需核对模型或思考深度可选值时再查 models(需启动探测,耗时较长)。",
188
+ "查找可复用的会话、查看助手状态或核对模型选项。查询模型会临时启动目标助手。",
234
189
  annotations: {
235
190
  title: "Discover Workers, Backends & Models",
236
191
  readOnlyHint: true,
@@ -246,21 +201,19 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
246
201
  target: {
247
202
  type: "string",
248
203
  enum: [...discoverTargets],
249
- description: "overview(默认,可用助手与已有会话)、workers(全部或单个会话状态)、backends(可用助手)、models(指定助手的模型与思考深度)。",
204
+ description: "overview(默认)列助手及当前会话拥有的 worker,workers 只查会话,backends 只查助手可用情况,models 查模型与思考深度。",
250
205
  },
251
206
  workerId: {
252
207
  type: "string",
253
- description: "仅 target=\"workers\" 可用:指定单个会话 ID,省略列全部。",
208
+ description: "查 workers 时可指定单个会话,省略列出全部所属会话。",
254
209
  },
255
210
  backend: {
256
211
  type: "string",
257
- description: availableIds
258
- ? `仅 target="models" 可用(${modelsBackendHint}):目标助手标识,支持别名;当前可用:${availableIds}。`
259
- : `仅 target="models" 可用(${modelsBackendHint}):目标助手标识,支持别名。`,
212
+ description: defaultBackend ? `查 models 时选择助手,默认 ${defaultBackend}。` : "查 models 时必填助手标识。",
260
213
  },
261
214
  model: {
262
215
  type: "string",
263
- description: "仅 target=\"models\" 可用:指定模型以查看其支持的思考深度选项。",
216
+ description: "查 models 时可指定模型以查看它支持的思考深度。",
264
217
  },
265
218
  workspace,
266
219
  },
@@ -275,7 +228,7 @@ export function buildWorkspaceMcpTools(workspaceBound = false) {
275
228
  {
276
229
  name: "workspace_mcp_discover" as const,
277
230
  description:
278
- "查询当前工作区共享 MCP 服务(.pbot/mcp.json)。省略 server 列出服务;传入 server 返回其工具列表与参数说明。",
231
+ "查找工作区共享的 MCP 服务,以及服务提供的工具和参数。",
279
232
  annotations: {
280
233
  title: "Discover Workspace MCP Servers & Tools",
281
234
  readOnlyHint: true,
@@ -290,7 +243,7 @@ export function buildWorkspaceMcpTools(workspaceBound = false) {
290
243
  properties: {
291
244
  server: {
292
245
  type: "string",
293
- description: "服务名称;省略列出工作区全部已配置服务。",
246
+ description: "填服务名列出其工具,省略则列出已配置的服务。",
294
247
  },
295
248
  workspace,
296
249
  },
@@ -299,11 +252,11 @@ export function buildWorkspaceMcpTools(workspaceBound = false) {
299
252
  {
300
253
  name: "workspace_mcp_call" as const,
301
254
  description:
302
- "调用工作区共享 MCP 服务中的指定工具。不确定工具名或参数时先用 workspace_mcp_discover(server) 查询。",
255
+ "执行工作区共享 MCP 服务的工具,读写效果取决于所选工具。工具名和参数可用 workspace_mcp_discover 查询。",
303
256
  annotations: {
304
257
  title: "Call Workspace MCP Tool",
305
258
  readOnlyHint: false,
306
- destructiveHint: false,
259
+ destructiveHint: true,
307
260
  idempotentHint: false,
308
261
  openWorldHint: true,
309
262
  },
@@ -314,16 +267,16 @@ export function buildWorkspaceMcpTools(workspaceBound = false) {
314
267
  properties: {
315
268
  server: {
316
269
  type: "string",
317
- description: "服务名称(来自 workspace_mcp_discover)。",
270
+ description: "工作区中登记的服务名。",
318
271
  },
319
272
  tool: {
320
273
  type: "string",
321
- description: "工具名称。",
274
+ description: "该服务提供的工具名。",
322
275
  },
323
276
  arguments: {
324
277
  type: "object",
325
278
  additionalProperties: true,
326
- description: "传给目标工具的参数对象,默认空对象。",
279
+ description: "按所选工具的参数定义填写,默认 {}。",
327
280
  },
328
281
  workspace,
329
282
  },
@@ -338,7 +291,7 @@ export function buildHistoryMcpTools(workspaceBound = false) {
338
291
  {
339
292
  name: "history_search" as const,
340
293
  description:
341
- "搜索当前工作区跨宿主历史问答与摘要归档(不含工具调用日志)。省略 query 列出各会话或指定维度摘要;传入 query 按不区分大小写的连续关键词匹配。",
294
+ "查找工作区各宿主归档的问答或摘要。用命中项的 id 调用 history_read 可读全文。",
342
295
  annotations: {
343
296
  title: "Search Workspace History",
344
297
  readOnlyHint: true,
@@ -353,38 +306,38 @@ export function buildHistoryMcpTools(workspaceBound = false) {
353
306
  properties: {
354
307
  host: {
355
308
  type: "string",
356
- description: "来源宿主筛选(如 pi、dsh、claude、antigravity、codex、qoder);省略查全部。",
309
+ description: "按来源宿主筛选,如 pi 或 claude。默认查全部来源。",
357
310
  },
358
311
  dimension: {
359
312
  type: "string",
360
- description: "范围筛选:raw 仅原文,或指定摘要维度(如 monthly、session);省略查全部。",
313
+ description: "raw 为原始问答,session、monthly 等为摘要维度。关键词搜索默认查全部。",
361
314
  },
362
315
  query: {
363
316
  type: "string",
364
- description: "连续关键词(不区分大小写);省略列会话或指定维度摘要。",
317
+ description: "匹配连续文本,忽略大小写。省略时列会话,指定摘要维度则列该维度的摘要。",
365
318
  },
366
319
  sessionId: {
367
320
  type: "string",
368
- description: "限定在指定原始会话 ID 内搜索。",
321
+ description: "按原始会话 ID 筛选。",
369
322
  },
370
323
  from: {
371
324
  type: "string",
372
- description: "ISO 日期或时间下界。",
325
+ description: "时间区间起点(含),用 ISO 日期或时间。",
373
326
  },
374
327
  to: {
375
328
  type: "string",
376
- description: "ISO 日期或时间上界。",
329
+ description: "时间区间终点(含),仅填 ISO 日期表示该日 UTC 零点。",
377
330
  },
378
331
  offset: {
379
332
  type: "integer",
380
333
  minimum: 0,
381
- description: "结果偏移,默认 0。",
334
+ description: "结果起点,默认 0。翻页传上页的 nextOffset。",
382
335
  },
383
336
  limit: {
384
337
  type: "integer",
385
338
  minimum: 1,
386
339
  maximum: historyPageLimits.search.max,
387
- description: `返回条数(1–${historyPageLimits.search.max}),默认 ${historyPageLimits.search.default}。`,
340
+ description: `每页条数,默认 ${historyPageLimits.search.default}。`,
388
341
  },
389
342
  workspace,
390
343
  },
@@ -393,7 +346,7 @@ export function buildHistoryMcpTools(workspaceBound = false) {
393
346
  {
394
347
  name: "history_read" as const,
395
348
  description:
396
- "按节点 id 读取历史正文与上下级(可从 monthly 汇总下钻至 session 摘要和 exchange 原文)。正文分页传 nextOffset,子节点分页传 nextChildrenOffset。",
349
+ "读取历史节点的正文和上下级。沿子节点可从月度汇总找到会话摘要和原始问答。",
397
350
  annotations: {
398
351
  title: "Read Workspace History Node",
399
352
  readOnlyHint: true,
@@ -408,27 +361,27 @@ export function buildHistoryMcpTools(workspaceBound = false) {
408
361
  properties: {
409
362
  id: {
410
363
  type: "string",
411
- description: "节点 id(来自 history_search 或上下级)。",
364
+ description: "搜索结果、父节点或子节点的 id。",
412
365
  },
413
366
  host: {
414
367
  type: "string",
415
- description: "跨宿主 id 冲突时指定来源宿主。",
368
+ description: "节点 id 重名时填来源宿主。",
416
369
  },
417
370
  offset: {
418
371
  type: "integer",
419
372
  minimum: 0,
420
- description: "正文字符偏移,默认 0;续读传上次 nextOffset。",
373
+ description: "正文字符偏移,默认 0。续读传上页的 nextOffset。",
421
374
  },
422
375
  limit: {
423
376
  type: "integer",
424
377
  minimum: 1,
425
378
  maximum: historyPageLimits.read.max,
426
- description: `正文字符数(1–${historyPageLimits.read.max}),默认 ${historyPageLimits.read.default}。`,
379
+ description: `每页正文字符数,默认 ${historyPageLimits.read.default}。`,
427
380
  },
428
381
  childrenOffset: {
429
382
  type: "integer",
430
383
  minimum: 0,
431
- description: "子节点偏移,默认 0;续读传上次 nextChildrenOffset。",
384
+ description: "子节点起点,默认 0。翻页传上页的 nextChildrenOffset。",
432
385
  },
433
386
  workspace,
434
387
  },