personal-bot 0.4.0 → 0.4.2

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 (120) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +2 -2
  3. package/README.md +4 -1
  4. package/README.zh-CN.md +4 -1
  5. package/docs/README.md +2 -3
  6. package/docs/architecture/design.md +41 -2
  7. package/docs/architecture/extensibility.md +3 -3
  8. package/docs/architecture/model-context.md +10 -4
  9. package/docs/architecture/principles.md +2 -2
  10. package/docs/guides/cross-harness-workers.md +27 -2
  11. package/docs/guides/workspace-configuration.md +3 -1
  12. package/docs/hosts/claude-code.md +1 -1
  13. package/docs/hosts/codex-qoder.md +3 -1
  14. package/hooks/hooks.json +3 -0
  15. package/lib/antigravity-plugin/lib/extension/acp-worker.js +22 -6
  16. package/lib/antigravity-plugin/lib/extension/cli.js +169 -95
  17. package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +3 -1
  18. package/lib/antigravity-plugin/lib/extension/mcp.js +163 -119
  19. package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +4 -2
  20. package/lib/antigravity-plugin/lib/integrations/agent-resources.js +23 -5
  21. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.js +0 -1
  22. package/lib/antigravity-plugin/lib/integrations/hosts/claude/adapter.js +1 -2
  23. package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.d.ts +2 -1
  24. package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.js +12 -13
  25. package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.js +4 -7
  26. package/lib/antigravity-plugin/lib/model/worker-template.d.ts +21 -0
  27. package/lib/antigravity-plugin/lib/model/worker-template.js +1 -0
  28. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.js +1 -1
  29. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.js +6 -3
  30. package/lib/antigravity-plugin/lib/services/history/summary-runner.js +3 -3
  31. package/lib/antigravity-plugin/lib/services/workspace/worker-templates.d.ts +17 -0
  32. package/lib/antigravity-plugin/lib/services/workspace/worker-templates.js +88 -0
  33. package/lib/antigravity-plugin/lib/storage/history-files.js +3 -2
  34. package/lib/antigravity-plugin/package.json +1 -1
  35. package/lib/antigravity-plugin/plugin.json +2 -2
  36. package/lib/antigravity-plugin/resources/agents/coordinator.md +2 -4
  37. package/lib/antigravity-plugin/resources/agents/general-purpose.md +2 -4
  38. package/lib/antigravity-plugin/resources/prompts/history-monthly-summary.md +6 -11
  39. package/lib/antigravity-plugin/resources/prompts/history-summary.md +6 -11
  40. package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -1
  41. package/lib/antigravity-plugin/resources/prompts/workspace.md +16 -23
  42. package/lib/antigravity-plugin/resources/skills/project-maintenance/SKILL.md +14 -21
  43. package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +23 -36
  44. package/lib/antigravity-plugin/resources/templates/workspace-agents.md +5 -13
  45. package/lib/antigravity-plugin/skills/pbot/SKILL.md +6 -23
  46. package/lib/antigravity-plugin/skills/project-maintenance/SKILL.md +14 -21
  47. package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +23 -36
  48. package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +2 -2
  49. package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +2 -2
  50. package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +3 -3
  51. package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +11 -3
  52. package/lib/extension/acp-worker.js +22 -6
  53. package/lib/extension/cli.js +169 -95
  54. package/lib/extension/hosts/dsh/command.js +1 -1
  55. package/lib/extension/hosts/dsh/workspace.js +5 -2
  56. package/lib/extension/hosts/plugin-runtime.js +3 -1
  57. package/lib/extension/mcp/tool-contract.d.ts +3 -3
  58. package/lib/extension/mcp/tool-contract.js +63 -101
  59. package/lib/extension/mcp/workers.d.ts +1 -1
  60. package/lib/extension/mcp/workers.js +19 -13
  61. package/lib/extension/mcp.js +163 -119
  62. package/lib/integrations/agent-resources.d.ts +4 -2
  63. package/lib/integrations/agent-resources.js +23 -5
  64. package/lib/integrations/hosts/antigravity/adapter.js +0 -1
  65. package/lib/integrations/hosts/claude/adapter.js +1 -2
  66. package/lib/integrations/hosts/dsh/resources.d.ts +2 -1
  67. package/lib/integrations/hosts/dsh/resources.js +12 -13
  68. package/lib/integrations/hosts/prompt-hooks.js +4 -7
  69. package/lib/model/worker-template.d.ts +21 -0
  70. package/lib/model/worker-template.js +1 -0
  71. package/lib/qoder-plugin/.mcp.json +2 -2
  72. package/lib/qoder-plugin/.qoder-plugin/plugin.json +2 -2
  73. package/lib/qoder-plugin/hooks/hooks.json +3 -3
  74. package/lib/qoder-plugin/skills/pbot/SKILL.md +11 -3
  75. package/lib/services/agents/agent-service.js +2 -2
  76. package/lib/services/history/summary-dimensions/monthly.js +1 -1
  77. package/lib/services/history/summary-dimensions/session.js +6 -3
  78. package/lib/services/history/summary-runner.js +3 -3
  79. package/lib/services/workspace/worker-templates.d.ts +17 -0
  80. package/lib/services/workspace/worker-templates.js +88 -0
  81. package/lib/storage/history-files.js +3 -2
  82. package/lib/tools/history/contract.d.ts +1 -1
  83. package/lib/tools/history/contract.js +14 -16
  84. package/package.json +2 -2
  85. package/resources/agents/coordinator.md +2 -4
  86. package/resources/agents/general-purpose.md +2 -4
  87. package/resources/antigravity/skills/pbot/SKILL.md +6 -23
  88. package/resources/claude/skills/pbot/SKILL.md +6 -23
  89. package/resources/plugin/skills/pbot/SKILL.md +11 -3
  90. package/resources/prompts/history-coordinator.md +1 -1
  91. package/resources/prompts/history-monthly-summary.md +6 -11
  92. package/resources/prompts/history-summary.md +6 -11
  93. package/resources/prompts/plugin-coordinator.md +1 -1
  94. package/resources/prompts/workspace.md +16 -23
  95. package/resources/skills/project-maintenance/SKILL.md +14 -21
  96. package/resources/skills/provider-connections/SKILL.md +23 -36
  97. package/resources/templates/workspace-agents.md +5 -13
  98. package/src/extension/cli/commands/mcp.ts +1 -1
  99. package/src/extension/hosts/dsh/command.ts +1 -1
  100. package/src/extension/hosts/dsh/workspace.ts +5 -1
  101. package/src/extension/hosts/pi/command.ts +1 -1
  102. package/src/extension/hosts/pi/events.ts +3 -1
  103. package/src/extension/hosts/plugin-runtime.ts +3 -1
  104. package/src/extension/mcp/tool-contract.ts +63 -103
  105. package/src/extension/mcp/workers.ts +21 -14
  106. package/src/integrations/agent-resources.ts +27 -7
  107. package/src/integrations/hosts/antigravity/adapter.ts +0 -1
  108. package/src/integrations/hosts/claude/adapter.ts +1 -2
  109. package/src/integrations/hosts/dsh/resources.ts +14 -13
  110. package/src/integrations/hosts/prompt-hooks.ts +3 -6
  111. package/src/model/worker-template.ts +24 -0
  112. package/src/pbot.ts +2 -2
  113. package/src/services/agents/agent-service.ts +2 -2
  114. package/src/services/history/summary-dimensions/monthly.ts +1 -1
  115. package/src/services/history/summary-dimensions/session.ts +6 -3
  116. package/src/services/history/summary-runner.ts +3 -3
  117. package/src/services/workspace/worker-templates.ts +80 -0
  118. package/src/storage/history-files.ts +3 -2
  119. package/src/tools/history/contract.ts +14 -16
  120. package/docs/architecture/model-instruction-guidelines.md +0 -34
