personal-bot 0.3.3 → 0.3.5
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 +2 -2
- package/README.zh-CN.md +2 -2
- package/bin/pbot.mjs +3 -17
- package/docs/architecture/design.md +8 -6
- package/docs/architecture/extensibility.md +21 -0
- package/docs/architecture/principles.md +1 -1
- package/docs/guides/workspace-configuration.md +13 -0
- package/lib/antigravity-plugin/lib/common/paths.d.ts +1 -0
- package/lib/antigravity-plugin/lib/common/paths.js +2 -0
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +26 -24
- package/lib/antigravity-plugin/lib/extension/cli.js +22596 -0
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +9 -2
- package/lib/antigravity-plugin/lib/extension/mcp.js +22 -20
- package/lib/antigravity-plugin/lib/extension/workspace-cli.js +5 -20121
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +12 -0
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +52 -4
- 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/common/paths.d.ts +1 -0
- package/lib/common/paths.js +2 -0
- package/lib/extension/acp-worker.js +26 -24
- package/lib/extension/cli.js +22596 -0
- package/lib/extension/hosts/plugin-runtime.js +9 -2
- package/lib/extension/mcp.js +22 -20
- package/lib/extension/workspace-cli.js +5 -20121
- 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/workspace/plugin-releases.d.ts +12 -0
- package/lib/services/workspace/plugin-releases.js +52 -4
- package/package.json +1 -1
- package/scripts/README.md +1 -1
- package/src/common/paths.ts +2 -0
- package/src/extension/cli/args.ts +104 -0
- package/src/extension/cli/commands/history.ts +81 -0
- package/src/extension/cli/commands/mcp.ts +165 -0
- package/src/extension/cli/commands/plugin.ts +33 -0
- package/src/extension/cli/commands/setup.ts +159 -0
- package/src/extension/cli/commands/upgrade.ts +158 -0
- package/src/extension/cli/commands/workspace.ts +71 -0
- package/src/extension/cli/index.ts +193 -0
- package/src/extension/cli/types.ts +30 -0
- package/src/extension/hosts/plugin-runtime.ts +9 -2
- package/src/integrations/installation/cli-update.ts +31 -3
- package/src/integrations/installation/pi-setup.ts +6 -3
- package/src/integrations/installation/upgraders/antigravity.ts +68 -0
- package/src/integrations/installation/upgraders/claude.ts +123 -0
- package/src/integrations/installation/upgraders/codex.ts +73 -0
- package/src/integrations/installation/upgraders/dsh.ts +63 -0
- package/src/integrations/installation/upgraders/pi.ts +87 -0
- package/src/integrations/installation/upgraders/qoder.ts +68 -0
- package/src/integrations/installation/upgraders/registry.ts +48 -0
- package/src/model/installation.ts +45 -0
- package/src/services/installation/setup-service.ts +0 -30
- package/src/services/installation/upgrade-service.ts +127 -0
- package/src/services/workspace/plugin-releases.ts +57 -4
- package/lib/extension/setup/cli.js +0 -352
- package/lib/integrations/installation/pi-setup.js +0 -193
- package/lib/integrations/installation/processes.js +0 -140
- package/lib/integrations/installation/workspace.js +0 -21
- package/lib/services/installation/setup-service.js +0 -137
- package/lib/ui/setup.js +0 -52
- package/src/extension/setup/cli.ts +0 -296
- package/src/extension/setup/workspace-cli.ts +0 -159
|
@@ -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({
|
|
@@ -41,8 +41,10 @@ function isOneOf(value, choices) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// src/common/paths.ts
|
|
44
|
+
import { resolve } from "node:path";
|
|
44
45
|
import { fileURLToPath } from "node:url";
|
|
45
46
|
var resourceRoot = fileURLToPath(new URL("../../resources/", import.meta.url));
|
|
47
|
+
var packageRoot = resolve(resourceRoot, "..");
|
|
46
48
|
|
|
47
49
|
// src/common/version.ts
|
|
48
50
|
import { readFileSync } from "node:fs";
|
|
@@ -59,7 +61,7 @@ releaseLine(packageVersion);
|
|
|
59
61
|
// src/integrations/acp/agents.ts
|
|
60
62
|
import { fork, spawnSync } from "node:child_process";
|
|
61
63
|
import { existsSync as existsSync2 } from "node:fs";
|
|
62
|
-
import { join as join7, resolve as
|
|
64
|
+
import { join as join7, resolve as resolve4 } from "node:path";
|
|
63
65
|
import { setTimeout as delay } from "node:timers/promises";
|
|
64
66
|
|
|
65
67
|
// src/storage/agent-files.ts
|
|
@@ -400,9 +402,9 @@ var AgentFiles = class {
|
|
|
400
402
|
|
|
401
403
|
// src/integrations/acp/executable.ts
|
|
402
404
|
import { accessSync, constants as constants2, realpathSync as realpathSync2, statSync } from "node:fs";
|
|
403
|
-
import { delimiter, isAbsolute as isAbsolute2, resolve } from "node:path";
|
|
405
|
+
import { delimiter, isAbsolute as isAbsolute2, resolve as resolve2 } from "node:path";
|
|
404
406
|
function findAcpExecutable(command) {
|
|
405
|
-
const candidates = isAbsolute2(command) ? [command] : (process.env.PATH ?? "").split(delimiter).filter(Boolean).map((directory) =>
|
|
407
|
+
const candidates = isAbsolute2(command) ? [command] : (process.env.PATH ?? "").split(delimiter).filter(Boolean).map((directory) => resolve2(directory, command));
|
|
406
408
|
for (const candidate of candidates) {
|
|
407
409
|
try {
|
|
408
410
|
accessSync(candidate, constants2.X_OK);
|
|
@@ -435,13 +437,13 @@ function acpExecutable(command, backend, harness) {
|
|
|
435
437
|
// src/integrations/acp/claude-settings.ts
|
|
436
438
|
import { createRequire } from "node:module";
|
|
437
439
|
import { pathToFileURL } from "node:url";
|
|
438
|
-
import { basename, join as join4, resolve as
|
|
440
|
+
import { basename, join as join4, resolve as resolve3 } from "node:path";
|
|
439
441
|
var levels = ["low", "medium", "high", "xhigh", "max"];
|
|
440
442
|
async function claudeOptions(command, cwd, supplied, includeSkills = true) {
|
|
441
443
|
const normalized = supplied?.trim().toLowerCase().replace(/[^a-z0-9]+/g, "");
|
|
442
444
|
const requested = normalized === "extrahigh" ? "xhigh" : normalized;
|
|
443
445
|
const script = command.args[0];
|
|
444
|
-
const anchor = ["node", "node.exe"].includes(basename(command.command)) && script && !script.startsWith("-") ?
|
|
446
|
+
const anchor = ["node", "node.exe"].includes(basename(command.command)) && script && !script.startsWith("-") ? resolve3(cwd, script) : command.command;
|
|
445
447
|
const require2 = createRequire(pathToFileURL(anchor));
|
|
446
448
|
const sdk = await import(pathToFileURL(require2.resolve("@anthropic-ai/claude-agent-sdk")).href);
|
|
447
449
|
requireThat(object(sdk) && typeof sdk.resolveSettings === "function", "Claude ACP \u9700\u8981\u63D0\u4F9B resolveSettings \u7684\u539F\u751F SDK\u3002");
|
|
@@ -754,7 +756,7 @@ var AcpWorkerHost = class {
|
|
|
754
756
|
this.files = new AgentFiles(directory);
|
|
755
757
|
}
|
|
756
758
|
files;
|
|
757
|
-
worker =
|
|
759
|
+
worker = resolve4(resourceRoot, "../lib/extension/acp-worker.js");
|
|
758
760
|
available(backend) {
|
|
759
761
|
requireThat(backend, "\u901A\u8FC7 worker_create \u59D4\u6D3E\u8DE8 Harness \u4E13\u5BB6\u65F6\u5FC5\u987B\u6307\u5B9A backend\uFF08\u4F8B\u5982 pi\u3001dsh\u3001claude\u3001antigravity\u3001codex \u6216\u81EA\u5B9A\u4E49 ACP \u540D\u79F0\uFF09\u3002");
|
|
760
762
|
requireThat(process.platform === "linux" || process.platform === "darwin", "ACP worker \u5F53\u524D\u652F\u6301 Linux \u548C macOS\u3002");
|
|
@@ -937,7 +939,7 @@ var AcpWorkerHost = class {
|
|
|
937
939
|
|
|
938
940
|
// src/integrations/hosts/antigravity/adapter.ts
|
|
939
941
|
import { readFile, realpath, stat } from "node:fs/promises";
|
|
940
|
-
import { dirname as dirname2, isAbsolute as isAbsolute3, join as join8, relative, resolve as
|
|
942
|
+
import { dirname as dirname2, isAbsolute as isAbsolute3, join as join8, relative, resolve as resolve5, sep } from "node:path";
|
|
941
943
|
var supportedEvents = ["SessionStart", "PreToolUse", "Stop"];
|
|
942
944
|
function cleanUserRequest(content) {
|
|
943
945
|
const match = content.match(/<USER_REQUEST>\s*([\s\S]*?)\s*<\/USER_REQUEST>/);
|
|
@@ -1004,9 +1006,9 @@ function workspaceFromPayload(cwd, payload) {
|
|
|
1004
1006
|
}
|
|
1005
1007
|
return cwd;
|
|
1006
1008
|
}
|
|
1007
|
-
function skillFromReadPath(targetPath, pluginRoot = process.env.PLUGIN_ROOT ||
|
|
1008
|
-
const skillsRoot =
|
|
1009
|
-
const rel = relative(skillsRoot,
|
|
1009
|
+
function skillFromReadPath(targetPath, pluginRoot = process.env.PLUGIN_ROOT || resolve5(resourceRoot, "..")) {
|
|
1010
|
+
const skillsRoot = resolve5(pluginRoot, "skills");
|
|
1011
|
+
const rel = relative(skillsRoot, resolve5(targetPath));
|
|
1010
1012
|
if (!rel || rel.startsWith("..") || isAbsolute3(rel)) return void 0;
|
|
1011
1013
|
const skill = rel.split(sep)[0];
|
|
1012
1014
|
if (!skill || skill === "pbot") return void 0;
|
|
@@ -1671,7 +1673,7 @@ function parseMcpToolCall(name, args) {
|
|
|
1671
1673
|
// src/services/agents/agent-service.ts
|
|
1672
1674
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
1673
1675
|
import { realpathSync as realpathSync3 } from "node:fs";
|
|
1674
|
-
import { resolve as
|
|
1676
|
+
import { resolve as resolve6 } from "node:path";
|
|
1675
1677
|
var AgentService = class {
|
|
1676
1678
|
constructor(root, directory, host) {
|
|
1677
1679
|
this.root = root;
|
|
@@ -1828,8 +1830,8 @@ var AgentService = class {
|
|
|
1828
1830
|
const prepared = this.files.control(() => {
|
|
1829
1831
|
requireThat(this.list(owner).filter((v) => v.alive).length < 50, "\u6700\u591A 50 \u4E2A\u5B58\u6D3B\u6216\u542F\u52A8\u4E2D worker\uFF1B\u8BF7\u5148\u505C\u6B62\u4E00\u4E2A\u7A7A\u95F2\u4F1A\u8BDD\u3002");
|
|
1830
1832
|
const agentId = randomUUID3();
|
|
1831
|
-
const cwd = realpathSync3(
|
|
1832
|
-
const files = (options.files ?? []).map((p) => realpathSync3(
|
|
1833
|
+
const cwd = realpathSync3(resolve6(this.root, options.cwd ?? "."));
|
|
1834
|
+
const files = (options.files ?? []).map((p) => realpathSync3(resolve6(this.root, p)));
|
|
1833
1835
|
const d = {
|
|
1834
1836
|
agentId,
|
|
1835
1837
|
release: packageVersion,
|
|
@@ -1890,7 +1892,7 @@ var AgentService = class {
|
|
|
1890
1892
|
requireThat(this.alive(id) && this.#starting.get(id)?.stage !== "validate" && !this.files.read(id, "launch.json", launch).stop, "worker \u5DF2\u505C\u6B62\u6216\u4ECD\u5728\u6062\u590D\u6821\u9A8C\uFF0C\u8BF7\u7B49\u5F85\u663E\u5F0F\u6062\u590D\u5B8C\u6210\u3002");
|
|
1891
1893
|
const view = this.view(d, owner);
|
|
1892
1894
|
requireThat(!(delivery === "steer" && view.state !== "idle"), "\u8BE5 ACP worker \u8FD0\u884C\u4E2D\u4E0D\u652F\u6301 steer\uFF1B\u8BF7\u7528 delivery: followUp \u6392\u961F\u3002");
|
|
1893
|
-
const files = attachments.map((path) => realpathSync3(
|
|
1895
|
+
const files = attachments.map((path) => realpathSync3(resolve6(this.root, path)));
|
|
1894
1896
|
const request = this.files.enqueue(id, text3, delivery, files);
|
|
1895
1897
|
return { ...this.view(d, owner), requestId: request.requestId, messageStatus: "queued" };
|
|
1896
1898
|
});
|
|
@@ -2087,7 +2089,7 @@ var AgentService = class {
|
|
|
2087
2089
|
// src/storage/history-files.ts
|
|
2088
2090
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
2089
2091
|
import { linkSync as linkSync2, lstatSync as lstatSync3, mkdirSync as mkdirSync4, readdirSync as readdirSync2, readFileSync as readFileSync3, realpathSync as realpathSync4, rmdirSync as rmdirSync2, unlinkSync as unlinkSync2 } from "node:fs";
|
|
2090
|
-
import { basename as basename2, dirname as dirname3, join as join9, relative as relative2, resolve as
|
|
2092
|
+
import { basename as basename2, dirname as dirname3, join as join9, relative as relative2, resolve as resolve7 } from "node:path";
|
|
2091
2093
|
import { isDeepStrictEqual } from "node:util";
|
|
2092
2094
|
|
|
2093
2095
|
// src/storage/history-format.ts
|
|
@@ -2180,8 +2182,8 @@ function ensureDirectory(path) {
|
|
|
2180
2182
|
const first = mkdirSync4(path, { recursive: true, mode: 448 });
|
|
2181
2183
|
requireThat(sharedDirectory(path), "\u65E0\u6CD5\u521B\u5EFA\u5386\u53F2\u76EE\u5F55\uFF1A" + path);
|
|
2182
2184
|
if (first) {
|
|
2183
|
-
const existing = dirname3(
|
|
2184
|
-
for (let child =
|
|
2185
|
+
const existing = dirname3(resolve7(first));
|
|
2186
|
+
for (let child = resolve7(path); child !== existing && child !== dirname3(child); child = dirname3(child)) {
|
|
2185
2187
|
syncDirectory(realpathSync4(dirname3(child)));
|
|
2186
2188
|
}
|
|
2187
2189
|
}
|
|
@@ -2313,7 +2315,7 @@ function findCandidateJsonFiles(directory, query, layout = "monthly", depth = "m
|
|
|
2313
2315
|
for (const line of result.stdout.split(/\r?\n/)) {
|
|
2314
2316
|
const trimmedLine = line.trim();
|
|
2315
2317
|
if (!trimmedLine) continue;
|
|
2316
|
-
const rel = relative2(base,
|
|
2318
|
+
const rel = relative2(base, resolve7(trimmedLine)).replaceAll("\\", "/");
|
|
2317
2319
|
if (layout === "flat") {
|
|
2318
2320
|
if (!rel.includes("/") && rel.endsWith(".json")) matched2.push(rel);
|
|
2319
2321
|
} else if (relativePattern.test(rel)) {
|
|
@@ -3030,7 +3032,7 @@ import { setTimeout as delay2 } from "node:timers/promises";
|
|
|
3030
3032
|
|
|
3031
3033
|
// src/services/workspace/workspace-mcp.ts
|
|
3032
3034
|
import { mkdir as mkdir2, readFile as readFile3 } from "node:fs/promises";
|
|
3033
|
-
import { dirname as dirname5, join as join12, resolve as
|
|
3035
|
+
import { dirname as dirname5, join as join12, resolve as resolve8 } from "node:path";
|
|
3034
3036
|
var serverNamePattern = /^[A-Za-z0-9][A-Za-z0-9_-]{0,31}$/;
|
|
3035
3037
|
var reservedServerNames = /* @__PURE__ */ new Set(["pbot"]);
|
|
3036
3038
|
var stdioKeys = /* @__PURE__ */ new Set(["command", "args", "env", "cwd", "description", "timeout", "enabled"]);
|
|
@@ -3184,7 +3186,7 @@ function resolveWorkspaceMcpServer(root, name, server, env = process.env) {
|
|
|
3184
3186
|
}
|
|
3185
3187
|
const command = expandEnvTemplate(server.command, env, `MCP \u670D\u52A1 "${name}" \u7684 command`);
|
|
3186
3188
|
const args = (server.args ?? []).map((arg, index) => expandEnvTemplate(arg, env, `MCP \u670D\u52A1 "${name}" \u7684 args[${index}]`));
|
|
3187
|
-
const cwd = server.cwd ?
|
|
3189
|
+
const cwd = server.cwd ? resolve8(root, expandEnvTemplate(server.cwd, env, `MCP \u670D\u52A1 "${name}" \u7684 cwd`)) : root;
|
|
3188
3190
|
return {
|
|
3189
3191
|
transport: "stdio",
|
|
3190
3192
|
name,
|