personal-bot 0.2.19 → 0.3.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 +3 -3
- package/.claude-plugin/plugin.json +2 -5
- package/.mcp.json +11 -0
- package/CONTEXT.md +17 -73
- package/README.md +41 -120
- package/README.zh-CN.md +41 -120
- package/docs/README.md +31 -23
- package/docs/architecture/design.md +74 -0
- package/docs/architecture/extensibility.md +78 -0
- package/docs/architecture/model-context.md +31 -0
- package/docs/architecture/model-instruction-guidelines.md +34 -0
- package/docs/architecture/principles.md +33 -0
- package/docs/guides/capabilities.md +36 -0
- package/docs/guides/cross-harness-workers.md +83 -0
- package/docs/guides/history.md +25 -0
- package/docs/guides/workspace-configuration.md +102 -0
- package/docs/hosts/antigravity.md +52 -0
- package/docs/hosts/claude-code.md +47 -0
- package/docs/hosts/dsh.md +67 -0
- package/docs/hosts/pi.md +49 -0
- package/docs/maintainers/release.md +59 -0
- package/hooks/hooks.json +0 -3
- package/lib/antigravity-plugin/hooks.json +23 -0
- package/lib/antigravity-plugin/lib/claude.d.ts +1 -0
- package/lib/antigravity-plugin/lib/claude.js +13 -0
- package/lib/antigravity-plugin/lib/common/json.d.ts +6 -0
- package/lib/antigravity-plugin/lib/common/json.js +16 -0
- package/lib/antigravity-plugin/lib/common/paths.d.ts +1 -0
- package/lib/antigravity-plugin/lib/common/paths.js +2 -0
- package/lib/antigravity-plugin/lib/common/validation.d.ts +3 -0
- package/lib/antigravity-plugin/lib/common/validation.js +8 -0
- package/lib/antigravity-plugin/lib/common/version.d.ts +3 -0
- package/lib/antigravity-plugin/lib/common/version.js +13 -0
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +11597 -0
- package/lib/antigravity-plugin/lib/extension/mcp.js +2715 -0
- package/lib/antigravity-plugin/lib/extension/plugin-runtime.d.ts +10 -0
- package/lib/antigravity-plugin/lib/extension/plugin-runtime.js +67 -0
- package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +16 -0
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +56 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.d.ts +4 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.js +79 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/claude.d.ts +3 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/claude.js +60 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/registry.d.ts +15 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/registry.js +34 -0
- package/lib/antigravity-plugin/lib/model/acp.d.ts +164 -0
- package/lib/antigravity-plugin/lib/model/acp.js +12 -0
- package/lib/antigravity-plugin/lib/model/plugin-host.d.ts +48 -0
- package/lib/antigravity-plugin/lib/model/workspace-config.d.ts +24 -0
- package/lib/antigravity-plugin/lib/model/workspace-config.js +1 -0
- package/lib/antigravity-plugin/lib/model/workspace-mcp.d.ts +51 -0
- package/lib/antigravity-plugin/lib/model/workspace-mcp.js +4 -0
- package/lib/antigravity-plugin/lib/plugin.d.ts +1 -0
- package/lib/antigravity-plugin/lib/plugin.js +17 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.d.ts +8 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.js +93 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-preparation.d.ts +3 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-preparation.js +26 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.d.ts +8 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.js +91 -0
- package/lib/antigravity-plugin/lib/storage/atomic-json.d.ts +11 -0
- package/lib/antigravity-plugin/lib/storage/atomic-json.js +101 -0
- package/lib/antigravity-plugin/mcp_config.json +13 -0
- package/lib/antigravity-plugin/package.json +6 -0
- package/lib/antigravity-plugin/plugin.json +7 -0
- package/lib/antigravity-plugin/resources/agents/coordinator.md +11 -0
- package/{resources/claude → lib/antigravity-plugin/resources}/agents/general-purpose.md +0 -5
- package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -0
- package/lib/antigravity-plugin/resources/prompts/workspace.md +31 -0
- package/lib/antigravity-plugin/resources/references/compute-finance.md +22 -0
- package/lib/antigravity-plugin/resources/references/compute.md +16 -0
- package/lib/antigravity-plugin/resources/references/task-conductor.md +25 -0
- package/lib/antigravity-plugin/resources/templates/workspace-agents.md +21 -0
- package/lib/antigravity-plugin/skills/pbot/SKILL.md +16 -0
- package/lib/antigravity-plugin/skills/project-maintenance/SKILL.md +35 -0
- package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +42 -0
- package/lib/claude.js +4 -11
- package/lib/client.js +14 -531
- package/lib/common/markdown.js +2 -3
- package/lib/common/validation.d.ts +2 -0
- package/lib/common/validation.js +4 -0
- package/lib/extension/acp-member.d.ts +2 -0
- package/lib/extension/acp-member.js +9 -8
- package/lib/extension/acp-worker.js +11578 -121
- package/lib/extension/dsh/acp-member.js +26 -2
- package/lib/extension/dsh/command.js +19 -57
- package/lib/extension/dsh/history.js +2 -4
- package/lib/extension/dsh/management.d.ts +0 -2
- package/lib/extension/dsh/management.js +27 -126
- package/lib/extension/dsh/workspace.d.ts +5 -47
- package/lib/extension/dsh/workspace.js +76 -108
- package/lib/extension/mcp-bridge.d.ts +41 -0
- package/lib/extension/mcp-bridge.js +412 -0
- package/lib/extension/mcp-workers.d.ts +980 -0
- package/lib/extension/mcp-workers.js +882 -0
- package/lib/extension/mcp.js +2715 -0
- package/lib/extension/plugin-runtime.d.ts +10 -0
- package/lib/extension/plugin-runtime.js +67 -0
- package/lib/extension/setup-cli.js +215 -2
- package/lib/integrations/acp/agents.d.ts +10 -11
- package/lib/integrations/acp/agents.js +65 -33
- package/lib/integrations/acp/claude.d.ts +2 -2
- package/lib/integrations/acp/claude.js +5 -3
- package/lib/integrations/acp/connection.d.ts +17 -4
- package/lib/integrations/acp/connection.js +53 -27
- package/lib/integrations/acp/executable.d.ts +3 -0
- package/lib/integrations/acp/executable.js +42 -0
- package/lib/integrations/acp/harnesses/claude.d.ts +2 -0
- package/lib/integrations/acp/harnesses/claude.js +49 -0
- package/lib/integrations/acp/harnesses/dsh.d.ts +2 -0
- package/lib/integrations/acp/harnesses/dsh.js +35 -0
- package/lib/integrations/acp/harnesses/generic.d.ts +13 -0
- package/lib/integrations/acp/harnesses/generic.js +37 -0
- package/lib/integrations/acp/harnesses/pi.d.ts +2 -0
- package/lib/integrations/acp/harnesses/pi.js +34 -0
- package/lib/integrations/acp/harnesses/presets.d.ts +3 -0
- package/lib/integrations/acp/harnesses/presets.js +20 -0
- package/lib/integrations/acp/launch.d.ts +33 -4
- package/lib/integrations/acp/launch.js +60 -48
- package/lib/integrations/acp/mcp.d.ts +6 -0
- package/lib/integrations/acp/mcp.js +40 -0
- package/lib/integrations/acp/model-selection.d.ts +9 -2
- package/lib/integrations/acp/model-selection.js +73 -27
- package/lib/integrations/acp/registry.d.ts +18 -0
- package/lib/integrations/acp/registry.js +50 -0
- package/lib/integrations/agent-resources.d.ts +16 -1
- package/lib/integrations/agent-resources.js +45 -9
- package/lib/integrations/dsh/mcp.d.ts +4 -0
- package/lib/integrations/dsh/mcp.js +28 -0
- package/lib/integrations/dsh/resources.d.ts +3 -3
- package/lib/integrations/dsh/resources.js +21 -12
- package/lib/integrations/dsh/skills.d.ts +5 -1
- package/lib/integrations/dsh/skills.js +10 -6
- package/lib/integrations/hosts/antigravity.d.ts +4 -0
- package/lib/integrations/hosts/antigravity.js +79 -0
- package/lib/integrations/hosts/claude.d.ts +3 -0
- package/lib/integrations/hosts/claude.js +60 -0
- package/lib/integrations/hosts/registry.d.ts +15 -0
- package/lib/integrations/hosts/registry.js +34 -0
- package/lib/model/acp.d.ts +107 -2
- package/lib/model/acp.js +12 -1
- package/lib/model/agent.d.ts +35 -33
- package/lib/model/plugin-host.d.ts +48 -0
- package/lib/model/plugin-host.js +1 -0
- package/lib/model/workspace-config.d.ts +12 -0
- package/lib/model/workspace-mcp.d.ts +51 -0
- package/lib/model/workspace-mcp.js +4 -0
- package/lib/plugin.d.ts +1 -0
- package/lib/plugin.js +17 -0
- package/lib/services/agents/acp-run.d.ts +13 -1
- package/lib/services/agents/acp-run.js +30 -2
- package/lib/services/agents/agent-service.d.ts +35 -120
- package/lib/services/agents/agent-service.js +156 -160
- package/lib/services/installation/setup-service.js +17 -1
- package/lib/services/workspace/workspace-config.d.ts +2 -1
- package/lib/services/workspace/workspace-config.js +39 -7
- package/lib/services/workspace/workspace-mcp.d.ts +14 -0
- package/lib/services/workspace/workspace-mcp.js +200 -0
- package/lib/services/workspace/workspace-skills.d.ts +8 -0
- package/lib/services/workspace/workspace-skills.js +91 -0
- package/lib/storage/acp-files.d.ts +3 -1
- package/lib/storage/acp-files.js +32 -2
- package/lib/storage/acp-history.d.ts +3 -2
- package/lib/storage/acp-history.js +19 -7
- package/lib/storage/agent-files.d.ts +8 -8
- package/lib/storage/agent-files.js +27 -47
- package/lib/tools/history/contract.d.ts +1 -1
- package/lib/tools/history/contract.js +17 -11
- package/lib/ui/dsh/index.js +8 -3
- package/lib/ui/dsh/management.d.ts +1 -1
- package/lib/ui/dsh/management.js +24 -456
- package/lib/ui/dsh/remote.d.ts +0 -2
- package/lib/ui/dsh/remote.js +1 -1
- package/package.json +12 -7
- package/resources/agents/coordinator.md +2 -2
- package/resources/antigravity/skills/pbot/SKILL.md +16 -0
- package/resources/claude/skills/pbot/SKILL.md +1 -1
- package/resources/prompts/history-coordinator.md +1 -0
- package/resources/prompts/plugin-coordinator.md +1 -0
- package/resources/prompts/workspace.md +9 -8
- package/resources/references/compute.md +9 -11
- package/resources/references/task-conductor.md +12 -26
- package/resources/skills/project-maintenance/SKILL.md +17 -22
- package/resources/skills/provider-connections/SKILL.md +24 -40
- package/resources/templates/workspace-agents.md +8 -0
- package/scripts/README.md +17 -34
- package/src/claude.ts +4 -8
- package/src/common/markdown.ts +2 -3
- package/src/common/validation.ts +6 -0
- package/src/extension/acp-member.ts +9 -8
- package/src/extension/acp-worker.ts +239 -97
- package/src/extension/command.ts +38 -36
- package/src/extension/dsh/acp-member.ts +21 -2
- package/src/extension/dsh/command.ts +21 -51
- package/src/extension/dsh/files.ts +1 -0
- package/src/extension/dsh/history.ts +9 -6
- package/src/extension/dsh/management.ts +27 -58
- package/src/extension/dsh/workspace.ts +88 -99
- package/src/extension/events.ts +13 -10
- package/src/extension/history.ts +2 -50
- package/src/extension/lifecycle.ts +37 -22
- package/src/extension/mcp-bridge.ts +412 -0
- package/src/extension/mcp-workers.ts +941 -0
- package/src/extension/pi-acp-member.ts +29 -5
- package/src/extension/plugin-runtime.ts +63 -0
- package/src/extension/setup-cli.ts +186 -2
- package/src/integrations/acp/agents.ts +70 -24
- package/src/integrations/acp/claude.ts +11 -4
- package/src/integrations/acp/connection.ts +63 -25
- package/src/integrations/acp/executable.ts +41 -0
- package/src/integrations/acp/harnesses/claude.ts +50 -0
- package/src/integrations/acp/harnesses/dsh.ts +40 -0
- package/src/integrations/acp/harnesses/generic.ts +52 -0
- package/src/integrations/acp/harnesses/pi.ts +35 -0
- package/src/integrations/acp/harnesses/presets.ts +22 -0
- package/src/integrations/acp/launch.ts +69 -47
- package/src/integrations/acp/mcp.ts +43 -0
- package/src/integrations/acp/model-selection.ts +68 -25
- package/src/integrations/acp/registry.ts +60 -0
- package/src/integrations/agent-resources.ts +70 -6
- package/src/integrations/dsh/mcp.ts +30 -0
- package/src/integrations/dsh/resources.ts +28 -13
- package/src/integrations/dsh/skills.ts +16 -6
- package/src/integrations/hosts/antigravity.ts +83 -0
- package/src/integrations/hosts/claude.ts +62 -0
- package/src/integrations/hosts/registry.ts +42 -0
- package/src/integrations/pi/mcp.ts +26 -0
- package/src/mcp.ts +14 -0
- package/src/model/acp.ts +113 -3
- package/src/model/agent.ts +18 -14
- package/src/model/plugin-host.ts +39 -0
- package/src/model/workspace-config.ts +14 -0
- package/src/model/workspace-mcp.ts +64 -0
- package/src/pbot.ts +69 -20
- package/src/plugin.ts +19 -0
- package/src/services/agents/acp-run.ts +35 -3
- package/src/services/agents/agent-service.ts +180 -160
- package/src/services/installation/setup-service.ts +17 -2
- package/src/services/workspace/workspace-config.ts +42 -6
- package/src/services/workspace/workspace-mcp.ts +242 -0
- package/src/services/workspace/workspace-skills.ts +78 -0
- package/src/storage/acp-files.ts +32 -3
- package/src/storage/acp-history.ts +18 -7
- package/src/storage/agent-files.ts +27 -41
- package/src/tools/history/contract.ts +17 -11
- package/src/tools/register.ts +4 -8
- package/src/ui/dsh/index.ts +8 -3
- package/src/ui/dsh/management.ts +40 -282
- package/src/ui/dsh/remote.ts +2 -2
- package/docs/adr/0001-claude-skill-discovery.md +0 -3
- package/docs/adr/0002-claude-native-collaboration.md +0 -3
- package/docs/agent-collaboration.md +0 -190
- package/docs/architecture-guidelines.md +0 -37
- package/docs/capability-design.md +0 -55
- package/docs/claude-code-design.md +0 -44
- package/docs/claude-code.md +0 -57
- package/docs/dsh.md +0 -337
- package/docs/file-storage.md +0 -97
- package/docs/history.md +0 -54
- package/docs/installation-design.md +0 -86
- package/docs/interaction-design.md +0 -21
- package/docs/model-context.md +0 -76
- package/docs/model-instruction-guidelines.md +0 -51
- package/docs/release.md +0 -108
- package/docs/technical-design.md +0 -163
- package/docs/workspace-configuration.md +0 -79
- package/lib/extension/claude-hooks.d.ts +0 -9
- package/lib/extension/claude-hooks.js +0 -78
- package/lib/extension/dsh/agent-events.d.ts +0 -24
- package/lib/extension/dsh/agent-events.js +0 -242
- package/lib/extension/dsh/agent-runtime.d.ts +0 -49
- package/lib/extension/dsh/agent-runtime.js +0 -351
- package/lib/integrations/dsh/dsh-agents.d.ts +0 -30
- package/lib/integrations/dsh/dsh-agents.js +0 -104
- package/lib/integrations/dsh/input.d.ts +0 -21
- package/lib/integrations/dsh/input.js +0 -62
- package/lib/integrations/dsh/notifications.d.ts +0 -8
- package/lib/integrations/dsh/notifications.js +0 -55
- package/lib/integrations/dsh/session.d.ts +0 -14
- package/lib/integrations/dsh/session.js +0 -60
- package/lib/integrations/team-context.d.ts +0 -18
- package/lib/integrations/team-context.js +0 -61
- package/lib/model/team.d.ts +0 -85
- package/lib/services/agents/agent-notices.d.ts +0 -13
- package/lib/services/agents/agent-notices.js +0 -25
- package/lib/services/agents/start-options.d.ts +0 -4
- package/lib/services/agents/start-options.js +0 -20
- package/lib/services/agents/team-service.d.ts +0 -168
- package/lib/services/agents/team-service.js +0 -345
- package/lib/storage/team-files.d.ts +0 -16
- package/lib/storage/team-files.js +0 -111
- package/lib/tools/agents/actions.d.ts +0 -62
- package/lib/tools/agents/actions.js +0 -62
- package/lib/tools/agents/contract.d.ts +0 -181
- package/lib/tools/agents/contract.js +0 -84
- package/lib/tools/agents/dsh-tool.d.ts +0 -5
- package/lib/tools/agents/dsh-tool.js +0 -34
- package/lib/tools/result.d.ts +0 -18
- package/lib/tools/result.js +0 -10
- package/lib/tools/teams/actions.d.ts +0 -23
- package/lib/tools/teams/actions.js +0 -40
- package/lib/tools/teams/contract.d.ts +0 -201
- package/lib/tools/teams/contract.js +0 -91
- package/lib/tools/teams/dsh-tool.d.ts +0 -8
- package/lib/tools/teams/dsh-tool.js +0 -39
- package/lib/ui/dsh/attachments.d.ts +0 -5
- package/lib/ui/dsh/attachments.js +0 -39
- package/resources/prompts/claude-coordinator.md +0 -1
- package/resources/prompts/native-coordinator.md +0 -1
- package/resources/prompts/team-member.md +0 -7
- package/src/extension/agent-events.ts +0 -210
- package/src/extension/agents-command.ts +0 -89
- package/src/extension/claude-hooks.ts +0 -74
- package/src/extension/dsh/agent-events.ts +0 -148
- package/src/extension/dsh/agent-runtime.ts +0 -252
- package/src/extension/subagent-entry.ts +0 -270
- package/src/extension/teams-command.ts +0 -67
- package/src/integrations/dsh/dsh-agents.ts +0 -97
- package/src/integrations/dsh/input.ts +0 -66
- package/src/integrations/dsh/notifications.ts +0 -46
- package/src/integrations/pi/agent-context.ts +0 -18
- package/src/integrations/pi/agent-input.ts +0 -19
- package/src/integrations/pi/pi-agents.ts +0 -84
- package/src/integrations/pi/team-context.ts +0 -26
- package/src/integrations/team-context.ts +0 -64
- package/src/model/team.ts +0 -29
- package/src/services/agents/agent-notices.ts +0 -28
- package/src/services/agents/start-options.ts +0 -19
- package/src/services/agents/team-service.ts +0 -275
- package/src/storage/team-files.ts +0 -93
- package/src/tools/agents/actions.ts +0 -57
- package/src/tools/agents/contract.ts +0 -101
- package/src/tools/agents/dsh-tool.ts +0 -37
- package/src/tools/agents/tool.ts +0 -20
- package/src/tools/teams/actions.ts +0 -34
- package/src/tools/teams/contract.ts +0 -109
- package/src/tools/teams/dsh-tool.ts +0 -45
- package/src/tools/teams/tool.ts +0 -29
- package/src/ui/agent-display.ts +0 -14
- package/src/ui/dsh/attachments.ts +0 -42
- package/src/ui/pi/menu.ts +0 -37
- package/src/ui/pi/reader.ts +0 -46
- /package/lib/{model/team.js → antigravity-plugin/lib/model/plugin-host.js} +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { requireThat } from "./common/validation.js";
|
|
4
|
+
import { runPluginHost } from "./extension/plugin-runtime.js";
|
|
5
|
+
import { listPluginHosts, pluginHosts } from "./integrations/hosts/registry.js";
|
|
6
|
+
export async function main(args) {
|
|
7
|
+
const [host, ...rest] = args;
|
|
8
|
+
const adapter = host ? pluginHosts.get(host) : undefined;
|
|
9
|
+
requireThat(adapter, `用法:node <插件目录>/lib/plugin.js <${listPluginHosts().join("|")}> hook|init|status`);
|
|
10
|
+
await runPluginHost(adapter, rest);
|
|
11
|
+
}
|
|
12
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(realpathSync(process.argv[1])).href) {
|
|
13
|
+
void main(process.argv.slice(2)).catch(error => {
|
|
14
|
+
process.stderr.write("Personal Bot: " + (error instanceof Error ? error.message : String(error)) + "\n");
|
|
15
|
+
process.exitCode = 1;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ResolvedWorkspaceFeatures, WorkspaceConfiguration, WorkspaceFeatures } from "../../model/workspace-config.js";
|
|
2
|
+
export declare function workspaceFeatures(configuration?: Pick<WorkspaceConfiguration, "features"> | WorkspaceFeatures): ResolvedWorkspaceFeatures;
|
|
3
|
+
export declare function workspaceConfigPath(root: string): string;
|
|
4
|
+
/** Read only this workspace's configuration; parent directories never grant activation. */
|
|
5
|
+
export declare function readWorkspaceConfig(root: string): Promise<WorkspaceConfiguration>;
|
|
6
|
+
/** Explicit init opts in this workspace while preserving its other configuration fields. */
|
|
7
|
+
export declare function initializeWorkspaceConfig(root: string): Promise<void>;
|
|
8
|
+
export declare function workspaceDisabledMessage(configuration: WorkspaceConfiguration): string;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { mkdir, readFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { object } from "../../common/json.js";
|
|
4
|
+
import { isAcpBackend } from "../../common/validation.js";
|
|
5
|
+
import { readJsonFile, writeJsonFile } from "../../storage/atomic-json.js";
|
|
6
|
+
const featureKeys = ["prompts", "skills", "mcp"];
|
|
7
|
+
function config(value) {
|
|
8
|
+
if (!object(value) || value.enabled !== undefined && typeof value.enabled !== "boolean") {
|
|
9
|
+
throw new Error("配置必须是 JSON 对象,enabled 必须是布尔值。");
|
|
10
|
+
}
|
|
11
|
+
if (value.features !== undefined) {
|
|
12
|
+
if (!object(value.features) ||
|
|
13
|
+
Object.entries(value.features).some(([key, entry]) => !featureKeys.includes(key) || (entry !== undefined && typeof entry !== "boolean"))) {
|
|
14
|
+
throw new Error("features 必须是 JSON 对象,仅支持 prompts、skills、mcp 布尔开关。");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (value.acp !== undefined) {
|
|
18
|
+
if (!object(value.acp) || Object.keys(value.acp).some(key => !isAcpBackend(key))) {
|
|
19
|
+
throw new Error("acp 键名必须为小写字母、数字和连字符(1–64 字符)。");
|
|
20
|
+
}
|
|
21
|
+
for (const command of Object.values(value.acp)) {
|
|
22
|
+
// Without command, an entry keeps the registered default command and only sets env or permission.
|
|
23
|
+
const launch = !object(command) ? false : command.command === undefined
|
|
24
|
+
? command.args === undefined
|
|
25
|
+
: typeof command.command === "string" && command.command.trim() && !command.command.includes("\0") &&
|
|
26
|
+
(command.args === undefined || (Array.isArray(command.args) && command.args.every(arg => typeof arg === "string" && !arg.includes("\0"))));
|
|
27
|
+
if (!object(command) || !launch ||
|
|
28
|
+
(command.env !== undefined && (!object(command.env) || Object.entries(command.env).some(([k, v]) => !k || k.includes("\0") || typeof v !== "string" || v.includes("\0")))) ||
|
|
29
|
+
(command.permission !== undefined && !["ask", "allow", "deny"].includes(String(command.permission))) ||
|
|
30
|
+
Object.keys(command).some(key => !["command", "args", "env", "permission"].includes(key))) {
|
|
31
|
+
throw new Error("ACP 配置需要 command(内置目标可省略)及可选 args 字符串数组、env 字符串映射、permission(ask、allow 或 deny)。");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
export function workspaceFeatures(configuration) {
|
|
38
|
+
const raw = configuration && "features" in configuration
|
|
39
|
+
? configuration.features
|
|
40
|
+
: configuration;
|
|
41
|
+
return {
|
|
42
|
+
prompts: raw?.prompts !== false,
|
|
43
|
+
skills: raw?.skills !== false,
|
|
44
|
+
mcp: raw?.mcp !== false,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function workspaceConfigPath(root) {
|
|
48
|
+
return join(root, ".pbot", "config.json");
|
|
49
|
+
}
|
|
50
|
+
/** Read only this workspace's configuration; parent directories never grant activation. */
|
|
51
|
+
export async function readWorkspaceConfig(root) {
|
|
52
|
+
const path = workspaceConfigPath(root);
|
|
53
|
+
let content;
|
|
54
|
+
try {
|
|
55
|
+
content = await readFile(path, "utf8");
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error.code === "ENOENT")
|
|
59
|
+
return { path, present: false, enabled: false };
|
|
60
|
+
return { path, present: true, enabled: false, error: `无法读取工作区配置 ${path}: ${String(error)}` };
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
const value = config(JSON.parse(content));
|
|
64
|
+
const settings = value;
|
|
65
|
+
return {
|
|
66
|
+
path,
|
|
67
|
+
present: true,
|
|
68
|
+
enabled: settings.enabled === true,
|
|
69
|
+
...(settings.features ? { features: settings.features } : {}),
|
|
70
|
+
...(settings.acp ? { acp: settings.acp } : {}),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
return { path, present: true, enabled: false, error: `工作区配置无效 ${path}: ${String(error)}` };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** Explicit init opts in this workspace while preserving its other configuration fields. */
|
|
78
|
+
export async function initializeWorkspaceConfig(root) {
|
|
79
|
+
const current = await readWorkspaceConfig(root);
|
|
80
|
+
if (current.error)
|
|
81
|
+
throw new Error(current.error);
|
|
82
|
+
if (current.enabled)
|
|
83
|
+
return;
|
|
84
|
+
const directory = dirname(current.path);
|
|
85
|
+
await mkdir(directory, { recursive: true });
|
|
86
|
+
const value = current.present ? readJsonFile(directory, "config.json", config) : {};
|
|
87
|
+
const written = writeJsonFile(directory, "config.json", { ...value, enabled: true }, config, !current.present);
|
|
88
|
+
if (!written)
|
|
89
|
+
await initializeWorkspaceConfig(root);
|
|
90
|
+
}
|
|
91
|
+
export function workspaceDisabledMessage(configuration) {
|
|
92
|
+
return configuration.error ?? `Personal Bot 未在此工作区启用。请执行 /pbot init 初始化并启用;配置文件:${configuration.path}`;
|
|
93
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { lstat, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { requireThat } from "../../common/validation.js";
|
|
4
|
+
import { resourceRoot } from "../../common/paths.js";
|
|
5
|
+
import { initializeWorkspaceConfig, readWorkspaceConfig } from "./workspace-config.js";
|
|
6
|
+
export async function initializeWorkspace(root) {
|
|
7
|
+
const configuration = await readWorkspaceConfig(root);
|
|
8
|
+
if (configuration.error)
|
|
9
|
+
throw new Error(configuration.error);
|
|
10
|
+
await prepareWorkspace(root);
|
|
11
|
+
await initializeWorkspaceConfig(root);
|
|
12
|
+
}
|
|
13
|
+
export const directories = ["areas", "projects", "knowledge", "providers", "scratch", "agents"];
|
|
14
|
+
export async function prepareWorkspace(root) {
|
|
15
|
+
for (const part of directories) {
|
|
16
|
+
const path = join(root, part);
|
|
17
|
+
await mkdir(path, { mode: 0o700 }).catch(error => { if (error.code !== "EEXIST")
|
|
18
|
+
throw error; });
|
|
19
|
+
const entry = await lstat(path);
|
|
20
|
+
requireThat(entry.isDirectory() && !entry.isSymbolicLink(), "工作区目录不能使用符号链接:" + path);
|
|
21
|
+
}
|
|
22
|
+
const agents = await readFile(join(resourceRoot, "templates/workspace-agents.md"), "utf8");
|
|
23
|
+
await writeFile(join(root, "AGENTS.md"), agents, { flag: "wx" })
|
|
24
|
+
.catch(error => { if (error.code !== "EEXIST")
|
|
25
|
+
throw error; });
|
|
26
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WorkspaceSkillMeta } from "../../model/workspace-mcp.js";
|
|
2
|
+
/** Parse YAML frontmatter fields (`name` and `description`) from a SKILL.md document. */
|
|
3
|
+
export declare function parseSkillFrontmatter(content: string): {
|
|
4
|
+
name?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
} | undefined;
|
|
7
|
+
/** Scan `<workspace>/.agents/skills/<dir>/SKILL.md` for workspace-authored skills. */
|
|
8
|
+
export declare function discoverWorkspaceSkills(root: string): Promise<WorkspaceSkillMeta[]>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
function unquoteYaml(value) {
|
|
4
|
+
const trimmed = value.trim();
|
|
5
|
+
if (trimmed.length >= 2 && ((trimmed.startsWith('"') && trimmed.endsWith('"')) || (trimmed.startsWith("'") && trimmed.endsWith("'")))) {
|
|
6
|
+
return trimmed.slice(1, -1).trim();
|
|
7
|
+
}
|
|
8
|
+
return trimmed;
|
|
9
|
+
}
|
|
10
|
+
/** Parse YAML frontmatter fields (`name` and `description`) from a SKILL.md document. */
|
|
11
|
+
export function parseSkillFrontmatter(content) {
|
|
12
|
+
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
|
|
13
|
+
if (!match)
|
|
14
|
+
return undefined;
|
|
15
|
+
const lines = match[1].split(/\r?\n/);
|
|
16
|
+
const fields = {};
|
|
17
|
+
for (let i = 0; i < lines.length; i++) {
|
|
18
|
+
const line = lines[i];
|
|
19
|
+
const pair = line.match(/^([A-Za-z0-9_-]+)\s*:\s*(.*)$/);
|
|
20
|
+
if (!pair)
|
|
21
|
+
continue;
|
|
22
|
+
const key = pair[1];
|
|
23
|
+
const raw = pair[2].trim();
|
|
24
|
+
if (/^[>|][+-]?$/.test(raw)) {
|
|
25
|
+
const folded = raw.startsWith(">");
|
|
26
|
+
const block = [];
|
|
27
|
+
let indent;
|
|
28
|
+
while (i + 1 < lines.length) {
|
|
29
|
+
const next = lines[i + 1];
|
|
30
|
+
if (!next.trim()) {
|
|
31
|
+
block.push("");
|
|
32
|
+
i++;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const leading = next.match(/^\s+/)?.[0].length ?? 0;
|
|
36
|
+
if (leading === 0)
|
|
37
|
+
break;
|
|
38
|
+
indent ??= leading;
|
|
39
|
+
block.push(next.slice(Math.min(indent, leading)).trimEnd());
|
|
40
|
+
i++;
|
|
41
|
+
}
|
|
42
|
+
const joined = folded
|
|
43
|
+
? block.map(item => item.trim()).filter(Boolean).join(" ")
|
|
44
|
+
: block.join("\n").trim();
|
|
45
|
+
fields[key] = joined;
|
|
46
|
+
}
|
|
47
|
+
else if (raw) {
|
|
48
|
+
fields[key] = unquoteYaml(raw);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
...(fields.name ? { name: fields.name } : {}),
|
|
53
|
+
...(fields.description ? { description: fields.description } : {}),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** Scan `<workspace>/.agents/skills/<dir>/SKILL.md` for workspace-authored skills. */
|
|
57
|
+
export async function discoverWorkspaceSkills(root) {
|
|
58
|
+
const skillsDir = join(root, ".agents", "skills");
|
|
59
|
+
let entries;
|
|
60
|
+
try {
|
|
61
|
+
entries = await readdir(skillsDir, { withFileTypes: true });
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
if (error.code === "ENOENT")
|
|
65
|
+
return [];
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
const results = [];
|
|
69
|
+
for (const entry of entries) {
|
|
70
|
+
if (entry.name.startsWith(".") || (!entry.isDirectory() && !entry.isSymbolicLink()))
|
|
71
|
+
continue;
|
|
72
|
+
const filePath = join(skillsDir, entry.name, "SKILL.md");
|
|
73
|
+
let content;
|
|
74
|
+
try {
|
|
75
|
+
content = await readFile(filePath, "utf8");
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const meta = parseSkillFrontmatter(content);
|
|
81
|
+
if (!meta?.name || !meta.description)
|
|
82
|
+
continue;
|
|
83
|
+
results.push({
|
|
84
|
+
name: meta.name,
|
|
85
|
+
description: meta.description,
|
|
86
|
+
path: `.agents/skills/${entry.name}/SKILL.md`,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
results.sort((a, b) => a.name.localeCompare(b.name));
|
|
90
|
+
return results;
|
|
91
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The root must already exist. Never follow aliases inside internal storage. */
|
|
2
|
+
export declare function internalPath(directory: string, relative: string): string;
|
|
3
|
+
export declare function syncDirectory(directory: string): void;
|
|
4
|
+
/** Validators return plain data and must reject incomplete contracts. */
|
|
5
|
+
export declare function readJsonFile<T>(directory: string, relative: string, validate: (value: unknown) => T): T;
|
|
6
|
+
/**
|
|
7
|
+
* A failure after publication does not mean that the old value remains.
|
|
8
|
+
* Callers must stop writes/sends on I/O failure, even if a subsequent read succeeds.
|
|
9
|
+
* createOnly publishes by link, so an existing destination is never overwritten.
|
|
10
|
+
*/
|
|
11
|
+
export declare function writeJsonFile<T>(directory: string, relative: string, value: unknown, validate: (value: unknown) => T, createOnly?: boolean): boolean;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { constants, closeSync, fstatSync, fsyncSync, linkSync, lstatSync, openSync, readFileSync, realpathSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { canonical } from "../common/json.js";
|
|
5
|
+
import { requireThat } from "../common/validation.js";
|
|
6
|
+
/** The root must already exist. Never follow aliases inside internal storage. */
|
|
7
|
+
export function internalPath(directory, relative) {
|
|
8
|
+
const parts = relative.split("/");
|
|
9
|
+
requireThat(parts.every(part => part && part !== "." && part !== ".." && !/[\\\x00-\x1f]/.test(part)), "内部状态路径无效。");
|
|
10
|
+
const info = lstatSync(directory);
|
|
11
|
+
requireThat(info.isDirectory() && !info.isSymbolicLink(), "内部状态必须使用普通目录。");
|
|
12
|
+
let path = realpathSync(directory);
|
|
13
|
+
for (const [index, part] of parts.entries()) {
|
|
14
|
+
path = join(path, part);
|
|
15
|
+
try {
|
|
16
|
+
const info = lstatSync(path);
|
|
17
|
+
requireThat(!info.isSymbolicLink() && (index === parts.length - 1 ? info.isFile() : info.isDirectory()), "内部状态不能使用符号链接或特殊文件。");
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error.code !== "ENOENT" || index !== parts.length - 1)
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return path;
|
|
25
|
+
}
|
|
26
|
+
export function syncDirectory(directory) {
|
|
27
|
+
const fd = openSync(directory, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
|
|
28
|
+
try {
|
|
29
|
+
fsyncSync(fd);
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
closeSync(fd);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Validators return plain data and must reject incomplete contracts. */
|
|
36
|
+
export function readJsonFile(directory, relative, validate) {
|
|
37
|
+
const path = internalPath(directory, relative);
|
|
38
|
+
const fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
39
|
+
try {
|
|
40
|
+
requireThat(fstatSync(fd).isFile(), "内部状态必须是普通文件。");
|
|
41
|
+
let value;
|
|
42
|
+
try {
|
|
43
|
+
value = JSON.parse(readFileSync(fd, "utf8"));
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
throw new Error("内部 JSON 文件不可读取:" + relative, { cause: error });
|
|
47
|
+
}
|
|
48
|
+
return validate(value);
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
closeSync(fd);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A failure after publication does not mean that the old value remains.
|
|
56
|
+
* Callers must stop writes/sends on I/O failure, even if a subsequent read succeeds.
|
|
57
|
+
* createOnly publishes by link, so an existing destination is never overwritten.
|
|
58
|
+
*/
|
|
59
|
+
export function writeJsonFile(directory, relative, value, validate, createOnly = false) {
|
|
60
|
+
const validated = validate(value);
|
|
61
|
+
// Check before touching disk: JSON.stringify alone silently drops unsupported values.
|
|
62
|
+
const expected = canonical(validated);
|
|
63
|
+
const content = JSON.stringify(validated, null, 2) + "\n";
|
|
64
|
+
requireThat(canonical(JSON.parse(content)) === expected, "JSON 序列化不能改变状态值。");
|
|
65
|
+
const path = internalPath(directory, relative), parent = dirname(path);
|
|
66
|
+
const temporary = join(parent, `.tmp-${randomUUID()}`);
|
|
67
|
+
const fd = openSync(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600);
|
|
68
|
+
try {
|
|
69
|
+
try {
|
|
70
|
+
writeFileSync(fd, content, "utf8");
|
|
71
|
+
fsyncSync(fd);
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
closeSync(fd);
|
|
75
|
+
}
|
|
76
|
+
requireThat(internalPath(directory, relative) === path, "内部状态路径已变化。");
|
|
77
|
+
if (createOnly) {
|
|
78
|
+
try {
|
|
79
|
+
linkSync(temporary, path);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
if (error.code === "EEXIST")
|
|
83
|
+
return false;
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else
|
|
88
|
+
renameSync(temporary, path);
|
|
89
|
+
syncDirectory(parent);
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
try {
|
|
94
|
+
unlinkSync(temporary);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
if (error.code !== "ENOENT")
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# 协调者
|
|
2
|
+
|
|
3
|
+
对本次交付负责,沿用已有约定,完成用户需要的结果。
|
|
4
|
+
|
|
5
|
+
普通问答直接完成。委派专家时写明目标、相关资料、约束和交付要求。周期、重复流程、DAG 或会话退出后仍需执行的任务,先读 `<resourceRoot>/references/task-conductor.md`。
|
|
6
|
+
|
|
7
|
+
汇总专家结果并整合正式资料。委派包含文件修改时说明修改范围,多人写入时划分文件责任;合并不同结果时处理口径差异和未解决的问题。
|
|
8
|
+
|
|
9
|
+
需要独立复核时,另开专家会话,提供待检查内容、相关资料和具体问题。
|
|
10
|
+
|
|
11
|
+
失败或中断后说明已完成部分、剩余工作和阻碍。需要用户决定的事项由你汇总说明。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
未指定其他程序时,默认由当前宿主直接处理或使用当前宿主原生子代理。需要委派其他程序(或按工作区 `AGENTS.md`、`agents/coordinator.md` 分工约定)时,使用 `pbot` MCP 的 `worker_*` 工具(先 `worker_create` 再 `worker_request`),并传入当前 `workspaceRoot` 作为 `workspace`。调用 `.pbot/mcp.json` 中统一注册的工作区 MCP 时,使用 `workspace_mcp_discover` 与 `workspace_mcp_call`(可与宿主原生 MCP 同时使用)。
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Personal Bot
|
|
2
|
+
|
|
3
|
+
按用户请求和已有约定推进工作,常规选择自行决定。只有缺失信息会改变目标或关键结果时才提问,并继续不受影响的工作。
|
|
4
|
+
|
|
5
|
+
## 工作方式
|
|
6
|
+
|
|
7
|
+
- 回查或续做项目时,按用户的称呼从根 `AGENTS.md` 找到项目正文;需要更多线索时按主题或交付物名称搜索。
|
|
8
|
+
- 操作后查看结果。超时、取消或断连后,先查状态再决定是否重试,避免重复执行。
|
|
9
|
+
- 优先复用工作区已接入的 CLI/MCP:工作区共享 MCP 定义在 `.pbot/mcp.json`(可通过宿主原生工具或 `pbot` MCP 的 `workspace_mcp_discover` / `workspace_mcp_call` 调用),也可同时使用宿主原生 MCP。接入或排障使用 `provider-connections` 技能;需要数据口径或使用限制时读取 `providers/<id>/GUIDE.md`。认证使用原生登录或环境变量引用,资料中不保存凭据值。
|
|
10
|
+
|
|
11
|
+
## 资料与环境
|
|
12
|
+
|
|
13
|
+
沿用已有工作区约定;新资料按下列用途组织,正文维护一份,其他位置用引用连接。
|
|
14
|
+
|
|
15
|
+
| 路径 | 用途 |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| `AGENTS.md` | 资料导航与已确认的工作区约定 |
|
|
18
|
+
| `areas/<领域>/` | 长期目标、约束、决策与复盘 |
|
|
19
|
+
| `projects/<名称>/` | 任务定义、结论与交付物;源码、依赖和测试 |
|
|
20
|
+
| `knowledge/<主题>/` | 可跨任务复用的概念、方法与口径 |
|
|
21
|
+
| `providers/AGENTS.md`、`providers/<id>/GUIDE.md` | 能力导航与使用手册 |
|
|
22
|
+
| `scratch/` | 临时脚本、查询与计算数据、下载及运行环境 |
|
|
23
|
+
| `agents/` | `coordinator.md`、`general-purpose.md` 的职责补充 |
|
|
24
|
+
| `.agents/skills/<名称>/SKILL.md` | 工作区自有专业方法(跨程序通用;正文描述意图与通用操作,不写死单一宿主的私有工具名) |
|
|
25
|
+
| `.pbot/mcp.json` | 工作区共享 MCP 服务清单(不含凭据值,凭据使用 `${ENV_VAR}` 或原生登录) |
|
|
26
|
+
|
|
27
|
+
保存有后续用途的结论、方法、决策和产物,普通问答不逐轮存档;更新、归集或整理资料时使用 `project-maintenance` 技能。保留用户资料、历史记录和备份。
|
|
28
|
+
|
|
29
|
+
环境上下文给出 `host`、`workspaceRoot`(资料工作区根目录)和 `resourceRoot`(包内资料根目录)。资料路径相对工作区根目录,命令与文件工具按实际 cwd 解析。需要 Python 计算时先读 `<resourceRoot>/references/compute.md`,涉及技术指标或回测另读 `<resourceRoot>/references/compute-finance.md`;计算、构建和测试遵循项目声明的环境。
|
|
30
|
+
|
|
31
|
+
答复先给结论,按需补充说明和产物路径。直接回答当前问题,不追加空泛的免责声明或无根据的推论;关键未知、前提和风险说清一次。数值注明对象、期间、单位与口径。
|
|
@@ -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、时间和非有限值。
|
|
@@ -0,0 +1,16 @@
|
|
|
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),显式确定数据口径和交易假设。
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Task Conductor
|
|
2
|
+
|
|
3
|
+
需要周期执行、重复流程、DAG 或离开当前会话后继续运行时使用本文。普通单次协助直接使用当前宿主专家。
|
|
4
|
+
|
|
5
|
+
## 发现与操作
|
|
6
|
+
|
|
7
|
+
在当前宿主原生工具与技能中查找 Task Conductor,先读取 `using-task-conductor` 技能,再按实际 MCP schema 调用(保留工具名中的连字符,如 `mcp__task-conductor__task_list`)。
|
|
8
|
+
|
|
9
|
+
工具或技能未出现时,向用户说明缺失项及对应宿主检查入口(如 Pi/Claude 的 `/mcp`、dsh 的 `/task-conductor status`),不要通过 Bash 代执行宿主聊天命令;继续不受影响的工作。
|
|
10
|
+
|
|
11
|
+
若需要在 dsh 后台执行节点,`executorId` 选择已注册的自定义执行端 `dsh-acp`(不是 `dsh`)。后台节点使用独立的 `acp` profile 运行环境,不继承当前主会话的模型、工具或 Python 配置。
|
|
12
|
+
|
|
13
|
+
## 定义任务
|
|
14
|
+
|
|
15
|
+
提交前写明输入、工作目录、所需工具与模型及预期产物;周期任务另须写明频率、时区、执行范围及每轮数据来源、期间与时点。
|
|
16
|
+
|
|
17
|
+
确认节点具备所需工具、技能、Python 环境和认证。需要人工交互的步骤留在交互会话中完成,节点直接执行分配任务,不递归委派。
|
|
18
|
+
|
|
19
|
+
## 状态与取消
|
|
20
|
+
|
|
21
|
+
任务定义、单次执行和节点分别用 `taskId`、`runId` 和节点 ID 标识。提交结果不明时先按 ID 或任务列表查询,避免重复创建。实时状态查 Task Conductor,项目资料只记录任务定义、标识和产物位置。
|
|
22
|
+
|
|
23
|
+
事件通知回到提交任务的原会话;新会话不代收,但可通过 MCP 查询。
|
|
24
|
+
|
|
25
|
+
取消当前执行与停止未来周期须分别操作并查询确认;停止本地专家或关闭当前会话不会停止 Task Conductor。汇报时区分“调度已创建”和“本轮已完成”,并给出状态与产物路径。
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# 工作区资料入口
|
|
2
|
+
|
|
3
|
+
## 目录树
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
./
|
|
7
|
+
├── areas/ # 长期目标、约束、建议、决策与复盘
|
|
8
|
+
├── projects/ # 任务定义、结论、交付物与源码
|
|
9
|
+
├── knowledge/ # 可复用的概念、方法与口径
|
|
10
|
+
├── providers/ # 能力提供方导航与手册
|
|
11
|
+
├── scratch/ # 临时脚本、查询与计算数据、下载及运行环境
|
|
12
|
+
└── agents/ # coordinator.md 与 general-purpose.md 的职责补充
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 项目速查
|
|
16
|
+
|
|
17
|
+
项目默认入口为 `projects/<目录名>/README.md`。
|
|
18
|
+
|
|
19
|
+
## 宿主分工偏好(可选)
|
|
20
|
+
|
|
21
|
+
可在此或 `agents/coordinator.md` 中约定不同任务优先使用的 Harness(如编码、分析、探索分别优先哪个 ACP `backend`)。
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pbot
|
|
3
|
+
description: 初始化 Personal Bot 工作区或查看状态。
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Personal Bot 工作区
|
|
8
|
+
|
|
9
|
+
从当前 Antigravity 工作区根目录,通过 `run_command` 执行对应命令。`<plugin-root>` 为本 `SKILL.md` 路径向上两级目录(即去掉尾部 `/skills/pbot/SKILL.md` 后的目录)。
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
node "<plugin-root>/lib/plugin.js" antigravity init
|
|
13
|
+
node "<plugin-root>/lib/plugin.js" antigravity status
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
根据用户参数选择一条:`init` 补建资料目录与根 `AGENTS.md` 并启用工作区,`status` 只查看工作区及当前配置状态。省略参数时查看状态。返回命令的实际结果和需要处理的错误。
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: project-maintenance
|
|
3
|
+
description: 维护项目导航、结论和可复用的任务定义,归集交付物,整理结项资料。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 项目整理与维护
|
|
7
|
+
|
|
8
|
+
只更新本次涉及的项目、长期事务正文及受影响的引用;全盘整理按用户指定范围进行。
|
|
9
|
+
|
|
10
|
+
## 更新正文与知识
|
|
11
|
+
|
|
12
|
+
- **项目正文**(默认 `projects/<目录名>/README.md`)和**长期事务**(`areas/<领域>/`):呈现当前结论、适用条件、分析口径和未决问题。直接修订同主题正文,合并重复内容并替换过时说明;重要结论或决策变化时简述原因,保留历史来源与时间并用引用连接,未解决的冲突保留原貌。
|
|
13
|
+
- **用户偏好与约定**:按用户实际表达记录,不把推测写成既定约定。
|
|
14
|
+
- **可复用知识**(`knowledge/<主题>/`):提炼可跨任务复用的概念、方法与口径,注明适用条件并引用来源。需要留史的研究和决策按日期与主题命名。
|
|
15
|
+
- **排查过程与测试流水**:不逐次追加到正文,必要实现细节写入对应技术资料。
|
|
16
|
+
|
|
17
|
+
## 维护根导航
|
|
18
|
+
|
|
19
|
+
更新根 `AGENTS.md` 的项目速查:列出目录名和用户常用称呼或主题词。采用默认入口(`projects/<目录名>/README.md`)的项目写目录名即可,其他项目链接到实际入口;进展和结论留在项目正文。
|
|
20
|
+
|
|
21
|
+
## 复用任务定义
|
|
22
|
+
|
|
23
|
+
需要跨会话继续或重复执行的任务,在所属项目或 `areas/<领域>/` 记录目标、输入、执行方式和预期产物,并随变化更新。
|
|
24
|
+
|
|
25
|
+
重复分析或报告按需写明:数据来源与查询方式、对象与筛选范围、期间与时区、单位、指标公式与分母、分组与比较基准、执行入口;单次报告引用该定义。
|
|
26
|
+
|
|
27
|
+
- 回查结论:引用对应时期的正文或交付物。
|
|
28
|
+
- 按原口径更新:核对原定义的来源与前提,使用本期数据;口径变化时说明对可比性的影响。
|
|
29
|
+
- 复现历史结果:使用当时的输入和版本。
|
|
30
|
+
|
|
31
|
+
## 归集、清理与结项
|
|
32
|
+
|
|
33
|
+
整理或结项时,检查本次涉及的项目目录和 `scratch/`:将结论与方法并入正文,将交付物和可复用源码归入项目目录,同步来源引用与执行入口。
|
|
34
|
+
|
|
35
|
+
归集完成后,只清理本次范围内已被吸收或不再需要的临时文件,不删除正式资料、历史记录或备份。结项时按目标核对交付物和执行入口,在项目正文记录交付结果、剩余工作和复用条件。
|