@@ -1,17 +1,19 @@
1
1
  import type { HostId, WorkspaceContext, WorkspaceRole } from "../model/plugin-host.js";
2
+ import type { ReadWorkerTemplates } from "../model/worker-template.js";
2
3
  import type { WorkspaceSkillMeta } from "../model/workspace-mcp.js";
3
4
  export declare function readOptionalFile(path: string): Promise<string>;
4
5
  export declare function readLocalRole(agent: WorkspaceRole, root: string): Promise<string>;
5
- export declare function agentText(agent: WorkspaceRole, root: string, coordinatorPrompt?: string): Promise<string>;
6
+ export declare function agentText(agent: WorkspaceRole, root: string, coordinatorPrompt?: string | null): Promise<string>;
6
7
  export declare function formatWorkspaceSkills(skills: readonly WorkspaceSkillMeta[]): string;
7
8
  export declare function loadWorkspaceContext(options: {
8
9
  host: HostId;
9
10
  root: string;
10
11
  role: WorkspaceRole;
11
- coordinatorPrompt?: string;
12
+ coordinatorPrompt?: string | null;
12
13
  includePrompts?: boolean;
13
14
  includeRootAgents?: boolean;
14
15
  localRoleOnly?: boolean;
16
+ readWorkerTemplates?: ReadWorkerTemplates;
15
17
  workspaceSkills?: readonly WorkspaceSkillMeta[];
16
18
  notices?: readonly string[];
17
19
  }): Promise<WorkspaceContext>;
