personal-bot 0.3.6 → 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.
Files changed (143) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +5 -8
  4. package/README.zh-CN.md +5 -8
  5. package/bin/pbot-pi-acp.mjs +1 -1
  6. package/docs/README.md +1 -1
  7. package/docs/architecture/design.md +2 -2
  8. package/docs/architecture/extensibility.md +1 -1
  9. package/docs/architecture/model-context.md +1 -2
  10. package/docs/guides/capabilities.md +4 -8
  11. package/docs/guides/cross-harness-workers.md +4 -4
  12. package/docs/guides/history.md +1 -3
  13. package/docs/guides/workspace-configuration.md +4 -4
  14. package/docs/hosts/claude-code.md +2 -2
  15. package/docs/hosts/codex-qoder.md +1 -1
  16. package/lib/antigravity-plugin/bin/pbot-pi-acp.mjs +1 -1
  17. package/lib/antigravity-plugin/lib/extension/acp/member.d.ts +1 -1
  18. package/lib/antigravity-plugin/lib/extension/acp/member.js +11 -10
  19. package/lib/antigravity-plugin/lib/extension/acp-worker.js +348 -203
  20. package/lib/antigravity-plugin/lib/extension/cli.js +574 -549
  21. package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-member.js +1 -1
  22. package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.js +3 -4
  23. package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +0 -11
  24. package/lib/antigravity-plugin/lib/extension/mcp.js +462 -326
  25. package/lib/antigravity-plugin/lib/integrations/agent-resources.js +2 -2
  26. package/lib/antigravity-plugin/lib/model/acp.d.ts +29 -35
  27. package/lib/antigravity-plugin/lib/model/agent.d.ts +33 -17
  28. package/lib/antigravity-plugin/lib/model/agent.js +0 -1
  29. package/lib/antigravity-plugin/lib/storage/acp-files.d.ts +5 -8
  30. package/lib/antigravity-plugin/lib/storage/acp-files.js +34 -40
  31. package/lib/antigravity-plugin/lib/storage/agent-files.d.ts +19 -10
  32. package/lib/antigravity-plugin/lib/storage/agent-files.js +147 -43
  33. package/lib/antigravity-plugin/package.json +1 -1
  34. package/lib/antigravity-plugin/plugin.json +1 -1
  35. package/lib/antigravity-plugin/resources/agents/coordinator.md +3 -7
  36. package/lib/antigravity-plugin/resources/agents/general-purpose.md +3 -3
  37. package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -2
  38. package/lib/antigravity-plugin/resources/prompts/workspace.md +12 -16
  39. package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +7 -6
  40. package/lib/antigravity-plugin/resources/templates/workspace-agents.md +0 -4
  41. package/lib/antigravity-plugin/skills/pbot/SKILL.md +14 -6
  42. package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +7 -6
  43. package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +1 -1
  44. package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +2 -2
  45. package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +3 -3
  46. package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +2 -2
  47. package/lib/extension/acp/member.d.ts +1 -1
  48. package/lib/extension/acp/member.js +11 -10
  49. package/lib/extension/acp/worker.js +34 -33
  50. package/lib/extension/acp-worker.js +348 -203
  51. package/lib/extension/cli.js +574 -549
  52. package/lib/extension/hosts/dsh/acp-member.js +1 -1
  53. package/lib/extension/hosts/dsh/command.js +1 -1
  54. package/lib/extension/hosts/dsh/workspace.js +1 -3
  55. package/lib/extension/hosts/pi/acp-member.js +3 -4
  56. package/lib/extension/hosts/plugin-runtime.js +0 -11
  57. package/lib/extension/mcp/tool-contract.d.ts +8 -50
  58. package/lib/extension/mcp/tool-contract.js +48 -62
  59. package/lib/extension/mcp/workers.d.ts +13 -27
  60. package/lib/extension/mcp/workers.js +60 -25
  61. package/lib/extension/mcp.js +462 -326
  62. package/lib/integrations/acp/agents.d.ts +2 -3
  63. package/lib/integrations/acp/agents.js +22 -22
  64. package/lib/integrations/acp/harnesses/claude.js +1 -1
  65. package/lib/integrations/agent-resources.js +2 -2
  66. package/lib/model/acp.d.ts +29 -35
  67. package/lib/model/agent.d.ts +33 -17
  68. package/lib/model/agent.js +0 -1
  69. package/lib/qoder-plugin/.mcp.json +2 -2
  70. package/lib/qoder-plugin/.qoder-plugin/plugin.json +1 -1
  71. package/lib/qoder-plugin/hooks/hooks.json +3 -3
  72. package/lib/qoder-plugin/skills/pbot/SKILL.md +2 -2
  73. package/lib/services/agents/acp-run.d.ts +6 -4
  74. package/lib/services/agents/acp-run.js +62 -43
  75. package/lib/services/agents/agent-run.d.ts +10 -6
  76. package/lib/services/agents/agent-run.js +142 -65
  77. package/lib/services/agents/agent-service.d.ts +3 -21
  78. package/lib/services/agents/agent-service.js +180 -126
  79. package/lib/storage/acp-files.d.ts +5 -8
  80. package/lib/storage/acp-files.js +34 -40
  81. package/lib/storage/agent-files.d.ts +19 -10
  82. package/lib/storage/agent-files.js +147 -43
  83. package/lib/tools/history/contract.js +12 -12
  84. package/package.json +1 -1
  85. package/resources/agents/coordinator.md +3 -7
  86. package/resources/agents/general-purpose.md +3 -3
  87. package/resources/antigravity/skills/pbot/SKILL.md +14 -6
  88. package/resources/claude/skills/pbot/SKILL.md +14 -6
  89. package/resources/plugin/skills/pbot/SKILL.md +2 -2
  90. package/resources/prompts/history-coordinator.md +1 -2
  91. package/resources/prompts/plugin-coordinator.md +1 -2
  92. package/resources/prompts/workspace.md +12 -16
  93. package/resources/skills/provider-connections/SKILL.md +7 -6
  94. package/resources/templates/workspace-agents.md +0 -4
  95. package/src/extension/acp/member.ts +14 -11
  96. package/src/extension/acp/worker.ts +31 -28
  97. package/src/extension/cli/commands/upgrade.ts +8 -36
  98. package/src/extension/cli/commands/workspace.ts +3 -8
  99. package/src/extension/cli/index.ts +1 -2
  100. package/src/extension/hosts/dsh/acp-member.ts +1 -1
  101. package/src/extension/hosts/dsh/command.ts +1 -1
  102. package/src/extension/hosts/dsh/workspace.ts +1 -3
  103. package/src/extension/hosts/pi/acp-member.ts +3 -4
  104. package/src/extension/hosts/pi/command.ts +1 -1
  105. package/src/extension/hosts/pi/lifecycle.ts +0 -2
  106. package/src/extension/hosts/plugin-runtime.ts +0 -10
  107. package/src/extension/mcp/tool-contract.ts +48 -62
  108. package/src/extension/mcp/workers.ts +66 -27
  109. package/src/integrations/acp/agents.ts +28 -27
  110. package/src/integrations/acp/harnesses/claude.ts +1 -1
  111. package/src/integrations/agent-resources.ts +2 -2
  112. package/src/integrations/hosts/dsh/session.ts +2 -2
  113. package/src/integrations/installation/cli-update.ts +2 -2
  114. package/src/integrations/installation/installers/claude.ts +4 -4
  115. package/src/integrations/installation/installers/qoder.ts +5 -5
  116. package/src/integrations/installation/upgraders/antigravity.ts +57 -15
  117. package/src/integrations/installation/upgraders/claude.ts +1 -4
  118. package/src/integrations/installation/upgraders/codex.ts +85 -15
  119. package/src/integrations/installation/upgraders/dsh.ts +46 -24
  120. package/src/integrations/installation/upgraders/pi.ts +18 -11
  121. package/src/integrations/installation/upgraders/qoder.ts +95 -20
  122. package/src/model/acp.ts +27 -29
  123. package/src/model/agent.ts +80 -16
  124. package/src/model/installation.ts +0 -2
  125. package/src/pbot.ts +2 -2
  126. package/src/services/agents/acp-run.ts +81 -49
  127. package/src/services/agents/agent-run.ts +154 -56
  128. package/src/services/agents/agent-service.ts +204 -133
  129. package/src/services/installation/upgrade-service.ts +1 -5
  130. package/src/storage/acp-files.ts +50 -45
  131. package/src/storage/agent-files.ts +159 -46
  132. package/src/tools/history/contract.ts +12 -12
  133. package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +0 -15
  134. package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +0 -126
  135. package/lib/antigravity-plugin/resources/references/compute-finance.md +0 -22
  136. package/lib/antigravity-plugin/resources/references/compute.md +0 -16
  137. package/lib/antigravity-plugin/resources/references/task-conductor.md +0 -25
  138. package/lib/services/workspace/plugin-releases.d.ts +0 -15
  139. package/lib/services/workspace/plugin-releases.js +0 -126
  140. package/resources/references/compute-finance.md +0 -22
  141. package/resources/references/compute.md +0 -16
  142. package/resources/references/task-conductor.md +0 -25
  143. package/src/services/workspace/plugin-releases.ts +0 -121
