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.
Files changed (120) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +2 -2
  3. package/README.md +4 -1
  4. package/README.zh-CN.md +4 -1
  5. package/docs/README.md +2 -3
  6. package/docs/architecture/design.md +41 -2
  7. package/docs/architecture/extensibility.md +3 -3
  8. package/docs/architecture/model-context.md +10 -4
  9. package/docs/architecture/principles.md +2 -2
  10. package/docs/guides/cross-harness-workers.md +27 -2
  11. package/docs/guides/workspace-configuration.md +3 -1
  12. package/docs/hosts/claude-code.md +1 -1
  13. package/docs/hosts/codex-qoder.md +3 -1
  14. package/hooks/hooks.json +3 -0
  15. package/lib/antigravity-plugin/lib/extension/acp-worker.js +22 -6
  16. package/lib/antigravity-plugin/lib/extension/cli.js +169 -95
  17. package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +3 -1
  18. package/lib/antigravity-plugin/lib/extension/mcp.js +163 -119
  19. package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +4 -2
  20. package/lib/antigravity-plugin/lib/integrations/agent-resources.js +23 -5
  21. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.js +0 -1
  22. package/lib/antigravity-plugin/lib/integrations/hosts/claude/adapter.js +1 -2
  23. package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.d.ts +2 -1
  24. package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.js +12 -13
  25. package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.js +4 -7
  26. package/lib/antigravity-plugin/lib/model/worker-template.d.ts +21 -0
  27. package/lib/antigravity-plugin/lib/model/worker-template.js +1 -0
  28. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.js +1 -1
  29. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.js +6 -3
  30. package/lib/antigravity-plugin/lib/services/history/summary-runner.js +3 -3
  31. package/lib/antigravity-plugin/lib/services/workspace/worker-templates.d.ts +17 -0
  32. package/lib/antigravity-plugin/lib/services/workspace/worker-templates.js +88 -0
  33. package/lib/antigravity-plugin/lib/storage/history-files.js +3 -2
  34. package/lib/antigravity-plugin/package.json +1 -1
  35. package/lib/antigravity-plugin/plugin.json +2 -2
  36. package/lib/antigravity-plugin/resources/agents/coordinator.md +2 -4
  37. package/lib/antigravity-plugin/resources/agents/general-purpose.md +2 -4
  38. package/lib/antigravity-plugin/resources/prompts/history-monthly-summary.md +6 -11
  39. package/lib/antigravity-plugin/resources/prompts/history-summary.md +6 -11
  40. package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -1
  41. package/lib/antigravity-plugin/resources/prompts/workspace.md +16 -23
  42. package/lib/antigravity-plugin/resources/skills/project-maintenance/SKILL.md +14 -21
  43. package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +23 -36
  44. package/lib/antigravity-plugin/resources/templates/workspace-agents.md +5 -13
  45. package/lib/antigravity-plugin/skills/pbot/SKILL.md +6 -23
  46. package/lib/antigravity-plugin/skills/project-maintenance/SKILL.md +14 -21
  47. package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +23 -36
  48. package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +2 -2
  49. package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +2 -2
  50. package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +3 -3
  51. package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +11 -3
  52. package/lib/extension/acp-worker.js +22 -6
  53. package/lib/extension/cli.js +169 -95
  54. package/lib/extension/hosts/dsh/command.js +1 -1
  55. package/lib/extension/hosts/dsh/workspace.js +5 -2
  56. package/lib/extension/hosts/plugin-runtime.js +3 -1
  57. package/lib/extension/mcp/tool-contract.d.ts +3 -3
  58. package/lib/extension/mcp/tool-contract.js +63 -101
  59. package/lib/extension/mcp/workers.d.ts +1 -1
  60. package/lib/extension/mcp/workers.js +19 -13
  61. package/lib/extension/mcp.js +163 -119
  62. package/lib/integrations/agent-resources.d.ts +4 -2
  63. package/lib/integrations/agent-resources.js +23 -5
  64. package/lib/integrations/hosts/antigravity/adapter.js +0 -1
  65. package/lib/integrations/hosts/claude/adapter.js +1 -2
  66. package/lib/integrations/hosts/dsh/resources.d.ts +2 -1
  67. package/lib/integrations/hosts/dsh/resources.js +12 -13
  68. package/lib/integrations/hosts/prompt-hooks.js +4 -7
  69. package/lib/model/worker-template.d.ts +21 -0
  70. package/lib/model/worker-template.js +1 -0
  71. package/lib/qoder-plugin/.mcp.json +2 -2
  72. package/lib/qoder-plugin/.qoder-plugin/plugin.json +2 -2
  73. package/lib/qoder-plugin/hooks/hooks.json +3 -3
  74. package/lib/qoder-plugin/skills/pbot/SKILL.md +11 -3
  75. package/lib/services/agents/agent-service.js +2 -2
  76. package/lib/services/history/summary-dimensions/monthly.js +1 -1
  77. package/lib/services/history/summary-dimensions/session.js +6 -3
  78. package/lib/services/history/summary-runner.js +3 -3
  79. package/lib/services/workspace/worker-templates.d.ts +17 -0
  80. package/lib/services/workspace/worker-templates.js +88 -0
  81. package/lib/storage/history-files.js +3 -2
  82. package/lib/tools/history/contract.d.ts +1 -1
  83. package/lib/tools/history/contract.js +14 -16
  84. package/package.json +2 -2
  85. package/resources/agents/coordinator.md +2 -4
  86. package/resources/agents/general-purpose.md +2 -4
  87. package/resources/antigravity/skills/pbot/SKILL.md +6 -23
  88. package/resources/claude/skills/pbot/SKILL.md +6 -23
  89. package/resources/plugin/skills/pbot/SKILL.md +11 -3
  90. package/resources/prompts/history-coordinator.md +1 -1
  91. package/resources/prompts/history-monthly-summary.md +6 -11
  92. package/resources/prompts/history-summary.md +6 -11
  93. package/resources/prompts/plugin-coordinator.md +1 -1
  94. package/resources/prompts/workspace.md +16 -23
  95. package/resources/skills/project-maintenance/SKILL.md +14 -21
  96. package/resources/skills/provider-connections/SKILL.md +23 -36
  97. package/resources/templates/workspace-agents.md +5 -13
  98. package/src/extension/cli/commands/mcp.ts +1 -1
  99. package/src/extension/hosts/dsh/command.ts +1 -1
  100. package/src/extension/hosts/dsh/workspace.ts +5 -1
  101. package/src/extension/hosts/pi/command.ts +1 -1
  102. package/src/extension/hosts/pi/events.ts +3 -1
  103. package/src/extension/hosts/plugin-runtime.ts +3 -1
  104. package/src/extension/mcp/tool-contract.ts +63 -103
  105. package/src/extension/mcp/workers.ts +21 -14
  106. package/src/integrations/agent-resources.ts +27 -7
  107. package/src/integrations/hosts/antigravity/adapter.ts +0 -1
  108. package/src/integrations/hosts/claude/adapter.ts +1 -2
  109. package/src/integrations/hosts/dsh/resources.ts +14 -13
  110. package/src/integrations/hosts/prompt-hooks.ts +3 -6
  111. package/src/model/worker-template.ts +24 -0
  112. package/src/pbot.ts +2 -2
  113. package/src/services/agents/agent-service.ts +2 -2
  114. package/src/services/history/summary-dimensions/monthly.ts +1 -1
  115. package/src/services/history/summary-dimensions/session.ts +6 -3
  116. package/src/services/history/summary-runner.ts +3 -3
  117. package/src/services/workspace/worker-templates.ts +80 -0
  118. package/src/storage/history-files.ts +3 -2
  119. package/src/tools/history/contract.ts +14 -16
  120. package/docs/architecture/model-instruction-guidelines.md +0 -34