@@ -19,7 +19,7 @@ export async function readLocalRole(agent, root) {
19
19
  export async function agentText(agent, root, coordinatorPrompt = "plugin-coordinator.md") {
20
20
  requireThat(agent === "coordinator" || agent === "general-purpose", "未知职责。");
21
21
  let text = await readFile(join(resourceRoot, "agents", agent + ".md"), "utf8");
22
- if (agent === "coordinator") {
22
+ if (agent === "coordinator" && coordinatorPrompt) {
23
23
  text += "\n\n" + await readFile(join(resourceRoot, "prompts", coordinatorPrompt), "utf8");
24
24
  }
25
25
  const local = await readLocalRole(agent, root);
@@ -32,20 +32,38 @@ export function formatWorkspaceSkills(skills) {
32
32
  if (!skills.length)
33
33
  return "";
34
34
  const lines = skills.map(skill => `- **${skill.name}**(\`${skill.path}\`):${skill.description}`);
35
- return "## 可用技能\n\n任务匹配时按需读取对应 `SKILL.md` 正文:\n" + lines.join("\n");
35
+ return "## 按需读取的技能\n\n" + lines.join("\n");
36
+ }
37
+ function formatWorkerTemplates(templates) {
38
+ if (!templates.length)
39
+ return "";
40
+ const lines = templates.map(({ id, name, description, create }) => {
41
+ const label = name === id ? id : `${name}(${id})`;
42
+ const settings = [
43
+ ["助手", create.backend],
44
+ ["执行工作区", create.workspace],
45
+ ["模型", create.model],
46
+ ["思考深度", create.thinking],
47
+ ].filter(([, value]) => value !== undefined)
48
+ .map(([field, value]) => `${field} ${JSON.stringify(value)}`).join(",");
49
+ return `- ${label} ${description}(${settings})`;
50
+ });
51
+ return "## 工作区助手模板\n\n选用模板时,用 worker_discover 查询最新设置(target=templates)。\n\n" + lines.join("\n");
36
52
  }
37
53
  export async function loadWorkspaceContext(options) {
38
54
  const { host, root, role, coordinatorPrompt, includePrompts = true, includeRootAgents = false, localRoleOnly = false, workspaceSkills = [], notices = [], } = options;
39
- const [workspace, roleText, rootAgents] = includePrompts
55
+ const [workspace, baseRole, rootAgents, catalog] = includePrompts
40
56
  ? await Promise.all([
41
57
  readFile(join(resourceRoot, "prompts/workspace.md"), "utf8"),
42
58
  localRoleOnly ? readLocalRole(role, root) : agentText(role, root, coordinatorPrompt),
43
59
  includeRootAgents ? readOptionalFile(join(root, "AGENTS.md")) : Promise.resolve(""),
60
+ role === "coordinator" ? options.readWorkerTemplates?.(root) : undefined,
44
61
  ])
45
- : ["", "", ""];
62
+ : ["", "", "", undefined];
63
+ const roleText = [baseRole, formatWorkerTemplates(catalog?.templates ?? [])].filter(Boolean).join("\n\n");
46
64
  const skillsSection = formatWorkspaceSkills(workspaceSkills);
47
65
  const noticesSection = notices.length
48
- ? "## 启动提示\n\n以下为工作区维护提醒,适时顺带告知用户即可,勿未经用户要求自行执行:\n" + notices.map(item => `- ${item}`).join("\n")
66
+ ? "## 维护提醒\n\n告知用户,按用户要求执行。\n\n" + notices.map(item => `- ${item}`).join("\n")
49
67
  : "";
50
68
  const environment = { host, workspaceRoot: root, resourceRoot };
51
69
  const text = [
@@ -104,7 +104,6 @@ export const antigravityAdapter = {
104
104
  host: "antigravity",
105
105
  nativeRootAgents: true,
106
106
  nativeWorkspaceSkills: true,
107
- coordinatorPrompt: "plugin-coordinator.md",
108
107
  initCommandHint: "/pbot init",
109
108
  usage: "用法:node <插件目录>/lib/plugin.js antigravity init|status",
110
109
  resolveRoot(cwd, rawPayload) {
@@ -1,7 +1,7 @@
1
1
  import { object } from "../../../common/json.js";
2
2
  import { requireThat } from "../../../common/validation.js";
3
3
  import { parsePromptEvent, pluginWorkspaceRoot, promptHooks } from "../prompt-hooks.js";
4
- const supportedEvents = ["UserPromptSubmit", "PreToolUse", "UserPromptExpansion", "Stop"];
4
+ const supportedEvents = ["SessionStart", "UserPromptSubmit", "PreToolUse", "UserPromptExpansion", "Stop"];
5
5
  const boundWorkspaceRoot = () => process.env.CLAUDE_PROJECT_DIR;
6
6
  export async function claudeWorkspaceRoot(cwd, projectDirectory = boundWorkspaceRoot()) {
7
7
  return pluginWorkspaceRoot(projectDirectory || cwd);
@@ -10,7 +10,6 @@ export const claudeAdapter = {
10
10
  host: "claude",
11
11
  nativeRootAgents: false,
12
12
  nativeWorkspaceSkills: false,
13
- coordinatorPrompt: "plugin-coordinator.md",
14
13
  initCommandHint: "/personal-bot:pbot init",
15
14
  usage: "用法:node <插件目录>/lib/claude.js init|status",
16
15
  boundWorkspaceRoot,
@@ -1,6 +1,7 @@
1
1
  import type { Context } from "@deepseek-ai/cordis";
2
2
  import type { Agent } from "@deepseek-ai/dsh-agent";
3
3
  import type { AgentOptions } from "../../../model/agent.js";
4
- export declare function dshResources(ctx: Context, _agent: Agent, root: string, role: "coordinator" | "general-purpose", check: () => void, coordinatorPrompt?: string): Promise<void>;
4
+ import type { ReadWorkerTemplates } from "../../../model/worker-template.js";
5
+ export declare function dshResources(ctx: Context, _agent: Agent, root: string, role: "coordinator" | "general-purpose", check: () => void, coordinatorPrompt?: string | null, readWorkerTemplates?: ReadWorkerTemplates): Promise<void>;
5
6
  /** Map an ACP dsh worker's native loadout without interfering with coordinator sessions. */
6
7
  export declare function dshExpertTools(ctx: Context, agent: Agent, options: AgentOptions): void;
@@ -1,28 +1,27 @@
1
- import { readFile } from "node:fs/promises";
2
- import { join } from "node:path";
3
- import { agentText } from "../../agent-resources.js";
4
- import { resourceRoot } from "../../../common/paths.js";
1
+ import { loadWorkspaceContext } from "../../agent-resources.js";
5
2
  import { requireThat } from "../../../common/validation.js";
6
3
  import { isMcpWorkerTool } from "../../../model/acp.js";
7
- export async function dshResources(ctx, _agent, root, role, check, coordinatorPrompt = "history-coordinator.md") {
8
- const read = () => Promise.all([agentText(role, root, coordinatorPrompt), readFile(join(resourceRoot, "prompts/workspace.md"), "utf8")]);
9
- const [text, workspace] = await read();
4
+ export async function dshResources(ctx, _agent, root, role, check, coordinatorPrompt = "history-coordinator.md", readWorkerTemplates) {
5
+ const read = () => loadWorkspaceContext({
6
+ host: "dsh", root, role, coordinatorPrompt, ...(readWorkerTemplates ? { readWorkerTemplates } : {}),
7
+ });
8
+ const context = await read();
10
9
  check();
11
- ctx.systemPrompt.section({ name: "pbot:role", order: 1, text, interpolate: false });
12
- ctx.systemPrompt.section({ name: "pbot:workspace", order: 2, text: workspace, interpolate: false });
10
+ ctx.systemPrompt.section({ name: "pbot:role", order: 1, text: context.role, interpolate: false });
11
+ ctx.systemPrompt.section({ name: "pbot:workspace", order: 2, text: context.workspace, interpolate: false });
13
12
  ctx.systemPrompt.context({
14
13
  name: "pbot:environment", order: 300, required: true, interpolate: false,
15
- text: JSON.stringify({ host: "dsh", workspaceRoot: root, resourceRoot }),
14
+ text: JSON.stringify(context.environment),
16
15
  });
17
16
  ctx.on("system-prompt/assemble", async (_assembly, _context, next) => {
18
17
  check();
19
- const [roleText, workspaceText] = await read();
18
+ const current = await read();
20
19
  check();
21
20
  const assembly = await next();
22
21
  return {
23
22
  ...assembly,
24
- sections: assembly.sections.map(section => section.name === "pbot:role" ? { ...section, text: roleText }
25
- : section.name === "pbot:workspace" ? { ...section, text: workspaceText } : section),
23
+ sections: assembly.sections.map(section => section.name === "pbot:role" ? { ...section, text: current.role }
24
+ : section.name === "pbot:workspace" ? { ...section, text: current.workspace } : section),
26
25
  };
27
26
  });
28
27
  }
@@ -17,14 +17,11 @@ export function parsePromptEvent(value) {
17
17
  if (typeof value.agent_id === "string")
18
18
  return { kind: "ignore" };
19
19
  requireThat(typeof value.cwd === "string", "插件 hook 缺少工作目录。");
20
- if (name === "Stop")
20
+ if (name !== "SessionStart")
21
21
  return { kind: "record-history", cwd: value.cwd, raw: value };
22
- if (name === "SessionStart") {
23
- if (value.source === "resume" || value.source === "compact")
24
- return { kind: "ignore" };
25
- return { kind: "inject-context", role: "coordinator", isSessionStart: true, noticesOnly: true, cwd: value.cwd, raw: value };
26
- }
27
- return { kind: "inject-context", role: "coordinator", cwd: value.cwd, raw: value };
22
+ if (value.source === "resume" || value.source === "compact")
23
+ return { kind: "ignore" };
24
+ return { kind: "inject-context", role: "coordinator", isSessionStart: true, cwd: value.cwd, raw: value };
28
25
  }
29
26
  export const promptHooks = {
30
27
  async extractHistory(event) {
@@ -0,0 +1,21 @@
1
+ export interface WorkerTemplate {
2
+ id: string;
3
+ name: string;
4
+ description: string;
5
+ create: {
6
+ backend: string;
7
+ workspace: string;
8
+ model?: string;
9
+ thinking?: string;
10
+ };
11
+ }
12
+ export interface WorkerTemplateError {
13
+ id: string;
14
+ message: string;
15
+ }
16
+ export interface WorkerTemplateCatalog {
17
+ templates: WorkerTemplate[];
18
+ errors: WorkerTemplateError[];
19
+ error?: string;
20
+ }
21
+ export type ReadWorkerTemplates = (root: string) => Promise<WorkerTemplateCatalog>;
@@ -0,0 +1 @@
1
+ export {};
@@ -4,13 +4,13 @@
4
4
  "command": "sh",
5
5
  "args": [
6
6
  "-c",
7
- "if pbot --at-least 0.3.3 </dev/null >/dev/null 2>&1; then exec pbot \"$@\"; fi\nexec npx --yes --ignore-scripts --prefer-offline personal-bot@0.4.0 \"$@\"",
7
+ "if pbot --at-least 0.3.3 </dev/null >/dev/null 2>&1; then exec pbot \"$@\"; fi\nexec npx --yes --ignore-scripts --prefer-offline personal-bot@0.4.2 \"$@\"",
8
8
  "pbot",
9
9
  "mcp"
10
10
  ],
11
11
  "env": {
12
12
  "PBOT_HOST": "qoder",
13
- "PBOT_PLUGIN_VERSION": "0.4.0"
13
+ "PBOT_PLUGIN_VERSION": "0.4.2"
14
14
  }
15
15
  }
16
16
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "personal-bot",
3
- "version": "0.4.0",
4
- "description": "Personal Bot workspace context and cross-harness workers.",
3
+ "version": "0.4.2",
4
+ "description": "Organize workspace files, search past conversations, use shared MCP tools, and delegate tasks to other assistants.",
5
5
  "skills": "./skills/",
6
6
  "mcpServers": "./.mcp.json"
7
7
  }
@@ -5,7 +5,7 @@
5
5
  "hooks": [
6
6
  {
7
7
  "type": "command",
8
- "command": "PBOT_PLUGIN_VERSION=0.4.0 sh -c 'if pbot --at-least 0.3.3 </dev/null >/dev/null 2>&1; then exec pbot \"$@\"; fi\nexec npx --yes --ignore-scripts --prefer-offline personal-bot@0.4.0 \"$@\"' pbot plugin qoder hook",
8
+ "command": "PBOT_PLUGIN_VERSION=0.4.2 sh -c 'if pbot --at-least 0.3.3 </dev/null >/dev/null 2>&1; then exec pbot \"$@\"; fi\nexec npx --yes --ignore-scripts --prefer-offline personal-bot@0.4.2 \"$@\"' pbot plugin qoder hook",
9
9
  "timeout": 120
10
10
  }
11
11
  ]
@@ -16,7 +16,7 @@
16
16
  "hooks": [
17
17
  {
18
18
  "type": "command",
19
- "command": "PBOT_PLUGIN_VERSION=0.4.0 sh -c 'if pbot --at-least 0.3.3 </dev/null >/dev/null 2>&1; then exec pbot \"$@\"; fi\nexec npx --yes --ignore-scripts --prefer-offline personal-bot@0.4.0 \"$@\"' pbot plugin qoder hook",
19
+ "command": "PBOT_PLUGIN_VERSION=0.4.2 sh -c 'if pbot --at-least 0.3.3 </dev/null >/dev/null 2>&1; then exec pbot \"$@\"; fi\nexec npx --yes --ignore-scripts --prefer-offline personal-bot@0.4.2 \"$@\"' pbot plugin qoder hook",
20
20
  "timeout": 120
21
21
  }
22
22
  ]
@@ -27,7 +27,7 @@
27
27
  "hooks": [
28
28
  {
29
29
  "type": "command",
30
- "command": "PBOT_PLUGIN_VERSION=0.4.0 sh -c 'if pbot --at-least 0.3.3 </dev/null >/dev/null 2>&1; then exec pbot \"$@\"; fi\nexec npx --yes --ignore-scripts --prefer-offline personal-bot@0.4.0 \"$@\"' pbot plugin qoder hook",
30
+ "command": "PBOT_PLUGIN_VERSION=0.4.2 sh -c 'if pbot --at-least 0.3.3 </dev/null >/dev/null 2>&1; then exec pbot \"$@\"; fi\nexec npx --yes --ignore-scripts --prefer-offline personal-bot@0.4.2 \"$@\"' pbot plugin qoder hook",
31
31
  "timeout": 120
32
32
  }
33
33
  ]
@@ -1,9 +1,17 @@
1
1
  ---
2
2
  name: pbot
3
- description: 初始化 Personal Bot 工作区、查看状态、搜索归档或生成历史摘要。
3
+ description: 初始化或检查 Personal Bot 工作区,检索、汇总或迁移历史归档。
4
4
  disable-model-invocation: true
5
5
  ---
6
6
 
7
- `--workspace` 传入当前会话的 `workspaceRoot`(工作区未启用时使用当前工作区根目录)。省略子命令时使用 `status`。可执行 `init`、`status`、`history status|list|summary|migrate|search|read`,保留用户指定的维度、模型和筛选参数。
7
+ 用当前会话的工作区根目录替换 `<workspaceRoot>`。无参数时执行 `status`。用户要求初始化时执行 `init`,启用工作区并补建缺失的资料目录和根 `AGENTS.md`。
8
8
 
9
- 若 `pbot --at-least 0.4.0` 返回 0,运行 `pbot <子命令> --workspace "<workspaceRoot>"`;否则运行 `npx --yes personal-bot@0.4.0 <子命令> --workspace "<workspaceRoot>"`。返回实际结果。
9
+ 会话给出 `resourceRoot` 时,用随包 CLI 执行所选命令。查看状态可运行
10
+
11
+ ```sh
12
+ node "<resourceRoot>/../lib/extension/cli.js" status --workspace "<workspaceRoot>"
13
+ ```
14
+
15
+ 没有该路径时,若 `pbot --at-least 0.4.2` 成功,用 `pbot` 替换上例的 `node ".../cli.js"`,否则用 `npx --yes --ignore-scripts personal-bot@0.4.2`。
16
+
17
+ 历史操作将 `status` 替换为 `history` 和用户指定的子命令、参数。`history summary` 更新各维度,`history summary monthly` 汇总已有会话摘要。迁移预览用 `history migrate --dry-run`,其他用法见 `history --help`。
@@ -89,11 +89,11 @@ export class AgentService {
89
89
  }
90
90
  const target = input.requestId ? pending.find(item => item.requestId === input.requestId) : pending[0];
91
91
  requireThat(target, input.requestId
92
- ? "没有待回复的请求:" + input.requestId + ";用 worker_discover 查看 pendingRequests。"
92
+ ? `没有待回复的请求 ${input.requestId}。用 worker_discover 查询 target="workers"、workerId="${id}" 的当前请求。`
93
93
  : "当前没有待回复的请求。");
94
94
  this.files.ensureSubdirectory(id, "interactions");
95
95
  if (target.kind === "permission") {
96
- requireThat(input.content === undefined, "权限请求不使用 content;请用 action(accept / decline / cancel)或指定 optionId。");
96
+ requireThat(input.content === undefined, "请移除 content。权限请求用 action 回复,选择具体权限范围时加上 optionId。");
97
97
  let resolved = null;
98
98
  if (input.action === "cancel") {
99
99
  requireThat(input.optionId === undefined, "action 为 cancel 时不能同时指定 optionId。");
@@ -45,7 +45,7 @@ function formatSessionSummaries(summaries) {
45
45
  export const monthlySummaryDimension = {
46
46
  id: "monthly",
47
47
  title: "月度历史汇总",
48
- description: "按自然月(UTC YYYY/MM)归纳当月单会话摘要,提炼月度主题、关键决定与产出,支持逐层下钻。",
48
+ description: "按会话开始的 UTC 月份汇总会话摘要,可从月度结果查回各会话。",
49
49
  requiresMonthlyLayout: true,
50
50
  plan(_raws, existing, options = {}) {
51
51
  const force = Boolean(options.force);
@@ -32,7 +32,7 @@ function isStrictUnchangedPrefix(existing, ordered) {
32
32
  export const sessionSummaryDimension = {
33
33
  id: "session",
34
34
  title: "会话任务摘要",
35
- description: "按单个会话提炼任务目标、关键决定、结果与未决事项,支持去重跳过与增量滚动更新。",
35
+ description: "汇总单次会话的目标、决定、结果和未决事项。",
36
36
  plan(raws, existing, options = {}) {
37
37
  const force = Boolean(options.force);
38
38
  const tasks = [];
@@ -95,9 +95,12 @@ export const sessionSummaryDimension = {
95
95
  ...heading,
96
96
  `【已有摘要(${task.existing.from} — ${task.existing.to})】\n${task.existing.text}`,
97
97
  `【新增对话】\n${formatExchanges(task.addedExchanges)}`,
98
- "在已有摘要基础上合并新增对话,输出更新后的完整摘要:保留仍有效的事实,用新决定覆盖旧决定,去重并保持简洁。",
99
98
  ].join("\n\n");
100
- return { system, prompt, maxTokens: 2048 };
99
+ return {
100
+ system: system + "\n合并已有摘要与新增对话,输出完整摘要。保留仍有效的事实,用后续明确的决定更新相应结论。",
101
+ prompt,
102
+ maxTokens: 2048,
103
+ };
101
104
  }
102
105
  const prompt = [
103
106
  ...heading,
@@ -67,9 +67,9 @@ function evaluateSummaryReminder(raws, allSummaries, pendingCount, options = {})
67
67
  return undefined;
68
68
  const rawAgeDays = Math.floor((nowMs - oldestRawMs) / dayMs);
69
69
  const daysSinceLastSummary = latestSummaryMs === undefined ? undefined : Math.floor((nowMs - latestSummaryMs) / dayMs);
70
- const message = daysSinceLastSummary === undefined
71
- ? `历史原文已累计 ${rawAgeDays} 天(待摘要 ${pendingCount} 项),尚未触发过摘要整理;可在终端运行 pbot history summary 生成摘要(Pi/dsh 可用 /pbot history summary)。`
72
- : `历史原文已累计 ${rawAgeDays} 天,且已 ${daysSinceLastSummary} 天未触发摘要整理(待摘要 ${pendingCount} 项);可在终端运行 pbot history summary 更新摘要(Pi/dsh 可用 /pbot history summary)。`;
70
+ const lastUpdate = daysSinceLastSummary === undefined ? "尚无摘要" : `上次更新摘要在 ${daysSinceLastSummary} 天前`;
71
+ const message = `工作区已积累 ${rawAgeDays} 天的历史,${lastUpdate},${pendingCount} 项待摘要。` +
72
+ "可在工作区根目录运行 pbot history summary,或在 Pi、dsh 会话中输入 /pbot history summary。";
73
73
  return {
74
74
  rawCount: raws.length,
75
75
  pendingCount,
@@ -0,0 +1,17 @@
1
+ import type { WorkerTemplateCatalog, WorkerTemplateError } from "../../model/worker-template.js";
2
+ export declare function readWorkerTemplates(root: string): Promise<WorkerTemplateCatalog>;
3
+ export declare function discoverWorkerTemplates(root: string): Promise<{
4
+ errors?: WorkerTemplateError[];
5
+ target: string;
6
+ templates: {
7
+ create: {
8
+ workspace: string;
9
+ backend: string;
10
+ model?: string;
11
+ thinking?: string;
12
+ };
13
+ id: string;
14
+ name: string;
15
+ description: string;
16
+ }[];
17
+ }>;
@@ -0,0 +1,88 @@
1
+ import { constants } from "node:fs";
2
+ import { open } from "node:fs/promises";
3
+ import { homedir } from "node:os";
4
+ import { join, resolve } from "node:path";
5
+ import { object } from "../../common/json.js";
6
+ const templateIdPattern = /^[a-z0-9][a-z0-9-]{0,63}$/;
7
+ const templateFields = ["name", "description", "create"];
8
+ const createFields = ["backend", "workspace", "model", "thinking"];
9
+ function validString(value) {
10
+ return typeof value === "string" && value.trim().length > 0 && !value.includes("\0");
11
+ }
12
+ function parseTemplate(id, entry) {
13
+ if (!templateIdPattern.test(id))
14
+ return { id, message: "模板标识无效。" };
15
+ if (!object(entry) || Object.keys(entry).some(key => !templateFields.includes(key))) {
16
+ return { id, message: "模板设置无效。" };
17
+ }
18
+ const { name = id, description, create } = entry;
19
+ if (!validString(name))
20
+ return { id, message: "模板名称无效。" };
21
+ if (!validString(description))
22
+ return { id, message: "模板缺少有效的职责说明。" };
23
+ if (!object(create) || Object.keys(create).some(key => !createFields.includes(key))) {
24
+ return { id, message: "助手的启动设置无效。" };
25
+ }
26
+ if (!validString(create.backend))
27
+ return { id, message: "模板缺少有效的助手标识。" };
28
+ const options = { backend: create.backend, workspace: "." };
29
+ for (const key of ["workspace", "model", "thinking"]) {
30
+ const value = create[key];
31
+ if (value === undefined)
32
+ continue;
33
+ if (!validString(value))
34
+ return { id, message: "助手的启动设置无效。" };
35
+ options[key] = value;
36
+ }
37
+ return { id, name, description, create: options };
38
+ }
39
+ export async function readWorkerTemplates(root) {
40
+ const path = join(root, ".pbot", "worker", "templates.json");
41
+ const catalog = { templates: [], errors: [] };
42
+ const unavailable = { ...catalog, error: "当前工作区的助手模板不可用。" };
43
+ let entries;
44
+ try {
45
+ const file = await open(path, constants.O_RDONLY | constants.O_NONBLOCK);
46
+ try {
47
+ if (!(await file.stat()).isFile())
48
+ return unavailable;
49
+ entries = JSON.parse(await file.readFile("utf8"));
50
+ }
51
+ finally {
52
+ await file.close();
53
+ }
54
+ }
55
+ catch (error) {
56
+ if (error.code === "ENOENT")
57
+ return catalog;
58
+ return unavailable;
59
+ }
60
+ if (!object(entries))
61
+ return unavailable;
62
+ for (const id of Object.keys(entries).sort()) {
63
+ const result = parseTemplate(id, entries[id]);
64
+ if ("message" in result)
65
+ catalog.errors.push(result);
66
+ else
67
+ catalog.templates.push(result);
68
+ }
69
+ return catalog;
70
+ }
71
+ function resolveTemplateWorkspace(root, workspace) {
72
+ if (workspace === "~" || workspace.startsWith("~/"))
73
+ return join(homedir(), workspace.slice(2));
74
+ return resolve(root, workspace);
75
+ }
76
+ export async function discoverWorkerTemplates(root) {
77
+ const { templates, errors, error } = await readWorkerTemplates(root);
78
+ if (error)
79
+ throw new Error(error);
80
+ return {
81
+ target: "templates",
82
+ templates: templates.map(template => ({
83
+ ...template,
84
+ create: { ...template.create, workspace: resolveTemplateWorkspace(root, template.create.workspace) },
85
+ })),
86
+ ...(errors.length ? { errors } : {}),
87
+ };
88
+ }
@@ -296,8 +296,9 @@ export class HistoryFiles {
296
296
  rawCount,
297
297
  summaryCount,
298
298
  total,
299
- message: `检测到 ${total} 个未迁移的平铺历史文件(raw ${rawCount},summaries ${summaryCount});当前为年月目录布局(history.layout: monthly),未迁移文件不会被读取。` +
300
- `请在终端运行 pbot history migrate 整理到 YYYY/MM/ 目录(Pi/dsh 可用 /pbot history migrate),或在 .pbot/config.json 中设置 "history": { "layout": "flat" } 切回平铺布局。`,
299
+ message: `当前按年月读取历史,平铺目录中的 ${rawCount} 份原文和 ${summaryCount} 份摘要尚未纳入检索。` +
300
+ "可在工作区根目录用 pbot history migrate --dry-run 预览,用 pbot history migrate 执行(Pi、dsh 可用 /pbot history migrate)。" +
301
+ '要继续使用平铺目录,可在 .pbot/config.json 中设置 "history": { "layout": "flat" }。',
301
302
  };
302
303
  }
303
304
  listFlatRawFiles() {
@@ -70,7 +70,7 @@ export declare const historyResultSchema: Type.TObject<{
70
70
  }>>;
71
71
  warnings: Type.TArray<Type.TString>;
72
72
  }>;
73
- export declare const historyDescription: string;
73
+ export declare const historyDescription = "\u67E5\u627E\u5DE5\u4F5C\u533A\u5404\u5BBF\u4E3B\u5F52\u6863\u7684\u95EE\u7B54\u548C\u6458\u8981\u3002\u6CBF\u5B50\u8282\u70B9\u53EF\u4ECE\u6708\u5EA6\u6C47\u603B\u67E5\u5230\u4F1A\u8BDD\u6458\u8981\u548C\u539F\u59CB\u95EE\u7B54\u3002";
74
74
  export declare const historyParameters: Type.TObject<{
75
75
  action: Type.TUnion<[Type.TLiteral<"search">, Type.TLiteral<"read">]>;
76
76
  host: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
@@ -9,7 +9,7 @@ const node = Type.Object({
9
9
  host: identifier,
10
10
  id: Type.String(),
11
11
  kind: Type.Union([Type.Literal("session"), Type.Literal("exchange"), Type.Literal("summary")], {
12
- description: "session=会话根;summary=维度摘要;exchange=单轮问答原文。",
12
+ description: "session 为会话,summary 为摘要,exchange 为单轮问答原文。",
13
13
  }),
14
14
  dimension: Type.Optional(identifier),
15
15
  sessionId: Type.String(),
@@ -18,7 +18,7 @@ const node = Type.Object({
18
18
  from: Type.String(),
19
19
  to: Type.String(),
20
20
  ready: Type.Boolean({ description: "正文或摘要是否已生成。" }),
21
- completed: Type.Boolean({ description: "该对话或问答是否正常结束(false 表示中断或未完)。" }),
21
+ completed: Type.Boolean({ description: "false 表示会话或问答中断或未完成。" }),
22
22
  });
23
23
  export const historyResultSchema = Type.Object({
24
24
  matches: Type.Optional(Type.Array(Type.Object({
@@ -46,23 +46,21 @@ export const historyResultSchema = Type.Object({
46
46
  })),
47
47
  warnings: Type.Array(Type.String()),
48
48
  });
49
- export const historyDescription = "查询当前工作区跨宿主历史问答与摘要归档。" +
50
- "search 按不区分大小写的连续关键词匹配原文与摘要,省略 query 列出各会话或指定维度摘要;" +
51
- "read 按 id 读取正文与上下级(可从 monthly 汇总下钻至 session 摘要和 exchange 原文),用 nextOffset 与 nextChildrenOffset 分页续读。";
49
+ export const historyDescription = "查找工作区各宿主归档的问答和摘要。沿子节点可从月度汇总查到会话摘要和原始问答。";
52
50
  export const historyParameters = Type.Object({
53
51
  action: Type.Union([Type.Literal("search"), Type.Literal("read")], {
54
- description: "search 搜索或列表;read 按 id 读取正文与上下级。仅读取对应动作参数,其余忽略。",
52
+ description: "search 搜索或列出记录,read 按 id 读取正文和上下级。",
55
53
  }),
56
- host: nullable(Type.String({ pattern: historyIdentifierPattern.source, description: "来源宿主筛选(如 pi、dsh、claude、antigravity、codex、qoder);省略查全部。" })),
57
- dimension: nullable(Type.String({ pattern: historyIdentifierPattern.source, description: "仅 search:raw 仅原文,或指定摘要维度(如 monthly、session);省略查全部。" })),
58
- query: nullable(Type.String({ description: "仅 search:连续关键词(不区分大小写);省略列会话或指定维度摘要。" })),
59
- sessionId: nullable(Type.String({ description: "仅 search:限定在指定原始会话 ID 内搜索。" })),
60
- from: nullable(Type.String({ description: "仅 search:ISO 日期或时间下界。" })),
61
- to: nullable(Type.String({ description: "仅 search:ISO 日期或时间上界。" })),
62
- id: nullable(Type.String({ description: "仅 read,必填:节点 id(来自 search 或上下级)。" })),
63
- offset: nullable(Type.Integer({ minimum: 0, description: "search 为结果偏移,read 为正文字符偏移;默认 0。" })),
64
- limit: nullable(Type.Integer({ minimum: 1, maximum: historyPageLimits.read.max, description: `search:返回条数(1–${historyPageLimits.search.max},默认 ${historyPageLimits.search.default});read:正文字符数(默认 ${historyPageLimits.read.default})。` })),
65
- childrenOffset: nullable(Type.Integer({ minimum: 0, description: "仅 read:子节点偏移,默认 0;续读传上次 nextChildrenOffset。" })),
54
+ host: nullable(Type.String({ pattern: historyIdentifierPattern.source, description: "来源宿主,如 pi 或 claude。可筛选搜索结果或区分重名节点。" })),
55
+ dimension: nullable(Type.String({ pattern: historyIdentifierPattern.source, description: "search 的范围。raw 为原始问答,session、monthly 等为摘要维度。关键词搜索默认查全部。" })),
56
+ query: nullable(Type.String({ description: "search 匹配连续文本,忽略大小写。省略时列会话,指定摘要维度则列该维度的摘要。" })),
57
+ sessionId: nullable(Type.String({ description: "search 按原始会话 ID 筛选。" })),
58
+ from: nullable(Type.String({ description: "search 时间区间起点(含),用 ISO 日期或时间。" })),
59
+ to: nullable(Type.String({ description: "search 时间区间终点(含),仅填日期表示该日 UTC 零点。" })),
60
+ id: nullable(Type.String({ description: "read 必填。使用搜索结果、父节点或子节点的 id。" })),
61
+ offset: nullable(Type.Integer({ minimum: 0, description: "翻页传上页的 nextOffset。search 按条目,read 按正文字符,默认从 0 开始。" })),
62
+ limit: nullable(Type.Integer({ minimum: 1, maximum: historyPageLimits.read.max, description: `search 每页默认 ${historyPageLimits.search.default} 条,最多 ${historyPageLimits.search.max} 条。read 每页默认 ${historyPageLimits.read.default} 个字符。` })),
63
+ childrenOffset: nullable(Type.Integer({ minimum: 0, description: "read 的子节点起点,默认 0。翻页传上页的 nextChildrenOffset。" })),
66
64
  }, { additionalProperties: false });
67
65
  const valid = schema(historyParameters);
68
66
  export function historyInput(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "personal-bot",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,7 +11,7 @@
11
11
  "registry": "https://registry.npmjs.org/",
12
12
  "tag": "latest"
13
13
  },
14
- "description": "A personal assistant connecting knowledge, research, and action for Pi, DeepSeek Harness, Claude Code, and Antigravity.",
14
+ "description": "Organize workspace files, search past conversations, use shared MCP tools, and delegate tasks to other assistants.",
15
15
  "type": "module",
16
16
  "bin": {
17
17
  "pbot": "./bin/pbot.mjs"
@@ -1,7 +1,5 @@
1
1
  # 协调者
2
2
 
3
- 委派专家时写明目标、相关资料、约束和交付要求;涉及文件修改时明确修改范围,多人并行写入时划分文件责任。
3
+ 委派时明确交付物和修改范围。并行协作时,同一文件由一人修改。另请助手独立复核时,把资料和问题交给新会话。
4
4
 
5
- 由你汇总专家结果、整合正式资料并处理口径差异。需要独立复核时,另开专家会话并提供待查内容与具体问题。
6
-
7
- 失败或中断后说明已完成部分、剩余工作与阻碍;需要用户决定的事项由你汇总提出。
5
+ 由你整合结果。结论冲突时核对依据和口径,指出未决分歧。普通问答直接回复,可复用的结论和产物归入项目。
@@ -1,7 +1,5 @@
1
1
  # 通用专家
2
2
 
3
- 完成本次委派,使用相关资料和技能,交回结果、问题说明及产物路径;独立复核时自行核查并指出问题与不确定之处。
3
+ 完成主会话交给你的任务。复核时独立核查,在回复中给出结论、依据位置和未能确认的问题。委派要求改文件时,直接修改指定范围并交回产物路径。其余正式资料由主会话整合。
4
4
 
5
- 默认交回报告,由主会话整合正式资料;委派包含文件修改时直接修改并说明变更。
6
-
7
- 可自主排查工具和环境问题;受阻且需要主会话或用户协助时,交回已有结果与具体阻碍。不递归委派其他助手;需要额外协作者时向主会话建议。
5
+ 遇到工具或环境问题,先自行排查。需要协助或其他专家时,把已有结果、具体阻碍和所需帮助交回主会话,由主会话安排协作。
@@ -1,34 +1,17 @@
1
1
  ---
2
2
  name: pbot
3
- description: 初始化 Personal Bot 工作区、查看状态、搜索归档或生成历史摘要。
3
+ description: 初始化或检查 Personal Bot 工作区,检索、汇总或迁移历史归档。
4
4
  disable-model-invocation: true
5
5
  ---
6
6
 
7
- # Personal Bot 工作区
7
+ 用 `run_command` 从当前 Antigravity 工作区根目录执行用户选择的命令。将本技能路径末尾的 `/skills/pbot/SKILL.md` 去掉,即得 `<plugin-root>`。无参数时执行 `status`。
8
8
 
9
- 从当前 Antigravity 工作区根目录,通过 `run_command` 执行对应命令。`<plugin-root>` 为本 `SKILL.md` 路径向上两级目录(去掉尾部 `/skills/pbot/SKILL.md`)。
10
-
11
- ## 初始化与状态
12
-
13
- ```sh
14
- node "<plugin-root>/lib/plugin.js" antigravity init
15
- node "<plugin-root>/lib/plugin.js" antigravity status
16
- ```
17
-
18
- `init` 补建资料目录与根 `AGENTS.md` 并启用工作区,`status` 查看工作区及配置状态;省略参数时执行 `status`。
19
-
20
- ## 历史管理与检索
21
-
22
- `--workspace` 传入当前会话的 `workspaceRoot`(工作区未启用时使用当前工作区根目录)。支持 `history status|list|summary|migrate|search|read`,保留用户指定参数(迁移预览加 `--dry-run`):
23
-
24
- ```sh
25
- pbot history summary --workspace "<workspaceRoot>"
26
- ```
27
-
28
- 未安装全局 `pbot` 或版本不匹配时,直接运行随插件打包的 CLI:
9
+ - 查看状态用 `node "<plugin-root>/lib/plugin.js" antigravity status`。
10
+ - 初始化用同一命令将 `status` 换成 `init`。它会启用工作区,补建缺失的资料目录和根 `AGENTS.md`。
11
+ - 历史操作使用随插件提供的 CLI,保留用户指定的参数。`summary` 更新各维度,`summary monthly` 汇总已有会话摘要。迁移预览用 `migrate --dry-run`,其他用法见 `history --help`。
29
12
 
30
13
  ```sh
31
14
  node "<plugin-root>/lib/extension/cli.js" history summary --workspace "<workspaceRoot>"
32
15
  ```
33
16
 
34
- 返回命令的实际结果和需要处理的错误。
17
+ `<workspaceRoot>` 取当前会话的工作区根目录。