personal-bot 0.3.1 → 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 +73 -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 +73 -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 +91 -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
|
@@ -1,11 +1,29 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
1
2
|
import { mkdir, readFile } from "node:fs/promises";
|
|
2
3
|
import { dirname, join } from "node:path";
|
|
3
4
|
import { object } from "../../common/json.js";
|
|
4
5
|
import { isAcpBackend } from "../../common/validation.js";
|
|
5
6
|
import { readJsonFile, writeJsonFile } from "../../storage/atomic-json.js";
|
|
6
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
HistoryLayout,
|
|
9
|
+
ResolvedWorkspaceFeatures,
|
|
10
|
+
ResolvedWorkspaceHistoryConfig,
|
|
11
|
+
ResolvedWorkspaceSummaryConfig,
|
|
12
|
+
WorkspaceConfig,
|
|
13
|
+
WorkspaceConfiguration,
|
|
14
|
+
WorkspaceFeatures,
|
|
15
|
+
WorkspaceHistoryConfig,
|
|
16
|
+
WorkspaceSummaryConfig,
|
|
17
|
+
} from "../../model/workspace-config.js";
|
|
7
18
|
|
|
8
|
-
const featureKeys = ["prompts", "skills", "mcp"] as const;
|
|
19
|
+
const featureKeys = ["prompts", "skills", "mcp", "history"] as const;
|
|
20
|
+
const summaryKeys = ["backend", "model", "thinking", "concurrency"] as const;
|
|
21
|
+
const historyKeys = ["layout"] as const;
|
|
22
|
+
const historyLayouts = ["monthly", "flat"] as const;
|
|
23
|
+
|
|
24
|
+
function nonEmptyString(value: unknown): value is string {
|
|
25
|
+
return typeof value === "string" && value.trim().length > 0 && !value.includes("\0");
|
|
26
|
+
}
|
|
9
27
|
|
|
10
28
|
function config(value: unknown): Record<string, unknown> {
|
|
11
29
|
if (!object(value) || value.enabled !== undefined && typeof value.enabled !== "boolean") {
|
|
@@ -14,7 +32,7 @@ function config(value: unknown): Record<string, unknown> {
|
|
|
14
32
|
if (value.features !== undefined) {
|
|
15
33
|
if (!object(value.features) ||
|
|
16
34
|
Object.entries(value.features).some(([key, entry]) => !(featureKeys as readonly string[]).includes(key) || (entry !== undefined && typeof entry !== "boolean"))) {
|
|
17
|
-
throw new Error("features 必须是 JSON 对象,仅支持 prompts、skills、mcp 布尔开关。");
|
|
35
|
+
throw new Error("features 必须是 JSON 对象,仅支持 prompts、skills、mcp、history 布尔开关。");
|
|
18
36
|
}
|
|
19
37
|
}
|
|
20
38
|
if (value.acp !== undefined) {
|
|
@@ -35,6 +53,32 @@ function config(value: unknown): Record<string, unknown> {
|
|
|
35
53
|
}
|
|
36
54
|
}
|
|
37
55
|
}
|
|
56
|
+
if (value.summary !== undefined) {
|
|
57
|
+
if (!object(value.summary) || Object.keys(value.summary).some(key => !(summaryKeys as readonly string[]).includes(key))) {
|
|
58
|
+
throw new Error("summary 必须是 JSON 对象,仅支持 backend、model、thinking、concurrency。");
|
|
59
|
+
}
|
|
60
|
+
if (value.summary.backend !== undefined && !isAcpBackend(value.summary.backend)) {
|
|
61
|
+
throw new Error("summary.backend 必须为小写字母、数字和连字符(1–64 字符)。");
|
|
62
|
+
}
|
|
63
|
+
if (value.summary.model !== undefined && !nonEmptyString(value.summary.model)) {
|
|
64
|
+
throw new Error("summary.model 必须是非空字符串。");
|
|
65
|
+
}
|
|
66
|
+
if (value.summary.thinking !== undefined && !nonEmptyString(value.summary.thinking)) {
|
|
67
|
+
throw new Error("summary.thinking 必须是非空字符串。");
|
|
68
|
+
}
|
|
69
|
+
if (value.summary.concurrency !== undefined &&
|
|
70
|
+
(typeof value.summary.concurrency !== "number" || !Number.isInteger(value.summary.concurrency) || value.summary.concurrency < 1 || value.summary.concurrency > 8)) {
|
|
71
|
+
throw new Error("summary.concurrency 必须是 1 到 8 之间的整数。");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (value.history !== undefined) {
|
|
75
|
+
if (!object(value.history) || Object.keys(value.history).some(key => !(historyKeys as readonly string[]).includes(key))) {
|
|
76
|
+
throw new Error("history 必须是 JSON 对象,仅支持 layout。");
|
|
77
|
+
}
|
|
78
|
+
if (value.history.layout !== undefined && !(historyLayouts as readonly string[]).includes(String(value.history.layout))) {
|
|
79
|
+
throw new Error('history.layout 必须是 "monthly" 或 "flat"。');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
38
82
|
return value;
|
|
39
83
|
}
|
|
40
84
|
|
|
@@ -46,6 +90,32 @@ export function workspaceFeatures(configuration?: Pick<WorkspaceConfiguration, "
|
|
|
46
90
|
prompts: raw?.prompts !== false,
|
|
47
91
|
skills: raw?.skills !== false,
|
|
48
92
|
mcp: raw?.mcp !== false,
|
|
93
|
+
history: raw?.history !== false,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function workspaceSummaryConfig(
|
|
98
|
+
configuration?: Pick<WorkspaceConfiguration, "summary"> | WorkspaceSummaryConfig,
|
|
99
|
+
): ResolvedWorkspaceSummaryConfig {
|
|
100
|
+
const raw: WorkspaceSummaryConfig | undefined = configuration && "summary" in configuration
|
|
101
|
+
? configuration.summary
|
|
102
|
+
: configuration as WorkspaceSummaryConfig | undefined;
|
|
103
|
+
return {
|
|
104
|
+
backend: raw?.backend ?? "pi",
|
|
105
|
+
...(raw?.model ? { model: raw.model } : {}),
|
|
106
|
+
...(raw?.thinking ? { thinking: raw.thinking } : {}),
|
|
107
|
+
concurrency: raw?.concurrency ?? 3,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function workspaceHistoryConfig(
|
|
112
|
+
configuration?: Pick<WorkspaceConfiguration, "history"> | WorkspaceHistoryConfig,
|
|
113
|
+
): ResolvedWorkspaceHistoryConfig {
|
|
114
|
+
const raw: WorkspaceHistoryConfig | undefined = configuration && "history" in configuration
|
|
115
|
+
? configuration.history
|
|
116
|
+
: configuration as WorkspaceHistoryConfig | undefined;
|
|
117
|
+
return {
|
|
118
|
+
layout: raw?.layout === "flat" ? "flat" : "monthly",
|
|
49
119
|
};
|
|
50
120
|
}
|
|
51
121
|
|
|
@@ -53,6 +123,18 @@ export function workspaceConfigPath(root: string): string {
|
|
|
53
123
|
return join(root, ".pbot", "config.json");
|
|
54
124
|
}
|
|
55
125
|
|
|
126
|
+
/** Synchronous read of history.layout for storage and query callers; defaults to "monthly". */
|
|
127
|
+
export function readWorkspaceHistoryLayoutSync(root: string): HistoryLayout {
|
|
128
|
+
const path = workspaceConfigPath(root);
|
|
129
|
+
try {
|
|
130
|
+
const content = readFileSync(path, "utf8");
|
|
131
|
+
const parsed = config(JSON.parse(content)) as WorkspaceConfig;
|
|
132
|
+
return workspaceHistoryConfig(parsed.history).layout;
|
|
133
|
+
} catch {
|
|
134
|
+
return "monthly";
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
56
138
|
/** Read only this workspace's configuration; parent directories never grant activation. */
|
|
57
139
|
export async function readWorkspaceConfig(root: string): Promise<WorkspaceConfiguration> {
|
|
58
140
|
const path = workspaceConfigPath(root);
|
|
@@ -71,6 +153,8 @@ export async function readWorkspaceConfig(root: string): Promise<WorkspaceConfig
|
|
|
71
153
|
enabled: settings.enabled === true,
|
|
72
154
|
...(settings.features ? { features: settings.features } : {}),
|
|
73
155
|
...(settings.acp ? { acp: settings.acp } : {}),
|
|
156
|
+
...(settings.summary ? { summary: settings.summary } : {}),
|
|
157
|
+
...(settings.history ? { history: settings.history } : {}),
|
|
74
158
|
};
|
|
75
159
|
} catch (error) {
|
|
76
160
|
return { path, present: true, enabled: false, error: `工作区配置无效 ${path}: ${String(error)}` };
|
|
@@ -82,12 +166,14 @@ export async function initializeWorkspaceConfig(root: string): Promise<void> {
|
|
|
82
166
|
const current = await readWorkspaceConfig(root);
|
|
83
167
|
if (current.error) throw new Error(current.error);
|
|
84
168
|
const hasExplicitFeatures = featureKeys.every(key => typeof current.features?.[key] === "boolean");
|
|
85
|
-
|
|
169
|
+
const hasExplicitSummary = typeof current.summary?.backend === "string" && typeof current.summary?.concurrency === "number";
|
|
170
|
+
if (current.enabled && hasExplicitFeatures && hasExplicitSummary) return;
|
|
86
171
|
const directory = dirname(current.path);
|
|
87
172
|
await mkdir(directory, { recursive: true });
|
|
88
173
|
const value = current.present ? readJsonFile(directory, "config.json", config) : {};
|
|
89
174
|
const features = workspaceFeatures((value as WorkspaceConfig).features);
|
|
90
|
-
const
|
|
175
|
+
const summary = workspaceSummaryConfig((value as WorkspaceConfig).summary);
|
|
176
|
+
const written = writeJsonFile(directory, "config.json", { ...value, enabled: true, features, summary }, config, !current.present);
|
|
91
177
|
if (!written) await initializeWorkspaceConfig(root);
|
|
92
178
|
}
|
|
93
179
|
|