personal-bot 0.3.0 → 0.3.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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/bin/pbot-pi-acp.mjs +27 -11
- package/bin/pbot.mjs +1 -1
- package/docs/README.md +1 -1
- package/docs/architecture/design.md +23 -10
- package/docs/architecture/extensibility.md +20 -18
- package/docs/architecture/model-context.md +2 -2
- package/docs/architecture/principles.md +4 -3
- package/docs/guides/capabilities.md +3 -3
- package/docs/guides/history.md +50 -16
- package/docs/guides/workspace-configuration.md +31 -6
- package/docs/hosts/antigravity.md +2 -0
- package/docs/hosts/claude-code.md +1 -1
- package/docs/hosts/dsh.md +1 -1
- package/docs/hosts/pi.md +1 -1
- package/hooks/hooks.json +3 -0
- package/lib/antigravity-plugin/hooks.json +7 -0
- package/lib/antigravity-plugin/lib/claude.js +2 -2
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +156 -11
- package/lib/antigravity-plugin/lib/extension/{plugin-runtime.d.ts → hosts/plugin-runtime.d.ts} +2 -2
- package/lib/antigravity-plugin/lib/extension/{plugin-runtime.js → hosts/plugin-runtime.js} +34 -8
- package/lib/antigravity-plugin/lib/extension/mcp.js +1113 -78
- package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +1 -0
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +5 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.d.ts +6 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.js +171 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/{claude.d.ts → claude/adapter.d.ts} +1 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/{claude.js → claude/adapter.js} +32 -4
- package/lib/antigravity-plugin/lib/integrations/hosts/{registry.js → plugin-registry.js} +2 -2
- package/lib/antigravity-plugin/lib/model/history.d.ts +169 -0
- package/lib/antigravity-plugin/lib/model/plugin-host.d.ts +26 -0
- package/lib/antigravity-plugin/lib/model/workspace-config.d.ts +25 -0
- package/lib/antigravity-plugin/lib/plugin.js +2 -2
- package/lib/antigravity-plugin/lib/services/history/history-capture.d.ts +4 -0
- package/lib/antigravity-plugin/lib/services/history/history-capture.js +86 -0
- package/lib/antigravity-plugin/lib/services/history/history-index.d.ts +17 -0
- package/lib/antigravity-plugin/lib/services/history/history-index.js +112 -0
- package/lib/antigravity-plugin/lib/services/history/history-migrate.d.ts +12 -0
- package/lib/antigravity-plugin/lib/services/history/history-migrate.js +88 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.d.ts +7 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.js +121 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.d.ts +7 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.js +124 -0
- package/lib/antigravity-plugin/lib/services/history/summary-registry.d.ts +7 -0
- package/lib/antigravity-plugin/lib/services/history/summary-registry.js +36 -0
- package/lib/antigravity-plugin/lib/services/history/summary-runner.d.ts +37 -0
- package/lib/antigravity-plugin/lib/services/history/summary-runner.js +301 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.d.ts +5 -1
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.js +75 -4
- package/lib/antigravity-plugin/lib/storage/file-access.d.ts +2 -0
- package/lib/antigravity-plugin/lib/storage/file-access.js +26 -0
- package/lib/antigravity-plugin/lib/storage/history-files.d.ts +54 -0
- package/lib/antigravity-plugin/lib/storage/history-files.js +467 -0
- package/lib/antigravity-plugin/lib/storage/history-format.d.ts +6 -0
- package/lib/antigravity-plugin/lib/storage/history-format.js +62 -0
- package/lib/antigravity-plugin/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +1 -1
- package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +22 -12
- package/lib/claude.js +2 -2
- package/lib/client.js +21 -11
- package/lib/dsh.js +4 -4
- package/lib/extension/{acp-member.d.ts → acp/member.d.ts} +5 -5
- package/lib/extension/{acp-member.js → acp/member.js} +6 -6
- package/lib/extension/acp/worker.d.ts +1 -0
- package/lib/extension/acp/worker.js +384 -0
- package/lib/extension/acp-worker.js +156 -11
- package/lib/extension/{dsh → hosts/dsh}/acp-member.js +8 -8
- package/lib/extension/hosts/dsh/command.js +92 -0
- package/lib/extension/{dsh → hosts/dsh}/files.js +3 -3
- package/lib/extension/hosts/dsh/history.d.ts +4 -0
- package/lib/extension/hosts/dsh/history.js +62 -0
- package/lib/extension/{dsh → hosts/dsh}/management.d.ts +1 -1
- package/lib/extension/{dsh → hosts/dsh}/management.js +12 -10
- package/lib/extension/{dsh → hosts/dsh}/workspace.d.ts +3 -9
- package/lib/extension/{dsh → hosts/dsh}/workspace.js +32 -70
- package/lib/extension/{plugin-runtime.d.ts → hosts/plugin-runtime.d.ts} +2 -2
- package/lib/extension/{plugin-runtime.js → hosts/plugin-runtime.js} +34 -8
- package/lib/extension/{mcp-bridge.d.ts → mcp/bridge.d.ts} +1 -1
- package/lib/extension/{mcp-bridge.js → mcp/bridge.js} +4 -4
- package/lib/extension/{mcp-workers.d.ts → mcp/workers.d.ts} +222 -2
- package/lib/extension/{mcp-workers.js → mcp/workers.js} +229 -63
- package/lib/extension/mcp.js +1113 -78
- package/lib/extension/{setup-cli.js → setup/cli.js} +9 -9
- package/lib/integrations/acp/connection.d.ts +11 -10
- package/lib/integrations/acp/connection.js +6 -0
- package/lib/integrations/acp/harnesses/claude.js +1 -1
- package/lib/integrations/acp/harnesses/dsh.js +1 -1
- package/lib/integrations/acp/history-summary.d.ts +17 -0
- package/lib/integrations/acp/history-summary.js +100 -0
- package/lib/integrations/agent-resources.d.ts +1 -0
- package/lib/integrations/agent-resources.js +5 -1
- package/lib/integrations/hosts/antigravity/adapter.d.ts +6 -0
- package/lib/integrations/hosts/antigravity/adapter.js +171 -0
- package/lib/integrations/hosts/{claude.d.ts → claude/adapter.d.ts} +1 -1
- package/lib/integrations/hosts/{claude.js → claude/adapter.js} +32 -4
- package/lib/integrations/{dsh → hosts/dsh}/mcp.d.ts +1 -1
- package/lib/integrations/{dsh → hosts/dsh}/resources.d.ts +1 -1
- package/lib/integrations/{dsh → hosts/dsh}/resources.js +4 -4
- package/lib/integrations/{dsh → hosts/dsh}/schema.js +1 -1
- package/lib/integrations/{dsh → hosts/dsh}/skills.js +1 -1
- package/lib/integrations/hosts/{registry.js → plugin-registry.js} +2 -2
- package/lib/integrations/installation/pi-setup.js +1 -1
- package/lib/model/history.d.ts +133 -34
- package/lib/model/plugin-host.d.ts +26 -0
- package/lib/model/workspace-config.d.ts +25 -0
- package/lib/plugin.js +2 -2
- package/lib/services/agents/agent-run.d.ts +1 -1
- package/lib/services/history/history-capture.d.ts +4 -0
- package/lib/services/history/history-capture.js +86 -0
- package/lib/services/history/history-index.d.ts +16 -7
- package/lib/services/history/history-index.js +48 -70
- package/lib/services/history/history-migrate.d.ts +12 -0
- package/lib/services/history/history-migrate.js +88 -0
- package/lib/services/history/history-query.d.ts +51 -0
- package/lib/services/history/history-query.js +371 -0
- package/lib/services/history/summary-command.d.ts +20 -0
- package/lib/services/history/summary-command.js +68 -0
- package/lib/services/history/summary-dimensions/monthly.d.ts +7 -0
- package/lib/services/history/summary-dimensions/monthly.js +121 -0
- package/lib/services/history/summary-dimensions/session.d.ts +7 -0
- package/lib/services/history/summary-dimensions/session.js +124 -0
- package/lib/services/history/summary-registry.d.ts +7 -0
- package/lib/services/history/summary-registry.js +36 -0
- package/lib/services/history/summary-runner.d.ts +37 -0
- package/lib/services/history/summary-runner.js +301 -0
- package/lib/services/workspace/workspace-config.d.ts +5 -1
- package/lib/services/workspace/workspace-config.js +75 -4
- package/lib/storage/history-files.d.ts +45 -9
- package/lib/storage/history-files.js +373 -247
- package/lib/storage/history-format.d.ts +3 -12
- package/lib/storage/history-format.js +26 -50
- package/lib/tools/history/actions.d.ts +3 -68
- package/lib/tools/history/actions.js +7 -5
- package/lib/tools/history/contract.d.ts +14 -7
- package/lib/tools/history/contract.js +58 -18
- package/lib/tools/history/dsh-tool.d.ts +1 -2
- package/lib/tools/history/dsh-tool.js +11 -5
- package/lib/ui/dsh/management.js +18 -5
- package/package.json +1 -1
- package/resources/prompts/history-coordinator.md +1 -1
- package/resources/prompts/history-monthly-summary.md +13 -0
- package/resources/prompts/history-summary.md +10 -4
- package/resources/skills/provider-connections/SKILL.md +22 -12
- package/src/claude.ts +2 -2
- package/src/dsh.ts +4 -4
- package/src/extension/{acp-member.ts → acp/member.ts} +7 -7
- package/src/extension/{acp-worker.ts → acp/worker.ts} +131 -17
- package/src/extension/{dsh → hosts/dsh}/acp-member.ts +9 -9
- package/src/extension/hosts/dsh/command.ts +92 -0
- package/src/extension/{dsh → hosts/dsh}/files.ts +3 -3
- package/src/extension/hosts/dsh/history.ts +67 -0
- package/src/extension/{dsh → hosts/dsh}/management.ts +11 -9
- package/src/extension/{dsh → hosts/dsh}/workspace.ts +31 -50
- package/src/extension/{pi-acp-member.ts → hosts/pi/acp-member.ts} +9 -9
- package/src/extension/hosts/pi/command.ts +158 -0
- package/src/extension/{events.ts → hosts/pi/events.ts} +14 -4
- package/src/extension/hosts/pi/history.ts +45 -0
- package/src/extension/{lifecycle.ts → hosts/pi/lifecycle.ts} +7 -11
- package/src/extension/{plugin-runtime.ts → hosts/plugin-runtime.ts} +29 -9
- package/src/extension/{mcp-bridge.ts → mcp/bridge.ts} +5 -5
- package/src/extension/{mcp-workers.ts → mcp/workers.ts} +237 -64
- package/src/extension/{setup-cli.ts → setup/cli.ts} +11 -11
- package/src/integrations/acp/connection.ts +6 -0
- package/src/integrations/acp/harnesses/claude.ts +1 -1
- package/src/integrations/acp/harnesses/dsh.ts +1 -1
- package/src/integrations/acp/history-summary.ts +108 -0
- package/src/integrations/agent-resources.ts +6 -0
- package/src/integrations/hosts/antigravity/adapter.ts +161 -0
- package/src/integrations/hosts/{claude.ts → claude/adapter.ts} +28 -5
- package/src/integrations/{dsh → hosts/dsh}/mcp.ts +1 -1
- package/src/integrations/{dsh → hosts/dsh}/resources.ts +5 -5
- package/src/integrations/{dsh → hosts/dsh}/schema.ts +1 -1
- package/src/integrations/{dsh → hosts/dsh}/session.ts +2 -2
- package/src/integrations/{dsh → hosts/dsh}/skills.ts +1 -1
- package/src/integrations/{pi → hosts/pi}/mcp.ts +1 -1
- package/src/integrations/{pi → hosts/pi}/skills.ts +1 -1
- package/src/integrations/hosts/{registry.ts → plugin-registry.ts} +2 -2
- package/src/integrations/installation/pi-setup.ts +1 -1
- package/src/mcp.ts +1 -1
- package/src/model/history.ts +151 -26
- package/src/model/plugin-host.ts +26 -2
- package/src/model/workspace-config.ts +30 -0
- package/src/pbot.ts +13 -22
- package/src/plugin.ts +2 -2
- package/src/services/history/history-capture.ts +83 -0
- package/src/services/history/history-index.ts +48 -62
- package/src/services/history/history-migrate.ts +89 -0
- package/src/services/history/history-query.ts +415 -0
- package/src/services/history/summary-command.ts +69 -0
- package/src/services/history/summary-dimensions/monthly.ts +139 -0
- package/src/services/history/summary-dimensions/session.ts +149 -0
- package/src/services/history/summary-registry.ts +44 -0
- package/src/services/history/summary-runner.ts +352 -0
- package/src/services/workspace/workspace-config.ts +93 -5
- package/src/storage/history-files.ts +408 -188
- package/src/storage/history-format.ts +46 -60
- package/src/tools/history/actions.ts +8 -6
- package/src/tools/history/contract.ts +65 -20
- package/src/tools/history/dsh-tool.ts +17 -8
- package/src/tools/history/pi-tool.ts +21 -0
- package/src/tools/register.ts +3 -4
- package/src/ui/dsh/management.ts +27 -11
- package/src/ui/{confirmation.ts → pi/confirmation.ts} +1 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.d.ts +0 -4
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.js +0 -79
- package/lib/extension/dsh/command.js +0 -50
- package/lib/extension/dsh/history.d.ts +0 -15
- package/lib/extension/dsh/history.js +0 -87
- package/lib/integrations/dsh/history-summary.d.ts +0 -11
- package/lib/integrations/dsh/history-summary.js +0 -36
- package/lib/integrations/dsh/history.d.ts +0 -16
- package/lib/integrations/dsh/history.js +0 -167
- package/lib/integrations/history-summary.d.ts +0 -4
- package/lib/integrations/history-summary.js +0 -32
- package/lib/integrations/hosts/antigravity.d.ts +0 -4
- package/lib/integrations/hosts/antigravity.js +0 -79
- package/lib/services/history/history-service.d.ts +0 -106
- package/lib/services/history/history-service.js +0 -242
- package/lib/storage/acp-history.d.ts +0 -10
- package/lib/storage/acp-history.js +0 -57
- package/src/extension/command.ts +0 -76
- package/src/extension/dsh/command.ts +0 -54
- package/src/extension/dsh/history.ts +0 -74
- package/src/extension/history.ts +0 -26
- package/src/integrations/dsh/history-summary.ts +0 -39
- package/src/integrations/dsh/history.ts +0 -84
- package/src/integrations/history-summary.ts +0 -30
- package/src/integrations/hosts/antigravity.ts +0 -83
- package/src/integrations/pi/history.ts +0 -99
- package/src/services/history/history-service.ts +0 -195
- package/src/storage/acp-history.ts +0 -49
- package/src/tools/history/tool.ts +0 -19
- /package/lib/antigravity-plugin/lib/integrations/hosts/{registry.d.ts → plugin-registry.d.ts} +0 -0
- /package/lib/{extension/acp-worker.d.ts → antigravity-plugin/lib/model/history.js} +0 -0
- /package/lib/extension/{dsh → hosts/dsh}/acp-member.d.ts +0 -0
- /package/lib/extension/{dsh → hosts/dsh}/command.d.ts +0 -0
- /package/lib/extension/{dsh → hosts/dsh}/files.d.ts +0 -0
- /package/lib/extension/{setup-guard.js → setup/guard.js} +0 -0
- /package/lib/integrations/acp/{claude.d.ts → claude-settings.d.ts} +0 -0
- /package/lib/integrations/acp/{claude.js → claude-settings.js} +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/mcp.js +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/messages.d.ts +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/messages.js +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/root-agents.d.ts +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/root-agents.js +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/schema.d.ts +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/skills.d.ts +0 -0
- /package/lib/integrations/hosts/{registry.d.ts → plugin-registry.d.ts} +0 -0
- /package/src/extension/{setup-guard.ts → setup/guard.ts} +0 -0
- /package/src/integrations/acp/{claude.ts → claude-settings.ts} +0 -0
- /package/src/integrations/{dsh → hosts/dsh}/messages.ts +0 -0
- /package/src/integrations/{dsh → hosts/dsh}/root-agents.ts +0 -0
- /package/src/integrations/{pi → hosts/pi}/agent-tools.ts +0 -0
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"plugins": [
|
|
7
7
|
{
|
|
8
8
|
"name": "personal-bot",
|
|
9
|
-
"version": "0.3.
|
|
9
|
+
"version": "0.3.2",
|
|
10
10
|
"description": "Workspace materials, skills, and cross-harness MCP worker delegation.",
|
|
11
11
|
"source": {
|
|
12
12
|
"source": "npm",
|
|
13
13
|
"package": "personal-bot",
|
|
14
|
-
"version": "0.3.
|
|
14
|
+
"version": "0.3.2"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
]
|
package/README.md
CHANGED
|
@@ -94,7 +94,7 @@ Supports built-in presets (`pi`, `dsh`, `claude`, `antigravity`, `codex`) and ar
|
|
|
94
94
|
|
|
95
95
|
## Development
|
|
96
96
|
|
|
97
|
-
Current release: **0.3.
|
|
97
|
+
Current release: **0.3.2**. Full development uses Linux/macOS and Node.js 24.9+:
|
|
98
98
|
|
|
99
99
|
```bash
|
|
100
100
|
npm ci --ignore-scripts
|
package/README.zh-CN.md
CHANGED
package/bin/pbot-pi-acp.mjs
CHANGED
|
@@ -1,19 +1,35 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawn } from "node:child_process";
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
|
-
import { join } from "node:path";
|
|
5
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
|
|
7
|
+
if (!process.env.PBOT_ACP_PI_COMMAND) throw new Error("Missing Personal Bot Pi ACP launch context");
|
|
8
|
+
|
|
9
|
+
let args;
|
|
10
|
+
if (process.env.PBOT_SUMMARY_WORKER === "1") {
|
|
11
|
+
// Minimal pure-text Pi runtime for history summarization: no tools, extensions, skills, templates, or AGENTS.md.
|
|
12
|
+
args = [
|
|
13
|
+
...process.argv.slice(2),
|
|
14
|
+
"--no-tools",
|
|
15
|
+
"--no-extensions",
|
|
16
|
+
"--no-skills",
|
|
17
|
+
"--no-prompt-templates",
|
|
18
|
+
"--no-context-files",
|
|
19
|
+
];
|
|
20
|
+
} else {
|
|
21
|
+
// pi-acp supplies RPC arguments. Add the managed member's native resource options.
|
|
22
|
+
const directory = process.env.PBOT_SUBAGENT_DIR;
|
|
23
|
+
if (!directory) throw new Error("Missing Personal Bot Pi ACP launch context");
|
|
24
|
+
const { options } = JSON.parse(readFileSync(join(directory, "descriptor.json"), "utf8"));
|
|
25
|
+
args = [...process.argv.slice(2), "--extension", fileURLToPath(new URL("../src/extension/hosts/pi/acp-member.ts", import.meta.url))];
|
|
26
|
+
if (options.noExtensions !== false) args.push("--no-extensions", "--extension", "builtin:mcp", "--extension", "builtin:codemode", "--extension", "builtin:tool-search");
|
|
27
|
+
if (options.noSkills) args.push("--no-skills");
|
|
28
|
+
if (options.noPromptTemplates) args.push("--no-prompt-templates");
|
|
29
|
+
if (options.noContextFiles) args.push("--no-context-files");
|
|
30
|
+
if (options.tools) args.push("--tools", options.tools.join(","));
|
|
31
|
+
}
|
|
6
32
|
|
|
7
|
-
// pi-acp supplies RPC arguments. Add the managed member's native resource options.
|
|
8
|
-
const directory = process.env.PBOT_SUBAGENT_DIR;
|
|
9
|
-
if (!directory || !process.env.PBOT_ACP_PI_COMMAND) throw new Error("Missing Personal Bot Pi ACP launch context");
|
|
10
|
-
const { options } = JSON.parse(readFileSync(join(directory, "descriptor.json"), "utf8"));
|
|
11
|
-
const args = [...process.argv.slice(2), "--extension", fileURLToPath(new URL("../src/extension/pi-acp-member.ts", import.meta.url))];
|
|
12
|
-
if (options.noExtensions !== false) args.push("--no-extensions", "--extension", "builtin:mcp", "--extension", "builtin:codemode", "--extension", "builtin:tool-search");
|
|
13
|
-
if (options.noSkills) args.push("--no-skills");
|
|
14
|
-
if (options.noPromptTemplates) args.push("--no-prompt-templates");
|
|
15
|
-
if (options.noContextFiles) args.push("--no-context-files");
|
|
16
|
-
if (options.tools) args.push("--tools", options.tools.join(","));
|
|
17
33
|
const child = spawn(process.env.PBOT_ACP_PI_COMMAND, args, { stdio: "inherit", env: process.env });
|
|
18
34
|
child.on("error", error => { console.error(error.message); process.exitCode = 1; });
|
|
19
35
|
for (const termination of ["SIGINT", "SIGTERM"]) process.on(termination, () => child.kill(termination));
|
package/bin/pbot.mjs
CHANGED
package/docs/README.md
CHANGED
|
@@ -17,7 +17,7 @@ Personal Bot 文档按使用场景与职责分为四类,根目录 [README.zh-C
|
|
|
17
17
|
| --- | --- |
|
|
18
18
|
| [工作区配置](guides/workspace-configuration.md) | 共用 `.pbot/config.json` 启用规则、自定义 ACP Harness(含可选 `env`)与配置生效方式 |
|
|
19
19
|
| [跨 Harness 专家调度](guides/cross-harness-workers.md) | 统一 MCP `worker_*` 工具集、与宿主原生 subagent 互补边界、ACP 生命周期与交互转发 |
|
|
20
|
-
| [历史对话](guides/history.md) | Pi/dsh `pbot_history`
|
|
20
|
+
| [历史对话](guides/history.md) | 全宿主统一事件采集、MCP `history_search`/`history_read`、Pi/dsh `pbot_history` 与跨宿主分层摘要 |
|
|
21
21
|
| [工具与执行能力](guides/capabilities.md) | 原生 CLI/MCP、Python 计算参考([通用](../resources/references/compute.md) / [金融](../resources/references/compute-finance.md))与可选 Task Conductor |
|
|
22
22
|
|
|
23
23
|
## 架构与扩展设计(`docs/architecture/`)
|
|
@@ -22,36 +22,49 @@ Claude / Antigravity / 任意插件宿主 hooks、CLI 与薄 stdio MCP
|
|
|
22
22
|
| `src/pbot.ts` / `src/dsh.ts` | Pi 与 dsh Host 装配(工作区生命周期、历史工具、原生 MCP 挂载) |
|
|
23
23
|
| `src/plugin.ts` / `src/claude.ts` | 通用插件宿主 CLI/hook 入口(查 `PluginHostRegistry`)与 Claude 兼容入口 |
|
|
24
24
|
| `src/mcp.ts` | 独立 stdio MCP 服务入口,暴露 6 个 `worker_*` 工具 |
|
|
25
|
-
| `src/extension/` |
|
|
26
|
-
| `src/integrations/` |
|
|
25
|
+
| `src/extension/` | 按运行域划分的运行时编排:`hosts/`(`pi/`、`dsh/` 与共享 `plugin-runtime.ts`)、`mcp/`(`workers.ts`、`bridge.ts`)、`acp/`(`worker.ts`、`member.ts`)、`setup/`(`cli.ts`、`guard.ts`) |
|
|
26
|
+
| `src/integrations/` | 按外部集成域划分的适配器:`hosts/`(各宿主平级目录 `pi/`、`dsh/`、`claude/`、`antigravity/` 及 `plugin-registry.ts`)、`acp/`(协议、`harnesses/` 与独立摘要执行器 `history-summary.ts`)、`installation/`(安装桥接),以及跨宿主辅助(`agent-resources.ts`) |
|
|
27
27
|
| `src/services/` | 宿主无关业务规则(`agents/`、`workspace/`、`history/`、`installation/`) |
|
|
28
28
|
| `src/model/` | 纯数据类型与窄能力契约(`plugin-host.ts`、`acp.ts`、`agent.ts`、`history.ts`、`workspace-config.ts`),不含实现或宿主 SDK 类型 |
|
|
29
29
|
| `src/storage/` | 原子 JSON、ACP worker 控制记录与历史归档存储 |
|
|
30
|
-
| `src/tools/` | `pbot_history`
|
|
31
|
-
| `src/ui/` |
|
|
30
|
+
| `src/tools/` | `pbot_history` 契约与对称宿主注册(`history/pi-tool.ts`、`history/dsh-tool.ts`) |
|
|
31
|
+
| `src/ui/` | 宿主专属 UI(`pi/confirmation.ts`、`dsh/` Web 工作区与历史面板)及共享展示/安装器交互(`presentation.ts`、`setup.ts`) |
|
|
32
32
|
| `src/common/` | JSON、校验、Ajv Schema、文件、路径与版本辅助 |
|
|
33
33
|
| `resources/` | 模型可见提示词、角色、技能、参考资料与模板 |
|
|
34
34
|
|
|
35
|
+
### 目录归属与命名规范(扩展必循)
|
|
36
|
+
|
|
37
|
+
为保持顶层目录维度一致并确保 `dependency-cruiser` 静态隔离生效,新增宿主、扩展或功能模块统一遵循以下规则:
|
|
38
|
+
|
|
39
|
+
1. **所有宿主统一收拢在 `hosts/` 下**:
|
|
40
|
+
- **进程内重 SDK 宿主(如 `pi`、`dsh`)**:按 `<host>/` 子目录对称存放——`src/extension/hosts/<host>/`、`src/integrations/hosts/<host>/`、`src/ui/<host>/` 与 `src/tools/<domain>/<host>-tool.ts`,并在 `.dependency-cruiser.cjs` 中声明跨宿主 SDK 隔离规则。
|
|
41
|
+
- **无 SDK Hook 插件宿主(如 `claude`、`antigravity` 及新接入 IDE/CLI)**:在 `src/integrations/hosts/<host>/adapter.ts` 实现 `PluginHostAdapter` 并在 `src/integrations/hosts/plugin-registry.ts` 注册,共用 `src/extension/hosts/plugin-runtime.ts`,零宿主 SDK 依赖。
|
|
42
|
+
2. **跨宿主协议与运行域**:
|
|
43
|
+
- **ACP Harness**:实现 `AcpHarnessAdapter` 放入 `src/integrations/acp/harnesses/<name>.ts` 并在 `src/integrations/acp/registry.ts` 注册;运行时在 `src/extension/acp/`;辅助模块避免与适配器重名(如 `acp/claude-settings.ts`)。
|
|
44
|
+
- **MCP 服务与桥接**:统一放在 `src/extension/mcp/`。
|
|
45
|
+
- **安装器与独立 CLI**:运行时在 `src/extension/setup/`,外部环境桥接在 `src/integrations/installation/`。
|
|
46
|
+
3. **宿主无关业务与共享模块**:业务规则放 `src/services/<domain>/`,纯数据契约放 `src/model/`,存储放 `src/storage/`,跨宿主 UI/展示辅助放 `src/ui/` 顶层。
|
|
47
|
+
|
|
35
48
|
所有单向依赖与宿主 SDK 隔离规则由 `.dependency-cruiser.cjs` 静态强制。`common/validation` 保持零第三方依赖,`common/schema`(Ajv)仅由 Pi/dsh 历史工具与管理查询显式引入。
|
|
36
49
|
|
|
37
50
|
## 宿主生命周期与交互
|
|
38
51
|
|
|
39
52
|
所有宿主读取同一工作区根目录 `.pbot/config.json`,缺失、停用或损坏时保持休眠,不向上级目录继承:
|
|
40
53
|
|
|
41
|
-
- **Pi**:`session_start` 读取配置,启用后注册 `pbot_history`、通过 `pi.registerMcpServer("pbot", ...)` 挂载 `lib/extension/mcp.js`(注入 `PBOT_WORKSPACE_ROOT`、`PBOT_MCP_AGENT_DIR` 与当前 `PBOT_MCP_SESSION_ID`),并在 `before_agent_start` 刷新工作区上下文。`/pbot`
|
|
42
|
-
- **dsh**:按根 Agent 的原始 `cwd` 读取配置,启用后注册技能、上下文、工作区外写保护、`pbot_history`
|
|
43
|
-
- **轻插件宿主(Claude Code、Antigravity 及后续扩展)**:由 `plugin-runtime.ts` 通过 `PluginHostAdapter` 处理无状态 command hook
|
|
54
|
+
- **Pi**:`session_start` 读取配置,启用后注册 `pbot_history`、通过 `pi.registerMcpServer("pbot", ...)` 挂载 `lib/extension/mcp.js`(注入 `PBOT_WORKSPACE_ROOT`、`PBOT_MCP_AGENT_DIR` 与当前 `PBOT_MCP_SESSION_ID`),并在 `before_agent_start` 刷新工作区上下文。`/pbot` 保留 `init`、`status`、`history` 与 `worker`(共享同一会话归属),工作区外写入触发安全确认队列。关闭或重载时自动注销 MCP 服务并清理资源。
|
|
55
|
+
- **dsh**:按根 Agent 的原始 `cwd` 读取配置,启用后注册技能、上下文、工作区外写保护、`pbot_history` 与根会话原始问答采集,并通过 `@deepseek-ai/dsh-mcp-client` 挂载同一 `lib/extension/mcp.js`(暴露 `mcp__pbot__worker_*`)。Web 工作台仅保留**工作区**与**历史**两页,经原生 Typert Remote(`snapshot`、`history`)查询,不增设 HTTP 服务;聊天命令为 `/pbot`、`status`、`init`、`history`、`worker`。
|
|
56
|
+
- **轻插件宿主(Claude Code、Antigravity 及后续扩展)**:由 `plugin-runtime.ts` 通过 `PluginHostAdapter` 处理无状态 command hook(上下文注入、技能门控与 `raw` 历史采集)及 `init`/`status` CLI,跨 Harness 调度与只读跨宿主历史查询由宿主挂载 `lib/extension/mcp.js` 完成。不设自定义面板,也不拦截宿主原生 subagent。
|
|
44
57
|
|
|
45
58
|
## 文件存储
|
|
46
59
|
|
|
47
60
|
| 位置 | 内容与所有者 |
|
|
48
61
|
| --- | --- |
|
|
49
|
-
| `<workspace>/.pbot/config.json` | 全宿主共用的启用开关、可选模块开关(`features: { prompts, skills, mcp }`)与开放 ACP Harness 配置 |
|
|
62
|
+
| `<workspace>/.pbot/config.json` | 全宿主共用的启用开关、可选模块开关(`features: { prompts, skills, mcp, history }`)与开放 ACP Harness 配置 |
|
|
50
63
|
| `<workspace>/.pbot/mcp.json` | 全宿主与 ACP worker 共享的工作区 MCP 服务清单(stdio / Streamable HTTP,支持 `${ENV_VAR}` 展开) |
|
|
51
64
|
| `<workspace>/.agents/skills/<name>/SKILL.md` | 全宿主共享的工作区自有技能(原生支持目录的宿主直接发现,其余宿主与 ACP worker 按需注入元数据索引) |
|
|
52
65
|
| `<workspace>/AGENTS.md`、`areas/`、`projects/`、`knowledge/`、`providers/`、`scratch/`、`agents/` | 用户工作区资料(`init` 只补缺、不覆盖) |
|
|
53
|
-
| `<workspace>/.pbot/history/raw
|
|
54
|
-
| `<workspace>/.pbot/history/
|
|
66
|
+
| `<workspace>/.pbot/history/raw/[<YYYY>/<MM>/]<id>.json` | 全宿主(Pi、dsh、Claude Code、Antigravity 等)原始问答与已知分支(默认按 UTC `YYYY/MM/` 分层,可配置 `history.layout: "flat"` 切回平铺;各自只写本宿主来源) |
|
|
67
|
+
| `<workspace>/.pbot/history/summaries/<dimension>/[<YYYY>/<MM>/]<id>.json` | 按维度派生的摘要产物(内置 `session` 与 `monthly` 月度汇总,由 `SummaryRunner` 按 `.write-summary-<dimension>` 锁并发生成,携带来源指纹支持去重与增量更新,可独立重建,损坏不影响原始问答查询) |
|
|
55
68
|
| `~/.pbot/subagents/<id>/`(或 `PBOT_MCP_AGENT_DIR` / `PLUGIN_DATA/subagents`) | MCP `worker_*` 的控制记录(`descriptor.json`、`launch.json`、`acp-session.json`、`acp-process.json`、`acp-model.json`、`inbox/`、`completions/`、`reports/`、`permissions/`、`elicitations/`) |
|
|
56
69
|
|
|
57
70
|
- `atomic-json` 先校验对象再写入临时文件并原子替换,拒绝符号链接、路径越界与特殊文件;短目录锁(`.control` / `.write-<host>`)串行化控制写操作。
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
```text
|
|
8
8
|
src/plugin.ts (动态查表,无硬编码宿主名)
|
|
9
9
|
↓
|
|
10
|
-
src/extension/plugin-runtime.ts (唯一核心逻辑:init/status/hook 引擎)
|
|
10
|
+
src/extension/hosts/plugin-runtime.ts (唯一核心逻辑:init/status/hook 引擎)
|
|
11
11
|
├── src/services/workspace/*
|
|
12
12
|
├── src/integrations/agent-resources.ts (按 adapter.coordinatorPrompt 组装)
|
|
13
|
-
└── PluginHostRegistry (src/integrations/hosts/registry.ts)
|
|
14
|
-
├── claudeAdapter (src/integrations/hosts/claude.ts)
|
|
15
|
-
├── antigravityAdapter (src/integrations/hosts/antigravity.ts)
|
|
13
|
+
└── PluginHostRegistry (src/integrations/hosts/plugin-registry.ts)
|
|
14
|
+
├── claudeAdapter (src/integrations/hosts/claude/adapter.ts)
|
|
15
|
+
├── antigravityAdapter (src/integrations/hosts/antigravity/adapter.ts)
|
|
16
16
|
└── <自定义宿主适配器> (通过 registerPluginHost 动态注册)
|
|
17
17
|
```
|
|
18
18
|
|
|
@@ -38,22 +38,24 @@ src/extension/plugin-runtime.ts (唯一核心逻辑:init/status/hook 引擎)
|
|
|
38
38
|
|
|
39
39
|
### 接入新插件宿主的步骤
|
|
40
40
|
|
|
41
|
-
1. 在 `src/integrations/hosts/<host
|
|
42
|
-
2. 在 `src/integrations/hosts/registry.ts` 注册该适配器(或由外部入口调用 `registerPluginHost(adapter)`)。
|
|
41
|
+
1. 在 `src/integrations/hosts/<host>/adapter.ts` 实现 `PluginHostAdapter`(禁止引入任何宿主 SDK)。
|
|
42
|
+
2. 在 `src/integrations/hosts/plugin-registry.ts` 注册该适配器(或由外部入口调用 `registerPluginHost(adapter)`)。
|
|
43
43
|
3. 在 `scripts/build-plugins.mjs` 的 `pluginTargets` 中声明对应清单与构建输出(挂载共享 `lib/extension/mcp.js` 与 `lib/plugin.js <host> hook`)。
|
|
44
|
-
4. 核心运行时(`plugin-runtime.ts`、`src/plugin.ts`、`agent-resources.ts`)无需任何修改。
|
|
44
|
+
4. 核心运行时(`src/extension/hosts/plugin-runtime.ts`、`src/plugin.ts`、`agent-resources.ts`)无需任何修改。
|
|
45
|
+
|
|
46
|
+
> 若接入的是**进程内重 SDK 宿主**(类似 Pi / dsh,而非无状态 hook 插件),则按对称目录规范放入 `src/extension/hosts/<host>/`、`src/integrations/hosts/<host>/`、`src/ui/<host>/` 与 `src/tools/<domain>/<host>-tool.ts`,并在 `.dependency-cruiser.cjs` 中补充跨宿主 SDK 隔离规则。
|
|
45
47
|
|
|
46
48
|
## 2. 可扩展 ACP Harness(`AcpHarnessRegistry`)
|
|
47
49
|
|
|
48
50
|
```text
|
|
49
|
-
MCP Server (src/extension/mcp
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
MCP Server (src/extension/mcp/workers.ts) -> AgentService -> AcpWorkerHost -> src/extension/acp/worker.ts
|
|
52
|
+
↓
|
|
53
|
+
AcpHarnessRegistry (src/integrations/acp/registry.ts)
|
|
54
|
+
├── genericAcpHarness (任意自定义 ACP v1 默认回退)
|
|
55
|
+
├── standardAcpPresets (antigravity, codex, ...)
|
|
56
|
+
├── piAcpHarness (src/integrations/acp/harnesses/pi.ts)
|
|
57
|
+
├── dshAcpHarness (src/integrations/acp/harnesses/dsh.ts)
|
|
58
|
+
└── claudeAcpHarness (src/integrations/acp/harnesses/claude.ts)
|
|
57
59
|
```
|
|
58
60
|
|
|
59
61
|
### `AcpHarnessAdapter` 契约(`src/model/acp.ts`)
|
|
@@ -68,11 +70,11 @@ MCP Server (src/extension/mcp-workers.ts) -> AgentService -> AcpWorkerHost -> ac
|
|
|
68
70
|
### 两种零侵入扩展方式
|
|
69
71
|
|
|
70
72
|
1. **用户级零代码接入**:在工作区 `.pbot/config.json` 的 `acp` 字段声明任意 `{ "command", "args", "env?" }`。`resolveAcpHarness(id)` 自动回退到 `createGenericAcpHarness(id)`:支持标准 ACP v1 协议、自动按对端 `sessionCapabilities.systemPrompt` 决定 append 还是首轮前置工作区上下文,并按流式 `agent_message_chunk` 收集最终报告。
|
|
71
|
-
2. **开发者级特化适配**:新增 `src/integrations/acp/harnesses/<name>.ts` 实现 `AcpHarnessAdapter` 并调用 `registerAcpHarness` 注册。`acp
|
|
73
|
+
2. **开发者级特化适配**:新增 `src/integrations/acp/harnesses/<name>.ts` 实现 `AcpHarnessAdapter` 并调用 `registerAcpHarness` 注册。`src/extension/acp/worker.ts`、`connection.ts`、`launch.ts`、`model-selection.ts` 与 `src/extension/mcp/workers.ts` 均零修改。
|
|
72
74
|
|
|
73
|
-
## 3. 薄 stdio MCP 桥接(`worker_*`)
|
|
75
|
+
## 3. 薄 stdio MCP 桥接(`worker_*`、`workspace_mcp_*`、`history_*`)
|
|
74
76
|
|
|
75
|
-
- `src/extension/mcp
|
|
77
|
+
- `src/extension/mcp/workers.ts` 与 `src/mcp.ts` 使用 Node 内置模块实现 JSON-RPC 2.0 stdio MCP 服务(不依赖 `@modelcontextprotocol/sdk`),封装 `AgentService` + `AcpWorkerHost`、`WorkspaceMcpBridge`(`src/extension/mcp/bridge.ts`)与只读跨宿主历史查询。
|
|
76
78
|
- 每次调用动态读取工作区 `.pbot/config.json` 并刷新 `acp` 映射,新增自定义 Harness 即改即生效。
|
|
77
79
|
- 支持 `PBOT_MCP_SESSION_ID` 与 `PBOT_MCP_AGENT_DIR`,使 Pi/dsh 的 `/pbot worker` 命令与自动挂载的 MCP 进程共享同一会话归属。
|
|
78
80
|
- `lib/extension/mcp.js` 与 `lib/extension/acp-worker.js` 通过 `esbuild` 独立打包,确保插件缓存目录在无 `node_modules` 环境下稳定运行。
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
|
|
28
28
|
## ACP Worker 上下文
|
|
29
29
|
|
|
30
|
-
- **受管成员(`pi`、`dsh`)**:通过 `pi
|
|
31
|
-
- **标准 ACP v1 目标(`claude`、`antigravity`、`codex` 及自定义 Harness)**:由 `acp
|
|
30
|
+
- **受管成员(`pi`、`dsh`)**:通过 `src/extension/hosts/pi/acp-member.ts` / `src/extension/hosts/dsh/acp-member.ts` 加载公共约定、`general-purpose` 职责、工作区 `agents/general-purpose.md` 与 `{ host, workspaceRoot, resourceRoot }`,禁止递归调用 `worker_*` / `pbot_history`。
|
|
31
|
+
- **标准 ACP v1 目标(`claude`、`antigravity`、`codex` 及自定义 Harness)**:由 `src/extension/acp/worker.ts` 拼装同一上下文;若对端声明 `sessionCapabilities.systemPrompt` 则在建会话时 append,否则在首轮消息前前置一次(后续轮次不重复)。
|
|
@@ -15,12 +15,13 @@ Personal Bot 不绑定单一宿主,所有能力按两条正交主线组织:
|
|
|
15
15
|
|
|
16
16
|
## 可扩展、运行时不感知
|
|
17
17
|
|
|
18
|
-
-
|
|
19
|
-
- **ACP Harness 扩展**:任意标准 ACP v1 程序在 `.pbot/config.json` 的 `acp` 字段声明 `{ command, args, env? }` 即可零代码接入;需要特殊会话参数或模型解析的 Harness 实现 `AcpHarnessAdapter` 并注册到 `AcpHarnessRegistry`,`acp
|
|
18
|
+
- **插件宿主扩展**:新增轻插件宿主只需在 `src/integrations/hosts/<host>/adapter.ts` 实现 `PluginHostAdapter` 并注册到 `PluginHostRegistry`(及在 `scripts/build-plugins.mjs` 追加构建目标),`src/extension/hosts/plugin-runtime.ts`、`src/plugin.ts` 与 `agent-resources.ts` 不感知具体宿主标识。
|
|
19
|
+
- **ACP Harness 扩展**:任意标准 ACP v1 程序在 `.pbot/config.json` 的 `acp` 字段声明 `{ command, args, env? }` 即可零代码接入;需要特殊会话参数或模型解析的 Harness 在 `src/integrations/acp/harnesses/<name>.ts` 实现 `AcpHarnessAdapter` 并注册到 `AcpHarnessRegistry`,`src/extension/acp/worker.ts`、`connection.ts`、`launch.ts` 与 `model-selection.ts` 不包含任何特定 Harness 分支。
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## 保持单向依赖与对称目录维度
|
|
22
22
|
|
|
23
23
|
- 顶层分层:`tools / extension / ui → services → storage / model`;`integrations` 只做协议适配不调用业务服务,`services` 不依赖宿主 SDK 或接入层。所有边界由 `.dependency-cruiser.cjs` 静态检查。
|
|
24
|
+
- 顶层目录按单一维度组织:`src/extension/` 按运行域(`hosts/`、`mcp/`、`acp/`、`setup/`),`src/integrations/` 按外部集成域(`hosts/`、`acp/`、`installation/`);`hosts/` 下所有具体宿主平级建目录,禁止将具体宿主与领域类别混放或将单宿主文件散落到父目录顶层(详规见[技术设计](design.md))。
|
|
24
25
|
- 资源的创建、状态变更和释放由同一责任主体管理。工具与服务绑定工作区实例,关闭后旧调用失效。
|
|
25
26
|
|
|
26
27
|
## 区分两类文档方法论
|
|
@@ -7,8 +7,8 @@ Personal Bot 复用各宿主的原生 CLI、MCP、认证与权限体系,不额
|
|
|
7
7
|
| 内容 | 所有者 |
|
|
8
8
|
| --- | --- |
|
|
9
9
|
| CLI 参数、校验、认证 | 原生命令与 profile |
|
|
10
|
-
| 工作区共享 MCP(stdio / HTTP + 环境变量) | 工作区 `.pbot/mcp.json
|
|
11
|
-
| 宿主原生 MCP
|
|
10
|
+
| 工作区共享 MCP(stdio / HTTP + 环境变量) | 工作区 `.pbot/mcp.json`(Pi/dsh 直接原生挂载;其余宿主经 `workspace_mcp_*` 桥接,二选一不重复暴露;ACP worker 自动透传) |
|
|
11
|
+
| 宿主原生 MCP(全局工具、原生插件/通知、交互式 OAuth 或独占本地资源) | 当前宿主的原生 MCP(与 `.pbot/mcp.json` 单点归属、互不重复注册) |
|
|
12
12
|
| 工作区共享技能 | 工作区 `.agents/skills/<name>/SKILL.md`(Pi/dsh/Antigravity/Codex 原生发现;Claude Code 与通用 ACP worker 自动注入元数据索引) |
|
|
13
13
|
| 数据口径、项目约定与使用经验 | 工作区 `providers/<id>/GUIDE.md` |
|
|
14
14
|
| 跨 Harness 专家委派 | 统一 stdio MCP 服务(`worker_*` 工具集) |
|
|
@@ -17,7 +17,7 @@ Personal Bot 复用各宿主的原生 CLI、MCP、认证与权限体系,不额
|
|
|
17
17
|
|
|
18
18
|
## 外部 CLI 与 MCP
|
|
19
19
|
|
|
20
|
-
- **工作区共享 MCP
|
|
20
|
+
- **工作区共享 MCP(跨宿主业务工具)**:使用 `pbot mcp add|remove|list` 维护 `.pbot/mcp.json`,凭据用 `${ENV_VAR}` 引用。Pi/dsh 启用 `features.mcp`(默认)时直接原生挂载(不再重复暴露 `workspace_mcp_*`);其余宿主通过 `workspace_mcp_discover` / `workspace_mcp_call` 动态调用(修改即生效),ACP worker 自动继承。
|
|
21
21
|
- **宿主原生 MCP(交互式 OAuth 或全局服务)**:
|
|
22
22
|
- **Pi**:项目级外部 MCP 使用 `pi mcp add --local <server> ...`(写入 `.pi/mcp.json`),`/mcp` 查看来源与状态。
|
|
23
23
|
- **dsh**:使用原生 `@deepseek-ai/dsh-mcp-client` 与 profile 配置管理外部 MCP。
|
package/docs/guides/history.md
CHANGED
|
@@ -1,25 +1,59 @@
|
|
|
1
1
|
# 历史对话
|
|
2
2
|
|
|
3
|
-
Pi
|
|
3
|
+
所有宿主(Pi、dsh、Claude Code、Antigravity 及自定义插件宿主)共用工作区 `.pbot/history/` 归档原始问答与多维度摘要:
|
|
4
|
+
|
|
5
|
+
- **统一 RAW 采集**:各宿主在主会话输入与回合结束时直接写入 `.pbot/history/raw/`(默认按会话开始时间 UTC `YYYY/MM/` 分层),工具调用、推理与子会话均不写入历史。
|
|
6
|
+
- **独立 Worker 摘要生成**:通过 Pi / dsh 的 `/pbot history summary` 命令主动扫描 `.pbot/history/raw/`,为每个待摘要项启动**独立的临时 ACP worker**(默认 `backend: "pi"`,使用 Pi 当前默认模型;带 `PBOT_SUBAGENT_RUN_ID` 隔离,绝不写回 `raw/`,不挂载工作区 MCP/技能,跑完即销毁)。可在 `.pbot/config.json` 的 `summary` 字段或命令行参数中切换 `backend`、`model`、`thinking` 与 `concurrency`。
|
|
7
|
+
- **独立只读搜索**:Pi 与 dsh 提供原生 `pbot_history` 工具(dsh 另提供 Web 工作台“历史”页与 `/pbot history {"action":...}` 命令);Claude Code、Antigravity 与其他插件宿主通过 `pbot` MCP 提供的 `history_search` / `history_read` 检索全部宿主的原始问答与各维度摘要。
|
|
8
|
+
- **开关控制**:在 `.pbot/config.json` 中设置 `features.history: false` 可关闭当前工作区的历史采集、摘要生成与查询入口(默认 `true`)。
|
|
9
|
+
- **启动提醒**:会话启动时自动探测历史目录;当存在未迁移的旧平铺文件(`monthly` 布局下)或原始历史累计满 7 天且近 7 天未更新摘要时,给出一次性轻量提示。
|
|
10
|
+
|
|
11
|
+
## 命令接口(Pi 与 dsh 对称)
|
|
12
|
+
|
|
13
|
+
| 命令 | 作用 |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| `/pbot history summary [维度...] [--force] [--backend <acp>] [--model <model>] [--thinking <level>]` | 按当前布局扫描历史并执行摘要整理;默认增量去重(未变化跳过、新增对话滚动更新),`--force` 强制全量重刷;`monthly` 布局下自动依次生成 `session` 与 `monthly` 汇总 |
|
|
16
|
+
| `/pbot history migrate [--dry-run]` | 显式将旧平铺 `.pbot/history/raw/*.json` 与 `summaries/<dimension>/*.json` 按 UTC 开始时间直接移动至 `YYYY/MM/`(或 `unknown/`),不保留副本、不修改配置文件、不覆盖目标冲突文件 |
|
|
17
|
+
| `/pbot history status` | 查看当前历史布局、原始会话数、各维度已就绪 / 待处理统计与未迁移提示 |
|
|
18
|
+
| `/pbot history list` | 列出当前布局下可用的摘要维度与说明 |
|
|
19
|
+
| `/pbot history {"action":"search"\|"read",...}` | 直接按查询契约检索或读取历史节点 |
|
|
20
|
+
|
|
21
|
+
## 可选历史与摘要配置(`.pbot/config.json`)
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"enabled": true,
|
|
26
|
+
"history": {
|
|
27
|
+
"layout": "monthly"
|
|
28
|
+
},
|
|
29
|
+
"summary": {
|
|
30
|
+
"backend": "pi",
|
|
31
|
+
"model": "provider/model",
|
|
32
|
+
"thinking": "low",
|
|
33
|
+
"concurrency": 3
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- `history.layout` 可选 `"monthly"`(默认,按 UTC 年月分层)或 `"flat"`(平铺目录);省略时默认为 `"monthly"`。读写与检索严格按当前配置布局执行,不混读两种布局。
|
|
39
|
+
- 已有平铺工作区在未迁移前运行于默认 `monthly` 布局时,启动提醒、`/pbot status` / `/pbot history status` 与 `pbot_history` 的 `warnings` 会提示运行 `/pbot history migrate` 或切回 `history.layout: "flat"`。
|
|
40
|
+
- `summary` 全部字段可选:省略 `summary` 或 `summary.backend` 时默认使用 `pi`;省略 `summary.model` 时使用目标 harness 的默认模型。
|
|
4
41
|
|
|
5
42
|
## 查询契约
|
|
6
43
|
|
|
7
|
-
|
|
|
44
|
+
| 能力 | 原生 `pbot_history` / MCP 工具 | 可选字段与默认值 |
|
|
8
45
|
| --- | --- | --- |
|
|
9
|
-
| `search`
|
|
10
|
-
| `read`
|
|
46
|
+
| 搜索 / 列会话 | `action: "search"` / `history_search` | `host`(如 `pi`、`dsh`、`claude`、`antigravity`,省略查全部)、`dimension`(`raw` 仅原文,或具体摘要维度如 `monthly`、`session`,省略查全部)、`query`(连续文本,不区分大小写;省略列会话或指定维度摘要)、`sessionId`、`from`、`to`(含时区 ISO 时间)、`offset=0`、`limit=20`(1–50) |
|
|
47
|
+
| 读取节点 | `action: "read"` / `history_read`(必填 `id`) | `host`、`offset=0`、`limit=12000`(1–24000 UTF-16 单元)、`childrenOffset=0`(每页固定 20 个子节点) |
|
|
11
48
|
|
|
12
|
-
- `
|
|
13
|
-
-
|
|
49
|
+
- 搜索链路与写入/摘要生产完全隔离:关键词检索优先使用 `rg` 预过滤当前布局内的候选 JSON 文件(未安装 `rg` 或含特殊转义字符时自动回退到 Node 文本扫描),再对命中文件精确解析与分页。
|
|
50
|
+
- `read` 支持逐层下钻:月度汇总(`summary:monthly:<YYYY-MM>`)→ 单会话摘要(`summary:session:<rawId>`)→ 会话根(`<rawId>`)→ 单轮问答原文(`<rawId>:0:<entryId>`)。
|
|
14
51
|
|
|
15
|
-
##
|
|
52
|
+
## 存储布局与多维度扩展
|
|
16
53
|
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- 按分支每四个连续节点形成一层摘要并逐层合并;仅在正常主交互结束后的空闲阶段调用当前宿主模型后台补齐,新人工输入优先取消整理。
|
|
24
|
-
- 归档保存在工作区 `.pbot/history/`:`raw/<id>.json` 存原始问答与已知分支,`summary/<id>.json` 存派生分层摘要。摘要损坏或缺失不影响原始问答搜索与读取。
|
|
25
|
-
- 备份或迁移工作区前先停止活动写入,再整体复制 `.pbot/history/`。
|
|
54
|
+
- **默认年月分层(`history.layout: "monthly"`)**:
|
|
55
|
+
- `.pbot/history/raw/<YYYY>/<MM>/<id>.json`(缺失有效时间戳时落入 `raw/unknown/<id>.json`):全宿主原始问答与已知分支,固定按会话开始时间(最早 `from` 的 UTC 年月)落桶,后续跨月追加消息不移动目录。
|
|
56
|
+
- `.pbot/history/summaries/<dimension>/<YYYY>/<MM>/<id>.json`(兜底 `unknown/`):按维度存放的单会话级派生摘要产物(如 `session`);月度汇总维度按年分目录存放为 `.pbot/history/summaries/monthly/<YYYY>/<YYYY-MM>.json`。
|
|
57
|
+
- **平铺布局(`history.layout: "flat"`)**:
|
|
58
|
+
- `.pbot/history/raw/<id>.json` 与 `.pbot/history/summaries/<dimension>/<id>.json`;不启用 `monthly` 维度。
|
|
59
|
+
- 派生摘要按 `.write-summary-<dimension>` 短锁写入,记录来源指纹 `source.fingerprint` 以实现精确去重与增量更新,可随时删目录重算,损坏或缺失不影响原始问答查询;开发者可通过 `SummaryRegistry`(`registerSummaryDimension`)注册更多维度。
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
| Claude Code | `/personal-bot:pbot init`(或 `lib/claude.js init`) | `/personal-bot:pbot status` |
|
|
12
12
|
| Antigravity | `/pbot init`(或 `lib/plugin.js antigravity init`) | `/pbot status` |
|
|
13
13
|
|
|
14
|
-
`init` 先补建资料目录(`areas/`、`projects/`、`knowledge/`、`providers/`、`scratch/`、`agents/`)和缺失的根 `AGENTS.md`,再将 `.pbot/config.json` 中的 `enabled` 设为 `true
|
|
14
|
+
`init` 先补建资料目录(`areas/`、`projects/`、`knowledge/`、`providers/`、`scratch/`、`agents/`)和缺失的根 `AGENTS.md`,再将 `.pbot/config.json` 中的 `enabled` 设为 `true` 并显式写入 `features`(`prompts`、`skills`、`mcp`、`history`,未设置项默认 `true`)与 `summary`(`backend: "pi"`、`concurrency: 3`),保留已有资料、宿主自有文件(如 `CLAUDE.md`)、已设置的开关/摘要配置及其他未知配置字段;配置文件损坏时先报错而不覆写。
|
|
15
15
|
|
|
16
16
|
## 启用、模块开关(`features`)与停用规则
|
|
17
17
|
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"features": {
|
|
22
22
|
"prompts": true,
|
|
23
23
|
"skills": true,
|
|
24
|
-
"mcp": true
|
|
24
|
+
"mcp": true,
|
|
25
|
+
"history": true
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
```
|
|
@@ -32,10 +33,11 @@
|
|
|
32
33
|
| `features.prompts: false` | 关闭工作区提示词与角色上下文注入 |
|
|
33
34
|
| `features.skills: false` | 关闭工作区与内置技能注册、技能门控及 `.agents/skills/` 索引注入 |
|
|
34
35
|
| `features.mcp: false` | 关闭 `.pbot/mcp.json` 统一 MCP 挂载、`workspace_mcp_*` 桥接与 ACP `mcpServers` 透传 |
|
|
36
|
+
| `features.history: false` | 关闭跨宿主历史归档采集、摘要生成及历史查询工具(`pbot_history` / `history_search` / `history_read`) |
|
|
35
37
|
| 文件不存在、缺少 `enabled` 或 `enabled: false` | 保持未启用,仅保留状态与初始化入口,宿主原生能力不受影响 |
|
|
36
38
|
| JSON 损坏、字段类型错误或不可读 | 保持未启用并报告具体错误,修复后重新启用 |
|
|
37
39
|
|
|
38
|
-
将 `features`
|
|
40
|
+
将 `features` 全部设为 `false` 时,可仅使用跨 Harness `worker_*` 调度能力而不注入任何工作区提示词、技能、统一 MCP 或历史功能。只检查当前绑定的工作区根目录,不向父目录继承,也不自动迁移历史配置。
|
|
39
41
|
|
|
40
42
|
## 统一工作区 MCP 配置(`.pbot/mcp.json`)
|
|
41
43
|
|
|
@@ -59,9 +61,9 @@
|
|
|
59
61
|
}
|
|
60
62
|
```
|
|
61
63
|
|
|
62
|
-
可用 `pbot mcp list|add|remove` 管理该文件。启用 `features.mcp
|
|
63
|
-
-
|
|
64
|
-
-
|
|
64
|
+
可用 `pbot mcp list|add|remove` 管理该文件。启用 `features.mcp`(默认)后,原生挂载与桥接工具二选一,避免同一服务重复暴露:
|
|
65
|
+
- Pi 与 dsh 直接通过原生 API 挂载 `.pbot/mcp.json` 中的服务(不再暴露 `workspace_mcp_*` 桥接工具);
|
|
66
|
+
- 轻插件宿主(Claude Code、Antigravity)及其他 MCP 宿主通过 `pbot` MCP 提供的 `workspace_mcp_discover` / `workspace_mcp_call` 动态发现并调用(修改 `.pbot/mcp.json` 即改即生效);
|
|
65
67
|
- 跨 Harness ACP worker 自动通过 ACP v1 `mcpServers`(或 Pi/dsh 受管成员原生挂载)获得同一组服务。
|
|
66
68
|
|
|
67
69
|
## ACP Harness 配置(`acp`)
|
|
@@ -92,6 +94,29 @@
|
|
|
92
94
|
- 命令不经过 shell 展开;参数中的相对路径按 worker 的 `cwd` 解析。凭据与模型认证由目标宿主自行管理,不写入此文件。
|
|
93
95
|
- 新建 worker 时固定解析后的可执行路径、参数与权限策略;修改 `.pbot/config.json` 后,MCP 下次 `worker_discover` / `worker_create` 调用自动读取最新 `acp` 配置。
|
|
94
96
|
|
|
97
|
+
## 历史目录布局与摘要配置(`history` / `summary`)
|
|
98
|
+
|
|
99
|
+
可选配置历史存储布局及 `/pbot history summary` 所使用的独立 ACP worker 后端、模型与并发度(未配置时默认 `history.layout: "monthly"`、`summary.backend: "pi"` 并使用目标 harness 当前默认模型):
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"enabled": true,
|
|
104
|
+
"history": {
|
|
105
|
+
"layout": "monthly"
|
|
106
|
+
},
|
|
107
|
+
"summary": {
|
|
108
|
+
"backend": "pi",
|
|
109
|
+
"model": "provider/model",
|
|
110
|
+
"thinking": "low",
|
|
111
|
+
"concurrency": 3
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- `history.layout` 可选 `"monthly"`(默认,按 UTC `YYYY/MM/` 分层并启用 `monthly` 月度汇总)或 `"flat"`(平铺布局,不生成月度汇总)。已有平铺工作区可手工执行 `/pbot history migrate` 整理历史文件,不会自动修改此文件或静默迁移数据。
|
|
117
|
+
- 每个待摘要项独立启动一个临时 ACP worker(附带 `PBOT_SUBAGENT_RUN_ID`,绝不写回 `raw/`),完成后立即销毁。
|
|
118
|
+
- 修改后下次执行 `/pbot history summary` 直接生效,也可用命令行参数(`--backend`、`--model`、`--thinking`)临时覆盖。
|
|
119
|
+
|
|
95
120
|
## 手工修改生效方式
|
|
96
121
|
|
|
97
122
|
| 宿主 | 应用方式 |
|
|
@@ -41,6 +41,8 @@ node /path/to/installed/personal-bot/lib/plugin.js antigravity status
|
|
|
41
41
|
- 同宿主子任务与多成员协作直接使用 Antigravity 原生 `invoke_subagent`(`self`、`research` 等)与 `/swarm`,Personal Bot 不注入自定义静态 agent 也不改写 `invoke_subagent` 参数;
|
|
42
42
|
- 跨 Harness 调度(调用 `claude`、`codex`、`pi`、`dsh` 或自定义 ACP 目标)通过插件内置 `mcp_config.json` 挂载的 `pbot` stdio MCP 服务(`worker_*` 工具集)完成,详见[跨 Harness 专家调度](../guides/cross-harness-workers.md)。
|
|
43
43
|
|
|
44
|
+
- **历史**:`Stop` hook 将主会话原始问答投影写入 `.pbot/history/raw/`(可在 `features.history: false` 关闭),并通过 `pbot` MCP 提供的 `history_search` / `history_read` 只读检索全宿主历史。
|
|
45
|
+
|
|
44
46
|
## MCP 与开发校验
|
|
45
47
|
|
|
46
48
|
- 工作区共享 MCP 统一写入 `.pbot/mcp.json`(通过 `pbot mcp add|remove|list` 管理),经内置 `pbot` MCP 的 `workspace_mcp_discover` / `workspace_mcp_call` 在当前工作区按需调用;全局或需交互式 OAuth 的 MCP 使用原生 `agy mcp add|remove|list`(管理 `~/.gemini/config/mcp_config.json`),两者可同时使用。
|
|
@@ -34,7 +34,7 @@ node /absolute/path/to/personal-bot/lib/claude.js status
|
|
|
34
34
|
- **同宿主 vs 跨 Harness 互补**:
|
|
35
35
|
- 同宿主任务与团队协作直接使用 Claude 原生 `Agent` 及原生团队(用户自行管理 `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1`);
|
|
36
36
|
- 跨 Harness 调度(调用 `antigravity`、`codex`、`pi`、`dsh` 或自定义 ACP 目标)通过 [.mcp.json](../../.mcp.json) 自动挂载的 `pbot` stdio MCP 服务(`worker_*` 工具集)完成,详见[跨 Harness 专家调度](../guides/cross-harness-workers.md)。
|
|
37
|
-
-
|
|
37
|
+
- **历史**:`UserPromptSubmit` 与 `Stop` hook 将主会话原始问答写入 `.pbot/history/raw/`(不含带 `agent_id` 的原生子代理,可在 `features.history: false` 关闭),并通过 `pbot` MCP 提供的 `history_search` / `history_read` 只读检索全宿主历史。
|
|
38
38
|
|
|
39
39
|
## 本地开发与校验
|
|
40
40
|
|
package/docs/hosts/dsh.md
CHANGED
|
@@ -61,7 +61,7 @@ dsh plugin --profile pbot add /absolute/path/to/personal-bot-<version>.tgz
|
|
|
61
61
|
|
|
62
62
|
已启用主会话中,模型工具包括:
|
|
63
63
|
- **dsh 原生 `subagent` / `subagent_fork`**:同宿主轻量委派,Personal Bot 不拦截也不覆盖。
|
|
64
|
-
- **MCP 工具 `mcp__pbot__worker_
|
|
64
|
+
- **MCP 工具 `mcp__pbot__worker_*`**:通过 `@deepseek-ai/dsh-mcp-client` 自动挂载 `lib/extension/mcp.js`,暴露跨 Harness 专家调度工具;启用 `features.mcp`(默认)时直接将 `.pbot/mcp.json` 中的服务通过原生 `@deepseek-ai/dsh-mcp-client` 挂载到当前工作区会话(不再重复暴露 `workspace_mcp_*` 桥接工具;与 dsh profile 原生 MCP 单点归属、不重复注册)。
|
|
65
65
|
- **原生工具 `pbot_history`**:跨来源搜索与读取历史问答及摘要,详见[历史对话](../guides/history.md)。
|
|
66
66
|
|
|
67
67
|
主会话通过原生 `write`/`edit`/`apply_patch` 修改工作区外文件时触发一次原生批准。Web 工作台只读查询通过原生 Typert Remote(`snapshot`、`history`)完成,不启动额外 HTTP 服务。
|
package/docs/hosts/pi.md
CHANGED
|
@@ -44,6 +44,6 @@ pi
|
|
|
44
44
|
|
|
45
45
|
## 原生 MCP、统一 MCP 与技能
|
|
46
46
|
|
|
47
|
-
- 工作区共享 MCP 统一写入 `.pbot/mcp.json`(`pbot mcp add|remove|list`),Pi 启用 `features.mcp`(默认)时自动通过 `pi.registerMcpServer`
|
|
47
|
+
- 工作区共享 MCP 统一写入 `.pbot/mcp.json`(`pbot mcp add|remove|list`),Pi 启用 `features.mcp`(默认)时自动通过 `pi.registerMcpServer` 直接原生挂载(不再重复暴露 `workspace_mcp_*` 桥接工具);全局工具、需交互式 OAuth 或宿主私有的 MCP 仍可用 `pi mcp add [--local] <server> ...`(写入 `~/.pi/agent/mcp.json` 或 `.pi/mcp.json`)并与之单点归属、互不重复注册,用 `/mcp` 查看状态。
|
|
48
48
|
- 工作区自有技能统一放在 `.agents/skills/<name>/SKILL.md`;包内技能遵守 Pi 原生 `--no-skills`、包级过滤及 `.pbot/config.json` 的 `features.skills`。
|
|
49
49
|
- 修改工作区外文件时,Pi 通过安全确认队列提示人工确认。
|
package/hooks/hooks.json
CHANGED
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
],
|
|
9
9
|
"UserPromptExpansion": [
|
|
10
10
|
{ "matcher": "personal-bot:.*", "hooks": [{ "type": "command", "command": "node", "args": ["${CLAUDE_PLUGIN_ROOT}/lib/claude.js", "hook"], "timeout": 10 }] }
|
|
11
|
+
],
|
|
12
|
+
"Stop": [
|
|
13
|
+
{ "hooks": [{ "type": "command", "command": "node", "args": ["${CLAUDE_PLUGIN_ROOT}/lib/claude.js", "hook"], "timeout": 10 }] }
|
|
11
14
|
]
|
|
12
15
|
}
|
|
13
16
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { realpathSync } from "node:fs";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
|
-
import { runPluginHost } from "./extension/plugin-runtime.js";
|
|
4
|
-
import { claudeAdapter } from "./integrations/hosts/claude.js";
|
|
3
|
+
import { runPluginHost } from "./extension/hosts/plugin-runtime.js";
|
|
4
|
+
import { claudeAdapter } from "./integrations/hosts/claude/adapter.js";
|
|
5
5
|
export function main(args) {
|
|
6
6
|
return runPluginHost(claudeAdapter, args);
|
|
7
7
|
}
|