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