@@ -1,22 +1,21 @@
1
- import { existsSync, mkdirSync, readdirSync, rmSync } from "node:fs";
1
+ import { existsSync, mkdirSync, readdirSync, rmdirSync, rmSync, unlinkSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { canonical, object } from "../common/json.js";
5
5
  import { isOneOf, requireThat } from "../common/validation.js";
6
6
  import { readJsonFile, writeJsonFile } from "./atomic-json.js";
7
7
  import { fileId, privateDirectory } from "./file-access.js";
8
- import { agentStates, cycleSources, cycleStates, messageDeliveries } from "../model/agent.js";
9
- import { acpElicitation, acpPermission, acpReference } from "./acp-files.js";
8
+ import { agentStates, cycleStates, messageDeliveries } from "../model/agent.js";
9
+ import { acpConfig, acpInteraction, acpReference } from "./acp-files.js";
10
10
  const text = (v) => typeof v === "string" && v.length > 0;
11
11
  const number = (v) => typeof v === "number" && Number.isFinite(v);
12
- export function descriptor(v) {
13
- requireThat(object(v) && text(v.agentId) && text(v.release) && text(v.workspace) && text(v.cwd) && text(v.parentSessionId) &&
14
- (v.parentLeaf === null || text(v.parentLeaf)) && number(v.createdAt) && object(v.options), "子会话身份无效。");
12
+ export function workerRecord(v) {
13
+ requireThat(object(v) && text(v.agentId) && text(v.release) && text(v.workspace) && text(v.parentSessionId) &&
14
+ text(v.generation) && Number.isSafeInteger(v.sequence) && typeof v.stop === "boolean" && number(v.startedAt) &&
15
+ (v.pid === undefined || (Number.isSafeInteger(v.pid) && Number(v.pid) > 1)) &&
16
+ (v.options === undefined || object(v.options)), "worker 控制记录无效。");
15
17
  fileId(v.agentId);
16
- return v;
17
- }
18
- export function launch(v) {
19
- requireThat(object(v) && text(v.generation) && text(v.name) && Number.isSafeInteger(v.sequence) && typeof v.stop === "boolean" && number(v.startedAt), "子会话启动状态无效。");
18
+ acpConfig(v.acp);
20
19
  return v;
21
20
  }
22
21
  export function message(v) {
@@ -26,18 +25,72 @@ export function message(v) {
26
25
  }
27
26
  export function cycle(v) {
28
27
  requireThat(object(v) && text(v.cycleId) && text(v.generation) && number(v.startedAt) &&
29
- isOneOf(v.state, cycleStates) &&
30
- (v.leaf === null || text(v.leaf)) && Array.isArray(v.requestIds) && v.requestIds.every(text) &&
31
- isOneOf(v.source, cycleSources) && (v.finishedAt === undefined || number(v.finishedAt)), "子会话周期无效。");
28
+ isOneOf(v.state, cycleStates) && Array.isArray(v.requestIds) && v.requestIds.every(text) &&
29
+ (v.finishedAt === undefined || number(v.finishedAt)) &&
30
+ (v.error === undefined || typeof v.error === "string"), "子会话周期无效。");
32
31
  return v;
33
32
  }
34
33
  export function status(v) {
35
34
  requireThat(object(v) && text(v.generation) && isOneOf(v.state, agentStates) &&
36
35
  typeof v.activity === "string" && number(v.updatedAt), "子会话状态无效。");
37
- if (v.cycle)
36
+ if (v.sessionId !== undefined)
37
+ requireThat(v.sessionId === null || text(v.sessionId), "ACP 会话 ID 无效。");
38
+ if (v.capabilities !== undefined) {
39
+ requireThat(object(v.capabilities) &&
40
+ ["resume", "load", "close"].every(key => typeof v.capabilities[key] === "boolean"), "ACP 会话能力无效。");
41
+ }
42
+ if (v.selection !== undefined) {
43
+ requireThat(object(v.selection) &&
44
+ ["provider", "model", "resolvedModel", "thinking"].every(key => v.selection[key] === undefined || text(v.selection[key])), "ACP 模型选择无效。");
45
+ }
46
+ if (v.activeRequestId !== undefined) {
47
+ requireThat(text(v.activeRequestId), "ACP 输入关联无效。");
48
+ fileId(v.activeRequestId);
49
+ }
50
+ if (v.accepted !== undefined)
51
+ requireThat(Array.isArray(v.accepted) && v.accepted.every(text), "已领取请求列表无效。");
52
+ if (v.cycle !== undefined)
38
53
  cycle(v.cycle);
54
+ if (v.error !== undefined)
55
+ requireThat(typeof v.error === "string", "子会话错误信息无效。");
56
+ return v;
57
+ }
58
+ export function outputRecord(v) {
59
+ requireThat(object(v) && text(v.cycleId) && text(v.generation) && number(v.startedAt) && number(v.finishedAt) &&
60
+ isOneOf(v.state, ["completed", "failed", "cancelled", "interrupted"]) &&
61
+ Array.isArray(v.requestIds) && v.requestIds.every(text) &&
62
+ typeof v.text === "string" && (v.error === undefined || typeof v.error === "string"), "子会话输出记录无效。");
63
+ fileId(v.cycleId);
39
64
  return v;
40
65
  }
66
+ export function toDescriptor(record) {
67
+ return {
68
+ agentId: record.agentId,
69
+ release: record.release,
70
+ workspace: record.workspace,
71
+ parentSessionId: record.parentSessionId,
72
+ options: record.options ?? {},
73
+ };
74
+ }
75
+ function tryUnlink(path) {
76
+ try {
77
+ unlinkSync(path);
78
+ }
79
+ catch (error) {
80
+ if (error.code !== "ENOENT")
81
+ throw error;
82
+ }
83
+ }
84
+ function tryRmdir(path) {
85
+ try {
86
+ rmdirSync(path);
87
+ }
88
+ catch (error) {
89
+ const code = error.code;
90
+ if (code !== "ENOENT" && code !== "ENOTEMPTY" && code !== "EEXIST")
91
+ throw error;
92
+ }
93
+ }
41
94
  export class AgentFiles {
42
95
  root;
43
96
  #failure;
@@ -72,56 +125,105 @@ export class AgentFiles {
72
125
  }
73
126
  requireThat(published, "子会话文件已存在。");
74
127
  }
128
+ remove(id, path) {
129
+ tryUnlink(join(this.directory(id), path));
130
+ }
75
131
  create(value, run, acp) {
76
132
  this.check();
77
133
  acpReference(acp);
78
134
  mkdirSync(this.root, { recursive: true, mode: 0o700 });
79
135
  mkdirSync(this.directory(value.agentId), { mode: 0o700 });
80
- for (const dir of ["inbox", "completions", "reports", "permissions", "elicitations"])
81
- privateDirectory(this.directory(value.agentId), dir);
82
- this.write(value.agentId, "descriptor.json", value, descriptor, true);
83
- this.write(value.agentId, "launch.json", run, launch, true);
84
- this.write(value.agentId, "acp-session.json", acp, acpReference, true);
136
+ const hasOptions = Object.keys(value.options).length > 0;
137
+ const record = {
138
+ agentId: value.agentId,
139
+ release: value.release,
140
+ workspace: value.workspace,
141
+ parentSessionId: value.parentSessionId,
142
+ generation: run.generation,
143
+ sequence: run.sequence,
144
+ stop: run.stop,
145
+ startedAt: run.startedAt,
146
+ acp: {
147
+ backend: acp.backend,
148
+ command: acp.command,
149
+ args: acp.args,
150
+ ...(acp.env ? { env: acp.env } : {}),
151
+ ...(acp.permission ? { permission: acp.permission } : {}),
152
+ },
153
+ ...(hasOptions ? { options: value.options } : {}),
154
+ };
155
+ this.write(value.agentId, "worker.json", record, workerRecord, true);
156
+ }
157
+ worker(id) {
158
+ return this.read(id, "worker.json", workerRecord);
85
159
  }
86
160
  list() {
87
161
  if (!existsSync(this.root))
88
162
  return [];
89
163
  return readdirSync(this.root, { withFileTypes: true }).filter(e => e.isDirectory() && !e.name.startsWith(".")).flatMap(e => {
90
- const d = this.optional(e.name, "descriptor.json", descriptor);
91
- return d ? [d] : [];
164
+ const record = this.optional(e.name, "worker.json", workerRecord);
165
+ return record ? [record] : [];
92
166
  });
93
167
  }
94
168
  messages(id) {
95
- return readdirSync(join(this.directory(id), "inbox")).filter(n => n.endsWith(".json"))
169
+ const dir = join(this.directory(id), "inbox");
170
+ if (!existsSync(dir))
171
+ return [];
172
+ return readdirSync(dir).filter(n => n.endsWith(".json"))
96
173
  .map(n => this.read(id, "inbox/" + n, message)).sort((a, b) => a.sequence - b.sequence);
97
174
  }
98
- completions(id) {
99
- return readdirSync(join(this.directory(id), "completions")).filter(n => n.endsWith(".json"))
100
- .map(n => this.read(id, "completions/" + n, cycle)).sort((a, b) => (a.finishedAt ?? 0) - (b.finishedAt ?? 0));
175
+ removeMessage(id, requestId) {
176
+ fileId(requestId);
177
+ const dir = join(this.directory(id), "inbox");
178
+ tryUnlink(join(dir, requestId + ".json"));
179
+ tryRmdir(dir);
101
180
  }
102
- /** Permission requests of a generation that have no reply yet. */
103
- pendingPermissions(id, generation) {
104
- const dir = join(this.directory(id), "permissions");
105
- if (!existsSync(dir))
106
- return [];
107
- const names = readdirSync(dir);
108
- return names.filter(n => n.endsWith(".json") && !n.endsWith("-reply.json") && !names.includes(n.slice(0, -5) + "-reply.json"))
109
- .map(n => this.read(id, "permissions/" + n, acpPermission)).filter(item => item.generation === generation);
181
+ output(id) {
182
+ return this.optional(id, "output.json", outputRecord);
110
183
  }
111
- /** Elicitation requests (forms, choices, text inputs, URL confirmations) of a generation that have no reply yet. */
112
- pendingElicitations(id, generation) {
113
- const dir = join(this.directory(id), "elicitations");
184
+ pendingInteractions(id, generation) {
185
+ const dir = join(this.directory(id), "interactions");
114
186
  if (!existsSync(dir))
115
187
  return [];
116
188
  const names = readdirSync(dir);
117
189
  return names.filter(n => n.endsWith(".json") && !n.endsWith("-reply.json") && !names.includes(n.slice(0, -5) + "-reply.json"))
118
- .map(n => this.read(id, "elicitations/" + n, acpElicitation)).filter(item => item.generation === generation);
190
+ .map(n => this.read(id, "interactions/" + n, acpInteraction)).filter(item => item.generation === generation);
191
+ }
192
+ removeInteraction(id, requestId) {
193
+ fileId(requestId);
194
+ const dir = join(this.directory(id), "interactions");
195
+ tryUnlink(join(dir, requestId + ".json"));
196
+ tryUnlink(join(dir, requestId + "-reply.json"));
197
+ tryRmdir(dir);
198
+ }
199
+ clearTransient(id) {
200
+ const base = this.directory(id);
201
+ if (!existsSync(base))
202
+ return;
203
+ rmSync(join(base, "inbox"), { recursive: true, force: true });
204
+ rmSync(join(base, "interactions"), { recursive: true, force: true });
205
+ tryUnlink(join(base, "acp-answer.json"));
206
+ }
207
+ removeWorker(id) {
208
+ rmSync(this.directory(id), { recursive: true, force: true });
209
+ tryRmdir(this.root);
119
210
  }
120
211
  ensureSubdirectory(id, name) {
121
212
  privateDirectory(this.directory(id), name);
122
213
  }
123
214
  reference(id) {
124
- return this.read(id, "acp-session.json", acpReference);
215
+ const w = this.worker(id);
216
+ const saved = this.optional(id, "state.json", status);
217
+ return {
218
+ host: "acp",
219
+ backend: w.acp.backend,
220
+ command: w.acp.command,
221
+ args: w.acp.args,
222
+ ...(w.acp.env ? { env: w.acp.env } : {}),
223
+ ...(w.acp.permission ? { permission: w.acp.permission } : {}),
224
+ sessionId: saved?.sessionId ?? null,
225
+ ...(saved?.capabilities ? { capabilities: saved.capabilities } : {}),
226
+ };
125
227
  }
126
228
  /** Short controller edits are serialized; an abandoned lock fails closed. */
127
229
  control(work) {
@@ -145,14 +247,16 @@ export class AgentFiles {
145
247
  }
146
248
  enqueue(id, text, delivery, files = [], requestId = randomUUID()) {
147
249
  fileId(requestId);
148
- const run = this.read(id, "launch.json", launch), previous = this.optional(id, "inbox/" + requestId + ".json", message);
250
+ const w = this.worker(id);
251
+ const previous = this.optional(id, "inbox/" + requestId + ".json", message);
149
252
  if (previous) {
150
- requireThat(previous.generation === run.generation && previous.message === text && previous.delivery === delivery && canonical(previous.files) === canonical(files), "请求 ID 已被不同输入使用。");
253
+ requireThat(previous.generation === w.generation && previous.message === text && previous.delivery === delivery && canonical(previous.files) === canonical(files), "请求 ID 已被不同输入使用。");
151
254
  return previous;
152
255
  }
153
- run.sequence++;
154
- this.write(id, "launch.json", run, launch);
155
- const value = { requestId, generation: run.generation, sequence: run.sequence, message: text, delivery, files };
256
+ w.sequence++;
257
+ this.write(id, "worker.json", w, workerRecord);
258
+ this.ensureSubdirectory(id, "inbox");
259
+ const value = { requestId, generation: w.generation, sequence: w.sequence, message: text, delivery, files };
156
260
  this.write(id, "inbox/" + value.requestId + ".json", value, message, true);
157
261
  return value;
158
262
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "personal-bot-antigravity-plugin",
3
- "version": "0.3.6",
3
+ "version": "0.4.0",
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.6",
4
+ "version": "0.4.0",
5
5
  "description": "Workspace materials, skills, and cross-harness MCP worker delegation.",
6
6
  "repository": "https://github.com/realqiyan/personal-bot"
7
7
  }
@@ -1,11 +1,7 @@
1
1
  # 协调者
2
2
 
3
- 对本次交付负责,沿用已有约定,完成用户需要的结果。
3
+ 委派专家时写明目标、相关资料、约束和交付要求;涉及文件修改时明确修改范围,多人并行写入时划分文件责任。
4
4
 
5
- 普通问答直接完成。委派专家时写明目标、相关资料、约束和交付要求。周期、重复流程、DAG 或会话退出后仍需执行的任务,先读 `<resourceRoot>/references/task-conductor.md`。
5
+ 由你汇总专家结果、整合正式资料并处理口径差异。需要独立复核时,另开专家会话并提供待查内容与具体问题。
6
6
 
7
- 汇总专家结果并整合正式资料。委派包含文件修改时说明修改范围,多人写入时划分文件责任;合并不同结果时处理口径差异和未解决的问题。
8
-
9
- 需要独立复核时,另开专家会话,提供待检查内容、相关资料和具体问题。
10
-
11
- 失败或中断后说明已完成部分、剩余工作和阻碍。需要用户决定的事项由你汇总说明。
7
+ 失败或中断后说明已完成部分、剩余工作与阻碍;需要用户决定的事项由你汇总提出。
@@ -1,7 +1,7 @@
1
1
  # 通用专家
2
2
 
3
- 完成本次委派,使用相关资料和技能。交回结果、需要说明的问题及产物路径。独立复核时自行检查,说明发现的问题和不确定之处。
3
+ 完成本次委派,使用相关资料和技能,交回结果、问题说明及产物路径;独立复核时自行核查并指出问题与不确定之处。
4
4
 
5
- 默认交回报告,由主会话整合正式资料;委派包含文件修改时直接完成,并说明变更。
5
+ 默认交回报告,由主会话整合正式资料;委派包含文件修改时直接修改并说明变更。
6
6
 
7
- 可自主诊断工具和环境问题。需要主会话或用户协助时,交回已有结果和具体阻碍,继续不受影响的工作。不创建子专家或外部任务,不管理团队;需要其他协作者或持久执行时向主会话提出建议。
7
+ 可自主排查工具和环境问题;受阻且需要主会话或用户协助时,交回已有结果与具体阻碍。不递归委派其他助手;需要额外协作者时向主会话建议。
@@ -1,2 +1 @@
1
- 未指定其他程序时,默认由当前宿主直接处理或使用当前宿主原生子代理。需要委派其他程序(或按工作区 `AGENTS.md`、`agents/coordinator.md` 分工约定)时,使用 `pbot` MCP 的 `worker_*` 工具(先 `worker_create` 再 `worker_request`),并传入当前 `workspaceRoot` 作为 `workspace`。调用 `.pbot/mcp.json` 中统一注册的工作区 MCP 时,使用 `workspace_mcp_discover` 与 `workspace_mcp_call`(可与宿主原生 MCP 同时使用)。
2
- 用户要求更新工作区历史摘要时,运行 `pbot history summary --workspace "<workspaceRoot>"`。需要按当前版本调用时,读取 `resourceRoot/../package.json` 的 `version`,用 `npx --yes personal-bot@<version>` 替换命令中的 `pbot`。
1
+ 未指定其他程序时,默认直接处理或使用当前宿主原生子代理;需要委派其他程序(或按工作区 `AGENTS.md`、`agents/coordinator.md` 分工约定)时,使用 `pbot` MCP 的 `worker_*` 工具。调用 `.pbot/mcp.json` 中的工作区 MCP 用 `workspace_mcp_discover` / `workspace_mcp_call`,回溯旧讨论用 `history_search` / `history_read`;更新历史摘要运行 `pbot history summary --workspace "<workspaceRoot>"`(未安装全局 `pbot` 时用 `node "<resourceRoot>/../lib/extension/cli.js"` 替换 `pbot`)。
@@ -1,31 +1,27 @@
1
1
  # Personal Bot
2
2
 
3
- 按用户请求和已有约定推进工作,常规选择自行决定。只有缺失信息会改变目标或关键结果时才提问,并继续不受影响的工作。
3
+ 按用户请求和已有约定推进工作,常规选择自行决定;只有缺失信息会改变目标或关键结果时才提问。超时、取消或断连后,先查状态再决定是否重试,避免重复执行。
4
4
 
5
- ## 工作方式
5
+ ## 资料与工作区
6
6
 
7
- - 回查或续做项目时,按用户的称呼从根 `AGENTS.md` 找到项目正文;需要更多线索时按主题或交付物名称搜索。
8
- - 操作后查看结果。超时、取消或断连后,先查状态再决定是否重试,避免重复执行。
9
- - 优先复用工作区已接入的 CLI/MCP:工作区共享 MCP 定义在 `.pbot/mcp.json`(可通过宿主原生工具或 `pbot` MCP 的 `workspace_mcp_discover` / `workspace_mcp_call` 调用),也可同时使用宿主原生 MCP。接入或排障使用 `provider-connections` 技能;需要数据口径或使用限制时读取 `providers/<id>/GUIDE.md`。认证使用原生登录或环境变量引用,资料中不保存凭据值。
10
-
11
- ## 资料与环境
12
-
13
- 沿用已有工作区约定;新资料按下列用途组织,正文维护一份,其他位置用引用连接。
7
+ 回查或续做项目时,按用户称呼从根 `AGENTS.md` 找到项目入口,必要时按主题或交付物名称搜索。已有工作区布局与约定优先;新资料按下列用途组织,同主题正文维护一份,其他位置用引用连接:
14
8
 
15
9
  | 路径 | 用途 |
16
10
  | --- | --- |
17
11
  | `AGENTS.md` | 资料导航与已确认的工作区约定 |
18
12
  | `areas/<领域>/` | 长期目标、约束、决策与复盘 |
19
- | `projects/<名称>/` | 任务定义、结论与交付物;源码、依赖和测试 |
13
+ | `projects/<名称>/` | 任务定义、结论、交付物与源码 |
20
14
  | `knowledge/<主题>/` | 可跨任务复用的概念、方法与口径 |
21
- | `providers/AGENTS.md`、`providers/<id>/GUIDE.md` | 能力导航与使用手册 |
22
- | `scratch/` | 临时脚本、查询与计算数据、下载及运行环境 |
15
+ | `providers/` | `AGENTS.md`(能力导航)与 `<id>/GUIDE.md`(使用手册) |
16
+ | `scratch/` | 临时脚本、中间数据、下载与运行环境 |
23
17
  | `agents/` | `coordinator.md`、`general-purpose.md` 的职责补充 |
24
- | `.agents/skills/<名称>/SKILL.md` | 工作区自有专业方法(跨程序通用;正文描述意图与通用操作,不写死单一宿主的私有工具名) |
25
- | `.pbot/mcp.json` | 工作区共享 MCP 服务清单(不含凭据值,凭据使用 `${ENV_VAR}` 或原生登录) |
18
+ | `.agents/skills/<名称>/SKILL.md` | 工作区自有技能(跨宿主通用) |
19
+ | `.pbot/mcp.json` | 工作区共享 MCP 服务清单 |
26
20
 
27
21
  保存有后续用途的结论、方法、决策和产物,普通问答不逐轮存档;更新、归集或整理资料时使用 `project-maintenance` 技能。保留用户资料、历史记录和备份。
28
22
 
29
- 环境上下文给出 `host`、`workspaceRoot`(资料工作区根目录)和 `resourceRoot`(包内资料根目录)。资料路径相对工作区根目录,命令与文件工具按实际 cwd 解析。需要 Python 计算时先读 `<resourceRoot>/references/compute.md`,涉及技术指标或回测另读 `<resourceRoot>/references/compute-finance.md`;计算、构建和测试遵循项目声明的环境。
23
+ ## 工具与环境
24
+
25
+ 优先复用工作区已接入的 CLI 与 MCP;接入或排障使用 `provider-connections` 技能,查数据口径或限制读 `providers/<id>/GUIDE.md`。资料与配置不保存明文凭据,使用环境变量引用或原生登录。计算、构建和测试遵循项目声明的环境。
30
26
 
31
- 答复先给结论,按需补充说明和产物路径。直接回答当前问题,不追加空泛的免责声明或无根据的推论;关键未知、前提和风险说清一次。数值注明对象、期间、单位与口径。
27
+ 环境上下文给出 `host`、`workspaceRoot`(资料工作区根目录)和 `resourceRoot`(包内资料根目录);资料路径相对 `workspaceRoot`,命令与文件工具按实际 cwd 解析。答复先给结论与产物路径,关键未知、前提和风险说清一次,数值注明对象、期间、单位与口径。
@@ -15,7 +15,7 @@ description: 接入或修复工作区共享 MCP 与原生 CLI/MCP,核对认证
15
15
 
16
16
  接入新 MCP 前先判断归属;边界不明确或用户未说明作用域时,写入前先向用户确认放工作区共享还是当前宿主原生:
17
17
 
18
- - **工作区共享 MCP(`.pbot/mcp.json`)**:归属当前工作区业务、需要跨宿主(Pi、dsh、Claude Code、Antigravity、Codex 及 ACP worker)共用,使用 stdio 或 Streamable HTTP + 环境变量/本地凭据,纯 `tools/list` + `tools/call` 请求-响应且可并发连接的服务。
18
+ - **工作区共享 MCP(`.pbot/mcp.json`)**:归属当前工作区业务、需要跨宿主(Pi、dsh、Claude Code、Antigravity、Codex、Qoder CLI 及 ACP worker)共用,使用 stdio 或 Streamable HTTP + 环境变量/本地凭据,纯 `tools/list` + `tools/call` 请求-响应且可并发连接的服务。
19
19
  - **宿主原生 MCP(全局或项目级)**:满足以下任一条件时走当前宿主原生入口,不写入 `.pbot/mcp.json`:
20
20
  1. 跨项目通用的本机全局基础设施或开发工具(如浏览器调试、全局调度);
21
21
  2. 依赖宿主浏览器交互式 OAuth 登录;
@@ -27,14 +27,14 @@ description: 接入或修复工作区共享 MCP 与原生 CLI/MCP,核对认证
27
27
 
28
28
  不保存明文凭据,使用 `${ENV_VAR}` 引用,保留无关项,不能使用保留名 `pbot`:
29
29
 
30
- - **查看**:`pbot mcp list --workspace <workspaceRoot>` 或(轻插件宿主)调用 `workspace_mcp_discover`
31
- - **新增 / 更新 stdio**:`pbot mcp add <name> --workspace <workspaceRoot> [--env K=\${VAR}] [--cwd .] [--description "..."] -- <command> [args...]`
32
- - **新增 / 更新 HTTP**:`pbot mcp add <name> --workspace <workspaceRoot> --url https://... [--header Authorization="Bearer \${TOKEN}"] [--description "..."]`
33
- - **删除**:`pbot mcp remove <name> --workspace <workspaceRoot>`
30
+ - **查看**:`pbot mcp list --workspace "<workspaceRoot>"`(若当前环境提供 `workspace_mcp_discover` 也可直接查询)
31
+ - **新增 / 更新 stdio**:`pbot mcp add <name> --workspace "<workspaceRoot>" [--env 'K=${VAR}'] [--cwd .] [--description "..."] -- <command> [args...]`
32
+ - **新增 / 更新 HTTP**:`pbot mcp add <name> --workspace "<workspaceRoot>" --url https://... [--header 'Authorization=Bearer ${TOKEN}'] [--description "..."]`
33
+ - **删除**:`pbot mcp remove <name> --workspace "<workspaceRoot>"`
34
34
 
35
35
  生效方式(原生挂载与桥接二选一,不重复暴露):
36
36
  - Pi 执行 `/reload`、dsh 重启会话后由宿主直接原生挂载(不暴露 `workspace_mcp_*`);
37
- - 轻插件宿主与任意 MCP 宿主通过 `workspace_mcp_discover` / `workspace_mcp_call` 桥接,即改即生效,无需重启;
37
+ - 通过 `workspace_mcp_discover` / `workspace_mcp_call` 桥接的宿主即改即生效,无需重启;
38
38
  - ACP worker 在下次新建或恢复会话时自动加载最新 `.pbot/mcp.json`。
39
39
 
40
40
  ## 宿主原生 MCP
@@ -43,6 +43,7 @@ description: 接入或修复工作区共享 MCP 与原生 CLI/MCP,核对认证
43
43
  - **`host = dsh`**:通过原生界面或 profile 配置管理(注意同一 profile 可能被多工作区共用)。
44
44
  - **`host = claude`**:`claude mcp add --scope project --transport http <server> <url>`(写入 `.mcp.json`),改完后请用户在会话中用 `/mcp` 核对认证与工具。
45
45
  - **`host = antigravity`**:全局使用 `agy mcp add <name> <commandOrUrl> [args...]` / `agy mcp remove <name>`(管理 `~/.gemini/config/mcp_config.json`),通过 `agy mcp list` 或 UI 面板核对。
46
+ - **其他宿主(如 `codex`、`qoder`)**:使用该宿主自身的原生 MCP 命令或配置入口管理。
46
47
 
47
48
  ## 验证与手册
48
49
 
@@ -15,7 +15,3 @@
15
15
  ## 项目速查
16
16
 
17
17
  项目默认入口为 `projects/<目录名>/README.md`。
18
-
19
- ## 宿主分工偏好(可选)
20
-
21
- 可在此或 `agents/coordinator.md` 中约定不同任务优先使用的 Harness(如编码、分析、探索分别优先哪个 ACP `backend`)。
@@ -6,21 +6,29 @@ disable-model-invocation: true
6
6
 
7
7
  # Personal Bot 工作区
8
8
 
9
- 从当前 Antigravity 工作区根目录,通过 `run_command` 执行对应命令。`<plugin-root>` 为本 `SKILL.md` 路径向上两级目录(即去掉尾部 `/skills/pbot/SKILL.md` 后的目录)。
9
+ 从当前 Antigravity 工作区根目录,通过 `run_command` 执行对应命令。`<plugin-root>` 为本 `SKILL.md` 路径向上两级目录(去掉尾部 `/skills/pbot/SKILL.md`)。
10
+
11
+ ## 初始化与状态
10
12
 
11
13
  ```sh
12
14
  node "<plugin-root>/lib/plugin.js" antigravity init
13
15
  node "<plugin-root>/lib/plugin.js" antigravity status
14
16
  ```
15
17
 
16
- 根据用户参数选择一条:`init` 补建资料目录与根 `AGENTS.md` 并启用工作区,`status` 只查看工作区及当前配置状态。省略参数时查看状态。返回命令的实际结果和需要处理的错误。
18
+ `init` 补建资料目录与根 `AGENTS.md` 并启用工作区,`status` 查看工作区及配置状态;省略参数时执行 `status`。
19
+
20
+ ## 历史管理与检索
21
+
22
+ `--workspace` 传入当前会话的 `workspaceRoot`(工作区未启用时使用当前工作区根目录)。支持 `history status|list|summary|migrate|search|read`,保留用户指定参数(迁移预览加 `--dry-run`):
17
23
 
18
- 用户要求整理历史时,在当前工作区执行 `pbot history summary --workspace "<workspaceRoot>"`。检查待处理数量用 `history status`,列维度用 `history list`,搜索与读取用 `history search`、`history read`,迁移预览用 `history migrate --dry-run`。保留用户指定的参数。
24
+ ```sh
25
+ pbot history summary --workspace "<workspaceRoot>"
26
+ ```
19
27
 
20
- 首次使用或全局 CLI 缺少该子命令时,可直接运行随插件安装的 CLI:
28
+ 未安装全局 `pbot` 或版本不匹配时,直接运行随插件打包的 CLI:
21
29
 
22
30
  ```sh
23
- node "<plugin-root>/lib/extension/workspace-cli.js" history summary --workspace "<workspaceRoot>"
31
+ node "<plugin-root>/lib/extension/cli.js" history summary --workspace "<workspaceRoot>"
24
32
  ```
25
33
 
26
- 也可读取 `<plugin-root>/package.json` 的 `version`,运行 `npx --yes personal-bot@<version> history summary --workspace "<workspaceRoot>"`。
34
+ 返回命令的实际结果和需要处理的错误。
@@ -15,7 +15,7 @@ description: 接入或修复工作区共享 MCP 与原生 CLI/MCP,核对认证
15
15
 
16
16
  接入新 MCP 前先判断归属;边界不明确或用户未说明作用域时,写入前先向用户确认放工作区共享还是当前宿主原生:
17
17
 
18
- - **工作区共享 MCP(`.pbot/mcp.json`)**:归属当前工作区业务、需要跨宿主(Pi、dsh、Claude Code、Antigravity、Codex 及 ACP worker)共用,使用 stdio 或 Streamable HTTP + 环境变量/本地凭据,纯 `tools/list` + `tools/call` 请求-响应且可并发连接的服务。
18
+ - **工作区共享 MCP(`.pbot/mcp.json`)**:归属当前工作区业务、需要跨宿主(Pi、dsh、Claude Code、Antigravity、Codex、Qoder CLI 及 ACP worker)共用,使用 stdio 或 Streamable HTTP + 环境变量/本地凭据,纯 `tools/list` + `tools/call` 请求-响应且可并发连接的服务。
19
19
  - **宿主原生 MCP(全局或项目级)**:满足以下任一条件时走当前宿主原生入口,不写入 `.pbot/mcp.json`:
20
20
  1. 跨项目通用的本机全局基础设施或开发工具(如浏览器调试、全局调度);
21
21
  2. 依赖宿主浏览器交互式 OAuth 登录;
@@ -27,14 +27,14 @@ description: 接入或修复工作区共享 MCP 与原生 CLI/MCP,核对认证
27
27
 
28
28
  不保存明文凭据,使用 `${ENV_VAR}` 引用,保留无关项,不能使用保留名 `pbot`:
29
29
 
30
- - **查看**:`pbot mcp list --workspace <workspaceRoot>` 或(轻插件宿主)调用 `workspace_mcp_discover`
31
- - **新增 / 更新 stdio**:`pbot mcp add <name> --workspace <workspaceRoot> [--env K=\${VAR}] [--cwd .] [--description "..."] -- <command> [args...]`
32
- - **新增 / 更新 HTTP**:`pbot mcp add <name> --workspace <workspaceRoot> --url https://... [--header Authorization="Bearer \${TOKEN}"] [--description "..."]`
33
- - **删除**:`pbot mcp remove <name> --workspace <workspaceRoot>`
30
+ - **查看**:`pbot mcp list --workspace "<workspaceRoot>"`(若当前环境提供 `workspace_mcp_discover` 也可直接查询)
31
+ - **新增 / 更新 stdio**:`pbot mcp add <name> --workspace "<workspaceRoot>" [--env 'K=${VAR}'] [--cwd .] [--description "..."] -- <command> [args...]`
32
+ - **新增 / 更新 HTTP**:`pbot mcp add <name> --workspace "<workspaceRoot>" --url https://... [--header 'Authorization=Bearer ${TOKEN}'] [--description "..."]`
33
+ - **删除**:`pbot mcp remove <name> --workspace "<workspaceRoot>"`
34
34
 
35
35
  生效方式(原生挂载与桥接二选一,不重复暴露):
36
36
  - Pi 执行 `/reload`、dsh 重启会话后由宿主直接原生挂载(不暴露 `workspace_mcp_*`);
37
- - 轻插件宿主与任意 MCP 宿主通过 `workspace_mcp_discover` / `workspace_mcp_call` 桥接,即改即生效,无需重启;
37
+ - 通过 `workspace_mcp_discover` / `workspace_mcp_call` 桥接的宿主即改即生效,无需重启;
38
38
  - ACP worker 在下次新建或恢复会话时自动加载最新 `.pbot/mcp.json`。
39
39
 
40
40
  ## 宿主原生 MCP
@@ -43,6 +43,7 @@ description: 接入或修复工作区共享 MCP 与原生 CLI/MCP,核对认证
43
43
  - **`host = dsh`**:通过原生界面或 profile 配置管理(注意同一 profile 可能被多工作区共用)。
44
44
  - **`host = claude`**:`claude mcp add --scope project --transport http <server> <url>`(写入 `.mcp.json`),改完后请用户在会话中用 `/mcp` 核对认证与工具。
45
45
  - **`host = antigravity`**:全局使用 `agy mcp add <name> <commandOrUrl> [args...]` / `agy mcp remove <name>`(管理 `~/.gemini/config/mcp_config.json`),通过 `agy mcp list` 或 UI 面板核对。
46
+ - **其他宿主(如 `codex`、`qoder`)**:使用该宿主自身的原生 MCP 命令或配置入口管理。
46
47
 
47
48
  ## 验证与手册
48
49
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "personal-bot",
3
- "version": "0.3.6",
3
+ "version": "0.4.0",
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.6 \"$@\"",
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.0 \"$@\"",
8
8
  "pbot",
9
9
  "mcp"
10
10
  ],
11
11
  "env": {
12
12
  "PBOT_HOST": "codex",
13
- "PBOT_PLUGIN_VERSION": "0.3.6"
13
+ "PBOT_PLUGIN_VERSION": "0.4.0"
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.6 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.6 \"$@\"' pbot plugin codex hook",
8
+ "command": "PBOT_PLUGIN_VERSION=0.4.0 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.0 \"$@\"' 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.6 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.6 \"$@\"' pbot plugin codex hook",
19
+ "command": "PBOT_PLUGIN_VERSION=0.4.0 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.0 \"$@\"' 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.6 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.6 \"$@\"' pbot plugin codex hook",
30
+ "command": "PBOT_PLUGIN_VERSION=0.4.0 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.0 \"$@\"' pbot plugin codex hook",
31
31
  "timeout": 120
32
32
  }
33
33
  ]
@@ -4,6 +4,6 @@ description: 初始化 Personal Bot 工作区、查看状态、搜索归档或
4
4
  disable-model-invocation: true
5
5
  ---
6
6
 
7
- 使用当前会话的 `workspaceRoot` 作为 `--workspace`。省略子命令时使用 `status`。可执行 `init`、`status`、`history status|list|summary|migrate|search|read`。保留用户指定的维度、模型和筛选参数。
7
+ `--workspace` 传入当前会话的 `workspaceRoot`(工作区未启用时使用当前工作区根目录)。省略子命令时使用 `status`。可执行 `init`、`status`、`history status|list|summary|migrate|search|read`,保留用户指定的维度、模型和筛选参数。
8
8
 
9
- 运行 `npx --yes personal-bot@0.3.6 <子命令> --workspace "<workspaceRoot>"`。如果 `pbot --at-least 0.3.6` 返回 0,也可以用 `pbot` 执行同一条命令。返回实际结果。
9
+ 若 `pbot --at-least 0.4.0` 返回 0,运行 `pbot <子命令> --workspace "<workspaceRoot>"`;否则运行 `npx --yes personal-bot@0.4.0 <子命令> --workspace "<workspaceRoot>"`。返回实际结果。
@@ -1,5 +1,5 @@
1
1
  import { AgentFiles } from "../../storage/agent-files.js";
2
- import type { AcpInput, AcpAnswer } from "../../model/acp.js";
2
+ import type { AcpAnswer, AcpInput } from "../../model/acp.js";
3
3
  export declare function acpMember(): Promise<{
4
4
  files: AgentFiles;
5
5
  d: import("../../model/agent.js").AgentDescriptor;
@@ -1,7 +1,7 @@
1
1
  import { dirname } from "node:path";
2
2
  import { realpathSync } from "node:fs";
3
- import { AgentFiles, descriptor, launch } from "../../storage/agent-files.js";
4
- import { acpInput, acpAnswer } from "../../storage/acp-files.js";
3
+ import { AgentFiles, status, toDescriptor } from "../../storage/agent-files.js";
4
+ import { acpAnswer } from "../../storage/acp-files.js";
5
5
  import { requireThat } from "../../common/validation.js";
6
6
  import { packageVersion, releaseLine } from "../../common/version.js";
7
7
  import { loadWorkspaceContext } from "../../integrations/agent-resources.js";
@@ -11,15 +11,15 @@ export async function acpMember() {
11
11
  requireThat(id && directory && generation, "缺少 ACP 成员启动身份。");
12
12
  const files = new AgentFiles(dirname(realpathSync(directory)));
13
13
  requireThat(files.directory(id) === realpathSync(directory), "ACP 成员目录不匹配。");
14
- const d = files.read(id, "descriptor.json", descriptor);
14
+ const d = toDescriptor(files.worker(id));
15
15
  requireThat(d.agentId === id && releaseLine(d.release) === releaseLine(packageVersion), "ACP 成员身份或版本无效。");
16
16
  const configuration = await readWorkspaceConfig(d.workspace);
17
17
  requireThat(configuration.enabled, workspaceDisabledMessage(configuration));
18
18
  const features = workspaceFeatures(configuration);
19
19
  const check = () => {
20
20
  files.check();
21
- const run = files.read(id, "launch.json", launch);
22
- requireThat(run.generation === generation && (!run.stop || process.env.PBOT_ACP_VALIDATE === "1"), "ACP 成员已停止或启动代次变化。");
21
+ const w = files.worker(id);
22
+ requireThat(w.generation === generation && (!w.stop || process.env.PBOT_ACP_VALIDATE === "1"), "ACP 成员已停止或启动代次变化。");
23
23
  };
24
24
  const context = async () => {
25
25
  const reference = files.reference(id);
@@ -27,16 +27,17 @@ export async function acpMember() {
27
27
  const loaded = await loadWorkspaceContext({ host, root: d.workspace, role: "general-purpose" });
28
28
  return { workspace: loaded.workspace, role: loaded.role, environment: JSON.stringify(loaded.environment) };
29
29
  };
30
- return { files, d, id, generation, configuration, features, check, context,
30
+ return {
31
+ files, d, id, generation, configuration, features, check, context,
31
32
  input() {
32
33
  check();
33
- const input = files.read(id, "acp-input.json", acpInput);
34
- requireThat(input.generation === generation, "ACP 输入代次无效。");
35
- return input;
34
+ const saved = files.read(id, "state.json", status);
35
+ requireThat(saved.generation === generation && typeof saved.activeRequestId === "string" && saved.activeRequestId.length > 0, "ACP 输入代次无效。");
36
+ return { generation, requestId: saved.activeRequestId };
36
37
  },
37
38
  answer(input, state, answer, error) {
38
39
  // A stop can race the native terminal event. The current generation may still seal its result.
39
- if (files.read(id, "launch.json", launch).generation !== generation)
40
+ if (files.worker(id).generation !== generation)
40
41
  return;
41
42
  files.write(id, "acp-answer.json", { ...input, state, answer, ...(error ? { error } : {}) }, acpAnswer);
42
43
  },