personal-bot 0.3.3 → 0.3.4

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 (54) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +2 -2
  4. package/README.zh-CN.md +2 -2
  5. package/bin/pbot.mjs +1 -1
  6. package/docs/architecture/extensibility.md +21 -0
  7. package/docs/guides/workspace-configuration.md +13 -0
  8. package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +9 -2
  9. package/lib/antigravity-plugin/lib/extension/workspace-cli.js +49 -5
  10. package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +12 -0
  11. package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +52 -4
  12. package/lib/antigravity-plugin/package.json +1 -1
  13. package/lib/antigravity-plugin/plugin.json +1 -1
  14. package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +1 -1
  15. package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +2 -2
  16. package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +3 -3
  17. package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +1 -1
  18. package/lib/extension/hosts/plugin-runtime.js +9 -2
  19. package/lib/extension/setup/cli.js +12 -0
  20. package/lib/extension/setup/upgrade.js +153 -0
  21. package/lib/extension/workspace-cli.js +49 -5
  22. package/lib/integrations/installation/cli-update.js +146 -0
  23. package/lib/integrations/installation/upgraders/antigravity.js +67 -0
  24. package/lib/integrations/installation/upgraders/claude.js +123 -0
  25. package/lib/integrations/installation/upgraders/codex.js +73 -0
  26. package/lib/integrations/installation/upgraders/dsh.js +62 -0
  27. package/lib/integrations/installation/upgraders/pi.js +90 -0
  28. package/lib/integrations/installation/upgraders/qoder.js +67 -0
  29. package/lib/integrations/installation/upgraders/registry.js +40 -0
  30. package/lib/qoder-plugin/.mcp.json +2 -2
  31. package/lib/qoder-plugin/.qoder-plugin/plugin.json +1 -1
  32. package/lib/qoder-plugin/hooks/hooks.json +3 -3
  33. package/lib/qoder-plugin/skills/pbot/SKILL.md +1 -1
  34. package/lib/services/installation/setup-service.js +4 -1
  35. package/lib/services/installation/upgrade-service.js +95 -0
  36. package/lib/services/workspace/plugin-releases.d.ts +12 -0
  37. package/lib/services/workspace/plugin-releases.js +52 -4
  38. package/package.json +1 -1
  39. package/src/extension/hosts/plugin-runtime.ts +9 -2
  40. package/src/extension/setup/cli.ts +7 -0
  41. package/src/extension/setup/upgrade.ts +158 -0
  42. package/src/extension/setup/workspace-cli.ts +10 -2
  43. package/src/integrations/installation/cli-update.ts +28 -0
  44. package/src/integrations/installation/upgraders/antigravity.ts +68 -0
  45. package/src/integrations/installation/upgraders/claude.ts +123 -0
  46. package/src/integrations/installation/upgraders/codex.ts +73 -0
  47. package/src/integrations/installation/upgraders/dsh.ts +63 -0
  48. package/src/integrations/installation/upgraders/pi.ts +87 -0
  49. package/src/integrations/installation/upgraders/qoder.ts +68 -0
  50. package/src/integrations/installation/upgraders/registry.ts +48 -0
  51. package/src/model/installation.ts +45 -0
  52. package/src/services/installation/setup-service.ts +7 -2
  53. package/src/services/installation/upgrade-service.ts +127 -0
  54. package/src/services/workspace/plugin-releases.ts +57 -4
@@ -6,12 +6,12 @@
6
6
  "plugins": [
7
7
  {
8
8
  "name": "personal-bot",
9
- "version": "0.3.3",
9
+ "version": "0.3.4",
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.3"
14
+ "version": "0.3.4"
15
15
  }
16
16
  }
17
17
  ]
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "personal-bot",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "license": "MIT",
5
5
  "description": "Workspace materials, skills, and cross-harness MCP worker delegation.",