@@ -1,15 +1,13 @@
1
- import { readFile } from "node:fs/promises";
2
- import { join } from "node:path";
3
1
  import type { Context } from "@deepseek-ai/cordis";
4
2
  import type { Agent } from "@deepseek-ai/dsh-agent";
5
3
  import type {} from "@deepseek-ai/dsh-skill";
6
4
  import type {} from "@deepseek-ai/dsh-working-directory";
7
5
  import type {} from "@deepseek-ai/dsh-tools";
8
- import { agentText } from "../../agent-resources.js";
9
- import { resourceRoot } from "../../../common/paths.js";
6
+ import { loadWorkspaceContext } from "../../agent-resources.js";
10
7
  import { requireThat } from "../../../common/validation.js";
11
8
  import { isMcpWorkerTool } from "../../../model/acp.js";
12
9
  import type { AgentOptions } from "../../../model/agent.js";
10
+ import type { ReadWorkerTemplates } from "../../../model/worker-template.js";
13
11
 
14
12
  export async function dshResources(
15
13
  ctx: Context,
@@ -17,26 +15,29 @@ export async function dshResources(
17
15
  root: string,
18
16
  role: "coordinator" | "general-purpose",
19
17
  check: () => void,
20
- coordinatorPrompt = "history-coordinator.md",
18
+ coordinatorPrompt: string | null = "history-coordinator.md",
19
+ readWorkerTemplates?: ReadWorkerTemplates,
21
20
  ) {
22
- const read = () => Promise.all([agentText(role, root, coordinatorPrompt), readFile(join(resourceRoot, "prompts/workspace.md"), "utf8")]);
23
- const [text, workspace] = await read();
21
+ const read = () => loadWorkspaceContext({
22
+ host: "dsh", root, role, coordinatorPrompt, ...(readWorkerTemplates ? { readWorkerTemplates } : {}),
23
+ });
24
+ const context = await read();
24
25
  check();
25
- ctx.systemPrompt.section({ name: "pbot:role", order: 1, text, interpolate: false });
26
- ctx.systemPrompt.section({ name: "pbot:workspace", order: 2, text: workspace, interpolate: false });
26
+ ctx.systemPrompt.section({ name: "pbot:role", order: 1, text: context.role, interpolate: false });
27
+ ctx.systemPrompt.section({ name: "pbot:workspace", order: 2, text: context.workspace, interpolate: false });
27
28
  ctx.systemPrompt.context({
28
29
  name: "pbot:environment", order: 300, required: true, interpolate: false,
29
- text: JSON.stringify({ host: "dsh", workspaceRoot: root, resourceRoot }),
30
+ text: JSON.stringify(context.environment),
30
31
  });
31
32
  ctx.on("system-prompt/assemble", async (_assembly, _context, next) => {
32
33
  check();
33
- const [roleText, workspaceText] = await read();
34
+ const current = await read();
34
35
  check();
35
36
  const assembly = await next();
36
37
  return {
37
38
  ...assembly,
38
- sections: assembly.sections.map(section => section.name === "pbot:role" ? { ...section, text: roleText }
39
- : section.name === "pbot:workspace" ? { ...section, text: workspaceText } : section),
39
+ sections: assembly.sections.map(section => section.name === "pbot:role" ? { ...section, text: current.role }
40
+ : section.name === "pbot:workspace" ? { ...section, text: current.workspace } : section),
40
41
  };
41
42
  });
42
43
  }
@@ -18,12 +18,9 @@ export function parsePromptEvent(value: unknown): HostEvent {
18
18
  if (name !== "Stop" && name !== "UserPromptSubmit" && name !== "SessionStart") return { kind: "ignore" };
19
19
  if (typeof value.agent_id === "string") return { kind: "ignore" };
20
20
  requireThat(typeof value.cwd === "string", "插件 hook 缺少工作目录。");
21
- if (name === "Stop") return { kind: "record-history", cwd: value.cwd, raw: value };
22
- if (name === "SessionStart") {
23
- if (value.source === "resume" || value.source === "compact") return { kind: "ignore" };
24
- return { kind: "inject-context", role: "coordinator", isSessionStart: true, noticesOnly: true, cwd: value.cwd, raw: value };
25
- }
26
- return { kind: "inject-context", role: "coordinator", cwd: value.cwd, raw: value };
21
+ if (name !== "SessionStart") return { kind: "record-history", cwd: value.cwd, raw: value };
22
+ if (value.source === "resume" || value.source === "compact") return { kind: "ignore" };
23
+ return { kind: "inject-context", role: "coordinator", isSessionStart: true, cwd: value.cwd, raw: value };
27
24
  }
28
25
 
29
26
  export const promptHooks = {
@@ -0,0 +1,24 @@
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
+
13
+ export interface WorkerTemplateError {
14
+ id: string;
15
+ message: string;
16
+ }
17
+
18
+ export interface WorkerTemplateCatalog {
19
+ templates: WorkerTemplate[];
20
+ errors: WorkerTemplateError[];
21
+ error?: string;
22
+ }
23
+
24
+ export type ReadWorkerTemplates = (root: string) => Promise<WorkerTemplateCatalog>;
package/src/pbot.ts CHANGED
@@ -5,7 +5,7 @@ import { Lifecycle, WorkspaceInstance } from "./extension/hosts/pi/lifecycle.js"
5
5
  import { registerCommand } from "./extension/hosts/pi/command.js";
6
6
  import { registerEvents } from "./extension/hosts/pi/events.js";
7
7
  import { registerHistoryEvents } from "./extension/hosts/pi/history.js";
8
- import { McpWorkerRuntime, defaultWorkerDirectory } from "./extension/mcp/workers.js";
8
+ import { McpWorkerRuntime, defaultWorkerDirectory, mcpWorkerOnlyInstructions } from "./extension/mcp/workers.js";
9
9
  import { workspaceFeatures } from "./services/workspace/workspace-config.js";
10
10
  import { loadNativeWorkspaceServers } from "./extension/hosts/workspace-mcp.js";
11
11
  import { toPiMcpConfig } from "./integrations/hosts/pi/mcp.js";
@@ -34,7 +34,7 @@ export default function pbot(pi: ExtensionAPI) {
34
34
  ...server,
35
35
  exposure: "direct",
36
36
  timeout: 600,
37
- description: "跨助手委派(worker_*)",
37
+ description: mcpWorkerOnlyInstructions,
38
38
  });
39
39
  registeredMcpServers.push(mcpServerName);
40
40
  }
