personal-bot 0.2.6 → 0.2.8
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/README.md +47 -13
- package/README.zh-CN.md +46 -12
- package/docs/README.md +4 -2
- package/docs/agent-collaboration.md +4 -4
- package/docs/capability-design.md +12 -6
- package/docs/dsh-implementation-plan.md +9 -7
- package/docs/dsh-support-proposal.md +6 -22
- package/docs/dsh.en.md +333 -0
- package/docs/dsh.md +346 -48
- package/docs/file-storage.md +1 -1
- package/docs/history.md +2 -0
- package/docs/installation-design.md +7 -4
- package/docs/model-context.md +60 -0
- package/docs/model-instruction-guidelines.md +51 -0
- package/docs/release.md +10 -6
- package/docs/subagent-upgrade-proposal.md +1 -1
- package/docs/technical-design.md +21 -15
- package/docs/validation.md +64 -7
- package/lib/dsh.js +4 -0
- package/lib/extension/dsh/agent-events.js +1 -1
- package/lib/extension/dsh/agent-runtime.js +8 -5
- package/lib/integrations/dsh/resources.d.ts +1 -1
- package/lib/integrations/dsh/resources.js +14 -14
- package/lib/integrations/dsh/session.js +1 -0
- package/lib/integrations/installation/pi-bridge.js +9 -9
- package/lib/integrations/team-context.js +7 -3
- package/lib/services/agents/agent-notices.js +2 -2
- package/lib/services/agents/team-service.js +1 -1
- package/lib/tools/agents/contract.d.ts +1 -1
- package/lib/tools/agents/contract.js +7 -7
- package/lib/tools/agents/dsh-contract.js +4 -4
- package/lib/tools/history/contract.d.ts +1 -1
- package/lib/tools/history/contract.js +2 -2
- package/lib/tools/teams/contract.d.ts +2 -2
- package/lib/tools/teams/contract.js +11 -11
- package/npm-shrinkwrap.json +30 -25
- package/package.json +28 -25
- package/python/README.md +1 -1
- package/resources/agents/coordinator.md +5 -33
- package/resources/agents/general-purpose.md +3 -15
- package/resources/prompts/history-summary.md +1 -1
- package/resources/prompts/team-member.md +7 -0
- package/resources/prompts/workspace.md +13 -24
- package/resources/references/compute-finance.md +22 -0
- package/resources/references/compute.md +11 -88
- package/resources/references/task-conductor.md +20 -15
- package/resources/skills/project-maintenance/SKILL.md +9 -11
- package/resources/skills/provider-connections/SKILL.md +7 -7
- package/scripts/README.md +1 -1
- package/src/dsh.ts +4 -0
- package/src/extension/agent-events.ts +17 -4
- package/src/extension/command.ts +1 -1
- package/src/extension/dsh/agent-events.ts +1 -1
- package/src/extension/dsh/agent-runtime.ts +7 -6
- package/src/extension/events.ts +14 -9
- package/src/extension/subagent-entry.ts +24 -16
- package/src/integrations/dsh/resources.ts +17 -14
- package/src/integrations/dsh/session.ts +2 -0
- package/src/integrations/installation/pi-bridge.ts +9 -7
- package/src/integrations/pi/agent-context.ts +1 -1
- package/src/integrations/team-context.ts +7 -3
- package/src/services/agents/agent-notices.ts +2 -2
- package/src/services/agents/team-service.ts +1 -1
- package/src/tools/agents/contract.ts +7 -7
- package/src/tools/agents/dsh-contract.ts +4 -4
- package/src/tools/history/contract.ts +2 -2
- package/src/tools/register.ts +1 -7
- package/src/tools/teams/contract.ts +11 -11
- package/resources/prompts/tool-guidelines.md +0 -3
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
|
-
export const agentDescription = "
|
|
2
|
+
export const agentDescription = "委派专家并继续对话。start 启动后即返回,完成自动通知,无需轮询;省略初始输入时待命。send 继续对话,团队占用期间不可私人 send。status 查看状态,read 读取报告;读取已结束周期即领取其通知,包括部分读取。续读固定 cycle.cycleId 并使用 nextOffset。state 表示执行状态,cycle.state 表示工作结果,queued 只表示入队。stop 保留历史,resume 携新 message 继续。每个父会话最多 50 个存活专家,空闲也计入。";
|
|
3
3
|
const id = Type.String({ minLength: 1, maxLength: 128 });
|
|
4
|
-
const message = Type.String({ minLength: 1, maxLength: 24000, description: "
|
|
4
|
+
const message = Type.String({ minLength: 1, maxLength: 24000, description: "本次目标、相关资料、约束和交付要求。" });
|
|
5
5
|
const name = Type.String({ minLength: 1, maxLength: 64, pattern: "^[^\\r\\n\\x00-\\x1f]+$" });
|
|
6
6
|
export const agentStartOptions = {
|
|
7
7
|
name: Type.Optional(name), message: Type.Optional(message),
|
|
8
8
|
files: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { maxItems: 32, description: "随初始消息读取的文件;相对路径基于原工作区根目录。" })),
|
|
9
|
-
prompts: Type.Optional(Type.Array(message, { maxItems: 32, description: "与 message
|
|
9
|
+
prompts: Type.Optional(Type.Array(message, { maxItems: 32, description: "与 message 按顺序合并为同一初始消息。" })),
|
|
10
10
|
provider: Type.Optional(Type.String({ ...id, description: "Pi 模型提供方,默认继承主会话。" })),
|
|
11
|
-
model: Type.Optional(Type.String({ ...id, description: "
|
|
11
|
+
model: Type.Optional(Type.String({ ...id, description: "Pi 模型 ID,默认继承主会话。" })),
|
|
12
12
|
thinking: Type.Optional(Type.Union([Type.Literal("off"), Type.Literal("minimal"), Type.Literal("low"), Type.Literal("medium"), Type.Literal("high"), Type.Literal("xhigh"), Type.Literal("max")], { description: "默认继承主会话思考级别。" })),
|
|
13
13
|
cwd: Type.Optional(Type.String({ minLength: 1, description: "执行目录,相对原工作区根目录;省略时使用工作区根目录。" })),
|
|
14
|
-
tools: Type.Optional(Type.Array(id, { minItems: 1, description: "按 Pi
|
|
14
|
+
tools: Type.Optional(Type.Array(id, { minItems: 1, description: "按 Pi 规则选择工具,省略时使用默认工具;MCP 工具按当前配置提供。" })),
|
|
15
15
|
noExtensions: Type.Optional(Type.Boolean({ description: "默认 true,不发现其他扩展。" })),
|
|
16
16
|
noSkills: Type.Optional(Type.Boolean({ description: "关闭技能发现,默认 false。" })),
|
|
17
17
|
noPromptTemplates: Type.Optional(Type.Boolean({ description: "关闭提示模板发现,默认 false。" })),
|
|
@@ -39,7 +39,7 @@ export const agentActionSchema = Type.Union([
|
|
|
39
39
|
Type.Object({ action: Type.Literal("read"), agentId: id, ...page }, { additionalProperties: false }),
|
|
40
40
|
]);
|
|
41
41
|
const cycle = Type.Object({ cycleId: Type.String(), startedAt: Type.Number(), finishedAt: Type.Optional(Type.Number()),
|
|
42
|
-
state: Type.Union([Type.Literal("running"), Type.Literal("completed"), Type.Literal("failed"), Type.Literal("cancelled"), Type.Literal("interrupted")], { description: "
|
|
42
|
+
state: Type.Union([Type.Literal("running"), Type.Literal("completed"), Type.Literal("failed"), Type.Literal("cancelled"), Type.Literal("interrupted")], { description: "本周期的工作结果,正文用 read 读取。" }),
|
|
43
43
|
requestIds: Type.Array(Type.String()),
|
|
44
44
|
source: Type.Union([Type.Literal("parent"), Type.Literal("interactive"), Type.Literal("mixed")]), error: Type.Optional(Type.String()),
|
|
45
45
|
}, { additionalProperties: false });
|
|
@@ -49,7 +49,7 @@ export const agentViewSchema = Type.Object({ agentId: Type.String(), name: Type.
|
|
|
49
49
|
activity: Type.String(), cycle: Type.Optional(cycle), error: Type.Optional(Type.String()),
|
|
50
50
|
requestId: Type.Optional(Type.String()), messageStatus: Type.Optional(Type.Literal("queued", { description: "消息已入队,不代表模型已阅读或完成。" })),
|
|
51
51
|
cycles: Type.Optional(Type.Array(Type.Object({ cycleId: Type.String(), state: Type.String() }), { description: "仅 read 返回:可读取的周期索引。" })),
|
|
52
|
-
report: Type.Optional(Type.String({ description: "仅 read
|
|
52
|
+
report: Type.Optional(Type.String({ description: "仅 read 返回:选定周期的报告正文片段。" })),
|
|
53
53
|
totalLength: Type.Optional(Type.Integer({ description: "仅 read 返回:完整报告的 UTF-16 字符数。" })),
|
|
54
54
|
nextOffset: Type.Optional(Type.Union([Type.Integer(), Type.Null()], { description: "仅 read 返回:null 表示本报告已读完;否则以相同 agentId、cycle.cycleId 和此 offset 继续。" })),
|
|
55
55
|
}, { additionalProperties: false });
|
|
@@ -4,10 +4,10 @@ const options = Type.Omit(Type.Object(agentStartOptions), ["provider", "model",
|
|
|
4
4
|
const native = {
|
|
5
5
|
provider: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "dsh 原生 provider route,默认继承父会话。" })),
|
|
6
6
|
model: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "该 dsh provider 的模型 ID,默认继承父会话。" })),
|
|
7
|
-
thinking: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "该 dsh
|
|
8
|
-
files: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { maxItems: 32, description: "
|
|
9
|
-
tools: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { minItems: 1, description: "
|
|
10
|
-
noSkills: Type.Optional(Type.Boolean({ description: "
|
|
7
|
+
thinking: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "该 dsh 模型的 reasoning effort ID,默认继承父会话。" })),
|
|
8
|
+
files: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { maxItems: 32, description: "附给专家的文件;相对原工作区根目录。图片大小与格式遵循 dsh 限制。" })),
|
|
9
|
+
tools: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { minItems: 1, description: "能力工具名,不填写 run_code;省略时使用原生工具和 pbot_team_message。" })),
|
|
10
|
+
noSkills: Type.Optional(Type.Boolean({ description: "关闭该专家的技能目录和 skill 工具。" })),
|
|
11
11
|
};
|
|
12
12
|
const omitted = ["noExtensions", "noPromptTemplates", "noContextFiles", "provider", "model", "thinking", "files", "tools", "noSkills"];
|
|
13
13
|
export const dshAgentParametersSchema = Type.Object({ ...Type.Omit(agentParametersSchema, omitted).properties, ...native }, { additionalProperties: false });
|
|
@@ -64,7 +64,7 @@ export declare const historyResultSchema: Type.TObject<{
|
|
|
64
64
|
}>>;
|
|
65
65
|
warnings: Type.TArray<Type.TString>;
|
|
66
66
|
}>;
|
|
67
|
-
export declare const historyDescription = "\u67E5\u8BE2\u5F53\u524D\u5DE5\u4F5C\u533A\u7684 Pi
|
|
67
|
+
export declare const historyDescription = "\u67E5\u8BE2\u5F53\u524D\u5DE5\u4F5C\u533A\u7684 Pi/dsh \u95EE\u7B54\u5F52\u6863\uFF0Chost \u53EF\u7B5B\u9009\u6765\u6E90\u3002search \u6309\u4E0D\u533A\u5206\u5927\u5C0F\u5199\u7684\u8FDE\u7EED\u6587\u672C\u5339\u914D\u539F\u6587\u548C\u6458\u8981\uFF1B\u65E0\u5339\u914D\u65F6\u6362\u8BCD\uFF0C\u7701\u7565 query \u5217\u4F1A\u8BDD\u3002read \u6309 parents/children \u7684 id \u5C55\u5F00\uFF0CnextOffset \u7EED\u8BFB\u6B63\u6587\uFF0CnextChildrenOffset \u7EED\u8BFB\u5B50\u8282\u70B9\u3002\u9700\u8981\u5BF9\u8BDD\u7EC6\u8282\u65F6\u8BFB\u53D6 exchange \u539F\u6587\uFF1B\u9700\u8981\u5DE5\u5177\u65E5\u5FD7\u65F6\u67E5\u6240\u5C5E\u5BBF\u4E3B\u7684\u539F\u59CB\u4F1A\u8BDD\u3002";
|
|
68
68
|
export declare const historyParameters: Type.TObject<{
|
|
69
69
|
action: Type.TUnion<[Type.TLiteral<"search">, Type.TLiteral<"read">]>;
|
|
70
70
|
host: Type.TOptional<Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">]>>;
|
|
@@ -9,10 +9,10 @@ export const historyResultSchema = Type.Object({
|
|
|
9
9
|
total: Type.Optional(Type.Integer()), nextOffset: Type.Optional(nullableOffset),
|
|
10
10
|
node: Type.Optional(Type.Object({ ...node.properties, text: Type.String(), totalLength: Type.Integer(), nextOffset: nullableOffset,
|
|
11
11
|
parents: Type.Array(node), children: Type.Array(node), nextChildrenOffset: nullableOffset,
|
|
12
|
-
source: Type.Object({ host, sessionId: Type.String({ description: "原始宿主会话 ID
|
|
12
|
+
source: Type.Object({ host, sessionId: Type.String({ description: "原始宿主会话 ID。" }), entryIds: Type.Array(Type.String()) }), warnings: Type.Array(Type.String()) })),
|
|
13
13
|
warnings: Type.Array(Type.String()),
|
|
14
14
|
});
|
|
15
|
-
export const historyDescription = "查询当前工作区的 Pi
|
|
15
|
+
export const historyDescription = "查询当前工作区的 Pi/dsh 问答归档,host 可筛选来源。search 按不区分大小写的连续文本匹配原文和摘要;无匹配时换词,省略 query 列会话。read 按 parents/children 的 id 展开,nextOffset 续读正文,nextChildrenOffset 续读子节点。需要对话细节时读取 exchange 原文;需要工具日志时查所属宿主的原始会话。";
|
|
16
16
|
export const historyParameters = Type.Object({ action: Type.Union([Type.Literal("search"), Type.Literal("read")]),
|
|
17
17
|
host: Type.Optional(host), query: Type.Optional(Type.String()), sessionId: Type.Optional(Type.String()),
|
|
18
18
|
from: Type.Optional(Type.String({ description: "search:ISO 日期或时间,下界。" })),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
|
-
export declare const teamDescription = "\
|
|
3
|
-
export declare const teamMessageDescription = "\
|
|
2
|
+
export declare const teamDescription = "\u7EC4\u7EC7\u56FA\u5B9A\u6210\u5458\u534F\u4F5C\u3002create \u5EFA\u7ACB\u56E2\u961F\uFF0Crun \u5F00\u59CB\u4E00\u6279\u8BA8\u8BBA\u3002\u8FD0\u884C\u65F6\u5360\u7528\u6210\u5458\uFF1Bpause \u505C\u6B62\u65B0\u5B89\u6392\uFF0C\u5141\u8BB8\u5728\u9014\u5DE5\u4F5C\u6536\u5C3E\uFF0C\u4E4B\u540E\u53EF\u79C1\u4EBA send\uFF1B\u4E2D\u6B62\u6210\u5458\u7528 pbot_agent stop\u3002close \u4FDD\u7559\u6210\u5458\u548C\u5386\u53F2\uFF1B\u6362\u6210\u5458\u987B\u5173\u95ED\u65E7\u56E2\u961F\u518D\u521B\u5EFA\u3002\u7EE7\u7EED\u8BA8\u8BBA\u7528 run \u63D0\u4EA4\u65B0\u8981\u6C42\u3002\u6210\u5458\u6700\u7EC8\u7B54\u590D\u5411\u56E2\u961F\u516C\u5F00\u3002";
|
|
3
|
+
export declare const teamMessageDescription = "\u8BFB\u5199\u56E2\u961F\u516C\u5171\u539F\u6587\u3002post \u5411\u5168\u4F53\u6210\u5458\u53D1\u5E03\u4FE1\u606F\uFF0C\u9700\u8981\u5B89\u6392\u56DE\u7B54\u65F6\u7531\u4E3B\u4F1A\u8BDD\u8C03\u7528 pbot_team run\uFF1B\u6210\u5458\u53EA\u80FD\u5728\u81EA\u5DF1\u7684\u56E2\u961F\u5DE5\u4F5C\u4E2D post\u3002read \u7528 afterSeq \u7FFB\u9875\uFF0C\u957F\u6B63\u6587\u6309 seq/offset \u7EED\u8BFB\uFF0C\u5148\u8865\u5B8C nextOffset \u975E\u7A7A\u7684\u6D88\u606F\u3002";
|
|
4
4
|
export declare const teamParametersSchema: Type.TObject<{
|
|
5
5
|
afterSeq: Type.TOptional<Type.TInteger>;
|
|
6
6
|
seq: Type.TOptional<Type.TInteger>;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
|
-
export const teamDescription = "
|
|
3
|
-
export const teamMessageDescription = "
|
|
2
|
+
export const teamDescription = "组织固定成员协作。create 建立团队,run 开始一批讨论。运行时占用成员;pause 停止新安排,允许在途工作收尾,之后可私人 send;中止成员用 pbot_agent stop。close 保留成员和历史;换成员须关闭旧团队再创建。继续讨论用 run 提交新要求。成员最终答复向团队公开。";
|
|
3
|
+
export const teamMessageDescription = "读写团队公共原文。post 向全体成员发布信息,需要安排回答时由主会话调用 pbot_team run;成员只能在自己的团队工作中 post。read 用 afterSeq 翻页,长正文按 seq/offset 续读,先补完 nextOffset 非空的消息。";
|
|
4
4
|
const id = Type.String({ minLength: 1, maxLength: 128 });
|
|
5
5
|
const text = Type.String({ minLength: 1, maxLength: 24000 });
|
|
6
6
|
const name = Type.String({ minLength: 1, maxLength: 64, pattern: "^[^\\r\\n\\x00-\\x1f]+$" });
|
|
7
7
|
const mode = Type.Union([Type.Literal("roundRobin"), Type.Literal("parallel")], { description: "run 必填:roundRobin 按成员顺序轮流发言;parallel 在并发上限内发言,全员本轮完成后才进入下一轮。" });
|
|
8
8
|
const members = Type.Array(Type.Object({ agentId: id, role: Type.String({ minLength: 1, maxLength: 4000 }) }, { additionalProperties: false }), {
|
|
9
|
-
minItems: 1, maxItems: 50, description: "仅 create
|
|
9
|
+
minItems: 1, maxItems: 50, description: "仅 create,必填:当前分支中的固定成员及职责;成员须版本兼容且未加入其他未关闭团队。",
|
|
10
10
|
});
|
|
11
11
|
const run = {
|
|
12
|
-
instruction: Type.String({ ...text, description: "仅 run
|
|
12
|
+
instruction: Type.String({ ...text, description: "仅 run,必填:本批次的任务、约束与交付要求。" }), mode,
|
|
13
13
|
rounds: Type.Optional(Type.Integer({ minimum: 1, maximum: 10, description: "仅 run:每位成员的轮数,默认 2。" })),
|
|
14
|
-
maxConcurrent: Type.Optional(Type.Integer({ minimum: 1, maximum: 50, description: "仅 run:roundRobin 默认且只允许 1;parallel 默认 min(2, 成员数)
|
|
15
|
-
timeoutSeconds: Type.Optional(Type.Integer({ minimum: 1, maximum: 86400, description: "仅 run:整批期限,默认 900
|
|
14
|
+
maxConcurrent: Type.Optional(Type.Integer({ minimum: 1, maximum: 50, description: "仅 run:roundRobin 默认且只允许 1;parallel 默认 min(2, 成员数)。不得超过成员数;待处理和执行中的发言都计入上限。" })),
|
|
15
|
+
timeoutSeconds: Type.Optional(Type.Integer({ minimum: 1, maximum: 86400, description: "仅 run:整批期限,默认 900 秒,包含所有轮次和等待。到期停止安排并尝试中止尚未人工接管的工作,之后仍须核对实际状态;pause 则允许在途工作收尾。" })),
|
|
16
16
|
};
|
|
17
17
|
const page = {
|
|
18
18
|
afterSeq: Type.Optional(Type.Integer({ minimum: 0, description: "仅 read:读取序号大于此值的消息,默认 0,不得超过 lastSeq。返回 nextAfterSeq 用于继续消息列表;单条续读使用 seq/offset,省略 afterSeq。先补完被截断的正文,再继续列表。" })),
|
|
@@ -23,7 +23,7 @@ const page = {
|
|
|
23
23
|
const object = (fields) => Type.Object(fields, { additionalProperties: false });
|
|
24
24
|
export const teamParametersSchema = object({
|
|
25
25
|
action: Type.Union(["create", "list", "status", "read", "run", "pause", "close"].map(v => Type.Literal(v)), {
|
|
26
|
-
description: "create
|
|
26
|
+
description: "create 必填 name/brief/members;list 只接受 action;status/pause/close 必填 teamId;read 必填 teamId,可选 afterSeq/seq/offset/limit;run 必填 teamId/instruction/mode,可选 rounds/maxConcurrent/timeoutSeconds。只传对应 action 的字段。run 前须确认所有成员存活、idle、可参与团队且无待处理私人输入,团队未关闭,也无运行批次或在途工作。close 前先暂停并等待在途工作结束。",
|
|
27
27
|
}),
|
|
28
28
|
teamId: Type.Optional(id), name: Type.Optional(name), brief: Type.Optional(text), members: Type.Optional(members),
|
|
29
29
|
instruction: Type.Optional(run.instruction), mode: Type.Optional(mode), rounds: run.rounds, maxConcurrent: run.maxConcurrent, timeoutSeconds: run.timeoutSeconds, ...page,
|
|
@@ -38,7 +38,7 @@ export const teamActionSchema = Type.Union([
|
|
|
38
38
|
export const teamMessageParametersSchema = object({
|
|
39
39
|
action: Type.Union([Type.Literal("read"), Type.Literal("post")], {
|
|
40
40
|
description: "read 必填 teamId,只可选 afterSeq/seq/offset/limit,禁止 text/replyTo;post 必填 teamId/text,只可选 replyTo,禁止所有分页字段。",
|
|
41
|
-
}), teamId: id, text: Type.Optional(Type.String({ ...text, description: "仅 post
|
|
41
|
+
}), teamId: id, text: Type.Optional(Type.String({ ...text, description: "仅 post,必填:向全体成员公开的原文。" })),
|
|
42
42
|
replyTo: Type.Optional(Type.Integer({ minimum: 1, description: "仅 post:回复已有消息的 seq。" })), ...page,
|
|
43
43
|
});
|
|
44
44
|
export const teamMessageActionSchema = Type.Union([
|
|
@@ -55,10 +55,10 @@ export const teamPageSchema = object({ teamId: id, messages: Type.Array(message)
|
|
|
55
55
|
nextAfterSeq: Type.Union([Type.Integer(), Type.Null()], { description: "后续消息列表的 afterSeq;null 只表示列表已到末尾,仍须检查每条消息的 nextOffset。指定 seq 时始终为 null。" }) });
|
|
56
56
|
const ownedView = object({ teamId: id, name: Type.String(), brief: Type.String(), closed: Type.Boolean(), owned: Type.Literal(true),
|
|
57
57
|
members: Type.Array(object({ agentId: id, role: Type.String(), name: Type.String(), state: Type.String() })),
|
|
58
|
-
lastSeq: Type.Integer(), activeCount: Type.Integer({ description: "
|
|
58
|
+
lastSeq: Type.Integer(), activeCount: Type.Integer({ description: "各批次仍在途的请求数;paused 时也可能大于 0。" }),
|
|
59
59
|
unresolved: Type.Array(object({ requestId: id, agentId: id, runId: id, round: Type.Integer(), active: Type.Boolean(),
|
|
60
|
-
state: Type.String({ description: "queued
|
|
61
|
-
description: "
|
|
60
|
+
state: Type.String({ description: "queued=待处理;accepted=在途;uncertain=结果未确认;cancelled=未执行或已取消;unpublished=已完成但结果尚未公开;mixed/interactive=含人工或私人工作,不自动公开;failed/interrupted=失败或中断。" }), cycleId: Type.Optional(id) }), {
|
|
61
|
+
description: "各批次尚未确认完成且公开的请求。先核对原请求和实际结果,再决定后续操作,避免重复执行。",
|
|
62
62
|
}),
|
|
63
63
|
run: Type.Optional(object({ runId: id, instruction: Type.String(), mode, state: Type.Union([Type.Literal("running"), Type.Literal("paused"), Type.Literal("finished")]),
|
|
64
64
|
rounds: Type.Integer(), maxConcurrent: Type.Integer(), deadlineAt: Type.Number(), scheduled: Type.Integer(), published: Type.Integer(), reason: Type.Optional(Type.String()) })) });
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "personal-bot",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "personal-bot",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.8",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"ajv": "8.17.1",
|
|
12
12
|
"ajv-formats": "3.0.1",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"@deepseek-ai/cordis": "4.1.0",
|
|
20
20
|
"@deepseek-ai/dsh": "0.2.2-rc.1",
|
|
21
21
|
"@deepseek-ai/dsh-agent": "0.2.2-rc.1",
|
|
22
|
+
"@deepseek-ai/dsh-agent-preset-registry": "0.2.2-rc.1",
|
|
22
23
|
"@deepseek-ai/dsh-api-remotes": "0.2.2-rc.1",
|
|
23
24
|
"@deepseek-ai/dsh-attachment": "0.2.2-rc.1",
|
|
24
25
|
"@deepseek-ai/dsh-client-file-upload": "0.2.2-rc.1",
|
|
@@ -51,33 +52,34 @@
|
|
|
51
52
|
"typescript": "5.9.3"
|
|
52
53
|
},
|
|
53
54
|
"engines": {
|
|
54
|
-
"dsh": "0.2.2-rc.1",
|
|
55
|
+
"dsh": ">=0.2.2-rc.1",
|
|
55
56
|
"node": ">=22.19.0"
|
|
56
57
|
},
|
|
57
58
|
"peerDependencies": {
|
|
58
59
|
"@deepseek-ai/cordis": "~4.1.0",
|
|
59
|
-
"@deepseek-ai/dsh-agent": "
|
|
60
|
-
"@deepseek-ai/dsh-
|
|
61
|
-
"@deepseek-ai/dsh-
|
|
62
|
-
"@deepseek-ai/dsh-
|
|
63
|
-
"@deepseek-ai/dsh-client-
|
|
64
|
-
"@deepseek-ai/dsh-commands": "
|
|
65
|
-
"@deepseek-ai/dsh-
|
|
66
|
-
"@deepseek-ai/dsh-fs
|
|
67
|
-
"@deepseek-ai/dsh-
|
|
68
|
-
"@deepseek-ai/dsh-
|
|
69
|
-
"@deepseek-ai/dsh-
|
|
70
|
-
"@deepseek-ai/dsh-session
|
|
71
|
-
"@deepseek-ai/dsh-session-
|
|
72
|
-
"@deepseek-ai/dsh-
|
|
73
|
-
"@deepseek-ai/dsh-skill
|
|
74
|
-
"@deepseek-ai/dsh-
|
|
75
|
-
"@deepseek-ai/dsh-
|
|
76
|
-
"@deepseek-ai/dsh-
|
|
77
|
-
"@deepseek-ai/dsh-
|
|
78
|
-
"@deepseek-ai/dsh-typert-
|
|
79
|
-
"@deepseek-ai/dsh-
|
|
80
|
-
"@deepseek-ai/dsh-
|
|
60
|
+
"@deepseek-ai/dsh-agent": "*",
|
|
61
|
+
"@deepseek-ai/dsh-agent-preset-registry": "*",
|
|
62
|
+
"@deepseek-ai/dsh-api-remotes": "*",
|
|
63
|
+
"@deepseek-ai/dsh-attachment": "*",
|
|
64
|
+
"@deepseek-ai/dsh-client-file-upload": "*",
|
|
65
|
+
"@deepseek-ai/dsh-client-ui-commands": "*",
|
|
66
|
+
"@deepseek-ai/dsh-commands": "*",
|
|
67
|
+
"@deepseek-ai/dsh-fs": "*",
|
|
68
|
+
"@deepseek-ai/dsh-fs-patch": "*",
|
|
69
|
+
"@deepseek-ai/dsh-home-paths": "*",
|
|
70
|
+
"@deepseek-ai/dsh-llm": "*",
|
|
71
|
+
"@deepseek-ai/dsh-session": "*",
|
|
72
|
+
"@deepseek-ai/dsh-session-persistence": "*",
|
|
73
|
+
"@deepseek-ai/dsh-session-query": "*",
|
|
74
|
+
"@deepseek-ai/dsh-skill": "*",
|
|
75
|
+
"@deepseek-ai/dsh-skill-filesystem": "*",
|
|
76
|
+
"@deepseek-ai/dsh-system-prompt": "*",
|
|
77
|
+
"@deepseek-ai/dsh-tool-executor-ptc": "*",
|
|
78
|
+
"@deepseek-ai/dsh-tools": "*",
|
|
79
|
+
"@deepseek-ai/dsh-typert-protocol": "*",
|
|
80
|
+
"@deepseek-ai/dsh-typert-registry": "*",
|
|
81
|
+
"@deepseek-ai/dsh-user-approval": "*",
|
|
82
|
+
"@deepseek-ai/dsh-working-directory": "*",
|
|
81
83
|
"@earendil-works/pi-ai": "*",
|
|
82
84
|
"@earendil-works/pi-coding-agent": "*",
|
|
83
85
|
"@earendil-works/pi-tui": "*",
|
|
@@ -90,6 +92,9 @@
|
|
|
90
92
|
"@deepseek-ai/dsh-agent": {
|
|
91
93
|
"optional": true
|
|
92
94
|
},
|
|
95
|
+
"@deepseek-ai/dsh-agent-preset-registry": {
|
|
96
|
+
"optional": true
|
|
97
|
+
},
|
|
93
98
|
"@deepseek-ai/dsh-api-remotes": {
|
|
94
99
|
"optional": true
|
|
95
100
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "personal-bot",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/realqiyan/personal-bot.git"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"extensions": [
|
|
23
23
|
"./src/pbot.ts"
|
|
24
24
|
],
|
|
25
|
-
"skills": [],
|
|
25
|
+
"skills": ["./resources/skills"],
|
|
26
26
|
"prompts": [],
|
|
27
27
|
"themes": []
|
|
28
28
|
},
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
],
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=22.19.0",
|
|
59
|
-
"dsh": "0.2.2-rc.1"
|
|
59
|
+
"dsh": ">=0.2.2-rc.1"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"check": "tsc --noEmit && npm run check:dependencies",
|
|
@@ -71,28 +71,29 @@
|
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"@deepseek-ai/cordis": "~4.1.0",
|
|
74
|
-
"@deepseek-ai/dsh-agent": "
|
|
75
|
-
"@deepseek-ai/dsh-
|
|
76
|
-
"@deepseek-ai/dsh-session
|
|
77
|
-
"@deepseek-ai/dsh-session-
|
|
78
|
-
"@deepseek-ai/dsh-
|
|
79
|
-
"@deepseek-ai/dsh-
|
|
80
|
-
"@deepseek-ai/dsh-
|
|
81
|
-
"@deepseek-ai/dsh-
|
|
82
|
-
"@deepseek-ai/dsh-client-
|
|
83
|
-
"@deepseek-ai/dsh-
|
|
84
|
-
"@deepseek-ai/dsh-
|
|
85
|
-
"@deepseek-ai/dsh-
|
|
86
|
-
"@deepseek-ai/dsh-
|
|
87
|
-
"@deepseek-ai/dsh-skill
|
|
88
|
-
"@deepseek-ai/dsh-
|
|
89
|
-
"@deepseek-ai/dsh-
|
|
90
|
-
"@deepseek-ai/dsh-
|
|
91
|
-
"@deepseek-ai/dsh-
|
|
92
|
-
"@deepseek-ai/dsh-
|
|
93
|
-
"@deepseek-ai/dsh-
|
|
94
|
-
"@deepseek-ai/dsh-
|
|
95
|
-
"@deepseek-ai/dsh-typert-
|
|
74
|
+
"@deepseek-ai/dsh-agent": "*",
|
|
75
|
+
"@deepseek-ai/dsh-agent-preset-registry": "*",
|
|
76
|
+
"@deepseek-ai/dsh-session": "*",
|
|
77
|
+
"@deepseek-ai/dsh-session-persistence": "*",
|
|
78
|
+
"@deepseek-ai/dsh-session-query": "*",
|
|
79
|
+
"@deepseek-ai/dsh-llm": "*",
|
|
80
|
+
"@deepseek-ai/dsh-commands": "*",
|
|
81
|
+
"@deepseek-ai/dsh-api-remotes": "*",
|
|
82
|
+
"@deepseek-ai/dsh-client-ui-commands": "*",
|
|
83
|
+
"@deepseek-ai/dsh-client-file-upload": "*",
|
|
84
|
+
"@deepseek-ai/dsh-tools": "*",
|
|
85
|
+
"@deepseek-ai/dsh-home-paths": "*",
|
|
86
|
+
"@deepseek-ai/dsh-system-prompt": "*",
|
|
87
|
+
"@deepseek-ai/dsh-skill": "*",
|
|
88
|
+
"@deepseek-ai/dsh-skill-filesystem": "*",
|
|
89
|
+
"@deepseek-ai/dsh-working-directory": "*",
|
|
90
|
+
"@deepseek-ai/dsh-fs": "*",
|
|
91
|
+
"@deepseek-ai/dsh-attachment": "*",
|
|
92
|
+
"@deepseek-ai/dsh-fs-patch": "*",
|
|
93
|
+
"@deepseek-ai/dsh-user-approval": "*",
|
|
94
|
+
"@deepseek-ai/dsh-tool-executor-ptc": "*",
|
|
95
|
+
"@deepseek-ai/dsh-typert-protocol": "*",
|
|
96
|
+
"@deepseek-ai/dsh-typert-registry": "*",
|
|
96
97
|
"@earendil-works/pi-ai": "*",
|
|
97
98
|
"@earendil-works/pi-coding-agent": "*",
|
|
98
99
|
"@earendil-works/pi-tui": "*",
|
|
@@ -101,6 +102,7 @@
|
|
|
101
102
|
"peerDependenciesMeta": {
|
|
102
103
|
"@deepseek-ai/cordis": { "optional": true },
|
|
103
104
|
"@deepseek-ai/dsh-agent": { "optional": true },
|
|
105
|
+
"@deepseek-ai/dsh-agent-preset-registry": { "optional": true },
|
|
104
106
|
"@deepseek-ai/dsh-session": { "optional": true },
|
|
105
107
|
"@deepseek-ai/dsh-session-persistence": { "optional": true },
|
|
106
108
|
"@deepseek-ai/dsh-session-query": { "optional": true },
|
|
@@ -141,6 +143,7 @@
|
|
|
141
143
|
"@deepseek-ai/cordis": "4.1.0",
|
|
142
144
|
"@deepseek-ai/dsh": "0.2.2-rc.1",
|
|
143
145
|
"@deepseek-ai/dsh-agent": "0.2.2-rc.1",
|
|
146
|
+
"@deepseek-ai/dsh-agent-preset-registry": "0.2.2-rc.1",
|
|
144
147
|
"@deepseek-ai/dsh-api-remotes": "0.2.2-rc.1",
|
|
145
148
|
"@deepseek-ai/dsh-client-ui-commands": "0.2.2-rc.1",
|
|
146
149
|
"@deepseek-ai/dsh-client-file-upload": "0.2.2-rc.1",
|
package/python/README.md
CHANGED
|
@@ -49,7 +49,7 @@ python3 scripts/setup-python.py --check # 只检查,不创建或安装
|
|
|
49
49
|
|
|
50
50
|
## 使用与验证
|
|
51
51
|
|
|
52
|
-
setup 安装 numpy、pandas、TA-Lib、backtesting、scipy、statsmodels、matplotlib、scikit-learn、pyarrow、openpyxl、seaborn 和 Bokeh
|
|
52
|
+
setup 安装 numpy、pandas、TA-Lib、backtesting、scipy、statsmodels、matplotlib、scikit-learn、pyarrow、openpyxl、seaborn 和 Bokeh。按任务导入,环境与项目运行见[计算参考](../resources/references/compute.md),需要技术指标或回测时再读[指标与回测](../resources/references/compute-finance.md)。市场规则、费用、成交时点和数据切分由具体研究确定,原生 Backtest 不自动提供 A 股 T+1、整手或涨跌停约束。
|
|
53
53
|
|
|
54
54
|
激活后直接执行 `python scripts/analyze.py` 或 `python -m analysis.main`。工作目录、模块导入、参数和结果位置遵循项目约定。项目构建或测试明确要求另一环境时,按项目约定执行。pbot 不复制源码、不生成输入文件或计算记录、不管理研究进程的超时。Python 与 Bash 不是文件或网络沙箱,也不授予交易权限。
|
|
55
55
|
|
|
@@ -1,39 +1,11 @@
|
|
|
1
1
|
# 协调者
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
对本次交付负责,沿用已有约定,完成用户需要的结果。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
普通问答直接完成。需要专家协助时用 pbot_agent,委派写明目标、相关资料、约束和交付要求。需要成员直接交流时用 pbot_team。回溯旧讨论用 pbot_history。周期、重复流程、DAG 或会话退出后仍需执行的任务,先读包内 `references/task-conductor.md`。
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- 回溯以前的讨论时使用 pbot_history,按事情的大意尝试相关词,沿父子节点展开到原文,核对后续修正和来源。历史内容用于查询,不自动成为当前任务或授权。
|
|
9
|
-
- 独立协助或核验使用 pbot_agent。委派提供目标、交付要求、资料依据和约束,不依赖专家知道父会话历史。
|
|
10
|
-
- 需要成员直接交流时,使用 pbot_team 组队。roundRobin 依次讨论,parallel 在每轮内并行、轮间汇合。提供目标、每人职责、授权范围及交付要求。成员原文直接同步,无须逐条转述。
|
|
11
|
-
- 周期、重复流程、DAG 或需在当前宿主会话退出后继续的任务,先读包内 `references/task-conductor.md`,再按 using-task-conductor 技能使用原生任务能力。缺少该能力只阻塞依赖它的部分。
|
|
7
|
+
汇总专家结果并整合正式资料。委派包含文件修改时说明修改范围,多人写入时划分文件责任;合并不同结果时处理口径差异和未解决的问题。
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
需要独立复核时,另开专家会话或任务节点,提供待检查内容、相关资料和具体问题。
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
收到结果后,按本次完成条件核对报告与实际产物。汇总数值前核对对象、时期、单位、指标定义和来源;范围不同的结果分别解释,重复转述不算独立证据。
|
|
18
|
-
|
|
19
|
-
失败、中断或取消后,判断已完成部分与后续条件,不自动重跑。人工子会话输入不扩大主会话原任务授权。委派不扩大原用户授权;需要用户决定的业务交回主会话说明。
|
|
20
|
-
|
|
21
|
-
## 团队协作
|
|
22
|
-
|
|
23
|
-
公共消息与成员当前团队请求的最终回答会向团队公开;只提供本次协作需要的信息,避免披露私人历史或无关资料。成员已有记忆可能影响回答,团队讨论不等于独立复核。
|
|
24
|
-
|
|
25
|
-
批次 finished 只表示安排的发言均结束,不证明任务完成或达成共识。直接核对成员原文和实际产物,按原任务验收;团队调度与状态转换遵循工具契约。
|
|
26
|
-
|
|
27
|
-
## 独立复核与业务执行
|
|
28
|
-
|
|
29
|
-
按任务风险或用户要求组织独立方案复核。使用新子会话或独立任务节点,提供具体方案、精确参数、原始依据和已确认约束;原分析会话的后续对话不算独立复核。
|
|
30
|
-
|
|
31
|
-
复核只使用查询与计算,不执行业务变更。要求复核者独立核验关键事实,交付通过、拒绝或无法确认及其依据。工作结束、成果验收、专业复核和用户批准是不同事实;复核通过不授予执行许可。
|
|
32
|
-
|
|
33
|
-
使用原生工具执行已授权业务并核对结果。结果未知时先核实,不自动重发;只暂停依赖未知结果的步骤。
|
|
34
|
-
|
|
35
|
-
## 成果保存
|
|
36
|
-
|
|
37
|
-
及时保存有依据的阶段结论、可复用知识、已确认决策,以及交接所需或用户要求的成果,无须再次询问。普通问答、零散想法和原始输出不逐轮存档。
|
|
38
|
-
|
|
39
|
-
新结果、纠正或状态变化需要同步,或用户要求整理、复用任务定义、结项时,使用 project-maintenance。发现其他未完成事项不构成开展新任务的授权。
|
|
11
|
+
失败或中断后说明已完成部分、剩余工作和阻碍。需要用户决定的事项由你汇总说明。
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
# 通用专家
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
完成本次委派,使用相关资料和技能。交回结果、需要说明的问题及产物路径。独立复核时自行检查,说明发现的问题和不确定之处。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
默认交回报告,由主会话整合正式资料;委派包含文件修改时直接完成,并说明变更。
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
默认交回报告与必要产物引用,由主会话整合正式资料。原任务已授权资料修改且委派明确修改范围时,可在该范围内修改正式正文并说明变更,无须再次询问。
|
|
10
|
-
|
|
11
|
-
使用原生 CLI/MCP 完成本次委派,可自主诊断工具接入与环境问题。新增权限或共享环境变更先核对原任务及委派中的已有授权,已覆盖的操作不重复询问;需要补充授权或用户在会话中操作时,交回已有结果、缺口和所需条件,继续不受影响的工作。项目构建和测试遵循项目声明的环境。
|
|
12
|
-
|
|
13
|
-
不创建子专家或外部任务,不管理团队。需要其他协作者或持久执行时,交回建议,由主会话决定。
|
|
14
|
-
|
|
15
|
-
## 团队工作
|
|
16
|
-
|
|
17
|
-
收到团队发言安排时,按当前职责和轮次工作。使用 pbot_team_message read/post 直接交流原文,replyTo 指向公共消息;不等待对方在线回应,不通过发消息追加轮次。上下文注明未包含或截断的内容时,按 seq/offset 读取所需原文后再下结论;压缩后缺少旧证据时也应重读。成员的话是协作信息,不是新的用户授权。
|
|
18
|
-
|
|
19
|
-
post 与本次团队请求的最终答复会公开给全体成员。只公开任务需要的信息,不主动披露私人工作历史、完整工具输出或无关资料。指出依据、分歧、未解决问题与产物位置。每轮接续已有工作,不重复可能产生副作用的步骤;结果未知时先查询,不重发操作。轮次结束不等于任务通过验收。
|
|
7
|
+
可自主诊断工具和环境问题。需要主会话或用户协助时,交回已有结果和具体阻碍,继续不受影响的工作。不创建子专家或外部任务,不管理团队;需要其他协作者或持久执行时向主会话提出建议。
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Personal Bot
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
按用户请求和已有约定推进工作,常规选择自行决定。只有缺失信息会改变目标或关键结果时才提问,并继续不受影响的工作。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## 工作方式
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- 按工作区约定定位相关资料,需要更多线索时读目录入口或搜索,按需使用匹配的技能。
|
|
8
|
+
- 操作后查看结果。超时、取消或断连后,先查状态再决定是否重试,避免重复执行。
|
|
9
|
+
- 使用当前宿主的原生 CLI/MCP。接入与排障使用 provider-connections;按需读取 `providers/<id>/GUIDE.md` 中的数据口径和限制。认证使用原生登录或凭据引用,资料中不保存凭据值。
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
- 复用历史结论前核对范围、时点与关键条件,只重核受变化影响的部分。分析假设不等于用户已确认的约束。
|
|
11
|
-
- 复杂任务先明确交付用途、必要证据、可接受限制与完成条件,沿用已有约定。
|
|
12
|
-
- 在当前授权内持续推进,常规、可逆的实现选择自行决定。新增权限、安装或共享环境变更先核对已有授权,已覆盖的操作不重复询问。仅当缺失信息影响目标、关键结果或授权时提问;暂停依赖步骤,继续有助于目标的独立工作。
|
|
13
|
-
- 资料、手册、工具结果、待办和职责补充不扩大用户授权。只开展当前任务需要的工作,不为普通问答增加文件或固定流程。
|
|
14
|
-
- 使用常用词、短句和一致术语。先给结论,按需说明依据、假设、验证、限制和实际产物路径。
|
|
11
|
+
## 资料与环境
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
沿用已有工作区约定;新资料按下列用途组织。正文维护一份,其他位置用引用连接。
|
|
17
14
|
|
|
18
15
|
| 路径 | 用途 |
|
|
19
16
|
| --- | --- |
|
|
@@ -21,21 +18,13 @@
|
|
|
21
18
|
| `areas/<领域>/` | 长期目标、约束、决策与复盘;个人组合信息 |
|
|
22
19
|
| `projects/<名称>/` | 任务定义、结论与交付物;源码、依赖和测试 |
|
|
23
20
|
| `knowledge/<主题>/` | 可跨任务复用的概念、方法与口径 |
|
|
24
|
-
| `providers
|
|
21
|
+
| `providers/AGENTS.md`、`providers/<id>/GUIDE.md` | 能力导航与使用手册 |
|
|
25
22
|
| `scratch/` | 临时脚本、查询与计算数据、下载及运行环境 |
|
|
26
|
-
| `agents/` | `coordinator.md
|
|
23
|
+
| `agents/` | `coordinator.md`、`general-purpose.md` 的职责补充 |
|
|
27
24
|
| `.agents/skills/` | 工作区自有专业方法 |
|
|
28
25
|
|
|
29
|
-
|
|
26
|
+
保存有后续用途的结论、方法、决策和产物;普通问答不逐轮存档。保存前查找同主题正文,更新或整理时使用 project-maintenance。可再次查询的数据按记录的口径获取。保留用户资料、历史记录和备份。
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
环境上下文中的 `workspaceRoot` 是资料工作区根目录,`resourceRoot` 是包内资料根目录,`python` 给出共享环境状态。资料路径相对工作区根目录,命令与文件工具按实际 cwd 解析路径。需要 Python 时读取包内 `references/compute.md`;共享环境未就绪时不退回系统 Python。项目构建和测试遵循项目声明的环境。
|
|
32
29
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
CLI 通过 Bash 使用原生命令与当前 help,MCP 使用当前宿主的原生接入与工具定义,Pi 和 dsh 配置分别管理。先按需读取 providers/ 中的手册,了解数据口径和限制;接入或修复使用 provider-connections 技能。不索取、输出或保存凭据值。目标、市场和偏好保存在所属普通资料中。
|
|
36
|
-
|
|
37
|
-
按用户授权执行本次业务。研究、接入和验证不授权交易、转账或账本修改。协议成功不证明业务完成;超时、断连和取消不证明未执行。可能已发送的操作先查询原生状态,不因恢复会话或结果缺失自动重发。
|
|
38
|
-
|
|
39
|
-
共享 Python 环境为 ready 时,通过 Bash 使用 python 或 python3 和第三方库原生 API。环境异常可自主诊断,只暂停依赖该环境的步骤,不自行退回系统 Python;项目构建和测试遵循项目声明的环境。运行计算前按需读取包内 `references/compute.md`,按项目约定选择工作目录并保存必要产物。
|
|
40
|
-
|
|
41
|
-
Bash、Python、MCP 和其他扩展具有实际账户与凭据权限,不是沙箱。
|
|
30
|
+
答复先给结论,按需补充说明和产物路径。数值注明影响理解的对象、期间、单位与口径。
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# 指标与回测
|
|
2
|
+
|
|
3
|
+
## TA-Lib
|
|
4
|
+
|
|
5
|
+
通过 `import talib` 使用原生函数。用 `talib.get_function_groups()`、`talib.get_functions()` 和 `help(talib.函数名)` 核对能力、参数与返回值。
|
|
6
|
+
|
|
7
|
+
计算前核对时间顺序、复权、缺失数据、单位与样本长度,多输入 OHLCV 数组必须按同一时间轴对齐。保留影响结果解释的原生规则:
|
|
8
|
+
|
|
9
|
+
- `MACD` 返回 `(macd, signal, hist)`,其中 `hist = macd - signal`,不乘 2。
|
|
10
|
+
- `BBANDS` 返回 `(upper, middle, lower)`,默认使用 SMA 中轨和两倍总体标准差。
|
|
11
|
+
- 暖机期为 NaN,例如 SMA(20) 前 19 根、RSI(14) 前 14 根不可用。EMA、RSI 的种子和平滑规则不等同于直接 pandas ewm;持平序列的 RSI 暖机后为 0,不是 50。
|
|
12
|
+
- NaN 输入可能影响后续输出,不擅自填零或把暖机值当成信号。严格 JSON 中将非有限值转为 null。
|
|
13
|
+
|
|
14
|
+
按需记录参数、库版本和数据来源,便于复现。
|
|
15
|
+
|
|
16
|
+
## backtesting
|
|
17
|
+
|
|
18
|
+
用 `from backtesting import Backtest, Strategy`,通过 Strategy 的 `init()`、`next()` 定义策略,再运行 `Backtest(data, 策略类, ...).run()`。数据为按时间升序的 OHLC DataFrame,可带 Volume;参数以当前版本 API 为准。TA-Lib 指标可用 `self.I(talib.SMA, self.data.Close, 20)` 注册。
|
|
19
|
+
|
|
20
|
+
显式确定资金、手续费、价差、成交时点与仓位假设。原生 Backtest 不自动提供 A 股 T+1、整手买入、涨跌停或交易日历约束;任务需要时明确建模和验证,无法表达时说明限制,不把默认值当作市场规则。
|
|
21
|
+
|
|
22
|
+
按研究问题选择样本内外划分及暖机方法,避免未来数据泄漏。交付时说明参数、版本与限制,按需保留统计和交易记录;导出时处理 Series、DataFrame、时间和非有限值。
|