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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +5 -8
- package/README.zh-CN.md +5 -8
- package/bin/pbot-pi-acp.mjs +1 -1
- package/docs/README.md +1 -1
- package/docs/architecture/design.md +2 -2
- package/docs/architecture/extensibility.md +1 -1
- package/docs/architecture/model-context.md +1 -2
- package/docs/guides/capabilities.md +4 -8
- package/docs/guides/cross-harness-workers.md +4 -4
- package/docs/guides/history.md +1 -3
- package/docs/guides/workspace-configuration.md +4 -4
- package/docs/hosts/claude-code.md +2 -2
- package/docs/hosts/codex-qoder.md +1 -1
- package/lib/antigravity-plugin/bin/pbot-pi-acp.mjs +1 -1
- package/lib/antigravity-plugin/lib/extension/acp/member.d.ts +1 -1
- package/lib/antigravity-plugin/lib/extension/acp/member.js +11 -10
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +348 -203
- package/lib/antigravity-plugin/lib/extension/cli.js +574 -549
- package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-member.js +1 -1
- package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.js +3 -4
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +0 -11
- package/lib/antigravity-plugin/lib/extension/mcp.js +462 -326
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +2 -2
- package/lib/antigravity-plugin/lib/model/acp.d.ts +29 -35
- package/lib/antigravity-plugin/lib/model/agent.d.ts +33 -17
- package/lib/antigravity-plugin/lib/model/agent.js +0 -1
- package/lib/antigravity-plugin/lib/storage/acp-files.d.ts +5 -8
- package/lib/antigravity-plugin/lib/storage/acp-files.js +34 -40
- package/lib/antigravity-plugin/lib/storage/agent-files.d.ts +19 -10
- package/lib/antigravity-plugin/lib/storage/agent-files.js +147 -43
- package/lib/antigravity-plugin/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +1 -1
- package/lib/antigravity-plugin/resources/agents/coordinator.md +3 -7
- package/lib/antigravity-plugin/resources/agents/general-purpose.md +3 -3
- package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -2
- package/lib/antigravity-plugin/resources/prompts/workspace.md +12 -16
- package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +7 -6
- package/lib/antigravity-plugin/resources/templates/workspace-agents.md +0 -4
- package/lib/antigravity-plugin/skills/pbot/SKILL.md +14 -6
- package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +7 -6
- package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +1 -1
- package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +2 -2
- package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +3 -3
- package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +2 -2
- package/lib/extension/acp/member.d.ts +1 -1
- package/lib/extension/acp/member.js +11 -10
- package/lib/extension/acp/worker.js +34 -33
- package/lib/extension/acp-worker.js +348 -203
- package/lib/extension/cli.js +574 -549
- package/lib/extension/hosts/dsh/acp-member.js +1 -1
- package/lib/extension/hosts/dsh/command.js +1 -1
- package/lib/extension/hosts/dsh/workspace.js +1 -3
- package/lib/extension/hosts/pi/acp-member.js +3 -4
- package/lib/extension/hosts/plugin-runtime.js +0 -11
- package/lib/extension/mcp/tool-contract.d.ts +8 -50
- package/lib/extension/mcp/tool-contract.js +48 -62
- package/lib/extension/mcp/workers.d.ts +13 -27
- package/lib/extension/mcp/workers.js +60 -25
- package/lib/extension/mcp.js +462 -326
- package/lib/integrations/acp/agents.d.ts +2 -3
- package/lib/integrations/acp/agents.js +22 -22
- package/lib/integrations/acp/harnesses/claude.js +1 -1
- package/lib/integrations/agent-resources.js +2 -2
- package/lib/model/acp.d.ts +29 -35
- package/lib/model/agent.d.ts +33 -17
- package/lib/model/agent.js +0 -1
- package/lib/qoder-plugin/.mcp.json +2 -2
- package/lib/qoder-plugin/.qoder-plugin/plugin.json +1 -1
- package/lib/qoder-plugin/hooks/hooks.json +3 -3
- package/lib/qoder-plugin/skills/pbot/SKILL.md +2 -2
- package/lib/services/agents/acp-run.d.ts +6 -4
- package/lib/services/agents/acp-run.js +62 -43
- package/lib/services/agents/agent-run.d.ts +10 -6
- package/lib/services/agents/agent-run.js +142 -65
- package/lib/services/agents/agent-service.d.ts +3 -21
- package/lib/services/agents/agent-service.js +180 -126
- package/lib/storage/acp-files.d.ts +5 -8
- package/lib/storage/acp-files.js +34 -40
- package/lib/storage/agent-files.d.ts +19 -10
- package/lib/storage/agent-files.js +147 -43
- package/lib/tools/history/contract.js +12 -12
- package/package.json +1 -1
- package/resources/agents/coordinator.md +3 -7
- package/resources/agents/general-purpose.md +3 -3
- package/resources/antigravity/skills/pbot/SKILL.md +14 -6
- package/resources/claude/skills/pbot/SKILL.md +14 -6
- package/resources/plugin/skills/pbot/SKILL.md +2 -2
- package/resources/prompts/history-coordinator.md +1 -2
- package/resources/prompts/plugin-coordinator.md +1 -2
- package/resources/prompts/workspace.md +12 -16
- package/resources/skills/provider-connections/SKILL.md +7 -6
- package/resources/templates/workspace-agents.md +0 -4
- package/src/extension/acp/member.ts +14 -11
- package/src/extension/acp/worker.ts +31 -28
- package/src/extension/cli/commands/upgrade.ts +8 -36
- package/src/extension/cli/commands/workspace.ts +3 -8
- package/src/extension/cli/index.ts +1 -2
- package/src/extension/hosts/dsh/acp-member.ts +1 -1
- package/src/extension/hosts/dsh/command.ts +1 -1
- package/src/extension/hosts/dsh/workspace.ts +1 -3
- package/src/extension/hosts/pi/acp-member.ts +3 -4
- package/src/extension/hosts/pi/command.ts +1 -1
- package/src/extension/hosts/pi/lifecycle.ts +0 -2
- package/src/extension/hosts/plugin-runtime.ts +0 -10
- package/src/extension/mcp/tool-contract.ts +48 -62
- package/src/extension/mcp/workers.ts +66 -27
- package/src/integrations/acp/agents.ts +28 -27
- package/src/integrations/acp/harnesses/claude.ts +1 -1
- package/src/integrations/agent-resources.ts +2 -2
- package/src/integrations/hosts/dsh/session.ts +2 -2
- package/src/integrations/installation/cli-update.ts +2 -2
- package/src/integrations/installation/installers/claude.ts +4 -4
- package/src/integrations/installation/installers/qoder.ts +5 -5
- package/src/integrations/installation/upgraders/antigravity.ts +57 -15
- package/src/integrations/installation/upgraders/claude.ts +1 -4
- package/src/integrations/installation/upgraders/codex.ts +85 -15
- package/src/integrations/installation/upgraders/dsh.ts +46 -24
- package/src/integrations/installation/upgraders/pi.ts +18 -11
- package/src/integrations/installation/upgraders/qoder.ts +95 -20
- package/src/model/acp.ts +27 -29
- package/src/model/agent.ts +80 -16
- package/src/model/installation.ts +0 -2
- package/src/pbot.ts +2 -2
- package/src/services/agents/acp-run.ts +81 -49
- package/src/services/agents/agent-run.ts +154 -56
- package/src/services/agents/agent-service.ts +204 -133
- package/src/services/installation/upgrade-service.ts +1 -5
- package/src/storage/acp-files.ts +50 -45
- package/src/storage/agent-files.ts +159 -46
- package/src/tools/history/contract.ts +12 -12
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +0 -15
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +0 -126
- package/lib/antigravity-plugin/resources/references/compute-finance.md +0 -22
- package/lib/antigravity-plugin/resources/references/compute.md +0 -16
- package/lib/antigravity-plugin/resources/references/task-conductor.md +0 -25
- package/lib/services/workspace/plugin-releases.d.ts +0 -15
- package/lib/services/workspace/plugin-releases.js +0 -126
- package/resources/references/compute-finance.md +0 -22
- package/resources/references/compute.md +0 -16
- package/resources/references/task-conductor.md +0 -25
- package/src/services/workspace/plugin-releases.ts +0 -121
package/src/storage/acp-files.ts
CHANGED
|
@@ -3,72 +3,77 @@ import { object } from "../common/json.js";
|
|
|
3
3
|
import { isAcpBackend, isOneOf, requireThat } from "../common/validation.js";
|
|
4
4
|
import { fileId } from "./file-access.js";
|
|
5
5
|
import { acpAnswerStates, acpElicitationActions, acpPermissionPolicies, isAcpElicitationValue } from "../model/acp.js";
|
|
6
|
-
import type { AcpAnswer,
|
|
6
|
+
import type { AcpAnswer, AcpInput, AcpInteraction, AcpInteractionReply, AcpSessionReference } from "../model/acp.js";
|
|
7
|
+
import type { AgentAcpConfig } from "../model/agent.js";
|
|
7
8
|
|
|
8
9
|
const text = (value: unknown): value is string => typeof value === "string" && value.length > 0 && !value.includes("\0");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
(value.
|
|
10
|
+
|
|
11
|
+
export function acpConfig(value: unknown): AgentAcpConfig {
|
|
12
|
+
requireThat(object(value) && isAcpBackend(value.backend) &&
|
|
13
|
+
text(value.command) && isAbsolute(value.command) &&
|
|
14
|
+
Array.isArray(value.args) && value.args.every(arg => typeof arg === "string" && !arg.includes("\0")), "ACP 启动配置无效。");
|
|
13
15
|
if (value.env !== undefined) {
|
|
14
16
|
requireThat(object(value.env) && Object.entries(value.env).every(([k, v]) => text(k) && typeof v === "string" && !v.includes("\0")), "ACP 环境变量配置无效。");
|
|
15
17
|
}
|
|
16
18
|
requireThat(value.permission === undefined || isOneOf(value.permission, acpPermissionPolicies), "ACP 权限策略无效。");
|
|
19
|
+
return value as unknown as AgentAcpConfig;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function acpReference(value: unknown): AcpSessionReference {
|
|
23
|
+
requireThat(object(value) && value.host === "acp" && (value.sessionId === null || text(value.sessionId)), "ACP 会话引用无效。");
|
|
24
|
+
acpConfig(value);
|
|
17
25
|
const capabilities = value.capabilities;
|
|
18
|
-
if (capabilities !== undefined)
|
|
19
|
-
|
|
26
|
+
if (capabilities !== undefined) {
|
|
27
|
+
requireThat(object(capabilities) &&
|
|
28
|
+
["resume", "load", "close"].every(key => typeof capabilities[key] === "boolean"), "ACP 会话能力无效。");
|
|
29
|
+
}
|
|
20
30
|
return value as unknown as AcpSessionReference;
|
|
21
31
|
}
|
|
22
|
-
|
|
23
|
-
requireThat(object(value) && text(value.generation) && ["provider", "model", "resolvedModel", "thinking"].every(key => value[key] === undefined || text(value[key])), "ACP 模型选择无效。");
|
|
24
|
-
return value as unknown as AcpModelState;
|
|
25
|
-
}
|
|
26
|
-
export function acpProcess(value: unknown): AcpProcess {
|
|
27
|
-
requireThat(object(value) && text(value.generation) && Number.isSafeInteger(value.pid) && Number(value.pid) > 1 &&
|
|
28
|
-
typeof value.startedAt === "number" && Number.isFinite(value.startedAt), "ACP 进程记录无效。");
|
|
29
|
-
return value as unknown as AcpProcess;
|
|
30
|
-
}
|
|
32
|
+
|
|
31
33
|
export function acpInput(value: unknown): AcpInput {
|
|
32
34
|
requireThat(object(value) && text(value.generation) && text(value.requestId), "ACP 输入关联无效。");
|
|
33
|
-
fileId(value.requestId);
|
|
35
|
+
fileId(value.requestId);
|
|
36
|
+
return value as unknown as AcpInput;
|
|
34
37
|
}
|
|
38
|
+
|
|
35
39
|
export function acpAnswer(value: unknown): AcpAnswer {
|
|
36
40
|
acpInput(value);
|
|
37
41
|
requireThat(object(value) && typeof value.answer === "string" && isOneOf(value.state, acpAnswerStates) &&
|
|
38
42
|
(value.error === undefined || typeof value.error === "string"), "ACP 最终回答无效。");
|
|
39
43
|
return value as unknown as AcpAnswer;
|
|
40
44
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
fileId(value.cycleId); return value as unknown as AcpReport;
|
|
44
|
-
}
|
|
45
|
-
export function acpPermission(value: unknown): AcpPermission {
|
|
46
|
-
acpInput(value);
|
|
47
|
-
requireThat(object(value) && typeof value.description === "string" && Array.isArray(value.options) && value.options.every(option =>
|
|
48
|
-
object(option) && text(option.optionId) && text(option.name) && isOneOf(option.kind, ["allow_once", "allow_always", "reject_once", "reject_always"])), "ACP 确认请求无效。");
|
|
49
|
-
return value as unknown as AcpPermission;
|
|
50
|
-
}
|
|
51
|
-
export function acpPermissionReply(value: unknown): AcpPermissionReply {
|
|
52
|
-
acpInput(value);
|
|
53
|
-
requireThat(object(value) && (value.optionId === null || text(value.optionId)), "ACP 确认答复无效。");
|
|
54
|
-
return value as unknown as AcpPermissionReply;
|
|
55
|
-
}
|
|
56
|
-
export function acpElicitation(value: unknown): AcpElicitation {
|
|
45
|
+
|
|
46
|
+
export function acpInteraction(value: unknown): AcpInteraction {
|
|
57
47
|
acpInput(value);
|
|
58
|
-
requireThat(object(value)
|
|
59
|
-
if (value.
|
|
60
|
-
requireThat(
|
|
61
|
-
|
|
62
|
-
|
|
48
|
+
requireThat(object(value), "ACP 交互请求无效。");
|
|
49
|
+
if (value.kind === "permission") {
|
|
50
|
+
requireThat(typeof value.description === "string" && Array.isArray(value.options) && value.options.every(option =>
|
|
51
|
+
object(option) && text(option.optionId) && text(option.name) && isOneOf(option.kind, ["allow_once", "allow_always", "reject_once", "reject_always"])), "ACP 确认请求无效。");
|
|
52
|
+
return value as unknown as AcpInteraction;
|
|
53
|
+
}
|
|
54
|
+
if (value.kind === "form") {
|
|
55
|
+
requireThat(typeof value.message === "string" && object(value.schema), "ACP 表单交互请求缺少有效 schema。");
|
|
56
|
+
return value as unknown as AcpInteraction;
|
|
63
57
|
}
|
|
64
|
-
|
|
58
|
+
requireThat(value.kind === "url" && typeof value.message === "string" && text(value.url), "ACP URL 交互请求无效。");
|
|
59
|
+
return value as unknown as AcpInteraction;
|
|
65
60
|
}
|
|
66
|
-
|
|
61
|
+
|
|
62
|
+
export function acpInteractionReply(value: unknown): AcpInteractionReply {
|
|
67
63
|
acpInput(value);
|
|
68
|
-
requireThat(object(value)
|
|
69
|
-
if (value.
|
|
70
|
-
requireThat(value.
|
|
71
|
-
|
|
64
|
+
requireThat(object(value), "ACP 交互答复无效。");
|
|
65
|
+
if (value.kind === "permission") {
|
|
66
|
+
requireThat(value.optionId === null || text(value.optionId), "ACP 确认答复无效。");
|
|
67
|
+
return value as unknown as AcpInteractionReply;
|
|
68
|
+
}
|
|
69
|
+
if (value.kind === "form") {
|
|
70
|
+
requireThat(isOneOf(value.action, acpElicitationActions), "ACP 表单答复 action 无效。");
|
|
71
|
+
if (value.content !== undefined) {
|
|
72
|
+
requireThat(value.action === "accept" && object(value.content) &&
|
|
73
|
+
Object.values(value.content).every(isAcpElicitationValue), "ACP 表单答复 content 无效。");
|
|
74
|
+
}
|
|
75
|
+
return value as unknown as AcpInteractionReply;
|
|
72
76
|
}
|
|
73
|
-
|
|
77
|
+
requireThat(value.kind === "url" && isOneOf(value.action, acpElicitationActions), "ACP URL 交互答复无效。");
|
|
78
|
+
return value as unknown as AcpInteractionReply;
|
|
74
79
|
}
|
|
@@ -1,43 +1,103 @@
|
|
|
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,
|
|
9
|
-
import type {
|
|
8
|
+
import { agentStates, cycleStates, messageDeliveries } from "../model/agent.js";
|
|
9
|
+
import type {
|
|
10
|
+
AgentCycle,
|
|
11
|
+
AgentDescriptor,
|
|
12
|
+
AgentMessage,
|
|
13
|
+
AgentOutput,
|
|
14
|
+
AgentSessionReference,
|
|
15
|
+
AgentStatus,
|
|
16
|
+
AgentWorkerRecord,
|
|
17
|
+
} from "../model/agent.js";
|
|
10
18
|
import type { AcpSessionReference } from "../model/acp.js";
|
|
11
|
-
import {
|
|
19
|
+
import { acpConfig, acpInteraction, acpReference } from "./acp-files.js";
|
|
12
20
|
|
|
13
21
|
const text = (v: unknown): v is string => typeof v === "string" && v.length > 0;
|
|
14
22
|
const number = (v: unknown): v is number => typeof v === "number" && Number.isFinite(v);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
|
|
24
|
+
export function workerRecord(v: unknown): AgentWorkerRecord {
|
|
25
|
+
requireThat(object(v) && text(v.agentId) && text(v.release) && text(v.workspace) && text(v.parentSessionId) &&
|
|
26
|
+
text(v.generation) && Number.isSafeInteger(v.sequence) && typeof v.stop === "boolean" && number(v.startedAt) &&
|
|
27
|
+
(v.pid === undefined || (Number.isSafeInteger(v.pid) && Number(v.pid) > 1)) &&
|
|
28
|
+
(v.options === undefined || object(v.options)), "worker 控制记录无效。");
|
|
29
|
+
fileId(v.agentId as string);
|
|
30
|
+
acpConfig(v.acp);
|
|
31
|
+
return v as unknown as AgentWorkerRecord;
|
|
23
32
|
}
|
|
33
|
+
|
|
24
34
|
export function message(v: unknown): AgentMessage {
|
|
25
35
|
requireThat(object(v) && text(v.requestId) && text(v.generation) && Number.isSafeInteger(v.sequence) && typeof v.message === "string" &&
|
|
26
36
|
isOneOf(v.delivery, messageDeliveries) && Array.isArray(v.files) && v.files.every(text), "子会话消息无效。");
|
|
27
37
|
return v as unknown as AgentMessage;
|
|
28
38
|
}
|
|
39
|
+
|
|
29
40
|
export function cycle(v: unknown): AgentCycle {
|
|
30
41
|
requireThat(object(v) && text(v.cycleId) && text(v.generation) && number(v.startedAt) &&
|
|
31
|
-
isOneOf(v.state, cycleStates) &&
|
|
32
|
-
(v.
|
|
33
|
-
|
|
42
|
+
isOneOf(v.state, cycleStates) && Array.isArray(v.requestIds) && v.requestIds.every(text) &&
|
|
43
|
+
(v.finishedAt === undefined || number(v.finishedAt)) &&
|
|
44
|
+
(v.error === undefined || typeof v.error === "string"), "子会话周期无效。");
|
|
34
45
|
return v as unknown as AgentCycle;
|
|
35
46
|
}
|
|
47
|
+
|
|
36
48
|
export function status(v: unknown): AgentStatus {
|
|
37
49
|
requireThat(object(v) && text(v.generation) && isOneOf(v.state, agentStates) &&
|
|
38
50
|
typeof v.activity === "string" && number(v.updatedAt), "子会话状态无效。");
|
|
39
|
-
if (v.
|
|
51
|
+
if (v.sessionId !== undefined) requireThat(v.sessionId === null || text(v.sessionId), "ACP 会话 ID 无效。");
|
|
52
|
+
if (v.capabilities !== undefined) {
|
|
53
|
+
requireThat(object(v.capabilities) &&
|
|
54
|
+
["resume", "load", "close"].every(key => typeof (v.capabilities as Record<string, unknown>)[key] === "boolean"), "ACP 会话能力无效。");
|
|
55
|
+
}
|
|
56
|
+
if (v.selection !== undefined) {
|
|
57
|
+
requireThat(object(v.selection) &&
|
|
58
|
+
["provider", "model", "resolvedModel", "thinking"].every(key => (v.selection as Record<string, unknown>)[key] === undefined || text((v.selection as Record<string, unknown>)[key])), "ACP 模型选择无效。");
|
|
59
|
+
}
|
|
60
|
+
if (v.activeRequestId !== undefined) {
|
|
61
|
+
requireThat(text(v.activeRequestId), "ACP 输入关联无效。");
|
|
62
|
+
fileId(v.activeRequestId);
|
|
63
|
+
}
|
|
64
|
+
if (v.accepted !== undefined) requireThat(Array.isArray(v.accepted) && v.accepted.every(text), "已领取请求列表无效。");
|
|
65
|
+
if (v.cycle !== undefined) cycle(v.cycle);
|
|
66
|
+
if (v.error !== undefined) requireThat(typeof v.error === "string", "子会话错误信息无效。");
|
|
67
|
+
return v as unknown as AgentStatus;
|
|
40
68
|
}
|
|
69
|
+
|
|
70
|
+
export function outputRecord(v: unknown): AgentOutput {
|
|
71
|
+
requireThat(object(v) && text(v.cycleId) && text(v.generation) && number(v.startedAt) && number(v.finishedAt) &&
|
|
72
|
+
isOneOf(v.state, ["completed", "failed", "cancelled", "interrupted"] as const) &&
|
|
73
|
+
Array.isArray(v.requestIds) && v.requestIds.every(text) &&
|
|
74
|
+
typeof v.text === "string" && (v.error === undefined || typeof v.error === "string"), "子会话输出记录无效。");
|
|
75
|
+
fileId(v.cycleId as string);
|
|
76
|
+
return v as unknown as AgentOutput;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function toDescriptor(record: AgentWorkerRecord): AgentDescriptor {
|
|
80
|
+
return {
|
|
81
|
+
agentId: record.agentId,
|
|
82
|
+
release: record.release,
|
|
83
|
+
workspace: record.workspace,
|
|
84
|
+
parentSessionId: record.parentSessionId,
|
|
85
|
+
options: record.options ?? {},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function tryUnlink(path: string) {
|
|
90
|
+
try { unlinkSync(path); } catch (error) { if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error; }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function tryRmdir(path: string) {
|
|
94
|
+
try { rmdirSync(path); }
|
|
95
|
+
catch (error) {
|
|
96
|
+
const code = (error as NodeJS.ErrnoException).code;
|
|
97
|
+
if (code !== "ENOENT" && code !== "ENOTEMPTY" && code !== "EEXIST") throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
41
101
|
export class AgentFiles {
|
|
42
102
|
#failure: unknown;
|
|
43
103
|
constructor(readonly root: string) {}
|
|
@@ -55,51 +115,101 @@ export class AgentFiles {
|
|
|
55
115
|
catch (error) { this.fail(error); throw error; }
|
|
56
116
|
requireThat(published, "子会话文件已存在。");
|
|
57
117
|
}
|
|
58
|
-
|
|
118
|
+
remove(id: string, path: string) {
|
|
119
|
+
tryUnlink(join(this.directory(id), path));
|
|
120
|
+
}
|
|
121
|
+
create(value: AgentDescriptor, run: { generation: string; sequence: number; stop: boolean; startedAt: number }, acp: AcpSessionReference) {
|
|
59
122
|
this.check();
|
|
60
123
|
acpReference(acp);
|
|
61
124
|
mkdirSync(this.root, { recursive: true, mode: 0o700 });
|
|
62
125
|
mkdirSync(this.directory(value.agentId), { mode: 0o700 });
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
126
|
+
const hasOptions = Object.keys(value.options).length > 0;
|
|
127
|
+
const record: AgentWorkerRecord = {
|
|
128
|
+
agentId: value.agentId,
|
|
129
|
+
release: value.release,
|
|
130
|
+
workspace: value.workspace,
|
|
131
|
+
parentSessionId: value.parentSessionId,
|
|
132
|
+
generation: run.generation,
|
|
133
|
+
sequence: run.sequence,
|
|
134
|
+
stop: run.stop,
|
|
135
|
+
startedAt: run.startedAt,
|
|
136
|
+
acp: {
|
|
137
|
+
backend: acp.backend,
|
|
138
|
+
command: acp.command,
|
|
139
|
+
args: acp.args,
|
|
140
|
+
...(acp.env ? { env: acp.env } : {}),
|
|
141
|
+
...(acp.permission ? { permission: acp.permission } : {}),
|
|
142
|
+
},
|
|
143
|
+
...(hasOptions ? { options: value.options } : {}),
|
|
144
|
+
};
|
|
145
|
+
this.write(value.agentId, "worker.json", record, workerRecord, true);
|
|
67
146
|
}
|
|
68
|
-
|
|
147
|
+
worker(id: string): AgentWorkerRecord {
|
|
148
|
+
return this.read(id, "worker.json", workerRecord);
|
|
149
|
+
}
|
|
150
|
+
list(): AgentWorkerRecord[] {
|
|
69
151
|
if (!existsSync(this.root)) return [];
|
|
70
152
|
return readdirSync(this.root, { withFileTypes: true }).filter(e => e.isDirectory() && !e.name.startsWith(".")).flatMap(e => {
|
|
71
|
-
const
|
|
153
|
+
const record = this.optional(e.name, "worker.json", workerRecord);
|
|
154
|
+
return record ? [record] : [];
|
|
72
155
|
});
|
|
73
156
|
}
|
|
74
|
-
messages(id: string) {
|
|
75
|
-
|
|
157
|
+
messages(id: string): AgentMessage[] {
|
|
158
|
+
const dir = join(this.directory(id), "inbox");
|
|
159
|
+
if (!existsSync(dir)) return [];
|
|
160
|
+
return readdirSync(dir).filter(n => n.endsWith(".json"))
|
|
76
161
|
.map(n => this.read(id, "inbox/" + n, message)).sort((a, b) => a.sequence - b.sequence);
|
|
77
162
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
163
|
+
removeMessage(id: string, requestId: string) {
|
|
164
|
+
fileId(requestId);
|
|
165
|
+
const dir = join(this.directory(id), "inbox");
|
|
166
|
+
tryUnlink(join(dir, requestId + ".json"));
|
|
167
|
+
tryRmdir(dir);
|
|
168
|
+
}
|
|
169
|
+
output(id: string): AgentOutput | undefined {
|
|
170
|
+
return this.optional(id, "output.json", outputRecord);
|
|
81
171
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const dir = join(this.directory(id), "permissions");
|
|
172
|
+
pendingInteractions(id: string, generation: string) {
|
|
173
|
+
const dir = join(this.directory(id), "interactions");
|
|
85
174
|
if (!existsSync(dir)) return [];
|
|
86
175
|
const names = readdirSync(dir);
|
|
87
176
|
return names.filter(n => n.endsWith(".json") && !n.endsWith("-reply.json") && !names.includes(n.slice(0, -5) + "-reply.json"))
|
|
88
|
-
.map(n => this.read(id, "
|
|
177
|
+
.map(n => this.read(id, "interactions/" + n, acpInteraction)).filter(item => item.generation === generation);
|
|
89
178
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const dir = join(this.directory(id), "
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
179
|
+
removeInteraction(id: string, requestId: string) {
|
|
180
|
+
fileId(requestId);
|
|
181
|
+
const dir = join(this.directory(id), "interactions");
|
|
182
|
+
tryUnlink(join(dir, requestId + ".json"));
|
|
183
|
+
tryUnlink(join(dir, requestId + "-reply.json"));
|
|
184
|
+
tryRmdir(dir);
|
|
185
|
+
}
|
|
186
|
+
clearTransient(id: string) {
|
|
187
|
+
const base = this.directory(id);
|
|
188
|
+
if (!existsSync(base)) return;
|
|
189
|
+
rmSync(join(base, "inbox"), { recursive: true, force: true });
|
|
190
|
+
rmSync(join(base, "interactions"), { recursive: true, force: true });
|
|
191
|
+
tryUnlink(join(base, "acp-answer.json"));
|
|
192
|
+
}
|
|
193
|
+
removeWorker(id: string) {
|
|
194
|
+
rmSync(this.directory(id), { recursive: true, force: true });
|
|
195
|
+
tryRmdir(this.root);
|
|
97
196
|
}
|
|
98
197
|
ensureSubdirectory(id: string, name: string) {
|
|
99
198
|
privateDirectory(this.directory(id), name);
|
|
100
199
|
}
|
|
101
200
|
reference(id: string): AgentSessionReference {
|
|
102
|
-
|
|
201
|
+
const w = this.worker(id);
|
|
202
|
+
const saved = this.optional(id, "state.json", status);
|
|
203
|
+
return {
|
|
204
|
+
host: "acp",
|
|
205
|
+
backend: w.acp.backend,
|
|
206
|
+
command: w.acp.command,
|
|
207
|
+
args: w.acp.args,
|
|
208
|
+
...(w.acp.env ? { env: w.acp.env } : {}),
|
|
209
|
+
...(w.acp.permission ? { permission: w.acp.permission } : {}),
|
|
210
|
+
sessionId: saved?.sessionId ?? null,
|
|
211
|
+
...(saved?.capabilities ? { capabilities: saved.capabilities } : {}),
|
|
212
|
+
};
|
|
103
213
|
}
|
|
104
214
|
/** Short controller edits are serialized; an abandoned lock fails closed. */
|
|
105
215
|
control<T>(work: () => T): T {
|
|
@@ -115,14 +225,17 @@ export class AgentFiles {
|
|
|
115
225
|
}
|
|
116
226
|
enqueue(id: string, text: string, delivery: AgentMessage["delivery"], files: string[] = [], requestId: string = randomUUID()) {
|
|
117
227
|
fileId(requestId);
|
|
118
|
-
const
|
|
228
|
+
const w = this.worker(id);
|
|
229
|
+
const previous = this.optional(id, "inbox/" + requestId + ".json", message);
|
|
119
230
|
if (previous) {
|
|
120
|
-
requireThat(previous.generation ===
|
|
231
|
+
requireThat(previous.generation === w.generation && previous.message === text && previous.delivery === delivery && canonical(previous.files) === canonical(files), "请求 ID 已被不同输入使用。");
|
|
121
232
|
return previous;
|
|
122
233
|
}
|
|
123
|
-
|
|
124
|
-
this.write(id, "
|
|
125
|
-
|
|
126
|
-
|
|
234
|
+
w.sequence++;
|
|
235
|
+
this.write(id, "worker.json", w, workerRecord);
|
|
236
|
+
this.ensureSubdirectory(id, "inbox");
|
|
237
|
+
const value: AgentMessage = { requestId, generation: w.generation, sequence: w.sequence, message: text, delivery, files };
|
|
238
|
+
this.write(id, "inbox/" + value.requestId + ".json", value, message, true);
|
|
239
|
+
return value;
|
|
127
240
|
}
|
|
128
241
|
}
|
|
@@ -50,24 +50,24 @@ export const historyResultSchema = Type.Object({
|
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
export const historyDescription =
|
|
53
|
-
"
|
|
54
|
-
"search
|
|
55
|
-
"read
|
|
53
|
+
"查询当前工作区跨宿主历史问答与摘要归档。" +
|
|
54
|
+
"search 按不区分大小写的连续关键词匹配原文与摘要,省略 query 列出各会话或指定维度摘要;" +
|
|
55
|
+
"read 按 id 读取正文与上下级(可从 monthly 汇总下钻至 session 摘要和 exchange 原文),用 nextOffset 与 nextChildrenOffset 分页续读。";
|
|
56
56
|
|
|
57
57
|
export const historyParameters = Type.Object({
|
|
58
58
|
action: Type.Union([Type.Literal("search"), Type.Literal("read")], {
|
|
59
|
-
description: "search
|
|
59
|
+
description: "search 搜索或列表;read 按 id 读取正文与上下级。仅读取对应动作参数,其余忽略。",
|
|
60
60
|
}),
|
|
61
|
-
host: nullable(Type.String({ pattern: historyIdentifierPattern.source, description: "
|
|
62
|
-
dimension: nullable(Type.String({ pattern: historyIdentifierPattern.source, description: "仅 search
|
|
63
|
-
query: nullable(Type.String({ description: "仅 search
|
|
64
|
-
sessionId: nullable(Type.String({ description: "仅 search
|
|
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
65
|
from: nullable(Type.String({ description: "仅 search:ISO 日期或时间下界。" })),
|
|
66
66
|
to: nullable(Type.String({ description: "仅 search:ISO 日期或时间上界。" })),
|
|
67
|
-
id: nullable(Type.String({ description: "仅 read
|
|
68
|
-
offset: nullable(Type.Integer({ minimum: 0, description: "search
|
|
69
|
-
limit: nullable(Type.Integer({ minimum: 1, maximum: historyPageLimits.read.max, description: `search
|
|
70
|
-
childrenOffset: nullable(Type.Integer({ minimum: 0, description: "仅 read
|
|
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。" })),
|
|
71
71
|
}, { additionalProperties: false });
|
|
72
72
|
|
|
73
73
|
export type HistoryInput =
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/** Each host owns its file, including when two hosts activate the same canonical workspace concurrently. */
|
|
2
|
-
export declare function bindWorkspacePlugin(root: string, host: string, binding?: string): void;
|
|
3
|
-
export interface WorkspacePluginBinding {
|
|
4
|
-
version: string;
|
|
5
|
-
bindingPath?: string;
|
|
6
|
-
}
|
|
7
|
-
export interface WorkspacePluginDrift {
|
|
8
|
-
outOfSync: boolean;
|
|
9
|
-
highest?: string;
|
|
10
|
-
lowest?: string;
|
|
11
|
-
versions: Record<string, string>;
|
|
12
|
-
}
|
|
13
|
-
export declare function workspacePluginBindings(root: string): Record<string, WorkspacePluginBinding>;
|
|
14
|
-
export declare function workspacePluginReleases(root: string): Record<string, string>;
|
|
15
|
-
export declare function workspacePluginDrift(releases: Record<string, string>): WorkspacePluginDrift;
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { mkdirSync, readdirSync, readFileSync } from "node:fs";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
|
-
import { isAbsolute, join, resolve } from "node:path";
|
|
5
|
-
import { object } from "../../common/json.js";
|
|
6
|
-
import { resourceRoot } from "../../common/paths.js";
|
|
7
|
-
import { requireThat } from "../../common/validation.js";
|
|
8
|
-
import { releaseLine } from "../../common/version.js";
|
|
9
|
-
import { readJsonFile, writeJsonFile } from "../../storage/atomic-json.js";
|
|
10
|
-
function compareSemver(a, b) {
|
|
11
|
-
const parse = (value) => {
|
|
12
|
-
const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?/.exec(value);
|
|
13
|
-
return match
|
|
14
|
-
? { major: Number(match[1]), minor: Number(match[2]), patch: Number(match[3]), pre: match[4] ?? "" }
|
|
15
|
-
: undefined;
|
|
16
|
-
};
|
|
17
|
-
const left = parse(a);
|
|
18
|
-
const right = parse(b);
|
|
19
|
-
if (!left || !right)
|
|
20
|
-
return a.localeCompare(b);
|
|
21
|
-
if (left.major !== right.major)
|
|
22
|
-
return left.major - right.major;
|
|
23
|
-
if (left.minor !== right.minor)
|
|
24
|
-
return left.minor - right.minor;
|
|
25
|
-
if (left.patch !== right.patch)
|
|
26
|
-
return left.patch - right.patch;
|
|
27
|
-
if (left.pre === right.pre)
|
|
28
|
-
return 0;
|
|
29
|
-
if (!left.pre)
|
|
30
|
-
return 1;
|
|
31
|
-
if (!right.pre)
|
|
32
|
-
return -1;
|
|
33
|
-
return left.pre.localeCompare(right.pre);
|
|
34
|
-
}
|
|
35
|
-
function bindingDirectory(root) {
|
|
36
|
-
const key = createHash("sha256").update(root).digest("hex");
|
|
37
|
-
return join(homedir(), ".pbot", "workspaces", key);
|
|
38
|
-
}
|
|
39
|
-
// Full plugins own a local manifest. Thin clients can supply the release stamped into their cached hooks.
|
|
40
|
-
function pluginBinding(value) {
|
|
41
|
-
requireThat(typeof value === "string", "无效的插件安装记录。");
|
|
42
|
-
if (!isAbsolute(value))
|
|
43
|
-
releaseLine(value);
|
|
44
|
-
return value;
|
|
45
|
-
}
|
|
46
|
-
function permissionDenied(error) {
|
|
47
|
-
return ["EACCES", "EPERM", "EROFS"].includes(error.code ?? "");
|
|
48
|
-
}
|
|
49
|
-
/** Each host owns its file, including when two hosts activate the same canonical workspace concurrently. */
|
|
50
|
-
export function bindWorkspacePlugin(root, host, binding = resolve(resourceRoot, "../package.json")) {
|
|
51
|
-
const directory = bindingDirectory(root);
|
|
52
|
-
const file = encodeURIComponent(host) + ".json";
|
|
53
|
-
try {
|
|
54
|
-
if (readJsonFile(directory, file, pluginBinding) === binding)
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
if (permissionDenied(error))
|
|
59
|
-
return;
|
|
60
|
-
if (error.code !== "ENOENT")
|
|
61
|
-
throw error;
|
|
62
|
-
}
|
|
63
|
-
try {
|
|
64
|
-
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
65
|
-
writeJsonFile(directory, file, binding, pluginBinding);
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
if (!permissionDenied(error))
|
|
69
|
-
throw error;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
export function workspacePluginBindings(root) {
|
|
73
|
-
const directory = bindingDirectory(root);
|
|
74
|
-
let files;
|
|
75
|
-
try {
|
|
76
|
-
files = readdirSync(directory);
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
if (error.code === "ENOENT" || permissionDenied(error))
|
|
80
|
-
return {};
|
|
81
|
-
throw error;
|
|
82
|
-
}
|
|
83
|
-
const bindings = Object.create(null);
|
|
84
|
-
for (const file of files.filter(name => name.endsWith(".json"))) {
|
|
85
|
-
const host = decodeURIComponent(file.slice(0, -5));
|
|
86
|
-
try {
|
|
87
|
-
const binding = readJsonFile(directory, file, pluginBinding);
|
|
88
|
-
if (!isAbsolute(binding)) {
|
|
89
|
-
bindings[host] = { version: binding };
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
const manifest = JSON.parse(readFileSync(binding, "utf8"));
|
|
93
|
-
requireThat(object(manifest) && typeof manifest.version === "string", "无效的插件安装清单:" + binding);
|
|
94
|
-
releaseLine(manifest.version);
|
|
95
|
-
bindings[host] = { version: manifest.version, bindingPath: binding };
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
if (error.code !== "ENOENT" && !permissionDenied(error))
|
|
99
|
-
throw error;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return bindings;
|
|
103
|
-
}
|
|
104
|
-
export function workspacePluginReleases(root) {
|
|
105
|
-
const bindings = workspacePluginBindings(root);
|
|
106
|
-
const releases = Object.create(null);
|
|
107
|
-
for (const [host, entry] of Object.entries(bindings))
|
|
108
|
-
releases[host] = entry.version;
|
|
109
|
-
return releases;
|
|
110
|
-
}
|
|
111
|
-
export function workspacePluginDrift(releases) {
|
|
112
|
-
let highest;
|
|
113
|
-
let lowest;
|
|
114
|
-
for (const version of Object.values(releases)) {
|
|
115
|
-
if (!highest || compareSemver(version, highest) > 0)
|
|
116
|
-
highest = version;
|
|
117
|
-
if (!lowest || compareSemver(version, lowest) < 0)
|
|
118
|
-
lowest = version;
|
|
119
|
-
}
|
|
120
|
-
return {
|
|
121
|
-
outOfSync: Boolean(highest && lowest && highest !== lowest),
|
|
122
|
-
...(highest ? { highest } : {}),
|
|
123
|
-
...(lowest ? { lowest } : {}),
|
|
124
|
-
versions: releases,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
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、时间和非有限值。
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Python 计算
|
|
2
|
-
|
|
3
|
-
## 运行方式
|
|
4
|
-
|
|
5
|
-
通过当前宿主的原生 Bash,沿用项目声明的解释器、依赖、工作目录、入口和输出位置。尚无约定时,先检查可用解释器和所需库再执行。
|
|
6
|
-
|
|
7
|
-
包内相对导入在项目根目录用 `python -m 包.模块`,不靠改 `sys.path` 绕过导入错误。交付时核对结果并给出实际产物路径。
|
|
8
|
-
|
|
9
|
-
解释器或依赖异常时,检查实际路径、导入错误与项目配置,继续不受影响的工作;专家需要主会话协助时交回具体阻碍和所需条件。
|
|
10
|
-
|
|
11
|
-
## 常见约束
|
|
12
|
-
|
|
13
|
-
- 无图形界面绘图:导入 `pyplot`/`seaborn` 前设置 Matplotlib `Agg` 后端,保存文件后关闭 figure。
|
|
14
|
-
- 表格与二进制文件(Excel/Parquet/Feather):核对读写后的字段类型、时间单位与时区;Excel 不直接保存带时区的 `datetime`,转换前先确定目标时区。
|
|
15
|
-
- 统计与建模:记录数据口径和假设;时间序列按时间切分,预处理只在训练集拟合,避免未来数据泄漏。
|
|
16
|
-
- 技术指标或回测:另读同目录 [compute-finance.md](compute-finance.md),显式确定数据口径和交易假设。
|