@@ -108,11 +108,11 @@ export class AgentService {
108
108
  }
109
109
  const target = input.requestId ? pending.find(item => item.requestId === input.requestId) : pending[0];
110
110
  requireThat(target, input.requestId
111
- ? "没有待回复的请求:" + input.requestId + ";用 worker_discover 查看 pendingRequests。"
111
+ ? `没有待回复的请求 ${input.requestId}。用 worker_discover 查询 target="workers"、workerId="${id}" 的当前请求。`
112
112
  : "当前没有待回复的请求。");
113
113
  this.files.ensureSubdirectory(id, "interactions");
114
114
  if (target.kind === "permission") {
115
- requireThat(input.content === undefined, "权限请求不使用 content;请用 action(accept / decline / cancel)或指定 optionId。");
115
+ requireThat(input.content === undefined, "请移除 content。权限请求用 action 回复,选择具体权限范围时加上 optionId。");
116
116
  let resolved: string | null = null;
117
117
  if (input.action === "cancel") {
118
118
  requireThat(input.optionId === undefined, "action 为 cancel 时不能同时指定 optionId。");
@@ -57,7 +57,7 @@ function formatSessionSummaries(summaries: readonly SummaryArtifact[]): string {
57
57
  export const monthlySummaryDimension: SummaryDimension = {
58
58
  id: "monthly",
59
59
  title: "月度历史汇总",
60
- description: "按自然月(UTC YYYY/MM)归纳当月单会话摘要,提炼月度主题、关键决定与产出,支持逐层下钻。",
60
+ description: "按会话开始的 UTC 月份汇总会话摘要,可从月度结果查回各会话。",
61
61
  requiresMonthlyLayout: true,
62
62
 
63
63
  plan(
@@ -46,7 +46,7 @@ function isStrictUnchangedPrefix(
46
46
  export const sessionSummaryDimension: SummaryDimension = {
47
47
  id: "session",
48
48
  title: "会话任务摘要",
49
- description: "按单个会话提炼任务目标、关键决定、结果与未决事项,支持去重跳过与增量滚动更新。",
49
+ description: "汇总单次会话的目标、决定、结果和未决事项。",
50
50
 
51
51
  plan(
52
52
  raws: readonly RawHistory[],
@@ -119,9 +119,12 @@ export const sessionSummaryDimension: SummaryDimension = {
119
119
  ...heading,
120
120
  `【已有摘要(${task.existing.from} — ${task.existing.to})】\n${task.existing.text}`,
121
121
  `【新增对话】\n${formatExchanges(task.addedExchanges)}`,
122
- "在已有摘要基础上合并新增对话,输出更新后的完整摘要:保留仍有效的事实,用新决定覆盖旧决定,去重并保持简洁。",
123
122
  ].join("\n\n");
124
- return { system, prompt, maxTokens: 2048 };
123
+ return {
124
+ system: system + "\n合并已有摘要与新增对话,输出完整摘要。保留仍有效的事实,用后续明确的决定更新相应结论。",
125
+ prompt,
126
+ maxTokens: 2048,
127
+ };
125
128
  }
126
129
  const prompt = [
127
130
  ...heading,
@@ -94,9 +94,9 @@ function evaluateSummaryReminder(
94
94
 
95
95
  const rawAgeDays = Math.floor((nowMs - oldestRawMs) / dayMs);
96
96
  const daysSinceLastSummary = latestSummaryMs === undefined ? undefined : Math.floor((nowMs - latestSummaryMs) / dayMs);
97
- const message = daysSinceLastSummary === undefined
98
- ? `历史原文已累计 ${rawAgeDays} 天(待摘要 ${pendingCount} 项),尚未触发过摘要整理;可在终端运行 pbot history summary 生成摘要(Pi/dsh 可用 /pbot history summary)。`
99
- : `历史原文已累计 ${rawAgeDays} 天,且已 ${daysSinceLastSummary} 天未触发摘要整理(待摘要 ${pendingCount} 项);可在终端运行 pbot history summary 更新摘要(Pi/dsh 可用 /pbot history summary)。`;
97
+ const lastUpdate = daysSinceLastSummary === undefined ? "尚无摘要" : `上次更新摘要在 ${daysSinceLastSummary} 天前`;
98
+ const message = `工作区已积累 ${rawAgeDays} 天的历史,${lastUpdate},${pendingCount} 项待摘要。` +
99
+ "可在工作区根目录运行 pbot history summary,或在 Pi、dsh 会话中输入 /pbot history summary。";
100
100
 
101
101
  return {
102
102
  rawCount: raws.length,
@@ -0,0 +1,80 @@
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
+ import type { WorkerTemplate, WorkerTemplateCatalog, WorkerTemplateError } from "../../model/worker-template.js";
7
+
8
+ const templateIdPattern = /^[a-z0-9][a-z0-9-]{0,63}$/;
9
+ const templateFields = ["name", "description", "create"];
10
+ const createFields = ["backend", "workspace", "model", "thinking"];
11
+
12
+ function validString(value: unknown): value is string {
13
+ return typeof value === "string" && value.trim().length > 0 && !value.includes("\0");
14
+ }
15
+
16
+ function parseTemplate(id: string, entry: unknown): WorkerTemplate | WorkerTemplateError {
17
+ if (!templateIdPattern.test(id)) return { id, message: "模板标识无效。" };
18
+ if (!object(entry) || Object.keys(entry).some(key => !templateFields.includes(key))) {
19
+ return { id, message: "模板设置无效。" };
20
+ }
21
+ const { name = id, description, create } = entry;
22
+ if (!validString(name)) return { id, message: "模板名称无效。" };
23
+ if (!validString(description)) return { id, message: "模板缺少有效的职责说明。" };
24
+ if (!object(create) || Object.keys(create).some(key => !createFields.includes(key))) {
25
+ return { id, message: "助手的启动设置无效。" };
26
+ }
27
+ if (!validString(create.backend)) return { id, message: "模板缺少有效的助手标识。" };
28
+ const options: WorkerTemplate["create"] = { backend: create.backend, workspace: "." };
29
+ for (const key of ["workspace", "model", "thinking"] as const) {
30
+ const value = create[key];
31
+ if (value === undefined) continue;
32
+ if (!validString(value)) return { id, message: "助手的启动设置无效。" };
33
+ options[key] = value;
34
+ }
35
+ return { id, name, description, create: options };
36
+ }
37
+
38
+ export async function readWorkerTemplates(root: string): Promise<WorkerTemplateCatalog> {
39
+ const path = join(root, ".pbot", "worker", "templates.json");
40
+ const catalog: WorkerTemplateCatalog = { templates: [], errors: [] };
41
+ const unavailable = { ...catalog, error: "当前工作区的助手模板不可用。" };
42
+ let entries: unknown;
43
+ try {
44
+ const file = await open(path, constants.O_RDONLY | constants.O_NONBLOCK);
45
+ try {
46
+ if (!(await file.stat()).isFile()) return unavailable;
47
+ entries = JSON.parse(await file.readFile("utf8"));
48
+ } finally {
49
+ await file.close();
50
+ }
51
+ } catch (error) {
52
+ if ((error as NodeJS.ErrnoException).code === "ENOENT") return catalog;
53
+ return unavailable;
54
+ }
55
+ if (!object(entries)) return unavailable;
56
+ for (const id of Object.keys(entries).sort()) {
57
+ const result = parseTemplate(id, entries[id]);
58
+ if ("message" in result) catalog.errors.push(result);
59
+ else catalog.templates.push(result);
60
+ }
61
+ return catalog;
62
+ }
63
+
64
+ function resolveTemplateWorkspace(root: string, workspace: string): string {
65
+ if (workspace === "~" || workspace.startsWith("~/")) return join(homedir(), workspace.slice(2));
66
+ return resolve(root, workspace);
67
+ }
68
+
69
+ export async function discoverWorkerTemplates(root: string) {
70
+ const { templates, errors, error } = await readWorkerTemplates(root);
71
+ if (error) throw new Error(error);
72
+ return {
73
+ target: "templates",
74
+ templates: templates.map(template => ({
75
+ ...template,
76
+ create: { ...template.create, workspace: resolveTemplateWorkspace(root, template.create.workspace) },
77
+ })),
78
+ ...(errors.length ? { errors } : {}),
79
+ };
80
+ }
@@ -305,8 +305,9 @@ export class HistoryFiles {
305
305
  summaryCount,
306
306
  total,
307
307
  message:
308
- `检测到 ${total} 个未迁移的平铺历史文件(raw ${rawCount},summaries ${summaryCount});当前为年月目录布局(history.layout: monthly),未迁移文件不会被读取。` +
309
- `请在终端运行 pbot history migrate 整理到 YYYY/MM/ 目录(Pi/dsh 可用 /pbot history migrate),或在 .pbot/config.json 中设置 "history": { "layout": "flat" } 切回平铺布局。`,
308
+ `当前按年月读取历史,平铺目录中的 ${rawCount} 份原文和 ${summaryCount} 份摘要尚未纳入检索。` +
309
+ "可在工作区根目录用 pbot history migrate --dry-run 预览,用 pbot history migrate 执行(Pi、dsh 可用 /pbot history migrate)。" +
310
+ '要继续使用平铺目录,可在 .pbot/config.json 中设置 "history": { "layout": "flat" }。',
310
311
  };
311
312
  }
312
313
 
@@ -10,7 +10,7 @@ const node = Type.Object({
10
10
  host: identifier,
11
11
  id: Type.String(),
12
12
  kind: Type.Union([Type.Literal("session"), Type.Literal("exchange"), Type.Literal("summary")], {
13
- description: "session=会话根;summary=维度摘要;exchange=单轮问答原文。",
13
+ description: "session 为会话,summary 为摘要,exchange 为单轮问答原文。",
14
14
  }),
15
15
  dimension: Type.Optional(identifier),
16
16
  sessionId: Type.String(),
@@ -19,7 +19,7 @@ const node = Type.Object({
19
19
  from: Type.String(),
20
20
  to: Type.String(),
21
21
  ready: Type.Boolean({ description: "正文或摘要是否已生成。" }),
22
- completed: Type.Boolean({ description: "该对话或问答是否正常结束(false 表示中断或未完)。" }),
22
+ completed: Type.Boolean({ description: "false 表示会话或问答中断或未完成。" }),
23
23
  });
24
24
 
25
25
  export const historyResultSchema = Type.Object({
@@ -50,24 +50,22 @@ export const historyResultSchema = Type.Object({
50
50
  });
51
51
 
52
52
  export const historyDescription =
53
- "查询当前工作区跨宿主历史问答与摘要归档。" +
54
- "search 按不区分大小写的连续关键词匹配原文与摘要,省略 query 列出各会话或指定维度摘要;" +
55
- "read 按 id 读取正文与上下级(可从 monthly 汇总下钻至 session 摘要和 exchange 原文),用 nextOffset 与 nextChildrenOffset 分页续读。";
53
+ "查找工作区各宿主归档的问答和摘要。沿子节点可从月度汇总查到会话摘要和原始问答。";
56
54
 
57
55
  export const historyParameters = Type.Object({
58
56
  action: Type.Union([Type.Literal("search"), Type.Literal("read")], {
59
- description: "search 搜索或列表;read 按 id 读取正文与上下级。仅读取对应动作参数,其余忽略。",
57
+ description: "search 搜索或列出记录,read 按 id 读取正文和上下级。",
60
58
  }),
61
- host: nullable(Type.String({ pattern: historyIdentifierPattern.source, description: "来源宿主筛选(如 pi、dsh、claude、antigravity、codex、qoder);省略查全部。" })),
62
- dimension: nullable(Type.String({ pattern: historyIdentifierPattern.source, description: "仅 search:raw 仅原文,或指定摘要维度(如 monthly、session);省略查全部。" })),
63
- query: nullable(Type.String({ description: "仅 search:连续关键词(不区分大小写);省略列会话或指定维度摘要。" })),
64
- sessionId: nullable(Type.String({ description: "仅 search:限定在指定原始会话 ID 内搜索。" })),
65
- from: nullable(Type.String({ description: "仅 search:ISO 日期或时间下界。" })),
66
- to: nullable(Type.String({ description: "仅 search:ISO 日期或时间上界。" })),
67
- id: nullable(Type.String({ description: "仅 read,必填:节点 id(来自 search 或上下级)。" })),
68
- offset: nullable(Type.Integer({ minimum: 0, description: "search 为结果偏移,read 为正文字符偏移;默认 0。" })),
69
- limit: nullable(Type.Integer({ minimum: 1, maximum: historyPageLimits.read.max, description: `search:返回条数(1–${historyPageLimits.search.max},默认 ${historyPageLimits.search.default});read:正文字符数(默认 ${historyPageLimits.read.default})。` })),
70
- childrenOffset: nullable(Type.Integer({ minimum: 0, description: "仅 read:子节点偏移,默认 0;续读传上次 nextChildrenOffset。" })),
59
+ host: nullable(Type.String({ pattern: historyIdentifierPattern.source, description: "来源宿主,如 pi 或 claude。可筛选搜索结果或区分重名节点。" })),
60
+ dimension: nullable(Type.String({ pattern: historyIdentifierPattern.source, description: "search 的范围。raw 为原始问答,session、monthly 等为摘要维度。关键词搜索默认查全部。" })),
61
+ query: nullable(Type.String({ description: "search 匹配连续文本,忽略大小写。省略时列会话,指定摘要维度则列该维度的摘要。" })),
62
+ sessionId: nullable(Type.String({ description: "search 按原始会话 ID 筛选。" })),
63
+ from: nullable(Type.String({ description: "search 时间区间起点(含),用 ISO 日期或时间。" })),
64
+ to: nullable(Type.String({ description: "search 时间区间终点(含),仅填日期表示该日 UTC 零点。" })),
65
+ id: nullable(Type.String({ description: "read 必填。使用搜索结果、父节点或子节点的 id。" })),
66
+ offset: nullable(Type.Integer({ minimum: 0, description: "翻页传上页的 nextOffset。search 按条目,read 按正文字符,默认从 0 开始。" })),
67
+ limit: nullable(Type.Integer({ minimum: 1, maximum: historyPageLimits.read.max, description: `search 每页默认 ${historyPageLimits.search.default} 条,最多 ${historyPageLimits.search.max} 条。read 每页默认 ${historyPageLimits.read.default} 个字符。` })),
68
+ childrenOffset: nullable(Type.Integer({ minimum: 0, description: "read 的子节点起点,默认 0。翻页传上页的 nextChildrenOffset。" })),
71
69
  }, { additionalProperties: false });
72
70
 
73
71
  export type HistoryInput =
@@ -1,34 +0,0 @@
1
- # 模型指令编写原则
2
-
3
- 修改 Agent 实际可见的内容及其加载方式时遵循本文。范围包括各宿主主会话与 ACP worker 的公共提示、角色、动态环境、工具说明、技能、参考资料、模板及历史摘要提示。本文方法论**仅面向运行时模型上下文**,与面向开发者的仓库技术文档(`AGENTS.md`、`docs/`)严格分开,不将仓库架构或构建实现写进 `resources/`。当前加载方式见[模型上下文](model-context.md)。
4
-
5
- ## 从实际上下文出发
6
-
7
- 以宿主实际组装的内容判断取舍,尤其检查新会话第一次任务。同时考虑宿主提示、用户资料、工具声明和技能目录,避免只看某个 Markdown 文件。
8
-
9
- 每段指令应有具体用途:帮助模型作什么决定、执行什么操作,或避免什么已知错误。根据用途保留、合并、删除、条件加载或按需读取,不以字数最少为目标,不加入没有明确需求的泛化约束。
10
-
11
- ## 直接说明要做什么
12
-
13
- 使用自然、直接的语言,写清职责、操作入口、参数含义和下一步。内部架构与执行机制只在改变实际操作时说明,其余留在开发文档。
14
-
15
- ## 不增加泛化流程
16
-
17
- 按用户请求和已有约定推进,不自行补入通用的证据收集、授权核对、审批、独立复核或业务验收流程。权限和确认机制沿用宿主、凭据、外部服务及用户约定;不通过提示掩盖或绕过实际执行限制,保留直接影响操作的事项(如配置作用域、凭据引用,以及结果未知时先查状态、避免重复执行)。
18
-
19
- ## 保留实用细节,按用途放置
20
-
21
- | 内容 | 放置要求 |
22
- | --- | --- |
23
- | 首次任务就需要的职责与资料位置 | 放在公共提示或对应角色中 |
24
- | 工作区目录用途与组织规范 | 保留首轮可见的目录说明和模板导航;已有用户布局与约定优先 |
25
- | 工具参数、分页、状态和结果入口 | 放在工具契约中,避免其他提示重复完整说明 |
26
- | 维护、接入、计算及调度方法 | 通过技能或参考资料按需读取,正文包含能实际执行的方法与关键口径 |
27
- | 动态环境与错误 | 提供当前操作需要的字段;详细诊断留在状态或日志入口 |
28
- | 历史摘要 | 使用专用提示与待总结资料,不混入普通工作角色和无关技能 |
29
-
30
- 优先使用宿主已有的资源发现、技能、工具、配置和上下文去重机制。加载缺失、时序错误或重复注入问题应修代码,不用提示词弥补。
31
-
32
- ## 验证要求
33
-
34
- 加载行为用真实宿主 SDK、本地文件和进程检查来源、首轮出现时机、后续更新、条件加载及去重;不编写断言提示词文案或全文快照的测试。