6
6
  "skills": [
package/README.md CHANGED
@@ -20,7 +20,7 @@ Missing, disabled, or invalid configuration keeps Personal Bot inactive without
20
20
 
21
21
  ## Install
22
22
 
23
- The workspace CLI runs from the workspace root or accepts `--workspace <dir>`. Install it with `npm install -g personal-bot`, or use `npx personal-bot@<installed-plugin-version>`. Use `pbot init`, `pbot status` and `pbot history status|list|summary|migrate|search|read`. During initialization and in enabled workspaces, the CLI selects a version that meets the registered plugins’ requirements. [CLI and history guide](docs/guides/history.md)
23
+ The workspace CLI runs from the workspace root or accepts `--workspace <dir>`. Install it with `npm install -g personal-bot`, or use `npx personal-bot@<installed-plugin-version>`. Use `pbot init`, `pbot status`, `pbot upgrade|update`, and `pbot history status|list|summary|migrate|search|read`. Run `pbot upgrade` to update the global CLI and all host plugins bound to the current workspace to the latest stable npm release. During initialization and in enabled workspaces, the CLI also selects a version that meets the registered plugins’ requirements. [Workspace configuration](docs/guides/workspace-configuration.md) · [CLI and history guide](docs/guides/history.md)
24
24
 
25
25
  ### Pi
26
26
 
@@ -100,7 +100,7 @@ Supports built-in presets (`pi`, `dsh`, `claude`, `antigravity`, `codex`, `qoder
100
100
 
101
101
  ## Development
102
102
 
103
- The package version is **0.3.3**. Full development uses Linux/macOS and Node.js 24.9+:
103
+ The package version is **0.3.4**. Full development uses Linux/macOS and Node.js 24.9+:
104
104
 
105
105
  ```bash
106
106
  npm ci --ignore-scripts
package/README.zh-CN.md CHANGED
@@ -20,7 +20,7 @@ Personal Bot 为多宿主环境([Pi](https://pi.dev)、dsh、Claude Code、Ant
20
20
 
21
21
  ## 安装
22
22
 
23
- 在工作区根目录运行 CLI,或用 `--workspace <目录>` 指定。全局安装用 `npm install -g personal-bot`,临时运行用 `npx personal-bot@<插件版本>`。所有宿主共用 `pbot init`、`pbot status` 和 `pbot history status|list|summary|migrate|search|read`。显式初始化或在已启用的工作区执行命令时,CLI 自动选择满足插件要求的版本。详见[历史与 CLI 指南](docs/guides/history.md)。
23
+ 在工作区根目录运行 CLI,或用 `--workspace <目录>` 指定。全局安装用 `npm install -g personal-bot`,临时运行用 `npx personal-bot@<插件版本>`。所有宿主共用 `pbot init`、`pbot status`、`pbot upgrade|update` 和 `pbot history status|list|summary|migrate|search|read`。运行 `pbot upgrade` 可将全局 CLI 与当前工作区已绑定的各宿主插件统一升级到 npm 最新稳定版;显式初始化或在已启用的工作区执行命令时,CLI 也会自动选择满足插件要求的版本。详见[工作区配置](docs/guides/workspace-configuration.md)与[历史与 CLI 指南](docs/guides/history.md)。
24
24
 
25
25
  ### Pi
26
26
 
@@ -100,7 +100,7 @@ pbot mcp
100
100
 
101
101
  ## 开发与验证
102
102
 
103
- 当前版本 **0.3.3**。完整开发使用 Linux/macOS、Node.js 24.9+:
103
+ 当前版本 **0.3.4**。完整开发使用 Linux/macOS、Node.js 24.9+:
104
104
 
105
105
  ```bash
106
106
  npm ci --ignore-scripts
package/bin/pbot.mjs CHANGED
@@ -6,7 +6,7 @@ try {
6
6
  process.exitCode = await main(args);
7
7
  } else {
8
8
  const { updateForCommand, updateForWorkspace } = await import("../lib/extension/workspace-cli.js");
9
- const updated = args.length && !["-h", "--help"].includes(args[0]) ? await updateForCommand(args) : undefined;
9
+ const updated = args.length && !["-h", "--help", "upgrade", "update"].includes(args[0]) ? await updateForCommand(args) : undefined;
10
10
  if (updated !== undefined) {
11
11
  process.exitCode = updated;
12
12
  } else if (args[0] === "plugin") {
@@ -84,3 +84,24 @@ MCP Server (src/extension/mcp/workers.ts) -> AgentService -> AcpWorkerHost -> sr
84
84
  - 每次调用动态读取工作区 `.pbot/config.json` 并刷新 `acp` 映射,新增自定义 Harness 即改即生效。
85
85
  - 支持 `PBOT_MCP_SESSION_ID` 与 `PBOT_MCP_AGENT_DIR`,使 Pi/dsh 的 `/pbot worker` 命令与自动挂载的 MCP 进程共享同一会话归属。
86
86
  - `lib/extension/mcp.js` 与 `lib/extension/acp-worker.js` 通过 `esbuild` 独立打包,确保插件缓存目录在无 `node_modules` 环境下稳定运行。
87
+
88
+ ## 4. 可扩展宿主升级适配器(`HostUpgraderRegistry`)
89
+
90
+ ```text
91
+ pbot upgrade|update (src/extension/setup/upgrade.ts)
92
+ ↓
93
+ src/services/installation/upgrade-service.ts (宿主无关编排与单宿主容错)
94
+ ↓
95
+ HostUpgraderRegistry (src/integrations/installation/upgraders/registry.ts)
96
+ ├── piUpgrader (src/integrations/installation/upgraders/pi.ts)
97
+ ├── claudeUpgrader (src/integrations/installation/upgraders/claude.ts)
98
+ ├── antigravityUpgrader (src/integrations/installation/upgraders/antigravity.ts)
99
+ ├── codexUpgrader (src/integrations/installation/upgraders/codex.ts)
100
+ ├── qoderUpgrader (src/integrations/installation/upgraders/qoder.ts)
101
+ ├── dshUpgrader (src/integrations/installation/upgraders/dsh.ts)
102
+ └── <自定义宿主升级器> (通过 registerHostUpgrader 动态注册)
103
+ ```
104
+
105
+ - `HostUpgrader` 契约定义在 `src/model/installation.ts`(`host: string` + `upgrade(context): Promise<HostUpgradeResult>`)。
106
+ - 升级编排主链路只按当前工作区绑定的宿主列表(`~/.pbot/workspaces/<hash>/*.json` 与本地 `.pi/`)动态查表调用,不感知具体宿主实现;单宿主失败或跳过不阻塞其余宿主。
107
+ - 接入新宿主升级能力只需新增 `src/integrations/installation/upgraders/<host>.ts` 并在 `registry.ts` 注册,无需修改 `upgrade-service.ts` 或 `upgrade.ts`。
@@ -15,6 +15,19 @@
15
15
 
16
16
  `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`)、已设置的开关/摘要配置及其他未知配置字段;配置文件损坏时先报错而不覆写。
17
17
 
18
+ ## 统一升级工作区多宿主插件
19
+
20
+ 当同一工作区交替使用多个宿主(如 Claude Code、Codex、Pi、Antigravity、Qoder CLI、dsh)时,各宿主激活后会在 `~/.pbot/workspaces/<工作区hash>/` 记录绑定版本;若检测到版本不一致,`pbot status` 会标记 `outOfSync: true`,会话启动时也会提示同步。在终端执行:
21
+
22
+ ```bash
23
+ pbot upgrade [--workspace <目录>] [--version <版本>] [--hosts <h1,h2>] [--dsh-profile <名称>] [--json]
24
+ # 等价别名
25
+ pbot update [--workspace <目录>]
26
+ ```
27
+
28
+ - 默认将全局 `pbot` CLI 与当前工作区已绑定的宿主插件统一升级到 npm 最新稳定版(本地开发或 `npm link` 安装跳过全局 CLI 覆盖)。
29
+ - 遵循最小影响原则:仅处理当前工作区已绑定的宿主并保留既有安装作用域(Pi 仅更新工作区 `--local` 的 `personal-bot`、非 npm 自定义来源跳过;Claude 保留原有的 `local`/`project`/`user` 作用域;dsh 自动从绑定路径识别 profile 或通过 `--dsh-profile` 指定,不强杀运行中的服务)。
30
+
18
31
  ## 启用、模块开关(`features`)与停用规则
19
32
 
20
33
  ```json
@@ -5,7 +5,7 @@ import { requireThat } from "../../common/validation.js";
5
5
  import { loadWorkspaceContext } from "../../integrations/agent-resources.js";
6
6
  import { recordHistoryCapture } from "../../services/history/history-capture.js";
7
7
  import { historyStartupNotices } from "../../services/history/summary-runner.js";
8
- import { bindWorkspacePlugin } from "../../services/workspace/plugin-releases.js";
8
+ import { bindWorkspacePlugin, workspacePluginDrift, workspacePluginReleases } from "../../services/workspace/plugin-releases.js";
9
9
  import { readWorkspaceConfig, workspaceFeatures } from "../../services/workspace/workspace-config.js";
10
10
  import { initializeWorkspace } from "../../services/workspace/workspace-preparation.js";
11
11
  import { discoverSkills, discoverWorkspaceSkills } from "../../services/workspace/workspace-skills.js";
@@ -83,7 +83,14 @@ export async function pluginHook(adapter, payload, replay) {
83
83
  const directory = join(resourceRoot, "skills");
84
84
  workspaceSkills.push(...await discoverSkills(directory, directory));
85
85
  }
86
- const notices = event.isSessionStart && features.history ? historyStartupNotices(root) : [];
86
+ const notices = event.isSessionStart && features.history ? [...historyStartupNotices(root)] : [];
87
+ if (event.isSessionStart) {
88
+ const drift = workspacePluginDrift(workspacePluginReleases(root));
89
+ if (drift.outOfSync) {
90
+ const summary = Object.entries(drift.versions).map(([host, version]) => `${host}=${version}`).join(", ");
91
+ notices.push(`检测到当前工作区各宿主 Personal Bot 插件版本不一致(${summary}),可在终端运行 pbot upgrade 统一升级。`);
92
+ }
93
+ }
87
94
  if (!includePrompts && !workspaceSkills.length && !notices.length)
88
95
  return adapter.formatPass(payload);
89
96
  const context = await loadWorkspaceContext({
@@ -19894,6 +19894,22 @@ import { mkdirSync as mkdirSync2, readdirSync, readFileSync as readFileSync3 } f
19894
19894
  import { homedir as homedir2 } from "node:os";
19895
19895
  import { isAbsolute as isAbsolute3, join as join5, resolve as resolve4 } from "node:path";
19896
19896
  init_atomic_json();
19897
+ function compareSemver(a, b) {
19898
+ const parse = (value) => {
19899
+ const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?/.exec(value);
19900
+ return match ? { major: Number(match[1]), minor: Number(match[2]), patch: Number(match[3]), pre: match[4] ?? "" } : void 0;
19901
+ };
19902
+ const left = parse(a);
19903
+ const right = parse(b);
19904
+ if (!left || !right) return a.localeCompare(b);
19905
+ if (left.major !== right.major) return left.major - right.major;
19906
+ if (left.minor !== right.minor) return left.minor - right.minor;
19907
+ if (left.patch !== right.patch) return left.patch - right.patch;
19908
+ if (left.pre === right.pre) return 0;
19909
+ if (!left.pre) return 1;
19910
+ if (!right.pre) return -1;
19911
+ return left.pre.localeCompare(right.pre);
19912
+ }
19897
19913
  function bindingDirectory(root) {
19898
19914
  const key = createHash("sha256").update(root).digest("hex");
19899
19915
  return join5(homedir2(), ".pbot", "workspaces", key);
@@ -19906,7 +19922,7 @@ function pluginBinding(value) {
19906
19922
  function permissionDenied(error) {
19907
19923
  return ["EACCES", "EPERM", "EROFS"].includes(error.code ?? "");
19908
19924
  }
19909
- function workspacePluginReleases(root) {
19925
+ function workspacePluginBindings(root) {
19910
19926
  const directory = bindingDirectory(root);
19911
19927
  let files;
19912
19928
  try {
@@ -19915,25 +19931,45 @@ function workspacePluginReleases(root) {
19915
19931
  if (error.code === "ENOENT" || permissionDenied(error)) return {};
19916
19932
  throw error;
19917
19933
  }
19918
- const releases = /* @__PURE__ */ Object.create(null);
19934
+ const bindings = /* @__PURE__ */ Object.create(null);
19919
19935
  for (const file of files.filter((name) => name.endsWith(".json"))) {
19920
19936
  const host = decodeURIComponent(file.slice(0, -5));
19921
19937
  try {
19922
19938
  const binding = readJsonFile(directory, file, pluginBinding);
19923
19939
  if (!isAbsolute3(binding)) {
19924
- releases[host] = binding;
19940
+ bindings[host] = { version: binding };
19925
19941
  continue;
19926
19942
  }
19927
19943
  const manifest2 = JSON.parse(readFileSync3(binding, "utf8"));
19928
19944
  requireThat(object(manifest2) && typeof manifest2.version === "string", "\u65E0\u6548\u7684\u63D2\u4EF6\u5B89\u88C5\u6E05\u5355\uFF1A" + binding);
19929
19945
  releaseLine(manifest2.version);
19930
- releases[host] = manifest2.version;
19946
+ bindings[host] = { version: manifest2.version, bindingPath: binding };
19931
19947
  } catch (error) {
19932
19948
  if (error.code !== "ENOENT" && !permissionDenied(error)) throw error;
19933
19949
  }
19934
19950
  }
19951
+ return bindings;
19952
+ }
19953
+ function workspacePluginReleases(root) {
19954
+ const bindings = workspacePluginBindings(root);
19955
+ const releases = /* @__PURE__ */ Object.create(null);
19956
+ for (const [host, entry] of Object.entries(bindings)) releases[host] = entry.version;
19935
19957
  return releases;
19936
19958
  }
19959
+ function workspacePluginDrift(releases) {
19960
+ let highest;
19961
+ let lowest;
19962
+ for (const version of Object.values(releases)) {
19963
+ if (!highest || compareSemver(version, highest) > 0) highest = version;
19964
+ if (!lowest || compareSemver(version, lowest) < 0) lowest = version;
19965
+ }
19966
+ return {
19967
+ outOfSync: Boolean(highest && lowest && highest !== lowest),
19968
+ ...highest ? { highest } : {},
19969
+ ...lowest ? { lowest } : {},
19970
+ versions: releases
19971
+ };
19972
+ }
19937
19973
 
19938
19974
  // src/extension/setup/workspace-cli.ts
19939
19975
  init_workspace_config2();
@@ -20077,7 +20113,15 @@ async function main(args) {
20077
20113
  }
20078
20114
  requireThat((await stat4(root)).isDirectory(), "\u5DE5\u4F5C\u533A\u5FC5\u987B\u662F\u76EE\u5F55\u3002");
20079
20115
  if (verb !== "history") {
20080
- print({ workspaceRoot: root, version: packageVersion, plugins, minimumCliVersion: required ?? null, configuration });
20116
+ const drift = workspacePluginDrift(plugins);
20117
+ print({
20118
+ workspaceRoot: root,
20119
+ version: packageVersion,
20120
+ plugins,
20121
+ outOfSync: drift.outOfSync,
20122
+ minimumCliVersion: required ?? null,
20123
+ configuration
20124
+ });
20081
20125
  return configuration.error ? 1 : 0;
20082
20126
  }
20083
20127
  const command = historyAction(tail);
@@ -1,3 +1,15 @@
1
1
  /** Each host owns its file, including when two hosts activate the same canonical workspace concurrently. */
2
2
  export declare function bindWorkspacePlugin(root: string, host: string, binding?: string): void;
3
+ export interface WorkspacePluginBinding {
4
+ version: string;
5
+ bindingPath?: string;
6
+ }
7
+ export interface WorkspacePluginDrift {
8
+ outOfSync: boolean;
9
+ highest?: string;
10
+ lowest?: string;
11
+ versions: Record<string, string>;
12
+ }
13
+ export declare function workspacePluginBindings(root: string): Record<string, WorkspacePluginBinding>;
3
14
  export declare function workspacePluginReleases(root: string): Record<string, string>;
15
+ export declare function workspacePluginDrift(releases: Record<string, string>): WorkspacePluginDrift;
@@ -7,6 +7,31 @@ import { resourceRoot } from "../../common/paths.js";
7
7
  import { requireThat } from "../../common/validation.js";
8
8
  import { releaseLine } from "../../common/version.js";
9
9
  import { readJsonFile, writeJsonFile } from "../../storage/atomic-json.js";
10
+ function compareSemver(a, b) {
11
+ const parse = (value) => {
12
+ const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?/.exec(value);
13
+ return match
14
+ ? { major: Number(match[1]), minor: Number(match[2]), patch: Number(match[3]), pre: match[4] ?? "" }
15
+ : undefined;
16
+ };
17
+ const left = parse(a);
18
+ const right = parse(b);
19
+ if (!left || !right)
20
+ return a.localeCompare(b);
21
+ if (left.major !== right.major)
22
+ return left.major - right.major;
23
+ if (left.minor !== right.minor)
24
+ return left.minor - right.minor;
25
+ if (left.patch !== right.patch)
26
+ return left.patch - right.patch;
27
+ if (left.pre === right.pre)
28
+ return 0;
29
+ if (!left.pre)
30
+ return 1;
31
+ if (!right.pre)
32
+ return -1;
33
+ return left.pre.localeCompare(right.pre);
34
+ }
10
35
  function bindingDirectory(root) {
11
36
  const key = createHash("sha256").update(root).digest("hex");
12
37
  return join(homedir(), ".pbot", "workspaces", key);
@@ -44,7 +69,7 @@ export function bindWorkspacePlugin(root, host, binding = resolve(resourceRoot,
44
69
  throw error;
45
70
  }
46
71
  }
47
- export function workspacePluginReleases(root) {
72
+ export function workspacePluginBindings(root) {
48
73
  const directory = bindingDirectory(root);
49
74
  let files;
50
75
  try {
@@ -55,24 +80,47 @@ export function workspacePluginReleases(root) {
55
80
  return {};
56
81
  throw error;
57
82
  }
58
- const releases = Object.create(null);
83
+ const bindings = Object.create(null);
59
84
  for (const file of files.filter(name => name.endsWith(".json"))) {
60
85
  const host = decodeURIComponent(file.slice(0, -5));
61
86
  try {
62
87
  const binding = readJsonFile(directory, file, pluginBinding);
63
88
  if (!isAbsolute(binding)) {
64
- releases[host] = binding;
89
+ bindings[host] = { version: binding };
65
90
  continue;
66
91
  }
67
92
  const manifest = JSON.parse(readFileSync(binding, "utf8"));
68
93
  requireThat(object(manifest) && typeof manifest.version === "string", "无效的插件安装清单:" + binding);
69
94
  releaseLine(manifest.version);
70
- releases[host] = manifest.version;
95
+ bindings[host] = { version: manifest.version, bindingPath: binding };
71
96
  }
72
97
  catch (error) {
73
98
  if (error.code !== "ENOENT" && !permissionDenied(error))
74
99
  throw error;
75
100
  }
76
101
  }
102
+ return bindings;
103
+ }
104
+ export function workspacePluginReleases(root) {
105
+ const bindings = workspacePluginBindings(root);
106
+ const releases = Object.create(null);
107
+ for (const [host, entry] of Object.entries(bindings))
108
+ releases[host] = entry.version;
77
109
  return releases;
78
110
  }
111
+ export function workspacePluginDrift(releases) {
112
+ let highest;
113
+ let lowest;
114
+ for (const version of Object.values(releases)) {
115
+ if (!highest || compareSemver(version, highest) > 0)
116
+ highest = version;
117
+ if (!lowest || compareSemver(version, lowest) < 0)
118
+ lowest = version;
119
+ }
120
+ return {
121
+ outOfSync: Boolean(highest && lowest && highest !== lowest),
122
+ ...(highest ? { highest } : {}),
123
+ ...(lowest ? { lowest } : {}),
124
+ versions: releases,
125
+ };
126
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "personal-bot-antigravity-plugin",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "type": "module",
5
5
  "private": true
6
6
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "personal-bot",
3
3
  "displayName": "Personal Bot",
4
- "version": "0.3.3",
4
+ "version": "0.3.4",
5
5
  "description": "Workspace materials, skills, and cross-harness MCP worker delegation.",
6
6
  "repository": "https://github.com/realqiyan/personal-bot"
7
7
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "personal-bot",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Personal Bot workspace context and cross-harness workers.",
5
5
  "skills": "./skills/",
6
6
  "mcpServers": "./.mcp.json"
@@ -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.3.3 \"$@\"",
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.3.4 \"$@\"",
8
8
  "pbot",
9
9
  "mcp"
10
10
  ],
11
11
  "env": {
12
12
  "PBOT_HOST": "codex",
13
- "PBOT_PLUGIN_VERSION": "0.3.3"
13
+ "PBOT_PLUGIN_VERSION": "0.3.4"
14
14
  }
15
15
  }
16
16
  }
@@ -5,7 +5,7 @@
5
5
  "hooks": [
6
6
  {
7
7
  "type": "command",
8
- "command": "PBOT_PLUGIN_VERSION=0.3.3 PBOT_PLUGIN_MANIFEST=\"${PLUGIN_ROOT:+$PLUGIN_ROOT/.codex-plugin/plugin.json}\" 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.3.3 \"$@\"' pbot plugin codex hook",
8
+ "command": "PBOT_PLUGIN_VERSION=0.3.4 PBOT_PLUGIN_MANIFEST=\"${PLUGIN_ROOT:+$PLUGIN_ROOT/.codex-plugin/plugin.json}\" 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.3.4 \"$@\"' pbot plugin codex 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.3.3 PBOT_PLUGIN_MANIFEST=\"${PLUGIN_ROOT:+$PLUGIN_ROOT/.codex-plugin/plugin.json}\" 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.3.3 \"$@\"' pbot plugin codex hook",
19
+ "command": "PBOT_PLUGIN_VERSION=0.3.4 PBOT_PLUGIN_MANIFEST=\"${PLUGIN_ROOT:+$PLUGIN_ROOT/.codex-plugin/plugin.json}\" 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.3.4 \"$@\"' pbot plugin codex 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.3.3 PBOT_PLUGIN_MANIFEST=\"${PLUGIN_ROOT:+$PLUGIN_ROOT/.codex-plugin/plugin.json}\" 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.3.3 \"$@\"' pbot plugin codex hook",
30
+ "command": "PBOT_PLUGIN_VERSION=0.3.4 PBOT_PLUGIN_MANIFEST=\"${PLUGIN_ROOT:+$PLUGIN_ROOT/.codex-plugin/plugin.json}\" 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.3.4 \"$@\"' pbot plugin codex hook",
31
31
  "timeout": 120
32
32
  }
33
33
  ]
@@ -6,4 +6,4 @@ disable-model-invocation: true
6
6
 
7
7
  使用当前会话的 `workspaceRoot` 作为 `--workspace`。省略子命令时使用 `status`。可执行 `init`、`status`、`history status|list|summary|migrate|search|read`。保留用户指定的维度、模型和筛选参数。
8
8
 
9
- 运行 `npx --yes personal-bot@0.3.3 <子命令> --workspace "<workspaceRoot>"`。如果 `pbot --at-least 0.3.3` 返回 0,也可以用 `pbot` 执行同一条命令。返回实际结果。
9
+ 运行 `npx --yes personal-bot@0.3.4 <子命令> --workspace "<workspaceRoot>"`。如果 `pbot --at-least 0.3.4` 返回 0,也可以用 `pbot` 执行同一条命令。返回实际结果。
@@ -5,7 +5,7 @@ import { requireThat } from "../../common/validation.js";
5
5
  import { loadWorkspaceContext } from "../../integrations/agent-resources.js";
6
6
  import { recordHistoryCapture } from "../../services/history/history-capture.js";
7
7
  import { historyStartupNotices } from "../../services/history/summary-runner.js";
8
- import { bindWorkspacePlugin } from "../../services/workspace/plugin-releases.js";
8
+ import { bindWorkspacePlugin, workspacePluginDrift, workspacePluginReleases } from "../../services/workspace/plugin-releases.js";
9
9
  import { readWorkspaceConfig, workspaceFeatures } from "../../services/workspace/workspace-config.js";
10
10
  import { initializeWorkspace } from "../../services/workspace/workspace-preparation.js";
11
11
  import { discoverSkills, discoverWorkspaceSkills } from "../../services/workspace/workspace-skills.js";
@@ -83,7 +83,14 @@ export async function pluginHook(adapter, payload, replay) {
83
83
  const directory = join(resourceRoot, "skills");
84
84
  workspaceSkills.push(...await discoverSkills(directory, directory));
85
85
  }
86
- const notices = event.isSessionStart && features.history ? historyStartupNotices(root) : [];
86
+ const notices = event.isSessionStart && features.history ? [...historyStartupNotices(root)] : [];
87
+ if (event.isSessionStart) {
88
+ const drift = workspacePluginDrift(workspacePluginReleases(root));
89
+ if (drift.outOfSync) {
90
+ const summary = Object.entries(drift.versions).map(([host, version]) => `${host}=${version}`).join(", ");
91
+ notices.push(`检测到当前工作区各宿主 Personal Bot 插件版本不一致(${summary}),可在终端运行 pbot upgrade 统一升级。`);
92
+ }
93
+ }
87
94
  if (!includePrompts && !workspaceSkills.length && !notices.length)
88
95
  return adapter.formatPass(payload);
89
96
  const context = await loadWorkspaceContext({
@@ -11,6 +11,7 @@ import { findExecutable, inspectSystem, SetupProcesses } from "../../integration
11
11
  import { resolveWorkspace } from "../../integrations/installation/workspace.js";
12
12
  import { readWorkspaceMcpConfig, removeWorkspaceMcpServer, upsertWorkspaceMcpServer, } from "../../services/workspace/workspace-mcp.js";
13
13
  import { SetupUI } from "../../ui/setup.js";
14
+ import { runUpgradeCommand } from "./upgrade.js";
14
15
  const root = new URL("../../../", import.meta.url);
15
16
  const quote = (value) => "'" + value.replaceAll("'", "'\\''") + "'";
16
17
  const mcpManageUsage = "用法:\n" +
@@ -190,6 +191,7 @@ export async function main(args) {
190
191
  if (options.action === "help") {
191
192
  console.log("Personal Bot " + manifest.version + "\n\n用法:pbot setup [--workspace <目录>]\n" +
192
193
  " npx personal-bot@latest setup\n" +
194
+ " pbot upgrade|update [--workspace <目录>] [--version <版本>] [--hosts <列表>] [--dsh-profile <名称>] [--json]\n" +
193
195
  " pbot init | status [--workspace <目录>] [--json]\n" +
194
196
  " pbot history status|list|summary|migrate|search|read [参数] [--workspace <目录>] [--json]\n" +
195
197
  " pbot install-antigravity\n" +
@@ -197,11 +199,21 @@ export async function main(args) {
197
199
  " pbot mcp\n" +
198
200
  " pbot mcp list|add|remove ...\n\n" +
199
201
  "setup 安装或升级 Pi、pbot 和选中的插件,然后启动 Pi 执行 /pbot init。\n" +
202
+ "upgrade|update 将全局 CLI 与当前工作区已绑定的各宿主插件统一升级到 npm 最新稳定版。\n" +
200
203
  "install-antigravity 通过原生 agy plugin install 安装或更新 Antigravity 插件。\n" +
201
204
  "mcp 无参数时启动统一 stdio MCP 服务(暴露 worker_* 与 workspace_mcp_*);带 list/add/remove 时管理工作区 .pbot/mcp.json。\n" +
202
205
  "支持 Linux/macOS,需要 Node.js 22.19+ 和 npm。\n--help 显示帮助;--version 显示安装器版本。");
203
206
  return 0;
204
207
  }
208
+ if (options.action === "upgrade") {
209
+ try {
210
+ return await runUpgradeCommand(options.upgradeArgs ?? [], options.upgradeVerb ?? "upgrade");
211
+ }
212
+ catch (error) {
213
+ console.error(error instanceof Error ? error.message : String(error));
214
+ return 2;
215
+ }
216
+ }
205
217
  if (options.action === "mcp-manage") {
206
218
  try {
207
219
  return await runMcpManage(options.mcpArgs ?? []);