personal-bot 0.3.7 → 0.4.0
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 +5 -8
- package/README.zh-CN.md +5 -8
- package/bin/pbot-pi-acp.mjs +1 -1
- package/docs/architecture/design.md +2 -2
- package/docs/architecture/extensibility.md +1 -1
- package/docs/guides/cross-harness-workers.md +4 -4
- package/docs/guides/history.md +1 -3
- package/docs/guides/workspace-configuration.md +4 -4
- package/docs/hosts/claude-code.md +2 -2
- package/docs/hosts/codex-qoder.md +1 -1
- package/lib/antigravity-plugin/bin/pbot-pi-acp.mjs +1 -1
- package/lib/antigravity-plugin/lib/extension/acp/member.d.ts +1 -1
- package/lib/antigravity-plugin/lib/extension/acp/member.js +11 -10
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +346 -201
- package/lib/antigravity-plugin/lib/extension/cli.js +563 -538
- package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-member.js +1 -1
- package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.js +3 -4
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +0 -11
- package/lib/antigravity-plugin/lib/extension/mcp.js +397 -278
- package/lib/antigravity-plugin/lib/model/acp.d.ts +29 -35
- package/lib/antigravity-plugin/lib/model/agent.d.ts +33 -17
- package/lib/antigravity-plugin/lib/model/agent.js +0 -1
- package/lib/antigravity-plugin/lib/storage/acp-files.d.ts +5 -8
- package/lib/antigravity-plugin/lib/storage/acp-files.js +34 -40
- package/lib/antigravity-plugin/lib/storage/agent-files.d.ts +19 -10
- package/lib/antigravity-plugin/lib/storage/agent-files.js +147 -43
- package/lib/antigravity-plugin/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +1 -1
- package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +1 -1
- package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +2 -2
- package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +3 -3
- package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +1 -1
- package/lib/extension/acp/member.d.ts +1 -1
- package/lib/extension/acp/member.js +11 -10
- package/lib/extension/acp/worker.js +34 -33
- package/lib/extension/acp-worker.js +346 -201
- package/lib/extension/cli.js +563 -538
- package/lib/extension/hosts/dsh/acp-member.js +1 -1
- package/lib/extension/hosts/dsh/command.js +1 -1
- package/lib/extension/hosts/dsh/workspace.js +1 -3
- package/lib/extension/hosts/pi/acp-member.js +3 -4
- package/lib/extension/hosts/plugin-runtime.js +0 -11
- package/lib/extension/mcp/tool-contract.d.ts +8 -50
- package/lib/extension/mcp/tool-contract.js +0 -8
- package/lib/extension/mcp/workers.d.ts +7 -27
- package/lib/extension/mcp/workers.js +35 -17
- package/lib/extension/mcp.js +397 -278
- package/lib/integrations/acp/agents.d.ts +2 -3
- package/lib/integrations/acp/agents.js +22 -22
- package/lib/integrations/acp/harnesses/claude.js +1 -1
- package/lib/model/acp.d.ts +29 -35
- package/lib/model/agent.d.ts +33 -17
- package/lib/model/agent.js +0 -1
- package/lib/qoder-plugin/.mcp.json +2 -2
- package/lib/qoder-plugin/.qoder-plugin/plugin.json +1 -1
- package/lib/qoder-plugin/hooks/hooks.json +3 -3
- package/lib/qoder-plugin/skills/pbot/SKILL.md +1 -1
- package/lib/services/agents/acp-run.d.ts +6 -4
- package/lib/services/agents/acp-run.js +62 -43
- package/lib/services/agents/agent-run.d.ts +10 -6
- package/lib/services/agents/agent-run.js +142 -65
- package/lib/services/agents/agent-service.d.ts +3 -21
- package/lib/services/agents/agent-service.js +180 -126
- package/lib/storage/acp-files.d.ts +5 -8
- package/lib/storage/acp-files.js +34 -40
- package/lib/storage/agent-files.d.ts +19 -10
- package/lib/storage/agent-files.js +147 -43
- package/package.json +1 -1
- package/src/extension/acp/member.ts +14 -11
- package/src/extension/acp/worker.ts +31 -28
- package/src/extension/cli/commands/upgrade.ts +8 -36
- package/src/extension/cli/commands/workspace.ts +3 -8
- package/src/extension/cli/index.ts +1 -2
- package/src/extension/hosts/dsh/acp-member.ts +1 -1
- package/src/extension/hosts/dsh/command.ts +1 -1
- package/src/extension/hosts/dsh/workspace.ts +1 -3
- package/src/extension/hosts/pi/acp-member.ts +3 -4
- package/src/extension/hosts/pi/command.ts +1 -1
- package/src/extension/hosts/pi/lifecycle.ts +0 -2
- package/src/extension/hosts/plugin-runtime.ts +0 -10
- package/src/extension/mcp/tool-contract.ts +0 -8
- package/src/extension/mcp/workers.ts +34 -17
- package/src/integrations/acp/agents.ts +28 -27
- package/src/integrations/acp/harnesses/claude.ts +1 -1
- package/src/integrations/hosts/dsh/session.ts +2 -2
- package/src/integrations/installation/cli-update.ts +2 -2
- package/src/integrations/installation/installers/claude.ts +4 -4
- package/src/integrations/installation/installers/qoder.ts +5 -5
- package/src/integrations/installation/upgraders/antigravity.ts +57 -15
- package/src/integrations/installation/upgraders/claude.ts +1 -4
- package/src/integrations/installation/upgraders/codex.ts +85 -15
- package/src/integrations/installation/upgraders/dsh.ts +46 -24
- package/src/integrations/installation/upgraders/pi.ts +18 -11
- package/src/integrations/installation/upgraders/qoder.ts +95 -20
- package/src/model/acp.ts +27 -29
- package/src/model/agent.ts +80 -16
- package/src/model/installation.ts +0 -2
- package/src/pbot.ts +1 -1
- package/src/services/agents/acp-run.ts +81 -49
- package/src/services/agents/agent-run.ts +154 -56
- package/src/services/agents/agent-service.ts +204 -133
- package/src/services/installation/upgrade-service.ts +1 -5
- package/src/storage/acp-files.ts +50 -45
- package/src/storage/agent-files.ts +159 -46
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +0 -15
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +0 -126
- package/lib/services/workspace/plugin-releases.d.ts +0 -15
- package/lib/services/workspace/plugin-releases.js +0 -126
- package/src/services/workspace/plugin-releases.ts +0 -121
|
@@ -4,6 +4,11 @@ import { gte, lt, valid } from "semver";
|
|
|
4
4
|
import { object } from "../../../common/json.js";
|
|
5
5
|
import type { HostUpgradeContext, HostUpgradeResult, HostUpgrader } from "../../../model/installation.js";
|
|
6
6
|
|
|
7
|
+
interface AntigravityPluginEntry {
|
|
8
|
+
name: string;
|
|
9
|
+
version?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
async function readManifestVersion(path: string): Promise<string | undefined> {
|
|
8
13
|
try {
|
|
9
14
|
const data: unknown = JSON.parse(await readFile(path, "utf8"));
|
|
@@ -14,15 +19,61 @@ async function readManifestVersion(path: string): Promise<string | undefined> {
|
|
|
14
19
|
}
|
|
15
20
|
}
|
|
16
21
|
|
|
22
|
+
function parsePluginList(raw: string): AntigravityPluginEntry[] {
|
|
23
|
+
const parsed: unknown = JSON.parse(raw);
|
|
24
|
+
const items = Array.isArray(parsed)
|
|
25
|
+
? parsed
|
|
26
|
+
: object(parsed) && Array.isArray(parsed.plugins)
|
|
27
|
+
? parsed.plugins
|
|
28
|
+
: [];
|
|
29
|
+
const entries: AntigravityPluginEntry[] = [];
|
|
30
|
+
for (const item of items) {
|
|
31
|
+
if (!object(item) || typeof item.name !== "string") continue;
|
|
32
|
+
entries.push({
|
|
33
|
+
name: item.name,
|
|
34
|
+
...(typeof item.version === "string" ? { version: item.version } : {}),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return entries;
|
|
38
|
+
}
|
|
39
|
+
|
|
17
40
|
export const antigravityUpgrader: HostUpgrader = {
|
|
18
41
|
host: "antigravity",
|
|
19
42
|
async upgrade(context: HostUpgradeContext): Promise<HostUpgradeResult> {
|
|
20
|
-
|
|
43
|
+
const agy = context.env.PBOT_AGY_COMMAND || await context.findExecutable("agy");
|
|
44
|
+
if (!agy) {
|
|
45
|
+
return {
|
|
46
|
+
host: this.host,
|
|
47
|
+
state: "skipped",
|
|
48
|
+
detail: "未找到 Antigravity CLI(agy),已跳过。",
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
let entries: AntigravityPluginEntry[];
|
|
52
|
+
try {
|
|
53
|
+
const raw = await context.run(agy, ["plugin", "list", "--json"], context.workspace);
|
|
54
|
+
entries = parsePluginList(raw);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
return {
|
|
57
|
+
host: this.host,
|
|
58
|
+
state: "failed",
|
|
59
|
+
detail: `查询 Antigravity 插件列表失败:${error instanceof Error ? error.message : String(error)}`,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const entry = entries.find(item => item.name === "personal-bot");
|
|
63
|
+
if (!entry) {
|
|
64
|
+
return {
|
|
65
|
+
host: this.host,
|
|
66
|
+
state: "skipped",
|
|
67
|
+
detail: "未在 Antigravity 插件列表中找到 personal-bot,已跳过。",
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const installedVersion = entry.version;
|
|
71
|
+
if (installedVersion && valid(installedVersion) && gte(installedVersion, context.targetVersion)) {
|
|
21
72
|
return {
|
|
22
73
|
host: this.host,
|
|
23
74
|
state: "up-to-date",
|
|
24
|
-
previousVersion:
|
|
25
|
-
version:
|
|
75
|
+
previousVersion: installedVersion,
|
|
76
|
+
version: installedVersion,
|
|
26
77
|
scope: "user",
|
|
27
78
|
detail: "已是最新版本。",
|
|
28
79
|
};
|
|
@@ -33,7 +84,7 @@ export const antigravityUpgrader: HostUpgrader = {
|
|
|
33
84
|
return {
|
|
34
85
|
host: this.host,
|
|
35
86
|
state: "skipped",
|
|
36
|
-
...(
|
|
87
|
+
...(installedVersion ? { previousVersion: installedVersion } : {}),
|
|
37
88
|
detail: `缺少 Antigravity 插件构建产物:${pluginDir}`,
|
|
38
89
|
};
|
|
39
90
|
}
|
|
@@ -41,24 +92,15 @@ export const antigravityUpgrader: HostUpgrader = {
|
|
|
41
92
|
return {
|
|
42
93
|
host: this.host,
|
|
43
94
|
state: "skipped",
|
|
44
|
-
...(
|
|
95
|
+
...(installedVersion ? { previousVersion: installedVersion } : {}),
|
|
45
96
|
detail: `当前本地包产物版本为 ${bundledVersion},低于目标版本 ${context.targetVersion};请先更新全局 personal-bot 包。`,
|
|
46
97
|
};
|
|
47
98
|
}
|
|
48
|
-
const agy = context.env.PBOT_AGY_COMMAND || await context.findExecutable("agy");
|
|
49
|
-
if (!agy) {
|
|
50
|
-
return {
|
|
51
|
-
host: this.host,
|
|
52
|
-
state: "skipped",
|
|
53
|
-
...(context.currentVersion ? { previousVersion: context.currentVersion } : {}),
|
|
54
|
-
detail: "未找到 Antigravity CLI(agy),已跳过。",
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
99
|
await context.run(agy, ["plugin", "install", pluginDir], context.workspace);
|
|
58
100
|
return {
|
|
59
101
|
host: this.host,
|
|
60
102
|
state: "updated",
|
|
61
|
-
...(
|
|
103
|
+
...(installedVersion ? { previousVersion: installedVersion } : {}),
|
|
62
104
|
version: bundledVersion,
|
|
63
105
|
scope: "user",
|
|
64
106
|
detail: `已通过 agy plugin install 更新到 ${bundledVersion}。`,
|
|
@@ -61,7 +61,6 @@ export const claudeUpgrader: HostUpgrader = {
|
|
|
61
61
|
return {
|
|
62
62
|
host: this.host,
|
|
63
63
|
state: "skipped",
|
|
64
|
-
...(context.currentVersion ? { previousVersion: context.currentVersion } : {}),
|
|
65
64
|
detail: "未找到 Claude Code CLI(claude),已跳过。",
|
|
66
65
|
};
|
|
67
66
|
}
|
|
@@ -73,7 +72,6 @@ export const claudeUpgrader: HostUpgrader = {
|
|
|
73
72
|
return {
|
|
74
73
|
host: this.host,
|
|
75
74
|
state: "failed",
|
|
76
|
-
...(context.currentVersion ? { previousVersion: context.currentVersion } : {}),
|
|
77
75
|
detail: `查询 Claude 插件列表失败:${error instanceof Error ? error.message : String(error)}`,
|
|
78
76
|
};
|
|
79
77
|
}
|
|
@@ -82,11 +80,10 @@ export const claudeUpgrader: HostUpgrader = {
|
|
|
82
80
|
return {
|
|
83
81
|
host: this.host,
|
|
84
82
|
state: "skipped",
|
|
85
|
-
...(context.currentVersion ? { previousVersion: context.currentVersion } : {}),
|
|
86
83
|
detail: "未在 Claude 插件列表中找到 personal-bot(可能通过 --plugin-dir 本地加载),已跳过。",
|
|
87
84
|
};
|
|
88
85
|
}
|
|
89
|
-
const installedVersion = entry.version
|
|
86
|
+
const installedVersion = entry.version;
|
|
90
87
|
const scope = entry.scope ?? "user";
|
|
91
88
|
if (installedVersion && valid(installedVersion) && gte(installedVersion, context.targetVersion)) {
|
|
92
89
|
return {
|
|
@@ -4,6 +4,13 @@ import { gte, lt, valid } from "semver";
|
|
|
4
4
|
import { object } from "../../../common/json.js";
|
|
5
5
|
import type { HostUpgradeContext, HostUpgradeResult, HostUpgrader } from "../../../model/installation.js";
|
|
6
6
|
|
|
7
|
+
interface CodexPluginEntry {
|
|
8
|
+
id: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
version?: string;
|
|
11
|
+
installed?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
7
14
|
async function readManifestVersion(path: string): Promise<string | undefined> {
|
|
8
15
|
try {
|
|
9
16
|
const data: unknown = JSON.parse(await readFile(path, "utf8"));
|
|
@@ -14,15 +21,87 @@ async function readManifestVersion(path: string): Promise<string | undefined> {
|
|
|
14
21
|
}
|
|
15
22
|
}
|
|
16
23
|
|
|
24
|
+
function parsePluginList(raw: string): CodexPluginEntry[] {
|
|
25
|
+
const parsed: unknown = JSON.parse(raw);
|
|
26
|
+
const items = Array.isArray(parsed)
|
|
27
|
+
? parsed
|
|
28
|
+
: object(parsed) && Array.isArray(parsed.installed)
|
|
29
|
+
? parsed.installed
|
|
30
|
+
: object(parsed) && Array.isArray(parsed.plugins)
|
|
31
|
+
? parsed.plugins
|
|
32
|
+
: [];
|
|
33
|
+
const entries: CodexPluginEntry[] = [];
|
|
34
|
+
for (const item of items) {
|
|
35
|
+
if (!object(item)) continue;
|
|
36
|
+
const id = typeof item.pluginId === "string"
|
|
37
|
+
? item.pluginId
|
|
38
|
+
: typeof item.id === "string"
|
|
39
|
+
? item.id
|
|
40
|
+
: typeof item.name === "string"
|
|
41
|
+
? item.name
|
|
42
|
+
: undefined;
|
|
43
|
+
if (!id) continue;
|
|
44
|
+
entries.push({
|
|
45
|
+
id,
|
|
46
|
+
...(typeof item.name === "string" ? { name: item.name } : {}),
|
|
47
|
+
...(typeof item.version === "string" ? { version: item.version } : {}),
|
|
48
|
+
...(typeof item.installed === "boolean" ? { installed: item.installed } : {}),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return entries;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function isMissingMarketplaceError(error: unknown): boolean {
|
|
55
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
56
|
+
return /marketplace.*(not found|unknown|does not exist|not configured)|unknown marketplace/i.test(message);
|
|
57
|
+
}
|
|
58
|
+
|
|
17
59
|
export const codexUpgrader: HostUpgrader = {
|
|
18
60
|
host: "codex",
|
|
19
61
|
async upgrade(context: HostUpgradeContext): Promise<HostUpgradeResult> {
|
|
20
|
-
|
|
62
|
+
const codex = context.env.PBOT_CODEX_COMMAND || await context.findExecutable("codex");
|
|
63
|
+
if (!codex) {
|
|
64
|
+
return {
|
|
65
|
+
host: this.host,
|
|
66
|
+
state: "skipped",
|
|
67
|
+
detail: "未找到 Codex CLI(codex),已跳过。",
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
let entries: CodexPluginEntry[];
|
|
71
|
+
try {
|
|
72
|
+
const raw = await context.run(codex, ["plugin", "list", "-m", "pbot-local", "--json"], context.workspace);
|
|
73
|
+
entries = parsePluginList(raw);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
if (isMissingMarketplaceError(error)) {
|
|
76
|
+
return {
|
|
77
|
+
host: this.host,
|
|
78
|
+
state: "skipped",
|
|
79
|
+
detail: "未在 Codex 插件列表中找到 personal-bot,已跳过。",
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
host: this.host,
|
|
84
|
+
state: "failed",
|
|
85
|
+
detail: `查询 Codex 插件列表失败:${error instanceof Error ? error.message : String(error)}`,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const entry = entries.find(item =>
|
|
89
|
+
item.installed !== false
|
|
90
|
+
&& (item.name === "personal-bot" || item.id === "personal-bot" || item.id.startsWith("personal-bot@")));
|
|
91
|
+
if (!entry) {
|
|
92
|
+
return {
|
|
93
|
+
host: this.host,
|
|
94
|
+
state: "skipped",
|
|
95
|
+
detail: "未在 Codex 插件列表中找到 personal-bot,已跳过。",
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
const installedVersion = entry.version;
|
|
99
|
+
if (installedVersion && valid(installedVersion) && gte(installedVersion, context.targetVersion)) {
|
|
21
100
|
return {
|
|
22
101
|
host: this.host,
|
|
23
102
|
state: "up-to-date",
|
|
24
|
-
previousVersion:
|
|
25
|
-
version:
|
|
103
|
+
previousVersion: installedVersion,
|
|
104
|
+
version: installedVersion,
|
|
26
105
|
scope: "user",
|
|
27
106
|
detail: "已是最新版本。",
|
|
28
107
|
};
|
|
@@ -33,7 +112,7 @@ export const codexUpgrader: HostUpgrader = {
|
|
|
33
112
|
return {
|
|
34
113
|
host: this.host,
|
|
35
114
|
state: "skipped",
|
|
36
|
-
...(
|
|
115
|
+
...(installedVersion ? { previousVersion: installedVersion } : {}),
|
|
37
116
|
detail: `缺少 Codex 插件构建产物:${marketplaceDir}`,
|
|
38
117
|
};
|
|
39
118
|
}
|
|
@@ -41,19 +120,10 @@ export const codexUpgrader: HostUpgrader = {
|
|
|
41
120
|
return {
|
|
42
121
|
host: this.host,
|
|
43
122
|
state: "skipped",
|
|
44
|
-
...(
|
|
123
|
+
...(installedVersion ? { previousVersion: installedVersion } : {}),
|
|
45
124
|
detail: `当前本地包产物版本为 ${bundledVersion},低于目标版本 ${context.targetVersion};请先更新全局 personal-bot 包。`,
|
|
46
125
|
};
|
|
47
126
|
}
|
|
48
|
-
const codex = context.env.PBOT_CODEX_COMMAND || await context.findExecutable("codex");
|
|
49
|
-
if (!codex) {
|
|
50
|
-
return {
|
|
51
|
-
host: this.host,
|
|
52
|
-
state: "skipped",
|
|
53
|
-
...(context.currentVersion ? { previousVersion: context.currentVersion } : {}),
|
|
54
|
-
detail: "未找到 Codex CLI(codex),已跳过。",
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
127
|
try {
|
|
58
128
|
await context.run(codex, ["plugin", "marketplace", "add", marketplaceDir], context.workspace);
|
|
59
129
|
} catch {
|
|
@@ -63,7 +133,7 @@ export const codexUpgrader: HostUpgrader = {
|
|
|
63
133
|
return {
|
|
64
134
|
host: this.host,
|
|
65
135
|
state: "updated",
|
|
66
|
-
...(
|
|
136
|
+
...(installedVersion ? { previousVersion: installedVersion } : {}),
|
|
67
137
|
version: bundledVersion,
|
|
68
138
|
scope: "user",
|
|
69
139
|
detail: `已通过 codex plugin add 更新到 ${bundledVersion}。`,
|
|
@@ -1,42 +1,64 @@
|
|
|
1
1
|
import { gte, valid } from "semver";
|
|
2
|
+
import { object } from "../../../common/json.js";
|
|
2
3
|
import type { HostUpgradeContext, HostUpgradeResult, HostUpgrader } from "../../../model/installation.js";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
5
|
+
function parseInstalledVersion(raw: string): string | undefined {
|
|
6
|
+
const trimmed = raw.trim();
|
|
7
|
+
if (!trimmed) return undefined;
|
|
8
|
+
const parsed: unknown = JSON.parse(trimmed);
|
|
9
|
+
const items = Array.isArray(parsed) ? parsed : [parsed];
|
|
10
|
+
for (const item of items) {
|
|
11
|
+
if (!object(item)) continue;
|
|
12
|
+
const deps = item.dependencies;
|
|
13
|
+
if (!object(deps)) continue;
|
|
14
|
+
const pkg = deps["personal-bot"];
|
|
15
|
+
if (object(pkg) && typeof pkg.version === "string" && valid(pkg.version)) return pkg.version;
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
9
18
|
}
|
|
10
19
|
|
|
11
20
|
export const dshUpgrader: HostUpgrader = {
|
|
12
21
|
host: "dsh",
|
|
13
22
|
async upgrade(context: HostUpgradeContext): Promise<HostUpgradeResult> {
|
|
14
|
-
|
|
23
|
+
const profile = context.options.dshProfile || "pbot";
|
|
24
|
+
const scope = `profile:${profile}`;
|
|
25
|
+
const dsh = context.env.PBOT_DSH_COMMAND || await context.findExecutable("dsh");
|
|
26
|
+
if (!dsh) {
|
|
15
27
|
return {
|
|
16
28
|
host: this.host,
|
|
17
|
-
state: "
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
detail: "已是最新版本。",
|
|
29
|
+
state: "skipped",
|
|
30
|
+
scope,
|
|
31
|
+
detail: "未找到 dsh CLI(dsh),已跳过。",
|
|
21
32
|
};
|
|
22
33
|
}
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
let installedVersion: string | undefined;
|
|
35
|
+
try {
|
|
36
|
+
const raw = await context.run(dsh, ["plugin", "--profile", profile, "list", "personal-bot", "--json"], context.workspace);
|
|
37
|
+
installedVersion = parseInstalledVersion(raw);
|
|
38
|
+
} catch (error) {
|
|
25
39
|
return {
|
|
26
40
|
host: this.host,
|
|
27
|
-
state: "
|
|
28
|
-
|
|
29
|
-
detail:
|
|
41
|
+
state: "failed",
|
|
42
|
+
scope,
|
|
43
|
+
detail: `查询 dsh profile "${profile}" 插件列表失败:${error instanceof Error ? error.message : String(error)}`,
|
|
30
44
|
};
|
|
31
45
|
}
|
|
32
|
-
|
|
33
|
-
if (!dsh) {
|
|
46
|
+
if (!installedVersion) {
|
|
34
47
|
return {
|
|
35
48
|
host: this.host,
|
|
36
49
|
state: "skipped",
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
50
|
+
scope,
|
|
51
|
+
detail: `dsh profile "${profile}" 中未安装 personal-bot,已跳过。`,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (gte(installedVersion, context.targetVersion)) {
|
|
55
|
+
return {
|
|
56
|
+
host: this.host,
|
|
57
|
+
state: "up-to-date",
|
|
58
|
+
previousVersion: installedVersion,
|
|
59
|
+
version: installedVersion,
|
|
60
|
+
scope,
|
|
61
|
+
detail: "已是最新版本。",
|
|
40
62
|
};
|
|
41
63
|
}
|
|
42
64
|
try {
|
|
@@ -45,17 +67,17 @@ export const dshUpgrader: HostUpgrader = {
|
|
|
45
67
|
return {
|
|
46
68
|
host: this.host,
|
|
47
69
|
state: "failed",
|
|
48
|
-
|
|
49
|
-
scope
|
|
70
|
+
previousVersion: installedVersion,
|
|
71
|
+
scope,
|
|
50
72
|
detail: `${error instanceof Error ? error.message : String(error)}(提示:更新 dsh 插件前需先停止对应 profile 的 dsh 服务)`,
|
|
51
73
|
};
|
|
52
74
|
}
|
|
53
75
|
return {
|
|
54
76
|
host: this.host,
|
|
55
77
|
state: "updated",
|
|
56
|
-
|
|
78
|
+
previousVersion: installedVersion,
|
|
57
79
|
version: context.targetVersion,
|
|
58
|
-
scope
|
|
80
|
+
scope,
|
|
59
81
|
detail: `已更新 dsh profile "${profile}" 中的 personal-bot。`,
|
|
60
82
|
nextStep: `重新启动 dsh --profile ${profile} 使新版本生效。`,
|
|
61
83
|
};
|
|
@@ -42,24 +42,31 @@ async function readLocalPiVersion(workspace: string): Promise<string | undefined
|
|
|
42
42
|
export const piUpgrader: HostUpgrader = {
|
|
43
43
|
host: "pi",
|
|
44
44
|
async upgrade(context: HostUpgradeContext): Promise<HostUpgradeResult> {
|
|
45
|
-
|
|
46
|
-
if (current && valid(current) && gte(current, context.targetVersion)) {
|
|
45
|
+
if (await hasCustomOnlySource(context.workspace)) {
|
|
47
46
|
return {
|
|
48
47
|
host: this.host,
|
|
49
|
-
state: "
|
|
50
|
-
previousVersion: current,
|
|
51
|
-
version: current,
|
|
48
|
+
state: "skipped",
|
|
52
49
|
scope: "local",
|
|
53
|
-
detail: "
|
|
50
|
+
detail: "工作区 Pi 配置中的 personal-bot 使用非 npm 自定义来源,已保留当前配置。",
|
|
54
51
|
};
|
|
55
52
|
}
|
|
56
|
-
|
|
53
|
+
const current = await readLocalPiVersion(context.workspace);
|
|
54
|
+
if (!current) {
|
|
57
55
|
return {
|
|
58
56
|
host: this.host,
|
|
59
57
|
state: "skipped",
|
|
60
|
-
...(current ? { previousVersion: current } : {}),
|
|
61
58
|
scope: "local",
|
|
62
|
-
detail: "
|
|
59
|
+
detail: "当前工作区未通过 Pi 安装 personal-bot,已跳过。",
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (gte(current, context.targetVersion)) {
|
|
63
|
+
return {
|
|
64
|
+
host: this.host,
|
|
65
|
+
state: "up-to-date",
|
|
66
|
+
previousVersion: current,
|
|
67
|
+
version: current,
|
|
68
|
+
scope: "local",
|
|
69
|
+
detail: "已是最新版本。",
|
|
63
70
|
};
|
|
64
71
|
}
|
|
65
72
|
const pi = context.env.PBOT_PI_COMMAND || await context.findExecutable("pi");
|
|
@@ -67,7 +74,7 @@ export const piUpgrader: HostUpgrader = {
|
|
|
67
74
|
return {
|
|
68
75
|
host: this.host,
|
|
69
76
|
state: "skipped",
|
|
70
|
-
|
|
77
|
+
previousVersion: current,
|
|
71
78
|
scope: "local",
|
|
72
79
|
detail: "未找到 Pi CLI(pi),已跳过。",
|
|
73
80
|
};
|
|
@@ -77,7 +84,7 @@ export const piUpgrader: HostUpgrader = {
|
|
|
77
84
|
return {
|
|
78
85
|
host: this.host,
|
|
79
86
|
state: "updated",
|
|
80
|
-
|
|
87
|
+
previousVersion: current,
|
|
81
88
|
version: installed,
|
|
82
89
|
scope: "local",
|
|
83
90
|
detail: `已通过 pi install --local 更新工作区 personal-bot 到 ${installed}。`,
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
1
|
+
import { readFile, realpath } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { gte, lt, valid } from "semver";
|
|
4
4
|
import { object } from "../../../common/json.js";
|
|
5
5
|
import type { HostUpgradeContext, HostUpgradeResult, HostUpgrader } from "../../../model/installation.js";
|
|
6
6
|
|
|
7
|
+
interface QoderPluginEntry {
|
|
8
|
+
id: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
version?: string;
|
|
11
|
+
scope?: string;
|
|
12
|
+
projectPath?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
async function readManifestVersion(path: string): Promise<string | undefined> {
|
|
8
16
|
try {
|
|
9
17
|
const data: unknown = JSON.parse(await readFile(path, "utf8"));
|
|
@@ -14,16 +22,90 @@ async function readManifestVersion(path: string): Promise<string | undefined> {
|
|
|
14
22
|
}
|
|
15
23
|
}
|
|
16
24
|
|
|
25
|
+
function parsePluginList(raw: string): QoderPluginEntry[] {
|
|
26
|
+
const parsed: unknown = JSON.parse(raw);
|
|
27
|
+
const items = Array.isArray(parsed)
|
|
28
|
+
? parsed
|
|
29
|
+
: object(parsed) && Array.isArray(parsed.plugins)
|
|
30
|
+
? parsed.plugins
|
|
31
|
+
: [];
|
|
32
|
+
const entries: QoderPluginEntry[] = [];
|
|
33
|
+
for (const item of items) {
|
|
34
|
+
if (!object(item)) continue;
|
|
35
|
+
const id = typeof item.id === "string" ? item.id : typeof item.name === "string" ? item.name : undefined;
|
|
36
|
+
if (!id) continue;
|
|
37
|
+
entries.push({
|
|
38
|
+
id,
|
|
39
|
+
...(typeof item.name === "string" ? { name: item.name } : {}),
|
|
40
|
+
...(typeof item.version === "string" ? { version: item.version } : {}),
|
|
41
|
+
...(typeof item.scope === "string" ? { scope: item.scope } : {}),
|
|
42
|
+
...(typeof item.projectPath === "string" ? { projectPath: item.projectPath } : {}),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return entries;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function resolvePathSafe(value: string): Promise<string> {
|
|
49
|
+
try { return await realpath(value); } catch { return value; }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function selectMatchingEntry(entries: QoderPluginEntry[], workspace: string): Promise<QoderPluginEntry | undefined> {
|
|
53
|
+
const canonicalWorkspace = await resolvePathSafe(workspace);
|
|
54
|
+
const candidates = entries.filter(entry =>
|
|
55
|
+
entry.name === "personal-bot" || entry.id === "personal-bot" || entry.id.startsWith("personal-bot@"));
|
|
56
|
+
if (!candidates.length) return undefined;
|
|
57
|
+
const scopedMatches: QoderPluginEntry[] = [];
|
|
58
|
+
for (const entry of candidates) {
|
|
59
|
+
if (!entry.projectPath) {
|
|
60
|
+
scopedMatches.push(entry);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (await resolvePathSafe(entry.projectPath) === canonicalWorkspace) scopedMatches.push(entry);
|
|
64
|
+
}
|
|
65
|
+
const priority = new Map<string, number>([["local", 0], ["project", 1], ["user", 2]]);
|
|
66
|
+
scopedMatches.sort((a, b) => (priority.get(a.scope ?? "") ?? 9) - (priority.get(b.scope ?? "") ?? 9));
|
|
67
|
+
return scopedMatches[0];
|
|
68
|
+
}
|
|
69
|
+
|
|
17
70
|
export const qoderUpgrader: HostUpgrader = {
|
|
18
71
|
host: "qoder",
|
|
19
72
|
async upgrade(context: HostUpgradeContext): Promise<HostUpgradeResult> {
|
|
20
|
-
|
|
73
|
+
const qodercli = context.env.PBOT_QODER_COMMAND || await context.findExecutable("qodercli");
|
|
74
|
+
if (!qodercli) {
|
|
75
|
+
return {
|
|
76
|
+
host: this.host,
|
|
77
|
+
state: "skipped",
|
|
78
|
+
detail: "未找到 Qoder CLI(qodercli),已跳过。",
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
let entries: QoderPluginEntry[];
|
|
82
|
+
try {
|
|
83
|
+
const raw = await context.run(qodercli, ["plugin", "list", "--json"], context.workspace);
|
|
84
|
+
entries = parsePluginList(raw);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
return {
|
|
87
|
+
host: this.host,
|
|
88
|
+
state: "failed",
|
|
89
|
+
detail: `查询 Qoder CLI 插件列表失败:${error instanceof Error ? error.message : String(error)}`,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const entry = await selectMatchingEntry(entries, context.workspace);
|
|
93
|
+
if (!entry) {
|
|
94
|
+
return {
|
|
95
|
+
host: this.host,
|
|
96
|
+
state: "skipped",
|
|
97
|
+
detail: "未在 Qoder CLI 插件列表中找到 personal-bot,已跳过。",
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const installedVersion = entry.version;
|
|
101
|
+
const scope = entry.scope ?? "user";
|
|
102
|
+
if (installedVersion && valid(installedVersion) && gte(installedVersion, context.targetVersion)) {
|
|
21
103
|
return {
|
|
22
104
|
host: this.host,
|
|
23
105
|
state: "up-to-date",
|
|
24
|
-
previousVersion:
|
|
25
|
-
version:
|
|
26
|
-
scope
|
|
106
|
+
previousVersion: installedVersion,
|
|
107
|
+
version: installedVersion,
|
|
108
|
+
scope,
|
|
27
109
|
detail: "已是最新版本。",
|
|
28
110
|
};
|
|
29
111
|
}
|
|
@@ -33,7 +115,8 @@ export const qoderUpgrader: HostUpgrader = {
|
|
|
33
115
|
return {
|
|
34
116
|
host: this.host,
|
|
35
117
|
state: "skipped",
|
|
36
|
-
...(
|
|
118
|
+
...(installedVersion ? { previousVersion: installedVersion } : {}),
|
|
119
|
+
scope,
|
|
37
120
|
detail: `缺少 Qoder CLI 插件构建产物:${pluginDir}`,
|
|
38
121
|
};
|
|
39
122
|
}
|
|
@@ -41,27 +124,19 @@ export const qoderUpgrader: HostUpgrader = {
|
|
|
41
124
|
return {
|
|
42
125
|
host: this.host,
|
|
43
126
|
state: "skipped",
|
|
44
|
-
...(
|
|
127
|
+
...(installedVersion ? { previousVersion: installedVersion } : {}),
|
|
128
|
+
scope,
|
|
45
129
|
detail: `当前本地包产物版本为 ${bundledVersion},低于目标版本 ${context.targetVersion};请先更新全局 personal-bot 包。`,
|
|
46
130
|
};
|
|
47
131
|
}
|
|
48
|
-
|
|
49
|
-
if (!qodercli) {
|
|
50
|
-
return {
|
|
51
|
-
host: this.host,
|
|
52
|
-
state: "skipped",
|
|
53
|
-
...(context.currentVersion ? { previousVersion: context.currentVersion } : {}),
|
|
54
|
-
detail: "未找到 Qoder CLI(qodercli),已跳过。",
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
await context.run(qodercli, ["plugin", "install", pluginDir], context.workspace);
|
|
132
|
+
await context.run(qodercli, ["plugin", "install", pluginDir, "--scope", scope], context.workspace);
|
|
58
133
|
return {
|
|
59
134
|
host: this.host,
|
|
60
135
|
state: "updated",
|
|
61
|
-
...(
|
|
136
|
+
...(installedVersion ? { previousVersion: installedVersion } : {}),
|
|
62
137
|
version: bundledVersion,
|
|
63
|
-
scope
|
|
64
|
-
detail:
|
|
138
|
+
scope,
|
|
139
|
+
detail: `已按原有作用域(${scope})通过 qodercli plugin install 更新到 ${bundledVersion}。`,
|
|
65
140
|
nextStep: "重启 Qoder CLI 会话使新版本生效。",
|
|
66
141
|
};
|
|
67
142
|
},
|