personal-bot 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/bin/pbot-pi-acp.mjs +27 -11
- package/bin/pbot.mjs +1 -1
- package/docs/README.md +1 -1
- package/docs/architecture/design.md +23 -10
- package/docs/architecture/extensibility.md +20 -18
- package/docs/architecture/model-context.md +2 -2
- package/docs/architecture/principles.md +4 -3
- package/docs/guides/capabilities.md +3 -3
- package/docs/guides/history.md +50 -16
- package/docs/guides/workspace-configuration.md +31 -6
- package/docs/hosts/antigravity.md +2 -0
- package/docs/hosts/claude-code.md +1 -1
- package/docs/hosts/dsh.md +1 -1
- package/docs/hosts/pi.md +1 -1
- package/hooks/hooks.json +3 -0
- package/lib/antigravity-plugin/hooks.json +7 -0
- package/lib/antigravity-plugin/lib/claude.js +2 -2
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +156 -11
- package/lib/antigravity-plugin/lib/extension/{plugin-runtime.d.ts → hosts/plugin-runtime.d.ts} +2 -2
- package/lib/antigravity-plugin/lib/extension/{plugin-runtime.js → hosts/plugin-runtime.js} +34 -8
- package/lib/antigravity-plugin/lib/extension/mcp.js +1113 -78
- package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +1 -0
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +5 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.d.ts +6 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.js +171 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/{claude.d.ts → claude/adapter.d.ts} +1 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/{claude.js → claude/adapter.js} +32 -4
- package/lib/antigravity-plugin/lib/integrations/hosts/{registry.js → plugin-registry.js} +2 -2
- package/lib/antigravity-plugin/lib/model/history.d.ts +169 -0
- package/lib/antigravity-plugin/lib/model/plugin-host.d.ts +26 -0
- package/lib/antigravity-plugin/lib/model/workspace-config.d.ts +25 -0
- package/lib/antigravity-plugin/lib/plugin.js +2 -2
- package/lib/antigravity-plugin/lib/services/history/history-capture.d.ts +4 -0
- package/lib/antigravity-plugin/lib/services/history/history-capture.js +86 -0
- package/lib/antigravity-plugin/lib/services/history/history-index.d.ts +17 -0
- package/lib/antigravity-plugin/lib/services/history/history-index.js +112 -0
- package/lib/antigravity-plugin/lib/services/history/history-migrate.d.ts +12 -0
- package/lib/antigravity-plugin/lib/services/history/history-migrate.js +88 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.d.ts +7 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.js +121 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.d.ts +7 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.js +124 -0
- package/lib/antigravity-plugin/lib/services/history/summary-registry.d.ts +7 -0
- package/lib/antigravity-plugin/lib/services/history/summary-registry.js +36 -0
- package/lib/antigravity-plugin/lib/services/history/summary-runner.d.ts +37 -0
- package/lib/antigravity-plugin/lib/services/history/summary-runner.js +301 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.d.ts +5 -1
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.js +75 -4
- package/lib/antigravity-plugin/lib/storage/file-access.d.ts +2 -0
- package/lib/antigravity-plugin/lib/storage/file-access.js +26 -0
- package/lib/antigravity-plugin/lib/storage/history-files.d.ts +54 -0
- package/lib/antigravity-plugin/lib/storage/history-files.js +467 -0
- package/lib/antigravity-plugin/lib/storage/history-format.d.ts +6 -0
- package/lib/antigravity-plugin/lib/storage/history-format.js +62 -0
- package/lib/antigravity-plugin/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +1 -1
- package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +22 -12
- package/lib/claude.js +2 -2
- package/lib/client.js +21 -11
- package/lib/dsh.js +4 -4
- package/lib/extension/{acp-member.d.ts → acp/member.d.ts} +5 -5
- package/lib/extension/{acp-member.js → acp/member.js} +6 -6
- package/lib/extension/acp/worker.d.ts +1 -0
- package/lib/extension/acp/worker.js +384 -0
- package/lib/extension/acp-worker.js +156 -11
- package/lib/extension/{dsh → hosts/dsh}/acp-member.js +8 -8
- package/lib/extension/hosts/dsh/command.js +92 -0
- package/lib/extension/{dsh → hosts/dsh}/files.js +3 -3
- package/lib/extension/hosts/dsh/history.d.ts +4 -0
- package/lib/extension/hosts/dsh/history.js +62 -0
- package/lib/extension/{dsh → hosts/dsh}/management.d.ts +1 -1
- package/lib/extension/{dsh → hosts/dsh}/management.js +12 -10
- package/lib/extension/{dsh → hosts/dsh}/workspace.d.ts +3 -9
- package/lib/extension/{dsh → hosts/dsh}/workspace.js +32 -70
- package/lib/extension/{plugin-runtime.d.ts → hosts/plugin-runtime.d.ts} +2 -2
- package/lib/extension/{plugin-runtime.js → hosts/plugin-runtime.js} +34 -8
- package/lib/extension/{mcp-bridge.d.ts → mcp/bridge.d.ts} +1 -1
- package/lib/extension/{mcp-bridge.js → mcp/bridge.js} +4 -4
- package/lib/extension/{mcp-workers.d.ts → mcp/workers.d.ts} +222 -2
- package/lib/extension/{mcp-workers.js → mcp/workers.js} +229 -63
- package/lib/extension/mcp.js +1113 -78
- package/lib/extension/{setup-cli.js → setup/cli.js} +9 -9
- package/lib/integrations/acp/connection.d.ts +11 -10
- package/lib/integrations/acp/connection.js +6 -0
- package/lib/integrations/acp/harnesses/claude.js +1 -1
- package/lib/integrations/acp/harnesses/dsh.js +1 -1
- package/lib/integrations/acp/history-summary.d.ts +17 -0
- package/lib/integrations/acp/history-summary.js +100 -0
- package/lib/integrations/agent-resources.d.ts +1 -0
- package/lib/integrations/agent-resources.js +5 -1
- package/lib/integrations/hosts/antigravity/adapter.d.ts +6 -0
- package/lib/integrations/hosts/antigravity/adapter.js +171 -0
- package/lib/integrations/hosts/{claude.d.ts → claude/adapter.d.ts} +1 -1
- package/lib/integrations/hosts/{claude.js → claude/adapter.js} +32 -4
- package/lib/integrations/{dsh → hosts/dsh}/mcp.d.ts +1 -1
- package/lib/integrations/{dsh → hosts/dsh}/resources.d.ts +1 -1
- package/lib/integrations/{dsh → hosts/dsh}/resources.js +4 -4
- package/lib/integrations/{dsh → hosts/dsh}/schema.js +1 -1
- package/lib/integrations/{dsh → hosts/dsh}/skills.js +1 -1
- package/lib/integrations/hosts/{registry.js → plugin-registry.js} +2 -2
- package/lib/integrations/installation/pi-setup.js +1 -1
- package/lib/model/history.d.ts +133 -34
- package/lib/model/plugin-host.d.ts +26 -0
- package/lib/model/workspace-config.d.ts +25 -0
- package/lib/plugin.js +2 -2
- package/lib/services/agents/agent-run.d.ts +1 -1
- package/lib/services/history/history-capture.d.ts +4 -0
- package/lib/services/history/history-capture.js +86 -0
- package/lib/services/history/history-index.d.ts +16 -7
- package/lib/services/history/history-index.js +48 -70
- package/lib/services/history/history-migrate.d.ts +12 -0
- package/lib/services/history/history-migrate.js +88 -0
- package/lib/services/history/history-query.d.ts +51 -0
- package/lib/services/history/history-query.js +371 -0
- package/lib/services/history/summary-command.d.ts +20 -0
- package/lib/services/history/summary-command.js +68 -0
- package/lib/services/history/summary-dimensions/monthly.d.ts +7 -0
- package/lib/services/history/summary-dimensions/monthly.js +121 -0
- package/lib/services/history/summary-dimensions/session.d.ts +7 -0
- package/lib/services/history/summary-dimensions/session.js +124 -0
- package/lib/services/history/summary-registry.d.ts +7 -0
- package/lib/services/history/summary-registry.js +36 -0
- package/lib/services/history/summary-runner.d.ts +37 -0
- package/lib/services/history/summary-runner.js +301 -0
- package/lib/services/workspace/workspace-config.d.ts +5 -1
- package/lib/services/workspace/workspace-config.js +75 -4
- package/lib/storage/history-files.d.ts +45 -9
- package/lib/storage/history-files.js +373 -247
- package/lib/storage/history-format.d.ts +3 -12
- package/lib/storage/history-format.js +26 -50
- package/lib/tools/history/actions.d.ts +3 -68
- package/lib/tools/history/actions.js +7 -5
- package/lib/tools/history/contract.d.ts +14 -7
- package/lib/tools/history/contract.js +58 -18
- package/lib/tools/history/dsh-tool.d.ts +1 -2
- package/lib/tools/history/dsh-tool.js +11 -5
- package/lib/ui/dsh/management.js +18 -5
- package/package.json +1 -1
- package/resources/prompts/history-coordinator.md +1 -1
- package/resources/prompts/history-monthly-summary.md +13 -0
- package/resources/prompts/history-summary.md +10 -4
- package/resources/skills/provider-connections/SKILL.md +22 -12
- package/src/claude.ts +2 -2
- package/src/dsh.ts +4 -4
- package/src/extension/{acp-member.ts → acp/member.ts} +7 -7
- package/src/extension/{acp-worker.ts → acp/worker.ts} +131 -17
- package/src/extension/{dsh → hosts/dsh}/acp-member.ts +9 -9
- package/src/extension/hosts/dsh/command.ts +92 -0
- package/src/extension/{dsh → hosts/dsh}/files.ts +3 -3
- package/src/extension/hosts/dsh/history.ts +67 -0
- package/src/extension/{dsh → hosts/dsh}/management.ts +11 -9
- package/src/extension/{dsh → hosts/dsh}/workspace.ts +31 -50
- package/src/extension/{pi-acp-member.ts → hosts/pi/acp-member.ts} +9 -9
- package/src/extension/hosts/pi/command.ts +158 -0
- package/src/extension/{events.ts → hosts/pi/events.ts} +14 -4
- package/src/extension/hosts/pi/history.ts +45 -0
- package/src/extension/{lifecycle.ts → hosts/pi/lifecycle.ts} +7 -11
- package/src/extension/{plugin-runtime.ts → hosts/plugin-runtime.ts} +29 -9
- package/src/extension/{mcp-bridge.ts → mcp/bridge.ts} +5 -5
- package/src/extension/{mcp-workers.ts → mcp/workers.ts} +237 -64
- package/src/extension/{setup-cli.ts → setup/cli.ts} +11 -11
- package/src/integrations/acp/connection.ts +6 -0
- package/src/integrations/acp/harnesses/claude.ts +1 -1
- package/src/integrations/acp/harnesses/dsh.ts +1 -1
- package/src/integrations/acp/history-summary.ts +108 -0
- package/src/integrations/agent-resources.ts +6 -0
- package/src/integrations/hosts/antigravity/adapter.ts +161 -0
- package/src/integrations/hosts/{claude.ts → claude/adapter.ts} +28 -5
- package/src/integrations/{dsh → hosts/dsh}/mcp.ts +1 -1
- package/src/integrations/{dsh → hosts/dsh}/resources.ts +5 -5
- package/src/integrations/{dsh → hosts/dsh}/schema.ts +1 -1
- package/src/integrations/{dsh → hosts/dsh}/session.ts +2 -2
- package/src/integrations/{dsh → hosts/dsh}/skills.ts +1 -1
- package/src/integrations/{pi → hosts/pi}/mcp.ts +1 -1
- package/src/integrations/{pi → hosts/pi}/skills.ts +1 -1
- package/src/integrations/hosts/{registry.ts → plugin-registry.ts} +2 -2
- package/src/integrations/installation/pi-setup.ts +1 -1
- package/src/mcp.ts +1 -1
- package/src/model/history.ts +151 -26
- package/src/model/plugin-host.ts +26 -2
- package/src/model/workspace-config.ts +30 -0
- package/src/pbot.ts +13 -22
- package/src/plugin.ts +2 -2
- package/src/services/history/history-capture.ts +83 -0
- package/src/services/history/history-index.ts +48 -62
- package/src/services/history/history-migrate.ts +89 -0
- package/src/services/history/history-query.ts +415 -0
- package/src/services/history/summary-command.ts +69 -0
- package/src/services/history/summary-dimensions/monthly.ts +139 -0
- package/src/services/history/summary-dimensions/session.ts +149 -0
- package/src/services/history/summary-registry.ts +44 -0
- package/src/services/history/summary-runner.ts +352 -0
- package/src/services/workspace/workspace-config.ts +93 -5
- package/src/storage/history-files.ts +408 -188
- package/src/storage/history-format.ts +46 -60
- package/src/tools/history/actions.ts +8 -6
- package/src/tools/history/contract.ts +65 -20
- package/src/tools/history/dsh-tool.ts +17 -8
- package/src/tools/history/pi-tool.ts +21 -0
- package/src/tools/register.ts +3 -4
- package/src/ui/dsh/management.ts +27 -11
- package/src/ui/{confirmation.ts → pi/confirmation.ts} +1 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.d.ts +0 -4
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.js +0 -79
- package/lib/extension/dsh/command.js +0 -50
- package/lib/extension/dsh/history.d.ts +0 -15
- package/lib/extension/dsh/history.js +0 -87
- package/lib/integrations/dsh/history-summary.d.ts +0 -11
- package/lib/integrations/dsh/history-summary.js +0 -36
- package/lib/integrations/dsh/history.d.ts +0 -16
- package/lib/integrations/dsh/history.js +0 -167
- package/lib/integrations/history-summary.d.ts +0 -4
- package/lib/integrations/history-summary.js +0 -32
- package/lib/integrations/hosts/antigravity.d.ts +0 -4
- package/lib/integrations/hosts/antigravity.js +0 -79
- package/lib/services/history/history-service.d.ts +0 -106
- package/lib/services/history/history-service.js +0 -242
- package/lib/storage/acp-history.d.ts +0 -10
- package/lib/storage/acp-history.js +0 -57
- package/src/extension/command.ts +0 -76
- package/src/extension/dsh/command.ts +0 -54
- package/src/extension/dsh/history.ts +0 -74
- package/src/extension/history.ts +0 -26
- package/src/integrations/dsh/history-summary.ts +0 -39
- package/src/integrations/dsh/history.ts +0 -84
- package/src/integrations/history-summary.ts +0 -30
- package/src/integrations/hosts/antigravity.ts +0 -83
- package/src/integrations/pi/history.ts +0 -99
- package/src/services/history/history-service.ts +0 -195
- package/src/storage/acp-history.ts +0 -49
- package/src/tools/history/tool.ts +0 -19
- /package/lib/antigravity-plugin/lib/integrations/hosts/{registry.d.ts → plugin-registry.d.ts} +0 -0
- /package/lib/{extension/acp-worker.d.ts → antigravity-plugin/lib/model/history.js} +0 -0
- /package/lib/extension/{dsh → hosts/dsh}/acp-member.d.ts +0 -0
- /package/lib/extension/{dsh → hosts/dsh}/command.d.ts +0 -0
- /package/lib/extension/{dsh → hosts/dsh}/files.d.ts +0 -0
- /package/lib/extension/{setup-guard.js → setup/guard.js} +0 -0
- /package/lib/integrations/acp/{claude.d.ts → claude-settings.d.ts} +0 -0
- /package/lib/integrations/acp/{claude.js → claude-settings.js} +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/mcp.js +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/messages.d.ts +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/messages.js +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/root-agents.d.ts +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/root-agents.js +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/schema.d.ts +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/skills.d.ts +0 -0
- /package/lib/integrations/hosts/{registry.d.ts → plugin-registry.d.ts} +0 -0
- /package/src/extension/{setup-guard.ts → setup/guard.ts} +0 -0
- /package/src/integrations/acp/{claude.ts → claude-settings.ts} +0 -0
- /package/src/integrations/{dsh → hosts/dsh}/messages.ts +0 -0
- /package/src/integrations/{dsh → hosts/dsh}/root-agents.ts +0 -0
- /package/src/integrations/{pi → hosts/pi}/agent-tools.ts +0 -0
|
@@ -4,6 +4,7 @@ import { setTimeout as delay } from "node:timers/promises";
|
|
|
4
4
|
import * as acp from "@agentclientprotocol/sdk";
|
|
5
5
|
import type { AcpHarnessAdapter, AcpModelSelection, AcpSessionReference } from "../../model/acp.js";
|
|
6
6
|
import type { AgentOptions } from "../../model/agent.js";
|
|
7
|
+
import { object } from "../../common/json.js";
|
|
7
8
|
import { requireThat } from "../../common/validation.js";
|
|
8
9
|
import { packageVersion } from "../../common/version.js";
|
|
9
10
|
import { acpChoices, acpModelSelection, acpModelValue, acpThinkingValue } from "./model-selection.js";
|
|
@@ -142,9 +143,13 @@ export async function openAcp(
|
|
|
142
143
|
systemPrompt: { mode: "append" as const, content: [{ type: "text" as const, text: openOptions.systemPrompt }] },
|
|
143
144
|
} : {}),
|
|
144
145
|
};
|
|
146
|
+
let startupInfo: string | undefined;
|
|
145
147
|
if (reference.sessionId === null) {
|
|
146
148
|
const created = await connection.agent.request<acp.NewSessionResponse>(acp.methods.agent.session.new, setup, { cancellationSignal: AbortSignal.any([cancel, AbortSignal.timeout(30_000)]), stopWaitingOnCancel: true });
|
|
147
149
|
sessionId = created.sessionId; options = created.configOptions ?? [];
|
|
150
|
+
if (object(created._meta) && object(created._meta.piAcp) && typeof created._meta.piAcp.startupInfo === "string") {
|
|
151
|
+
startupInfo = created._meta.piAcp.startupInfo;
|
|
152
|
+
}
|
|
148
153
|
} else {
|
|
149
154
|
requireThat(capabilities.resume || capabilities.load, "目标 ACP 后端不支持恢复已有会话,请新建 worker。");
|
|
150
155
|
const restored = capabilities.resume
|
|
@@ -157,6 +162,7 @@ export async function openAcp(
|
|
|
157
162
|
return {
|
|
158
163
|
sessionId: activeId, capabilities, signal: connected, close, images: advertised?.promptCapabilities?.image === true,
|
|
159
164
|
systemPrompt: Boolean(advertised?.sessionCapabilities?.systemPrompt),
|
|
165
|
+
...(startupInfo ? { startupInfo } : {}),
|
|
160
166
|
selection,
|
|
161
167
|
choices: () => acpChoices(options),
|
|
162
168
|
async configure(requested: AgentOptions) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { object } from "../../../common/json.js";
|
|
2
2
|
import { requireThat } from "../../../common/validation.js";
|
|
3
3
|
import type { AcpHarnessAdapter } from "../../../model/acp.js";
|
|
4
|
-
import { claudeOptions } from "../claude.js";
|
|
4
|
+
import { claudeOptions } from "../claude-settings.js";
|
|
5
5
|
import { defaultPrepareLaunch, filterStandardAcpOptions, validateStandardAcpOptions } from "./generic.js";
|
|
6
6
|
|
|
7
7
|
export const claudeAcpHarness: AcpHarnessAdapter = {
|
|
@@ -20,7 +20,7 @@ export const dshAcpHarness: AcpHarnessAdapter = {
|
|
|
20
20
|
const patch = join(context.directory, "acp-dsh-patch.json");
|
|
21
21
|
await writeFile(
|
|
22
22
|
patch,
|
|
23
|
-
JSON.stringify([{ insert: [{ id: "pbot-acp-member", name: join(context.packageRoot, "lib/extension/dsh/acp-member.js") }] }]) + "\n",
|
|
23
|
+
JSON.stringify([{ insert: [{ id: "pbot-acp-member", name: join(context.packageRoot, "lib/extension/hosts/dsh/acp-member.js") }] }]) + "\n",
|
|
24
24
|
{ mode: 0o600 },
|
|
25
25
|
);
|
|
26
26
|
return {
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { fork } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { resourceRoot } from "../../common/paths.js";
|
|
5
|
+
import { requireThat } from "../../common/validation.js";
|
|
6
|
+
import type { AcpBackend, AcpCommands } from "../../model/acp.js";
|
|
7
|
+
import type { HistorySummarizer } from "../../model/history.js";
|
|
8
|
+
import { acpLaunch, canonicalAcpBackend } from "./launch.js";
|
|
9
|
+
|
|
10
|
+
export interface AcpHistorySummarizerOptions {
|
|
11
|
+
cwd: string;
|
|
12
|
+
backend?: AcpBackend;
|
|
13
|
+
commands?: AcpCommands;
|
|
14
|
+
model?: string;
|
|
15
|
+
thinking?: string;
|
|
16
|
+
timeoutMs?: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const defaultTimeoutMs = 180_000;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Spawns one isolated, ephemeral ACP worker process per summary task (default backend: "pi").
|
|
23
|
+
* Each worker runs with PBOT_SUBAGENT_RUN_ID set (so no host records raw history),
|
|
24
|
+
* denies all write/tool permissions, uses the target harness's default model unless overridden,
|
|
25
|
+
* and exits immediately after returning the summary text.
|
|
26
|
+
*/
|
|
27
|
+
export function createAcpHistorySummarizer(options: AcpHistorySummarizerOptions): HistorySummarizer {
|
|
28
|
+
const workerPath = resolve(resourceRoot, "../lib/extension/acp-worker.js");
|
|
29
|
+
requireThat(process.platform === "linux" || process.platform === "darwin", "ACP 摘要 worker 当前支持 Linux 和 macOS。");
|
|
30
|
+
requireThat(existsSync(workerPath), "缺少 ACP worker 构建产物;请先运行 npm run build。");
|
|
31
|
+
|
|
32
|
+
const commands = options.commands ?? {};
|
|
33
|
+
const backend = canonicalAcpBackend(options.backend ?? "pi", commands);
|
|
34
|
+
const reference = acpLaunch(backend, commands, {});
|
|
35
|
+
const timeoutMs = options.timeoutMs ?? defaultTimeoutMs;
|
|
36
|
+
|
|
37
|
+
return async (request, signal) => {
|
|
38
|
+
signal.throwIfAborted();
|
|
39
|
+
return await new Promise<string>((resolveAnswer, reject) => {
|
|
40
|
+
const child = fork(workerPath, ["--prompt"], {
|
|
41
|
+
cwd: options.cwd,
|
|
42
|
+
env: { ...process.env },
|
|
43
|
+
detached: true,
|
|
44
|
+
stdio: ["ignore", "ignore", "ignore", "ipc"],
|
|
45
|
+
execArgv: [],
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
let answer: string | undefined;
|
|
49
|
+
let failure: Error | undefined;
|
|
50
|
+
let settled = false;
|
|
51
|
+
|
|
52
|
+
const killGroup = () => {
|
|
53
|
+
if (!child.pid) return;
|
|
54
|
+
try { process.kill(-child.pid, "SIGKILL"); }
|
|
55
|
+
catch { /* Process group already exited. */ }
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const onAbort = () => {
|
|
59
|
+
const abortError = signal.reason instanceof Error
|
|
60
|
+
? signal.reason
|
|
61
|
+
: Object.assign(new Error("历史摘要已取消。"), { name: "AbortError" });
|
|
62
|
+
failure = abortError;
|
|
63
|
+
killGroup();
|
|
64
|
+
};
|
|
65
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
66
|
+
|
|
67
|
+
const timer = setTimeout(() => {
|
|
68
|
+
failure = new Error(`ACP 摘要 worker(${backend})执行超时。`);
|
|
69
|
+
killGroup();
|
|
70
|
+
}, timeoutMs);
|
|
71
|
+
|
|
72
|
+
const finish = (err?: Error, value?: string) => {
|
|
73
|
+
if (settled) return;
|
|
74
|
+
settled = true;
|
|
75
|
+
clearTimeout(timer);
|
|
76
|
+
signal.removeEventListener("abort", onAbort);
|
|
77
|
+
if (err) reject(err);
|
|
78
|
+
else resolveAnswer(value!);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
child.on("message", (message: { type?: string; text?: string; error?: string }) => {
|
|
82
|
+
if (message.type === "answer" && typeof message.text === "string") answer = message.text;
|
|
83
|
+
if (message.type === "error") failure = new Error(message.error ?? `ACP 摘要 worker(${backend})失败。`);
|
|
84
|
+
});
|
|
85
|
+
child.once("error", error => { failure = error; });
|
|
86
|
+
child.once("spawn", () => {
|
|
87
|
+
if (signal.aborted) { onAbort(); return; }
|
|
88
|
+
child.send({
|
|
89
|
+
reference,
|
|
90
|
+
cwd: options.cwd,
|
|
91
|
+
system: request.system,
|
|
92
|
+
prompt: request.prompt,
|
|
93
|
+
...(options.model ? { model: options.model } : {}),
|
|
94
|
+
...(options.thinking ? { thinking: options.thinking } : {}),
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
child.once("close", code => {
|
|
98
|
+
if (signal.aborted) {
|
|
99
|
+
finish(failure ?? Object.assign(new Error("历史摘要已取消。"), { name: "AbortError" }));
|
|
100
|
+
} else if (answer && code === 0 && !failure) {
|
|
101
|
+
finish(undefined, answer);
|
|
102
|
+
} else {
|
|
103
|
+
finish(failure ?? new Error(`ACP 摘要 worker(${backend})异常退出(code=${String(code)})。`));
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
}
|
|
@@ -49,6 +49,7 @@ export async function loadWorkspaceContext(options: {
|
|
|
49
49
|
includeRootAgents?: boolean;
|
|
50
50
|
localRoleOnly?: boolean;
|
|
51
51
|
workspaceSkills?: readonly WorkspaceSkillMeta[];
|
|
52
|
+
notices?: readonly string[];
|
|
52
53
|
}): Promise<WorkspaceContext> {
|
|
53
54
|
const {
|
|
54
55
|
host,
|
|
@@ -59,6 +60,7 @@ export async function loadWorkspaceContext(options: {
|
|
|
59
60
|
includeRootAgents = false,
|
|
60
61
|
localRoleOnly = false,
|
|
61
62
|
workspaceSkills = [],
|
|
63
|
+
notices = [],
|
|
62
64
|
} = options;
|
|
63
65
|
const [workspace, roleText, rootAgents] = includePrompts
|
|
64
66
|
? await Promise.all([
|
|
@@ -68,12 +70,16 @@ export async function loadWorkspaceContext(options: {
|
|
|
68
70
|
])
|
|
69
71
|
: ["", "", ""];
|
|
70
72
|
const skillsSection = formatWorkspaceSkills(workspaceSkills);
|
|
73
|
+
const noticesSection = notices.length
|
|
74
|
+
? "## 启动提示\n\n" + notices.map(item => `- ${item}`).join("\n")
|
|
75
|
+
: "";
|
|
71
76
|
const environment = { host, workspaceRoot: root, resourceRoot };
|
|
72
77
|
const text = [
|
|
73
78
|
workspace,
|
|
74
79
|
roleText,
|
|
75
80
|
rootAgents,
|
|
76
81
|
skillsSection,
|
|
82
|
+
noticesSection,
|
|
77
83
|
"## 环境\n\n" + JSON.stringify(environment),
|
|
78
84
|
].filter(Boolean).join("\n\n");
|
|
79
85
|
return { workspace, role: roleText, rootAgents, workspaceSkills: [...workspaceSkills], environment, text };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { readFile, realpath, stat } from "node:fs/promises";
|
|
2
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { object } from "../../../common/json.js";
|
|
4
|
+
import { resourceRoot } from "../../../common/paths.js";
|
|
5
|
+
import { requireThat } from "../../../common/validation.js";
|
|
6
|
+
import type { HistoryExchange, HistorySession } from "../../../model/history.js";
|
|
7
|
+
import type { HostEvent, PluginHostAdapter } from "../../../model/plugin-host.js";
|
|
8
|
+
|
|
9
|
+
const supportedEvents = ["SessionStart", "PreToolUse", "Stop"];
|
|
10
|
+
|
|
11
|
+
function cleanUserRequest(content: string): string {
|
|
12
|
+
const match = content.match(/<USER_REQUEST>\s*([\s\S]*?)\s*<\/USER_REQUEST>/);
|
|
13
|
+
return (match ? match[1]! : content).trim();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function projectAntigravityTranscript(sessionId: string, content: string, terminationReason?: string): HistorySession {
|
|
17
|
+
const exchanges: HistoryExchange[] = [];
|
|
18
|
+
const lines = content.split(/\r?\n/);
|
|
19
|
+
let users: { id: string; text: string; time: string }[] = [];
|
|
20
|
+
let answer: { id: string; text: string; time: string } | undefined;
|
|
21
|
+
|
|
22
|
+
const finish = (completed: boolean) => {
|
|
23
|
+
if (!users.length) return;
|
|
24
|
+
const entryIds = [...users.map(u => u.id), ...(answer ? [answer.id] : [])];
|
|
25
|
+
const from = users[0]!.time;
|
|
26
|
+
const to = answer?.time ?? users.at(-1)!.time;
|
|
27
|
+
const text = users.map(u => "用户:\n" + u.text).join("\n\n") +
|
|
28
|
+
(answer ? "\n\n助手:\n" + answer.text : "");
|
|
29
|
+
exchanges.push({ entryIds, from, to, completed, text });
|
|
30
|
+
users = [];
|
|
31
|
+
answer = undefined;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
for (const line of lines) {
|
|
35
|
+
const trimmed = line.trim();
|
|
36
|
+
if (!trimmed) continue;
|
|
37
|
+
let entry: unknown;
|
|
38
|
+
try { entry = JSON.parse(trimmed); } catch { continue; }
|
|
39
|
+
if (!object(entry) || typeof entry.type !== "string") continue;
|
|
40
|
+
const stepIndex = typeof entry.step_index === "number" ? entry.step_index : exchanges.length;
|
|
41
|
+
const time = typeof entry.created_at === "string" && entry.created_at ? entry.created_at : new Date().toISOString();
|
|
42
|
+
if (entry.type === "USER_INPUT" && typeof entry.content === "string") {
|
|
43
|
+
if (answer) finish(true);
|
|
44
|
+
const cleaned = cleanUserRequest(entry.content);
|
|
45
|
+
if (cleaned) users.push({ id: `agy:${stepIndex}`, text: cleaned, time });
|
|
46
|
+
} else if (entry.type === "PLANNER_RESPONSE" && users.length) {
|
|
47
|
+
const hasToolCalls = Array.isArray(entry.tool_calls) && entry.tool_calls.length > 0;
|
|
48
|
+
const text = typeof entry.content === "string" ? entry.content.trim() : "";
|
|
49
|
+
if (!hasToolCalls && text) {
|
|
50
|
+
answer = { id: `agy:${stepIndex}`, text, time };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const completed = Boolean(answer) && (!terminationReason || terminationReason === "NO_TOOL_CALL");
|
|
55
|
+
finish(completed);
|
|
56
|
+
return { sessionId, name: "", branches: exchanges.length ? [exchanges] : [] };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function readAntigravityTranscript(transcriptPath: string): Promise<string | undefined> {
|
|
60
|
+
const fullPath = join(dirname(transcriptPath), "transcript_full.jsonl");
|
|
61
|
+
for (const path of [fullPath, transcriptPath]) {
|
|
62
|
+
try { return await readFile(path, "utf8"); }
|
|
63
|
+
catch (error) { if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error; }
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function workspaceFromPayload(cwd: string, payload?: unknown): string {
|
|
69
|
+
if (object(payload) && Array.isArray(payload.workspacePaths)) {
|
|
70
|
+
const first = payload.workspacePaths.find(value => typeof value === "string" && value.length > 0);
|
|
71
|
+
if (typeof first === "string") return first;
|
|
72
|
+
}
|
|
73
|
+
return cwd;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function skillFromReadPath(targetPath: string, pluginRoot = process.env.PLUGIN_ROOT || resolve(resourceRoot, "..")): string | undefined {
|
|
77
|
+
const skillsRoot = resolve(pluginRoot, "skills");
|
|
78
|
+
const rel = relative(skillsRoot, resolve(targetPath));
|
|
79
|
+
if (!rel || rel.startsWith("..") || isAbsolute(rel)) return undefined;
|
|
80
|
+
const skill = rel.split(sep)[0];
|
|
81
|
+
if (!skill || skill === "pbot") return undefined;
|
|
82
|
+
return skill;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function isPreToolUse(payload: unknown): boolean {
|
|
86
|
+
return object(payload) && payload.hookEventName === "PreToolUse";
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export async function antigravityWorkspaceRoot(cwd: string, payload?: unknown): Promise<string> {
|
|
90
|
+
const directory = workspaceFromPayload(cwd, payload);
|
|
91
|
+
requireThat(isAbsolute(directory), "Antigravity 工作区需要绝对路径。");
|
|
92
|
+
const root = await realpath(directory);
|
|
93
|
+
requireThat((await stat(root)).isDirectory(), "Antigravity 工作区需要目录。");
|
|
94
|
+
return root;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export const antigravityAdapter: PluginHostAdapter = {
|
|
98
|
+
host: "antigravity",
|
|
99
|
+
nativeRootAgents: true,
|
|
100
|
+
nativeWorkspaceSkills: true,
|
|
101
|
+
coordinatorPrompt: "plugin-coordinator.md",
|
|
102
|
+
initCommandHint: "/pbot init",
|
|
103
|
+
usage: "用法:node <插件目录>/lib/plugin.js antigravity init|status",
|
|
104
|
+
resolveRoot(cwd, rawPayload) {
|
|
105
|
+
return antigravityWorkspaceRoot(cwd, rawPayload);
|
|
106
|
+
},
|
|
107
|
+
parseEvent(value): HostEvent {
|
|
108
|
+
requireThat(object(value) && typeof value.hookEventName === "string", "Antigravity hook 输入无效。");
|
|
109
|
+
const event = value.hookEventName;
|
|
110
|
+
requireThat(supportedEvents.includes(event), "Antigravity hook 事件未支持。");
|
|
111
|
+
const cwd = typeof value.cwd === "string" && value.cwd ? value.cwd : workspaceFromPayload("", value);
|
|
112
|
+
requireThat(cwd, "Antigravity hook 缺少工作目录。");
|
|
113
|
+
if (event === "SessionStart") {
|
|
114
|
+
return { kind: "inject-context", role: "coordinator", isSessionStart: true, cwd, raw: value };
|
|
115
|
+
}
|
|
116
|
+
if (event === "Stop") {
|
|
117
|
+
return { kind: "record-history", cwd, raw: value };
|
|
118
|
+
}
|
|
119
|
+
if (!object(value.toolCall) || typeof value.toolCall.name !== "string" || !object(value.toolCall.args)) {
|
|
120
|
+
return { kind: "ignore" };
|
|
121
|
+
}
|
|
122
|
+
const { name, args } = value.toolCall;
|
|
123
|
+
if (name === "read_file" && typeof args.Path === "string") {
|
|
124
|
+
const skill = skillFromReadPath(args.Path);
|
|
125
|
+
if (skill) return { kind: "check-skill", skill, cwd, raw: value };
|
|
126
|
+
}
|
|
127
|
+
return { kind: "ignore" };
|
|
128
|
+
},
|
|
129
|
+
async extractHistory(event) {
|
|
130
|
+
if (event.kind !== "record-history" || !object(event.raw)) return undefined;
|
|
131
|
+
const sessionId = typeof event.raw.conversationId === "string" ? event.raw.conversationId.trim() : "";
|
|
132
|
+
if (!sessionId) return undefined;
|
|
133
|
+
const terminationReason = typeof event.raw.terminationReason === "string" ? event.raw.terminationReason : undefined;
|
|
134
|
+
const transcriptPath = typeof event.raw.transcriptPath === "string" ? event.raw.transcriptPath.trim() : "";
|
|
135
|
+
if (transcriptPath) {
|
|
136
|
+
const content = await readAntigravityTranscript(transcriptPath);
|
|
137
|
+
if (content) {
|
|
138
|
+
const session = projectAntigravityTranscript(sessionId, content, terminationReason);
|
|
139
|
+
if (session.branches.length) return { kind: "session", session };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const lastUserInput = typeof event.raw.lastUserInput === "string" ? event.raw.lastUserInput.trim() : "";
|
|
143
|
+
if (lastUserInput) return { kind: "input", sessionId, text: lastUserInput };
|
|
144
|
+
return undefined;
|
|
145
|
+
},
|
|
146
|
+
formatPass(payload) {
|
|
147
|
+
return isPreToolUse(payload) ? { decision: "allow" } : {};
|
|
148
|
+
},
|
|
149
|
+
formatContext(_event, context) {
|
|
150
|
+
return {
|
|
151
|
+
injectSteps: [
|
|
152
|
+
{ systemMessage: { systemMessage: context.text } },
|
|
153
|
+
],
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
formatDeny(_event, reason) {
|
|
157
|
+
return { decision: "deny", reason };
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export const antigravitySkillPath = (pluginRoot: string, skill: string) => join(pluginRoot, "skills", skill, "SKILL.md");
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { realpath, stat } from "node:fs/promises";
|
|
2
2
|
import { isAbsolute } from "node:path";
|
|
3
|
-
import { object } from "
|
|
4
|
-
import { requireThat } from "
|
|
5
|
-
import type { HostEvent, PluginHostAdapter } from "
|
|
3
|
+
import { object } from "../../../common/json.js";
|
|
4
|
+
import { requireThat } from "../../../common/validation.js";
|
|
5
|
+
import type { HostEvent, PluginHostAdapter } from "../../../model/plugin-host.js";
|
|
6
6
|
|
|
7
|
-
const supportedEvents = ["UserPromptSubmit", "PreToolUse", "UserPromptExpansion"];
|
|
7
|
+
const supportedEvents = ["UserPromptSubmit", "PreToolUse", "UserPromptExpansion", "Stop"];
|
|
8
8
|
|
|
9
9
|
export async function claudeWorkspaceRoot(cwd: string, projectDirectory = process.env.CLAUDE_PROJECT_DIR): Promise<string> {
|
|
10
10
|
const directory = projectDirectory || cwd;
|
|
@@ -36,11 +36,34 @@ export const claudeAdapter: PluginHostAdapter = {
|
|
|
36
36
|
requireThat(typeof value.cwd === "string", "Claude hook 缺少工作目录。");
|
|
37
37
|
return { kind: "check-skill", skill, cwd: value.cwd, raw: value };
|
|
38
38
|
}
|
|
39
|
-
// Leave Claude's native subagents untouched; only inject coordinator context
|
|
39
|
+
// Leave Claude's native subagents untouched; only inject coordinator context or record history in main sessions.
|
|
40
40
|
if (typeof value.agent_id === "string") return { kind: "ignore" };
|
|
41
41
|
requireThat(typeof value.cwd === "string", "Claude hook 缺少工作目录。");
|
|
42
|
+
if (event === "Stop") return { kind: "record-history", cwd: value.cwd, raw: value };
|
|
42
43
|
return { kind: "inject-context", role: "coordinator", cwd: value.cwd, raw: value };
|
|
43
44
|
},
|
|
45
|
+
async extractHistory(event) {
|
|
46
|
+
if (!object(event.raw)) return undefined;
|
|
47
|
+
const sessionId = typeof event.raw.session_id === "string" ? event.raw.session_id.trim() : "";
|
|
48
|
+
if (!sessionId) return undefined;
|
|
49
|
+
if (event.raw.hook_event_name === "UserPromptSubmit") {
|
|
50
|
+
const text = typeof event.raw.prompt === "string" ? event.raw.prompt.trim() : "";
|
|
51
|
+
if (!text) return undefined;
|
|
52
|
+
return { kind: "input", sessionId, text };
|
|
53
|
+
}
|
|
54
|
+
if (event.raw.hook_event_name === "Stop") {
|
|
55
|
+
const assistantText = typeof event.raw.last_assistant_message === "string" ? event.raw.last_assistant_message.trim() : "";
|
|
56
|
+
if (!assistantText) return undefined;
|
|
57
|
+
return {
|
|
58
|
+
kind: "answer",
|
|
59
|
+
sessionId,
|
|
60
|
+
assistantText,
|
|
61
|
+
completed: true,
|
|
62
|
+
...(event.raw.stop_hook_active === true ? { isContinuation: true } : {}),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
},
|
|
44
67
|
formatPass() {
|
|
45
68
|
return {};
|
|
46
69
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as McpClient from "@deepseek-ai/dsh-mcp-client";
|
|
2
|
-
import type { ResolvedWorkspaceMcpServer } from "
|
|
2
|
+
import type { ResolvedWorkspaceMcpServer } from "../../../model/workspace-mcp.js";
|
|
3
3
|
|
|
4
4
|
/** Translate a resolved workspace MCP entry into dsh's native `@deepseek-ai/dsh-mcp-client` config. */
|
|
5
5
|
export function toDshMcpConfig(server: ResolvedWorkspaceMcpServer): McpClient.Config {
|
|
@@ -5,11 +5,11 @@ import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
|
5
5
|
import type {} from "@deepseek-ai/dsh-skill";
|
|
6
6
|
import type {} from "@deepseek-ai/dsh-working-directory";
|
|
7
7
|
import type {} from "@deepseek-ai/dsh-tools";
|
|
8
|
-
import { agentText } from "
|
|
9
|
-
import { resourceRoot } from "
|
|
10
|
-
import { requireThat } from "
|
|
11
|
-
import { isMcpWorkerTool } from "
|
|
12
|
-
import type { AgentOptions } from "
|
|
8
|
+
import { agentText } from "../../agent-resources.js";
|
|
9
|
+
import { resourceRoot } from "../../../common/paths.js";
|
|
10
|
+
import { requireThat } from "../../../common/validation.js";
|
|
11
|
+
import { isMcpWorkerTool } from "../../../model/acp.js";
|
|
12
|
+
import type { AgentOptions } from "../../../model/agent.js";
|
|
13
13
|
|
|
14
14
|
export async function dshResources(
|
|
15
15
|
ctx: Context,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TSchema } from "typebox";
|
|
2
2
|
import type { JsonSchemaNode } from "@deepseek-ai/dsh-tools";
|
|
3
|
-
import { requireThat } from "
|
|
3
|
+
import { requireThat } from "../../../common/validation.js";
|
|
4
4
|
|
|
5
5
|
/** Remove TypeBox's non-JSON metadata before passing a schema to the native host. */
|
|
6
6
|
export function dshParameters(value: TSchema): Record<string, unknown> {
|
|
@@ -5,8 +5,8 @@ import { ReasoningEffortId } from "@deepseek-ai/dsh-llm";
|
|
|
5
5
|
import type { SessionHeader } from "@deepseek-ai/dsh-session";
|
|
6
6
|
import type {} from "@deepseek-ai/dsh-session-persistence";
|
|
7
7
|
import type {} from "@deepseek-ai/dsh-agent-preset-registry";
|
|
8
|
-
import type { AgentDescriptor } from "
|
|
9
|
-
import { requireThat } from "
|
|
8
|
+
import type { AgentDescriptor } from "../../../model/agent.js";
|
|
9
|
+
import { requireThat } from "../../../common/validation.js";
|
|
10
10
|
|
|
11
11
|
function validateHeader(d: AgentDescriptor, header: SessionHeader) {
|
|
12
12
|
requireThat(header.id === d.agentId && header.cwd === d.cwd && header.parentSession === d.parentSessionId &&
|
|
@@ -4,7 +4,7 @@ import type {} from "@deepseek-ai/dsh-fs";
|
|
|
4
4
|
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
5
5
|
import { scopeParentOf } from "@deepseek-ai/dsh-scope";
|
|
6
6
|
import { FileSystemSkillProvider } from "@deepseek-ai/dsh-skill-filesystem";
|
|
7
|
-
import { resourceRoot } from "
|
|
7
|
+
import { resourceRoot } from "../../../common/paths.js";
|
|
8
8
|
|
|
9
9
|
export interface DshSkillsOptions {
|
|
10
10
|
/** Also register `<workspaceRoot>/.agents/skills` (useful when agent cwd is nested inside the workspace). */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { McpServerConfig } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import type { ResolvedWorkspaceMcpServer } from "
|
|
2
|
+
import type { ResolvedWorkspaceMcpServer } from "../../../model/workspace-mcp.js";
|
|
3
3
|
|
|
4
4
|
/** Translate a resolved workspace MCP entry into Pi's native `registerMcpServer` config. */
|
|
5
5
|
export function toPiMcpConfig(server: ResolvedWorkspaceMcpServer): McpServerConfig {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { basename, dirname, join, matchesGlob, normalize, relative, resolve, sep } from "node:path";
|
|
2
2
|
import { getAgentDir, loadSkillsFromDir, parseArgs, SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
import { resourceRoot } from "
|
|
4
|
+
import { resourceRoot } from "../../../common/paths.js";
|
|
5
5
|
|
|
6
6
|
/** Dynamic resources follow the owning package's native include/exclude settings. */
|
|
7
7
|
export function workspaceSkillPaths(pi: ExtensionAPI, cwd: string): string[] {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { requireThat } from "../../common/validation.js";
|
|
2
2
|
import type { PluginHostAdapter, PluginHostId } from "../../model/plugin-host.js";
|
|
3
|
-
import { antigravityAdapter } from "./antigravity.js";
|
|
4
|
-
import { claudeAdapter } from "./claude.js";
|
|
3
|
+
import { antigravityAdapter } from "./antigravity/adapter.js";
|
|
4
|
+
import { claudeAdapter } from "./claude/adapter.js";
|
|
5
5
|
|
|
6
6
|
/** Extensible registry of hook-based plugin host adapters; runtime never branches on host IDs. */
|
|
7
7
|
export class PluginHostRegistry {
|
|
@@ -10,7 +10,7 @@ import { findExecutable, npmGlobalBinary, SetupProcesses } from "./processes.js"
|
|
|
10
10
|
export const piPackageName = "@earendil-works/pi-coding-agent";
|
|
11
11
|
export class PiBootstrapRequired extends Error {}
|
|
12
12
|
const bridge = fileURLToPath(new URL("./pi-bridge.js", import.meta.url));
|
|
13
|
-
const guard = fileURLToPath(new URL("../../extension/setup
|
|
13
|
+
const guard = fileURLToPath(new URL("../../extension/setup/guard.js", import.meta.url));
|
|
14
14
|
|
|
15
15
|
async function packageRoot(command: string, version: string, env: NodeJS.ProcessEnv): Promise<string> {
|
|
16
16
|
const resolved = await realpath(command);
|
package/src/mcp.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { realpathSync } from "node:fs";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
|
-
import { serveMcpStdio } from "./extension/mcp
|
|
3
|
+
import { serveMcpStdio } from "./extension/mcp/workers.js";
|
|
4
4
|
|
|
5
5
|
export function main(): Promise<void> {
|
|
6
6
|
return serveMcpStdio();
|